40 #include "llvm/ADT/STLExtras.h"
41 #include "llvm/ADT/SetVector.h"
42 #include "llvm/ADT/SmallPtrSet.h"
43 #include "llvm/ADT/StringMap.h"
44 #include "llvm/ADT/TinyPtrVector.h"
45 #include "llvm/ADT/edit_distance.h"
46 #include "llvm/Support/ErrorHandling.h"
56 using namespace clang;
60 class UnqualUsingEntry {
67 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
71 return CommonAncestor;
80 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
81 return L.getCommonAncestor() < R.getCommonAncestor();
84 bool operator()(
const UnqualUsingEntry &
E,
const DeclContext *DC) {
85 return E.getCommonAncestor() < DC;
88 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
89 return DC < E.getCommonAncestor();
96 class UnqualUsingDirectiveSet {
100 llvm::SmallPtrSet<DeclContext*, 8> visited;
103 UnqualUsingDirectiveSet() {}
105 void visitScopeChain(
Scope *
S,
Scope *InnermostFileScope) {
122 visit(
I, InnermostFileDC);
135 if (!visited.insert(DC).second)
138 addUsingDirectives(DC, EffectiveDC);
146 if (!visited.insert(NS).second)
149 addUsingDirective(UD, EffectiveDC);
150 addUsingDirectives(NS, EffectiveDC);
161 if (visited.insert(NS).second) {
162 addUsingDirective(UD, EffectiveDC);
170 DC = queue.pop_back_val();
185 while (!Common->
Encloses(EffectiveDC))
193 std::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
196 typedef ListTy::const_iterator const_iterator;
198 const_iterator
begin()
const {
return list.begin(); }
199 const_iterator
end()
const {
return list.end(); }
201 llvm::iterator_range<const_iterator>
203 return llvm::make_range(std::equal_range(
begin(),
end(),
205 UnqualUsingEntry::Comparator()));
214 bool Redeclaration) {
234 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
273 assert(Redeclaration &&
"should only be used for redecl lookup");
292 void LookupResult::configure() {
294 isForRedeclaration());
299 switch (NameInfo.getName().getCXXOverloadedOperator()) {
303 case OO_Array_Delete:
304 getSema().DeclareGlobalNewDelete();
314 if (
unsigned BuiltinID = Id->getBuiltinID()) {
315 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
321 bool LookupResult::sanity()
const {
323 assert(ResultKind != NotFound || Decls.size() == 0);
324 assert(ResultKind != Found || Decls.size() == 1);
325 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
326 (Decls.size() == 1 &&
327 isa<FunctionTemplateDecl>((*
begin())->getUnderlyingDecl())));
328 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
329 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
330 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
331 Ambiguity == AmbiguousBaseSubobjectTypes)));
332 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
333 (Ambiguity == AmbiguousBaseSubobjectTypes ||
334 Ambiguity == AmbiguousBaseSubobjects)));
365 !isa<UsingShadowDecl>(Existing))
377 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
378 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
379 bool HaveTag = isa<TagDecl>(EUnderlying);
381 return HaveTag != WantTag;
388 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
389 auto *EFD = cast<FunctionDecl>(EUnderlying);
390 unsigned DMin = DFD->getMinRequiredArguments();
391 unsigned EMin = EFD->getMinRequiredArguments();
400 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
401 auto *ETD = cast<TemplateDecl>(EUnderlying);
402 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
403 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
412 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
415 ETD->getTemplateParameters()->getParam(
I)) &&
417 DTD->getTemplateParameters()->getParam(
I)))
423 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
432 if (Prev == EUnderlying)
454 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
455 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D);
460 unsigned N = Decls.size();
464 assert(ResultKind == NotFound ||
465 ResultKind == NotFoundInCurrentInstantiation);
472 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
473 if (isa<FunctionTemplateDecl>(D))
474 ResultKind = FoundOverloaded;
475 else if (isa<UnresolvedUsingValueDecl>(D))
476 ResultKind = FoundUnresolvedValue;
481 if (ResultKind == Ambiguous)
return;
483 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
484 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
486 bool Ambiguous =
false;
487 bool HasTag =
false, HasFunction =
false;
488 bool HasFunctionTemplate =
false, HasUnresolved =
false;
493 unsigned UniqueTagIndex = 0;
502 Decls[
I] = Decls[--N];
512 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
513 QualType T = getSema().Context.getTypeDeclType(TD);
514 auto UniqueResult = UniqueTypes.insert(
516 if (!UniqueResult.second) {
518 ExistingI = UniqueResult.first->second;
525 auto UniqueResult = Unique.insert(std::make_pair(D, I));
526 if (!UniqueResult.second) {
528 ExistingI = UniqueResult.first->second;
537 Decls[*ExistingI] = Decls[
I];
538 Decls[
I] = Decls[--N];
544 if (isa<UnresolvedUsingValueDecl>(D)) {
545 HasUnresolved =
true;
546 }
else if (isa<TagDecl>(D)) {
551 }
else if (isa<FunctionTemplateDecl>(D)) {
553 HasFunctionTemplate =
true;
554 }
else if (isa<FunctionDecl>(D)) {
557 if (HasNonFunction) {
562 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
564 EquivalentNonFunctions.push_back(D);
565 Decls[
I] = Decls[--N];
585 if (N > 1 && HideTags && HasTag && !Ambiguous &&
586 (HasFunction || HasNonFunction || HasUnresolved)) {
587 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
588 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
592 Decls[UniqueTagIndex] = Decls[--N];
599 if (!EquivalentNonFunctions.empty() && !Ambiguous)
600 getSema().diagnoseEquivalentInternalLinkageDeclarations(
601 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
605 if (HasNonFunction && (HasFunction || HasUnresolved))
610 else if (HasUnresolved)
612 else if (N > 1 || HasFunctionTemplate)
618 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
622 DE = I->Decls.end(); DI != DE; ++DI)
629 addDeclsFromBasePaths(*Paths);
631 setAmbiguous(AmbiguousBaseSubobjects);
637 addDeclsFromBasePaths(*Paths);
639 setAmbiguous(AmbiguousBaseSubobjectTypes);
643 Out << Decls.size() <<
" result(s)";
644 if (isAmbiguous()) Out <<
", ambiguous";
645 if (Paths) Out <<
", base paths present";
654 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
686 if (
unsigned BuiltinID = II->getBuiltinID()) {
724 DeclareImplicitDefaultConstructor(Class);
728 DeclareImplicitCopyConstructor(Class);
732 DeclareImplicitCopyAssignment(Class);
734 if (getLangOpts().CPlusPlus11) {
737 DeclareImplicitMoveConstructor(Class);
741 DeclareImplicitMoveAssignment(Class);
746 DeclareImplicitDestructor(Class);
777 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
780 if (Record->needsImplicitDefaultConstructor())
782 if (Record->needsImplicitCopyConstructor())
785 Record->needsImplicitMoveConstructor())
791 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
792 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
801 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
804 if (Record->needsImplicitCopyAssignment())
807 Record->needsImplicitMoveAssignment())
844 !isa<CXXRecordDecl>(DC))
886 assert(ConvProto &&
"Nonsensical conversion function template type");
901 Specialization, Info)
916 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
923 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
950 if (OuterS->getEntity()) {
951 Lexical = OuterS->getEntity();
978 if (!Lexical || !DC || !S->
getParent() ||
980 return std::make_pair(Lexical,
false);
986 while (OutermostTemplateScope->
getParent() &&
988 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1002 return std::make_pair(Semantic,
true);
1004 return std::make_pair(Lexical,
false);
1010 struct FindLocalExternScope {
1012 : R(R), OldFindLocalExtern(R.getIdentifierNamespace() &
1013 Decl::IDNS_LocalExtern) {
1019 ~FindLocalExternScope() {
1023 bool OldFindLocalExtern;
1028 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1046 I = IdResolver.begin(Name),
1047 IEnd = IdResolver.end();
1067 UnqualUsingDirectiveSet UDirs;
1068 bool VisitedUsingDirectives =
false;
1069 bool LeftStartingScope =
false;
1073 FindLocalExternScope FindLocals(R);
1082 if (NameKind == LookupRedeclarationWithLinkage) {
1085 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1086 LeftStartingScope =
true;
1091 if (LeftStartingScope && !((*I)->hasLinkage()) &&
1092 !(*I)->isTemplateParameter()) {
1105 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1110 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1126 Ctx = OutsideOfTemplateParamDC;
1127 OutsideOfTemplateParamDC =
nullptr;
1132 bool SearchAfterTemplateScope;
1134 if (SearchAfterTemplateScope)
1135 OutsideOfTemplateParamDC = OuterCtx;
1154 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(
1173 if (!VisitedUsingDirectives) {
1176 if (UCtx->isTransparentContext())
1179 UDirs.visit(UCtx, UCtx);
1184 Scope *InnermostFileScope =
S;
1185 while (InnermostFileScope &&
1187 InnermostFileScope = InnermostFileScope->
getParent();
1188 UDirs.visitScopeChain(Initial, InnermostFileScope);
1192 VisitedUsingDirectives =
true;
1209 if (LookupQualifiedName(R, Ctx,
true))
1217 if (!S)
return false;
1220 if (NameKind == LookupMemberName)
1228 if (!VisitedUsingDirectives) {
1229 UDirs.visitScopeChain(Initial, S);
1236 FindLocals.restore();
1269 Ctx = OutsideOfTemplateParamDC;
1270 OutsideOfTemplateParamDC =
nullptr;
1275 bool SearchAfterTemplateScope;
1277 if (SearchAfterTemplateScope)
1278 OutsideOfTemplateParamDC = OuterCtx;
1292 "We should have been looking only at file context here already.");
1325 if (M || !isa<NamedDecl>(Entity) || !cast<NamedDecl>(Entity)->isHidden())
1328 "hidden entity from AST file has no owning module");
1330 if (!getLangOpts().ModulesLocalVisibility) {
1336 assert(Parent->isHidden() &&
"unexpectedly hidden decl");
1337 return getOwningModule(Parent);
1345 if (
auto *Containing =
1346 PP.getModuleContainingLocation(Entity->
getLocation())) {
1351 cast<NamedDecl>(Entity)->setHidden(
false);
1356 if (!CachedFakeTopLevelModule) {
1357 CachedFakeTopLevelModule =
1358 PP.getHeaderSearchInfo().getModuleMap().findOrCreateModule(
1359 "<top-level>",
nullptr,
false,
false).first;
1361 auto &SrcMgr = PP.getSourceManager();
1363 SrcMgr.getLocForStartOfFile(SrcMgr.getMainFileID());
1365 VisibleModulesStack.empty() ? VisibleModules : VisibleModulesStack[0];
1366 TopLevel.setVisible(CachedFakeTopLevelModule, StartLoc);
1369 M = CachedFakeTopLevelModule;
1378 if (
auto *M = PP.getModuleContainingLocation(Loc))
1386 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1387 for (
auto *Param : *TD->getTemplateParameters())
1388 makeMergedDefinitionVisible(Param, Loc);
1393 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1398 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1401 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1404 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1419 unsigned N = ActiveTemplateInstantiations.size();
1420 for (
unsigned I = ActiveTemplateInstantiationLookupModules.size();
1424 if (M && !LookupModulesCache.insert(M).second)
1426 ActiveTemplateInstantiationLookupModules.push_back(M);
1428 return LookupModulesCache;
1433 if (isModuleVisible(Merged))
1438 template<
typename ParmDecl>
1442 if (!D->hasDefaultArgument())
1446 auto &DefaultArg = D->getDefaultArgStorage();
1447 if (!DefaultArg.isInherited() && S.
isVisible(D))
1450 if (!DefaultArg.isInherited() && Modules) {
1451 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1454 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1458 D = DefaultArg.getInheritedFrom();
1465 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1467 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1481 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1482 assert(D->
isHidden() &&
"should not call this: not in slow case");
1483 Module *DeclModule =
nullptr;
1485 if (SemaRef.
getLangOpts().ModulesLocalVisibility) {
1489 assert(!D->
isHidden() &&
"hidden decl not from a module");
1511 ? isVisible(SemaRef, cast<NamedDecl>(DC))
1527 if (LookupModules.empty())
1532 assert(DeclModule &&
"hidden decl not from a module");
1536 if (LookupModules.count(DeclModule))
1545 return std::any_of(LookupModules.begin(), LookupModules.end(),
1546 [&](
Module *M) {
return M->isModuleVisible(DeclModule); });
1549 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1572 for (
auto RD : D->
redecls()) {
1573 if (
auto ND = dyn_cast<NamedDecl>(RD)) {
1619 if (!Name)
return false;
1634 FindLocalExternScope FindLocals(R);
1640 bool LeftStartingScope =
false;
1643 IEnd = IdResolver.end();
1646 if (NameKind == LookupRedeclarationWithLinkage) {
1650 LeftStartingScope =
true;
1654 if (LeftStartingScope && !((*I)->hasLinkage())) {
1659 else if (NameKind == LookupObjCImplicitSelfParam &&
1660 !isa<ImplicitParamDecl>(*I))
1685 for (++LastI; LastI != IEnd; ++LastI) {
1710 if (CppLookupName(R, S))
1724 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1756 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1759 if (UsingDirectives.begin() == UsingDirectives.end())
return false;
1762 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1763 Visited.insert(StartDC);
1771 for (
auto *I : UsingDirectives) {
1772 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
1773 if (Visited.insert(ND).second)
1774 Queue.push_back(ND);
1781 bool FoundTag =
false;
1782 bool FoundNonTag =
false;
1787 while (!Queue.empty()) {
1792 bool UseLocal = !R.
empty();
1821 if (Visited.insert(Nom).second)
1822 Queue.push_back(Nom);
1827 if (FoundTag && FoundNonTag)
1847 template<
typename InputIterator>
1850 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1853 if (isa<CXXMethodDecl>(D)) {
1855 bool AllMethodsAreStatic =
true;
1856 for(; First !=
Last; ++First) {
1857 D = (*First)->getUnderlyingDecl();
1859 if (!isa<CXXMethodDecl>(D)) {
1860 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1864 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1865 AllMethodsAreStatic =
false;
1870 if (AllMethodsAreStatic)
1900 bool InUnqualifiedLookup) {
1901 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
1907 assert((!isa<TagDecl>(LookupCtx) ||
1909 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
1910 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
1911 "Declaration context must already be complete!");
1913 struct QualifiedLookupInScope {
1920 ~QualifiedLookupInScope() {
1921 Context->setUseQualifiedLookup(oldVal);
1927 if (isa<CXXRecordDecl>(LookupCtx))
1973 case LookupObjCImplicitSelfParam:
1974 case LookupOrdinaryName:
1975 case LookupMemberName:
1976 case LookupRedeclarationWithLinkage:
1977 case LookupLocalFriendName:
1989 case LookupUsingDeclName:
1992 case LookupOperatorName:
1993 case LookupNamespaceName:
1994 case LookupObjCProtocolName:
1999 case LookupNestedNameSpecifierName:
2007 return BaseCallback(Specifier, Path, Name);
2012 R.setNamingClass(LookupRec);
2021 int SubobjectNumber = 0;
2025 Path != PathEnd; ++Path) {
2030 SubobjectAccess = std::min(SubobjectAccess, Path->Access);
2033 if (SubobjectType.isNull()) {
2050 while (FirstD != FirstPath->Decls.end() &&
2051 CurrentD != Path->Decls.end()) {
2052 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2053 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2060 if (FirstD == FirstPath->Decls.end() &&
2061 CurrentD == Path->Decls.end())
2065 R.setAmbiguousBaseSubobjectTypes(Paths);
2081 R.setAmbiguousBaseSubobjects(Paths);
2088 for (
auto *D : Paths.front().Decls) {
2142 bool AllowBuiltinCreation,
bool EnteringContext) {
2149 if (SS && SS->
isSet()) {
2173 return LookupName(R, S, AllowBuiltinCreation);
2190 for (
const auto &BaseSpec : Class->
bases()) {
2192 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2205 Result.suppressDiagnostics();
2219 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2228 QualType SubobjectType = Paths->
front().back().Base->getType();
2229 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2234 while (isa<CXXMethodDecl>(*Found) &&
2235 cast<CXXMethodDecl>(*Found)->isStatic())
2238 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2243 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2244 << Name << LookupRange;
2247 std::set<Decl *> DeclsPrinted;
2249 PathEnd = Paths->
end();
2250 Path != PathEnd; ++Path) {
2251 Decl *D = Path->Decls.front();
2252 if (DeclsPrinted.insert(D).second)
2259 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2261 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2263 for (
auto *D : Result)
2264 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2265 TagDecls.insert(TD);
2266 Diag(TD->getLocation(), diag::note_hidden_tag);
2269 for (
auto *D : Result)
2270 if (!isa<TagDecl>(D))
2276 if (TagDecls.count(F.
next()))
2284 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2286 for (
auto *D : Result)
2294 struct AssociatedLookup {
2298 : S(S), Namespaces(Namespaces), Classes(Classes),
2299 InstantiationLoc(InstantiationLoc) {
2356 DeclContext *Ctx = ClassTemplate->getDeclContext();
2357 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2358 Result.Classes.insert(EnclosingClass);
2388 if (Class->
getDeclName() == Result.S.VAListTagName)
2401 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2402 Result.Classes.insert(EnclosingClass);
2412 if (!Result.Classes.insert(Class).second)
2425 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2426 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2427 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2428 Result.Classes.insert(EnclosingClass);
2433 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++
I)
2438 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2439 Result.S.Context.getRecordType(Class)))
2445 Bases.push_back(Class);
2446 while (!Bases.empty()) {
2448 Class = Bases.pop_back_val();
2451 for (
const auto &
Base : Class->
bases()) {
2462 if (Result.Classes.insert(BaseDecl).second) {
2469 Bases.push_back(BaseDecl);
2497 #define TYPE(Class, Base)
2498 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
2499 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
2500 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
2501 #define ABSTRACT_TYPE(Class, Base)
2502 #include "clang/AST/TypeNodes.def"
2513 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2515 case Type::ConstantArray:
2516 case Type::IncompleteArray:
2517 case Type::VariableArray:
2531 case Type::Record: {
2533 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2543 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2546 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2547 Result.Classes.insert(EnclosingClass);
2558 case Type::FunctionProto: {
2561 Queue.push_back(Arg.getTypePtr());
2564 case Type::FunctionNoProto: {
2579 case Type::MemberPointer: {
2583 Queue.push_back(MemberPtr->
getClass());
2591 case Type::BlockPointer:
2592 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2597 case Type::LValueReference:
2598 case Type::RValueReference:
2599 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2604 case Type::ExtVector:
2615 case Type::ObjCObject:
2616 case Type::ObjCInterface:
2617 case Type::ObjCObjectPointer:
2618 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2624 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2633 T = Queue.pop_back_val();
2648 AssociatedNamespaces.clear();
2649 AssociatedClasses.clear();
2651 AssociatedLookup
Result(*
this, InstantiationLoc,
2652 AssociatedNamespaces, AssociatedClasses);
2661 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2662 Expr *Arg = Args[ArgIdx];
2679 Arg = unaryOp->getSubExpr();
2684 for (
const auto *D : ULE->
decls()) {
2710 return cast_or_null<ObjCProtocolDecl>(D);
2726 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2736 bool VolatileThis) {
2738 "doing special member lookup into record that isn't fully complete");
2740 if (RValueThis || ConstThis || VolatileThis)
2742 "constructors and destructors always have unqualified lvalue this");
2743 if (ConstArg || VolatileArg)
2745 "parameter-less special members can't have qualified arguments");
2747 llvm::FoldingSetNodeID
ID;
2750 ID.AddInteger(ConstArg);
2751 ID.AddInteger(VolatileArg);
2752 ID.AddInteger(RValueThis);
2753 ID.AddInteger(ConstThis);
2754 ID.AddInteger(VolatileThis);
2772 assert(DD &&
"record without a destructor");
2784 Expr *Arg =
nullptr;
2857 "lookup for a constructor or assignment operator was empty");
2867 for (
auto *Cand : Candidates) {
2868 if (Cand->isInvalidDecl())
2876 Cand = U->getTargetDecl();
2878 if (Cand->isInvalidDecl())
2885 Classification, llvm::makeArrayRef(&Arg, NumArgs),
2889 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2891 dyn_cast<FunctionTemplateDecl>(Cand)) {
2894 RD,
nullptr, ThisTy, Classification,
2895 llvm::makeArrayRef(&Arg, NumArgs),
2899 nullptr, llvm::makeArrayRef(&Arg, NumArgs),
2902 assert(isa<UsingDecl>(Cand) &&
"illegal Kind of operator = Decl");
2909 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
2914 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
2938 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
2945 "non-const, non-volatile qualifiers for copy ctor arg");
2950 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
2960 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
2977 return Class->
lookup(Name);
2982 unsigned Quals,
bool RValueThis,
2983 unsigned ThisQuals) {
2985 "non-const, non-volatile qualifiers for copy assignment arg");
2987 "non-const, non-volatile qualifiers for copy assignment this");
2991 ThisQuals & Qualifiers::Const,
2992 ThisQuals & Qualifiers::Volatile);
3001 unsigned ThisQuals) {
3003 "non-const, non-volatile qualifiers for copy assignment this");
3007 ThisQuals & Qualifiers::Const,
3008 ThisQuals & Qualifiers::Volatile);
3021 false,
false,
false,
3034 bool AllowRaw,
bool AllowTemplate,
3035 bool AllowStringTemplate) {
3038 "literal operator lookup can't be ambiguous");
3043 bool FoundRaw =
false;
3044 bool FoundTemplate =
false;
3045 bool FoundStringTemplate =
false;
3046 bool FoundExactMatch =
false;
3048 while (F.hasNext()) {
3051 D = USD->getTargetDecl();
3060 bool IsTemplate =
false;
3061 bool IsStringTemplate =
false;
3062 bool IsExactMatch =
false;
3065 if (FD->getNumParams() == 1 &&
3066 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3068 else if (FD->getNumParams() == ArgTys.size()) {
3069 IsExactMatch =
true;
3070 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3071 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3073 IsExactMatch =
false;
3081 if (Params->
size() == 1)
3084 IsStringTemplate =
true;
3088 FoundExactMatch =
true;
3090 AllowTemplate =
false;
3091 AllowStringTemplate =
false;
3092 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3096 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3098 }
else if (AllowRaw && IsRaw) {
3100 }
else if (AllowTemplate && IsTemplate) {
3101 FoundTemplate =
true;
3102 }
else if (AllowStringTemplate && IsStringTemplate) {
3103 FoundStringTemplate =
true;
3114 if (FoundExactMatch)
3119 if (FoundRaw && FoundTemplate) {
3132 if (FoundStringTemplate)
3138 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3139 << (AllowTemplate || AllowStringTemplate);
3148 if (Old ==
nullptr || Old == New) {
3163 if (!Cursor)
return;
3166 if (Cursor == OldFD)
break;
3181 AssociatedNamespaces,
3195 for (
auto *NS : AssociatedNamespaces) {
3216 bool DeclaredInAssociatedClass =
false;
3219 if (isa<CXXRecordDecl>(LexDC) &&
3220 AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)) &&
3222 DeclaredInAssociatedClass =
true;
3226 if (!DeclaredInAssociatedClass)
3230 if (isa<UsingShadowDecl>(D))
3231 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3233 if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D))
3253 class ShadowContextRAII;
3255 class VisibleDeclsRecord {
3260 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3265 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3268 std::list<ShadowMap> ShadowMaps;
3271 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3273 friend class ShadowContextRAII;
3279 return !VisitedContexts.insert(Ctx).second;
3283 return VisitedContexts.count(Ctx);
3295 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3300 class ShadowContextRAII {
3301 VisibleDeclsRecord &Visible;
3303 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3306 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3307 Visible.ShadowMaps.emplace_back();
3310 ~ShadowContextRAII() {
3311 Visible.ShadowMaps.pop_back();
3319 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3320 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3321 SM != SMEnd; ++
SM) {
3323 if (Pos == SM->end())
3326 for (
auto *D : Pos->second) {
3344 SM == ShadowMaps.rbegin())
3356 bool QualifiedNameLookup,
3359 VisibleDeclsRecord &Visited) {
3368 if (isa<TranslationUnitDecl>(Ctx) &&
3371 auto &Idents = S.Context.Idents;
3375 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3376 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3381 for (
const auto &Ident : Idents) {
3382 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3383 E = S.IdResolver.end();
3385 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3387 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3404 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3411 if (QualifiedNameLookup) {
3412 ShadowContextRAII Shadow(Visited);
3415 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3421 if (!Record->hasDefinition())
3424 for (
const auto &B : Record->bases()) {
3456 ShadowContextRAII Shadow(Visited);
3458 true, Consumer, Visited);
3465 for (
auto *Cat : IFace->visible_categories()) {
3466 ShadowContextRAII Shadow(Visited);
3472 for (
auto *I : IFace->all_referenced_protocols()) {
3473 ShadowContextRAII Shadow(Visited);
3479 if (IFace->getSuperClass()) {
3480 ShadowContextRAII Shadow(Visited);
3482 true, Consumer, Visited);
3487 if (IFace->getImplementation()) {
3488 ShadowContextRAII Shadow(Visited);
3490 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3493 for (
auto *I : Protocol->protocols()) {
3494 ShadowContextRAII Shadow(Visited);
3499 for (
auto *I :
Category->protocols()) {
3500 ShadowContextRAII Shadow(Visited);
3506 if (
Category->getImplementation()) {
3507 ShadowContextRAII Shadow(Visited);
3509 QualifiedNameLookup,
true, Consumer, Visited);
3515 UnqualUsingDirectiveSet &UDirs,
3517 VisibleDeclsRecord &Visited) {
3523 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3525 FindLocalExternScope FindLocals(Result);
3527 for (
auto *D : S->
decls()) {
3528 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3530 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3548 if (Method->isInstanceMethod()) {
3554 false, Consumer, Visited);
3568 false, Consumer, Visited);
3582 false, Consumer, Visited);
3588 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3591 false, Consumer, Visited);
3595 ShadowContextRAII Shadow(Visited);
3601 bool IncludeGlobalScope) {
3605 UnqualUsingDirectiveSet UDirs;
3611 UDirs.visitScopeChain(Initial, S);
3618 VisibleDeclsRecord Visited;
3619 if (!IncludeGlobalScope)
3621 ShadowContextRAII Shadow(Visited);
3627 bool IncludeGlobalScope) {
3630 VisibleDeclsRecord Visited;
3631 if (!IncludeGlobalScope)
3633 ShadowContextRAII Shadow(Visited);
3635 false, Consumer, Visited);
3650 Scope *S = CurScope;
3652 return cast<LabelDecl>(Res);
3665 assert(S &&
"Not in a function?");
3668 return cast<LabelDecl>(Res);
3686 bool EnteringContext,
3687 bool isObjCIvarLookup,
3699 for (; DI != DE; ++DI)
3707 bool AnyVisibleDecls = !NewDecls.empty();
3709 for (; DI != DE; ++DI) {
3715 if (!AnyVisibleDecls) {
3717 AnyVisibleDecls =
true;
3720 NewDecls.push_back(VisibleDecl);
3721 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3722 NewDecls.push_back(*DI);
3725 if (NewDecls.empty())
3742 Identifiers.clear();
3772 Identifiers.push_back(II);
3800 addName(Name,
nullptr);
3806 addName(Keyword,
nullptr,
nullptr,
true);
3809 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3813 StringRef TypoStr = Typo->
getName();
3814 unsigned MinED = abs((
int)Name.size() - (int)TypoStr.size());
3815 if (MinED && TypoStr.size() / MinED < 3)
3820 unsigned UpperBound = (TypoStr.size() + 2) / 3 + 1;
3821 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
3822 if (ED >= UpperBound)
return;
3833 StringRef TypoStr = Typo->
getName();
3839 if (TypoStr.size() < 3 &&
3840 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
3853 if (!CList.empty() && !CList.back().isResolved())
3858 RI != RIEnd; ++RI) {
3863 if (RI->getCorrectionDecl() == NewND) {
3864 if (CorrectionStr < RI->getAsString(SemaRef.
getLangOpts()))
3870 if (CList.empty() || Correction.
isResolved())
3871 CList.push_back(Correction);
3874 CorrectionResults.erase(std::prev(CorrectionResults.end()));
3878 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
3879 SearchNamespaces =
true;
3881 for (
auto KNPair : KnownNamespaces)
3882 Namespaces.addNameSpecifier(KNPair.first);
3884 bool SSIsTemplate =
false;
3886 (SS && SS->isValid()) ? SS->getScopeRep() :
nullptr) {
3887 if (
const Type *T = NNS->getAsType())
3888 SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization;
3894 for (
unsigned I = 0; I != Types.size(); ++
I) {
3895 const auto *TI = Types[
I];
3897 CD = CD->getCanonicalDecl();
3898 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
3899 !CD->isUnion() && CD->getIdentifier() &&
3900 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
3901 (CD->isBeingDefined() || CD->isCompleteDefinition()))
3902 Namespaces.addNameSpecifier(CD);
3908 if (++CurrentTCIndex < ValidatedCorrections.size())
3909 return ValidatedCorrections[CurrentTCIndex];
3911 CurrentTCIndex = ValidatedCorrections.size();
3912 while (!CorrectionResults.empty()) {
3913 auto DI = CorrectionResults.begin();
3914 if (DI->second.empty()) {
3915 CorrectionResults.erase(DI);
3919 auto RI = DI->second.begin();
3920 if (RI->second.empty()) {
3921 DI->second.erase(RI);
3922 performQualifiedLookups();
3928 ValidatedCorrections.push_back(TC);
3929 return ValidatedCorrections[CurrentTCIndex];
3932 return ValidatedCorrections[0];
3935 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
3942 CorrectionValidator->IsObjCIvarLookup,
3954 if (TempMemberContext) {
3957 TempMemberContext =
nullptr;
3960 if (SearchNamespaces)
3961 QualifiedResults.push_back(Candidate);
3971 for (
auto *TRD : Result)
3975 if (SearchNamespaces)
3976 QualifiedResults.push_back(Candidate);
3985 void TypoCorrectionConsumer::performQualifiedLookups() {
3986 unsigned TypoLen = Typo->
getName().size();
3987 for (
auto QR : QualifiedResults) {
3988 for (
auto NSI : Namespaces) {
3990 const Type *NSType = NSI.NameSpecifier->getAsType();
3998 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4003 TC.ClearCorrectionDecls();
4004 TC.setCorrectionSpecifier(NSI.NameSpecifier);
4005 TC.setQualifierDistance(NSI.EditDistance);
4006 TC.setCallbackDistance(0);
4011 unsigned TmpED = TC.getEditDistance(
true);
4012 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4013 TypoLen / TmpED < 3)
4017 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4023 switch (Result.getResultKind()) {
4026 if (SS && SS->isValid()) {
4027 std::string NewQualified = TC.getAsString(SemaRef.
getLangOpts());
4028 std::string OldQualified;
4029 llvm::raw_string_ostream OldOStream(OldQualified);
4031 OldOStream << Typo->
getName();
4035 if (OldOStream.str() == NewQualified)
4039 TRD != TRDEnd; ++TRD) {
4044 TC.addCorrectionDecl(*TRD);
4046 if (TC.isResolved()) {
4047 TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
4060 QualifiedResults.clear();
4063 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4065 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4067 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4068 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4076 for (DeclContextList::reverse_iterator
C = CurContextChain.rbegin(),
4077 CEnd = CurContextChain.rend();
4086 DistanceMap[1].push_back(SI);
4089 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4091 assert(Start &&
"Building a context chain from a null context");
4092 DeclContextList Chain;
4104 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4106 unsigned NumSpecifiers = 0;
4107 for (DeclContextList::reverse_iterator
C = DeclChain.rbegin(),
4108 CEnd = DeclChain.rend();
4113 }
else if (
RecordDecl *RD = dyn_cast_or_null<RecordDecl>(*
C)) {
4115 RD->getTypeForDecl());
4119 return NumSpecifiers;
4122 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4125 unsigned NumSpecifiers = 0;
4126 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4127 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4130 for (DeclContextList::reverse_iterator
C = CurContextChain.rbegin(),
4131 CEnd = CurContextChain.rend();
4132 C != CEnd && !NamespaceDeclChain.empty() &&
4133 NamespaceDeclChain.back() == *
C; ++
C) {
4134 NamespaceDeclChain.pop_back();
4138 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4141 if (NamespaceDeclChain.empty()) {
4145 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4147 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4149 bool SameNameSpecifier =
false;
4150 if (std::find(CurNameSpecifierIdentifiers.begin(),
4151 CurNameSpecifierIdentifiers.end(),
4152 Name) != CurNameSpecifierIdentifiers.end()) {
4153 std::string NewNameSpecifier;
4154 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4158 SpecifierOStream.flush();
4159 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4161 if (SameNameSpecifier ||
4162 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4163 Name) != CurContextIdentifiers.end()) {
4167 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4175 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4178 NumSpecifiers = llvm::ComputeEditDistance(
4179 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4180 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4183 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4184 DistanceMap[NumSpecifiers].push_back(SI);
4193 bool EnteringContext,
4194 bool isObjCIvarLookup,
4200 if (MemberContext) {
4202 if (isObjCIvarLookup) {
4203 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4227 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4232 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4244 bool AfterNestedNameSpecifier) {
4245 if (AfterNestedNameSpecifier) {
4258 static const char *
const CTypeSpecs[] = {
4259 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4260 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4261 "_Complex",
"_Imaginary",
4263 "extern",
"inline",
"static",
"typedef"
4266 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4267 for (
unsigned I = 0; I != NumCTypeSpecs; ++
I)
4294 static const char *
const CastableTypeSpecs[] = {
4295 "char",
"double",
"float",
"int",
"long",
"short",
4296 "signed",
"unsigned",
"void"
4298 for (
auto *kw : CastableTypeSpecs)
4317 static const char *
const CXXExprs[] = {
4318 "delete",
"new",
"operator",
"throw",
"typeid"
4320 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4321 for (
unsigned I = 0; I != NumCXXExprs; ++
I)
4324 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4325 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4344 static const char *
const CStmts[] = {
4345 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4346 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4347 for (
unsigned I = 0; I != NumCStmts; ++
I)
4391 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4394 std::unique_ptr<CorrectionCandidateCallback> CCC,
4431 locs->second.count(TypoName.
getLoc()))
4458 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4459 *
this, TypoName, LookupKind,
S, SS, std::move(CCC), MemberContext,
4463 bool IsUnqualifiedLookup =
false;
4465 if (MemberContext) {
4470 for (
auto *I : OPT->
quals())
4473 }
else if (SS && SS->isSet()) {
4480 IsUnqualifiedLookup =
true;
4485 bool SearchNamespaces
4487 (IsUnqualifiedLookup || (SS && SS->isSet()));
4489 if (IsUnqualifiedLookup || SearchNamespaces) {
4493 for (
const auto &I : Context.
Idents)
4500 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4502 StringRef Name = Iter->Next();
4515 if (SearchNamespaces) {
4517 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4519 LoadedExternalKnownNamespaces =
true;
4521 for (
auto *N : ExternalKnownNamespaces)
4522 KnownNamespaces[N] =
true;
4525 Consumer->addNamespaces(KnownNamespaces);
4565 std::unique_ptr<CorrectionCandidateCallback> CCC,
4568 bool EnteringContext,
4570 bool RecordFailure) {
4571 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4575 if (ExternalSource) {
4577 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4585 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4588 auto Consumer = makeTypoCorrectionConsumer(
4589 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4597 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4601 unsigned ED =
Consumer->getBestEditDistance(
true);
4602 unsigned TypoLen = Typo->
getName().size();
4603 if (ED > 0 && TypoLen / ED < 3)
4604 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4609 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4611 ED = BestTC.getEditDistance();
4613 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4617 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4621 if (!SecondBestTC ||
4622 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4628 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4634 }
else if (SecondBestTC && ObjCMessageReceiver) {
4638 if (BestTC.getCorrection().getAsString() !=
"super") {
4640 BestTC = SecondBestTC;
4641 else if ((*
Consumer)[
"super"].front().isKeyword())
4642 BestTC = (*
Consumer)[
"super"].front();
4646 if (BestTC.getEditDistance() == 0 ||
4647 BestTC.getCorrection().getAsString() !=
"super")
4648 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4657 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4701 std::unique_ptr<CorrectionCandidateCallback> CCC,
4705 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4708 auto Consumer = makeTypoCorrectionConsumer(
4709 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4717 unsigned ED =
Consumer->getBestEditDistance(
true);
4719 if (ED > 0 && Typo->
getName().size() / ED < 3)
4723 return createDelayedTypo(std::move(
Consumer), std::move(TDG), std::move(TRC));
4730 CorrectionDecls.clear();
4732 CorrectionDecls.push_back(CDecl);
4734 if (!CorrectionName)
4739 if (CorrectionNameSpec) {
4740 std::string tmpBuffer;
4741 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4743 PrefixOStream << CorrectionName;
4744 return PrefixOStream.str();
4759 bool HasNonType =
false;
4760 bool HasStaticMethod =
false;
4761 bool HasNonStaticMethod =
false;
4762 for (
Decl *D : candidate) {
4764 D = FTD->getTemplatedDecl();
4766 if (Method->isStatic())
4767 HasStaticMethod =
true;
4769 HasNonStaticMethod =
true;
4771 if (!isa<TypeDecl>(D))
4776 !candidate.getCorrectionSpecifier())
4783 bool HasExplicitTemplateArgs,
4785 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4786 CurContext(SemaRef.CurContext), MemberFn(ME) {
4796 for (
auto *
C : candidate) {
4800 FD = FTD->getTemplatedDecl();
4801 if (!HasExplicitTemplateArgs && !FD) {
4802 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4806 QualType ValType = cast<ValueDecl>(ND)->getType();
4810 if (FPT->getNumParams() == NumArgs)
4826 if (MemberFn || !MD->isStatic()) {
4829 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
4830 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
4845 bool ErrorRecovery) {
4853 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
4854 return VD->getDefinition();
4855 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
4856 return FD->isDefined(FD) ?
const_cast<FunctionDecl*
>(FD) :
nullptr;
4857 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
4858 return TD->getDefinition();
4860 return ID->getDefinition();
4862 return PD->getDefinition();
4869 bool NeedDefinition,
bool Recover) {
4870 assert(!
isVisible(Decl) &&
"missing import for non-hidden decl?");
4881 assert(Owner &&
"definition of hidden declaration is not in a module");
4884 OwningModules.push_back(Owner);
4886 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
4898 assert(!Modules.empty());
4900 if (Modules.size() > 1) {
4901 std::string ModuleList;
4903 for (
Module *M : Modules) {
4904 ModuleList +=
"\n ";
4905 if (++N == 5 && N != Modules.size()) {
4906 ModuleList +=
"[...]";
4909 ModuleList += M->getFullModuleName();
4912 Diag(UseLoc, diag::err_module_unimported_use_multiple)
4913 << (int)MIK << Decl << ModuleList;
4915 Diag(UseLoc, diag::err_module_unimported_use)
4916 << (int)MIK << Decl << Modules[0]->getFullModuleName();
4922 DiagID = diag::note_previous_declaration;
4925 DiagID = diag::note_previous_definition;
4928 DiagID = diag::note_default_argument_declared_here;
4931 Diag(DeclLoc, DiagID);
4953 bool ErrorRecovery) {
4962 assert(Decl &&
"import required but no declaration to import");
4965 false, ErrorRecovery);
4970 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
4975 Diag(ChosenDecl->getLocation(), PrevNote)
4976 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
4979 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
4980 TypoDiagnosticGenerator TDG,
4981 TypoRecoveryCallback TRC) {
4982 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
4984 auto &
State = DelayedTypos[TE];
4985 State.Consumer = std::move(TCC);
4986 State.DiagHandler = std::move(TDG);
4987 State.RecoveryHandler = std::move(TRC);
4992 auto Entry = DelayedTypos.find(TE);
4993 assert(Entry != DelayedTypos.end() &&
4994 "Failed to get the state for a TypoExpr!");
4995 return Entry->second;
4999 DelayedTypos.erase(TE);
unsigned getFlags() const
getFlags - Return the flags for this scope.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Name lookup found a set of overloaded functions that met the criteria.
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.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
void setOrigin(CXXRecordDecl *Rec)
no exception specification
IdentifierInfo * getSuperIdentifier() const
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
void setHidden(bool Hide)
Set whether this declaration is hidden from name lookup.
ExtInfo withCallingConv(CallingConv cc) const
QualType getType() const
Retrieves the type of the base class.
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
Template argument deduction was successful.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
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.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
DeclClass * getAsSingle() 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.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Provides information about an attempted template argument deduction, whose success or failure was des...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
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...
void erase()
Erase the last element returned from this iterator.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
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.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
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...
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.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
MissingImportKind
Kinds of missing import.
QualType getRecordType(const RecordDecl *Decl) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Ambiguous candidates found.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Look up of a name that precedes the '::' scope resolution operator in C++.
void makeKeyword()
Mark this TypoCorrection as being a keyword.
IdentifierInfo * getFloat128Identifier() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
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.
Represents a C++ constructor within a class.
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
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...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
An identifier, stored as an IdentifierInfo*.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
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.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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.
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited)
DiagnosticsEngine & Diags
static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last)
Determine whether the given set of member declarations contains only static members, nested types, and enumerators.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
AccessSpecifier getAccess() const
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point...
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.
A namespace, stored as a NamespaceDecl*.
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
SpecialMemberOverloadResult * LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
virtual TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, int LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, DeclContext *MemberContext, bool EnteringContext, const ObjCObjectPointerType *OPT)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
Look up an ordinary name that is going to be redeclared as a name with linkage.
Defines the clang::Expr interface and subclasses for C++ expressions.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
void addKeywordResult(StringRef Keyword)
bool WantExpressionKeywords
std::list< CXXBasePath >::const_iterator const_paths_iterator
void setMethod(CXXMethodDecl *MD)
const SmallVectorImpl< Type * > & getTypes() const
Types, declared with 'struct foo', typedefs, etc.
static Decl * getInstantiatedFrom(Decl *D, MemberSpecializationInfo *MSInfo)
Find the declaration that a class temploid member specialization was instantiated from...
RecordDecl - Represents a struct/union/class.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
DeclarationName getName() const
getName - Returns the embedded declaration name.
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...
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
IdentifierInfo * getCorrectionAsIdentifierInfo() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool isReferenceType() const
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.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true)
bool isAnyPointerType() const
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations, so that repeated attempts to correct an identifier in a given location are ignored if typo correction already failed for it.
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.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
unsigned getIdentifierNamespace() const
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
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 isInlineNamespace() const
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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...
Describes a module or submodule.
llvm::BumpPtrAllocator BumpAlloc
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.
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
param_type_range param_types() const
Look up implicit 'self' parameter of an objective-c method.
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)
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.
Succeeded, but refers to a deleted function.
unsigned getDiagID() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
QualType getReturnType() const
Look up all declarations in a scope with the given name, including resolved using declarations...
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
static NamedDecl * getDefinitionToImport(NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
AmbiguityKind getAmbiguityKind() const
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
The lookup found an overload set of literal operator templates, which expect the character type and c...
TypeDecl - Represents a declaration of a type.
A set of unresolved declarations.
RecordDecl * getDecl() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
static unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, bool Redeclaration)
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.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
std::string getQuoted(const LangOptions &LO) const
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.
TypeClass getTypeClass() const
base_class_iterator bases_begin()
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
Represents an Objective-C protocol declaration.
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.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
Labels, declared with 'x:' and referenced with 'goto x'.
void setLocalOwningModule(Module *M)
Module * getLocalOwningModule() const
Get the local owning module, if known.
const TypoCorrection & getNextCorrection()
Return the next typo correction that passes all internal filters and is deemed valid by the consumer'...
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.
detail::InMemoryDirectory::const_iterator I
QualType getCanonicalTypeInternal() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
SourceRange getRange() const
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
CXXMethodDecl * getMethod() const
static const unsigned InvalidDistance
CXXSpecialMember
Kinds of C++ special members.
bool WantRemainingKeywords
Sema - This implements semantic analysis and AST building for C.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
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...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Represents a prototype with parameter type info, e.g.
This declaration is a C++ operator declared in a non-class context.
llvm::iterator_range< decls_iterator > decls() const
ArrayRef< Module * > getModulesWithMergedDefinition(NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
The return type of classify().
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
DeclarationNameTable DeclarationNames
Provides lookups to, and iteration over, IdentiferInfo objects.
ID
Defines the set of possible language-specific address spaces.
lookups_range lookups() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
This declaration is a friend class.
static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Callback that looks for any member of a class with the given name.
virtual void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces)
Load the set of namespaces that are known to the external source, which will be used during typo corr...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, DeclContext *StartDC)
Perform qualified name lookup in the namespaces nominated by using directives by the given context...
bool isDeleted() const
Whether this function has been deleted.
Expr - This represents one expression.
Defines the clang::LangOptions interface.
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
StringRef getName() const
Return the actual identifier string.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool hasFatalErrorOccurred() const
llvm::iterator_range< udir_iterator > udir_range
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to...
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isModuleVisible(Module *M)
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
conversion_iterator conversion_end() const
Represents a C++ destructor within a class.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void setRequiresImport(bool Req)
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
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...
Overload resolution succeeded.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Represents a C++ template name within the type system.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
llvm::SmallPtrSet< CXXRecordDecl *, 16 > AssociatedClassSet
bool isFunctionOrMethod() const
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D)
Retrieve the visible declaration corresponding to D, if any.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
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.
void addCorrection(TypoCorrection Correction)
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
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...
bool isExternallyVisible() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
DiagnosticsEngine & getDiagnostics() const
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
The result type of a method or function.
llvm::FoldingSet< SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
A type, stored as a Type*.
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
const clang::PrintingPolicy & getPrintingPolicy() const
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
const TypoExprState & getTypoExprState(TypoExpr *TE) const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
virtual bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)=0
Check global module index for missing imports.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this 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.
DeclContext * getEntity() const
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Tag name lookup, which finds the names of enums, classes, structs, and unions.
void setCorrectionDecls(ArrayRef< NamedDecl * > Decls)
Clears the list of NamedDecls and adds the given set.
bool hasTagIdentifierNamespace() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function 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.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
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...
const TemplateArgument * iterator
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier *NNS, SmallVectorImpl< const IdentifierInfo * > &Identifiers)
TagDecl - Represents the declaration of a struct/union/class/enum.
IdentifierInfo * getMakeIntegerSeqName() const
ASTContext & getASTContext() const
void FoundName(StringRef Name)
LabelDecl - Represents the declaration of a label.
bool hasVisibleMergedDefinition(NamedDecl *Def)
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isInvalid() const
An error occurred during parsing of the scope specifier.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
Name lookup found an unresolvable value declaration and cannot yet complete.
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
ObjCCategoryDecl - Represents a category declaration.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Look up any declaration with any name.
A class for iterating through a result set and possibly filtering out results.
Represents one property declaration in an Objective-C interface.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
SourceLocation getBegin() const
llvm::SmallPtrSet< DeclContext *, 16 > AssociatedNamespaceSet
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
No entity found met the criteria.
bool isFileContext() const
sema::FunctionScopeInfo * getCurFunction() const
static bool canHideTag(NamedDecl *D)
Determine whether D can hide a tag declaration.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
A class for storing results from argument-dependent lookup.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery...
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.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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 ...
QualType getAsType() const
Retrieve the type for a type template argument.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
static const Type * getElementType(const Expr *BaseExpr)
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
SourceLocation getLocStart() const LLVM_READONLY
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC)
Check whether the declarations found for a typo correction are visible, and if none of them are...
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.).
void setContextRange(SourceRange SR)
Sets a 'context' source range.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
The template argument is a pack expansion of a template name that was provided for a template templat...
bool isExplicitSpecialization() const
bool isInvalidDecl() const
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.
void makeMergedDefinitionVisible(NamedDecl *ND, SourceLocation Loc)
Make a merged definition of an existing hidden definition ND visible at the specified location...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
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.
DeclarationName - The name of a declaration.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
U cast(CodeGen::Address addr)
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
EnumDecl - Represents an enum.
static const unsigned MaxTypoDistanceResultSets
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
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...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
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.
bool empty() const
Return true if no decls were found.
Name lookup found a single declaration that met the criteria.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, bool NeedDefinition, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
std::string getAsString(const LangOptions &LO) const
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...
The template argument is actually a parameter pack.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
This is a scope that can contain a declaration.
TypeDecl * getFloat128StubType() const
Retrieve the declaration for a 128-bit float stub type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
A template argument list.
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...
SourceRange getCorrectionRange() const
const Type * getClass() const
static bool isNamespaceOrTranslationUnitScope(Scope *S)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Represents a C++ struct/union/class.
The template argument is a template name that was provided for a template template parameter...
Look up a friend of a local class.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
ObjCIvarDecl - Represents an ObjC instance variable.
Provides information a specialization of a member of a class template, which may be a member function...
base_class_iterator bases_end()
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
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.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
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...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
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.
This declaration is a function-local extern declaration of a variable or function.
conversion_iterator conversion_begin() const
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
bool isSet() const
Deprecated.
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
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...
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 setUseQualifiedLookup(bool use=true)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
NamedDecl - This represents a decl with a name.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false)
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
Represents C++ using-directive.
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.
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC)
void WillReplaceSpecifier(bool ForceReplacement)
bool WantFunctionLikeCasts
The lookup resulted in an error.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
ExceptionSpecInfo ExceptionSpec
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
iterator - Iterate over the decls of a specified declaration name.
void setFindLocalExtern(bool FindLocalExtern)
std::list< CXXBasePath >::iterator paths_iterator
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static bool isCandidateViable(CorrectionCandidateCallback &CCC, TypoCorrection &Candidate)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
This declaration is a using declaration.
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on #pragma clang __debug dump II.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.