Lines Matching +full:16 +full:- +full:shadowmaps
1 //===---------------- SemaCodeComplete.cpp - Code Completion ----*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
10 // This file defines the code-completion semantic actions.
12 //===----------------------------------------------------------------------===//
41 /// \brief A container of code-completion results.
44 /// \brief The type of a name-lookup filter, which can be provided to the
45 /// name-lookup routines to specify which declarations should be included in
59 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
82 // 0 - > 1 elements: just set the single element information. in Add()
90 // 1 -> 2 elements: create the vector of results and push in the in Add()
93 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex)); in Add()
98 DeclOrVector.get<DeclIndexPairVector*>()->push_back( in Add()
125 /// \brief The allocator used to allocate new code-completion strings.
130 /// \brief If non-NULL, a filter function used to remove any code-completion
135 /// nested-name-specifiers that would otherwise be filtered out.
147 std::list<ShadowMap> ShadowMaps; member in __anonc63445210111::ResultBuilder
181 // If this is an Objective-C instance method definition, dig out the in ResultBuilder()
190 if (Method->isInstanceMethod()) in ResultBuilder()
191 if (ObjCInterfaceDecl *Interface = Method->getClassInterface()) in ResultBuilder()
192 ObjCImplementation = Interface->getImplementation(); in ResultBuilder()
207 SemaRef.CodeCompleter->includeCodePatterns(); in includeCodePatterns()
210 /// \brief Set the filter used for code-completion results.
212 this->Filter = Filter; in setFilter()
224 /// \brief Set the cv-qualifiers on the object type, for us in filtering
229 /// cv-qualifier mismatch) or prefer functions with an exact qualifier
238 /// When an Objective-C method declaration result is added, and that
245 /// \brief Retrieve the code-completion context for which results are
251 /// \brief Specify whether nested-name-specifiers are allowed.
266 /// as a code-completion result.
271 /// only interesting when it is a nested-name-specifier.
307 /// \brief Add a new non-declaration result to this result set.
317 void Ignore(const Decl *D) { AllDeclsFound.insert(D->getCanonicalDecl()); } in Ignore()
362 const DeclIndexPair *operator->() const { in operator ->()
401 pointer operator->() const { in operator ->()
424 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin()); in begin()
432 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end()); in end()
455 CommonAncestor && !CommonAncestor->Encloses(CurContext); in getRequiredQualification()
456 CommonAncestor = CommonAncestor->getLookupParent()) { in getRequiredQualification()
457 if (CommonAncestor->isTransparentContext() || in getRequiredQualification()
458 CommonAncestor->isFunctionOrMethod()) in getRequiredQualification()
469 if (!Namespace->getIdentifier()) in getRequiredQualification()
486 if (Id->getLength() < 2) in isReservedName()
488 const char *Name = Id->getNameStart(); in isReservedName()
498 const IdentifierInfo *Id = ND->getIdentifier(); in shouldIgnoreDueToReservedName()
503 if (isReservedName(Id) && ND->getLocation().isInvalid()) in shouldIgnoreDueToReservedName()
506 // For system headers ignore only double-underscore names. in shouldIgnoreDueToReservedName()
511 SemaRef.SourceMgr.getSpellingLoc(ND->getLocation()))) in shouldIgnoreDueToReservedName()
522 ND = ND->getUnderlyingDecl(); in isInterestingDecl()
525 if (!ND->getDeclName()) in isInterestingDecl()
530 if (ND->getFriendObjectKind() == Decl::FOK_Undeclared) in isInterestingDecl()
553 if (Filter && !(this->*Filter)(Named)) { in isInterestingDecl()
554 // Check whether it is interesting as a nested-name-specifier. in isInterestingDecl()
559 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) { in isInterestingDecl()
579 R.Declaration->getDeclContext()->getRedeclContext(); in CheckHiddenResult()
582 if (HiddenCtx->isFunctionOrMethod()) in CheckHiddenResult()
585 if (HiddenCtx == Hiding->getDeclContext()->getRedeclContext()) in CheckHiddenResult()
595 R.Declaration->getDeclContext()); in CheckHiddenResult()
602 switch (T->getTypeClass()) { in getSimplifiedTypeClass()
604 switch (cast<BuiltinType>(T)->getKind()) { in getSimplifiedTypeClass()
635 return getSimplifiedTypeClass(T->getAs<ReferenceType>()->getPointeeType()); in getSimplifiedTypeClass()
669 /// is used as an expression in its "typical" code-completion form.
671 ND = cast<NamedDecl>(ND->getUnderlyingDecl()); in getDeclUsageType()
679 if (const FunctionDecl *Function = ND->getAsFunction()) in getDeclUsageType()
680 T = Function->getCallResultType(); in getDeclUsageType()
682 T = Method->getSendResultType(); in getDeclUsageType()
684 T = C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext())); in getDeclUsageType()
686 T = Property->getType(); in getDeclUsageType()
688 T = Value->getType(); in getDeclUsageType()
696 if (const ReferenceType *Ref = T->getAs<ReferenceType>()) { in getDeclUsageType()
697 T = Ref->getPointeeType(); in getDeclUsageType()
701 if (const PointerType *Pointer = T->getAs<PointerType>()) { in getDeclUsageType()
702 if (Pointer->getPointeeType()->isFunctionType()) { in getDeclUsageType()
703 T = Pointer->getPointeeType(); in getDeclUsageType()
710 if (const BlockPointerType *Block = T->getAs<BlockPointerType>()) { in getDeclUsageType()
711 T = Block->getPointeeType(); in getDeclUsageType()
715 if (const FunctionType *Function = T->getAs<FunctionType>()) { in getDeclUsageType()
716 T = Function->getReturnType(); in getDeclUsageType()
730 // Context-based decisions. in getBasePriority()
731 const DeclContext *LexicalDC = ND->getLexicalDeclContext(); in getBasePriority()
732 if (LexicalDC->isFunctionOrMethod()) { in getBasePriority()
736 if (ImplicitParam->getIdentifier() && in getBasePriority()
737 ImplicitParam->getIdentifier()->isStr("_cmd")) in getBasePriority()
743 const DeclContext *DC = ND->getDeclContext()->getRedeclContext(); in getBasePriority()
744 if (DC->isRecord() || isa<ObjCContainerDecl>(DC)) in getBasePriority()
747 // Content-based decisions. in getBasePriority()
751 // Use CCP_Type for type declarations unless we're in a statement, Objective-C in getBasePriority()
766 // If this is an Objective-C method declaration whose selector matches our in AdjustResultPriorityForDecl()
770 if (PreferredSelector == Method->getSelector()) in AdjustResultPriorityForDecl()
773 // If we have a preferred type, adjust the priority for results with exactly- in AdjustResultPriorityForDecl()
774 // matching or nearly-matching types. in AdjustResultPriorityForDecl()
779 // Check for exactly-matching types (modulo qualifiers). in AdjustResultPriorityForDecl()
782 // Check for nearly-matching types, based on classification of each. in AdjustResultPriorityForDecl()
785 !(PreferredType->isEnumeralType() && TC->isEnumeralType())) in AdjustResultPriorityForDecl()
800 Record = ClassTemplate->getTemplatedDecl(); in MaybeAddConstructorResults()
810 Record = Record->getDefinition(); in MaybeAddConstructorResults()
819 DeclContext::lookup_result Ctors = Record->lookup(ConstructorName); in MaybeAddConstructorResults()
830 assert(!ShadowMaps.empty() && "Must enter into a results scope"); in MaybeAddResult()
833 // For non-declaration results, just add the result. in MaybeAddResult()
841 MaybeAddResult(Result(Using->getTargetDecl(), in MaybeAddResult()
842 getBasePriority(Using->getTargetDecl()), in MaybeAddResult()
848 const Decl *CanonDecl = R.Declaration->getCanonicalDecl(); in MaybeAddResult()
849 unsigned IDNS = CanonDecl->getIdentifierNamespace(); in MaybeAddResult()
859 ShadowMap &SMap = ShadowMaps.back(); in MaybeAddResult()
861 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName()); in MaybeAddResult()
863 I = NamePos->second.begin(); in MaybeAddResult()
864 IEnd = NamePos->second.end(); in MaybeAddResult()
868 const NamedDecl *ND = I->first; in MaybeAddResult()
869 unsigned Index = I->second; in MaybeAddResult()
870 if (ND->getCanonicalDecl() == CanonDecl) { in MaybeAddResult()
880 // declaration name is hidden by a similarly-named declaration in an outer in MaybeAddResult()
882 std::list<ShadowMap>::iterator SM, SMEnd = ShadowMaps.end(); in MaybeAddResult()
883 --SMEnd; in MaybeAddResult()
884 for (SM = ShadowMaps.begin(); SM != SMEnd; ++SM) { in MaybeAddResult()
886 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName()); in MaybeAddResult()
887 if (NamePos != SM->end()) { in MaybeAddResult()
888 I = NamePos->second.begin(); in MaybeAddResult()
889 IEnd = NamePos->second.end(); in MaybeAddResult()
892 // A tag declaration does not hide a non-tag declaration. in MaybeAddResult()
893 if (I->first->hasTagIdentifierNamespace() && in MaybeAddResult()
899 if (((I->first->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol) in MaybeAddResult()
901 I->first->getIdentifierNamespace() != IDNS) in MaybeAddResult()
904 // The newly-added result is hidden by an entry in the shadow map. in MaybeAddResult()
905 if (CheckHiddenResult(R, CurContext, I->first)) in MaybeAddResult()
916 // If the filter is for nested-name-specifiers, then this result starts a in MaybeAddResult()
917 // nested-name-specifier. in MaybeAddResult()
927 const DeclContext *Ctx = R.Declaration->getDeclContext(); in MaybeAddResult()
940 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size()); in MaybeAddResult()
950 // For non-declaration results, just add the result. in AddResult()
957 AddResult(Result(Using->getTargetDecl(), in AddResult()
958 getBasePriority(Using->getTargetDecl()), in AddResult()
976 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second) in AddResult()
979 // If the filter is for nested-name-specifiers, then this result starts a in AddResult()
980 // nested-name-specifier. in AddResult()
986 isa<CXXRecordDecl>(R.Declaration->getDeclContext() in AddResult()
987 ->getRedeclContext())) in AddResult()
993 const DeclContext *Ctx = R.Declaration->getDeclContext(); in AddResult()
1012 if (Method->isInstance()) { in AddResult()
1014 = Qualifiers::fromCVRMask(Method->getTypeQualifiers()); in AddResult()
1017 else if (ObjectTypeQualifiers - MethodQuals) { in AddResult()
1038 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); } in EnterNewScope()
1042 for (ShadowMap::iterator E = ShadowMaps.back().begin(), in ExitScope()
1043 EEnd = ShadowMaps.back().end(); in ExitScope()
1046 E->second.Destroy(); in ExitScope()
1048 ShadowMaps.pop_back(); in ExitScope()
1054 ND = cast<NamedDecl>(ND->getUnderlyingDecl()); in IsOrdinaryName()
1066 return ND->getIdentifierNamespace() & IDNS; in IsOrdinaryName()
1072 ND = cast<NamedDecl>(ND->getUnderlyingDecl()); in IsOrdinaryNonTypeName()
1084 return ND->getIdentifierNamespace() & IDNS; in IsOrdinaryNonTypeName()
1091 if (const ValueDecl *VD = dyn_cast<ValueDecl>(ND->getUnderlyingDecl())) in IsIntegralConstantValue()
1092 if (VD->getType()->isIntegralOrEnumerationType()) in IsIntegralConstantValue()
1101 ND = cast<NamedDecl>(ND->getUnderlyingDecl()); in IsOrdinaryNonValueName()
1107 return (ND->getIdentifierNamespace() & IDNS) && in IsOrdinaryNonValueName()
1113 /// start of a C++ nested-name-specifier, e.g., a class or namespace.
1117 ND = ClassTemplate->getTemplatedDecl(); in IsNestedNameSpecifier()
1131 ND = ClassTemplate->getTemplatedDecl(); in IsClassOrStruct()
1135 return RD->getTagKind() == TTK_Class || in IsClassOrStruct()
1136 RD->getTagKind() == TTK_Struct || in IsClassOrStruct()
1137 RD->getTagKind() == TTK_Interface; in IsClassOrStruct()
1146 ND = ClassTemplate->getTemplatedDecl(); in IsUnion()
1149 return RD->getTagKind() == TTK_Union; in IsUnion()
1162 return isa<NamespaceDecl>(ND->getUnderlyingDecl()); in IsNamespaceOrAlias()
1167 ND = ND->getUnderlyingDecl(); in IsType()
1172 /// "." or "->". Only value declarations, nested name specifiers, and
1175 ND = ND->getUnderlyingDecl(); in IsMember()
1182 switch (T->getTypeClass()) { in isObjCReceiverType()
1189 switch (cast<BuiltinType>(T)->getKind()) { in isObjCReceiverType()
1208 // particular class type has any conversions to Objective-C types. For now, in isObjCReceiverType()
1210 return T->isDependentType() || T->isRecordType(); in isObjCReceiverType()
1230 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>(); in IsObjCMessageReceiverOrLambdaCapture()
1243 return T->isObjCObjectType() || T->isObjCObjectPointerType() || in IsObjCCollection()
1244 T->isObjCIdType() || in IsObjCCollection()
1245 (SemaRef.getLangOpts().CPlusPlus && T->isRecordType()); in IsObjCCollection()
1252 /// \brief Determines whether the given declaration is an Objective-C
1259 /// \brief Visible declaration consumer that adds a code-completion result
1302 // C99-specific in AddTypeSpecifierResults()
1312 // C++-specific in AddTypeSpecifierResults()
1318 // typename qualified-id in AddTypeSpecifierResults()
1489 // Built-in type names are constant strings. in GetCompletionTypeString()
1491 return BT->getNameAsCString(Policy); in GetCompletionTypeString()
1495 if (TagDecl *Tag = TagT->getDecl()) in GetCompletionTypeString()
1496 if (!Tag->hasNameForLinkage()) { in GetCompletionTypeString()
1497 switch (Tag->getTagKind()) { in GetCompletionTypeString()
1570 // asm(string-literal) in AddOrdinaryNameResults()
1573 Builder.AddPlaceholderChunk("string-literal"); in AddOrdinaryNameResults()
1603 if (SemaRef.CurContext->isDependentContext()) { in AddOrdinaryNameResults()
1722 // Switch-specific statements. in AddOrdinaryNameResults()
1723 if (!SemaRef.getCurFunction()->SwitchStack.empty()) { in AddOrdinaryNameResults()
1764 // for ( for-init-statement ; condition ; expression ) { statements } in AddOrdinaryNameResults()
1768 Builder.AddPlaceholderChunk("init-statement"); in AddOrdinaryNameResults()
1770 Builder.AddPlaceholderChunk("init-expression"); in AddOrdinaryNameResults()
1774 Builder.AddPlaceholderChunk("inc-expression"); in AddOrdinaryNameResults()
1784 if (S->getContinueParent()) { in AddOrdinaryNameResults()
1790 if (S->getBreakParent()) { in AddOrdinaryNameResults()
1800 isVoid = Function->getReturnType()->isVoidType(); in AddOrdinaryNameResults()
1803 isVoid = Method->getReturnType()->isVoidType(); in AddOrdinaryNameResults()
1805 !SemaRef.getCurBlock()->ReturnType.isNull()) in AddOrdinaryNameResults()
1806 isVoid = SemaRef.getCurBlock()->ReturnType->isVoidType(); in AddOrdinaryNameResults()
1846 // (__bridge_transfer <Objective-C type>)<expression> in AddOrdinaryNameResults()
1849 Builder.AddPlaceholderChunk("Objective-C type"); in AddOrdinaryNameResults()
1866 // 'this', if we're in a non-static member function. in AddOrdinaryNameResults()
1880 // dynamic_cast < type-id > ( expression ) in AddOrdinaryNameResults()
1891 // static_cast < type-id > ( expression ) in AddOrdinaryNameResults()
1901 // reinterpret_cast < type-id > ( expression ) in AddOrdinaryNameResults()
1911 // const_cast < type-id > ( expression ) in AddOrdinaryNameResults()
1922 // typeid ( expression-or-type ) in AddOrdinaryNameResults()
1926 Builder.AddPlaceholderChunk("expression-or-type"); in AddOrdinaryNameResults()
2006 Builder.AddPlaceholderChunk("parameter-pack"); in AddOrdinaryNameResults()
2013 // Add "super", if we're in an Objective-C class with a superclass. in AddOrdinaryNameResults()
2016 if (ObjCInterfaceDecl *ID = Method->getClassInterface()) in AddOrdinaryNameResults()
2017 if (ID->getSuperClass()) { in AddOrdinaryNameResults()
2019 SuperType = ID->getSuperClass()->getNameAsString(); in AddOrdinaryNameResults()
2020 if (Method->isInstanceMethod()) in AddOrdinaryNameResults()
2049 Builder.AddPlaceholderChunk("expression-or-type"); in AddOrdinaryNameResults()
2084 if (const FunctionDecl *Function = ND->getAsFunction()) in AddResultTypeChunk()
2085 T = Function->getReturnType(); in AddResultTypeChunk()
2088 T = Method->getSendResultType(BaseType); in AddResultTypeChunk()
2090 T = Method->getReturnType(); in AddResultTypeChunk()
2092 T = Context.getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext())); in AddResultTypeChunk()
2097 T = Ivar->getUsageType(BaseType); in AddResultTypeChunk()
2099 T = Ivar->getType(); in AddResultTypeChunk()
2101 T = Value->getType(); in AddResultTypeChunk()
2104 T = Property->getUsageType(BaseType); in AddResultTypeChunk()
2106 T = Property->getType(); in AddResultTypeChunk()
2119 if (SentinelAttr *Sentinel = FunctionOrMethod->getAttr<SentinelAttr>()) in MaybeAddSentinel()
2120 if (Sentinel->getSentinel() == 0) { in MaybeAddSentinel()
2170 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext()); in FormatFunctionParameter()
2171 if (Param->getType()->isDependentType() || in FormatFunctionParameter()
2172 !Param->getType()->isBlockPointerType()) { in FormatFunctionParameter()
2173 // The argument for a dependent or non-block parameter is a placeholder in FormatFunctionParameter()
2177 if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName) in FormatFunctionParameter()
2178 Result = Param->getIdentifier()->getName(); in FormatFunctionParameter()
2180 QualType Type = Param->getType(); in FormatFunctionParameter()
2182 Type = Type.substObjCTypeArgs(Param->getASTContext(), *ObjCSubsts, in FormatFunctionParameter()
2185 Result = "(" + formatObjCParamQualifiers(Param->getObjCDeclQualifier(), in FormatFunctionParameter()
2188 if (Param->getIdentifier() && !SuppressName) in FormatFunctionParameter()
2189 Result += Param->getIdentifier()->getName(); in FormatFunctionParameter()
2201 if (TypeSourceInfo *TSInfo = Param->getTypeSourceInfo()) { in FormatFunctionParameter()
2202 TL = TSInfo->getTypeLoc().getUnqualifiedLoc(); in FormatFunctionParameter()
2208 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) { in FormatFunctionParameter()
2209 TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc(); in FormatFunctionParameter()
2241 if (!ObjCMethodParam && Param->getIdentifier()) in FormatFunctionParameter()
2242 Result = Param->getIdentifier()->getName(); in FormatFunctionParameter()
2244 QualType Type = Param->getType().getUnqualifiedType(); in FormatFunctionParameter()
2247 Result = "(" + formatObjCParamQualifiers(Param->getObjCDeclQualifier(), in FormatFunctionParameter()
2250 if (Param->getIdentifier()) in FormatFunctionParameter()
2251 Result += Param->getIdentifier()->getName(); in FormatFunctionParameter()
2262 QualType ResultType = Block.getTypePtr()->getReturnType(); in FormatFunctionParameter()
2264 ResultType = ResultType.substObjCTypeArgs(Param->getASTContext(), in FormatFunctionParameter()
2267 if (!ResultType->isVoidType() || SuppressBlock) in FormatFunctionParameter()
2273 if (BlockProto && BlockProto.getTypePtr()->isVariadic()) in FormatFunctionParameter()
2287 if (I == N - 1 && BlockProto.getTypePtr()->isVariadic()) in FormatFunctionParameter()
2296 if (Param->getIdentifier()) in FormatFunctionParameter()
2297 Result += Param->getIdentifier()->getName(); in FormatFunctionParameter()
2305 if (Param->getIdentifier()) in FormatFunctionParameter()
2306 Result += Param->getIdentifier()->getName(); in FormatFunctionParameter()
2321 for (unsigned P = Start, N = Function->getNumParams(); P != N; ++P) { in AddFunctionParameterChunks()
2322 const ParmVarDecl *Param = Function->getParamDecl(P); in AddFunctionParameterChunks()
2324 if (Param->hasDefaultArg() && !InOptional) { in AddFunctionParameterChunks()
2346 if (Function->isVariadic() && P == N - 1) in AddFunctionParameterChunks()
2355 = Function->getType()->getAs<FunctionProtoType>()) in AddFunctionParameterChunks()
2356 if (Proto->isVariadic()) { in AddFunctionParameterChunks()
2357 if (Proto->getNumParams() == 0) in AddFunctionParameterChunks()
2376 Template = cast<TemplateDecl>(Template->getCanonicalDecl()); in AddTemplateParameterChunks()
2378 TemplateParameterList *Params = Template->getTemplateParameters(); in AddTemplateParameterChunks()
2379 TemplateParameterList::iterator PEnd = Params->end(); in AddTemplateParameterChunks()
2381 PEnd = Params->begin() + MaxParameters; in AddTemplateParameterChunks()
2382 for (TemplateParameterList::iterator P = Params->begin() + Start; in AddTemplateParameterChunks()
2387 if (TTP->wasDeclaredWithTypename()) in AddTemplateParameterChunks()
2392 if (TTP->getIdentifier()) { in AddTemplateParameterChunks()
2394 PlaceholderStr += TTP->getIdentifier()->getName(); in AddTemplateParameterChunks()
2397 HasDefaultArg = TTP->hasDefaultArgument(); in AddTemplateParameterChunks()
2400 if (NTTP->getIdentifier()) in AddTemplateParameterChunks()
2401 PlaceholderStr = NTTP->getIdentifier()->getName(); in AddTemplateParameterChunks()
2402 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy); in AddTemplateParameterChunks()
2403 HasDefaultArg = NTTP->hasDefaultArgument(); in AddTemplateParameterChunks()
2411 if (TTP->getIdentifier()) { in AddTemplateParameterChunks()
2413 PlaceholderStr += TTP->getIdentifier()->getName(); in AddTemplateParameterChunks()
2416 HasDefaultArg = TTP->hasDefaultArgument(); in AddTemplateParameterChunks()
2427 P - Params->begin(), true); in AddTemplateParameterChunks()
2445 /// \brief Add a qualifier to the given code-completion string, if the
2446 /// provided nested-name-specifier is non-NULL.
2459 Qualifier->print(OS, Policy); in AddQualifierToCompletionString()
2471 = Function->getType()->getAs<FunctionProtoType>(); in AddFunctionTypeQualsToCompletionString()
2472 if (!Proto || !Proto->getTypeQuals()) in AddFunctionTypeQualsToCompletionString()
2475 // FIXME: Add ref-qualifier! in AddFunctionTypeQualsToCompletionString()
2478 if (Proto->getTypeQuals() == Qualifiers::Const) { in AddFunctionTypeQualsToCompletionString()
2483 if (Proto->getTypeQuals() == Qualifiers::Volatile) { in AddFunctionTypeQualsToCompletionString()
2488 if (Proto->getTypeQuals() == Qualifiers::Restrict) { in AddFunctionTypeQualsToCompletionString()
2495 if (Proto->isConst()) in AddFunctionTypeQualsToCompletionString()
2497 if (Proto->isVolatile()) in AddFunctionTypeQualsToCompletionString()
2499 if (Proto->isRestrict()) in AddFunctionTypeQualsToCompletionString()
2508 DeclarationName Name = ND->getDeclName(); in AddTypedNameChunk()
2543 Result.getAllocator().CopyString(ND->getNameAsString())); in AddTypedNameChunk()
2555 if (const RecordType *RecordTy = Ty->getAs<RecordType>()) in AddTypedNameChunk()
2556 Record = cast<CXXRecordDecl>(RecordTy->getDecl()); in AddTypedNameChunk()
2558 = Ty->getAs<InjectedClassNameType>()) in AddTypedNameChunk()
2559 Record = InjectedTy->getDecl(); in AddTypedNameChunk()
2562 Result.getAllocator().CopyString(ND->getNameAsString())); in AddTypedNameChunk()
2567 Result.getAllocator().CopyString(Record->getNameAsString())); in AddTypedNameChunk()
2568 if (ClassTemplateDecl *Template = Record->getDescribedClassTemplate()) { in AddTypedNameChunk()
2590 /// \returns Either a new, heap-allocated code completion string describing
2604 Pattern->Priority = Priority; in CreateCodeCompletionString()
2605 Pattern->Availability = Availability; in CreateCodeCompletionString()
2608 Result.addParentContext(Declaration->getDeclContext()); in CreateCodeCompletionString()
2609 Pattern->ParentName = Result.getParentName(); in CreateCodeCompletionString()
2616 if (M->isPropertyAccessor()) in CreateCodeCompletionString()
2617 if (const ObjCPropertyDecl *PDecl = M->findPropertyDecl()) in CreateCodeCompletionString()
2618 if (PDecl->getGetterName() == M->getSelector() && in CreateCodeCompletionString()
2619 PDecl->getIdentifier() != M->getIdentifier()) { in CreateCodeCompletionString()
2622 Result.addBriefComment(RC->getBriefText(Ctx)); in CreateCodeCompletionString()
2623 Pattern->BriefComment = Result.getBriefComment(); in CreateCodeCompletionString()
2627 Result.addBriefComment(RC->getBriefText(Ctx)); in CreateCodeCompletionString()
2628 Pattern->BriefComment = Result.getBriefComment(); in CreateCodeCompletionString()
2644 Result.getAllocator().CopyString(Macro->getName())); in CreateCodeCompletionString()
2646 if (!MI || !MI->isFunctionLike()) in CreateCodeCompletionString()
2649 // Format a function-like macro with placeholders for the arguments. in CreateCodeCompletionString()
2651 MacroInfo::arg_iterator A = MI->arg_begin(), AEnd = MI->arg_end(); in CreateCodeCompletionString()
2654 if (MI->isC99Varargs()) { in CreateCodeCompletionString()
2655 --AEnd; in CreateCodeCompletionString()
2662 for (MacroInfo::arg_iterator A = MI->arg_begin(); A != AEnd; ++A) { in CreateCodeCompletionString()
2663 if (A != MI->arg_begin()) in CreateCodeCompletionString()
2666 if (MI->isVariadic() && (A+1) == AEnd) { in CreateCodeCompletionString()
2667 SmallString<32> Arg = (*A)->getName(); in CreateCodeCompletionString()
2668 if (MI->isC99Varargs()) in CreateCodeCompletionString()
2676 // Non-variadic macros are simple. in CreateCodeCompletionString()
2678 Result.getAllocator().CopyString((*A)->getName())); in CreateCodeCompletionString()
2686 Result.addParentContext(ND->getDeclContext()); in CreateCodeCompletionString()
2691 Result.addBriefComment(RC->getBriefText(Ctx)); in CreateCodeCompletionString()
2694 if (OMD->isPropertyAccessor()) in CreateCodeCompletionString()
2695 if (const ObjCPropertyDecl *PDecl = OMD->findPropertyDecl()) in CreateCodeCompletionString()
2697 Result.addBriefComment(RC->getBriefText(Ctx)); in CreateCodeCompletionString()
2702 Result.getAllocator().CopyString(ND->getNameAsString())); in CreateCodeCompletionString()
2707 for (const auto *I : ND->specific_attrs<AnnotateAttr>()) in CreateCodeCompletionString()
2708 Result.AddAnnotation(Result.getAllocator().CopyString(I->getAnnotation())); in CreateCodeCompletionString()
2726 FunctionDecl *Function = FunTmpl->getTemplatedDecl(); in CreateCodeCompletionString()
2735 --LastDeducibleArgument) { in CreateCodeCompletionString()
2736 if (!Deduced[LastDeducibleArgument - 1]) { in CreateCodeCompletionString()
2741 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam( in CreateCodeCompletionString()
2742 LastDeducibleArgument - 1); in CreateCodeCompletionString()
2744 HasDefaultArg = TTP->hasDefaultArgument(); in CreateCodeCompletionString()
2747 HasDefaultArg = NTTP->hasDefaultArgument(); in CreateCodeCompletionString()
2751 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument(); in CreateCodeCompletionString()
2781 Result.getAllocator().CopyString(Template->getNameAsString())); in CreateCodeCompletionString()
2789 Selector Sel = Method->getSelector(); in CreateCodeCompletionString()
2804 // typed-text chunk since there is nothing to type. in CreateCodeCompletionString()
2805 if (Method->param_size() == 1) in CreateCodeCompletionString()
2809 for (ObjCMethodDecl::param_const_iterator P = Method->param_begin(), in CreateCodeCompletionString()
2810 PEnd = Method->param_end(); in CreateCodeCompletionString()
2817 Keyword += II->getName(); in CreateCodeCompletionString()
2830 QualType ParamType = (*P)->getType(); in CreateCodeCompletionString()
2833 ObjCSubsts = CCContext.getBaseType()->getObjCSubstitutions(Method); in CreateCodeCompletionString()
2835 if (ParamType->isBlockPointerType() && !DeclaringEntity) in CreateCodeCompletionString()
2843 Arg = "(" + formatObjCParamQualifiers((*P)->getObjCDeclQualifier(), in CreateCodeCompletionString()
2846 if (IdentifierInfo *II = (*P)->getIdentifier()) in CreateCodeCompletionString()
2848 Arg += II->getName(); in CreateCodeCompletionString()
2851 if (Method->isVariadic() && (P + 1) == PEnd) in CreateCodeCompletionString()
2862 if (Method->isVariadic()) { in CreateCodeCompletionString()
2863 if (Method->param_size() == 0) { in CreateCodeCompletionString()
2883 Result.getAllocator().CopyString(ND->getNameAsString())); in CreateCodeCompletionString()
2898 unsigned NumParams = Function ? Function->getNumParams() in AddOverloadParameterChunks()
2899 : Prototype->getNumParams(); in AddOverloadParameterChunks()
2902 if (Function && Function->getParamDecl(P)->hasDefaultArg() && !InOptional) { in AddOverloadParameterChunks()
2926 Placeholder = FormatFunctionParameter(Policy, Function->getParamDecl(P)); in AddOverloadParameterChunks()
2928 Placeholder = Prototype->getParamType(P).getAsString(Policy); in AddOverloadParameterChunks()
2937 if (Prototype && Prototype->isVariadic()) { in AddOverloadParameterChunks()
2970 FT->getReturnType().getAsString(Policy))); in CreateSignatureString()
2978 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams()) in CreateSignatureString()
2980 FDecl->getParamDecl(CurrentArg))) in CreateSignatureString()
2981 Result.addBriefComment(RC->getBriefText(S.getASTContext())); in CreateSignatureString()
2984 Result.getAllocator().CopyString(FDecl->getNameAsString())); in CreateSignatureString()
2988 Proto->getReturnType().getAsString(Policy))); in CreateSignatureString()
3027 switch (D->getKind()) { in getCursorKindForDecl()
3040 return cast<ObjCMethodDecl>(D)->isInstanceMethod() in getCursorKindForDecl()
3073 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) { in getCursorKindForDecl()
3088 switch (TD->getTagKind()) { in getCursorKindForDecl()
3111 auto MD = PP.getMacroDefinition(M->first); in AddMacroResults()
3114 if (MI->isUsedForHeaderGuard()) in AddMacroResults()
3117 Results.AddResult(Result(M->first, in AddMacroResults()
3118 getMacroUsagePriority(M->first->getName(), in AddMacroResults()
3147 CodeCompleter->ProcessCodeCompleteResults(*S, Context, Results, NumResults); in HandleCodeCompleteResults()
3170 if (S.CurContext->isFileContext()) in mapCodeCompletionContext()
3172 if (S.CurContext->isRecord()) in mapCodeCompletionContext()
3212 /// \param InContext This context in which the nested-name-specifier preceding
3213 /// the code-completion point
3219 CurContext = CurContext->getParent(); in MaybeAddOverrideCalls()
3223 if (!Method || !Method->isVirtual()) in MaybeAddOverrideCalls()
3228 for (auto P : Method->parameters()) in MaybeAddOverrideCalls()
3229 if (!P->getDeclName()) in MaybeAddOverrideCalls()
3233 for (CXXMethodDecl::method_iterator M = Method->begin_overridden_methods(), in MaybeAddOverrideCalls()
3234 MEnd = Method->end_overridden_methods(); in MaybeAddOverrideCalls()
3239 if (Overridden->getCanonicalDecl() == Method->getCanonicalDecl()) in MaybeAddOverrideCalls()
3242 // If we need a nested-name-specifier, add one now. in MaybeAddOverrideCalls()
3246 Overridden->getDeclContext()); in MaybeAddOverrideCalls()
3250 NNS->print(OS, Policy); in MaybeAddOverrideCalls()
3253 } else if (!InContext->Equals(Overridden->getDeclContext())) in MaybeAddOverrideCalls()
3257 Overridden->getNameAsString())); in MaybeAddOverrideCalls()
3260 for (auto P : Method->parameters()) { in MaybeAddOverrideCalls()
3267 Results.getAllocator().CopyString(P->getIdentifier()->getName())); in MaybeAddOverrideCalls()
3282 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteModuleImport()
3283 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteModuleImport()
3291 // Enumerate all top-level modules. in CodeCompleteModuleImport()
3296 Builder.getAllocator().CopyString(Modules[I]->Name)); in CodeCompleteModuleImport()
3300 Modules[I]->isAvailable() in CodeCompleteModuleImport()
3311 for (Module::submodule_iterator Sub = Mod->submodule_begin(), in CodeCompleteModuleImport()
3312 SubEnd = Mod->submodule_end(); in CodeCompleteModuleImport()
3316 Builder.getAllocator().CopyString((*Sub)->Name)); in CodeCompleteModuleImport()
3320 (*Sub)->isAvailable() in CodeCompleteModuleImport()
3333 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteOrdinaryName()
3334 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteOrdinaryName()
3373 // If we are in a C++ non-static member function, check the qualifiers on in CodeCompleteOrdinaryName()
3376 if (CurMethod->isInstance()) in CodeCompleteOrdinaryName()
3378 Qualifiers::fromCVRMask(CurMethod->getTypeQualifiers())); in CodeCompleteOrdinaryName()
3382 CodeCompleter->includeGlobals()); in CodeCompleteOrdinaryName()
3392 if (S->getFnParent()) in CodeCompleteOrdinaryName()
3410 if (CodeCompleter->includeMacros()) in CodeCompleteOrdinaryName()
3428 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteDeclSpec()
3429 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteDeclSpec()
3446 // Add nested-name-specifiers. in CodeCompleteDeclSpec()
3452 CodeCompleter->includeGlobals()); in CodeCompleteDeclSpec()
3459 // declaration), and what we've seen so far is an Objective-C type that could in CodeCompleteDeclSpec()
3469 (S->getFlags() & Scope::DeclScope) != 0 && in CodeCompleteDeclSpec()
3470 (S->getFlags() & (Scope::ClassScope | Scope::TemplateParamScope | in CodeCompleteDeclSpec()
3474 if (!T.get().isNull() && T.get()->isObjCObjectOrInterfaceType()) in CodeCompleteDeclSpec()
3497 /// \brief Perform code-completion in an expression context when we know what
3501 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteExpression()
3502 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteExpression()
3522 CodeCompleter->includeGlobals()); in CodeCompleteExpression()
3530 PreferredTypeIsPointer = Data.PreferredType->isAnyPointerType() in CodeCompleteExpression()
3531 || Data.PreferredType->isMemberPointerType() in CodeCompleteExpression()
3532 || Data.PreferredType->isBlockPointerType(); in CodeCompleteExpression()
3534 if (S->getFnParent() && in CodeCompleteExpression()
3539 if (CodeCompleter->includeMacros()) in CodeCompleteExpression()
3556 typedef llvm::SmallPtrSet<IdentifierInfo*, 16> AddedPropertiesSet;
3561 if (Interface->hasDefinition()) in getContainerDef()
3562 return Interface->getDefinition(); in getContainerDef()
3568 if (Protocol->hasDefinition()) in getContainerDef()
3569 return Protocol->getDefinition(); in getContainerDef()
3589 for (const auto *P : Container->instance_properties()) in AddObjCProperties()
3590 if (AddedProperties.insert(P->getIdentifier()).second) in AddObjCProperties()
3596 ASTContext &Context = Container->getASTContext(); in AddObjCProperties()
3598 for (auto *M : Container->methods()) { in AddObjCProperties()
3599 if (M->getSelector().isUnarySelector()) in AddObjCProperties()
3600 if (IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0)) in AddObjCProperties()
3607 Results.getAllocator().CopyString(Name->getName())); in AddObjCProperties()
3619 for (auto *P : Protocol->protocols()) in AddObjCProperties()
3625 for (auto *Cat : IFace->known_categories()) in AddObjCProperties()
3631 for (auto *I : IFace->all_referenced_protocols()) in AddObjCProperties()
3636 if (IFace->getSuperClass()) in AddObjCProperties()
3637 AddObjCProperties(CCContext, IFace->getSuperClass(), AllowCategories, in AddObjCProperties()
3643 for (auto *P : Category->protocols()) in AddObjCProperties()
3662 QualType BaseType = Base->getType(); in CodeCompleteMemberReferenceExpr()
3665 if (const PointerType *Ptr = BaseType->getAs<PointerType>()) in CodeCompleteMemberReferenceExpr()
3666 BaseType = Ptr->getPointeeType(); in CodeCompleteMemberReferenceExpr()
3667 else if (BaseType->isObjCObjectPointerType()) in CodeCompleteMemberReferenceExpr()
3679 if (BaseType->isObjCObjectPointerType() || in CodeCompleteMemberReferenceExpr()
3680 BaseType->isObjCObjectOrInterfaceType()) { in CodeCompleteMemberReferenceExpr()
3689 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteMemberReferenceExpr()
3690 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteMemberReferenceExpr()
3694 if (const RecordType *Record = BaseType->getAs<RecordType>()) { in CodeCompleteMemberReferenceExpr()
3695 // Indicate that we are performing a member access, and the cv-qualifiers in CodeCompleteMemberReferenceExpr()
3702 LookupVisibleDecls(Record->getDecl(), LookupMemberName, Consumer, in CodeCompleteMemberReferenceExpr()
3703 CodeCompleter->includeGlobals()); in CodeCompleteMemberReferenceExpr()
3707 // The "template" keyword can follow "->" or "." in the grammar. in CodeCompleteMemberReferenceExpr()
3710 bool IsDependent = BaseType->isDependentType(); in CodeCompleteMemberReferenceExpr()
3712 for (Scope *DepScope = S; DepScope; DepScope = DepScope->getParent()) in CodeCompleteMemberReferenceExpr()
3713 if (DeclContext *Ctx = DepScope->getEntity()) { in CodeCompleteMemberReferenceExpr()
3714 IsDependent = Ctx->isDependentContext(); in CodeCompleteMemberReferenceExpr()
3723 } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) { in CodeCompleteMemberReferenceExpr()
3724 // Objective-C property reference. in CodeCompleteMemberReferenceExpr()
3729 = BaseType->getAsObjCInterfacePointerType(); in CodeCompleteMemberReferenceExpr()
3730 assert(ObjCPtr && "Non-NULL pointer guaranteed above!"); in CodeCompleteMemberReferenceExpr()
3731 AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true, in CodeCompleteMemberReferenceExpr()
3736 for (auto *I : ObjCPtr->quals()) in CodeCompleteMemberReferenceExpr()
3739 } else if ((IsArrow && BaseType->isObjCObjectPointerType()) || in CodeCompleteMemberReferenceExpr()
3740 (!IsArrow && BaseType->isObjCObjectType())) { in CodeCompleteMemberReferenceExpr()
3741 // Objective-C instance variable access. in CodeCompleteMemberReferenceExpr()
3744 = BaseType->getAs<ObjCObjectPointerType>()) in CodeCompleteMemberReferenceExpr()
3745 Class = ObjCPtr->getInterfaceDecl(); in CodeCompleteMemberReferenceExpr()
3747 Class = BaseType->getAs<ObjCObjectType>()->getInterface(); in CodeCompleteMemberReferenceExpr()
3754 CodeCompleter->includeGlobals()); in CodeCompleteMemberReferenceExpr()
3797 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteTag()
3798 CodeCompleter->getCodeCompletionTUInfo(), ContextKind); in CodeCompleteTag()
3804 CodeCompleter->includeGlobals()); in CodeCompleteTag()
3806 if (CodeCompleter->includeGlobals()) { in CodeCompleteTag()
3817 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteTypeQualifiers()
3818 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteTypeQualifiers()
3845 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter) in CodeCompleteCase()
3848 SwitchStmt *Switch = getCurFunction()->SwitchStack.back(); in CodeCompleteCase()
3849 QualType type = Switch->getCond()->IgnoreImplicit()->getType(); in CodeCompleteCase()
3850 if (!type->isEnumeralType()) { in CodeCompleteCase()
3857 // Code-complete the cases of a switch statement over an enumeration type in CodeCompleteCase()
3859 EnumDecl *Enum = type->castAs<EnumType>()->getDecl(); in CodeCompleteCase()
3860 if (EnumDecl *Def = Enum->getDefinition()) in CodeCompleteCase()
3864 // FIXME: Ideally, we would also be able to look *past* the code-completion in CodeCompleteCase()
3865 // token, in case we are code-completing in the middle of the switch and not in CodeCompleteCase()
3869 for (SwitchCase *SC = Switch->getSwitchCaseList(); SC; in CodeCompleteCase()
3870 SC = SC->getNextSwitchCase()) { in CodeCompleteCase()
3875 Expr *CaseVal = Case->getLHS()->IgnoreParenCasts(); in CodeCompleteCase()
3878 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) { in CodeCompleteCase()
3882 // values of each enumerator. However, value-based approach would not in CodeCompleteCase()
3884 // template are type- and value-dependent. in CodeCompleteCase()
3887 // If this is a qualified-id, keep track of the nested-name-specifier in CodeCompleteCase()
3898 Qualifier = DRE->getQualifier(); in CodeCompleteCase()
3910 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteCase()
3911 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteCase()
3914 for (auto *E : Enum->enumerators()) { in CodeCompleteCase()
3926 if (CodeCompleter->includeMacros()) { in CodeCompleteCase()
3961 // Add the remaining viable overload candidates as code-completion results. in mergeCandidatesWithResults()
3981 if (N < Proto->getNumParams()) { in getParamType()
3983 ParamType = Proto->getParamType(N); in getParamType()
3986 Proto->getParamType(N).getNonReferenceType())) in getParamType()
3987 // Otherwise return a default-constructed QualType. in getParamType()
4009 SemaRef.CodeCompleter->ProcessOverloadCandidates(SemaRef, CurrentArg, in CodeCompleteOverloadResults()
4018 // When we're code-completing for a call, we fall back to ordinary in CodeCompleteCall()
4019 // name code-completion whenever we can't produce specific in CodeCompleteCall()
4025 // Ignore type-dependent call expressions entirely. in CodeCompleteCall()
4026 if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args) || in CodeCompleteCall()
4033 SourceLocation Loc = Fn->getExprLoc(); in CodeCompleteCall()
4038 Expr *NakedFn = Fn->IgnoreParenCasts(); in CodeCompleteCall()
4044 if (UME->hasExplicitTemplateArgs()) { in CodeCompleteCall()
4045 UME->copyTemplateArgumentsInto(TemplateArgsBuffer); in CodeCompleteCall()
4048 SmallVector<Expr *, 12> ArgExprs(1, UME->getBase()); in CodeCompleteCall()
4051 Decls.append(UME->decls_begin(), UME->decls_end()); in CodeCompleteCall()
4058 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl()); in CodeCompleteCall()
4060 FD = dyn_cast<FunctionDecl>(DRE->getDecl()); in CodeCompleteCall()
4063 !FD->getType()->getAs<FunctionProtoType>()) in CodeCompleteCall()
4066 AddOverloadCandidate(FD, DeclAccessPair::make(FD, FD->getAccess()), in CodeCompleteCall()
4071 } else if (auto DC = NakedFn->getType()->getAsCXXRecordDecl()) { in CodeCompleteCall()
4075 if (isCompleteType(Loc, NakedFn->getType())) { in CodeCompleteCall()
4091 QualType T = NakedFn->getType(); in CodeCompleteCall()
4092 if (!T->getPointeeType().isNull()) in CodeCompleteCall()
4093 T = T->getPointeeType(); in CodeCompleteCall()
4095 if (auto FP = T->getAs<FunctionProtoType>()) { in CodeCompleteCall()
4096 if (!TooManyArguments(FP->getNumParams(), Args.size(), in CodeCompleteCall()
4098 FP->isVariadic()) in CodeCompleteCall()
4100 } else if (auto FT = T->getAs<FunctionType>()) in CodeCompleteCall()
4120 CXXRecordDecl *RD = Type->getAsCXXRecordDecl(); in CodeCompleteConstructor()
4133 AddOverloadCandidate(FD, DeclAccessPair::make(FD, C->getAccess()), in CodeCompleteConstructor()
4139 DeclAccessPair::make(FTD, C->getAccess()), in CodeCompleteConstructor()
4159 CodeCompleteExpression(S, VD->getType()); in CodeCompleteInitializer()
4166 ResultType = BSI->ReturnType; in CodeCompleteReturn()
4168 ResultType = Function->getReturnType(); in CodeCompleteReturn()
4170 ResultType = Method->getReturnType(); in CodeCompleteReturn()
4179 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteAfterIf()
4180 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteAfterIf()
4187 CodeCompleter->includeGlobals()); in CodeCompleteAfterIf()
4228 if (S->getFnParent()) in CodeCompleteAfterIf()
4231 if (CodeCompleter->includeMacros()) in CodeCompleteAfterIf()
4240 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType()); in CodeCompleteAssignmentRHS()
4254 // Try to instantiate any non-dependent declaration contexts before in CodeCompleteQualifiedId()
4259 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteQualifiedId()
4260 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteQualifiedId()
4265 // put it into the grammar if the nested-name-specifier is dependent. in CodeCompleteQualifiedId()
4267 if (!Results.empty() && NNS->isDependent()) in CodeCompleteQualifiedId()
4274 // qualified-id completions. in CodeCompleteQualifiedId()
4291 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteUsing()
4292 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteUsing()
4298 if (!S->isClassScope()) in CodeCompleteUsing()
4302 // nested-name-specifier. in CodeCompleteUsing()
4305 CodeCompleter->includeGlobals()); in CodeCompleteUsing()
4319 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteUsingDirective()
4320 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteUsingDirective()
4326 CodeCompleter->includeGlobals()); in CodeCompleteUsingDirective()
4337 DeclContext *Ctx = S->getEntity(); in CodeCompleteNamespaceDecl()
4338 if (!S->getParent()) in CodeCompleteNamespaceDecl()
4342 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx); in CodeCompleteNamespaceDecl()
4344 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteNamespaceDecl()
4345 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteNamespaceDecl()
4351 if (Ctx && Ctx->isFileContext() && !SuppressedGlobalResults) { in CodeCompleteNamespaceDecl()
4358 NS(Ctx->decls_begin()), NSEnd(Ctx->decls_end()); in CodeCompleteNamespaceDecl()
4360 OrigToLatest[NS->getOriginalNamespace()] = *NS; in CodeCompleteNamespaceDecl()
4370 NS->second, Results.getBasePriority(NS->second), in CodeCompleteNamespaceDecl()
4386 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteNamespaceAliasDecl()
4387 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteNamespaceAliasDecl()
4392 CodeCompleter->includeGlobals()); in CodeCompleteNamespaceAliasDecl()
4403 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteOperatorName()
4404 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteOperatorName()
4419 CodeCompleter->includeGlobals()); in CodeCompleteOperatorName()
4442 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteConstructorInitializer()
4443 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteConstructorInitializer()
4447 // Fill in any already-initialized fields or base classes. in CodeCompleteConstructorInitializer()
4451 if (Initializers[I]->isBaseInitializer()) in CodeCompleteConstructorInitializer()
4453 Context.getCanonicalType(QualType(Initializers[I]->getBaseClass(), 0))); in CodeCompleteConstructorInitializer()
4456 Initializers[I]->getAnyMember())); in CodeCompleteConstructorInitializer()
4464 CXXRecordDecl *ClassDecl = Constructor->getParent(); in CodeCompleteConstructorInitializer()
4465 for (const auto &Base : ClassDecl->bases()) { in CodeCompleteConstructorInitializer()
4470 Initializers.back()->isBaseInitializer() && in CodeCompleteConstructorInitializer()
4472 QualType(Initializers.back()->getBaseClass(), 0)); in CodeCompleteConstructorInitializer()
4489 for (const auto &Base : ClassDecl->vbases()) { in CodeCompleteConstructorInitializer()
4494 Initializers.back()->isBaseInitializer() && in CodeCompleteConstructorInitializer()
4496 QualType(Initializers.back()->getBaseClass(), 0)); in CodeCompleteConstructorInitializer()
4513 for (auto *Field : ClassDecl->fields()) { in CodeCompleteConstructorInitializer()
4514 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl())) in CodeCompleteConstructorInitializer()
4518 Initializers.back()->isAnyMemberInitializer() && in CodeCompleteConstructorInitializer()
4519 Initializers.back()->getAnyMember() == Field; in CodeCompleteConstructorInitializer()
4523 if (!Field->getDeclName()) in CodeCompleteConstructorInitializer()
4527 Field->getIdentifier()->getName())); in CodeCompleteConstructorInitializer()
4547 DeclContext *DC = S->getEntity(); in isNamespaceScope()
4551 return DC->isFileContext(); in isNamespaceScope()
4556 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteLambdaIntroducer()
4557 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteLambdaIntroducer()
4574 for (; S && !isNamespaceScope(S); S = S->getParent()) { in CodeCompleteLambdaIntroducer()
4575 for (const auto *D : S->decls()) { in CodeCompleteLambdaIntroducer()
4578 !Var->hasLocalStorage() || in CodeCompleteLambdaIntroducer()
4579 Var->hasAttr<BlocksAttr>()) in CodeCompleteLambdaIntroducer()
4582 if (Known.insert(Var->getIdentifier()).second) in CodeCompleteLambdaIntroducer()
4697 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCAtDirective()
4698 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCAtDirective()
4703 else if (CurContext->isObjCContainer()) in CodeCompleteObjCAtDirective()
4718 // @encode ( type-name ) in AddObjCExpressionResults()
4726 Builder.AddPlaceholderChunk("type-name"); in AddObjCExpressionResults()
4730 // @protocol ( protocol-name ) in AddObjCExpressionResults()
4734 Builder.AddPlaceholderChunk("protocol-name"); in AddObjCExpressionResults()
4836 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCAtVisibility()
4837 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCAtVisibility()
4848 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCAtStatement()
4849 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCAtStatement()
4861 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCAtExpression()
4862 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCAtExpression()
4872 /// \brief Determine whether the addition of the given flag to an Objective-C
4911 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPropertyFlags()
4912 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPropertyFlags()
4935 // Only suggest "weak" if we're compiling for ARC-with-weak-references or GC. in CodeCompleteObjCPropertyFlags()
4968 /// \brief Describes the kind of Objective-C method that we want to find
4972 MK_ZeroArgSelector, ///< Zero-argument (unary) selector.
4973 MK_OneArgSelector ///< One-argument selector.
5004 return isAcceptableObjCSelector(Method->getSelector(), WantKind, SelIdents, in isAcceptableObjCMethod()
5011 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5014 /// \brief Add all of the Objective-C methods in the given Objective-C
5046 bool isRootClass = IFace && !IFace->getSuperClass(); in AddObjCMethods()
5047 for (auto *M : Container->methods()) { in AddObjCMethods()
5050 if (M->isInstanceMethod() == WantInstanceMethods || in AddObjCMethods()
5057 if (!Selectors.insert(M->getSelector()).second) in AddObjCMethods()
5071 if (Protocol->hasDefinition()) { in AddObjCMethods()
5073 = Protocol->getReferencedProtocols(); in AddObjCMethods()
5082 if (!IFace || !IFace->hasDefinition()) in AddObjCMethods()
5086 for (auto *I : IFace->protocols()) in AddObjCMethods()
5091 for (auto *CatDecl : IFace->known_categories()) { in AddObjCMethods()
5098 = CatDecl->getReferencedProtocols(); in AddObjCMethods()
5107 if (ObjCCategoryImplDecl *Impl = CatDecl->getImplementation()) in AddObjCMethods()
5114 if (IFace->getSuperClass()) in AddObjCMethods()
5115 AddObjCMethods(IFace->getSuperClass(), WantInstanceMethods, WantKind, in AddObjCMethods()
5120 if (ObjCImplementationDecl *Impl = IFace->getImplementation()) in AddObjCMethods()
5133 Class = Category->getClassInterface(); in CodeCompleteObjCPropertyGetter()
5140 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPropertyGetter()
5141 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPropertyGetter()
5161 Class = Category->getClassInterface(); in CodeCompleteObjCPropertySetter()
5168 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPropertySetter()
5169 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPropertySetter()
5185 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPassingType()
5186 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPassingType()
5190 // Add context-sensitive, Objective-C parameter-passing keywords. in CodeCompleteObjCPassingType()
5217 // If we're completing the return type of an Objective-C method and the in CodeCompleteObjCPassingType()
5250 CodeCompleter->includeGlobals()); in CodeCompleteObjCPassingType()
5252 if (CodeCompleter->includeMacros()) in CodeCompleteObjCPassingType()
5261 /// that it has some more-specific class type based on knowledge of
5262 /// common uses of Objective-C. This routine returns that class type,
5269 Selector Sel = Msg->getSelector(); in GetAssumedMessageSendExprType()
5277 ObjCMethodDecl *Method = Msg->getMethodDecl(); in GetAssumedMessageSendExprType()
5283 switch (Msg->getReceiverKind()) { in GetAssumedMessageSendExprType()
5286 = Msg->getClassReceiver()->getAs<ObjCObjectType>()) in GetAssumedMessageSendExprType()
5287 IFace = ObjType->getInterface(); in GetAssumedMessageSendExprType()
5291 QualType T = Msg->getInstanceReceiver()->getType(); in GetAssumedMessageSendExprType()
5292 if (const ObjCObjectPointerType *Ptr = T->getAs<ObjCObjectPointerType>()) in GetAssumedMessageSendExprType()
5293 IFace = Ptr->getInterfaceDecl(); in GetAssumedMessageSendExprType()
5305 ObjCInterfaceDecl *Super = IFace->getSuperClass(); in GetAssumedMessageSendExprType()
5306 if (Method->isInstanceMethod()) in GetAssumedMessageSendExprType()
5307 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->getName()) in GetAssumedMessageSendExprType()
5322 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->getName()) in GetAssumedMessageSendExprType()
5345 /// \returns the Objective-C method declaration that would be invoked by
5355 ObjCInterfaceDecl *Class = CurMethod->getClassInterface(); in AddSuperSendCompletion()
5361 while ((Class = Class->getSuperClass()) && !SuperMethod) { in AddSuperSendCompletion()
5363 SuperMethod = Class->getMethod(CurMethod->getSelector(), in AddSuperSendCompletion()
5364 CurMethod->isInstanceMethod()); in AddSuperSendCompletion()
5368 for (const auto *Cat : Class->known_categories()) { in AddSuperSendCompletion()
5369 if ((SuperMethod = Cat->getMethod(CurMethod->getSelector(), in AddSuperSendCompletion()
5370 CurMethod->isInstanceMethod()))) in AddSuperSendCompletion()
5380 if (CurMethod->param_size() != SuperMethod->param_size() || in AddSuperSendCompletion()
5381 CurMethod->isVariadic() != SuperMethod->isVariadic()) in AddSuperSendCompletion()
5384 for (ObjCMethodDecl::param_iterator CurP = CurMethod->param_begin(), in AddSuperSendCompletion()
5385 CurPEnd = CurMethod->param_end(), in AddSuperSendCompletion()
5386 SuperP = SuperMethod->param_begin(); in AddSuperSendCompletion()
5389 if (!S.Context.hasSameUnqualifiedType((*CurP)->getType(), in AddSuperSendCompletion()
5390 (*SuperP)->getType())) in AddSuperSendCompletion()
5394 if (!(*CurP)->getIdentifier()) in AddSuperSendCompletion()
5398 // We have a superclass method. Now, form the send-to-super completion. in AddSuperSendCompletion()
5413 Selector Sel = CurMethod->getSelector(); in AddSuperSendCompletion()
5422 ObjCMethodDecl::param_iterator CurP = CurMethod->param_begin(); in AddSuperSendCompletion()
5436 (*CurP)->getIdentifier()->getName())); in AddSuperSendCompletion()
5442 (*CurP)->getIdentifier()->getName())); in AddSuperSendCompletion()
5454 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCMessageReceiver()
5455 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCMessageReceiver()
5464 CodeCompleter->includeGlobals()); in CodeCompleteObjCMessageReceiver()
5466 // If we are in an Objective-C method inside a class that has a superclass, in CodeCompleteObjCMessageReceiver()
5469 if (ObjCInterfaceDecl *Iface = Method->getClassInterface()) in CodeCompleteObjCMessageReceiver()
5470 if (Iface->getSuperClass()) { in CodeCompleteObjCMessageReceiver()
5481 if (CodeCompleter->includeMacros()) in CodeCompleteObjCMessageReceiver()
5494 CDecl = CurMethod->getClassInterface(); in CodeCompleteObjCSuperMessage()
5499 CDecl = CDecl->getSuperClass(); in CodeCompleteObjCSuperMessage()
5503 if (CurMethod->isInstanceMethod()) { in CodeCompleteObjCSuperMessage()
5523 = Context.getTypeDeclType(TD)->getAs<ObjCObjectType>()) in CodeCompleteObjCSuperMessage()
5524 CDecl = Iface->getInterface(); in CodeCompleteObjCSuperMessage()
5551 /// \brief Given a set of code-completion results for the argument of a message
5567 if (NumSelIdents <= Method->param_size()) { in getPreferredArgumentTypeForMessageSend()
5568 QualType MyPreferredType = Method->parameters()[NumSelIdents - 1] in getPreferredArgumentTypeForMessageSend()
5569 ->getType(); in getPreferredArgumentTypeForMessageSend()
5599 if (const ObjCObjectType *Interface = T->getAs<ObjCObjectType>()) in AddClassMessageCompletions()
5600 CDecl = Interface->getInterface(); in AddClassMessageCompletions()
5603 // Add all of the factory methods in this Objective-C class, its protocols, in AddClassMessageCompletions()
5607 // If this is a send-to-super, try to add the special "super" send in AddClassMessageCompletions()
5615 // If we're inside an Objective-C method definition, prefer its selector to in AddClassMessageCompletions()
5618 Results.setPreferredSelector(CurMethod->getSelector()); in AddClassMessageCompletions()
5632 N = SemaRef.getExternalSource()->GetNumExternalSelectors(); in AddClassMessageCompletions()
5634 Selector Sel = SemaRef.getExternalSource()->GetExternalSelector(I); in AddClassMessageCompletions()
5645 for (ObjCMethodList *MethList = &M->second.second; in AddClassMessageCompletions()
5646 MethList && MethList->getMethod(); in AddClassMessageCompletions()
5647 MethList = MethList->getNext()) { in AddClassMessageCompletions()
5648 if (!isAcceptableObjCMethod(MethList->getMethod(), MK_Any, SelIdents)) in AddClassMessageCompletions()
5651 Result R(MethList->getMethod(), in AddClassMessageCompletions()
5652 Results.getBasePriority(MethList->getMethod()), nullptr); in AddClassMessageCompletions()
5668 QualType T = this->GetTypeFromParser(Receiver); in CodeCompleteObjCClassMessage()
5670 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCClassMessage()
5671 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCClassMessage()
5681 // code-complete the expression using the corresponding parameter type as in CodeCompleteObjCClassMessage()
5714 QualType ReceiverType = RecExpr? RecExpr->getType() in CodeCompleteObjCInstanceMessage()
5721 // us to assume a more-specific receiver type. in CodeCompleteObjCInstanceMessage()
5722 if (ReceiverType->isObjCIdType() || ReceiverType->isObjCClassType()) { in CodeCompleteObjCInstanceMessage()
5724 if (ReceiverType->isObjCClassType()) in CodeCompleteObjCInstanceMessage()
5737 ReceiverType = RecExpr->getType(); in CodeCompleteObjCInstanceMessage()
5742 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCInstanceMessage()
5743 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCInstanceMessage()
5749 // If this is a send-to-super, try to add the special "super" send in CodeCompleteObjCInstanceMessage()
5757 // If we're inside an Objective-C method definition, prefer its selector to in CodeCompleteObjCInstanceMessage()
5760 Results.setPreferredSelector(CurMethod->getSelector()); in CodeCompleteObjCInstanceMessage()
5768 if (ReceiverType->isObjCClassType() || in CodeCompleteObjCInstanceMessage()
5769 ReceiverType->isObjCQualifiedClassType()) { in CodeCompleteObjCInstanceMessage()
5771 if (ObjCInterfaceDecl *ClassDecl = CurMethod->getClassInterface()) in CodeCompleteObjCInstanceMessage()
5778 = ReceiverType->getAsObjCQualifiedIdType()) { in CodeCompleteObjCInstanceMessage()
5780 for (auto *I : QualID->quals()) in CodeCompleteObjCInstanceMessage()
5786 = ReceiverType->getAsObjCInterfacePointerType()) { in CodeCompleteObjCInstanceMessage()
5788 AddObjCMethods(IFacePtr->getInterfaceDecl(), true, MK_Any, SelIdents, in CodeCompleteObjCInstanceMessage()
5793 for (auto *I : IFacePtr->quals()) in CodeCompleteObjCInstanceMessage()
5798 else if (ReceiverType->isObjCIdType()) { in CodeCompleteObjCInstanceMessage()
5800 // about as code-completion results. in CodeCompleteObjCInstanceMessage()
5805 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); in CodeCompleteObjCInstanceMessage()
5807 Selector Sel = ExternalSource->GetExternalSelector(I); in CodeCompleteObjCInstanceMessage()
5818 for (ObjCMethodList *MethList = &M->second.first; in CodeCompleteObjCInstanceMessage()
5819 MethList && MethList->getMethod(); in CodeCompleteObjCInstanceMessage()
5820 MethList = MethList->getNext()) { in CodeCompleteObjCInstanceMessage()
5821 if (!isAcceptableObjCMethod(MethList->getMethod(), MK_Any, SelIdents)) in CodeCompleteObjCInstanceMessage()
5824 if (!Selectors.insert(MethList->getMethod()->getSelector()).second) in CodeCompleteObjCInstanceMessage()
5827 Result R(MethList->getMethod(), in CodeCompleteObjCInstanceMessage()
5828 Results.getBasePriority(MethList->getMethod()), nullptr); in CodeCompleteObjCInstanceMessage()
5841 // code-complete the expression using the corresponding parameter type as in CodeCompleteObjCInstanceMessage()
5879 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); in CodeCompleteObjCSelector()
5881 Selector Sel = ExternalSource->GetExternalSelector(I); in CodeCompleteObjCSelector()
5889 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCSelector()
5890 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCSelector()
5897 Selector Sel = M->first; in CodeCompleteObjCSelector()
5940 for (const auto *D : Ctx->decls()) { in AddProtocolResults()
5943 if (!OnlyForwardDeclarations || !Proto->hasDefinition()) in AddProtocolResults()
5951 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCProtocolReferences()
5952 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCProtocolReferences()
5955 if (CodeCompleter && CodeCompleter->includeGlobals()) { in CodeCompleteObjCProtocolReferences()
5960 // FIXME: This doesn't work when caching code-completion results. in CodeCompleteObjCProtocolReferences()
5979 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCProtocolDecl()
5980 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCProtocolDecl()
5983 if (CodeCompleter && CodeCompleter->includeGlobals()) { in CodeCompleteObjCProtocolDecl()
5998 /// \brief Add all of the Objective-C interface declarations that we find in
6006 for (const auto *D : Ctx->decls()) { in AddInterfaceResults()
6009 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) && in AddInterfaceResults()
6010 (!OnlyUnimplemented || !Class->getImplementation())) in AddInterfaceResults()
6017 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCInterfaceDecl()
6018 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCInterfaceDecl()
6022 if (CodeCompleter->includeGlobals()) { in CodeCompleteObjCInterfaceDecl()
6037 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCSuperclass()
6038 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCSuperclass()
6048 if (CodeCompleter->includeGlobals()) { in CodeCompleteObjCSuperclass()
6062 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCImplementationDecl()
6063 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCImplementationDecl()
6067 if (CodeCompleter->includeGlobals()) { in CodeCompleteObjCImplementationDecl()
6085 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCInterfaceCategory()
6086 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCInterfaceCategory()
6091 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames; in CodeCompleteObjCInterfaceCategory()
6095 for (const auto *Cat : Class->visible_categories()) in CodeCompleteObjCInterfaceCategory()
6096 CategoryNames.insert(Cat->getIdentifier()); in CodeCompleteObjCInterfaceCategory()
6102 for (const auto *D : TU->decls()) in CodeCompleteObjCInterfaceCategory()
6104 if (CategoryNames.insert(Category->getIdentifier()).second) in CodeCompleteObjCInterfaceCategory()
6121 // program itself is ill-formed. However, we'll try to be helpful still by in CodeCompleteObjCImplementationCategory()
6129 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCImplementationCategory()
6130 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCImplementationCategory()
6135 // already-implemented categories in the class itself. in CodeCompleteObjCImplementationCategory()
6136 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames; in CodeCompleteObjCImplementationCategory()
6140 for (const auto *Cat : Class->visible_categories()) { in CodeCompleteObjCImplementationCategory()
6141 if ((!IgnoreImplemented || !Cat->getImplementation()) && in CodeCompleteObjCImplementationCategory()
6142 CategoryNames.insert(Cat->getIdentifier()).second) in CodeCompleteObjCImplementationCategory()
6147 Class = Class->getSuperClass(); in CodeCompleteObjCImplementationCategory()
6159 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPropertyDefinition()
6160 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPropertyDefinition()
6173 for (const auto *D : Container->decls()) in CodeCompleteObjCPropertyDefinition()
6175 Results.Ignore(PropertyImpl->getPropertyDecl()); in CodeCompleteObjCPropertyDefinition()
6182 AddObjCProperties(CCContext, ClassImpl->getClassInterface(), false, in CodeCompleteObjCPropertyDefinition()
6187 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(), in CodeCompleteObjCPropertyDefinition()
6200 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCPropertySynthesizeIvar()
6201 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCPropertySynthesizeIvar()
6216 Class = ClassImpl->getClassInterface(); in CodeCompleteObjCPropertySynthesizeIvar()
6218 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl() in CodeCompleteObjCPropertySynthesizeIvar()
6219 ->getClassInterface(); in CodeCompleteObjCPropertySynthesizeIvar()
6224 if (ObjCPropertyDecl *Property = Class->FindPropertyDeclaration( in CodeCompleteObjCPropertySynthesizeIvar()
6227 = Property->getType().getNonReferenceType().getUnqualifiedType(); in CodeCompleteObjCPropertySynthesizeIvar()
6239 NameWithPrefix += PropertyName->getName(); in CodeCompleteObjCPropertySynthesizeIvar()
6240 std::string NameWithSuffix = PropertyName->getName().str(); in CodeCompleteObjCPropertySynthesizeIvar()
6242 for(; Class; Class = Class->getSuperClass()) { in CodeCompleteObjCPropertySynthesizeIvar()
6243 for (ObjCIvarDecl *Ivar = Class->all_declared_ivar_begin(); Ivar; in CodeCompleteObjCPropertySynthesizeIvar()
6244 Ivar = Ivar->getNextIvar()) { in CodeCompleteObjCPropertySynthesizeIvar()
6250 if ((PropertyName == Ivar->getIdentifier() || in CodeCompleteObjCPropertySynthesizeIvar()
6251 NameWithPrefix == Ivar->getName() || in CodeCompleteObjCPropertySynthesizeIvar()
6252 NameWithSuffix == Ivar->getName())) { in CodeCompleteObjCPropertySynthesizeIvar()
6258 Results.data()[Results.size() - 1].Kind in CodeCompleteObjCPropertySynthesizeIvar()
6260 Results.data()[Results.size() - 1].Declaration == Ivar) in CodeCompleteObjCPropertySynthesizeIvar()
6261 Results.data()[Results.size() - 1].Priority--; in CodeCompleteObjCPropertySynthesizeIvar()
6307 if (!IFace->hasDefinition()) in FindImplementableMethods()
6310 IFace = IFace->getDefinition(); in FindImplementableMethods()
6314 = IFace->getReferencedProtocols(); in FindImplementableMethods()
6322 for (auto *Cat : IFace->visible_categories()) { in FindImplementableMethods()
6328 if (IFace->getSuperClass()) in FindImplementableMethods()
6329 FindImplementableMethods(Context, IFace->getSuperClass(), in FindImplementableMethods()
6337 = Category->getReferencedProtocols(); in FindImplementableMethods()
6345 if (InOriginalClass && Category->getClassInterface()) in FindImplementableMethods()
6346 FindImplementableMethods(Context, Category->getClassInterface(), in FindImplementableMethods()
6353 if (!Protocol->hasDefinition()) in FindImplementableMethods()
6355 Protocol = Protocol->getDefinition(); in FindImplementableMethods()
6360 = Protocol->getReferencedProtocols(); in FindImplementableMethods()
6371 for (auto *M : Container->methods()) { in FindImplementableMethods()
6372 if (M->isInstanceMethod() == WantInstanceMethods) { in FindImplementableMethods()
6374 !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType())) in FindImplementableMethods()
6377 KnownMethods[M->getSelector()] = in FindImplementableMethods()
6406 if (Class->getIdentifier() && Class->getIdentifier()->getName() == Name) in InheritsFromClassNamed()
6409 return InheritsFromClassNamed(Class->getSuperClass(), Name); in InheritsFromClassNamed()
6412 /// \brief Add code completions for Objective-C Key-Value Coding (KVC) and
6413 /// Key-Value Observing (KVO).
6420 IdentifierInfo *PropName = Property->getIdentifier(); in AddObjCKeyValueCompletions()
6421 if (!PropName || PropName->getLength() == 0) in AddObjCKeyValueCompletions()
6450 } Key(Allocator, PropName->getName()); in AddObjCKeyValueCompletions()
6453 std::string UpperKey = PropName->getName(); in AddObjCKeyValueCompletions()
6459 Property->getType()); in AddObjCKeyValueCompletions()
6461 = ReturnType.isNull() || ReturnType->isVoidType(); in AddObjCKeyValueCompletions()
6463 // Add the normal accessor -(type)key. in AddObjCKeyValueCompletions()
6466 ReturnTypeMatchesProperty && !Property->getGetterMethodDecl()) { in AddObjCKeyValueCompletions()
6468 AddObjCPassingTypeChunk(Property->getType(), /*Quals=*/0, in AddObjCKeyValueCompletions()
6477 // an integral or boolean return type), add the accessor -(type)isKey. in AddObjCKeyValueCompletions()
6480 (ReturnType->isIntegerType() || ReturnType->isBooleanType())) || in AddObjCKeyValueCompletions()
6482 (Property->getType()->isIntegerType() || in AddObjCKeyValueCompletions()
6483 Property->getType()->isBooleanType())))) { in AddObjCKeyValueCompletions()
6495 Allocator.CopyString(SelectorId->getName())); in AddObjCKeyValueCompletions()
6503 !Property->getSetterMethodDecl()) { in AddObjCKeyValueCompletions()
6514 Allocator.CopyString(SelectorId->getName())); in AddObjCKeyValueCompletions()
6516 AddObjCPassingTypeChunk(Property->getType(), /*Quals=*/0, in AddObjCKeyValueCompletions()
6530 = Property->getType()->getAs<ObjCObjectPointerType>()) { in AddObjCKeyValueCompletions()
6531 if (ObjCInterfaceDecl *IFace = ObjCPointer->getInterfaceDecl()) { in AddObjCKeyValueCompletions()
6553 // Add -(NSUInteger)countOf<key> in AddObjCKeyValueCompletions()
6555 (ReturnType.isNull() || ReturnType->isIntegerType())) { in AddObjCKeyValueCompletions()
6567 Allocator.CopyString(SelectorId->getName())); in AddObjCKeyValueCompletions()
6576 // Add -(id)objectInKeyAtIndex:(NSUInteger)index in AddObjCKeyValueCompletions()
6578 (ReturnType.isNull() || ReturnType->isObjCObjectPointerType())) { in AddObjCKeyValueCompletions()
6599 // Add -(NSArray *)keyAtIndexes:(NSIndexSet *)indexes in AddObjCKeyValueCompletions()
6602 (ReturnType->isObjCObjectPointerType() && in AddObjCKeyValueCompletions()
6603 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() && in AddObjCKeyValueCompletions()
6604 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() in AddObjCKeyValueCompletions()
6605 ->getName() == "NSArray"))) { in AddObjCKeyValueCompletions()
6607 = (Twine(Property->getName()) + "AtIndexes").str(); in AddObjCKeyValueCompletions()
6626 // Add -(void)getKey:(type **)buffer range:(NSRange)inRange in AddObjCKeyValueCompletions()
6643 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6660 // - (void)insertObject:(type *)object inKeyAtIndex:(NSUInteger)index in AddObjCKeyValueCompletions()
6677 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6692 // - (void)insertKey:(NSArray *)array atIndexes:(NSIndexSet *)indexes in AddObjCKeyValueCompletions()
6723 // -(void)removeObjectFromKeyAtIndex:(NSUInteger)index in AddObjCKeyValueCompletions()
6745 // -(void)removeKeyAtIndexes:(NSIndexSet *)indexes in AddObjCKeyValueCompletions()
6767 // - (void)replaceObjectInKeyAtIndex:(NSUInteger)index withObject:(id)object in AddObjCKeyValueCompletions()
6799 // - (void)replaceKeyAtIndexes:(NSIndexSet *)indexes withKey:(NSArray *)array in AddObjCKeyValueCompletions()
6833 // - (NSEnumerator *)enumeratorOfKey in AddObjCKeyValueCompletions()
6836 (ReturnType->isObjCObjectPointerType() && in AddObjCKeyValueCompletions()
6837 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() && in AddObjCKeyValueCompletions()
6838 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() in AddObjCKeyValueCompletions()
6839 ->getName() == "NSEnumerator"))) { in AddObjCKeyValueCompletions()
6856 // - (type *)memberOfKey:(type *)object in AddObjCKeyValueCompletions()
6858 (ReturnType.isNull() || ReturnType->isObjCObjectPointerType())) { in AddObjCKeyValueCompletions()
6864 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6872 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6887 // - (void)addKeyObject:(type *)object in AddObjCKeyValueCompletions()
6901 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6910 // - (void)addKey:(NSSet *)objects in AddObjCKeyValueCompletions()
6931 // - (void)removeKeyObject:(type *)object in AddObjCKeyValueCompletions()
6945 Builder.AddPlaceholderChunk("object-type"); in AddObjCKeyValueCompletions()
6954 // - (void)removeKey:(NSSet *)objects in AddObjCKeyValueCompletions()
6975 // - (void)intersectKey:(NSSet *)objects in AddObjCKeyValueCompletions()
6996 // Key-Value Observing in AddObjCKeyValueCompletions()
7000 (ReturnType->isObjCObjectPointerType() && in AddObjCKeyValueCompletions()
7001 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() && in AddObjCKeyValueCompletions()
7002 ReturnType->getAs<ObjCObjectPointerType>()->getInterfaceDecl() in AddObjCKeyValueCompletions()
7003 ->getName() == "NSSet"))) { in AddObjCKeyValueCompletions()
7024 ReturnType->isIntegerType() || in AddObjCKeyValueCompletions()
7025 ReturnType->isBooleanType())) { in AddObjCKeyValueCompletions()
7051 if (CurContext->isObjCContainer()) { in CodeCompleteObjCMethodDecl()
7060 SearchDecl = Impl->getClassInterface(); in CodeCompleteObjCMethodDecl()
7064 SearchDecl = CatImpl->getCategoryDecl(); in CodeCompleteObjCMethodDecl()
7071 if (DeclContext *DC = S->getEntity()) in CodeCompleteObjCMethodDecl()
7089 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCMethodDecl()
7090 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCMethodDecl()
7097 ObjCMethodDecl *Method = M->second.getPointer(); in CodeCompleteObjCMethodDecl()
7104 QualType ResTy = Method->getSendResultType().stripObjCKindOfType(Context); in CodeCompleteObjCMethodDecl()
7107 Method->getObjCDeclQualifier(), Context, Policy, in CodeCompleteObjCMethodDecl()
7111 Selector Sel = Method->getSelector(); in CodeCompleteObjCMethodDecl()
7119 for (ObjCMethodDecl::param_iterator P = Method->param_begin(), in CodeCompleteObjCMethodDecl()
7120 PEnd = Method->param_end(); in CodeCompleteObjCMethodDecl()
7134 if ((*P)->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability) in CodeCompleteObjCMethodDecl()
7135 ParamType = (*P)->getType(); in CodeCompleteObjCMethodDecl()
7137 ParamType = (*P)->getOriginalType(); in CodeCompleteObjCMethodDecl()
7142 (*P)->getObjCDeclQualifier(), in CodeCompleteObjCMethodDecl()
7146 if (IdentifierInfo *Id = (*P)->getIdentifier()) in CodeCompleteObjCMethodDecl()
7147 Builder.AddTextChunk(Builder.getAllocator().CopyString( Id->getName())); in CodeCompleteObjCMethodDecl()
7150 if (Method->isVariadic()) { in CodeCompleteObjCMethodDecl()
7151 if (Method->param_size() > 0) in CodeCompleteObjCMethodDecl()
7161 if (!Method->getReturnType()->isVoidType()) { in CodeCompleteObjCMethodDecl()
7175 if (!M->second.getInt()) in CodeCompleteObjCMethodDecl()
7181 // Add Key-Value-Coding and Key-Value-Observing accessor methods for all of in CodeCompleteObjCMethodDecl()
7191 KnownSelectors.insert(M->first); in CodeCompleteObjCMethodDecl()
7197 IFace = Category->getClassInterface(); in CodeCompleteObjCMethodDecl()
7200 for (auto *Cat : IFace->visible_categories()) in CodeCompleteObjCMethodDecl()
7204 for (auto *P : Containers[I]->instance_properties()) in CodeCompleteObjCMethodDecl()
7224 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors(); in CodeCompleteObjCMethodDeclSelector()
7226 Selector Sel = ExternalSource->GetExternalSelector(I); in CodeCompleteObjCMethodDeclSelector()
7236 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompleteObjCMethodDeclSelector()
7237 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompleteObjCMethodDeclSelector()
7247 for (ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first : in CodeCompleteObjCMethodDeclSelector()
7248 &M->second.second; in CodeCompleteObjCMethodDeclSelector()
7249 MethList && MethList->getMethod(); in CodeCompleteObjCMethodDeclSelector()
7250 MethList = MethList->getNext()) { in CodeCompleteObjCMethodDeclSelector()
7251 if (!isAcceptableObjCMethod(MethList->getMethod(), MK_Any, SelIdents)) in CodeCompleteObjCMethodDeclSelector()
7258 NumSelIdents <= MethList->getMethod()->param_size()) { in CodeCompleteObjCMethodDeclSelector()
7260 MethList->getMethod()->parameters()[NumSelIdents - 1]; in CodeCompleteObjCMethodDeclSelector()
7261 if (Param->getIdentifier()) { in CodeCompleteObjCMethodDeclSelector()
7265 Param->getIdentifier()->getName())); in CodeCompleteObjCMethodDeclSelector()
7273 Result R(MethList->getMethod(), in CodeCompleteObjCMethodDeclSelector()
7274 Results.getBasePriority(MethList->getMethod()), nullptr); in CodeCompleteObjCMethodDeclSelector()
7289 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompletePreprocessorDirective()
7290 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompletePreprocessorDirective()
7436 // completions for them. And __include_macros is a Clang-internal extension in CodeCompletePreprocessorDirective()
7449 S->getFnParent()? Sema::PCC_RecoveryInFunction in CodeCompleteInPreprocessorConditionalExclusion()
7454 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompletePreprocessorMacroName()
7455 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompletePreprocessorMacroName()
7458 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) { in CodeCompletePreprocessorMacroName()
7467 M->first->getName())); in CodeCompletePreprocessorMacroName()
7482 ResultBuilder Results(*this, CodeCompleter->getAllocator(), in CodeCompletePreprocessorExpression()
7483 CodeCompleter->getCodeCompletionTUInfo(), in CodeCompletePreprocessorExpression()
7486 if (!CodeCompleter || CodeCompleter->includeMacros()) in CodeCompletePreprocessorExpression()
7513 // Now just ignore this. There will be another code-completion callback in CodeCompletePreprocessorMacroArgument()
7528 if (!CodeCompleter || CodeCompleter->includeGlobals()) { in GatherGlobalCodeCompletions()
7535 if (!CodeCompleter || CodeCompleter->includeMacros()) in GatherGlobalCodeCompletions()