38 #include "llvm/ADT/STLExtras.h"
39 #include "llvm/ADT/SmallPtrSet.h"
40 #include "llvm/ADT/TinyPtrVector.h"
41 #include "llvm/ADT/edit_distance.h"
42 #include "llvm/Support/ErrorHandling.h"
50 using namespace clang;
54 class UnqualUsingEntry {
61 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
65 return CommonAncestor;
74 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
75 return L.getCommonAncestor() < R.getCommonAncestor();
78 bool operator()(
const UnqualUsingEntry &
E,
const DeclContext *DC) {
79 return E.getCommonAncestor() < DC;
82 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
83 return DC < E.getCommonAncestor();
90 class UnqualUsingDirectiveSet {
94 llvm::SmallPtrSet<DeclContext*, 8> visited;
97 UnqualUsingDirectiveSet() {}
99 void visitScopeChain(
Scope *
S,
Scope *InnermostFileScope) {
116 visit(
I, InnermostFileDC);
129 if (!visited.insert(DC).second)
132 addUsingDirectives(DC, EffectiveDC);
140 if (!visited.insert(NS).second)
143 addUsingDirective(UD, EffectiveDC);
144 addUsingDirectives(NS, EffectiveDC);
155 if (visited.insert(NS).second) {
156 addUsingDirective(UD, EffectiveDC);
164 DC = queue.pop_back_val();
179 while (!Common->
Encloses(EffectiveDC))
187 std::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
190 typedef ListTy::const_iterator const_iterator;
192 const_iterator begin()
const {
return list.begin(); }
193 const_iterator end()
const {
return list.end(); }
195 llvm::iterator_range<const_iterator>
197 return llvm::make_range(std::equal_range(begin(), end(),
199 UnqualUsingEntry::Comparator()));
208 bool Redeclaration) {
228 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
267 assert(Redeclaration &&
"should only be used for redecl lookup");
290 void LookupResult::configure() {
292 isForRedeclaration());
297 switch (NameInfo.getName().getCXXOverloadedOperator()) {
301 case OO_Array_Delete:
302 getSema().DeclareGlobalNewDelete();
312 if (
unsigned BuiltinID = Id->getBuiltinID()) {
313 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
319 bool LookupResult::sanity()
const {
321 assert(ResultKind != NotFound || Decls.size() == 0);
322 assert(ResultKind != Found || Decls.size() == 1);
323 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
324 (Decls.size() == 1 &&
325 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
326 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
327 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
328 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
329 Ambiguity == AmbiguousBaseSubobjectTypes)));
330 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
331 (Ambiguity == AmbiguousBaseSubobjectTypes ||
332 Ambiguity == AmbiguousBaseSubobjects)));
363 !isa<UsingShadowDecl>(Existing))
375 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
376 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
377 bool HaveTag = isa<TagDecl>(EUnderlying);
379 return HaveTag != WantTag;
386 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
387 auto *EFD = cast<FunctionDecl>(EUnderlying);
388 unsigned DMin = DFD->getMinRequiredArguments();
389 unsigned EMin = EFD->getMinRequiredArguments();
398 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
399 auto *ETD = cast<TemplateDecl>(EUnderlying);
400 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
401 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
410 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
413 ETD->getTemplateParameters()->getParam(
I)) &&
415 DTD->getTemplateParameters()->getParam(
I)))
422 if (
VarDecl *DVD = dyn_cast<VarDecl>(DUnderlying)) {
423 VarDecl *EVD = cast<VarDecl>(EUnderlying);
425 !DVD->getType()->isIncompleteType()) {
433 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
442 if (Prev == EUnderlying)
462 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
463 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D) ||
464 isa<UnresolvedUsingValueDecl>(D);
469 unsigned N = Decls.size();
473 assert(ResultKind == NotFound ||
474 ResultKind == NotFoundInCurrentInstantiation);
481 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
482 if (isa<FunctionTemplateDecl>(D))
483 ResultKind = FoundOverloaded;
484 else if (isa<UnresolvedUsingValueDecl>(D))
485 ResultKind = FoundUnresolvedValue;
490 if (ResultKind == Ambiguous)
return;
492 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
493 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
495 bool Ambiguous =
false;
496 bool HasTag =
false, HasFunction =
false;
497 bool HasFunctionTemplate =
false, HasUnresolved =
false;
502 unsigned UniqueTagIndex = 0;
511 Decls[
I] = Decls[--N];
521 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
522 QualType T = getSema().Context.getTypeDeclType(TD);
523 auto UniqueResult = UniqueTypes.insert(
525 if (!UniqueResult.second) {
527 ExistingI = UniqueResult.first->second;
534 auto UniqueResult = Unique.insert(std::make_pair(D, I));
535 if (!UniqueResult.second) {
537 ExistingI = UniqueResult.first->second;
546 Decls[*ExistingI] = Decls[
I];
547 Decls[
I] = Decls[--N];
553 if (isa<UnresolvedUsingValueDecl>(D)) {
554 HasUnresolved =
true;
555 }
else if (isa<TagDecl>(D)) {
560 }
else if (isa<FunctionTemplateDecl>(D)) {
562 HasFunctionTemplate =
true;
563 }
else if (isa<FunctionDecl>(D)) {
566 if (HasNonFunction) {
571 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
573 EquivalentNonFunctions.push_back(D);
574 Decls[
I] = Decls[--N];
594 if (N > 1 && HideTags && HasTag && !Ambiguous &&
595 (HasFunction || HasNonFunction || HasUnresolved)) {
596 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
597 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
601 Decls[UniqueTagIndex] = Decls[--N];
608 if (!EquivalentNonFunctions.empty() && !Ambiguous)
609 getSema().diagnoseEquivalentInternalLinkageDeclarations(
610 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
614 if (HasNonFunction && (HasFunction || HasUnresolved))
619 else if (HasUnresolved)
621 else if (N > 1 || HasFunctionTemplate)
627 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
631 DE = I->Decls.end(); DI != DE; ++DI)
638 addDeclsFromBasePaths(*Paths);
640 setAmbiguous(AmbiguousBaseSubobjects);
646 addDeclsFromBasePaths(*Paths);
648 setAmbiguous(AmbiguousBaseSubobjectTypes);
652 Out << Decls.size() <<
" result(s)";
653 if (isAmbiguous()) Out <<
", ambiguous";
654 if (Paths) Out <<
", base paths present";
656 for (
iterator I = begin(), E = end(); I !=
E; ++
I) {
663 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
730 DeclareImplicitDefaultConstructor(Class);
734 DeclareImplicitCopyConstructor(Class);
738 DeclareImplicitCopyAssignment(Class);
740 if (getLangOpts().CPlusPlus11) {
743 DeclareImplicitMoveConstructor(Class);
747 DeclareImplicitMoveAssignment(Class);
752 DeclareImplicitDestructor(Class);
784 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
787 if (Record->needsImplicitDefaultConstructor())
789 if (Record->needsImplicitCopyConstructor())
792 Record->needsImplicitMoveConstructor())
798 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
799 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
808 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
811 if (Record->needsImplicitCopyAssignment())
814 Record->needsImplicitMoveAssignment())
854 !isa<CXXRecordDecl>(DC))
868 auto *ContainedDeducedType =
872 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
906 assert(ConvProto &&
"Nonsensical conversion function template type");
921 Specialization, Info)
936 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
943 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
970 if (OuterS->getEntity()) {
971 Lexical = OuterS->getEntity();
998 if (!Lexical || !DC || !S->
getParent() ||
1000 return std::make_pair(Lexical,
false);
1006 while (OutermostTemplateScope->
getParent() &&
1008 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1022 return std::make_pair(Semantic,
true);
1024 return std::make_pair(Lexical,
false);
1030 struct FindLocalExternScope {
1032 : R(R), OldFindLocalExtern(R.getIdentifierNamespace() &
1033 Decl::IDNS_LocalExtern) {
1039 ~FindLocalExternScope() {
1043 bool OldFindLocalExtern;
1048 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1066 I = IdResolver.begin(Name),
1067 IEnd = IdResolver.end();
1087 UnqualUsingDirectiveSet UDirs;
1088 bool VisitedUsingDirectives =
false;
1089 bool LeftStartingScope =
false;
1093 FindLocalExternScope FindLocals(R);
1097 bool SearchNamespaceScope =
true;
1101 if (NameKind == LookupRedeclarationWithLinkage &&
1102 !(*I)->isTemplateParameter()) {
1108 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1109 LeftStartingScope =
true;
1113 if (LeftStartingScope && !((*I)->hasLinkage())) {
1120 SearchNamespaceScope =
false;
1125 if (!SearchNamespaceScope) {
1128 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1133 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1149 Ctx = OutsideOfTemplateParamDC;
1150 OutsideOfTemplateParamDC =
nullptr;
1155 bool SearchAfterTemplateScope;
1157 if (SearchAfterTemplateScope)
1158 OutsideOfTemplateParamDC = OuterCtx;
1196 if (!VisitedUsingDirectives) {
1199 if (UCtx->isTransparentContext())
1202 UDirs.visit(UCtx, UCtx);
1207 Scope *InnermostFileScope =
S;
1208 while (InnermostFileScope &&
1210 InnermostFileScope = InnermostFileScope->
getParent();
1211 UDirs.visitScopeChain(Initial, InnermostFileScope);
1215 VisitedUsingDirectives =
true;
1232 if (LookupQualifiedName(R, Ctx,
true))
1240 if (!S)
return false;
1243 if (NameKind == LookupMemberName)
1251 if (!VisitedUsingDirectives) {
1252 UDirs.visitScopeChain(Initial, S);
1259 FindLocals.restore();
1292 Ctx = OutsideOfTemplateParamDC;
1293 OutsideOfTemplateParamDC =
nullptr;
1298 bool SearchAfterTemplateScope;
1300 if (SearchAfterTemplateScope)
1301 OutsideOfTemplateParamDC = OuterCtx;
1315 "We should have been looking only at file context here already.");
1340 if (
auto *M = getCurrentModule())
1348 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1349 for (
auto *Param : *TD->getTemplateParameters())
1350 makeMergedDefinitionVisible(Param);
1355 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1360 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1363 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1364 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1366 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1380 unsigned N = CodeSynthesisContexts.size();
1381 for (
unsigned I = CodeSynthesisContextLookupModules.size();
1384 if (M && !LookupModulesCache.insert(M).second)
1386 CodeSynthesisContextLookupModules.push_back(M);
1388 return LookupModulesCache;
1393 if (isModuleVisible(Merged))
1404 getLangOpts().ModulesLocalVisibility)
1407 if (Merged->getTopLevelModuleName() == getLangOpts().CurrentModule)
1412 template<
typename ParmDecl>
1416 if (!D->hasDefaultArgument())
1420 auto &DefaultArg = D->getDefaultArgStorage();
1421 if (!DefaultArg.isInherited() && S.
isVisible(D))
1424 if (!DefaultArg.isInherited() && Modules) {
1425 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1428 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1432 D = DefaultArg.getInheritedFrom();
1439 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1441 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1447 template<
typename Filter>
1451 for (
auto *Redecl : D->
redecls()) {
1452 auto *R = cast<NamedDecl>(Redecl);
1460 Modules->push_back(R->getOwningModule());
1462 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1472 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1474 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1476 if (
auto *VD = dyn_cast<VarDecl>(D))
1478 llvm_unreachable(
"unknown explicit specialization kind");
1485 "not a member specialization");
1508 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1509 assert(D->
isHidden() &&
"should not call this: not in slow case");
1526 ? DeclModule->getTopLevelModuleName() ==
1537 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1539 isa<ExportDecl>(DC);
1545 if (DC && !IsEffectivelyFileContext(DC)) {
1553 bool VisibleWithinParent;
1555 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1556 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1560 VisibleWithinParent =
false;
1563 VisibleWithinParent =
true;
1567 }
while (!IsEffectivelyFileContext(DC));
1579 return VisibleWithinParent;
1589 if (LookupModules.empty())
1593 if (LookupModules.count(DeclModule))
1602 return std::any_of(LookupModules.begin(), LookupModules.end(),
1603 [&](
Module *M) {
return M->isModuleVisible(DeclModule); });
1606 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1629 for (
auto RD : D->
redecls()) {
1634 auto ND = cast<NamedDecl>(RD);
1647 assert(!isVisible(D) &&
"not in slow case");
1649 [](
const NamedDecl *) {
return true; });
1653 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1661 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1666 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1703 if (!Name)
return false;
1718 FindLocalExternScope FindLocals(R);
1724 bool LeftStartingScope =
false;
1727 IEnd = IdResolver.end();
1730 if (NameKind == LookupRedeclarationWithLinkage) {
1734 LeftStartingScope =
true;
1738 if (LeftStartingScope && !((*I)->hasLinkage())) {
1743 else if (NameKind == LookupObjCImplicitSelfParam &&
1744 !isa<ImplicitParamDecl>(*I))
1769 for (++LastI; LastI != IEnd; ++LastI) {
1794 if (CppLookupName(R, S))
1808 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1840 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1843 if (UsingDirectives.begin() == UsingDirectives.end())
return false;
1846 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1847 Visited.insert(StartDC);
1855 for (
auto *I : UsingDirectives) {
1856 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
1857 if (Visited.insert(ND).second)
1858 Queue.push_back(ND);
1865 bool FoundTag =
false;
1866 bool FoundNonTag =
false;
1871 while (!Queue.empty()) {
1876 bool UseLocal = !R.
empty();
1905 if (Visited.insert(Nom).second)
1906 Queue.push_back(Nom);
1911 if (FoundTag && FoundNonTag)
1931 template<
typename InputIterator>
1934 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1937 if (isa<CXXMethodDecl>(D)) {
1939 bool AllMethodsAreStatic =
true;
1940 for(; First != Last; ++First) {
1941 D = (*First)->getUnderlyingDecl();
1943 if (!isa<CXXMethodDecl>(D)) {
1944 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1948 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1949 AllMethodsAreStatic =
false;
1954 if (AllMethodsAreStatic)
1984 bool InUnqualifiedLookup) {
1985 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
1991 assert((!isa<TagDecl>(LookupCtx) ||
1993 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
1994 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
1995 "Declaration context must already be complete!");
1997 struct QualifiedLookupInScope {
2004 ~QualifiedLookupInScope() {
2005 Context->setUseQualifiedLookup(oldVal);
2011 if (isa<CXXRecordDecl>(LookupCtx))
2057 case LookupObjCImplicitSelfParam:
2058 case LookupOrdinaryName:
2059 case LookupMemberName:
2060 case LookupRedeclarationWithLinkage:
2061 case LookupLocalFriendName:
2073 case LookupOMPReductionName:
2077 case LookupUsingDeclName:
2080 case LookupOperatorName:
2081 case LookupNamespaceName:
2082 case LookupObjCProtocolName:
2087 case LookupNestedNameSpecifierName:
2095 return BaseCallback(Specifier, Path, Name);
2100 R.setNamingClass(LookupRec);
2109 int SubobjectNumber = 0;
2113 Path != PathEnd; ++Path) {
2118 SubobjectAccess =
std::min(SubobjectAccess, Path->Access);
2121 if (SubobjectType.isNull()) {
2138 while (FirstD != FirstPath->Decls.end() &&
2139 CurrentD != Path->Decls.end()) {
2140 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2141 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2148 if (FirstD == FirstPath->Decls.end() &&
2149 CurrentD == Path->Decls.end())
2153 R.setAmbiguousBaseSubobjectTypes(Paths);
2169 R.setAmbiguousBaseSubobjects(Paths);
2176 for (
auto *D : Paths.front().Decls) {
2230 bool AllowBuiltinCreation,
bool EnteringContext) {
2237 if (SS && SS->
isSet()) {
2261 return LookupName(R, S, AllowBuiltinCreation);
2278 for (
const auto &BaseSpec : Class->
bases()) {
2280 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2293 Result.suppressDiagnostics();
2307 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2316 QualType SubobjectType = Paths->
front().back().Base->getType();
2317 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2322 while (isa<CXXMethodDecl>(*Found) &&
2323 cast<CXXMethodDecl>(*Found)->isStatic())
2326 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2331 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2332 << Name << LookupRange;
2335 std::set<Decl *> DeclsPrinted;
2337 PathEnd = Paths->
end();
2338 Path != PathEnd; ++Path) {
2339 Decl *D = Path->Decls.front();
2340 if (DeclsPrinted.insert(D).second)
2347 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2349 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2351 for (
auto *D : Result)
2352 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2353 TagDecls.insert(TD);
2354 Diag(TD->getLocation(), diag::note_hidden_tag);
2357 for (
auto *D : Result)
2358 if (!isa<TagDecl>(D))
2364 if (TagDecls.count(F.
next()))
2372 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2374 for (
auto *D : Result)
2382 struct AssociatedLookup {
2386 : S(S), Namespaces(Namespaces), Classes(Classes),
2387 InstantiationLoc(InstantiationLoc) {
2444 DeclContext *Ctx = ClassTemplate->getDeclContext();
2445 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2446 Result.Classes.insert(EnclosingClass);
2476 if (Class->
getDeclName() == Result.S.VAListTagName)
2489 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2490 Result.Classes.insert(EnclosingClass);
2500 if (!Result.Classes.insert(Class))
2513 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2514 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2515 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2516 Result.Classes.insert(EnclosingClass);
2521 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++
I)
2526 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2527 Result.S.Context.getRecordType(Class)))
2533 Bases.push_back(Class);
2534 while (!Bases.empty()) {
2536 Class = Bases.pop_back_val();
2539 for (
const auto &
Base : Class->
bases()) {
2550 if (Result.Classes.insert(BaseDecl)) {
2557 Bases.push_back(BaseDecl);
2585 #define TYPE(Class, Base)
2586 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
2587 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
2588 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
2589 #define ABSTRACT_TYPE(Class, Base)
2590 #include "clang/AST/TypeNodes.def"
2601 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2603 case Type::ConstantArray:
2604 case Type::IncompleteArray:
2605 case Type::VariableArray:
2606 T = cast<ArrayType>(T)->getElementType().getTypePtr();
2619 case Type::Record: {
2621 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2631 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2634 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2635 Result.Classes.insert(EnclosingClass);
2646 case Type::FunctionProto: {
2649 Queue.push_back(Arg.getTypePtr());
2653 case Type::FunctionNoProto: {
2668 case Type::MemberPointer: {
2672 Queue.push_back(MemberPtr->
getClass());
2680 case Type::BlockPointer:
2681 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2686 case Type::LValueReference:
2687 case Type::RValueReference:
2688 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2693 case Type::ExtVector:
2699 case Type::DeducedTemplateSpecialization:
2705 case Type::ObjCObject:
2706 case Type::ObjCInterface:
2707 case Type::ObjCObjectPointer:
2708 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2714 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2717 T = cast<PipeType>(T)->getElementType().getTypePtr();
2723 T = Queue.pop_back_val();
2738 AssociatedNamespaces.clear();
2739 AssociatedClasses.clear();
2741 AssociatedLookup
Result(*
this, InstantiationLoc,
2742 AssociatedNamespaces, AssociatedClasses);
2751 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2752 Expr *Arg = Args[ArgIdx];
2768 if (unaryOp->getOpcode() == UO_AddrOf)
2769 Arg = unaryOp->getSubExpr();
2774 for (
const auto *D : ULE->
decls()) {
2800 return cast_or_null<ObjCProtocolDecl>(D);
2816 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2826 bool VolatileThis) {
2828 "doing special member lookup into record that isn't fully complete");
2830 if (RValueThis || ConstThis || VolatileThis)
2832 "constructors and destructors always have unqualified lvalue this");
2833 if (ConstArg || VolatileArg)
2835 "parameter-less special members can't have qualified arguments");
2840 llvm::FoldingSetNodeID
ID;
2843 ID.AddInteger(ConstArg);
2844 ID.AddInteger(VolatileArg);
2845 ID.AddInteger(RValueThis);
2846 ID.AddInteger(ConstThis);
2847 ID.AddInteger(VolatileThis);
2865 assert(DD &&
"record without a destructor");
2877 Expr *Arg =
nullptr;
2950 "lookup for a constructor or assignment operator was empty");
2960 for (
NamedDecl *CandDecl : Candidates) {
2961 if (CandDecl->isInvalidDecl())
2969 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2972 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2980 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
2981 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2984 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
2985 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2988 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2990 assert(isa<UsingDecl>(Cand.
getDecl()) &&
2991 "illegal Kind of operator = Decl");
2998 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3003 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3027 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3034 "non-const, non-volatile qualifiers for copy ctor arg");
3039 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3049 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3066 return Class->
lookup(Name);
3071 unsigned Quals,
bool RValueThis,
3072 unsigned ThisQuals) {
3074 "non-const, non-volatile qualifiers for copy assignment arg");
3076 "non-const, non-volatile qualifiers for copy assignment this");
3080 ThisQuals & Qualifiers::Const,
3081 ThisQuals & Qualifiers::Volatile);
3090 unsigned ThisQuals) {
3092 "non-const, non-volatile qualifiers for copy assignment this");
3096 ThisQuals & Qualifiers::Const,
3097 ThisQuals & Qualifiers::Volatile);
3110 false,
false,
false,
3123 bool AllowRaw,
bool AllowTemplate,
3124 bool AllowStringTemplate) {
3127 "literal operator lookup can't be ambiguous");
3132 bool FoundRaw =
false;
3133 bool FoundTemplate =
false;
3134 bool FoundStringTemplate =
false;
3135 bool FoundExactMatch =
false;
3137 while (F.hasNext()) {
3140 D = USD->getTargetDecl();
3149 bool IsTemplate =
false;
3150 bool IsStringTemplate =
false;
3151 bool IsExactMatch =
false;
3154 if (FD->getNumParams() == 1 &&
3155 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3157 else if (FD->getNumParams() == ArgTys.size()) {
3158 IsExactMatch =
true;
3159 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3160 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3162 IsExactMatch =
false;
3170 if (Params->
size() == 1)
3173 IsStringTemplate =
true;
3177 FoundExactMatch =
true;
3179 AllowTemplate =
false;
3180 AllowStringTemplate =
false;
3181 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3185 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3187 }
else if (AllowRaw && IsRaw) {
3189 }
else if (AllowTemplate && IsTemplate) {
3190 FoundTemplate =
true;
3191 }
else if (AllowStringTemplate && IsStringTemplate) {
3192 FoundStringTemplate =
true;
3203 if (FoundExactMatch)
3208 if (FoundRaw && FoundTemplate) {
3221 if (FoundStringTemplate)
3227 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3228 << (AllowTemplate || AllowStringTemplate);
3237 if (Old ==
nullptr || Old == New) {
3252 if (!Cursor)
return;
3255 if (Cursor == OldFD)
break;
3270 AssociatedNamespaces,
3284 for (
auto *NS : AssociatedNamespaces) {
3305 bool DeclaredInAssociatedClass =
false;
3308 if (isa<CXXRecordDecl>(LexDC) &&
3309 AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)) &&
3311 DeclaredInAssociatedClass =
true;
3315 if (!DeclaredInAssociatedClass)
3319 if (isa<UsingShadowDecl>(D))
3320 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3322 if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D))
3342 class ShadowContextRAII;
3344 class VisibleDeclsRecord {
3349 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3354 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3357 std::list<ShadowMap> ShadowMaps;
3360 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3362 friend class ShadowContextRAII;
3368 return !VisitedContexts.insert(Ctx).second;
3372 return VisitedContexts.count(Ctx);
3384 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3389 class ShadowContextRAII {
3390 VisibleDeclsRecord &Visible;
3392 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3395 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3396 Visible.ShadowMaps.emplace_back();
3399 ~ShadowContextRAII() {
3400 Visible.ShadowMaps.pop_back();
3408 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3409 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3410 SM != SMEnd; ++
SM) {
3411 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
3412 if (Pos == SM->end())
3415 for (
auto *D : Pos->second) {
3433 SM == ShadowMaps.rbegin())
3438 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
3439 cast<UsingShadowDecl>(ND)->getUsingDecl() == D)
3451 bool QualifiedNameLookup,
3454 VisibleDeclsRecord &Visited,
3455 bool IncludeDependentBases =
false) {
3464 if (isa<TranslationUnitDecl>(Ctx) &&
3467 auto &Idents = S.Context.Idents;
3471 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3472 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3477 for (
const auto &Ident : Idents) {
3478 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3479 E = S.IdResolver.end();
3481 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3483 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3500 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3507 if (QualifiedNameLookup) {
3508 ShadowContextRAII Shadow(Visited);
3511 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3512 IncludeDependentBases);
3518 if (!Record->hasDefinition())
3521 for (
const auto &B : Record->bases()) {
3526 if (!IncludeDependentBases) {
3539 RD = TD->getTemplatedDecl();
3544 RD = Record->getDecl();
3567 ShadowContextRAII Shadow(Visited);
3569 Visited, IncludeDependentBases);
3576 for (
auto *Cat : IFace->visible_categories()) {
3577 ShadowContextRAII Shadow(Visited);
3583 for (
auto *I : IFace->all_referenced_protocols()) {
3584 ShadowContextRAII Shadow(Visited);
3590 if (IFace->getSuperClass()) {
3591 ShadowContextRAII Shadow(Visited);
3593 true, Consumer, Visited);
3598 if (IFace->getImplementation()) {
3599 ShadowContextRAII Shadow(Visited);
3601 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3604 for (
auto *I : Protocol->protocols()) {
3605 ShadowContextRAII Shadow(Visited);
3610 for (
auto *I :
Category->protocols()) {
3611 ShadowContextRAII Shadow(Visited);
3617 if (
Category->getImplementation()) {
3618 ShadowContextRAII Shadow(Visited);
3620 QualifiedNameLookup,
true, Consumer, Visited);
3626 UnqualUsingDirectiveSet &UDirs,
3628 VisibleDeclsRecord &Visited) {
3634 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3636 FindLocalExternScope FindLocals(Result);
3638 for (
auto *D : S->
decls()) {
3639 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3641 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3659 if (Method->isInstanceMethod()) {
3665 false, Consumer, Visited);
3679 false, Consumer, Visited);
3693 false, Consumer, Visited);
3699 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3702 false, Consumer, Visited);
3706 ShadowContextRAII Shadow(Visited);
3712 bool IncludeGlobalScope) {
3716 UnqualUsingDirectiveSet UDirs;
3722 UDirs.visitScopeChain(Initial, S);
3729 VisibleDeclsRecord Visited;
3730 if (!IncludeGlobalScope)
3732 ShadowContextRAII Shadow(Visited);
3738 bool IncludeGlobalScope,
3739 bool IncludeDependentBases) {
3742 VisibleDeclsRecord Visited;
3743 if (!IncludeGlobalScope)
3745 ShadowContextRAII Shadow(Visited);
3747 false, Consumer, Visited,
3748 IncludeDependentBases);
3763 Scope *S = CurScope;
3765 return cast<LabelDecl>(Res);
3778 assert(S &&
"Not in a function?");
3781 return cast<LabelDecl>(Res);
3799 bool EnteringContext,
3800 bool isObjCIvarLookup,
3809 for (; DI != DE; ++DI)
3819 bool AnyVisibleDecls = !NewDecls.empty();
3821 for (; DI != DE; ++DI) {
3827 if (!AnyVisibleDecls) {
3829 AnyVisibleDecls =
true;
3832 NewDecls.push_back(VisibleDecl);
3833 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3834 NewDecls.push_back(*DI);
3837 if (NewDecls.empty())
3854 Identifiers.clear();
3884 Identifiers.push_back(II);
3912 addName(Name,
nullptr);
3918 addName(Keyword,
nullptr,
nullptr,
true);
3921 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3925 StringRef TypoStr = Typo->
getName();
3926 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
3927 if (MinED && TypoStr.size() / MinED < 3)
3932 unsigned UpperBound = (TypoStr.size() + 2) / 3 + 1;
3933 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
3934 if (ED >= UpperBound)
return;
3945 StringRef TypoStr = Typo->
getName();
3951 if (TypoStr.size() < 3 &&
3952 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
3965 if (!CList.empty() && !CList.back().isResolved())
3969 for (TypoResultList::iterator RI = CList.begin(), RIEnd = CList.end();
3970 RI != RIEnd; ++RI) {
3975 if (RI->getCorrectionDecl() == NewND) {
3976 if (CorrectionStr < RI->getAsString(SemaRef.
getLangOpts()))
3982 if (CList.empty() || Correction.
isResolved())
3983 CList.push_back(Correction);
3986 CorrectionResults.erase(std::prev(CorrectionResults.end()));
3990 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
3991 SearchNamespaces =
true;
3993 for (
auto KNPair : KnownNamespaces)
3994 Namespaces.addNameSpecifier(KNPair.first);
3996 bool SSIsTemplate =
false;
3998 (SS && SS->isValid()) ? SS->getScopeRep() :
nullptr) {
3999 if (
const Type *T = NNS->getAsType())
4000 SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization;
4006 for (
unsigned I = 0; I != Types.size(); ++
I) {
4007 const auto *TI = Types[
I];
4009 CD = CD->getCanonicalDecl();
4010 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4011 !CD->isUnion() && CD->getIdentifier() &&
4012 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4013 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4014 Namespaces.addNameSpecifier(CD);
4020 if (++CurrentTCIndex < ValidatedCorrections.size())
4021 return ValidatedCorrections[CurrentTCIndex];
4023 CurrentTCIndex = ValidatedCorrections.size();
4024 while (!CorrectionResults.empty()) {
4025 auto DI = CorrectionResults.begin();
4026 if (DI->second.empty()) {
4027 CorrectionResults.erase(DI);
4031 auto RI = DI->second.begin();
4032 if (RI->second.empty()) {
4033 DI->second.erase(RI);
4034 performQualifiedLookups();
4040 ValidatedCorrections.push_back(TC);
4041 return ValidatedCorrections[CurrentTCIndex];
4044 return ValidatedCorrections[0];
4047 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4054 CorrectionValidator->IsObjCIvarLookup,
4066 if (TempMemberContext) {
4069 TempMemberContext =
nullptr;
4072 if (SearchNamespaces)
4073 QualifiedResults.push_back(Candidate);
4083 for (
auto *TRD : Result)
4087 if (SearchNamespaces)
4088 QualifiedResults.push_back(Candidate);
4097 void TypoCorrectionConsumer::performQualifiedLookups() {
4098 unsigned TypoLen = Typo->
getName().size();
4100 for (
const auto &NSI : Namespaces) {
4102 const Type *NSType = NSI.NameSpecifier->getAsType();
4110 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4115 TC.ClearCorrectionDecls();
4116 TC.setCorrectionSpecifier(NSI.NameSpecifier);
4117 TC.setQualifierDistance(NSI.EditDistance);
4118 TC.setCallbackDistance(0);
4123 unsigned TmpED = TC.getEditDistance(
true);
4124 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4125 TypoLen / TmpED < 3)
4129 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4135 switch (Result.getResultKind()) {
4138 if (SS && SS->isValid()) {
4139 std::string NewQualified = TC.getAsString(SemaRef.
getLangOpts());
4140 std::string OldQualified;
4141 llvm::raw_string_ostream OldOStream(OldQualified);
4143 OldOStream << Typo->
getName();
4147 if (OldOStream.str() == NewQualified)
4151 TRD != TRDEnd; ++TRD) {
4156 TC.addCorrectionDecl(*TRD);
4158 if (TC.isResolved()) {
4159 TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
4172 QualifiedResults.clear();
4175 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4177 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4179 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4180 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4188 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4189 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4196 DistanceMap[1].push_back(SI);
4199 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4201 assert(Start &&
"Building a context chain from a null context");
4202 DeclContextList Chain;
4214 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4216 unsigned NumSpecifiers = 0;
4218 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4221 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4223 RD->getTypeForDecl());
4227 return NumSpecifiers;
4230 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4233 unsigned NumSpecifiers = 0;
4234 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4235 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4238 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4239 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() !=
C)
4241 NamespaceDeclChain.pop_back();
4245 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4248 if (NamespaceDeclChain.empty()) {
4252 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4254 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4256 bool SameNameSpecifier =
false;
4257 if (std::find(CurNameSpecifierIdentifiers.begin(),
4258 CurNameSpecifierIdentifiers.end(),
4259 Name) != CurNameSpecifierIdentifiers.end()) {
4260 std::string NewNameSpecifier;
4261 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4265 SpecifierOStream.flush();
4266 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4268 if (SameNameSpecifier ||
4269 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4270 Name) != CurContextIdentifiers.end()) {
4274 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4282 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4285 NumSpecifiers = llvm::ComputeEditDistance(
4286 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4287 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4290 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4291 DistanceMap[NumSpecifiers].push_back(SI);
4300 bool EnteringContext,
4301 bool isObjCIvarLookup,
4307 if (MemberContext) {
4309 if (isObjCIvarLookup) {
4310 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4335 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4340 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4352 bool AfterNestedNameSpecifier) {
4353 if (AfterNestedNameSpecifier) {
4366 static const char *
const CTypeSpecs[] = {
4367 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4368 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4369 "_Complex",
"_Imaginary",
4371 "extern",
"inline",
"static",
"typedef"
4374 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4375 for (
unsigned I = 0; I != NumCTypeSpecs; ++
I)
4402 static const char *
const CastableTypeSpecs[] = {
4403 "char",
"double",
"float",
"int",
"long",
"short",
4404 "signed",
"unsigned",
"void"
4406 for (
auto *kw : CastableTypeSpecs)
4425 static const char *
const CXXExprs[] = {
4426 "delete",
"new",
"operator",
"throw",
"typeid"
4428 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4429 for (
unsigned I = 0; I != NumCXXExprs; ++
I)
4432 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4433 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4452 static const char *
const CStmts[] = {
4453 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4454 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4455 for (
unsigned I = 0; I != NumCStmts; ++
I)
4499 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4502 std::unique_ptr<CorrectionCandidateCallback> CCC,
4538 locs->second.count(TypoName.
getLoc()))
4565 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4566 *
this, TypoName, LookupKind,
S, SS, std::move(CCC), MemberContext,
4570 bool IsUnqualifiedLookup =
false;
4572 if (MemberContext) {
4577 for (
auto *I : OPT->
quals())
4580 }
else if (SS && SS->isSet()) {
4587 IsUnqualifiedLookup =
true;
4592 bool SearchNamespaces
4594 (IsUnqualifiedLookup || (SS && SS->isSet()));
4596 if (IsUnqualifiedLookup || SearchNamespaces) {
4600 for (
const auto &I : Context.
Idents)
4607 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4609 StringRef Name = Iter->Next();
4622 if (SearchNamespaces) {
4624 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4626 LoadedExternalKnownNamespaces =
true;
4628 for (
auto *N : ExternalKnownNamespaces)
4629 KnownNamespaces[N] =
true;
4632 Consumer->addNamespaces(KnownNamespaces);
4672 std::unique_ptr<CorrectionCandidateCallback> CCC,
4675 bool EnteringContext,
4677 bool RecordFailure) {
4678 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4682 if (ExternalSource) {
4684 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4692 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4695 auto Consumer = makeTypoCorrectionConsumer(
4696 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4704 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4708 unsigned ED =
Consumer->getBestEditDistance(
true);
4709 unsigned TypoLen = Typo->
getName().size();
4710 if (ED > 0 && TypoLen / ED < 3)
4711 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4716 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4718 ED = BestTC.getEditDistance();
4720 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4724 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4728 if (!SecondBestTC ||
4729 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4735 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4741 }
else if (SecondBestTC && ObjCMessageReceiver) {
4745 if (BestTC.getCorrection().getAsString() !=
"super") {
4747 BestTC = SecondBestTC;
4748 else if ((*
Consumer)[
"super"].front().isKeyword())
4749 BestTC = (*
Consumer)[
"super"].front();
4753 if (BestTC.getEditDistance() == 0 ||
4754 BestTC.getCorrection().getAsString() !=
"super")
4755 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4764 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4808 std::unique_ptr<CorrectionCandidateCallback> CCC,
4812 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4814 auto Consumer = makeTypoCorrectionConsumer(
4815 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4822 TypoName, LookupKind, S, SS, *
Consumer->getCorrectionValidator(),
4823 MemberContext, EnteringContext, OPT);
4825 Consumer->addCorrection(ExternalTypo);
4833 unsigned ED =
Consumer->getBestEditDistance(
true);
4835 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
4839 return createDelayedTypo(std::move(
Consumer), std::move(TDG), std::move(TRC));
4846 CorrectionDecls.clear();
4848 CorrectionDecls.push_back(CDecl);
4850 if (!CorrectionName)
4855 if (CorrectionNameSpec) {
4856 std::string tmpBuffer;
4857 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4859 PrefixOStream << CorrectionName;
4860 return PrefixOStream.str();
4875 bool HasNonType =
false;
4876 bool HasStaticMethod =
false;
4877 bool HasNonStaticMethod =
false;
4878 for (
Decl *D : candidate) {
4880 D = FTD->getTemplatedDecl();
4882 if (Method->isStatic())
4883 HasStaticMethod =
true;
4885 HasNonStaticMethod =
true;
4887 if (!isa<TypeDecl>(D))
4892 !candidate.getCorrectionSpecifier())
4899 bool HasExplicitTemplateArgs,
4901 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4902 CurContext(SemaRef.CurContext), MemberFn(ME) {
4912 for (
auto *C : candidate) {
4916 FD = FTD->getTemplatedDecl();
4917 if (!HasExplicitTemplateArgs && !FD) {
4918 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4922 QualType ValType = cast<ValueDecl>(ND)->getType();
4926 if (FPT->getNumParams() == NumArgs)
4942 if (MemberFn || !MD->isStatic()) {
4945 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
4946 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
4961 bool ErrorRecovery) {
4969 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
4970 return VD->getDefinition();
4972 return FD->getDefinition();
4973 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
4974 return TD->getDefinition();
4976 return ID->getDefinition();
4978 return PD->getDefinition();
4993 assert(Owner &&
"definition of hidden declaration is not in a module");
4996 OwningModules.push_back(Owner);
4998 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5011 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
5018 assert(!Modules.empty());
5022 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5023 for (
auto *M : Modules)
5024 if (UniqueModuleSet.insert(M).second)
5025 UniqueModules.push_back(M);
5026 Modules = UniqueModules;
5028 if (Modules.size() > 1) {
5029 std::string ModuleList;
5031 for (
Module *M : Modules) {
5032 ModuleList +=
"\n ";
5033 if (++N == 5 && N != Modules.size()) {
5034 ModuleList +=
"[...]";
5037 ModuleList += M->getFullModuleName();
5040 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5041 << (int)MIK << Decl << ModuleList;
5043 UseLoc, Modules[0], DeclLoc)) {
5049 Diag(UseLoc, diag::err_module_unimported_use_header)
5050 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5054 Diag(UseLoc, diag::err_module_unimported_use)
5055 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5061 DiagID = diag::note_previous_declaration;
5064 DiagID = diag::note_previous_definition;
5067 DiagID = diag::note_default_argument_declared_here;
5070 DiagID = diag::note_explicit_specialization_declared_here;
5073 DiagID = diag::note_partial_specialization_declared_here;
5076 Diag(DeclLoc, DiagID);
5098 bool ErrorRecovery) {
5107 assert(Decl &&
"import required but no declaration to import");
5115 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5120 Diag(ChosenDecl->getLocation(), PrevNote)
5121 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5128 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5129 TypoDiagnosticGenerator TDG,
5130 TypoRecoveryCallback TRC) {
5131 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5133 auto &
State = DelayedTypos[TE];
5134 State.Consumer = std::move(TCC);
5135 State.DiagHandler = std::move(TDG);
5136 State.RecoveryHandler = std::move(TRC);
5141 auto Entry = DelayedTypos.find(TE);
5142 assert(Entry != DelayedTypos.end() &&
5143 "Failed to get the state for a TypoExpr!");
5144 return Entry->second;
5148 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.
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
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
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
static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Filter F)
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...
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
void erase()
Erase the last element returned from this iterator.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
__DEVICE__ long long abs(long long __n)
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...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
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.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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...
const NestedNameSpecifier * Specifier
Look up of a name that precedes the '::' scope resolution operator in C++.
void makeKeyword()
Mark this TypoCorrection as being a keyword.
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.
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.
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.
static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare reduction member wi...
A namespace, stored as a NamespaceDecl*.
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.
Stores a list of template parameters for a TemplateDecl and its derived classes.
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
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.
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...
ArrayRef< PartialDiagnostic > getExtraDiagnostics() const
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.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
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...
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
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
IdentifierInfo * getTypePackElementName() 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...
HeaderSearch & getHeaderSearchInfo() const
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)
Look up the name of an OpenMP user-defined reduction operation.
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Scope - A scope is a transient data structure that is used while parsing the program.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
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.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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'.
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
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
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.
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
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.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
This declaration is a C++ operator declared in a non-class context.
llvm::iterator_range< decls_iterator > decls() const
bool hasMergedDefinitionInCurrentModule(NamedDecl *Def)
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.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
NamedDecl * getDecl() const
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.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
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...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location...
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
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.
This declaration is an OpenMP user defined reduction construction.
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.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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...
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.
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
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
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
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.
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
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
This declaration has an owning module, but is globally visible (typically because its owning module i...
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.
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
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...
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.
Cached information about one file (either on disk or in the virtual file system). ...
bool hasVisibleMergedDefinition(NamedDecl *Def)
Represents a static or instance method of a struct/union/class.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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
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...
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
A POD class for pairing a NamedDecl* with an access specifier.
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.
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.
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 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.
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.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
DeclarationName - The name of a declaration.
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.
BuiltinTemplateDecl * getTypePackElementDecl() const
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.
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
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.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
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.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, SourceLocation Loc, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
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...
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases=false)
Represents a base class of a C++ class.
This is a scope that can contain a declaration.
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.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
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.
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.
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
const FileEntry * getModuleHeaderToIncludeForDiagnostics(SourceLocation IncLoc, Module *M, SourceLocation MLoc)
We want to produce a diagnostic at location IncLoc concerning a missing module import.
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...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
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.
Represents a type template specialization; the template must be a class template, a type alias templa...
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.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
This declaration is a using declaration.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
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.