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 #include "OpenCLBuiltins.inc" 52 using namespace clang;
56 class UnqualUsingEntry {
63 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
67 return CommonAncestor;
76 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
77 return L.getCommonAncestor() < R.getCommonAncestor();
80 bool operator()(
const UnqualUsingEntry &E,
const DeclContext *DC) {
81 return E.getCommonAncestor() < DC;
84 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
85 return DC < E.getCommonAncestor();
92 class UnqualUsingDirectiveSet {
98 llvm::SmallPtrSet<DeclContext*, 8> visited;
101 UnqualUsingDirectiveSet(
Sema &SemaRef) : SemaRef(SemaRef) {}
103 void visitScopeChain(
Scope *S,
Scope *InnermostFileScope) {
121 visit(I, InnermostFileDC);
134 if (!visited.insert(DC).second)
137 addUsingDirectives(DC, EffectiveDC);
145 if (!visited.insert(NS).second)
148 addUsingDirective(UD, EffectiveDC);
149 addUsingDirectives(NS, EffectiveDC);
160 if (SemaRef.
isVisible(UD) && visited.insert(NS).second) {
161 addUsingDirective(UD, EffectiveDC);
169 DC = queue.pop_back_val();
184 while (!Common->
Encloses(EffectiveDC))
191 void done() { llvm::sort(list, UnqualUsingEntry::Comparator()); }
193 typedef ListTy::const_iterator const_iterator;
195 const_iterator begin()
const {
return list.begin(); }
196 const_iterator end()
const {
return list.end(); }
198 llvm::iterator_range<const_iterator>
200 return llvm::make_range(std::equal_range(begin(), end(),
202 UnqualUsingEntry::Comparator()));
211 bool Redeclaration) {
231 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
270 assert(Redeclaration &&
"should only be used for redecl lookup");
297 void LookupResult::configure() {
299 isForRedeclaration());
304 switch (NameInfo.getName().getCXXOverloadedOperator()) {
308 case OO_Array_Delete:
309 getSema().DeclareGlobalNewDelete();
319 if (
unsigned BuiltinID =
Id->getBuiltinID()) {
320 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
326 bool LookupResult::sanity()
const {
328 assert(ResultKind != NotFound || Decls.size() == 0);
329 assert(ResultKind != Found || Decls.size() == 1);
330 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
331 (Decls.size() == 1 &&
332 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
333 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
334 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
335 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
336 Ambiguity == AmbiguousBaseSubobjectTypes)));
337 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
338 (Ambiguity == AmbiguousBaseSubobjectTypes ||
339 Ambiguity == AmbiguousBaseSubobjects)));
370 !isa<UsingShadowDecl>(Existing))
382 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
383 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
384 bool HaveTag = isa<TagDecl>(EUnderlying);
386 return HaveTag != WantTag;
393 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
394 auto *EFD = cast<FunctionDecl>(EUnderlying);
395 unsigned DMin = DFD->getMinRequiredArguments();
396 unsigned EMin = EFD->getMinRequiredArguments();
405 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
406 auto *ETD = cast<TemplateDecl>(EUnderlying);
407 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
408 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
417 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
420 ETD->getTemplateParameters()->getParam(I)) &&
422 DTD->getTemplateParameters()->getParam(I)))
429 if (
VarDecl *DVD = dyn_cast<VarDecl>(DUnderlying)) {
430 VarDecl *EVD = cast<VarDecl>(EUnderlying);
432 !DVD->getType()->isIncompleteType()) {
440 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
449 if (Prev == EUnderlying)
469 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
470 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D) ||
471 isa<UnresolvedUsingValueDecl>(D);
476 unsigned N = Decls.size();
480 assert(ResultKind == NotFound ||
481 ResultKind == NotFoundInCurrentInstantiation);
488 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
489 if (isa<FunctionTemplateDecl>(D))
490 ResultKind = FoundOverloaded;
491 else if (isa<UnresolvedUsingValueDecl>(D))
492 ResultKind = FoundUnresolvedValue;
497 if (ResultKind == Ambiguous)
return;
499 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
500 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
502 bool Ambiguous =
false;
503 bool HasTag =
false, HasFunction =
false;
504 bool HasFunctionTemplate =
false, HasUnresolved =
false;
509 unsigned UniqueTagIndex = 0;
518 Decls[I] = Decls[--N];
528 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
529 QualType T = getSema().Context.getTypeDeclType(TD);
530 auto UniqueResult = UniqueTypes.insert(
532 if (!UniqueResult.second) {
534 ExistingI = UniqueResult.first->second;
541 auto UniqueResult = Unique.insert(std::make_pair(D, I));
542 if (!UniqueResult.second) {
544 ExistingI = UniqueResult.first->second;
553 Decls[*ExistingI] = Decls[I];
554 Decls[I] = Decls[--N];
560 if (isa<UnresolvedUsingValueDecl>(D)) {
561 HasUnresolved =
true;
562 }
else if (isa<TagDecl>(D)) {
567 }
else if (isa<FunctionTemplateDecl>(D)) {
569 HasFunctionTemplate =
true;
570 }
else if (isa<FunctionDecl>(D)) {
573 if (HasNonFunction) {
578 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
580 EquivalentNonFunctions.push_back(D);
581 Decls[I] = Decls[--N];
601 if (N > 1 && HideTags && HasTag && !Ambiguous &&
602 (HasFunction || HasNonFunction || HasUnresolved)) {
603 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
604 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
608 Decls[UniqueTagIndex] = Decls[--N];
615 if (!EquivalentNonFunctions.empty() && !Ambiguous)
616 getSema().diagnoseEquivalentInternalLinkageDeclarations(
617 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
621 if (HasNonFunction && (HasFunction || HasUnresolved))
626 else if (HasUnresolved)
628 else if (N > 1 || HasFunctionTemplate)
634 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
636 for (I = P.
begin(), E = P.
end(); I != E; ++I)
638 DE = I->Decls.end(); DI != DE; ++DI)
645 addDeclsFromBasePaths(*Paths);
647 setAmbiguous(AmbiguousBaseSubobjects);
653 addDeclsFromBasePaths(*Paths);
655 setAmbiguous(AmbiguousBaseSubobjectTypes);
659 Out << Decls.size() <<
" result(s)";
660 if (isAmbiguous()) Out <<
", ambiguous";
661 if (Paths) Out <<
", base paths present";
663 for (
iterator I = begin(), E = end(); I != E; ++I) {
670 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
690 for (
unsigned i = 0;
i < Len; ++
i) {
691 const OpenCLBuiltinDecl &
Decl = OpenCLBuiltins[Index - 1 +
i];
695 if (Context.
getLangOpts().OpenCLVersion < Decl.Version)
702 QualType RT = OCL2Qual(Context, OpenCLSignature[Decl.ArgTableIndex]);
705 for (
unsigned I = 1; I < Decl.NumArgs; I++) {
706 QualType Ty = OCL2Qual(Context, OpenCLSignature[Decl.ArgTableIndex + I]);
707 ArgTypes.push_back(Ty);
725 for (
unsigned i = 0, e = FT->getNumParams();
i != e; ++
i) {
731 Params.push_back(Parm);
733 New->setParams(Params);
736 New->
addAttr(OverloadableAttr::CreateImplicit(Context));
738 if (strlen(Decl.Extension))
773 auto Index = isOpenCLBuiltin(II->
getName());
819 DeclareImplicitDefaultConstructor(Class);
823 DeclareImplicitCopyConstructor(Class);
827 DeclareImplicitCopyAssignment(Class);
829 if (getLangOpts().CPlusPlus11) {
832 DeclareImplicitMoveConstructor(Class);
836 DeclareImplicitMoveAssignment(Class);
841 DeclareImplicitDestructor(Class);
873 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
876 if (Record->needsImplicitDefaultConstructor())
878 if (Record->needsImplicitCopyConstructor())
881 Record->needsImplicitMoveConstructor())
887 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
888 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
897 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
900 if (Record->needsImplicitCopyAssignment())
903 Record->needsImplicitMoveAssignment())
943 !isa<CXXRecordDecl>(DC))
957 auto *ContainedDeducedType =
961 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
995 assert(ConvProto &&
"Nonsensical conversion function template type");
1010 Specialization, Info)
1023 DeclContext *NS, UnqualUsingDirectiveSet &UDirs) {
1025 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
1032 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
1059 if (OuterS->getEntity()) {
1060 Lexical = OuterS->getEntity();
1087 if (!Lexical || !DC || !S->
getParent() ||
1089 return std::make_pair(Lexical,
false);
1095 while (OutermostTemplateScope->
getParent() &&
1097 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1111 return std::make_pair(Semantic,
true);
1113 return std::make_pair(Lexical,
false);
1119 struct FindLocalExternScope {
1129 ~FindLocalExternScope() {
1133 bool OldFindLocalExtern;
1138 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1156 I = IdResolver.begin(Name),
1157 IEnd = IdResolver.end();
1177 UnqualUsingDirectiveSet UDirs(*
this);
1178 bool VisitedUsingDirectives =
false;
1179 bool LeftStartingScope =
false;
1183 FindLocalExternScope FindLocals(R);
1187 bool SearchNamespaceScope =
true;
1191 if (NameKind == LookupRedeclarationWithLinkage &&
1192 !(*I)->isTemplateParameter()) {
1198 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1199 LeftStartingScope =
true;
1203 if (LeftStartingScope && !((*I)->hasLinkage())) {
1210 SearchNamespaceScope =
false;
1215 if (!SearchNamespaceScope) {
1218 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1223 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1239 Ctx = OutsideOfTemplateParamDC;
1240 OutsideOfTemplateParamDC =
nullptr;
1245 bool SearchAfterTemplateScope;
1247 if (SearchAfterTemplateScope)
1248 OutsideOfTemplateParamDC = OuterCtx;
1267 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(
1286 if (!VisitedUsingDirectives) {
1289 if (UCtx->isTransparentContext())
1292 UDirs.visit(UCtx, UCtx);
1297 Scope *InnermostFileScope = S;
1298 while (InnermostFileScope &&
1300 InnermostFileScope = InnermostFileScope->
getParent();
1301 UDirs.visitScopeChain(Initial, InnermostFileScope);
1305 VisitedUsingDirectives =
true;
1322 if (LookupQualifiedName(R, Ctx,
true))
1330 if (!S)
return false;
1333 if (NameKind == LookupMemberName)
1341 if (!VisitedUsingDirectives) {
1342 UDirs.visitScopeChain(Initial, S);
1349 FindLocals.restore();
1382 Ctx = OutsideOfTemplateParamDC;
1383 OutsideOfTemplateParamDC =
nullptr;
1388 bool SearchAfterTemplateScope;
1390 if (SearchAfterTemplateScope)
1391 OutsideOfTemplateParamDC = OuterCtx;
1405 "We should have been looking only at file context here already.");
1430 if (
auto *M = getCurrentModule())
1438 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1439 for (
auto *Param : *TD->getTemplateParameters())
1440 makeMergedDefinitionVisible(Param);
1445 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1450 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1453 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1454 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1456 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1470 unsigned N = CodeSynthesisContexts.size();
1471 for (
unsigned I = CodeSynthesisContextLookupModules.size();
1474 if (M && !LookupModulesCache.insert(M).second)
1476 CodeSynthesisContextLookupModules.push_back(M);
1478 return LookupModulesCache;
1492 if (isModuleVisible(Merged))
1504 template<
typename ParmDecl>
1508 if (!D->hasDefaultArgument())
1512 auto &DefaultArg = D->getDefaultArgStorage();
1513 if (!DefaultArg.isInherited() && S.
isVisible(D))
1516 if (!DefaultArg.isInherited() && Modules) {
1517 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1522 D = DefaultArg.getInheritedFrom();
1529 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1531 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1537 template<
typename Filter>
1541 bool HasFilteredRedecls =
false;
1543 for (
auto *Redecl : D->
redecls()) {
1544 auto *R = cast<NamedDecl>(Redecl);
1551 HasFilteredRedecls =
true;
1554 Modules->push_back(R->getOwningModule());
1558 if (HasFilteredRedecls)
1567 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1569 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1571 if (
auto *VD = dyn_cast<VarDecl>(D))
1573 llvm_unreachable(
"unknown explicit specialization kind");
1580 "not a member specialization");
1601 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1602 assert(D->
isHidden() &&
"should not call this: not in slow case");
1605 assert(DeclModule &&
"hidden decl has no owning module");
1614 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1616 isa<ExportDecl>(DC);
1622 if (DC && !IsEffectivelyFileContext(DC)) {
1630 bool VisibleWithinParent;
1632 bool SearchDefinitions =
true;
1633 if (
const auto *DCD = dyn_cast<Decl>(DC)) {
1634 if (
const auto *TD = DCD->getDescribedTemplate()) {
1637 SearchDefinitions = Index >= TPL->
size() || TPL->
getParam(Index) != D;
1640 if (SearchDefinitions)
1643 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1644 }
else if (isa<ParmVarDecl>(D) ||
1645 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1646 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1650 VisibleWithinParent =
false;
1653 VisibleWithinParent =
true;
1657 }
while (!IsEffectivelyFileContext(DC));
1669 return VisibleWithinParent;
1679 if (ModulePrivate) {
1683 if (VisibleModules.isVisible(M))
1691 const auto &LookupModules = getLookupModules();
1692 if (LookupModules.empty())
1696 if (LookupModules.count(M))
1704 return llvm::any_of(LookupModules, [&](
const Module *LookupM) {
1709 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1727 "should not have hidden, non-externally-declarable result here");
1761 for (
auto RD : D->
redecls()) {
1766 auto ND = cast<NamedDecl>(RD);
1770 if (ND->isInIdentifierNamespace(IDNS) &&
1780 assert(!isVisible(D) &&
"not in slow case");
1782 [](
const NamedDecl *) {
return true; });
1786 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1794 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1796 auto *Acceptable = isVisible(getSema(), Key)
1800 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1837 if (!Name)
return false;
1852 FindLocalExternScope FindLocals(R);
1858 bool LeftStartingScope =
false;
1861 IEnd = IdResolver.end();
1864 if (NameKind == LookupRedeclarationWithLinkage) {
1868 LeftStartingScope =
true;
1872 if (LeftStartingScope && !((*I)->hasLinkage())) {
1877 else if (NameKind == LookupObjCImplicitSelfParam &&
1878 !isa<ImplicitParamDecl>(*I))
1903 for (++LastI; LastI != IEnd; ++LastI) {
1928 if (CppLookupName(R, S))
1942 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1974 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1981 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1982 Visited.insert(StartDC);
1988 if (S.
isVisible(I) && Visited.insert(ND).second)
1989 Queue.push_back(ND);
1996 bool FoundTag =
false;
1997 bool FoundNonTag =
false;
2002 while (!Queue.empty()) {
2007 bool UseLocal = !R.
empty();
2036 if (S.
isVisible(I) && Visited.insert(Nom).second)
2037 Queue.push_back(Nom);
2042 if (FoundTag && FoundNonTag)
2062 template<
typename InputIterator>
2065 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
2068 if (isa<CXXMethodDecl>(D)) {
2070 bool AllMethodsAreStatic =
true;
2071 for(; First != Last; ++First) {
2072 D = (*First)->getUnderlyingDecl();
2074 if (!isa<CXXMethodDecl>(D)) {
2075 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
2079 if (!cast<CXXMethodDecl>(D)->isStatic()) {
2080 AllMethodsAreStatic =
false;
2085 if (AllMethodsAreStatic)
2115 bool InUnqualifiedLookup) {
2116 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2122 assert((!isa<TagDecl>(LookupCtx) ||
2124 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
2125 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
2126 "Declaration context must already be complete!");
2128 struct QualifiedLookupInScope {
2132 QualifiedLookupInScope(
DeclContext *ctx) : Context(ctx) {
2135 ~QualifiedLookupInScope() {
2142 if (isa<CXXRecordDecl>(LookupCtx))
2188 case LookupObjCImplicitSelfParam:
2189 case LookupOrdinaryName:
2190 case LookupMemberName:
2191 case LookupRedeclarationWithLinkage:
2192 case LookupLocalFriendName:
2204 case LookupOMPReductionName:
2208 case LookupOMPMapperName:
2212 case LookupUsingDeclName:
2215 case LookupOperatorName:
2216 case LookupNamespaceName:
2217 case LookupObjCProtocolName:
2222 case LookupNestedNameSpecifierName:
2230 return BaseCallback(Specifier, Path, Name);
2244 int SubobjectNumber = 0;
2248 Path != PathEnd; ++Path) {
2256 if (SubobjectType.
isNull()) {
2284 if (
auto *TD = getAsTemplateNameDecl(D))
2289 while (FirstD != FirstPath->Decls.end() &&
2291 if (GetRepresentativeDecl(*FirstD) !=
2292 GetRepresentativeDecl(*CurrentD))
2299 if (FirstD == FirstPath->Decls.end() &&
2355 return LookupInSuper(R, NNS->getAsRecordDecl());
2358 return LookupQualifiedName(R, LookupCtx);
2381 bool AllowBuiltinCreation,
bool EnteringContext) {
2388 if (SS && SS->
isSet()) {
2393 if (
DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
2400 return LookupQualifiedName(R, DC);
2412 return LookupName(R, S, AllowBuiltinCreation);
2429 for (
const auto &BaseSpec : Class->
bases()) {
2431 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2434 LookupQualifiedName(Result, RD);
2438 for (
auto I = Result.begin(), E = Result.end(); I != E; ++I) {
2444 Result.suppressDiagnostics();
2458 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2467 QualType SubobjectType = Paths->
front().back().Base->getType();
2468 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2469 << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths)
2473 while (isa<CXXMethodDecl>(*Found) &&
2474 cast<CXXMethodDecl>(*Found)->isStatic())
2477 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2482 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2483 << Name << LookupRange;
2486 std::set<Decl *> DeclsPrinted;
2488 PathEnd = Paths->
end();
2489 Path != PathEnd; ++Path) {
2490 Decl *D = Path->Decls.front();
2491 if (DeclsPrinted.insert(D).second)
2498 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2500 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2502 for (
auto *D : Result)
2503 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2504 TagDecls.insert(TD);
2505 Diag(TD->getLocation(), diag::note_hidden_tag);
2508 for (
auto *D : Result)
2509 if (!isa<TagDecl>(D))
2515 if (TagDecls.count(F.
next()))
2523 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2525 for (
auto *D : Result)
2533 struct AssociatedLookup {
2537 : S(S), Namespaces(Namespaces), Classes(Classes),
2538 InstantiationLoc(InstantiationLoc) {
2543 return ClassesTransitive.insert(RD);
2611 DeclContext *Ctx = ClassTemplate->getDeclContext();
2612 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2613 Result.Classes.insert(EnclosingClass);
2642 if (Class->
getDeclName() == Result.S.VAListTagName)
2655 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2656 Result.Classes.insert(EnclosingClass);
2671 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2672 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2673 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2674 Result.Classes.insert(EnclosingClass);
2679 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
2685 if (!Result.addClassTransitive(Class))
2689 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2690 Result.S.Context.getRecordType(Class)))
2696 Bases.push_back(Class);
2697 while (!Bases.empty()) {
2699 Class = Bases.pop_back_val();
2702 for (
const auto &
Base : Class->
bases()) {
2713 if (Result.addClassTransitive(BaseDecl)) {
2720 Bases.push_back(BaseDecl);
2748 #define TYPE(Class, Base) 2749 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 2750 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 2751 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 2752 #define ABSTRACT_TYPE(Class, Base) 2753 #include "clang/AST/TypeNodes.def" 2764 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2766 case Type::ConstantArray:
2767 case Type::IncompleteArray:
2768 case Type::VariableArray:
2769 T = cast<ArrayType>(T)->getElementType().getTypePtr();
2782 case Type::Record: {
2784 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2794 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2797 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2798 Result.Classes.insert(EnclosingClass);
2809 case Type::FunctionProto: {
2812 Queue.push_back(Arg.getTypePtr());
2816 case Type::FunctionNoProto: {
2831 case Type::MemberPointer: {
2835 Queue.push_back(MemberPtr->
getClass());
2843 case Type::BlockPointer:
2844 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2849 case Type::LValueReference:
2850 case Type::RValueReference:
2851 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2856 case Type::ExtVector:
2862 case Type::DeducedTemplateSpecialization:
2868 case Type::ObjCObject:
2869 case Type::ObjCInterface:
2870 case Type::ObjCObjectPointer:
2871 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2877 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2880 T = cast<PipeType>(T)->getElementType().getTypePtr();
2886 T = Queue.pop_back_val();
2901 AssociatedNamespaces.clear();
2902 AssociatedClasses.clear();
2904 AssociatedLookup Result(*
this, InstantiationLoc,
2905 AssociatedNamespaces, AssociatedClasses);
2914 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2915 Expr *Arg = Args[ArgIdx];
2955 Decl *D = LookupSingleName(TUScope, II, IdLoc,
2956 LookupObjCProtocolName, Redecl);
2957 return cast_or_null<ObjCProtocolDecl>(D);
2971 LookupName(Operators, S);
2973 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2983 bool VolatileThis) {
2985 "doing special member lookup into record that isn't fully complete");
2987 if (RValueThis || ConstThis || VolatileThis)
2988 assert((SM == CXXCopyAssignment || SM == CXXMoveAssignment) &&
2989 "constructors and destructors always have unqualified lvalue this");
2990 if (ConstArg || VolatileArg)
2991 assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
2992 "parameter-less special members can't have qualified arguments");
2997 llvm::FoldingSetNodeID
ID;
3000 ID.AddInteger(ConstArg);
3001 ID.AddInteger(VolatileArg);
3002 ID.AddInteger(RValueThis);
3003 ID.AddInteger(ConstThis);
3004 ID.AddInteger(VolatileThis);
3008 SpecialMemberCache.FindNodeOrInsertPos(ID, InsertPoint);
3016 SpecialMemberCache.InsertNode(Result, InsertPoint);
3018 if (SM == CXXDestructor) {
3020 DeclareImplicitDestructor(RD);
3022 assert(DD &&
"record without a destructor");
3025 SpecialMemberOverloadResult::NoMemberOrDeleted :
3026 SpecialMemberOverloadResult::Success);
3034 Expr *Arg =
nullptr;
3040 if (SM == CXXDefaultConstructor) {
3044 DeclareImplicitDefaultConstructor(RD);
3046 if (SM == CXXCopyConstructor || SM == CXXMoveConstructor) {
3049 DeclareImplicitCopyConstructor(RD);
3051 DeclareImplicitMoveConstructor(RD);
3055 DeclareImplicitCopyAssignment(RD);
3057 DeclareImplicitMoveAssignment(RD);
3072 if (SM == CXXCopyConstructor || SM == CXXCopyAssignment)
3080 if (SM != CXXDefaultConstructor) {
3106 assert(SM == CXXDefaultConstructor &&
3107 "lookup for a constructor or assignment operator was empty");
3109 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3117 for (
NamedDecl *CandDecl : Candidates) {
3118 if (CandDecl->isInvalidDecl())
3124 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3125 AddMethodCandidate(M, Cand, RD, ThisTy, Classification,
3126 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3128 AddOverloadCandidate(CtorInfo.Constructor, CtorInfo.FoundDecl,
3129 llvm::makeArrayRef(&Arg, NumArgs), OCS,
3132 AddOverloadCandidate(M, Cand, llvm::makeArrayRef(&Arg, NumArgs), OCS,
3136 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3137 AddMethodTemplateCandidate(
3138 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
3139 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3141 AddTemplateOverloadCandidate(
3142 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
3143 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3145 AddTemplateOverloadCandidate(
3146 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3148 assert(isa<UsingDecl>(Cand.
getDecl()) &&
3149 "illegal Kind of operator = Decl");
3156 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3157 Result->
setKind(SpecialMemberOverloadResult::Success);
3161 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3162 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3167 Result->
setKind(SpecialMemberOverloadResult::Ambiguous);
3172 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3182 LookupSpecialMember(Class, CXXDefaultConstructor,
false,
false,
false,
3185 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3192 "non-const, non-volatile qualifiers for copy ctor arg");
3197 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3207 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3215 DeclareImplicitDefaultConstructor(Class);
3217 DeclareImplicitCopyConstructor(Class);
3219 DeclareImplicitMoveConstructor(Class);
3224 return Class->
lookup(Name);
3229 unsigned Quals,
bool RValueThis,
3230 unsigned ThisQuals) {
3232 "non-const, non-volatile qualifiers for copy assignment arg");
3234 "non-const, non-volatile qualifiers for copy assignment this");
3238 ThisQuals & Qualifiers::Const,
3239 ThisQuals & Qualifiers::Volatile);
3248 unsigned ThisQuals) {
3250 "non-const, non-volatile qualifiers for copy assignment this");
3254 ThisQuals & Qualifiers::Const,
3255 ThisQuals & Qualifiers::Volatile);
3267 return cast<CXXDestructorDecl>(LookupSpecialMember(Class, CXXDestructor,
3268 false,
false,
false,
3269 false,
false).getMethod());
3281 bool AllowRaw,
bool AllowTemplate,
3282 bool AllowStringTemplate,
bool DiagnoseMissing) {
3285 "literal operator lookup can't be ambiguous");
3290 bool FoundRaw =
false;
3291 bool FoundTemplate =
false;
3292 bool FoundStringTemplate =
false;
3293 bool FoundExactMatch =
false;
3295 while (F.hasNext()) {
3298 D = USD->getTargetDecl();
3307 bool IsTemplate =
false;
3308 bool IsStringTemplate =
false;
3309 bool IsExactMatch =
false;
3312 if (FD->getNumParams() == 1 &&
3313 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3315 else if (FD->getNumParams() == ArgTys.size()) {
3316 IsExactMatch =
true;
3317 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3318 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3320 IsExactMatch =
false;
3328 if (Params->
size() == 1)
3331 IsStringTemplate =
true;
3335 FoundExactMatch =
true;
3337 AllowTemplate =
false;
3338 AllowStringTemplate =
false;
3339 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3343 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3345 }
else if (AllowRaw && IsRaw) {
3347 }
else if (AllowTemplate && IsTemplate) {
3348 FoundTemplate =
true;
3349 }
else if (AllowStringTemplate && IsStringTemplate) {
3350 FoundStringTemplate =
true;
3361 if (FoundExactMatch)
3366 if (FoundRaw && FoundTemplate) {
3369 NoteOverloadCandidate(*I, (*I)->getUnderlyingDecl()->getAsFunction());
3377 return LOLR_Template;
3379 if (FoundStringTemplate)
3380 return LOLR_StringTemplate;
3383 if (DiagnoseMissing) {
3386 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3387 << (AllowTemplate || AllowStringTemplate);
3391 return LOLR_ErrorNoDiagnostic;
3399 if (Old ==
nullptr || Old == New) {
3414 if (!Cursor)
return;
3417 if (Cursor == OldFD)
break;
3431 FindAssociatedClassesAndNamespaces(Loc, Args,
3432 AssociatedNamespaces,
3446 for (
auto *NS : AssociatedNamespaces) {
3460 auto *Underlying = D;
3461 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3462 Underlying = USD->getTargetDecl();
3464 if (!isa<FunctionDecl>(Underlying) &&
3465 !isa<FunctionTemplateDecl>(Underlying))
3471 bool Visible =
false;
3481 if (AssociatedClasses.count(RD) && isVisible(D)) {
3490 Result.
insert(Underlying);
3504 class ShadowContextRAII;
3506 class VisibleDeclsRecord {
3511 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3516 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3519 std::list<ShadowMap> ShadowMaps;
3522 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3524 friend class ShadowContextRAII;
3530 return !VisitedContexts.insert(Ctx).second;
3534 return VisitedContexts.count(Ctx);
3546 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3551 class ShadowContextRAII {
3552 VisibleDeclsRecord &Visible;
3554 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3557 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3558 Visible.ShadowMaps.emplace_back();
3561 ~ShadowContextRAII() {
3562 Visible.ShadowMaps.pop_back();
3570 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3571 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3572 SM != SMEnd; ++
SM) {
3573 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
3574 if (Pos == SM->end())
3577 for (
auto *D : Pos->second) {
3595 SM == ShadowMaps.rbegin())
3600 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
3601 cast<UsingShadowDecl>(ND)->getUsingDecl() == D)
3613 bool QualifiedNameLookup,
3616 VisibleDeclsRecord &Visited,
3617 bool IncludeDependentBases,
3618 bool LoadExternal) {
3629 if (isa<TranslationUnitDecl>(Ctx) &&
3632 auto &Idents = S.Context.Idents;
3637 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3638 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3643 for (
const auto &Ident : Idents) {
3644 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3645 E = S.IdResolver.end();
3647 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3649 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3663 bool Load = LoadExternal ||
3664 !(isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx));
3671 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3678 if (QualifiedNameLookup) {
3679 ShadowContextRAII Shadow(Visited);
3684 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3685 IncludeDependentBases, LoadExternal);
3691 if (!Record->hasDefinition())
3694 for (
const auto &B : Record->bases()) {
3699 if (!IncludeDependentBases) {
3712 RD = TD->getTemplatedDecl();
3717 RD = Record->getDecl();
3740 ShadowContextRAII Shadow(Visited);
3742 Consumer, Visited, IncludeDependentBases,
3750 for (
auto *Cat : IFace->visible_categories()) {
3751 ShadowContextRAII Shadow(Visited);
3753 Visited, IncludeDependentBases, LoadExternal);
3757 for (
auto *I : IFace->all_referenced_protocols()) {
3758 ShadowContextRAII Shadow(Visited);
3760 Visited, IncludeDependentBases, LoadExternal);
3764 if (IFace->getSuperClass()) {
3765 ShadowContextRAII Shadow(Visited);
3767 true, Consumer, Visited, IncludeDependentBases,
3773 if (IFace->getImplementation()) {
3774 ShadowContextRAII Shadow(Visited);
3776 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3777 IncludeDependentBases, LoadExternal);
3780 for (
auto *I : Protocol->protocols()) {
3781 ShadowContextRAII Shadow(Visited);
3783 Visited, IncludeDependentBases, LoadExternal);
3786 for (
auto *I :
Category->protocols()) {
3787 ShadowContextRAII Shadow(Visited);
3789 Visited, IncludeDependentBases, LoadExternal);
3793 if (
Category->getImplementation()) {
3794 ShadowContextRAII Shadow(Visited);
3796 QualifiedNameLookup,
true, Consumer, Visited,
3797 IncludeDependentBases, LoadExternal);
3803 UnqualUsingDirectiveSet &UDirs,
3805 VisibleDeclsRecord &Visited,
3806 bool LoadExternal) {
3812 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3814 FindLocalExternScope FindLocals(Result);
3818 for (
Decl *D : ScopeDecls) {
3819 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3821 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3839 if (Method->isInstanceMethod()) {
3845 false, Consumer, Visited,
3846 false, LoadExternal);
3860 false, Consumer, Visited,
3861 false, LoadExternal);
3875 false, Consumer, Visited,
3876 false, LoadExternal);
3882 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3885 false, Consumer, Visited,
3886 false, LoadExternal);
3890 ShadowContextRAII Shadow(Visited);
3897 bool IncludeGlobalScope,
bool LoadExternal) {
3901 UnqualUsingDirectiveSet UDirs(*
this);
3907 UDirs.visitScopeChain(Initial, S);
3914 VisibleDeclsRecord Visited;
3915 if (!IncludeGlobalScope)
3917 ShadowContextRAII Shadow(Visited);
3923 bool IncludeGlobalScope,
3924 bool IncludeDependentBases,
bool LoadExternal) {
3927 VisibleDeclsRecord Visited;
3928 if (!IncludeGlobalScope)
3930 ShadowContextRAII Shadow(Visited);
3932 false, Consumer, Visited,
3933 IncludeDependentBases, LoadExternal);
3948 Scope *S = CurScope;
3949 PushOnScopeChains(Res, S,
true);
3950 return cast<LabelDecl>(Res);
3954 Res = LookupSingleName(CurScope, II, Loc, LookupLabel, NotForRedeclaration);
3957 if (Res && Res->getDeclContext() != CurContext)
3963 assert(S &&
"Not in a function?");
3964 PushOnScopeChains(Res, S,
true);
3966 return cast<LabelDecl>(Res);
3984 bool EnteringContext,
3985 bool isObjCIvarLookup,
3994 for (; DI != DE; ++DI)
4004 bool AnyVisibleDecls = !NewDecls.empty();
4006 for (; DI != DE; ++DI) {
4008 if (!AnyVisibleDecls) {
4010 AnyVisibleDecls =
true;
4013 NewDecls.push_back(*DI);
4014 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
4015 NewDecls.push_back(*DI);
4018 if (NewDecls.empty())
4035 Identifiers.clear();
4065 Identifiers.push_back(II);
4092 addName(Name,
nullptr);
4098 addName(Keyword,
nullptr,
nullptr,
true);
4101 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
4105 StringRef TypoStr = Typo->getName();
4106 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
4107 if (MinED && TypoStr.size() / MinED < 3)
4112 unsigned UpperBound = (TypoStr.size() + 2) / 3;
4113 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
4114 if (ED > UpperBound)
return;
4118 TC.setCorrectionRange(
nullptr, Result.getLookupNameInfo());
4125 StringRef TypoStr = Typo->getName();
4131 if (TypoStr.size() < 3 &&
4132 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4145 if (!CList.empty() && !CList.back().isResolved())
4149 for (TypoResultList::iterator RI = CList.begin(), RIEnd = CList.end();
4150 RI != RIEnd; ++RI) {
4155 if (RI->getCorrectionDecl() == NewND) {
4162 if (CList.empty() || Correction.
isResolved())
4163 CList.push_back(Correction);
4166 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4170 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4171 SearchNamespaces =
true;
4173 for (
auto KNPair : KnownNamespaces)
4174 Namespaces.addNameSpecifier(KNPair.first);
4176 bool SSIsTemplate =
false;
4180 SSIsTemplate = T->
getTypeClass() == Type::TemplateSpecialization;
4186 for (
unsigned I = 0; I != Types.size(); ++I) {
4187 const auto *TI = Types[I];
4189 CD = CD->getCanonicalDecl();
4190 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4191 !CD->isUnion() && CD->getIdentifier() &&
4192 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4193 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4194 Namespaces.addNameSpecifier(CD);
4200 if (++CurrentTCIndex < ValidatedCorrections.size())
4201 return ValidatedCorrections[CurrentTCIndex];
4203 CurrentTCIndex = ValidatedCorrections.size();
4204 while (!CorrectionResults.empty()) {
4205 auto DI = CorrectionResults.
begin();
4206 if (DI->second.empty()) {
4207 CorrectionResults.erase(DI);
4211 auto RI = DI->second.begin();
4212 if (RI->second.empty()) {
4213 DI->second.erase(RI);
4214 performQualifiedLookups();
4220 ValidatedCorrections.push_back(TC);
4221 return ValidatedCorrections[CurrentTCIndex];
4224 return ValidatedCorrections[0];
4227 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4234 CorrectionValidator->IsObjCIvarLookup,
4236 switch (Result.getResultKind()) {
4246 if (TempMemberContext) {
4249 TempMemberContext =
nullptr;
4252 if (SearchNamespaces)
4253 QualifiedResults.push_back(Candidate);
4263 for (
auto *TRD : Result)
4267 if (SearchNamespaces)
4268 QualifiedResults.push_back(Candidate);
4277 void TypoCorrectionConsumer::performQualifiedLookups() {
4278 unsigned TypoLen = Typo->getName().size();
4280 for (
const auto &NSI : Namespaces) {
4282 const Type *NSType = NSI.NameSpecifier->getAsType();
4290 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4304 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4305 TypoLen / TmpED < 3)
4309 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4315 switch (Result.getResultKind()) {
4320 std::string OldQualified;
4321 llvm::raw_string_ostream OldOStream(OldQualified);
4323 OldOStream << Typo->getName();
4327 if (OldOStream.str() == NewQualified)
4331 TRD != TRDEnd; ++TRD) {
4352 QualifiedResults.clear();
4355 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4357 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4359 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4360 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4368 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4369 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4376 DistanceMap[1].push_back(SI);
4379 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4381 assert(Start &&
"Building a context chain from a null context");
4382 DeclContextList Chain;
4394 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4396 unsigned NumSpecifiers = 0;
4398 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4401 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4403 RD->getTypeForDecl());
4407 return NumSpecifiers;
4410 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4413 unsigned NumSpecifiers = 0;
4414 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4415 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4418 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4419 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C)
4421 NamespaceDeclChain.pop_back();
4425 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4428 if (NamespaceDeclChain.empty()) {
4432 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4434 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4436 bool SameNameSpecifier =
false;
4437 if (std::find(CurNameSpecifierIdentifiers.begin(),
4438 CurNameSpecifierIdentifiers.end(),
4439 Name) != CurNameSpecifierIdentifiers.end()) {
4440 std::string NewNameSpecifier;
4441 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4445 SpecifierOStream.flush();
4446 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4448 if (SameNameSpecifier || llvm::find(CurContextIdentifiers, Name) !=
4449 CurContextIdentifiers.end()) {
4453 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4461 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4464 NumSpecifiers = llvm::ComputeEditDistance(
4465 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4466 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4469 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4470 DistanceMap[NumSpecifiers].push_back(SI);
4479 bool EnteringContext,
4480 bool isObjCIvarLookup,
4486 if (MemberContext) {
4488 if (isObjCIvarLookup) {
4489 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4514 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4519 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4531 bool AfterNestedNameSpecifier) {
4532 if (AfterNestedNameSpecifier) {
4545 static const char *
const CTypeSpecs[] = {
4546 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4547 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4548 "_Complex",
"_Imaginary",
4550 "extern",
"inline",
"static",
"typedef" 4553 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4554 for (
unsigned I = 0; I != NumCTypeSpecs; ++I)
4581 static const char *
const CastableTypeSpecs[] = {
4582 "char",
"double",
"float",
"int",
"long",
"short",
4583 "signed",
"unsigned",
"void" 4585 for (
auto *kw : CastableTypeSpecs)
4604 static const char *
const CXXExprs[] = {
4605 "delete",
"new",
"operator",
"throw",
"typeid" 4607 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4608 for (
unsigned I = 0; I != NumCXXExprs; ++I)
4611 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4612 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4631 static const char *
const CStmts[] = {
4632 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4633 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4634 for (
unsigned I = 0; I != NumCStmts; ++I)
4679 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4685 if (Diags.hasFatalErrorOccurred() || !getLangOpts().SpellChecking ||
4686 DisableTypoCorrection)
4693 isa<CXXMethodDecl>(CurContext))
4707 if (!CodeSynthesisContexts.empty())
4715 IdentifierSourceLocations::iterator locs = TypoCorrectionFailures.find(Typo);
4716 if (locs != TypoCorrectionFailures.end() &&
4717 locs->second.count(TypoName.
getLoc()))
4723 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->
isStr(
"vector"))
4729 unsigned Limit = getDiagnostics().getDiagnosticOptions().SpellCheckingLimit;
4730 if (Limit && TyposCorrected >= Limit)
4736 if (ErrorRecovery && getLangOpts().Modules &&
4737 getLangOpts().ModulesSearchAll) {
4739 getModuleLoader().lookupMissingImports(Typo->
getName(),
4747 std::unique_ptr<CorrectionCandidateCallback> ClonedCCC = CCC.
clone();
4748 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4749 *
this, TypoName, LookupKind, S, SS, std::move(ClonedCCC), MemberContext,
4753 bool IsUnqualifiedLookup =
false;
4755 if (MemberContext) {
4760 for (
auto *I : OPT->
quals())
4763 }
else if (SS && SS->isSet()) {
4764 QualifiedDC = computeDeclContext(*SS, EnteringContext);
4770 IsUnqualifiedLookup =
true;
4775 bool SearchNamespaces
4776 = getLangOpts().CPlusPlus &&
4777 (IsUnqualifiedLookup || (SS && SS->isSet()));
4779 if (IsUnqualifiedLookup || SearchNamespaces) {
4783 for (
const auto &I : Context.
Idents)
4784 Consumer->FoundName(I.getKey());
4790 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4792 StringRef Name = Iter->Next();
4796 Consumer->FoundName(Name);
4802 *Consumer->getCorrectionValidator(),
4803 SS && SS->isNotEmpty());
4807 if (SearchNamespaces) {
4809 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4811 LoadedExternalKnownNamespaces =
true;
4812 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces);
4813 for (
auto *N : ExternalKnownNamespaces)
4814 KnownNamespaces[N] =
true;
4817 Consumer->addNamespaces(KnownNamespaces);
4860 bool EnteringContext,
4862 bool RecordFailure) {
4865 if (ExternalSource) {
4867 ExternalSource->CorrectTypo(TypoName, LookupKind, S, SS, CCC,
4868 MemberContext, EnteringContext, OPT))
4879 auto Consumer = makeTypoCorrectionConsumer(TypoName, LookupKind, S, SS, CCC,
4880 MemberContext, EnteringContext,
4881 OPT, Mode == CTK_ErrorRecovery);
4887 if (Consumer->empty())
4888 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4892 unsigned ED = Consumer->getBestEditDistance(
true);
4893 unsigned TypoLen = Typo->
getName().size();
4894 if (ED > 0 && TypoLen / ED < 3)
4895 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4900 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4904 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4908 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4912 if (!SecondBestTC ||
4913 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4919 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4925 }
else if (SecondBestTC && ObjCMessageReceiver) {
4929 if (BestTC.getCorrection().getAsString() !=
"super") {
4931 BestTC = SecondBestTC;
4932 else if ((*Consumer)[
"super"].front().isKeyword())
4933 BestTC = (*Consumer)[
"super"].front();
4937 if (BestTC.getEditDistance() == 0 ||
4938 BestTC.getCorrection().getAsString() !=
"super")
4939 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4948 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4995 auto Consumer = makeTypoCorrectionConsumer(TypoName, LookupKind, S, SS, CCC,
4996 MemberContext, EnteringContext,
4997 OPT, Mode == CTK_ErrorRecovery);
5001 if (ExternalSource && Consumer) {
5002 ExternalTypo = ExternalSource->CorrectTypo(
5003 TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(),
5004 MemberContext, EnteringContext, OPT);
5006 Consumer->addCorrection(ExternalTypo);
5009 if (!Consumer || Consumer->empty())
5014 unsigned ED = Consumer->getBestEditDistance(
true);
5016 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
5019 ExprEvalContexts.back().NumTypos++;
5020 return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC));
5027 CorrectionDecls.clear();
5029 CorrectionDecls.push_back(CDecl);
5031 if (!CorrectionName)
5036 if (CorrectionNameSpec) {
5037 std::string tmpBuffer;
5038 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
5040 PrefixOStream << CorrectionName;
5041 return PrefixOStream.str();
5044 return CorrectionName.getAsString();
5053 return WantTypeSpecifiers || WantExpressionKeywords || WantCXXNamedCasts ||
5054 WantRemainingKeywords || WantObjCSuper;
5056 bool HasNonType =
false;
5057 bool HasStaticMethod =
false;
5058 bool HasNonStaticMethod =
false;
5059 for (
Decl *D : candidate) {
5061 D = FTD->getTemplatedDecl();
5063 if (Method->isStatic())
5064 HasStaticMethod =
true;
5066 HasNonStaticMethod =
true;
5068 if (!isa<TypeDecl>(D))
5072 if (IsAddressOfOperand && HasNonStaticMethod && !HasStaticMethod &&
5073 !candidate.getCorrectionSpecifier())
5076 return WantTypeSpecifiers || HasNonType;
5080 bool HasExplicitTemplateArgs,
5082 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
5083 CurContext(SemaRef.CurContext), MemberFn(ME) {
5086 !HasExplicitTemplateArgs && NumArgs == 1;
5095 for (
auto *
C : candidate) {
5099 FD = FTD->getTemplatedDecl();
5100 if (!HasExplicitTemplateArgs && !FD) {
5101 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
5105 QualType ValType = cast<ValueDecl>(ND)->getType();
5111 if (FPT->getNumParams() == NumArgs)
5118 : isa<TypeDecl>(ND)) &&
5121 return NumArgs <= 1 || HasExplicitTemplateArgs || isa<CXXRecordDecl>(ND);
5134 if (MemberFn || !MD->isStatic()) {
5137 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
5138 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
5153 bool ErrorRecovery) {
5154 diagnoseTypo(Correction, TypoDiag, PDiag(diag::note_previous_decl),
5161 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
5162 return VD->getDefinition();
5164 return FD->getDefinition();
5165 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
5166 return TD->getDefinition();
5168 return ID->getDefinition();
5170 return PD->getDefinition();
5172 if (
NamedDecl *TTD = TD->getTemplatedDecl())
5185 Module *Owner = getOwningModule(Def);
5186 assert(Owner &&
"definition of hidden declaration is not in a module");
5189 OwningModules.push_back(Owner);
5191 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5193 diagnoseMissingImport(Loc, Def, Def->
getLocation(), OwningModules, MIK,
5201 llvm::StringRef IncludingFile) {
5202 bool IsSystem =
false;
5204 E, IncludingFile, &IsSystem);
5205 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
5212 assert(!Modules.empty());
5214 auto NotePrevious = [&] {
5217 case MissingImportKind::Declaration:
5218 DiagID = diag::note_previous_declaration;
5220 case MissingImportKind::Definition:
5221 DiagID = diag::note_previous_definition;
5223 case MissingImportKind::DefaultArgument:
5224 DiagID = diag::note_default_argument_declared_here;
5226 case MissingImportKind::ExplicitSpecialization:
5227 DiagID = diag::note_explicit_specialization_declared_here;
5229 case MissingImportKind::PartialSpecialization:
5230 DiagID = diag::note_partial_specialization_declared_here;
5233 Diag(DeclLoc, DiagID);
5238 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5239 for (
auto *M : Modules) {
5242 if (UniqueModuleSet.insert(M).second)
5243 UniqueModules.push_back(M);
5246 llvm::StringRef IncludingFile;
5248 SourceMgr.getFileEntryForID(SourceMgr.getFileID(UseLoc)))
5249 IncludingFile = FE->tryGetRealPathName();
5251 if (UniqueModules.empty()) {
5254 PP.getModuleHeaderToIncludeForDiagnostics(UseLoc, Modules[0], DeclLoc);
5257 Diag(UseLoc, diag::err_module_unimported_use_global_module_fragment)
5258 << (int)MIK << Decl << !!E
5267 createImplicitModuleImportForErrorRecovery(UseLoc, Modules[0]);
5271 Modules = UniqueModules;
5273 if (Modules.size() > 1) {
5274 std::string ModuleList;
5276 for (
Module *M : Modules) {
5277 ModuleList +=
"\n ";
5278 if (++N == 5 && N != Modules.size()) {
5279 ModuleList +=
"[...]";
5282 ModuleList += M->getFullModuleName();
5285 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5286 << (int)MIK << Decl << ModuleList;
5287 }
else if (
const FileEntry *E = PP.getModuleHeaderToIncludeForDiagnostics(
5288 UseLoc, Modules[0], DeclLoc)) {
5294 Diag(UseLoc, diag::err_module_unimported_use_header)
5295 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5299 Diag(UseLoc, diag::err_module_unimported_use)
5300 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5307 createImplicitModuleImportForErrorRecovery(UseLoc, Modules[0]);
5325 bool ErrorRecovery) {
5326 std::string CorrectedStr = Correction.
getAsString(getLangOpts());
5327 std::string CorrectedQuotedStr = Correction.
getQuoted(getLangOpts());
5334 assert(Decl &&
"import required but no declaration to import");
5337 MissingImportKind::Declaration, ErrorRecovery);
5342 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5347 Diag(ChosenDecl->getLocation(), PrevNote)
5348 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5355 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5358 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5360 auto &
State = DelayedTypos[TE];
5361 State.Consumer = std::move(TCC);
5362 State.DiagHandler = std::move(TDG);
5363 State.RecoveryHandler = std::move(TRC);
5368 auto Entry = DelayedTypos.find(TE);
5369 assert(Entry != DelayedTypos.end() &&
5370 "Failed to get the state for a TypoExpr!");
5371 return Entry->second;
5375 DelayedTypos.erase(TE);
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Defines the clang::ASTContext interface.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
void setImplicit(bool I=true)
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.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=CSK_unspecified)
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.
Defines the clang::FileManager interface and associated types.
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)
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.
NamedDecl * getParam(unsigned Idx)
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.
Represents a parameter to a function.
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...
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E, llvm::StringRef IncludingFile)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
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.
static void InsertOCLBuiltinDeclarations(Sema &S, LookupResult &LR, IdentifierInfo *II, unsigned Index, unsigned Len)
When trying to resolve a function name, if the isOpenCLBuiltin function defined in "OpenCLBuiltins...
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...
bool isTemplateNameLookup() const
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.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
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().
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
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.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, 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...
This represents one expression.
Defines the clang::LangOptions interface.
void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts)
Set OpenCL extensions for a declaration which can only be used when these OpenCL extensions are enabl...
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...
Look up the name of an OpenMP user-defined mapper.
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to...
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
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...
This declaration is an OpenMP user defined mapper.
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...
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.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
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
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.
static bool FindOMPMapperMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare mapper member with ...
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.
virtual std::unique_ptr< CorrectionCandidateCallback > clone()=0
Clone this CorrectionCandidateCallback.
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++ 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...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, 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...
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.
bool isFunctionProtoType() const
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.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
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
Return the parent of this method declaration, which is the class in which this method is defined...
OverloadExpr * Expression
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.
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.
__DEVICE__ int min(int __a, int __b)
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.
ASTContext & getParentASTContext() const
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...
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...
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
const LangOptions & getLangOpts() 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)
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.