38 #include "llvm/ADT/STLExtras.h" 39 #include "llvm/ADT/SmallPtrSet.h" 40 #include "llvm/ADT/TinyPtrVector.h" 41 #include "llvm/ADT/edit_distance.h" 42 #include "llvm/Support/ErrorHandling.h" 50 using namespace clang;
54 class UnqualUsingEntry {
61 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
65 return CommonAncestor;
74 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
75 return L.getCommonAncestor() < R.getCommonAncestor();
78 bool operator()(
const UnqualUsingEntry &E,
const DeclContext *DC) {
79 return E.getCommonAncestor() < DC;
82 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
83 return DC < E.getCommonAncestor();
90 class UnqualUsingDirectiveSet {
96 llvm::SmallPtrSet<DeclContext*, 8> visited;
99 UnqualUsingDirectiveSet(
Sema &SemaRef) : SemaRef(SemaRef) {}
101 void visitScopeChain(
Scope *S,
Scope *InnermostFileScope) {
119 visit(I, InnermostFileDC);
132 if (!visited.insert(DC).second)
135 addUsingDirectives(DC, EffectiveDC);
143 if (!visited.insert(NS).second)
146 addUsingDirective(UD, EffectiveDC);
147 addUsingDirectives(NS, EffectiveDC);
158 if (SemaRef.
isVisible(UD) && visited.insert(NS).second) {
159 addUsingDirective(UD, EffectiveDC);
167 DC = queue.pop_back_val();
182 while (!Common->
Encloses(EffectiveDC))
189 void done() { llvm::sort(list, UnqualUsingEntry::Comparator()); }
191 typedef ListTy::const_iterator const_iterator;
193 const_iterator begin()
const {
return list.begin(); }
194 const_iterator end()
const {
return list.end(); }
196 llvm::iterator_range<const_iterator>
198 return llvm::make_range(std::equal_range(begin(), end(),
200 UnqualUsingEntry::Comparator()));
209 bool Redeclaration) {
229 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
268 assert(Redeclaration &&
"should only be used for redecl lookup");
291 void LookupResult::configure() {
293 isForRedeclaration());
298 switch (NameInfo.getName().getCXXOverloadedOperator()) {
302 case OO_Array_Delete:
303 getSema().DeclareGlobalNewDelete();
313 if (
unsigned BuiltinID =
Id->getBuiltinID()) {
314 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
320 bool LookupResult::sanity()
const {
322 assert(ResultKind != NotFound || Decls.size() == 0);
323 assert(ResultKind != Found || Decls.size() == 1);
324 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
325 (Decls.size() == 1 &&
326 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
327 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
328 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
329 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
330 Ambiguity == AmbiguousBaseSubobjectTypes)));
331 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
332 (Ambiguity == AmbiguousBaseSubobjectTypes ||
333 Ambiguity == AmbiguousBaseSubobjects)));
364 !isa<UsingShadowDecl>(Existing))
376 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
377 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
378 bool HaveTag = isa<TagDecl>(EUnderlying);
380 return HaveTag != WantTag;
387 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
388 auto *EFD = cast<FunctionDecl>(EUnderlying);
389 unsigned DMin = DFD->getMinRequiredArguments();
390 unsigned EMin = EFD->getMinRequiredArguments();
399 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
400 auto *ETD = cast<TemplateDecl>(EUnderlying);
401 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
402 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
411 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
414 ETD->getTemplateParameters()->getParam(I)) &&
416 DTD->getTemplateParameters()->getParam(I)))
423 if (
VarDecl *DVD = dyn_cast<VarDecl>(DUnderlying)) {
424 VarDecl *EVD = cast<VarDecl>(EUnderlying);
426 !DVD->getType()->isIncompleteType()) {
434 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
443 if (Prev == EUnderlying)
463 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
464 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D) ||
465 isa<UnresolvedUsingValueDecl>(D);
470 unsigned N = Decls.size();
474 assert(ResultKind == NotFound ||
475 ResultKind == NotFoundInCurrentInstantiation);
482 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
483 if (isa<FunctionTemplateDecl>(D))
484 ResultKind = FoundOverloaded;
485 else if (isa<UnresolvedUsingValueDecl>(D))
486 ResultKind = FoundUnresolvedValue;
491 if (ResultKind == Ambiguous)
return;
493 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
494 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
496 bool Ambiguous =
false;
497 bool HasTag =
false, HasFunction =
false;
498 bool HasFunctionTemplate =
false, HasUnresolved =
false;
503 unsigned UniqueTagIndex = 0;
512 Decls[I] = Decls[--N];
522 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
523 QualType T = getSema().Context.getTypeDeclType(TD);
524 auto UniqueResult = UniqueTypes.insert(
526 if (!UniqueResult.second) {
528 ExistingI = UniqueResult.first->second;
535 auto UniqueResult = Unique.insert(std::make_pair(D, I));
536 if (!UniqueResult.second) {
538 ExistingI = UniqueResult.first->second;
547 Decls[*ExistingI] = Decls[I];
548 Decls[I] = Decls[--N];
554 if (isa<UnresolvedUsingValueDecl>(D)) {
555 HasUnresolved =
true;
556 }
else if (isa<TagDecl>(D)) {
561 }
else if (isa<FunctionTemplateDecl>(D)) {
563 HasFunctionTemplate =
true;
564 }
else if (isa<FunctionDecl>(D)) {
567 if (HasNonFunction) {
572 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
574 EquivalentNonFunctions.push_back(D);
575 Decls[I] = Decls[--N];
595 if (N > 1 && HideTags && HasTag && !Ambiguous &&
596 (HasFunction || HasNonFunction || HasUnresolved)) {
597 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
598 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
602 Decls[UniqueTagIndex] = Decls[--N];
609 if (!EquivalentNonFunctions.empty() && !Ambiguous)
610 getSema().diagnoseEquivalentInternalLinkageDeclarations(
611 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
615 if (HasNonFunction && (HasFunction || HasUnresolved))
620 else if (HasUnresolved)
622 else if (N > 1 || HasFunctionTemplate)
628 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
630 for (I = P.
begin(), E = P.
end(); I != E; ++I)
632 DE = I->Decls.end(); DI != DE; ++DI)
639 addDeclsFromBasePaths(*Paths);
641 setAmbiguous(AmbiguousBaseSubobjects);
647 addDeclsFromBasePaths(*Paths);
649 setAmbiguous(AmbiguousBaseSubobjectTypes);
653 Out << Decls.size() <<
" result(s)";
654 if (isAmbiguous()) Out <<
", ambiguous";
655 if (Paths) Out <<
", base paths present";
657 for (
iterator I = begin(), E = end(); I != E; ++I) {
664 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
731 DeclareImplicitDefaultConstructor(Class);
735 DeclareImplicitCopyConstructor(Class);
739 DeclareImplicitCopyAssignment(Class);
741 if (getLangOpts().CPlusPlus11) {
744 DeclareImplicitMoveConstructor(Class);
748 DeclareImplicitMoveAssignment(Class);
753 DeclareImplicitDestructor(Class);
785 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
788 if (Record->needsImplicitDefaultConstructor())
790 if (Record->needsImplicitCopyConstructor())
793 Record->needsImplicitMoveConstructor())
799 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
800 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
809 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
812 if (Record->needsImplicitCopyAssignment())
815 Record->needsImplicitMoveAssignment())
855 !isa<CXXRecordDecl>(DC))
869 auto *ContainedDeducedType =
873 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
907 assert(ConvProto &&
"Nonsensical conversion function template type");
922 Specialization, Info)
937 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
944 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
971 if (OuterS->getEntity()) {
972 Lexical = OuterS->getEntity();
999 if (!Lexical || !DC || !S->
getParent() ||
1001 return std::make_pair(Lexical,
false);
1007 while (OutermostTemplateScope->
getParent() &&
1009 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1023 return std::make_pair(Semantic,
true);
1025 return std::make_pair(Lexical,
false);
1031 struct FindLocalExternScope {
1041 ~FindLocalExternScope() {
1045 bool OldFindLocalExtern;
1050 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1068 I = IdResolver.begin(Name),
1069 IEnd = IdResolver.end();
1089 UnqualUsingDirectiveSet UDirs(*
this);
1090 bool VisitedUsingDirectives =
false;
1091 bool LeftStartingScope =
false;
1095 FindLocalExternScope FindLocals(R);
1099 bool SearchNamespaceScope =
true;
1103 if (NameKind == LookupRedeclarationWithLinkage &&
1104 !(*I)->isTemplateParameter()) {
1110 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1111 LeftStartingScope =
true;
1115 if (LeftStartingScope && !((*I)->hasLinkage())) {
1122 SearchNamespaceScope =
false;
1127 if (!SearchNamespaceScope) {
1130 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1135 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1151 Ctx = OutsideOfTemplateParamDC;
1152 OutsideOfTemplateParamDC =
nullptr;
1157 bool SearchAfterTemplateScope;
1159 if (SearchAfterTemplateScope)
1160 OutsideOfTemplateParamDC = OuterCtx;
1179 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(
1198 if (!VisitedUsingDirectives) {
1201 if (UCtx->isTransparentContext())
1204 UDirs.visit(UCtx, UCtx);
1209 Scope *InnermostFileScope = S;
1210 while (InnermostFileScope &&
1212 InnermostFileScope = InnermostFileScope->
getParent();
1213 UDirs.visitScopeChain(Initial, InnermostFileScope);
1217 VisitedUsingDirectives =
true;
1234 if (LookupQualifiedName(R, Ctx,
true))
1242 if (!S)
return false;
1245 if (NameKind == LookupMemberName)
1253 if (!VisitedUsingDirectives) {
1254 UDirs.visitScopeChain(Initial, S);
1261 FindLocals.restore();
1294 Ctx = OutsideOfTemplateParamDC;
1295 OutsideOfTemplateParamDC =
nullptr;
1300 bool SearchAfterTemplateScope;
1302 if (SearchAfterTemplateScope)
1303 OutsideOfTemplateParamDC = OuterCtx;
1317 "We should have been looking only at file context here already.");
1342 if (
auto *M = getCurrentModule())
1350 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1351 for (
auto *Param : *TD->getTemplateParameters())
1352 makeMergedDefinitionVisible(Param);
1357 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1362 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1365 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1366 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1368 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1382 unsigned N = CodeSynthesisContexts.size();
1383 for (
unsigned I = CodeSynthesisContextLookupModules.size();
1386 if (M && !LookupModulesCache.insert(M).second)
1388 CodeSynthesisContextLookupModules.push_back(M);
1390 return LookupModulesCache;
1404 if (isModuleVisible(Merged))
1416 template<
typename ParmDecl>
1420 if (!D->hasDefaultArgument())
1424 auto &DefaultArg = D->getDefaultArgStorage();
1425 if (!DefaultArg.isInherited() && S.
isVisible(D))
1428 if (!DefaultArg.isInherited() && Modules) {
1429 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1434 D = DefaultArg.getInheritedFrom();
1441 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1443 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1449 template<
typename Filter>
1453 bool HasFilteredRedecls =
false;
1455 for (
auto *Redecl : D->
redecls()) {
1456 auto *R = cast<NamedDecl>(Redecl);
1463 HasFilteredRedecls =
true;
1466 Modules->push_back(R->getOwningModule());
1470 if (HasFilteredRedecls)
1479 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1481 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1483 if (
auto *VD = dyn_cast<VarDecl>(D))
1485 llvm_unreachable(
"unknown explicit specialization kind");
1492 "not a member specialization");
1513 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1514 assert(D->
isHidden() &&
"should not call this: not in slow case");
1517 assert(DeclModule &&
"hidden decl has no owning module");
1526 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1528 isa<ExportDecl>(DC);
1534 if (DC && !IsEffectivelyFileContext(DC)) {
1542 bool VisibleWithinParent;
1544 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1545 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1549 VisibleWithinParent =
false;
1552 VisibleWithinParent =
true;
1556 }
while (!IsEffectivelyFileContext(DC));
1568 return VisibleWithinParent;
1578 if (ModulePrivate) {
1582 if (VisibleModules.isVisible(M))
1590 const auto &LookupModules = getLookupModules();
1591 if (LookupModules.empty())
1595 if (LookupModules.count(M))
1603 return llvm::any_of(LookupModules, [&](
const Module *LookupM) {
1608 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1626 "should not have hidden, non-externally-declarable result here");
1660 for (
auto RD : D->
redecls()) {
1665 auto ND = cast<NamedDecl>(RD);
1669 if (ND->isInIdentifierNamespace(IDNS) &&
1679 assert(!isVisible(D) &&
"not in slow case");
1681 [](
const NamedDecl *) {
return true; });
1685 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1693 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1695 auto *Acceptable = isVisible(getSema(), Key)
1699 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1736 if (!Name)
return false;
1751 FindLocalExternScope FindLocals(R);
1757 bool LeftStartingScope =
false;
1760 IEnd = IdResolver.end();
1763 if (NameKind == LookupRedeclarationWithLinkage) {
1767 LeftStartingScope =
true;
1771 if (LeftStartingScope && !((*I)->hasLinkage())) {
1776 else if (NameKind == LookupObjCImplicitSelfParam &&
1777 !isa<ImplicitParamDecl>(*I))
1802 for (++LastI; LastI != IEnd; ++LastI) {
1827 if (CppLookupName(R, S))
1841 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1873 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1880 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1881 Visited.insert(StartDC);
1887 if (S.
isVisible(I) && Visited.insert(ND).second)
1888 Queue.push_back(ND);
1895 bool FoundTag =
false;
1896 bool FoundNonTag =
false;
1901 while (!Queue.empty()) {
1906 bool UseLocal = !R.
empty();
1935 if (S.
isVisible(I) && Visited.insert(Nom).second)
1936 Queue.push_back(Nom);
1941 if (FoundTag && FoundNonTag)
1961 template<
typename InputIterator>
1964 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1967 if (isa<CXXMethodDecl>(D)) {
1969 bool AllMethodsAreStatic =
true;
1970 for(; First != Last; ++First) {
1971 D = (*First)->getUnderlyingDecl();
1973 if (!isa<CXXMethodDecl>(D)) {
1974 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1978 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1979 AllMethodsAreStatic =
false;
1984 if (AllMethodsAreStatic)
2014 bool InUnqualifiedLookup) {
2015 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2021 assert((!isa<TagDecl>(LookupCtx) ||
2023 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
2024 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
2025 "Declaration context must already be complete!");
2027 struct QualifiedLookupInScope {
2031 QualifiedLookupInScope(
DeclContext *ctx) : Context(ctx) {
2034 ~QualifiedLookupInScope() {
2041 if (isa<CXXRecordDecl>(LookupCtx))
2087 case LookupObjCImplicitSelfParam:
2088 case LookupOrdinaryName:
2089 case LookupMemberName:
2090 case LookupRedeclarationWithLinkage:
2091 case LookupLocalFriendName:
2103 case LookupOMPReductionName:
2107 case LookupUsingDeclName:
2110 case LookupOperatorName:
2111 case LookupNamespaceName:
2112 case LookupObjCProtocolName:
2117 case LookupNestedNameSpecifierName:
2125 return BaseCallback(Specifier, Path, Name);
2139 int SubobjectNumber = 0;
2143 Path != PathEnd; ++Path) {
2151 if (SubobjectType.
isNull()) {
2168 while (FirstD != FirstPath->Decls.end() &&
2170 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2171 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2178 if (FirstD == FirstPath->Decls.end() &&
2234 return LookupInSuper(R, NNS->getAsRecordDecl());
2237 return LookupQualifiedName(R, LookupCtx);
2260 bool AllowBuiltinCreation,
bool EnteringContext) {
2267 if (SS && SS->
isSet()) {
2272 if (
DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
2279 return LookupQualifiedName(R, DC);
2291 return LookupName(R, S, AllowBuiltinCreation);
2308 for (
const auto &BaseSpec : Class->
bases()) {
2310 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2313 LookupQualifiedName(Result, RD);
2317 for (
auto I = Result.begin(), E = Result.end(); I != E; ++I) {
2323 Result.suppressDiagnostics();
2337 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2346 QualType SubobjectType = Paths->
front().back().Base->getType();
2347 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2348 << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths)
2352 while (isa<CXXMethodDecl>(*Found) &&
2353 cast<CXXMethodDecl>(*Found)->isStatic())
2356 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2361 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2362 << Name << LookupRange;
2365 std::set<Decl *> DeclsPrinted;
2367 PathEnd = Paths->
end();
2368 Path != PathEnd; ++Path) {
2369 Decl *D = Path->Decls.front();
2370 if (DeclsPrinted.insert(D).second)
2377 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2379 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2381 for (
auto *D : Result)
2382 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2383 TagDecls.insert(TD);
2384 Diag(TD->getLocation(), diag::note_hidden_tag);
2387 for (
auto *D : Result)
2388 if (!isa<TagDecl>(D))
2394 if (TagDecls.count(F.
next()))
2402 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2404 for (
auto *D : Result)
2412 struct AssociatedLookup {
2416 : S(S), Namespaces(Namespaces), Classes(Classes),
2417 InstantiationLoc(InstantiationLoc) {
2474 DeclContext *Ctx = ClassTemplate->getDeclContext();
2475 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2476 Result.Classes.insert(EnclosingClass);
2506 if (Class->
getDeclName() == Result.S.VAListTagName)
2519 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2520 Result.Classes.insert(EnclosingClass);
2530 if (!Result.Classes.insert(Class))
2543 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2544 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2545 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2546 Result.Classes.insert(EnclosingClass);
2551 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
2556 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2557 Result.S.Context.getRecordType(Class)))
2563 Bases.push_back(Class);
2564 while (!Bases.empty()) {
2566 Class = Bases.pop_back_val();
2569 for (
const auto &
Base : Class->
bases()) {
2580 if (Result.Classes.insert(BaseDecl)) {
2587 Bases.push_back(BaseDecl);
2615 #define TYPE(Class, Base) 2616 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 2617 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 2618 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 2619 #define ABSTRACT_TYPE(Class, Base) 2620 #include "clang/AST/TypeNodes.def" 2631 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2633 case Type::ConstantArray:
2634 case Type::IncompleteArray:
2635 case Type::VariableArray:
2636 T = cast<ArrayType>(T)->getElementType().getTypePtr();
2649 case Type::Record: {
2651 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2661 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2664 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2665 Result.Classes.insert(EnclosingClass);
2676 case Type::FunctionProto: {
2679 Queue.push_back(Arg.getTypePtr());
2683 case Type::FunctionNoProto: {
2698 case Type::MemberPointer: {
2702 Queue.push_back(MemberPtr->
getClass());
2710 case Type::BlockPointer:
2711 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2716 case Type::LValueReference:
2717 case Type::RValueReference:
2718 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2723 case Type::ExtVector:
2729 case Type::DeducedTemplateSpecialization:
2735 case Type::ObjCObject:
2736 case Type::ObjCInterface:
2737 case Type::ObjCObjectPointer:
2738 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2744 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2747 T = cast<PipeType>(T)->getElementType().getTypePtr();
2753 T = Queue.pop_back_val();
2768 AssociatedNamespaces.clear();
2769 AssociatedClasses.clear();
2771 AssociatedLookup Result(*
this, InstantiationLoc,
2772 AssociatedNamespaces, AssociatedClasses);
2781 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2782 Expr *Arg = Args[ArgIdx];
2798 if (unaryOp->getOpcode() == UO_AddrOf)
2799 Arg = unaryOp->getSubExpr();
2804 for (
const auto *D : ULE->
decls()) {
2828 Decl *D = LookupSingleName(TUScope, II, IdLoc,
2829 LookupObjCProtocolName, Redecl);
2830 return cast_or_null<ObjCProtocolDecl>(D);
2844 LookupName(Operators, S);
2846 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2856 bool VolatileThis) {
2858 "doing special member lookup into record that isn't fully complete");
2860 if (RValueThis || ConstThis || VolatileThis)
2861 assert((SM == CXXCopyAssignment || SM == CXXMoveAssignment) &&
2862 "constructors and destructors always have unqualified lvalue this");
2863 if (ConstArg || VolatileArg)
2864 assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
2865 "parameter-less special members can't have qualified arguments");
2870 llvm::FoldingSetNodeID
ID;
2873 ID.AddInteger(ConstArg);
2874 ID.AddInteger(VolatileArg);
2875 ID.AddInteger(RValueThis);
2876 ID.AddInteger(ConstThis);
2877 ID.AddInteger(VolatileThis);
2881 SpecialMemberCache.FindNodeOrInsertPos(ID, InsertPoint);
2889 SpecialMemberCache.InsertNode(Result, InsertPoint);
2891 if (SM == CXXDestructor) {
2893 DeclareImplicitDestructor(RD);
2895 assert(DD &&
"record without a destructor");
2898 SpecialMemberOverloadResult::NoMemberOrDeleted :
2899 SpecialMemberOverloadResult::Success);
2907 Expr *Arg =
nullptr;
2913 if (SM == CXXDefaultConstructor) {
2917 DeclareImplicitDefaultConstructor(RD);
2919 if (SM == CXXCopyConstructor || SM == CXXMoveConstructor) {
2922 DeclareImplicitCopyConstructor(RD);
2924 DeclareImplicitMoveConstructor(RD);
2928 DeclareImplicitCopyAssignment(RD);
2930 DeclareImplicitMoveAssignment(RD);
2945 if (SM == CXXCopyConstructor || SM == CXXCopyAssignment)
2953 if (SM != CXXDefaultConstructor) {
2979 assert(SM == CXXDefaultConstructor &&
2980 "lookup for a constructor or assignment operator was empty");
2982 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
2990 for (
NamedDecl *CandDecl : Candidates) {
2991 if (CandDecl->isInvalidDecl())
2997 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
2998 AddMethodCandidate(M, Cand, RD, ThisTy, Classification,
2999 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3001 AddOverloadCandidate(CtorInfo.Constructor, CtorInfo.FoundDecl,
3002 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3004 AddOverloadCandidate(M, Cand, llvm::makeArrayRef(&Arg, NumArgs), OCS,
3008 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3009 AddMethodTemplateCandidate(
3010 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
3011 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3013 AddTemplateOverloadCandidate(
3014 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
3015 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3017 AddTemplateOverloadCandidate(
3018 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3020 assert(isa<UsingDecl>(Cand.
getDecl()) &&
3021 "illegal Kind of operator = Decl");
3028 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3029 Result->
setKind(SpecialMemberOverloadResult::Success);
3033 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3034 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3039 Result->
setKind(SpecialMemberOverloadResult::Ambiguous);
3044 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3054 LookupSpecialMember(Class, CXXDefaultConstructor,
false,
false,
false,
3057 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3064 "non-const, non-volatile qualifiers for copy ctor arg");
3069 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3079 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3087 DeclareImplicitDefaultConstructor(Class);
3089 DeclareImplicitCopyConstructor(Class);
3091 DeclareImplicitMoveConstructor(Class);
3096 return Class->
lookup(Name);
3101 unsigned Quals,
bool RValueThis,
3102 unsigned ThisQuals) {
3104 "non-const, non-volatile qualifiers for copy assignment arg");
3106 "non-const, non-volatile qualifiers for copy assignment this");
3110 ThisQuals & Qualifiers::Const,
3111 ThisQuals & Qualifiers::Volatile);
3120 unsigned ThisQuals) {
3122 "non-const, non-volatile qualifiers for copy assignment this");
3126 ThisQuals & Qualifiers::Const,
3127 ThisQuals & Qualifiers::Volatile);
3139 return cast<CXXDestructorDecl>(LookupSpecialMember(Class, CXXDestructor,
3140 false,
false,
false,
3141 false,
false).getMethod());
3153 bool AllowRaw,
bool AllowTemplate,
3154 bool AllowStringTemplate,
bool DiagnoseMissing) {
3157 "literal operator lookup can't be ambiguous");
3162 bool FoundRaw =
false;
3163 bool FoundTemplate =
false;
3164 bool FoundStringTemplate =
false;
3165 bool FoundExactMatch =
false;
3167 while (F.hasNext()) {
3170 D = USD->getTargetDecl();
3179 bool IsTemplate =
false;
3180 bool IsStringTemplate =
false;
3181 bool IsExactMatch =
false;
3184 if (FD->getNumParams() == 1 &&
3185 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3187 else if (FD->getNumParams() == ArgTys.size()) {
3188 IsExactMatch =
true;
3189 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3190 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3192 IsExactMatch =
false;
3200 if (Params->
size() == 1)
3203 IsStringTemplate =
true;
3207 FoundExactMatch =
true;
3209 AllowTemplate =
false;
3210 AllowStringTemplate =
false;
3211 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3215 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3217 }
else if (AllowRaw && IsRaw) {
3219 }
else if (AllowTemplate && IsTemplate) {
3220 FoundTemplate =
true;
3221 }
else if (AllowStringTemplate && IsStringTemplate) {
3222 FoundStringTemplate =
true;
3233 if (FoundExactMatch)
3238 if (FoundRaw && FoundTemplate) {
3241 NoteOverloadCandidate(*I, (*I)->getUnderlyingDecl()->getAsFunction());
3249 return LOLR_Template;
3251 if (FoundStringTemplate)
3252 return LOLR_StringTemplate;
3255 if (DiagnoseMissing) {
3258 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3259 << (AllowTemplate || AllowStringTemplate);
3263 return LOLR_ErrorNoDiagnostic;
3271 if (Old ==
nullptr || Old == New) {
3286 if (!Cursor)
return;
3289 if (Cursor == OldFD)
break;
3303 FindAssociatedClassesAndNamespaces(Loc, Args,
3304 AssociatedNamespaces,
3318 for (
auto *NS : AssociatedNamespaces) {
3332 auto *Underlying = D;
3333 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3334 Underlying = USD->getTargetDecl();
3336 if (!isa<FunctionDecl>(Underlying) &&
3337 !isa<FunctionTemplateDecl>(Underlying))
3343 bool Visible =
false;
3353 if (AssociatedClasses.count(RD) && isVisible(D)) {
3362 Result.
insert(Underlying);
3376 class ShadowContextRAII;
3378 class VisibleDeclsRecord {
3383 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3388 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3391 std::list<ShadowMap> ShadowMaps;
3394 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3396 friend class ShadowContextRAII;
3402 return !VisitedContexts.insert(Ctx).second;
3406 return VisitedContexts.count(Ctx);
3418 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3423 class ShadowContextRAII {
3424 VisibleDeclsRecord &Visible;
3426 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3429 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3430 Visible.ShadowMaps.emplace_back();
3433 ~ShadowContextRAII() {
3434 Visible.ShadowMaps.pop_back();
3442 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3443 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3444 SM != SMEnd; ++
SM) {
3445 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
3446 if (Pos == SM->end())
3449 for (
auto *D : Pos->second) {
3467 SM == ShadowMaps.rbegin())
3472 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
3473 cast<UsingShadowDecl>(ND)->getUsingDecl() == D)
3485 bool QualifiedNameLookup,
3488 VisibleDeclsRecord &Visited,
3489 bool IncludeDependentBases,
3490 bool LoadExternal) {
3501 if (isa<TranslationUnitDecl>(Ctx) &&
3504 auto &Idents = S.Context.Idents;
3509 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3510 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3515 for (
const auto &Ident : Idents) {
3516 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3517 E = S.IdResolver.end();
3519 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3521 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3535 bool Load = LoadExternal ||
3536 !(isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx));
3543 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3550 if (QualifiedNameLookup) {
3551 ShadowContextRAII Shadow(Visited);
3556 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3557 IncludeDependentBases, LoadExternal);
3563 if (!Record->hasDefinition())
3566 for (
const auto &B : Record->bases()) {
3571 if (!IncludeDependentBases) {
3584 RD = TD->getTemplatedDecl();
3589 RD = Record->getDecl();
3612 ShadowContextRAII Shadow(Visited);
3614 Consumer, Visited, IncludeDependentBases,
3622 for (
auto *Cat : IFace->visible_categories()) {
3623 ShadowContextRAII Shadow(Visited);
3625 Visited, IncludeDependentBases, LoadExternal);
3629 for (
auto *I : IFace->all_referenced_protocols()) {
3630 ShadowContextRAII Shadow(Visited);
3632 Visited, IncludeDependentBases, LoadExternal);
3636 if (IFace->getSuperClass()) {
3637 ShadowContextRAII Shadow(Visited);
3639 true, Consumer, Visited, IncludeDependentBases,
3645 if (IFace->getImplementation()) {
3646 ShadowContextRAII Shadow(Visited);
3648 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3649 IncludeDependentBases, LoadExternal);
3652 for (
auto *I : Protocol->protocols()) {
3653 ShadowContextRAII Shadow(Visited);
3655 Visited, IncludeDependentBases, LoadExternal);
3658 for (
auto *I :
Category->protocols()) {
3659 ShadowContextRAII Shadow(Visited);
3661 Visited, IncludeDependentBases, LoadExternal);
3665 if (
Category->getImplementation()) {
3666 ShadowContextRAII Shadow(Visited);
3668 QualifiedNameLookup,
true, Consumer, Visited,
3669 IncludeDependentBases, LoadExternal);
3675 UnqualUsingDirectiveSet &UDirs,
3677 VisibleDeclsRecord &Visited,
3678 bool LoadExternal) {
3684 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3686 FindLocalExternScope FindLocals(Result);
3690 for (
Decl *D : ScopeDecls) {
3691 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3693 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3711 if (Method->isInstanceMethod()) {
3717 false, Consumer, Visited,
3718 false, LoadExternal);
3732 false, Consumer, Visited,
3733 false, LoadExternal);
3747 false, Consumer, Visited,
3748 false, LoadExternal);
3754 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3757 false, Consumer, Visited,
3758 false, LoadExternal);
3762 ShadowContextRAII Shadow(Visited);
3769 bool IncludeGlobalScope,
bool LoadExternal) {
3773 UnqualUsingDirectiveSet UDirs(*
this);
3779 UDirs.visitScopeChain(Initial, S);
3786 VisibleDeclsRecord Visited;
3787 if (!IncludeGlobalScope)
3789 ShadowContextRAII Shadow(Visited);
3795 bool IncludeGlobalScope,
3796 bool IncludeDependentBases,
bool LoadExternal) {
3799 VisibleDeclsRecord Visited;
3800 if (!IncludeGlobalScope)
3802 ShadowContextRAII Shadow(Visited);
3804 false, Consumer, Visited,
3805 IncludeDependentBases, LoadExternal);
3820 Scope *S = CurScope;
3821 PushOnScopeChains(Res, S,
true);
3822 return cast<LabelDecl>(Res);
3826 Res = LookupSingleName(CurScope, II, Loc, LookupLabel, NotForRedeclaration);
3829 if (Res && Res->getDeclContext() != CurContext)
3835 assert(S &&
"Not in a function?");
3836 PushOnScopeChains(Res, S,
true);
3838 return cast<LabelDecl>(Res);
3856 bool EnteringContext,
3857 bool isObjCIvarLookup,
3866 for (; DI != DE; ++DI)
3876 bool AnyVisibleDecls = !NewDecls.empty();
3878 for (; DI != DE; ++DI) {
3880 if (!AnyVisibleDecls) {
3882 AnyVisibleDecls =
true;
3885 NewDecls.push_back(*DI);
3886 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3887 NewDecls.push_back(*DI);
3890 if (NewDecls.empty())
3907 Identifiers.clear();
3937 Identifiers.push_back(II);
3964 addName(Name,
nullptr);
3970 addName(Keyword,
nullptr,
nullptr,
true);
3973 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3977 StringRef TypoStr = Typo->getName();
3978 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
3979 if (MinED && TypoStr.size() / MinED < 3)
3984 unsigned UpperBound = (TypoStr.size() + 2) / 3;
3985 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
3986 if (ED > UpperBound)
return;
3990 TC.setCorrectionRange(
nullptr, Result.getLookupNameInfo());
3997 StringRef TypoStr = Typo->getName();
4003 if (TypoStr.size() < 3 &&
4004 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4017 if (!CList.empty() && !CList.back().isResolved())
4021 for (TypoResultList::iterator RI = CList.begin(), RIEnd = CList.end();
4022 RI != RIEnd; ++RI) {
4027 if (RI->getCorrectionDecl() == NewND) {
4034 if (CList.empty() || Correction.
isResolved())
4035 CList.push_back(Correction);
4038 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4042 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4043 SearchNamespaces =
true;
4045 for (
auto KNPair : KnownNamespaces)
4046 Namespaces.addNameSpecifier(KNPair.first);
4048 bool SSIsTemplate =
false;
4052 SSIsTemplate = T->
getTypeClass() == Type::TemplateSpecialization;
4058 for (
unsigned I = 0; I != Types.size(); ++I) {
4059 const auto *TI = Types[I];
4061 CD = CD->getCanonicalDecl();
4062 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4063 !CD->isUnion() && CD->getIdentifier() &&
4064 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4065 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4066 Namespaces.addNameSpecifier(CD);
4072 if (++CurrentTCIndex < ValidatedCorrections.size())
4073 return ValidatedCorrections[CurrentTCIndex];
4075 CurrentTCIndex = ValidatedCorrections.size();
4076 while (!CorrectionResults.empty()) {
4077 auto DI = CorrectionResults.
begin();
4078 if (DI->second.empty()) {
4079 CorrectionResults.erase(DI);
4083 auto RI = DI->second.begin();
4084 if (RI->second.empty()) {
4085 DI->second.erase(RI);
4086 performQualifiedLookups();
4092 ValidatedCorrections.push_back(TC);
4093 return ValidatedCorrections[CurrentTCIndex];
4096 return ValidatedCorrections[0];
4099 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4106 CorrectionValidator->IsObjCIvarLookup,
4108 switch (Result.getResultKind()) {
4118 if (TempMemberContext) {
4121 TempMemberContext =
nullptr;
4124 if (SearchNamespaces)
4125 QualifiedResults.push_back(Candidate);
4135 for (
auto *TRD : Result)
4139 if (SearchNamespaces)
4140 QualifiedResults.push_back(Candidate);
4149 void TypoCorrectionConsumer::performQualifiedLookups() {
4150 unsigned TypoLen = Typo->getName().size();
4152 for (
const auto &NSI : Namespaces) {
4154 const Type *NSType = NSI.NameSpecifier->getAsType();
4162 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4176 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4177 TypoLen / TmpED < 3)
4181 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4187 switch (Result.getResultKind()) {
4192 std::string OldQualified;
4193 llvm::raw_string_ostream OldOStream(OldQualified);
4195 OldOStream << Typo->getName();
4199 if (OldOStream.str() == NewQualified)
4203 TRD != TRDEnd; ++TRD) {
4224 QualifiedResults.clear();
4227 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4229 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4231 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4232 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4240 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4241 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4248 DistanceMap[1].push_back(SI);
4251 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4253 assert(Start &&
"Building a context chain from a null context");
4254 DeclContextList Chain;
4266 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4268 unsigned NumSpecifiers = 0;
4270 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4273 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4275 RD->getTypeForDecl());
4279 return NumSpecifiers;
4282 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4285 unsigned NumSpecifiers = 0;
4286 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4287 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4290 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4291 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C)
4293 NamespaceDeclChain.pop_back();
4297 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4300 if (NamespaceDeclChain.empty()) {
4304 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4306 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4308 bool SameNameSpecifier =
false;
4309 if (std::find(CurNameSpecifierIdentifiers.begin(),
4310 CurNameSpecifierIdentifiers.end(),
4311 Name) != CurNameSpecifierIdentifiers.end()) {
4312 std::string NewNameSpecifier;
4313 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4317 SpecifierOStream.flush();
4318 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4320 if (SameNameSpecifier ||
4321 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4322 Name) != CurContextIdentifiers.end()) {
4326 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4334 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4337 NumSpecifiers = llvm::ComputeEditDistance(
4338 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4339 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4342 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4343 DistanceMap[NumSpecifiers].push_back(SI);
4352 bool EnteringContext,
4353 bool isObjCIvarLookup,
4359 if (MemberContext) {
4361 if (isObjCIvarLookup) {
4362 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4387 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4392 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4404 bool AfterNestedNameSpecifier) {
4405 if (AfterNestedNameSpecifier) {
4418 static const char *
const CTypeSpecs[] = {
4419 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4420 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4421 "_Complex",
"_Imaginary",
4423 "extern",
"inline",
"static",
"typedef" 4426 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4427 for (
unsigned I = 0; I != NumCTypeSpecs; ++I)
4454 static const char *
const CastableTypeSpecs[] = {
4455 "char",
"double",
"float",
"int",
"long",
"short",
4456 "signed",
"unsigned",
"void" 4458 for (
auto *kw : CastableTypeSpecs)
4477 static const char *
const CXXExprs[] = {
4478 "delete",
"new",
"operator",
"throw",
"typeid" 4480 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4481 for (
unsigned I = 0; I != NumCXXExprs; ++I)
4484 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4485 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4504 static const char *
const CStmts[] = {
4505 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4506 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4507 for (
unsigned I = 0; I != NumCStmts; ++I)
4552 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4555 std::unique_ptr<CorrectionCandidateCallback> CCC,
4559 if (Diags.hasFatalErrorOccurred() || !getLangOpts().SpellChecking ||
4560 DisableTypoCorrection)
4567 isa<CXXMethodDecl>(CurContext))
4581 if (!CodeSynthesisContexts.empty())
4589 IdentifierSourceLocations::iterator locs = TypoCorrectionFailures.find(Typo);
4590 if (locs != TypoCorrectionFailures.end() &&
4591 locs->second.count(TypoName.
getLoc()))
4597 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->
isStr(
"vector"))
4603 unsigned Limit = getDiagnostics().getDiagnosticOptions().SpellCheckingLimit;
4604 if (Limit && TyposCorrected >= Limit)
4610 if (ErrorRecovery && getLangOpts().Modules &&
4611 getLangOpts().ModulesSearchAll) {
4613 getModuleLoader().lookupMissingImports(Typo->
getName(),
4618 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4619 *
this, TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4623 bool IsUnqualifiedLookup =
false;
4625 if (MemberContext) {
4630 for (
auto *I : OPT->
quals())
4633 }
else if (SS && SS->isSet()) {
4634 QualifiedDC = computeDeclContext(*SS, EnteringContext);
4640 IsUnqualifiedLookup =
true;
4645 bool SearchNamespaces
4646 = getLangOpts().CPlusPlus &&
4647 (IsUnqualifiedLookup || (SS && SS->isSet()));
4649 if (IsUnqualifiedLookup || SearchNamespaces) {
4653 for (
const auto &I : Context.
Idents)
4654 Consumer->FoundName(I.getKey());
4660 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4662 StringRef Name = Iter->Next();
4666 Consumer->FoundName(Name);
4675 if (SearchNamespaces) {
4677 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4679 LoadedExternalKnownNamespaces =
true;
4680 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces);
4681 for (
auto *N : ExternalKnownNamespaces)
4682 KnownNamespaces[N] =
true;
4685 Consumer->addNamespaces(KnownNamespaces);
4725 std::unique_ptr<CorrectionCandidateCallback> CCC,
4728 bool EnteringContext,
4730 bool RecordFailure) {
4731 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4735 if (ExternalSource) {
4737 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4745 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4748 auto Consumer = makeTypoCorrectionConsumer(
4749 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4750 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4756 if (Consumer->empty())
4757 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4761 unsigned ED = Consumer->getBestEditDistance(
true);
4762 unsigned TypoLen = Typo->
getName().size();
4763 if (ED > 0 && TypoLen / ED < 3)
4764 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4769 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4773 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4777 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4781 if (!SecondBestTC ||
4782 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4788 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4794 }
else if (SecondBestTC && ObjCMessageReceiver) {
4798 if (BestTC.getCorrection().getAsString() !=
"super") {
4800 BestTC = SecondBestTC;
4801 else if ((*Consumer)[
"super"].front().isKeyword())
4802 BestTC = (*Consumer)[
"super"].front();
4806 if (BestTC.getEditDistance() == 0 ||
4807 BestTC.getCorrection().getAsString() !=
"super")
4808 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4817 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4861 std::unique_ptr<CorrectionCandidateCallback> CCC,
4865 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4867 auto Consumer = makeTypoCorrectionConsumer(
4868 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4869 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4873 if (ExternalSource && Consumer) {
4874 ExternalTypo = ExternalSource->CorrectTypo(
4875 TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(),
4876 MemberContext, EnteringContext, OPT);
4878 Consumer->addCorrection(ExternalTypo);
4881 if (!Consumer || Consumer->empty())
4886 unsigned ED = Consumer->getBestEditDistance(
true);
4888 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
4891 ExprEvalContexts.back().NumTypos++;
4892 return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC));
4899 CorrectionDecls.clear();
4901 CorrectionDecls.push_back(CDecl);
4903 if (!CorrectionName)
4908 if (CorrectionNameSpec) {
4909 std::string tmpBuffer;
4910 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4912 PrefixOStream << CorrectionName;
4913 return PrefixOStream.str();
4916 return CorrectionName.getAsString();
4925 return WantTypeSpecifiers || WantExpressionKeywords || WantCXXNamedCasts ||
4926 WantRemainingKeywords || WantObjCSuper;
4928 bool HasNonType =
false;
4929 bool HasStaticMethod =
false;
4930 bool HasNonStaticMethod =
false;
4931 for (
Decl *D : candidate) {
4933 D = FTD->getTemplatedDecl();
4935 if (Method->isStatic())
4936 HasStaticMethod =
true;
4938 HasNonStaticMethod =
true;
4940 if (!isa<TypeDecl>(D))
4944 if (IsAddressOfOperand && HasNonStaticMethod && !HasStaticMethod &&
4945 !candidate.getCorrectionSpecifier())
4948 return WantTypeSpecifiers || HasNonType;
4952 bool HasExplicitTemplateArgs,
4954 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4955 CurContext(SemaRef.CurContext), MemberFn(ME) {
4965 for (
auto *
C : candidate) {
4969 FD = FTD->getTemplatedDecl();
4970 if (!HasExplicitTemplateArgs && !FD) {
4971 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4975 QualType ValType = cast<ValueDecl>(ND)->getType();
4981 if (FPT->getNumParams() == NumArgs)
4997 if (MemberFn || !MD->isStatic()) {
5000 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
5001 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
5016 bool ErrorRecovery) {
5017 diagnoseTypo(Correction, TypoDiag, PDiag(diag::note_previous_decl),
5024 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
5025 return VD->getDefinition();
5027 return FD->getDefinition();
5028 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
5029 return TD->getDefinition();
5031 return ID->getDefinition();
5033 return PD->getDefinition();
5047 Module *Owner = getOwningModule(Def);
5048 assert(Owner &&
"definition of hidden declaration is not in a module");
5051 OwningModules.push_back(Owner);
5053 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5055 diagnoseMissingImport(Loc, Decl, Decl->
getLocation(), OwningModules, MIK,
5066 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
5073 assert(!Modules.empty());
5077 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5078 for (
auto *M : Modules)
5079 if (UniqueModuleSet.insert(M).second)
5080 UniqueModules.push_back(M);
5081 Modules = UniqueModules;
5083 if (Modules.size() > 1) {
5084 std::string ModuleList;
5086 for (
Module *M : Modules) {
5087 ModuleList +=
"\n ";
5088 if (++N == 5 && N != Modules.size()) {
5089 ModuleList +=
"[...]";
5092 ModuleList += M->getFullModuleName();
5095 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5096 << (int)MIK << Decl << ModuleList;
5097 }
else if (
const FileEntry *E = PP.getModuleHeaderToIncludeForDiagnostics(
5098 UseLoc, Modules[0], DeclLoc)) {
5104 Diag(UseLoc, diag::err_module_unimported_use_header)
5105 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5109 Diag(UseLoc, diag::err_module_unimported_use)
5110 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5115 case MissingImportKind::Declaration:
5116 DiagID = diag::note_previous_declaration;
5118 case MissingImportKind::Definition:
5119 DiagID = diag::note_previous_definition;
5121 case MissingImportKind::DefaultArgument:
5122 DiagID = diag::note_default_argument_declared_here;
5124 case MissingImportKind::ExplicitSpecialization:
5125 DiagID = diag::note_explicit_specialization_declared_here;
5127 case MissingImportKind::PartialSpecialization:
5128 DiagID = diag::note_partial_specialization_declared_here;
5131 Diag(DeclLoc, DiagID);
5135 createImplicitModuleImportForErrorRecovery(UseLoc, Modules[0]);
5153 bool ErrorRecovery) {
5154 std::string CorrectedStr = Correction.
getAsString(getLangOpts());
5155 std::string CorrectedQuotedStr = Correction.
getQuoted(getLangOpts());
5162 assert(Decl &&
"import required but no declaration to import");
5165 MissingImportKind::Declaration, ErrorRecovery);
5170 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5175 Diag(ChosenDecl->getLocation(), PrevNote)
5176 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5183 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5186 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5188 auto &
State = DelayedTypos[TE];
5189 State.Consumer = std::move(TCC);
5190 State.DiagHandler = std::move(TDG);
5191 State.RecoveryHandler = std::move(TRC);
5196 auto Entry = DelayedTypos.find(TE);
5197 assert(Entry != DelayedTypos.end() &&
5198 "Failed to get the state for a TypoExpr!");
5199 return Entry->second;
5203 DelayedTypos.erase(TE);
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Defines the clang::ASTContext interface.
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
Represents a function declaration or definition.
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Name lookup found a set of overloaded functions that met the criteria.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
SourceRange getCorrectionRange() const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases, bool LoadExternal)
Template argument deduction was successful.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
AmbiguityKind getAmbiguityKind() const
Look up the name of an Objective-C protocol.
Filter makeFilter()
Create a filter for this result set.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
void erase()
Erase the last element returned from this iterator.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Decl - This represents one declaration (or definition), e.g.
__DEVICE__ long long abs(long long __n)
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
Defines the C++ template declaration subclasses.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void swap(CXXBasePaths &Other)
Swap this data structure's contents with another CXXBasePaths object.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules, Filter F)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
The base class of the type hierarchy.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
MissingImportKind
Kinds of missing import.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Ambiguous candidates found.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
Look up of a name that precedes the '::' scope resolution operator in C++.
void makeKeyword()
Mark this TypoCorrection as being a keyword.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
void setCorrectionSpecifier(NestedNameSpecifier *NNS)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
lookups_range noload_lookups(bool PreserveInternalState) const
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
An identifier, stored as an IdentifierInfo*.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
std::list< CXXBasePath >::iterator paths_iterator
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
static bool LookupBuiltin(Sema &S, LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Represents a variable declaration or definition.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last)
Determine whether the given set of member declarations contains only static members, nested types, and enumerators.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare reduction member wi...
A namespace, stored as a NamespaceDecl*.
unsigned getDiagID() const
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Look up an ordinary name that is going to be redeclared as a name with linkage.
Defines the clang::Expr interface and subclasses for C++ expressions.
void addKeywordResult(StringRef Keyword)
bool WantExpressionKeywords
void setMethod(CXXMethodDecl *MD)
ModuleKind Kind
The kind of this module.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Types, declared with 'struct foo', typedefs, etc.
Represents a struct/union/class.
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
std::string getQuoted(const LangOptions &LO) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
The results of name lookup within a DeclContext.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
NameKind getNameKind() const
Determine what kind of name this is.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
This declaration is a friend function.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
conversion_iterator conversion_end() const
bool isReferenceType() const
The iterator over UnresolvedSets.
void addCorrectionDecl(NamedDecl *CDecl)
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the Decla...
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
LookupResultKind getResultKind() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
Describes a module or submodule.
SpecialMemberOverloadResult - The overloading result for a special member function.
void setCallbackDistance(unsigned ED)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
DeclClass * getAsSingle() const
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
Look up implicit 'self' parameter of an objective-c method.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents the results of name lookup.
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Namespaces, declared with 'namespace foo {}'.
static void LookupPotentialTypoResult(Sema &SemaRef, LookupResult &Res, IdentifierInfo *Name, Scope *S, CXXScopeSpec *SS, DeclContext *MemberContext, bool EnteringContext, bool isObjCIvarLookup, bool FindHidden)
Perform name lookup for a possible result for typo correction.
HeaderSearch & getHeaderSearchInfo() const
void setQualifierDistance(unsigned ED)
bool hasTagIdentifierNamespace() const
Succeeded, but refers to a deleted function.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
Look up all declarations in a scope with the given name, including resolved using declarations...
static NamedDecl * getDefinitionToImport(NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
const clang::PrintingPolicy & getPrintingPolicy() const
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
Represents a declaration of a type.
A set of unresolved declarations.
static unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, bool Redeclaration)
Module * Parent
The parent of this module.
const Type * getClass() const
Look up the name of an OpenMP user-defined reduction operation.
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Scope - A scope is a transient data structure that is used while parsing the program.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
using_directives_range using_directives()
void append(iterator I, iterator E)
Represents a C++ nested-name-specifier or a global scope specifier.
base_class_iterator bases_begin()
Represents an Objective-C protocol declaration.
lookups_range lookups() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
const LangOptions & getLangOpts() const
Labels, declared with 'x:' and referenced with 'goto x'.
const TypoCorrection & getNextCorrection()
Return the next typo correction that passes all internal filters and is deemed valid by the consumer'...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Represents an ObjC class declaration.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
ExtInfo withCallingConv(CallingConv cc) const
static const unsigned InvalidDistance
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool WantRemainingKeywords
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
Sema - This implements semantic analysis and AST building for C.
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
This declaration is a C++ operator declared in a non-class context.
virtual void EnteredContext(DeclContext *Ctx)
Callback to inform the client that Sema entered into a new context to find a visible declaration...
bool hasMergedDefinitionInCurrentModule(NamedDecl *Def)
The return type of classify().
DeclarationNameTable DeclarationNames
Provides lookups to, and iteration over, IdentiferInfo objects.
SourceRange getRange() const
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
This declaration is a friend class.
std::string getAsString(const LangOptions &LO) const
static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Callback that looks for any member of a class with the given name.
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr *> Args, ADLResult &Functions)
bool isInlineNamespace() const
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, DeclContext *StartDC)
Perform qualified name lookup in the namespaces nominated by using directives by the given context...
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This represents one expression.
Defines the clang::LangOptions interface.
LookupNameKind
Describes the kind of name lookup to perform.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
llvm::StringRef getAsString(SyncScope S)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to...
DeclContext * getEntity() const
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location...
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
std::string getAsString() const
Retrieve the human-readable string for this name.
This declaration is an OpenMP user defined reduction construction.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D, unsigned IDNS)
Retrieve the visible declaration corresponding to D, if any.
Defines the clang::Preprocessor interface.
void setRequiresImport(bool Req)
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFileContext() const
DeclContext * getDeclContext()
static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name that can...
CXXRecordDecl * getDefinition() const
Overload resolution succeeded.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Represents a C++ template name within the type system.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionOrMethod() const
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void addCorrection(TypoCorrection Correction)
QualType getRecordType(const RecordDecl *Decl) const
static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name...
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
RecordDecl * getDecl() const
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const CXXBaseSpecifier * Base
The base specifier that states the link from a derived class to a base class, which will be followed ...
static Module * getDefiningModule(Sema &S, Decl *Entity)
Find the module in which the given declaration was defined.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
SmallVectorImpl< OverloadCandidate >::iterator iterator
Tag name lookup, which finds the names of enums, classes, structs, and unions.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
param_type_range param_types() const
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
void addVolatile()
Add the volatile type qualifier to this QualType.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
Members, declared with object declarations within tag definitions.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr *> Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
void FoundName(StringRef Name)
Represents the declaration of a label.
Cached information about one file (either on disk or in the virtual file system). ...
bool hasVisibleMergedDefinition(NamedDecl *Def)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Name lookup found an unresolvable value declaration and cannot yet complete.
bool isModuleVisible(const Module *M) const
Determine whether the specified module would be visible to a lookup at the end of this module...
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
ObjCCategoryDecl - Represents a category declaration.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
This is a fragment of the global module within some C++ Modules TS module.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Look up any declaration with any name.
bool isAnyPointerType() const
A class for iterating through a result set and possibly filtering out results.
const TypoExprState & getTypoExprState(TypoExpr *TE) const
Represents one property declaration in an Objective-C interface.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
No entity found met the criteria.
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
const SmallVectorImpl< Type * > & getTypes() const
static bool canHideTag(NamedDecl *D)
Determine whether D can hide a tag declaration.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
A POD class for pairing a NamedDecl* with an access specifier.
StringRef getName() const
Return the actual identifier string.
A class for storing results from argument-dependent lookup.
Represents an element in a path from a derived class to a base class.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Represents a template argument.
static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces, DeclContext *Ctx)
static DeclContext * getContextForScopeMatching(Decl *D)
Get a representative context for a declaration such that two declarations will have the same context ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
std::list< CXXBasePath >::const_iterator const_paths_iterator
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier *NNS, SmallVectorImpl< const IdentifierInfo *> &Identifiers)
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC)
Check whether the declarations found for a typo correction are visible.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static void AddKeywordsToConsumer(Sema &SemaRef, TypoCorrectionConsumer &Consumer, Scope *S, CorrectionCandidateCallback &CCC, bool AfterNestedNameSpecifier)
Add keywords to the consumer as possible typo corrections.
The base class of all kinds of template declarations (e.g., class, function, etc.).
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
void setContextRange(SourceRange SR)
Sets a 'context' source range.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
The template argument is a pack expansion of a template name that was provided for a template templat...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
AccessSpecifier getAccess() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
conversion_iterator conversion_begin() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
static const unsigned MaxTypoDistanceResultSets
A pointer to member type per C++ 8.3.3 - Pointers to members.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
Name lookup found a single declaration that met the criteria.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
BuiltinTemplateDecl * getTypePackElementDecl() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
QualType getCanonicalTypeInternal() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, SourceLocation Loc, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
The template argument is a type.
static bool FindTagMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a tag with the given name...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
Represents a base class of a C++ class.
This is a scope that can contain a declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
llvm::iterator_range< decls_iterator > decls() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isSet() const
Deprecated.
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
ArgKind getKind() const
Return the kind of stored template argument.
static bool isNamespaceOrTranslationUnitScope(Scope *S)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
void setCorrectionDecls(ArrayRef< NamedDecl *> Decls)
Clears the list of NamedDecls and adds the given set.
Represents a C++ struct/union/class.
IdentifierInfo * getTypePackElementName() const
void ClearCorrectionDecls()
Clears the list of NamedDecls.
The template argument is a template name that was provided for a template template parameter...
sema::FunctionScopeInfo * getCurFunction() const
Look up a friend of a local class.
bool setUseQualifiedLookup(bool use=true) const
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
IdentifierInfo * getMakeIntegerSeqName() const
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
base_class_iterator bases_end()
void setCorrectionRange(CXXScopeSpec *SS, const DeclarationNameInfo &TypoName)
void print(raw_ostream &)
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
static bool isPreferredLookupResult(Sema &S, Sema::LookupNameKind Kind, NamedDecl *D, NamedDecl *Existing)
Determine whether D is a better lookup result than Existing, given that they declare the same entity...
AccessSpecifier Access
The access along this inheritance path.
void addNamespaces(const llvm::MapVector< NamespaceDecl *, bool > &KnownNamespaces)
Set-up method to add to the consumer the set of namespaces to use in performing corrections to nested...
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
This declaration is a function-local extern declaration of a variable or function.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
Represents a type template specialization; the template must be a class template, a type alias templa...
NamedDecl * getMostRecentDecl()
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
__DEVICE__ int min(int __a, int __b)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
No viable function found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static std::pair< DeclContext *, bool > findOuterContext(Scope *S)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
A trivial tuple used to represent a source range.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
This represents a decl that may have a name.
bool isTranslationUnit() const
Represents C++ using-directive.
SourceLocation getNameLoc() const
Gets the location of the identifier.
static bool isInCurrentModule(const Module *M, const LangOptions &LangOpts)
Determine whether the module M is part of the current module from the perspective of a module-private...
Look up of an operator name (e.g., operator+) for use with operator overloading.
static bool CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, DeclContext *NS, UnqualUsingDirectiveSet &UDirs)
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getBegin() const
void WillReplaceSpecifier(bool ForceReplacement)
bool WantFunctionLikeCasts
ExceptionSpecInfo ExceptionSpec
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
iterator - Iterate over the decls of a specified declaration name.
void setFindLocalExtern(bool FindLocalExtern)
SourceLocation getLocation() const
QualType getPointeeType() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isBeingDefined() const
Return true if this decl is currently being defined.
static bool isCandidateViable(CorrectionCandidateCallback &CCC, TypoCorrection &Candidate)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
This declaration is a using declaration.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on #pragma clang __debug dump II.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
ArrayRef< PartialDiagnostic > getExtraDiagnostics() const
QualType getType() const
Retrieves the type of the base class.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.