Lines Matching +full:coexist +full:- +full:support

1 //===--------------------- SemaLookup.cpp - Name Lookup  ------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements name lookup for C, C++, Objective-C, and
10 // Objective-C++.
12 //===----------------------------------------------------------------------===//
45 #include "llvm/Support/Casting.h"
46 #include "llvm/Support/ErrorHandling.h"
112 // both the using-directive and the nominated namespace. in visitScopeChain()
113 DeclContext *InnermostFileDC = InnermostFileScope->getEntity(); in visitScopeChain()
114 assert(InnermostFileDC && InnermostFileDC->isFileContext()); in visitScopeChain()
116 for (; S; S = S->getParent()) { in visitScopeChain()
118 // A using-directive shall not appear in class scope, but may in visitScopeChain()
120 DeclContext *Ctx = S->getEntity(); in visitScopeChain()
121 if (Ctx && Ctx->isFileContext()) { in visitScopeChain()
123 } else if (!Ctx || Ctx->isFunctionOrMethod()) { in visitScopeChain()
124 for (auto *I : S->using_directives()) in visitScopeChain()
149 DeclContext *NS = UD->getNominatedNamespace(); in visit()
163 for (auto *UD : DC->using_directives()) { in addUsingDirectives()
164 DeclContext *NS = UD->getNominatedNamespace(); in addUsingDirectives()
180 // The using-directive is transitive: if a scope contains a
181 // using-directive that nominates a second namespace that itself
182 // contains using-directives, the effect is as if the
183 // using-directives from the second namespace also appeared in
188 DeclContext *Common = UD->getNominatedNamespace(); in addUsingDirective()
189 while (!Common->Encloses(EffectiveDC)) in addUsingDirective()
190 Common = Common->getParent(); in addUsingDirective()
191 Common = Common->getPrimaryContext(); in addUsingDirective()
193 list.push_back(UnqualUsingEntry(UD->getNominatedNamespace(), Common)); in addUsingDirective()
206 DC->getPrimaryContext(), in getNamespacesFor()
308 // operators, make sure that the implicitly-declared new and delete in configure()
325 if (unsigned BuiltinID = Id->getBuiltinID()) { in configure()
338 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl()))); in checkDebugAssumptions()
357 // For function-local declarations, use that function as the context. This in getContextForScopeMatching()
360 if (const DeclContext *DC = D->getLexicalDeclContext(); in getContextForScopeMatching()
361 DC->isFunctionOrMethod()) in getContextForScopeMatching()
366 return D->getDeclContext()->getRedeclContext(); in getContextForScopeMatching()
380 const auto *DUnderlying = D->getUnderlyingDecl(); in isPreferredLookupResult()
381 const auto *EUnderlying = Existing->getUnderlyingDecl(); in isPreferredLookupResult()
390 // class-name in a destructor declaration. in isPreferredLookupResult()
391 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) { in isPreferredLookupResult()
405 unsigned DMin = DFD->getMinRequiredArguments(); in isPreferredLookupResult()
406 unsigned EMin = EFD->getMinRequiredArguments(); in isPreferredLookupResult()
417 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments(); in isPreferredLookupResult()
418 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments(); in isPreferredLookupResult()
427 for (unsigned I = DMin, N = DTD->getTemplateParameters()->size(); in isPreferredLookupResult()
430 ETD->getTemplateParameters()->getParam(I)) && in isPreferredLookupResult()
432 DTD->getTemplateParameters()->getParam(I))) in isPreferredLookupResult()
441 if (EVD->getType()->isIncompleteType() && in isPreferredLookupResult()
442 !DVD->getType()->isIncompleteType()) { in isPreferredLookupResult()
457 for (const Decl *Prev = DUnderlying->getPreviousDecl(); Prev; in isPreferredLookupResult()
458 Prev = Prev->getPreviousDecl()) in isPreferredLookupResult()
470 // the same variable, non-static data member, or enumerator, or all refer in canHideTag()
478 D = D->getUnderlyingDecl(); in canHideTag()
498 const NamedDecl *D = (*Decls.begin())->getUnderlyingDecl(); in resolveKind()
522 const NamedDecl *D = Decls[I]->getUnderlyingDecl(); in resolveKind()
523 D = cast<NamedDecl>(D->getCanonicalDecl()); in resolveKind()
527 if ((D->isInvalidDecl() || isa<HLSLBufferDecl>(D)) && in resolveKind()
528 N - RemovedDecls.count() > 1) { in resolveKind()
543 if (canHideTag(OtherDecl) && !OtherDecl->isInvalidDecl() && in resolveKind()
544 getContextForScopeMatching(OtherDecl)->Equals( in resolveKind()
567 ExistingI = UniqueResult.first->second; in resolveKind()
571 // For non-type declarations, check for a prior lookup result naming this in resolveKind()
577 ExistingI = UniqueResult.first->second; in resolveKind()
616 if (D->isPlaceholderVar(getSema().getLangOpts()) && in resolveKind()
637 Decls[I] = Decls[--N]; in resolveKind()
659 for (DeclContext::lookup_iterator DI = I->Decls, DE = DI.end(); DI != DE; in addDeclsFromBasePaths()
666 Paths->swap(P); in setAmbiguousBaseSubobjects()
674 Paths->swap(P); in setAmbiguousBaseSubobjectTypes()
687 (*I)->print(Out, 2); in print()
695 D->dump(); in dump()
809 /// non-null <Index, Len> pair, then the name is referencing an OpenCL
881 FTy->isFunctionProtoType()); in InsertOCLBuiltinDeclarationsFromTable()
882 NewOpenCLBuiltin->setImplicit(); in InsertOCLBuiltinDeclarationsFromTable()
888 for (unsigned IParm = 0, e = FP->getNumParams(); IParm != e; ++IParm) { in InsertOCLBuiltinDeclarationsFromTable()
891 nullptr, FP->getParamType(IParm), nullptr, SC_None, nullptr); in InsertOCLBuiltinDeclarationsFromTable()
892 Parm->setScopeInfo(0, IParm); in InsertOCLBuiltinDeclarationsFromTable()
895 NewOpenCLBuiltin->setParams(ParmList); in InsertOCLBuiltinDeclarationsFromTable()
899 NewOpenCLBuiltin->addAttr(PureAttr::CreateImplicit(Context)); in InsertOCLBuiltinDeclarationsFromTable()
901 NewOpenCLBuiltin->addAttr(ConstAttr::CreateImplicit(Context)); in InsertOCLBuiltinDeclarationsFromTable()
903 NewOpenCLBuiltin->addAttr(ConvergentAttr::CreateImplicit(Context)); in InsertOCLBuiltinDeclarationsFromTable()
906 NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context)); in InsertOCLBuiltinDeclarationsFromTable()
939 auto Index = isOpenCLBuiltin(II->getName()); in LookupBuiltin()
941 InsertOCLBuiltinDeclarationsFromTable(*this, R, II, Index.first - 1, in LookupBuiltin()
951 RISCV().IntrinsicManager->InitIntrinsicList(); in LookupBuiltin()
953 if (RISCV().IntrinsicManager->CreateIntrinsicIfFound(R, II, PP)) in LookupBuiltin()
958 if (unsigned BuiltinID = II->getBuiltinID()) { in LookupBuiltin()
1000 if (!Class->getDefinition() || Class->isDependentContext()) in CanDeclareSpecialMemberFunction()
1004 return !Class->isBeingDefined(); in CanDeclareSpecialMemberFunction()
1012 if (Class->needsImplicitDefaultConstructor()) in ForceDeclarationOfImplicitMembers()
1016 if (Class->needsImplicitCopyConstructor()) in ForceDeclarationOfImplicitMembers()
1020 if (Class->needsImplicitCopyAssignment()) in ForceDeclarationOfImplicitMembers()
1025 if (Class->needsImplicitMoveConstructor()) in ForceDeclarationOfImplicitMembers()
1029 if (Class->needsImplicitMoveAssignment()) in ForceDeclarationOfImplicitMembers()
1034 if (Class->needsImplicitDestructor()) in ForceDeclarationOfImplicitMembers()
1038 /// Determine whether this is the name of an implicitly-declared
1068 if (Record->getDefinition() && CanDeclareSpecialMemberFunction(Record)) { in DeclareImplicitMemberFunctionsWithName()
1070 if (Record->needsImplicitDefaultConstructor()) in DeclareImplicitMemberFunctionsWithName()
1072 if (Record->needsImplicitCopyConstructor()) in DeclareImplicitMemberFunctionsWithName()
1075 Record->needsImplicitMoveConstructor()) in DeclareImplicitMemberFunctionsWithName()
1082 if (Record->getDefinition() && Record->needsImplicitDestructor() && in DeclareImplicitMemberFunctionsWithName()
1092 if (Record->getDefinition() && CanDeclareSpecialMemberFunction(Record)) { in DeclareImplicitMemberFunctionsWithName()
1094 if (Record->needsImplicitCopyAssignment()) in DeclareImplicitMemberFunctionsWithName()
1097 Record->needsImplicitMoveAssignment()) in DeclareImplicitMemberFunctionsWithName()
1123 DeclContext::lookup_result DR = DC->lookup(R.getLookupName()); in LookupDirect()
1131 if (!Found && DC->isTranslationUnit() && S.LookupBuiltin(R)) in LookupDirect()
1136 R.getLookupName().getCXXNameType()->isDependentType() || in LookupDirect()
1145 if (!Record->isCompleteDefinition()) in LookupDirect()
1152 R.getLookupName().getCXXNameType()->getContainedDeducedType(); in LookupDirect()
1155 ContainedDeducedType && ContainedDeducedType->isUndeducedType()) in LookupDirect()
1158 for (CXXRecordDecl::conversion_iterator U = Record->conversion_begin(), in LookupDirect()
1159 UEnd = Record->conversion_end(); U != UEnd; ++U) { in LookupDirect()
1188 = ConvTemplate->getTemplatedDecl()->getType()->getAs<FunctionProtoType>(); in LookupDirect()
1194 FunctionProtoType::ExtProtoInfo EPI = ConvProto->getExtProtoInfo(); in LookupDirect()
1218 assert(NS && NS->isFileContext() && "CppNamespaceLookup() requires namespace!"); in CppNamespaceLookup()
1235 if (DeclContext *Ctx = S->getEntity()) in isNamespaceOrTranslationUnitScope()
1236 return Ctx->isFileContext(); in isNamespaceOrTranslationUnitScope()
1244 for (Scope *OuterS = S->getParent(); OuterS; OuterS = OuterS->getParent()) in findOuterContext()
1245 if (DeclContext *DC = OuterS->getLookupEntity()) in findOuterContext()
1277 // If this is the name of an implicitly-declared special member function, in CppLookupName()
1280 for (Scope *PreS = S; PreS; PreS = PreS->getParent()) in CppLookupName()
1281 if (DeclContext *DC = PreS->getEntity()) in CppLookupName()
1286 // The component name of an unqualified-id is dependent if in CppLookupName()
1287 // - it is a conversion-function-id whose conversion-type-id in CppLookupName()
1289 // - it is operator= and the current class is a templated entity, or in CppLookupName()
1290 // - the unqualified-id is the postfix-expression in a dependent call. in CppLookupName()
1292 Name.getCXXNameType()->isDependentType()) { in CppLookupName()
1306 // We don't consider using-directives, as per 7.3.4.p1 [namespace.udir] in CppLookupName()
1309 // both the using-directive and the nominated namespace. in CppLookupName()
1330 for (; S && !isNamespaceOrTranslationUnitScope(S); S = S->getParent()) { in CppLookupName()
1333 for (; I != IEnd && S->isDeclScope(*I); ++I) { in CppLookupName()
1336 !(*I)->isTemplateParameter()) { in CppLookupName()
1341 // out-of-scope. in CppLookupName()
1342 if (!LeftStartingScope && !Initial->isDeclScope(*I)) in CppLookupName()
1347 if (LeftStartingScope && !((*I)->hasLinkage())) { in CppLookupName()
1361 if (S->isClassScope()) in CppLookupName()
1362 if (auto *Record = dyn_cast_if_present<CXXRecordDecl>(S->getEntity())) in CppLookupName()
1367 if (NameKind == LookupLocalFriendName && !S->isClassScope()) { in CppLookupName()
1372 // innermost enclosing non-class scope. in CppLookupName()
1376 if (DeclContext *Ctx = S->getLookupEntity()) { in CppLookupName()
1378 for (; Ctx && !Ctx->Equals(OuterCtx); Ctx = Ctx->getLookupParent()) { in CppLookupName()
1381 // non-transparent context. in CppLookupName()
1382 if (Ctx->isTransparentContext()) in CppLookupName()
1388 if (Ctx->isFunctionOrMethod()) { in CppLookupName()
1389 // If we have an Objective-C instance method, look for ivars in CppLookupName()
1392 if (Method->isInstanceMethod() && Name.getAsIdentifierInfo()) in CppLookupName()
1393 if (ObjCInterfaceDecl *Class = Method->getClassInterface()) { in CppLookupName()
1395 if (ObjCIvarDecl *Ivar = Class->lookupInstanceVariable( in CppLookupName()
1412 if (Ctx->isFileContext()) { in CppLookupName()
1416 for (DeclContext *UCtx = Ctx; UCtx; UCtx = UCtx->getParent()) { in CppLookupName()
1417 if (UCtx->isTransparentContext()) in CppLookupName()
1428 InnermostFileScope = InnermostFileScope->getParent(); in CppLookupName()
1465 // nominated namespaces by those using-directives. in CppLookupName()
1483 for (; S; S = S->getParent()) { in CppLookupName()
1486 for (; I != IEnd && S->isDeclScope(*I); ++I) { in CppLookupName()
1497 if (Found && S->isTemplateParamScope()) { in CppLookupName()
1502 DeclContext *Ctx = S->getLookupEntity(); in CppLookupName()
1505 for (; Ctx && !Ctx->Equals(OuterCtx); Ctx = Ctx->getLookupParent()) { in CppLookupName()
1508 // non-transparent context. in CppLookupName()
1509 if (Ctx->isTransparentContext()) in CppLookupName()
1513 // template parameter scope for an out-of-line definition, also in CppLookupName()
1515 if (!(Found && S->isTemplateParamScope())) { in CppLookupName()
1516 assert(Ctx->isFileContext() && in CppLookupName()
1519 // Look into context considering using-directives. in CppLookupName()
1529 if (R.isForRedeclaration() && !Ctx->isTransparentContext()) in CppLookupName()
1534 if (R.isForRedeclaration() && Ctx && !Ctx->isTransparentContext()) in CppLookupName()
1546 ND->setVisibleDespiteOwningModule(); in makeMergedDefinitionVisible()
1551 for (auto *Param : *TD->getTemplateParameters()) in makeMergedDefinitionVisible()
1560 if (FunctionDecl *Pattern = FD->getTemplateInstantiationPattern()) in getDefiningModule()
1563 if (CXXRecordDecl *Pattern = RD->getTemplateInstantiationPattern()) in getDefiningModule()
1566 if (auto *Pattern = ED->getTemplateInstantiationPattern()) in getDefiningModule()
1569 if (VarDecl *Pattern = VD->getTemplateInstantiationPattern()) in getDefiningModule()
1575 DeclContext *Context = Entity->getLexicalDeclContext(); in getDefiningModule()
1576 if (Context->isFileContext()) in getDefiningModule()
1613 if (M->isGlobalModule()) in isUsableModule()
1658 if (!D->hasDefaultArgument()) in hasAcceptableDefaultArgument()
1663 auto &DefaultArg = D->getDefaultArgStorage(); in hasAcceptableDefaultArgument()
1669 Modules->push_back(S.getOwningModule(NonConstD)); in hasAcceptableDefaultArgument()
1711 for (auto *Redecl : D->redecls()) { in hasAcceptableDeclarationImpl()
1722 Modules->push_back(R->getOwningModule()); in hasAcceptableDeclarationImpl()
1740 return RD->getTemplateSpecializationKind() == in hasAcceptableExplicitSpecialization()
1743 return FD->getTemplateSpecializationKind() == in hasAcceptableExplicitSpecialization()
1746 return VD->getTemplateSpecializationKind() == in hasAcceptableExplicitSpecialization()
1769 assert(isa<CXXRecordDecl>(D->getDeclContext()) && in hasAcceptableMemberSpecialization()
1780 // FIXME: What about MS-style explicit specializations declared within a in hasAcceptableMemberSpecialization()
1782 return D->getLexicalDeclContext()->isFileContext(); in hasAcceptableMemberSpecialization()
1810 assert(!D->isUnconditionallyVisible() && in isAcceptableSlow()
1818 D->isInvisibleOutsideTheOwningModule())) in isAcceptableSlow()
1825 return DC->isFileContext() || isa<LinkageSpecDecl>(DC) || in isAcceptableSlow()
1831 DeclContext *DC = D->getLexicalDeclContext(); in isAcceptableSlow()
1841 if (D->isTemplateParameter()) { in isAcceptableSlow()
1844 if (const auto *TD = DCD->getDescribedTemplate()) { in isAcceptableSlow()
1845 TemplateParameterList *TPL = TD->getTemplateParameters(); in isAcceptableSlow()
1847 SearchDefinitions = Index >= TPL->size() || TPL->getParam(Index) != D; in isAcceptableSlow()
1859 else if (D->isModulePrivate()) { in isAcceptableSlow()
1860 // A module-private declaration is only acceptable if an enclosing lexical in isAcceptableSlow()
1868 DC = DC->getLexicalParent(); in isAcceptableSlow()
1881 D->setVisibleDespiteOwningModule(); in isAcceptableSlow()
1895 // The module might be ordinarily visible. For a module-private query, that in isModuleVisible()
1900 // For a query which is not module-private, that means it is in our visible in isModuleVisible()
1920 if (M->isGlobalModule() && LookupModules.count(M->getTopLevelModule())) in isModuleVisible()
1923 // For a module-private query, that's everywhere we get to look. in isModuleVisible()
1929 return LookupM->isModuleVisible(M); in isModuleVisible()
1942 if (DeclModule->isHeaderLikeModule()) in isReachableSlow()
1945 if (!D->isInAnotherModuleUnit()) in isReachableSlow()
1951 // - D is not discarded ([module.global.frag]), appears in a translation unit in isReachableSlow()
1955 // A declaration that's discarded in the GMF should be module-private. in isReachableSlow()
1956 if (D->isModulePrivate()) in isReachableSlow()
1967 // it contains a declaration (possibly a module-declaration) that imports U in isReachableSlow()
1977 if (DeclModule->getTopLevelModule()->isModuleInterfaceUnit()) in isReachableSlow()
1999 // Non-imported module: in shouldLinkPossiblyHiddenDecl()
2008 assert(D->isExternallyDeclarable() && in shouldLinkPossiblyHiddenDecl()
2009 "should not have hidden, non-externally-declarable result here"); in shouldLinkPossiblyHiddenDecl()
2028 return New->isExternallyDeclarable(); in shouldLinkPossiblyHiddenDecl()
2043 for (auto *RD : D->redecls()) { in findAcceptableDecl()
2052 if (ND->isInIdentifierNamespace(IDNS) && in findAcceptableDecl()
2084 auto *Key = ND->getCanonicalDecl(); in getAcceptableDeclSlow()
2100 if (D->isUnconditionallyVisible()) in isVisible()
2109 if (D->isUnconditionallyVisible()) in isReachable()
2124 if (auto *DeductionGuide = ND->getDeclName().getCXXDeductionGuideTemplate()) in isAvailableForLookup()
2133 // (See https://github.com/llvm/llvm-project/issues/59601) in isAvailableForLookup()
2140 FD && FD->isReservedGlobalPlacementOperator()) in isAvailableForLookup()
2143 auto *DC = ND->getDeclContext(); in isAvailableForLookup()
2146 if (DC->isFileContext()) in isAvailableForLookup()
2162 // auto b = e1; // Should be error. namespace-scope name e1 is not visible in isAvailableForLookup()
2183 // Unqualified name lookup in C/Objective-C is purely lexical, so in LookupName()
2186 // Find the nearest non-transparent declaration scope. in LookupName()
2187 while (!(S->getFlags() & Scope::DeclScope) || in LookupName()
2188 (S->getEntity() && S->getEntity()->isTransparentContext())) in LookupName()
2189 S = S->getParent(); in LookupName()
2207 // out-of-scope. in LookupName()
2208 if (!LeftStartingScope && !S->isDeclScope(*I)) in LookupName()
2213 if (LeftStartingScope && !((*I)->hasLinkage())) { in LookupName()
2229 while (S && !S->isDeclScope(D)) in LookupName()
2230 S = S->getParent(); in LookupName()
2241 DC = (*I)->getDeclContext()->getRedeclContext(); in LookupName()
2247 if (!S->isDeclScope(*LastI)) in LookupName()
2252 = (*LastI)->getDeclContext()->getRedeclContext(); in LookupName()
2253 if (!LastDC->Equals(DC)) in LookupName()
2283 return (ExternalSource && ExternalSource->LookupUnqualified(R, S)); in LookupName()
2290 /// Given X::m (where X is a user-declared namespace), or given \::m
2293 /// namespaces nominated by using-directives in X and its used
2294 /// namespaces, except that using-directives are ignored in any
2298 /// ill-formed. Otherwise, if S has exactly one member, or if the
2299 /// context of the reference is a using-declaration
2302 /// declaration to be chosen from S, the program is ill-formed.
2309 /// enumerator or a set of functions, the non-type name hides the
2312 /// different namespaces), the program is ill-formed.
2315 assert(StartDC->isFileContext() && "start context is not a file context"); in LookupQualifiedNameInUsingDirectives()
2318 // their "using-children" to the queue. in LookupQualifiedNameInUsingDirectives()
2326 // with its using-children. in LookupQualifiedNameInUsingDirectives()
2327 for (auto *I : StartDC->using_directives()) { in LookupQualifiedNameInUsingDirectives()
2328 NamespaceDecl *ND = I->getNominatedNamespace()->getFirstDecl(); in LookupQualifiedNameInUsingDirectives()
2375 for (auto *I : ND->using_directives()) { in LookupQualifiedNameInUsingDirectives()
2376 NamespaceDecl *Nom = I->getNominatedNamespace(); in LookupQualifiedNameInUsingDirectives()
2401 LookupCtx->isDependentContext() || in LookupQualifiedName()
2402 cast<TagDecl>(LookupCtx)->isCompleteDefinition() || in LookupQualifiedName()
2403 cast<TagDecl>(LookupCtx)->isBeingDefined()) && in LookupQualifiedName()
2411 : oldVal(ctx->shouldUseQualifiedLookup()), Context(ctx) { in LookupQualifiedName()
2412 ctx->setUseQualifiedLookup(); in LookupQualifiedName()
2415 Context->setUseQualifiedLookup(oldVal); in LookupQualifiedName()
2421 // if it's a dependent conversion-function-id or operator= where the current in LookupQualifiedName()
2426 // - it is a conversion-function-id whose conversion-type-id in LookupQualifiedName()
2428 // - [...] in LookupQualifiedName()
2429 // - its lookup context is the current instantiation and it in LookupQualifiedName()
2431 // - [...] in LookupQualifiedName()
2434 Name.getCXXNameType()->isDependentType()) { in LookupQualifiedName()
2450 // declarator-id is a qualified-id, given that the qualified-id in LookupQualifiedName()
2452 // nested-name-specifier unqualified-id in LookupQualifiedName()
2453 // the unqualified-id shall name a member of the namespace in LookupQualifiedName()
2454 // designated by the nested-name-specifier. in LookupQualifiedName()
2460 if (LookupCtx->isFileContext()) in LookupQualifiedName()
2465 if (!LookupRec || !LookupRec->getDefinition()) in LookupQualifiedName()
2480 if (!InUnqualifiedLookup && LookupRec->isDependentContext() && in LookupQualifiedName()
2481 LookupRec->hasAnyDependentBases()) { in LookupQualifiedName()
2493 CXXBasePath &Path) -> bool { in LookupQualifiedName()
2494 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl(); in LookupQualifiedName()
2495 // Drop leading non-matching lookup results from the declaration list so in LookupQualifiedName()
2497 for (Path.Decls = BaseRecord->lookup(Name).begin(); in LookupQualifiedName()
2499 if ((*Path.Decls)->isInIdentifierNamespace(IDNS)) in LookupQualifiedName()
2507 if (!LookupRec->lookupInBases(BaseCallback, Paths)) in LookupQualifiedName()
2514 // sub-objects of the same type, or the set has a nonstatic member in LookupQualifiedName()
2515 // and includes members from distinct sub-objects, there is an in LookupQualifiedName()
2516 // ambiguity and the program is ill-formed. Otherwise that set is in LookupQualifiedName()
2525 if ((*I)->isInIdentifierNamespace(IDNS) && (*I)->isCXXInstanceMember()) in LookupQualifiedName()
2539 auto Next = [&](Iterator &It, Iterator End) -> Result { in LookupQualifiedName()
2542 if (!ND->isInIdentifierNamespace(IDNS)) in LookupQualifiedName()
2546 // A lookup that finds an injected-class-name (10.2) can result in in LookupQualifiedName()
2548 // more than one base class). If all of the injected-class-names in LookupQualifiedName()
2550 // template, and if the name is used as a template-name, the in LookupQualifiedName()
2558 // type declarations (including injected-class-names) are replaced by in LookupQualifiedName()
2560 if (const TypeDecl *TD = dyn_cast<TypeDecl>(ND->getUnderlyingDecl())) { in LookupQualifiedName()
2565 return ND->getUnderlyingDecl()->getCanonicalDecl(); in LookupQualifiedName()
2591 if (!It->second) { in LookupQualifiedName()
2592 It->second = true; in LookupQualifiedName()
2603 const CXXBasePathElement &PathElement = Path->back(); in LookupQualifiedName()
2607 SubobjectAccess = std::min(SubobjectAccess, Path->Access); in LookupQualifiedName()
2609 // Determine whether we're looking at a distinct sub-object or not. in LookupQualifiedName()
2612 SubobjectType = Context.getCanonicalType(PathElement.Base->getType()); in LookupQualifiedName()
2618 Context.getCanonicalType(PathElement.Base->getType())) { in LookupQualifiedName()
2625 if (HasOnlyStaticMembers(Path->Decls) && in LookupQualifiedName()
2626 HasSameDeclarations(Paths.begin()->Decls, Path->Decls)) in LookupQualifiedName()
2643 if (HasOnlyStaticMembers(Path->Decls)) in LookupQualifiedName()
2658 (*I)->getAccess()); in LookupQualifiedName()
2669 if (NNS && NNS->getKind() == NestedNameSpecifier::Super) in LookupQualifiedName()
2670 return LookupInSuper(R, NNS->getAsRecordDecl()); in LookupQualifiedName()
2680 if (SS && SS->isInvalid()) in LookupParsedName()
2687 // This nested-name-specifier occurs in a member access expression, e.g., in LookupParsedName()
2688 // x->B::f, and we are looking into the type of the object. in LookupParsedName()
2689 assert((!SS || SS->isEmpty()) && in LookupParsedName()
2690 "ObjectType and scope specifier cannot coexist"); in LookupParsedName()
2692 IsDependent = !DC && ObjectType->isDependentType(); in LookupParsedName()
2693 assert(((!DC && ObjectType->isDependentType()) || in LookupParsedName()
2694 !ObjectType->isIncompleteType() || !ObjectType->getAs<TagType>() || in LookupParsedName()
2695 ObjectType->castAs<TagType>()->isBeingDefined()) && in LookupParsedName()
2697 } else if (SS && SS->isNotEmpty()) { in LookupParsedName()
2698 // This nested-name-specifier occurs after another nested-name-specifier, in LookupParsedName()
2699 // so long into the context associated with the prior nested-name-specifier. in LookupParsedName()
2702 if (!DC->isDependentContext() && RequireCompleteDeclContext(*SS, DC)) in LookupParsedName()
2704 R.setContextRange(SS->getRange()); in LookupParsedName()
2708 if (NestedNameSpecifier *NNS = SS->getScopeRep(); in LookupParsedName()
2709 NNS->getKind() == NestedNameSpecifier::Super) in LookupParsedName()
2710 return LookupInSuper(R, NNS->getAsRecordDecl()); in LookupParsedName()
2731 // The access-control rules we use here are essentially the rules for in LookupInSuper()
2735 for (const auto &BaseSpec : Class->bases()) { in LookupInSuper()
2737 BaseSpec.getType()->castAs<RecordType>()->getDecl()); in LookupInSuper()
2769 QualType SubobjectType = Paths->front().back().Base->getType(); in DiagnoseAmbiguousLookup()
2774 DeclContext::lookup_iterator Found = Paths->front().Decls; in DiagnoseAmbiguousLookup()
2776 cast<CXXMethodDecl>(*Found)->isStatic()) in DiagnoseAmbiguousLookup()
2779 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found); in DiagnoseAmbiguousLookup()
2789 for (CXXBasePaths::paths_iterator Path = Paths->begin(), in DiagnoseAmbiguousLookup()
2790 PathEnd = Paths->end(); in DiagnoseAmbiguousLookup()
2792 const NamedDecl *D = *Path->Decls; in DiagnoseAmbiguousLookup()
2793 if (!D->isInIdentifierNamespace(Result.getIdentifierNamespace())) in DiagnoseAmbiguousLookup()
2796 if (const auto *TD = dyn_cast<TypedefNameDecl>(D->getUnderlyingDecl())) in DiagnoseAmbiguousLookup()
2797 Diag(D->getLocation(), diag::note_ambiguous_member_type_found) in DiagnoseAmbiguousLookup()
2798 << TD->getUnderlyingType(); in DiagnoseAmbiguousLookup()
2799 else if (const auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl())) in DiagnoseAmbiguousLookup()
2800 Diag(D->getLocation(), diag::note_ambiguous_member_type_found) in DiagnoseAmbiguousLookup()
2803 Diag(D->getLocation(), diag::note_ambiguous_member_found); in DiagnoseAmbiguousLookup()
2817 Diag(TD->getLocation(), diag::note_hidden_tag); in DiagnoseAmbiguousLookup()
2822 Diag(D->getLocation(), diag::note_hiding_object); in DiagnoseAmbiguousLookup()
2838 Diag(D->getLocation(), diag::note_reference_placeholder) << D; in DiagnoseAmbiguousLookup()
2839 if (DC != nullptr && DC != D->getDeclContext()) in DiagnoseAmbiguousLookup()
2841 DC = D->getDeclContext(); in DiagnoseAmbiguousLookup()
2850 Diag(D->getLocation(), diag::note_ambiguous_candidate) << D; in DiagnoseAmbiguousLookup()
2900 // We additionally skip inline namespaces. The innermost non-inline namespace in CollectEnclosingNamespace()
2903 while (!Ctx->isFileContext() || Ctx->isInlineNamespace()) in CollectEnclosingNamespace()
2904 Ctx = Ctx->getParent(); in CollectEnclosingNamespace()
2906 Namespaces.insert(Ctx->getPrimaryContext()); in CollectEnclosingNamespace()
2909 // Add the associated classes and namespaces for argument-dependent
2915 // -- [...] ; in addAssociatedClassesAndNamespaces()
2935 DeclContext *Ctx = ClassTemplate->getDeclContext(); in addAssociatedClassesAndNamespaces()
2949 // [Note: non-type template arguments do not contribute to the set of in addAssociatedClassesAndNamespaces()
2960 // Add the associated classes and namespaces for argument-dependent lookup
2967 if (Class->getDeclName() == Result.S.VAListTagName) in addAssociatedClassesAndNamespaces()
2972 // -- If T is a class type (including unions), its associated in addAssociatedClassesAndNamespaces()
2979 DeclContext *Ctx = Class->getDeclContext(); in addAssociatedClassesAndNamespaces()
2986 // -- If T is a template-id, its associated namespaces and classes are in addAssociatedClassesAndNamespaces()
2993 // arguments are defined. [Note: non-type template arguments do not in addAssociatedClassesAndNamespaces()
2997 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext(); in addAssociatedClassesAndNamespaces()
3003 const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs(); in addAssociatedClassesAndNamespaces()
3027 for (const auto &Base : Class->bases()) { in addAssociatedClassesAndNamespaces()
3028 const RecordType *BaseType = Base.getType()->getAs<RecordType>(); in addAssociatedClassesAndNamespaces()
3032 // FIXME: If we want to support export, we probably need to add the in addAssociatedClassesAndNamespaces()
3034 // the classes and namespaces of known non-dependent arguments. in addAssociatedClassesAndNamespaces()
3037 CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(BaseType->getDecl()); in addAssociatedClassesAndNamespaces()
3040 DeclContext *BaseCtx = BaseDecl->getDeclContext(); in addAssociatedClassesAndNamespaces()
3044 if (BaseDecl->bases_begin() != BaseDecl->bases_end()) in addAssociatedClassesAndNamespaces()
3052 // argument-dependent lookup with an argument of type T
3063 // argument). Typedef names and using-declarations used to specify in addAssociatedClassesAndNamespaces()
3068 const Type *T = Ty->getCanonicalTypeInternal().getTypePtr(); in addAssociatedClassesAndNamespaces()
3071 switch (T->getTypeClass()) { in addAssociatedClassesAndNamespaces()
3086 // -- If T is a pointer to U or an array of U, its associated in addAssociatedClassesAndNamespaces()
3089 T = cast<PointerType>(T)->getPointeeType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3094 T = cast<ArrayType>(T)->getElementType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3097 // -- If T is a fundamental type, its associated sets of in addAssociatedClassesAndNamespaces()
3102 // -- If T is a class type (including unions), its associated in addAssociatedClassesAndNamespaces()
3109 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl()); in addAssociatedClassesAndNamespaces()
3114 // -- If T is an enumeration type, its associated namespace in addAssociatedClassesAndNamespaces()
3119 EnumDecl *Enum = cast<EnumType>(T)->getDecl(); in addAssociatedClassesAndNamespaces()
3121 DeclContext *Ctx = Enum->getDeclContext(); in addAssociatedClassesAndNamespaces()
3131 // -- If T is a function type, its associated namespaces and in addAssociatedClassesAndNamespaces()
3136 for (const auto &Arg : Proto->param_types()) in addAssociatedClassesAndNamespaces()
3143 T = FnType->getReturnType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3147 // -- If T is a pointer to a member function of a class X, its in addAssociatedClassesAndNamespaces()
3152 // -- If T is a pointer to a data member of class X, its in addAssociatedClassesAndNamespaces()
3160 Queue.push_back(MemberPtr->getClass()); in addAssociatedClassesAndNamespaces()
3163 T = MemberPtr->getPointeeType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3169 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3176 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3187 // Non-deduced auto types only get here for error cases. in addAssociatedClassesAndNamespaces()
3192 // If T is an Objective-C object or interface type, or a pointer to an in addAssociatedClassesAndNamespaces()
3204 T = cast<AtomicType>(T)->getValueType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3207 T = cast<PipeType>(T)->getElementType().getTypePtr(); in addAssociatedClassesAndNamespaces()
3241 if (Arg->getType() != Context.OverloadTy) { in FindAssociatedClassesAndNamespaces()
3242 addAssociatedClassesAndNamespaces(Result, Arg->getType()); in FindAssociatedClassesAndNamespaces()
3251 // classes and namespaces associated with its (non-dependent) in FindAssociatedClassesAndNamespaces()
3255 for (const NamedDecl *D : OE->decls()) { in FindAssociatedClassesAndNamespaces()
3257 const FunctionDecl *FDecl = D->getUnderlyingDecl()->getAsFunction(); in FindAssociatedClassesAndNamespaces()
3261 addAssociatedClassesAndNamespaces(Result, FDecl->getType()); in FindAssociatedClassesAndNamespaces()
3278 // -- The set of non-member candidates is the result of the in LookupOverloadedOperatorName()
3297 RD = RD->getDefinition(); in LookupSpecialMember()
3305 "parameter-less special members can't have qualified arguments"); in LookupSpecialMember()
3308 SourceLocation LookupLoc = RD->getLocation(); in LookupSpecialMember()
3332 if (RD->needsImplicitDestructor()) { in LookupSpecialMember()
3333 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3337 CXXDestructorDecl *DD = RD->getDestructor(); in LookupSpecialMember()
3338 Result->setMethod(DD); in LookupSpecialMember()
3339 Result->setKind(DD && !DD->isDeleted() in LookupSpecialMember()
3358 if (RD->needsImplicitDefaultConstructor()) { in LookupSpecialMember()
3359 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3367 if (RD->needsImplicitCopyConstructor()) { in LookupSpecialMember()
3368 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3372 if (getLangOpts().CPlusPlus11 && RD->needsImplicitMoveConstructor()) { in LookupSpecialMember()
3373 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3379 if (RD->needsImplicitCopyAssignment()) { in LookupSpecialMember()
3380 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3384 if (getLangOpts().CPlusPlus11 && RD->needsImplicitMoveAssignment()) { in LookupSpecialMember()
3385 runWithSufficientStackSpace(RD->getLocation(), [&] { in LookupSpecialMember()
3431 DeclContext::lookup_result R = RD->lookup(Name); in LookupSpecialMember()
3440 Result->setMethod(nullptr); in LookupSpecialMember()
3441 Result->setKind(SpecialMemberOverloadResult::NoMemberOrDeleted); in LookupSpecialMember()
3450 if (CandDecl->isInvalidDecl()) in LookupSpecialMember()
3455 if (CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(Cand->getUnderlyingDecl())) { in LookupSpecialMember()
3468 dyn_cast<FunctionTemplateDecl>(Cand->getUnderlyingDecl())) { in LookupSpecialMember()
3490 Result->setMethod(cast<CXXMethodDecl>(Best->Function)); in LookupSpecialMember()
3491 Result->setKind(SpecialMemberOverloadResult::Success); in LookupSpecialMember()
3495 Result->setMethod(cast<CXXMethodDecl>(Best->Function)); in LookupSpecialMember()
3496 Result->setKind(SpecialMemberOverloadResult::NoMemberOrDeleted); in LookupSpecialMember()
3500 Result->setMethod(nullptr); in LookupSpecialMember()
3501 Result->setKind(SpecialMemberOverloadResult::Ambiguous); in LookupSpecialMember()
3505 Result->setMethod(nullptr); in LookupSpecialMember()
3506 Result->setKind(SpecialMemberOverloadResult::NoMemberOrDeleted); in LookupSpecialMember()
3524 "non-const, non-volatile qualifiers for copy ctor arg"); in LookupCopyingConstructor()
3544 runWithSufficientStackSpace(Class->getLocation(), [&] { in LookupConstructors()
3545 if (Class->needsImplicitDefaultConstructor()) in LookupConstructors()
3547 if (Class->needsImplicitCopyConstructor()) in LookupConstructors()
3549 if (getLangOpts().CPlusPlus11 && Class->needsImplicitMoveConstructor()) in LookupConstructors()
3556 return Class->lookup(Name); in LookupConstructors()
3563 "non-const, non-volatile qualifiers for copy assignment arg"); in LookupCopyingAssignment()
3565 "non-const, non-volatile qualifiers for copy assignment this"); in LookupCopyingAssignment()
3579 "non-const, non-volatile qualifiers for copy assignment this"); in LookupMovingAssignment()
3616 D = USD->getTargetDecl(); in LookupLiteralOperator()
3619 if (D->isInvalidDecl()) { in LookupLiteralOperator()
3630 if (FD->getNumParams() == 1 && in LookupLiteralOperator()
3631 FD->getParamDecl(0)->getType()->getAs<PointerType>()) in LookupLiteralOperator()
3633 else if (FD->getNumParams() == ArgTys.size()) { in LookupLiteralOperator()
3636 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType(); in LookupLiteralOperator()
3645 TemplateParameterList *Params = FD->getTemplateParameters(); in LookupLiteralOperator()
3646 if (Params->size() == 1) { in LookupLiteralOperator()
3648 if (!Params->getParam(0)->isTemplateParameterPack() && !StringLit) { in LookupLiteralOperator()
3649 // Implied but not stated: user-defined integer and floating literals in LookupLiteralOperator()
3657 // is a well-formed template argument for the template parameter. in LookupLiteralOperator()
3663 Params->getParam(0), Arg, FD, R.getNameLoc(), R.getNameLoc(), in LookupLiteralOperator()
3706 // Per C++20 [lex.ext]p5, we prefer the template form over the non-template in LookupLiteralOperator()
3722 NoteOverloadCandidate(D, D->getUnderlyingDecl()->getAsFunction()); in LookupLiteralOperator()
3748 NamedDecl *&Old = Decls[cast<NamedDecl>(New->getCanonicalDecl())]; in insert()
3758 FunctionDecl *OldFD = Old->getAsFunction(); in insert()
3759 FunctionDecl *NewFD = New->getAsFunction(); in insert()
3763 Cursor = Cursor->getPreviousDecl(); in insert()
3804 // -- Any using-directives in the associated namespace are in ArgumentDependentLookup()
3807 // -- Any namespace-scope friend functions declared in in ArgumentDependentLookup()
3813 // -- are exported, are attached to a named module M, do not appear in ArgumentDependentLookup()
3815 // have the same innermost enclosing non-inline namespace scope as in ArgumentDependentLookup()
3817 DeclContext::lookup_result R = NS->lookup(Name); in ArgumentDependentLookup()
3821 Underlying = USD->getTargetDecl(); in ArgumentDependentLookup()
3827 // The declaration is visible to argument-dependent lookup if either in ArgumentDependentLookup()
3831 for (D = D->getMostRecentDecl(); D; in ArgumentDependentLookup()
3832 D = cast_or_null<NamedDecl>(D->getPreviousDecl())) { in ArgumentDependentLookup()
3833 if (D->getIdentifierNamespace() & Decl::IDNS_Ordinary) { in ArgumentDependentLookup()
3842 if (D->isInExportDeclContext()) { in ArgumentDependentLookup()
3843 Module *FM = D->getOwningModule(); in ArgumentDependentLookup()
3848 assert(FM && FM->isNamedModule() && !FM->isPrivateModule() && in ArgumentDependentLookup()
3852 if (D->isInAnotherModuleUnit() && in ArgumentDependentLookup()
3854 // ... and have the same innermost enclosing non-inline in ArgumentDependentLookup()
3857 if (E->getOwningModule() != FM) in ArgumentDependentLookup()
3861 DeclContext *Ctx = E->getDeclContext(); in ArgumentDependentLookup()
3862 while (!Ctx->isFileContext() || Ctx->isInlineNamespace()) in ArgumentDependentLookup()
3863 Ctx = Ctx->getParent(); in ArgumentDependentLookup()
3870 } else if (D->getFriendObjectKind()) { in ArgumentDependentLookup()
3871 auto *RD = cast<CXXRecordDecl>(D->getLexicalDeclContext()); in ArgumentDependentLookup()
3873 // Argument-dependent lookup finds all declarations of functions and in ArgumentDependentLookup()
3875 // - ... in ArgumentDependentLookup()
3876 // - are declared as a friend ([class.friend]) of any class with a in ArgumentDependentLookup()
3895 //----------------------------------------------------------------------------
3897 //----------------------------------------------------------------------------
3946 ShadowMaps.back()[ND->getDeclName()].push_back(ND); in add()
3969 unsigned IDNS = ND->getIdentifierNamespace(); in checkHidden()
3973 ShadowMap::iterator Pos = SM->find(ND->getDeclName()); in checkHidden()
3974 if (Pos == SM->end()) in checkHidden()
3977 for (auto *D : Pos->second) { in checkHidden()
3978 // A tag declaration does not hide a non-tag declaration. in checkHidden()
3979 if (D->hasTagIdentifierNamespace() && in checkHidden()
3985 if (((D->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol) in checkHidden()
3987 D->getIdentifierNamespace() != IDNS) in checkHidden()
3993 if (D->getUnderlyingDecl()->isFunctionOrFunctionTemplate() && in checkHidden()
3994 ND->getUnderlyingDecl()->isFunctionOrFunctionTemplate() && in checkHidden()
4001 cast<UsingShadowDecl>(ND)->getIntroducer() == D) in checkHidden()
4027 // Find the first namespace or translation-unit scope. in lookupVisibleDecls()
4029 S = S->getParent(); in lookupVisibleDecls()
4063 if (Visited.visitedContext(Ctx->getPrimaryContext())) in lookupInDeclContext()
4078 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers()); in lookupInDeclContext()
4079 for (StringRef Name = Iter->Next(); !Name.empty(); in lookupInDeclContext()
4080 Name = Iter->Next()) in lookupInDeclContext()
4105 // We sometimes skip loading namespace-level results (they tend to be huge). in lookupInDeclContext()
4110 Load ? Ctx->lookups() in lookupInDeclContext()
4111 : Ctx->noload_lookups(/*PreserveInternalState=*/false)) in lookupInDeclContext()
4131 for (auto *I : Ctx->using_directives()) { in lookupInDeclContext()
4134 lookupInDeclContext(I->getNominatedNamespace(), Result, in lookupInDeclContext()
4141 if (!Record->hasDefinition()) in lookupInDeclContext()
4144 for (const auto &B : Record->bases()) { in lookupInDeclContext()
4148 if (BaseType->isDependentType()) { in lookupInDeclContext()
4154 const auto *TST = BaseType->getAs<TemplateSpecializationType>(); in lookupInDeclContext()
4157 TemplateName TN = TST->getTemplateName(); in lookupInDeclContext()
4162 RD = TD->getTemplatedDecl(); in lookupInDeclContext()
4164 const auto *Record = BaseType->getAs<RecordType>(); in lookupInDeclContext()
4167 RD = Record->getDecl(); in lookupInDeclContext()
4177 // void f(C *c) { c->### } in lookupInDeclContext()
4183 // c->B::member in lookupInDeclContext()
4187 // c->A::member in lookupInDeclContext()
4196 // Traverse the contexts of Objective-C classes. in lookupInDeclContext()
4199 for (auto *Cat : IFace->visible_categories()) { in lookupInDeclContext()
4206 for (auto *I : IFace->all_referenced_protocols()) { in lookupInDeclContext()
4213 if (IFace->getSuperClass()) { in lookupInDeclContext()
4215 lookupInDeclContext(IFace->getSuperClass(), Result, QualifiedNameLookup, in lookupInDeclContext()
4221 if (IFace->getImplementation()) { in lookupInDeclContext()
4223 lookupInDeclContext(IFace->getImplementation(), Result, in lookupInDeclContext()
4227 for (auto *I : Protocol->protocols()) { in lookupInDeclContext()
4233 for (auto *I : Category->protocols()) { in lookupInDeclContext()
4240 if (Category->getImplementation()) { in lookupInDeclContext()
4242 lookupInDeclContext(Category->getImplementation(), Result, in lookupInDeclContext()
4257 if (!S->getEntity() || in lookupInScope()
4258 (!S->getParent() && !Visited.alreadyVisitedContext(S->getEntity())) || in lookupInScope()
4259 (S->getEntity())->isFunctionOrMethod()) { in lookupInScope()
4263 SmallVector<Decl *, 8> ScopeDecls(S->decls().begin(), S->decls().end()); in lookupInScope()
4273 DeclContext *Entity = S->getLookupEntity(); in lookupInScope()
4280 for (DeclContext *Ctx = Entity; Ctx && !Ctx->Equals(OuterCtx); in lookupInScope()
4281 Ctx = Ctx->getLookupParent()) { in lookupInScope()
4283 if (Method->isInstanceMethod()) { in lookupInScope()
4288 if (ObjCInterfaceDecl *IFace = Method->getClassInterface()) { in lookupInScope()
4296 // to for Objective-C methods; the next context will be the in lookupInScope()
4301 if (Ctx->isFunctionOrMethod()) in lookupInScope()
4307 } else if (!S->getParent()) { in lookupInScope()
4313 // However, doing so would force the normal C++ name-lookup code to look in lookupInScope()
4335 lookupInScope(S->getParent(), Result, UDirs); in lookupInScope()
4380 if (Res && Res->getDeclContext() != CurContext) in LookupOrCreateLabel()
4385 Scope *S = CurScope->getFnParent(); in LookupOrCreateLabel()
4392 //===----------------------------------------------------------------------===//
4394 //===----------------------------------------------------------------------===//
4437 } else if (!AnyVisibleDecls && !(*DI)->isModulePrivate()) in checkCorrectionVisibility()
4455 if (NestedNameSpecifier *Prefix = NNS->getPrefix()) in getNestedNameSpecifierIdentifiers()
4462 switch (NNS->getKind()) { in getNestedNameSpecifierIdentifiers()
4464 II = NNS->getAsIdentifier(); in getNestedNameSpecifierIdentifiers()
4468 if (NNS->getAsNamespace()->isAnonymousNamespace()) in getNestedNameSpecifierIdentifiers()
4470 II = NNS->getAsNamespace()->getIdentifier(); in getNestedNameSpecifierIdentifiers()
4474 II = NNS->getAsNamespaceAlias()->getIdentifier(); in getNestedNameSpecifierIdentifiers()
4479 II = QualType(NNS->getAsType(), 0).getBaseTypeIdentifier(); in getNestedNameSpecifierIdentifiers()
4500 IdentifierInfo *Name = ND->getIdentifier(); in FoundDecl()
4509 FoundName(Name->getName()); in FoundDecl()
4526 // Use a simple length-based heuristic to determine the minimum possible in addName()
4528 StringRef TypoStr = Typo->getName(); in addName()
4529 unsigned MinED = abs((int)Name.size() - (int)TypoStr.size()); in addName()
4534 // edit-distance algorithm can short-circuit. in addName()
4548 StringRef TypoStr = Typo->getName(); in addCorrection()
4549 StringRef Name = Correction.getCorrectionAsIdentifierInfo()->getName(); in addCorrection()
4580 if (D->isDeprecated()) in addCorrection()
4582 D = llvm::dyn_cast_or_null<NamespaceDecl>(D->getDeclContext()); in addCorrection()
4594 IsDeprecated(RI->getFoundDecl()), in addCorrection()
4595 RI->getAsString(SemaRef.getLangOpts())}; in addCorrection()
4618 (SS && SS->isValid()) ? SS->getScopeRep() : nullptr) { in addNamespaces()
4619 if (const Type *T = NNS->getAsType()) in addNamespaces()
4620 SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization; in addNamespaces()
4622 // Do not transform this into an iterator-based loop. The loop body can in addNamespaces()
4628 if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) { in addNamespaces()
4629 CD = CD->getCanonicalDecl(); in addNamespaces()
4630 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() && in addNamespaces()
4631 !CD->isUnion() && CD->getIdentifier() && in addNamespaces()
4633 (CD->isBeingDefined() || CD->isCompleteDefinition())) in addNamespaces()
4646 if (DI->second.empty()) { in getNextCorrection()
4651 auto RI = DI->second.begin(); in getNextCorrection()
4652 if (RI->second.empty()) { in getNextCorrection()
4653 DI->second.erase(RI); in getNextCorrection()
4658 TypoCorrection TC = RI->second.pop_back_val(); in getNextCorrection()
4674 CorrectionValidator->IsObjCIvarLookup, in resolveCorrection()
4718 unsigned TypoLen = Typo->getName().size(); in performQualifiedLookups()
4722 const Type *NSType = NSI.NameSpecifier->getAsType(); in performQualifiedLookups()
4728 if (CXXRecordDecl *NSDecl = NSType ? NSType->getAsCXXRecordDecl() : in performQualifiedLookups()
4730 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo()) in performQualifiedLookups()
4758 if (SS && SS->isValid()) { in performQualifiedLookups()
4762 SS->getScopeRep()->print(OldOStream, SemaRef.getPrintingPolicy()); in performQualifiedLookups()
4763 OldOStream << Typo->getName(); in performQualifiedLookups()
4773 NSType ? NSType->getAsCXXRecordDecl() in performQualifiedLookups()
4799 CurScopeSpec ? CurScopeSpec->getScopeRep() : nullptr) { in NamespaceSpecifierSet()
4801 NNS->print(SpecifierOStream, Context.getPrintingPolicy()); in NamespaceSpecifierSet()
4810 CurContextIdentifiers.push_back(ND->getIdentifier()); in NamespaceSpecifierSet()
4820 DeclContext *Start) -> DeclContextList { in buildContextChain()
4823 for (DeclContext *DC = Start->getPrimaryContext(); DC != nullptr; in buildContextChain()
4824 DC = DC->getLookupParent()) { in buildContextChain()
4826 if (!DC->isInlineNamespace() && !DC->isTransparentContext() && in buildContextChain()
4827 !(ND && ND->isAnonymousNamespace())) in buildContextChain()
4828 Chain.push_back(DC->getPrimaryContext()); in buildContextChain()
4842 NNS = NestedNameSpecifier::Create(Context, NNS, RD->isTemplateDecl(), in buildNestedNameSpecifier()
4843 RD->getTypeForDecl()); in buildNestedNameSpecifier()
4869 // Rebuild the NestedNameSpecifier as a globally-qualified specifier. in addNameSpecifier()
4875 IdentifierInfo *Name = ND->getIdentifier(); in addNameSpecifier()
4882 NNS->print(SpecifierOStream, Context.getPrintingPolicy()); in addNameSpecifier()
4887 // Rebuild the NestedNameSpecifier as a globally-qualified specifier. in addNameSpecifier()
4926 if (ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) { in LookupPotentialTypoResult()
4933 if (ObjCPropertyDecl *Prop = Class->FindPropertyDeclaration( in LookupPotentialTypoResult()
4952 if (Method->isInstanceMethod() && Method->getClassInterface() && in LookupPotentialTypoResult()
4955 Res.getFoundDecl()->isDefinedOutsideFunctionOrMethod()))) { in LookupPotentialTypoResult()
4957 = Method->getClassInterface()->lookupInstanceVariable(Name)) { in LookupPotentialTypoResult()
4982 // Add type-specifier keywords to the set of results. in AddKeywordsToConsumer()
4987 // storage-specifiers as well in AddKeywordsToConsumer()
5051 cast<CXXMethodDecl>(SemaRef.CurContext)->isInstance()) in AddKeywordsToConsumer()
5080 if (S && S->getBreakParent()) in AddKeywordsToConsumer()
5083 if (S && S->getContinueParent()) in AddKeywordsToConsumer()
5087 !SemaRef.getCurFunction()->SwitchStack.empty()) { in AddKeywordsToConsumer()
5097 if (S && S->isClassScope()) { in AddKeywordsToConsumer()
5130 if (getLangOpts().MSVCCompat && CurContext->isDependentContext() && in makeTypoCorrectionConsumer()
5141 if (SS && SS->isInvalid()) in makeTypoCorrectionConsumer()
5149 if (S && S->isInObjcMethodScope() && Typo == getSuperIdentifier()) in makeTypoCorrectionConsumer()
5155 locs->second.count(TypoName.getLoc())) in makeTypoCorrectionConsumer()
5161 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->isStr("vector")) in makeTypoCorrectionConsumer()
5177 getModuleLoader().lookupMissingImports(Typo->getName(), in makeTypoCorrectionConsumer()
5184 // initially stack-allocated. in makeTypoCorrectionConsumer()
5190 // Perform name lookup to find visible, similarly-named entities. in makeTypoCorrectionConsumer()
5198 for (auto *I : OPT->quals()) in makeTypoCorrectionConsumer()
5201 } else if (SS && SS->isSet()) { in makeTypoCorrectionConsumer()
5215 (IsUnqualifiedLookup || (SS && SS->isSet())); in makeTypoCorrectionConsumer()
5220 // FIXME: Re-add the ability to skip very unlikely potential corrections. in makeTypoCorrectionConsumer()
5222 Consumer->FoundName(I.getKey()); in makeTypoCorrectionConsumer()
5225 // FIXME: Re-add the ability to skip very unlikely potential corrections. in makeTypoCorrectionConsumer()
5228 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers()); in makeTypoCorrectionConsumer()
5230 StringRef Name = Iter->Next(); in makeTypoCorrectionConsumer()
5234 Consumer->FoundName(Name); in makeTypoCorrectionConsumer()
5240 *Consumer->getCorrectionValidator(), in makeTypoCorrectionConsumer()
5241 SS && SS->isNotEmpty()); in makeTypoCorrectionConsumer()
5246 // Load any externally-known namespaces. in makeTypoCorrectionConsumer()
5250 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces); in makeTypoCorrectionConsumer()
5255 Consumer->addNamespaces(KnownNamespaces); in makeTypoCorrectionConsumer()
5274 ExternalSource->CorrectTypo(TypoName, LookupKind, S, SS, CCC, in CorrectTypo()
5294 if (Consumer->empty()) in CorrectTypo()
5299 unsigned ED = Consumer->getBestEditDistance(true); in CorrectTypo()
5300 unsigned TypoLen = Typo->getName().size(); in CorrectTypo()
5304 TypoCorrection BestTC = Consumer->getNextCorrection(); in CorrectTypo()
5305 TypoCorrection SecondBestTC = Consumer->getNextCorrection(); in CorrectTypo()
5333 // Prefer 'super' when we're completing in a message-receiver in CorrectTypo()
5371 ExternalTypo = ExternalSource->CorrectTypo( in CorrectTypoDelayed()
5372 TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(), in CorrectTypoDelayed()
5375 Consumer->addCorrection(ExternalTypo); in CorrectTypoDelayed()
5378 if (!Consumer || Consumer->empty()) in CorrectTypoDelayed()
5383 unsigned ED = Consumer->getBestEditDistance(true); in CorrectTypoDelayed()
5385 if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3) in CorrectTypoDelayed()
5401 CorrectionName = CDecl->getDeclName(); in addCorrectionDecl()
5408 CorrectionNameSpec->print(PrefixOStream, PrintingPolicy(LO)); in getAsString()
5430 D = FTD->getTemplatedDecl(); in ValidateCandidate()
5432 if (Method->isStatic()) in ValidateCandidate()
5466 NamedDecl *ND = C->getUnderlyingDecl(); in ValidateCandidate()
5468 FD = FTD->getTemplatedDecl(); in ValidateCandidate()
5474 QualType ValType = cast<ValueDecl>(ND)->getType(); in ValidateCandidate()
5477 if (ValType->isAnyPointerType() || ValType->isReferenceType()) in ValidateCandidate()
5478 ValType = ValType->getPointeeType(); in ValidateCandidate()
5479 if (const FunctionProtoType *FPT = ValType->getAs<FunctionProtoType>()) in ValidateCandidate()
5480 if (FPT->getNumParams() == NumArgs) in ValidateCandidate()
5485 // A typo for a function-style cast can look like a function call in C++. in ValidateCandidate()
5488 CurContext->getParentASTContext().getLangOpts().CPlusPlus) in ValidateCandidate()
5494 if (!FD || !(FD->getNumParams() >= NumArgs && in ValidateCandidate()
5495 FD->getMinRequiredArguments() <= NumArgs)) in ValidateCandidate()
5498 // If the current candidate is a non-static C++ method, skip the candidate in ValidateCandidate()
5499 // unless the method being corrected--or the current DeclContext, if the in ValidateCandidate()
5500 // function being corrected is not a method--is a method in the same class in ValidateCandidate()
5503 if (MemberFn || !MD->isStatic()) { in ValidateCandidate()
5506 ? dyn_cast_if_present<CXXMethodDecl>(MemberFn->getMemberDecl()) in ValidateCandidate()
5509 CurMD ? CurMD->getParent()->getCanonicalDecl() : nullptr; in ValidateCandidate()
5510 const CXXRecordDecl *RD = MD->getParent()->getCanonicalDecl(); in ValidateCandidate()
5511 if (!CurRD || (CurRD != RD && !CurRD->isDerivedFrom(RD))) in ValidateCandidate()
5531 return VD->getDefinition(); in getDefinitionToImport()
5533 return FD->getDefinition(); in getDefinitionToImport()
5535 return TD->getDefinition(); in getDefinitionToImport()
5537 return ID->getDefinition(); in getDefinitionToImport()
5539 return PD->getDefinition(); in getDefinitionToImport()
5541 if (const NamedDecl *TTD = TD->getTemplatedDecl()) in getDefinitionToImport()
5562 diagnoseMissingImport(Loc, Def, Def->getLocation(), OwningModules, MIK, in diagnoseMissingImport()
5582 // See https://github.com/llvm/llvm-project/issues/73893. It is generally in diagnoseMissingImport()
5589 // -fdiagnostics-show-note-include-stack. We don't care how this in diagnoseMissingImport()
5598 if (M->isExplicitGlobalModule() || M->isPrivateModule()) in diagnoseMissingImport()
5604 // Try to find a suitable header-name to #include. in diagnoseMissingImport()
5611 getHeaderNameForHeader(PP, *Header, FE->tryGetRealPathName()); in diagnoseMissingImport()
5630 auto GetModuleNameForDiagnostic = [this](const Module *M) -> std::string { in diagnoseMissingImport()
5631 if (M->isModuleMapModule()) in diagnoseMissingImport()
5632 return M->getFullModuleName(); in diagnoseMissingImport()
5634 if (M->isImplicitGlobalModule()) in diagnoseMissingImport()
5635 M = M->getTopLevelModule(); in diagnoseMissingImport()
5641 return M->getTopLevelModuleName().str(); in diagnoseMissingImport()
5643 return M->getPrimaryModuleInterfaceName().str(); in diagnoseMissingImport()
5701 FD && FD->getBuiltinID() && in diagnoseTypo()
5703 Correction.getCorrectionRange().getBegin() == FD->getBeginLoc()) { in diagnoseTypo()
5708 Diag(ChosenDecl->getLocation(), PrevNote) in diagnoseTypo()
5735 return Entry->second; in getTypoExprState()
5753 E->dump(); in ActOnPragmaDump()
5761 if (cast<Decl>(CurContext)->getOwningModuleForLinkage()) in forRedeclarationInCurContext()