38 #include "llvm/ADT/STLExtras.h" 39 #include "llvm/ADT/SmallPtrSet.h" 40 #include "llvm/ADT/TinyPtrVector.h" 41 #include "llvm/ADT/edit_distance.h" 42 #include "llvm/Support/ErrorHandling.h" 50 using namespace clang;
54 class UnqualUsingEntry {
61 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
65 return CommonAncestor;
74 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
75 return L.getCommonAncestor() < R.getCommonAncestor();
78 bool operator()(
const UnqualUsingEntry &E,
const DeclContext *DC) {
79 return E.getCommonAncestor() < DC;
82 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
83 return DC < E.getCommonAncestor();
90 class UnqualUsingDirectiveSet {
96 llvm::SmallPtrSet<DeclContext*, 8> visited;
99 UnqualUsingDirectiveSet(
Sema &SemaRef) : SemaRef(SemaRef) {}
101 void visitScopeChain(
Scope *S,
Scope *InnermostFileScope) {
119 visit(I, InnermostFileDC);
132 if (!visited.insert(DC).second)
135 addUsingDirectives(DC, EffectiveDC);
143 if (!visited.insert(NS).second)
146 addUsingDirective(UD, EffectiveDC);
147 addUsingDirectives(NS, EffectiveDC);
158 if (SemaRef.
isVisible(UD) && visited.insert(NS).second) {
159 addUsingDirective(UD, EffectiveDC);
167 DC = queue.pop_back_val();
182 while (!Common->
Encloses(EffectiveDC))
190 std::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
193 typedef ListTy::const_iterator const_iterator;
195 const_iterator begin()
const {
return list.begin(); }
196 const_iterator end()
const {
return list.end(); }
198 llvm::iterator_range<const_iterator>
200 return llvm::make_range(std::equal_range(begin(), end(),
202 UnqualUsingEntry::Comparator()));
211 bool Redeclaration) {
231 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
270 assert(Redeclaration &&
"should only be used for redecl lookup");
293 void LookupResult::configure() {
295 isForRedeclaration());
300 switch (NameInfo.getName().getCXXOverloadedOperator()) {
304 case OO_Array_Delete:
305 getSema().DeclareGlobalNewDelete();
315 if (
unsigned BuiltinID =
Id->getBuiltinID()) {
316 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
322 bool LookupResult::sanity()
const {
324 assert(ResultKind != NotFound || Decls.size() == 0);
325 assert(ResultKind != Found || Decls.size() == 1);
326 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
327 (Decls.size() == 1 &&
328 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
329 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
330 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
331 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
332 Ambiguity == AmbiguousBaseSubobjectTypes)));
333 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
334 (Ambiguity == AmbiguousBaseSubobjectTypes ||
335 Ambiguity == AmbiguousBaseSubobjects)));
366 !isa<UsingShadowDecl>(Existing))
378 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
379 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
380 bool HaveTag = isa<TagDecl>(EUnderlying);
382 return HaveTag != WantTag;
389 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
390 auto *EFD = cast<FunctionDecl>(EUnderlying);
391 unsigned DMin = DFD->getMinRequiredArguments();
392 unsigned EMin = EFD->getMinRequiredArguments();
401 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
402 auto *ETD = cast<TemplateDecl>(EUnderlying);
403 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
404 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
413 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
416 ETD->getTemplateParameters()->getParam(I)) &&
418 DTD->getTemplateParameters()->getParam(I)))
425 if (
VarDecl *DVD = dyn_cast<VarDecl>(DUnderlying)) {
426 VarDecl *EVD = cast<VarDecl>(EUnderlying);
428 !DVD->getType()->isIncompleteType()) {
436 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
445 if (Prev == EUnderlying)
465 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
466 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D) ||
467 isa<UnresolvedUsingValueDecl>(D);
472 unsigned N = Decls.size();
476 assert(ResultKind == NotFound ||
477 ResultKind == NotFoundInCurrentInstantiation);
484 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
485 if (isa<FunctionTemplateDecl>(D))
486 ResultKind = FoundOverloaded;
487 else if (isa<UnresolvedUsingValueDecl>(D))
488 ResultKind = FoundUnresolvedValue;
493 if (ResultKind == Ambiguous)
return;
495 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
496 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
498 bool Ambiguous =
false;
499 bool HasTag =
false, HasFunction =
false;
500 bool HasFunctionTemplate =
false, HasUnresolved =
false;
505 unsigned UniqueTagIndex = 0;
514 Decls[I] = Decls[--N];
524 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
525 QualType T = getSema().Context.getTypeDeclType(TD);
526 auto UniqueResult = UniqueTypes.insert(
528 if (!UniqueResult.second) {
530 ExistingI = UniqueResult.first->second;
537 auto UniqueResult = Unique.insert(std::make_pair(D, I));
538 if (!UniqueResult.second) {
540 ExistingI = UniqueResult.first->second;
549 Decls[*ExistingI] = Decls[I];
550 Decls[I] = Decls[--N];
556 if (isa<UnresolvedUsingValueDecl>(D)) {
557 HasUnresolved =
true;
558 }
else if (isa<TagDecl>(D)) {
563 }
else if (isa<FunctionTemplateDecl>(D)) {
565 HasFunctionTemplate =
true;
566 }
else if (isa<FunctionDecl>(D)) {
569 if (HasNonFunction) {
574 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
576 EquivalentNonFunctions.push_back(D);
577 Decls[I] = Decls[--N];
597 if (N > 1 && HideTags && HasTag && !Ambiguous &&
598 (HasFunction || HasNonFunction || HasUnresolved)) {
599 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
600 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
604 Decls[UniqueTagIndex] = Decls[--N];
611 if (!EquivalentNonFunctions.empty() && !Ambiguous)
612 getSema().diagnoseEquivalentInternalLinkageDeclarations(
613 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
617 if (HasNonFunction && (HasFunction || HasUnresolved))
622 else if (HasUnresolved)
624 else if (N > 1 || HasFunctionTemplate)
630 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
632 for (I = P.
begin(), E = P.
end(); I != E; ++I)
634 DE = I->Decls.end(); DI != DE; ++DI)
641 addDeclsFromBasePaths(*Paths);
643 setAmbiguous(AmbiguousBaseSubobjects);
649 addDeclsFromBasePaths(*Paths);
651 setAmbiguous(AmbiguousBaseSubobjectTypes);
655 Out << Decls.size() <<
" result(s)";
656 if (isAmbiguous()) Out <<
", ambiguous";
657 if (Paths) Out <<
", base paths present";
659 for (
iterator I = begin(), E = end(); I != E; ++I) {
666 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
733 DeclareImplicitDefaultConstructor(Class);
737 DeclareImplicitCopyConstructor(Class);
741 DeclareImplicitCopyAssignment(Class);
743 if (getLangOpts().CPlusPlus11) {
746 DeclareImplicitMoveConstructor(Class);
750 DeclareImplicitMoveAssignment(Class);
755 DeclareImplicitDestructor(Class);
787 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
790 if (Record->needsImplicitDefaultConstructor())
792 if (Record->needsImplicitCopyConstructor())
795 Record->needsImplicitMoveConstructor())
801 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
802 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
811 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
814 if (Record->needsImplicitCopyAssignment())
817 Record->needsImplicitMoveAssignment())
857 !isa<CXXRecordDecl>(DC))
871 auto *ContainedDeducedType =
875 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
909 assert(ConvProto &&
"Nonsensical conversion function template type");
924 Specialization, Info)
939 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
946 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
973 if (OuterS->getEntity()) {
974 Lexical = OuterS->getEntity();
1001 if (!Lexical || !DC || !S->
getParent() ||
1003 return std::make_pair(Lexical,
false);
1009 while (OutermostTemplateScope->
getParent() &&
1011 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1025 return std::make_pair(Semantic,
true);
1027 return std::make_pair(Lexical,
false);
1033 struct FindLocalExternScope {
1043 ~FindLocalExternScope() {
1047 bool OldFindLocalExtern;
1052 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1070 I = IdResolver.begin(Name),
1071 IEnd = IdResolver.end();
1091 UnqualUsingDirectiveSet UDirs(*
this);
1092 bool VisitedUsingDirectives =
false;
1093 bool LeftStartingScope =
false;
1097 FindLocalExternScope FindLocals(R);
1101 bool SearchNamespaceScope =
true;
1105 if (NameKind == LookupRedeclarationWithLinkage &&
1106 !(*I)->isTemplateParameter()) {
1112 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1113 LeftStartingScope =
true;
1117 if (LeftStartingScope && !((*I)->hasLinkage())) {
1124 SearchNamespaceScope =
false;
1129 if (!SearchNamespaceScope) {
1132 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1137 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1153 Ctx = OutsideOfTemplateParamDC;
1154 OutsideOfTemplateParamDC =
nullptr;
1159 bool SearchAfterTemplateScope;
1161 if (SearchAfterTemplateScope)
1162 OutsideOfTemplateParamDC = OuterCtx;
1181 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(
1200 if (!VisitedUsingDirectives) {
1203 if (UCtx->isTransparentContext())
1206 UDirs.visit(UCtx, UCtx);
1211 Scope *InnermostFileScope = S;
1212 while (InnermostFileScope &&
1214 InnermostFileScope = InnermostFileScope->
getParent();
1215 UDirs.visitScopeChain(Initial, InnermostFileScope);
1219 VisitedUsingDirectives =
true;
1236 if (LookupQualifiedName(R, Ctx,
true))
1244 if (!S)
return false;
1247 if (NameKind == LookupMemberName)
1255 if (!VisitedUsingDirectives) {
1256 UDirs.visitScopeChain(Initial, S);
1263 FindLocals.restore();
1296 Ctx = OutsideOfTemplateParamDC;
1297 OutsideOfTemplateParamDC =
nullptr;
1302 bool SearchAfterTemplateScope;
1304 if (SearchAfterTemplateScope)
1305 OutsideOfTemplateParamDC = OuterCtx;
1319 "We should have been looking only at file context here already.");
1344 if (
auto *M = getCurrentModule())
1352 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1353 for (
auto *Param : *TD->getTemplateParameters())
1354 makeMergedDefinitionVisible(Param);
1359 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1364 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1367 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1368 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1370 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1384 unsigned N = CodeSynthesisContexts.size();
1385 for (
unsigned I = CodeSynthesisContextLookupModules.size();
1388 if (M && !LookupModulesCache.insert(M).second)
1390 CodeSynthesisContextLookupModules.push_back(M);
1392 return LookupModulesCache;
1397 if (isModuleVisible(Merged))
1408 getLangOpts().ModulesLocalVisibility)
1411 if (Merged->getTopLevelModuleName() == getLangOpts().CurrentModule)
1416 template<
typename ParmDecl>
1420 if (!D->hasDefaultArgument())
1424 auto &DefaultArg = D->getDefaultArgStorage();
1425 if (!DefaultArg.isInherited() && S.
isVisible(D))
1428 if (!DefaultArg.isInherited() && Modules) {
1429 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1432 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1436 D = DefaultArg.getInheritedFrom();
1443 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1445 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1451 template<
typename Filter>
1455 for (
auto *Redecl : D->
redecls()) {
1456 auto *R = cast<NamedDecl>(Redecl);
1464 Modules->push_back(R->getOwningModule());
1466 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1476 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1478 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1480 if (
auto *VD = dyn_cast<VarDecl>(D))
1482 llvm_unreachable(
"unknown explicit specialization kind");
1489 "not a member specialization");
1512 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1513 assert(D->
isHidden() &&
"should not call this: not in slow case");
1530 ? DeclModule->getTopLevelModuleName() ==
1541 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1543 isa<ExportDecl>(DC);
1549 if (DC && !IsEffectivelyFileContext(DC)) {
1557 bool VisibleWithinParent;
1559 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1560 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1564 VisibleWithinParent =
false;
1567 VisibleWithinParent =
true;
1571 }
while (!IsEffectivelyFileContext(DC));
1583 return VisibleWithinParent;
1593 if (LookupModules.empty())
1597 if (LookupModules.count(DeclModule))
1606 return std::any_of(LookupModules.begin(), LookupModules.end(),
1608 return M->isModuleVisible(DeclModule); });
1611 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1629 "should not have hidden, non-externally-declarable result here");
1662 for (
auto RD : D->
redecls()) {
1667 auto ND = cast<NamedDecl>(RD);
1680 assert(!isVisible(D) &&
"not in slow case");
1682 [](
const NamedDecl *) {
return true; });
1686 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1694 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1699 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1736 if (!Name)
return false;
1751 FindLocalExternScope FindLocals(R);
1757 bool LeftStartingScope =
false;
1760 IEnd = IdResolver.end();
1763 if (NameKind == LookupRedeclarationWithLinkage) {
1767 LeftStartingScope =
true;
1771 if (LeftStartingScope && !((*I)->hasLinkage())) {
1776 else if (NameKind == LookupObjCImplicitSelfParam &&
1777 !isa<ImplicitParamDecl>(*I))
1802 for (++LastI; LastI != IEnd; ++LastI) {
1827 if (CppLookupName(R, S))
1841 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1873 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1880 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1881 Visited.insert(StartDC);
1886 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
1887 if (S.
isVisible(I) && Visited.insert(ND).second)
1888 Queue.push_back(ND);
1895 bool FoundTag =
false;
1896 bool FoundNonTag =
false;
1901 while (!Queue.empty()) {
1906 bool UseLocal = !R.
empty();
1935 if (S.
isVisible(I) && Visited.insert(Nom).second)
1936 Queue.push_back(Nom);
1941 if (FoundTag && FoundNonTag)
1961 template<
typename InputIterator>
1964 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1967 if (isa<CXXMethodDecl>(D)) {
1969 bool AllMethodsAreStatic =
true;
1970 for(; First != Last; ++First) {
1971 D = (*First)->getUnderlyingDecl();
1973 if (!isa<CXXMethodDecl>(D)) {
1974 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1978 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1979 AllMethodsAreStatic =
false;
1984 if (AllMethodsAreStatic)
2014 bool InUnqualifiedLookup) {
2015 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2021 assert((!isa<TagDecl>(LookupCtx) ||
2023 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
2024 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
2025 "Declaration context must already be complete!");
2027 struct QualifiedLookupInScope {
2031 QualifiedLookupInScope(
DeclContext *ctx) : Context(ctx) {
2034 ~QualifiedLookupInScope() {
2041 if (isa<CXXRecordDecl>(LookupCtx))
2087 case LookupObjCImplicitSelfParam:
2088 case LookupOrdinaryName:
2089 case LookupMemberName:
2090 case LookupRedeclarationWithLinkage:
2091 case LookupLocalFriendName:
2103 case LookupOMPReductionName:
2107 case LookupUsingDeclName:
2110 case LookupOperatorName:
2111 case LookupNamespaceName:
2112 case LookupObjCProtocolName:
2117 case LookupNestedNameSpecifierName:
2125 return BaseCallback(Specifier, Path, Name);
2139 int SubobjectNumber = 0;
2143 Path != PathEnd; ++Path) {
2151 if (SubobjectType.
isNull()) {
2168 while (FirstD != FirstPath->Decls.end() &&
2170 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2171 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2178 if (FirstD == FirstPath->Decls.end() &&
2234 return LookupInSuper(R, NNS->getAsRecordDecl());
2237 return LookupQualifiedName(R, LookupCtx);
2260 bool AllowBuiltinCreation,
bool EnteringContext) {
2267 if (SS && SS->
isSet()) {
2272 if (
DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
2279 return LookupQualifiedName(R, DC);
2291 return LookupName(R, S, AllowBuiltinCreation);
2308 for (
const auto &BaseSpec : Class->
bases()) {
2310 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2313 LookupQualifiedName(Result, RD);
2317 for (
auto I = Result.begin(), E = Result.end(); I != E; ++I) {
2323 Result.suppressDiagnostics();
2337 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2346 QualType SubobjectType = Paths->
front().back().Base->getType();
2347 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2348 << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths)
2352 while (isa<CXXMethodDecl>(*Found) &&
2353 cast<CXXMethodDecl>(*Found)->isStatic())
2356 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2361 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2362 << Name << LookupRange;
2365 std::set<Decl *> DeclsPrinted;
2367 PathEnd = Paths->
end();
2368 Path != PathEnd; ++Path) {
2369 Decl *D = Path->Decls.front();
2370 if (DeclsPrinted.insert(D).second)
2377 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2379 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2381 for (
auto *D : Result)
2382 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2383 TagDecls.insert(TD);
2384 Diag(TD->getLocation(), diag::note_hidden_tag);
2387 for (
auto *D : Result)
2388 if (!isa<TagDecl>(D))
2394 if (TagDecls.count(F.
next()))
2402 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2404 for (
auto *D : Result)
2412 struct AssociatedLookup {
2416 : S(S), Namespaces(Namespaces), Classes(Classes),
2417 InstantiationLoc(InstantiationLoc) {
2474 DeclContext *Ctx = ClassTemplate->getDeclContext();
2475 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2476 Result.Classes.insert(EnclosingClass);
2506 if (Class->
getDeclName() == Result.S.VAListTagName)
2519 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2520 Result.Classes.insert(EnclosingClass);
2530 if (!Result.Classes.insert(Class))
2543 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2544 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2545 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2546 Result.Classes.insert(EnclosingClass);
2551 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
2556 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2557 Result.S.Context.getRecordType(Class)))
2563 Bases.push_back(Class);
2564 while (!Bases.empty()) {
2566 Class = Bases.pop_back_val();
2569 for (
const auto &
Base : Class->
bases()) {
2580 if (Result.Classes.insert(BaseDecl)) {
2587 Bases.push_back(BaseDecl);
2615 #define TYPE(Class, Base) 2616 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 2617 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 2618 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 2619 #define ABSTRACT_TYPE(Class, Base) 2620 #include "clang/AST/TypeNodes.def" 2631 T = cast<PointerType>(
T)->getPointeeType().getTypePtr();
2633 case Type::ConstantArray:
2634 case Type::IncompleteArray:
2635 case Type::VariableArray:
2636 T = cast<ArrayType>(
T)->getElementType().getTypePtr();
2649 case Type::Record: {
2651 cast<CXXRecordDecl>(cast<RecordType>(
T)->getDecl());
2661 EnumDecl *Enum = cast<EnumType>(
T)->getDecl();
2664 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2665 Result.Classes.insert(EnclosingClass);
2676 case Type::FunctionProto: {
2679 Queue.push_back(Arg.getTypePtr());
2683 case Type::FunctionNoProto: {
2698 case Type::MemberPointer: {
2702 Queue.push_back(MemberPtr->
getClass());
2710 case Type::BlockPointer:
2711 T = cast<BlockPointerType>(
T)->getPointeeType().getTypePtr();
2716 case Type::LValueReference:
2717 case Type::RValueReference:
2718 T = cast<ReferenceType>(
T)->getPointeeType().getTypePtr();
2723 case Type::ExtVector:
2729 case Type::DeducedTemplateSpecialization:
2735 case Type::ObjCObject:
2736 case Type::ObjCInterface:
2737 case Type::ObjCObjectPointer:
2738 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2744 T = cast<AtomicType>(
T)->getValueType().getTypePtr();
2747 T = cast<PipeType>(
T)->getElementType().getTypePtr();
2753 T = Queue.pop_back_val();
2768 AssociatedNamespaces.clear();
2769 AssociatedClasses.clear();
2771 AssociatedLookup Result(*
this, InstantiationLoc,
2772 AssociatedNamespaces, AssociatedClasses);
2781 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2782 Expr *Arg = Args[ArgIdx];
2798 if (unaryOp->getOpcode() == UO_AddrOf)
2799 Arg = unaryOp->getSubExpr();
2804 for (
const auto *D : ULE->
decls()) {
2828 Decl *D = LookupSingleName(TUScope, II, IdLoc,
2829 LookupObjCProtocolName, Redecl);
2830 return cast_or_null<ObjCProtocolDecl>(D);
2844 LookupName(Operators, S);
2846 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2856 bool VolatileThis) {
2858 "doing special member lookup into record that isn't fully complete");
2860 if (RValueThis || ConstThis || VolatileThis)
2861 assert((SM == CXXCopyAssignment || SM == CXXMoveAssignment) &&
2862 "constructors and destructors always have unqualified lvalue this");
2863 if (ConstArg || VolatileArg)
2864 assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
2865 "parameter-less special members can't have qualified arguments");
2870 llvm::FoldingSetNodeID
ID;
2873 ID.AddInteger(ConstArg);
2874 ID.AddInteger(VolatileArg);
2875 ID.AddInteger(RValueThis);
2876 ID.AddInteger(ConstThis);
2877 ID.AddInteger(VolatileThis);
2881 SpecialMemberCache.FindNodeOrInsertPos(ID, InsertPoint);
2889 SpecialMemberCache.InsertNode(Result, InsertPoint);
2891 if (SM == CXXDestructor) {
2893 DeclareImplicitDestructor(RD);
2895 assert(DD &&
"record without a destructor");
2898 SpecialMemberOverloadResult::NoMemberOrDeleted :
2899 SpecialMemberOverloadResult::Success);
2907 Expr *Arg =
nullptr;
2913 if (SM == CXXDefaultConstructor) {
2917 DeclareImplicitDefaultConstructor(RD);
2919 if (SM == CXXCopyConstructor || SM == CXXMoveConstructor) {
2922 DeclareImplicitCopyConstructor(RD);
2924 DeclareImplicitMoveConstructor(RD);
2928 DeclareImplicitCopyAssignment(RD);
2930 DeclareImplicitMoveAssignment(RD);
2945 if (SM == CXXCopyConstructor || SM == CXXCopyAssignment)
2953 if (SM != CXXDefaultConstructor) {
2979 assert(SM == CXXDefaultConstructor &&
2980 "lookup for a constructor or assignment operator was empty");
2982 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
2990 for (
NamedDecl *CandDecl : Candidates) {
2991 if (CandDecl->isInvalidDecl())
2997 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
2998 AddMethodCandidate(M, Cand, RD, ThisTy, Classification,
2999 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3001 AddOverloadCandidate(CtorInfo.Constructor, CtorInfo.FoundDecl,
3002 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3004 AddOverloadCandidate(M, Cand, llvm::makeArrayRef(&Arg, NumArgs), OCS,
3008 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3009 AddMethodTemplateCandidate(
3010 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
3011 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3013 AddTemplateOverloadCandidate(
3014 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
3015 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3017 AddTemplateOverloadCandidate(
3018 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3020 assert(isa<UsingDecl>(Cand.
getDecl()) &&
3021 "illegal Kind of operator = Decl");
3028 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3029 Result->
setKind(SpecialMemberOverloadResult::Success);
3033 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3034 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3039 Result->
setKind(SpecialMemberOverloadResult::Ambiguous);
3044 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3054 LookupSpecialMember(Class, CXXDefaultConstructor,
false,
false,
false,
3057 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3064 "non-const, non-volatile qualifiers for copy ctor arg");
3069 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3079 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3087 DeclareImplicitDefaultConstructor(Class);
3089 DeclareImplicitCopyConstructor(Class);
3091 DeclareImplicitMoveConstructor(Class);
3096 return Class->
lookup(Name);
3101 unsigned Quals,
bool RValueThis,
3102 unsigned ThisQuals) {
3104 "non-const, non-volatile qualifiers for copy assignment arg");
3106 "non-const, non-volatile qualifiers for copy assignment this");
3110 ThisQuals & Qualifiers::Const,
3111 ThisQuals & Qualifiers::Volatile);
3120 unsigned ThisQuals) {
3122 "non-const, non-volatile qualifiers for copy assignment this");
3126 ThisQuals & Qualifiers::Const,
3127 ThisQuals & Qualifiers::Volatile);
3139 return cast<CXXDestructorDecl>(LookupSpecialMember(Class, CXXDestructor,
3140 false,
false,
false,
3141 false,
false).getMethod());
3153 bool AllowRaw,
bool AllowTemplate,
3154 bool AllowStringTemplate,
bool DiagnoseMissing) {
3157 "literal operator lookup can't be ambiguous");
3162 bool FoundRaw =
false;
3163 bool FoundTemplate =
false;
3164 bool FoundStringTemplate =
false;
3165 bool FoundExactMatch =
false;
3167 while (F.hasNext()) {
3170 D = USD->getTargetDecl();
3179 bool IsTemplate =
false;
3180 bool IsStringTemplate =
false;
3181 bool IsExactMatch =
false;
3184 if (FD->getNumParams() == 1 &&
3185 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3187 else if (FD->getNumParams() == ArgTys.size()) {
3188 IsExactMatch =
true;
3189 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3190 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3192 IsExactMatch =
false;
3200 if (Params->
size() == 1)
3203 IsStringTemplate =
true;
3207 FoundExactMatch =
true;
3209 AllowTemplate =
false;
3210 AllowStringTemplate =
false;
3211 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3215 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3217 }
else if (AllowRaw && IsRaw) {
3219 }
else if (AllowTemplate && IsTemplate) {
3220 FoundTemplate =
true;
3221 }
else if (AllowStringTemplate && IsStringTemplate) {
3222 FoundStringTemplate =
true;
3233 if (FoundExactMatch)
3238 if (FoundRaw && FoundTemplate) {
3241 NoteOverloadCandidate(*I, (*I)->getUnderlyingDecl()->getAsFunction());
3249 return LOLR_Template;
3251 if (FoundStringTemplate)
3252 return LOLR_StringTemplate;
3255 if (DiagnoseMissing) {
3258 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3259 << (AllowTemplate || AllowStringTemplate);
3263 return LOLR_ErrorNoDiagnostic;
3271 if (Old ==
nullptr || Old == New) {
3286 if (!Cursor)
return;
3289 if (Cursor == OldFD)
break;
3303 FindAssociatedClassesAndNamespaces(Loc, Args,
3304 AssociatedNamespaces,
3318 for (
auto *NS : AssociatedNamespaces) {
3339 bool DeclaredInAssociatedClass =
false;
3342 if (isa<CXXRecordDecl>(LexDC) &&
3343 AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)) &&
3344 isVisible(cast<NamedDecl>(DI))) {
3345 DeclaredInAssociatedClass =
true;
3349 if (!DeclaredInAssociatedClass)
3353 auto *Underlying = D;
3354 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3355 Underlying = USD->getTargetDecl();
3357 if (!isa<FunctionDecl>(Underlying) &&
3358 !isa<FunctionTemplateDecl>(Underlying))
3361 if (!isVisible(D)) {
3365 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3366 Underlying = USD->getTargetDecl();
3370 Result.
insert(Underlying);
3384 class ShadowContextRAII;
3386 class VisibleDeclsRecord {
3391 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3396 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3399 std::list<ShadowMap> ShadowMaps;
3402 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3404 friend class ShadowContextRAII;
3410 return !VisitedContexts.insert(Ctx).second;
3414 return VisitedContexts.count(Ctx);
3426 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3431 class ShadowContextRAII {
3432 VisibleDeclsRecord &Visible;
3434 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3437 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3438 Visible.ShadowMaps.emplace_back();
3441 ~ShadowContextRAII() {
3442 Visible.ShadowMaps.pop_back();
3450 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3451 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3452 SM != SMEnd; ++
SM) {
3453 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
3454 if (Pos == SM->end())
3457 for (
auto *D : Pos->second) {
3475 SM == ShadowMaps.rbegin())
3480 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
3481 cast<UsingShadowDecl>(ND)->getUsingDecl() == D)
3493 bool QualifiedNameLookup,
3496 VisibleDeclsRecord &Visited,
3497 bool IncludeDependentBases =
false) {
3506 if (isa<TranslationUnitDecl>(Ctx) &&
3509 auto &Idents = S.Context.Idents;
3513 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3514 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3519 for (
const auto &Ident : Idents) {
3520 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3521 E = S.IdResolver.end();
3523 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3525 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3542 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3549 if (QualifiedNameLookup) {
3550 ShadowContextRAII Shadow(Visited);
3555 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3556 IncludeDependentBases);
3562 if (!Record->hasDefinition())
3565 for (
const auto &B : Record->bases()) {
3570 if (!IncludeDependentBases) {
3583 RD = TD->getTemplatedDecl();
3588 RD = Record->getDecl();
3611 ShadowContextRAII Shadow(Visited);
3613 Visited, IncludeDependentBases);
3620 for (
auto *Cat : IFace->visible_categories()) {
3621 ShadowContextRAII Shadow(Visited);
3627 for (
auto *I : IFace->all_referenced_protocols()) {
3628 ShadowContextRAII Shadow(Visited);
3634 if (IFace->getSuperClass()) {
3635 ShadowContextRAII Shadow(Visited);
3637 true, Consumer, Visited);
3642 if (IFace->getImplementation()) {
3643 ShadowContextRAII Shadow(Visited);
3645 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3648 for (
auto *I : Protocol->protocols()) {
3649 ShadowContextRAII Shadow(Visited);
3654 for (
auto *I :
Category->protocols()) {
3655 ShadowContextRAII Shadow(Visited);
3661 if (
Category->getImplementation()) {
3662 ShadowContextRAII Shadow(Visited);
3664 QualifiedNameLookup,
true, Consumer, Visited);
3670 UnqualUsingDirectiveSet &UDirs,
3672 VisibleDeclsRecord &Visited) {
3678 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3680 FindLocalExternScope FindLocals(Result);
3684 for (
Decl *D : ScopeDecls) {
3685 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3687 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3705 if (Method->isInstanceMethod()) {
3711 false, Consumer, Visited);
3725 false, Consumer, Visited);
3739 false, Consumer, Visited);
3745 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3748 false, Consumer, Visited);
3752 ShadowContextRAII Shadow(Visited);
3758 bool IncludeGlobalScope) {
3762 UnqualUsingDirectiveSet UDirs(*
this);
3768 UDirs.visitScopeChain(Initial, S);
3775 VisibleDeclsRecord Visited;
3776 if (!IncludeGlobalScope)
3778 ShadowContextRAII Shadow(Visited);
3784 bool IncludeGlobalScope,
3785 bool IncludeDependentBases) {
3788 VisibleDeclsRecord Visited;
3789 if (!IncludeGlobalScope)
3791 ShadowContextRAII Shadow(Visited);
3793 false, Consumer, Visited,
3794 IncludeDependentBases);
3809 Scope *S = CurScope;
3810 PushOnScopeChains(Res, S,
true);
3811 return cast<LabelDecl>(Res);
3815 Res = LookupSingleName(CurScope, II, Loc, LookupLabel, NotForRedeclaration);
3818 if (Res && Res->getDeclContext() != CurContext)
3824 assert(S &&
"Not in a function?");
3825 PushOnScopeChains(Res, S,
true);
3827 return cast<LabelDecl>(Res);
3845 bool EnteringContext,
3846 bool isObjCIvarLookup,
3855 for (; DI != DE; ++DI)
3865 bool AnyVisibleDecls = !NewDecls.empty();
3867 for (; DI != DE; ++DI) {
3873 if (!AnyVisibleDecls) {
3875 AnyVisibleDecls =
true;
3878 NewDecls.push_back(VisibleDecl);
3879 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3880 NewDecls.push_back(*DI);
3883 if (NewDecls.empty())
3900 Identifiers.clear();
3930 Identifiers.push_back(II);
3958 addName(Name,
nullptr);
3964 addName(Keyword,
nullptr,
nullptr,
true);
3967 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3971 StringRef TypoStr = Typo->getName();
3972 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
3973 if (MinED && TypoStr.size() / MinED < 3)
3978 unsigned UpperBound = (TypoStr.size() + 2) / 3 + 1;
3979 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
3980 if (ED >= UpperBound)
return;
3984 TC.setCorrectionRange(
nullptr, Result.getLookupNameInfo());
3991 StringRef TypoStr = Typo->getName();
3997 if (TypoStr.size() < 3 &&
3998 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4011 if (!CList.empty() && !CList.back().isResolved())
4015 for (TypoResultList::iterator RI = CList.begin(), RIEnd = CList.end();
4016 RI != RIEnd; ++RI) {
4021 if (RI->getCorrectionDecl() == NewND) {
4028 if (CList.empty() || Correction.
isResolved())
4029 CList.push_back(Correction);
4032 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4036 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4037 SearchNamespaces =
true;
4039 for (
auto KNPair : KnownNamespaces)
4040 Namespaces.addNameSpecifier(KNPair.first);
4042 bool SSIsTemplate =
false;
4046 SSIsTemplate = T->
getTypeClass() == Type::TemplateSpecialization;
4052 for (
unsigned I = 0; I != Types.size(); ++I) {
4053 const auto *TI = Types[I];
4055 CD = CD->getCanonicalDecl();
4056 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4057 !CD->isUnion() && CD->getIdentifier() &&
4058 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4059 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4060 Namespaces.addNameSpecifier(CD);
4066 if (++CurrentTCIndex < ValidatedCorrections.size())
4067 return ValidatedCorrections[CurrentTCIndex];
4069 CurrentTCIndex = ValidatedCorrections.size();
4070 while (!CorrectionResults.empty()) {
4071 auto DI = CorrectionResults.
begin();
4072 if (DI->second.empty()) {
4073 CorrectionResults.erase(DI);
4077 auto RI = DI->second.begin();
4078 if (RI->second.empty()) {
4079 DI->second.erase(RI);
4080 performQualifiedLookups();
4086 ValidatedCorrections.push_back(TC);
4087 return ValidatedCorrections[CurrentTCIndex];
4090 return ValidatedCorrections[0];
4093 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4100 CorrectionValidator->IsObjCIvarLookup,
4102 switch (Result.getResultKind()) {
4112 if (TempMemberContext) {
4115 TempMemberContext =
nullptr;
4118 if (SearchNamespaces)
4119 QualifiedResults.push_back(Candidate);
4129 for (
auto *TRD : Result)
4133 if (SearchNamespaces)
4134 QualifiedResults.push_back(Candidate);
4143 void TypoCorrectionConsumer::performQualifiedLookups() {
4144 unsigned TypoLen = Typo->getName().size();
4146 for (
const auto &NSI : Namespaces) {
4148 const Type *NSType = NSI.NameSpecifier->getAsType();
4156 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4170 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4171 TypoLen / TmpED < 3)
4175 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4181 switch (Result.getResultKind()) {
4186 std::string OldQualified;
4187 llvm::raw_string_ostream OldOStream(OldQualified);
4189 OldOStream << Typo->getName();
4193 if (OldOStream.str() == NewQualified)
4197 TRD != TRDEnd; ++TRD) {
4218 QualifiedResults.clear();
4221 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4223 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4225 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4226 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4234 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4235 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4242 DistanceMap[1].push_back(SI);
4245 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4247 assert(Start &&
"Building a context chain from a null context");
4248 DeclContextList Chain;
4260 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4262 unsigned NumSpecifiers = 0;
4264 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4267 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4269 RD->getTypeForDecl());
4273 return NumSpecifiers;
4276 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4279 unsigned NumSpecifiers = 0;
4280 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4281 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4284 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4285 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C)
4287 NamespaceDeclChain.pop_back();
4291 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4294 if (NamespaceDeclChain.empty()) {
4298 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4300 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4302 bool SameNameSpecifier =
false;
4303 if (std::find(CurNameSpecifierIdentifiers.begin(),
4304 CurNameSpecifierIdentifiers.end(),
4305 Name) != CurNameSpecifierIdentifiers.end()) {
4306 std::string NewNameSpecifier;
4307 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4311 SpecifierOStream.flush();
4312 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4314 if (SameNameSpecifier ||
4315 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4316 Name) != CurContextIdentifiers.end()) {
4320 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4328 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4331 NumSpecifiers = llvm::ComputeEditDistance(
4332 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4333 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4336 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4337 DistanceMap[NumSpecifiers].push_back(SI);
4346 bool EnteringContext,
4347 bool isObjCIvarLookup,
4353 if (MemberContext) {
4355 if (isObjCIvarLookup) {
4356 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4381 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4386 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4398 bool AfterNestedNameSpecifier) {
4399 if (AfterNestedNameSpecifier) {
4412 static const char *
const CTypeSpecs[] = {
4413 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4414 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4415 "_Complex",
"_Imaginary",
4417 "extern",
"inline",
"static",
"typedef" 4420 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4421 for (
unsigned I = 0; I != NumCTypeSpecs; ++I)
4448 static const char *
const CastableTypeSpecs[] = {
4449 "char",
"double",
"float",
"int",
"long",
"short",
4450 "signed",
"unsigned",
"void" 4452 for (
auto *kw : CastableTypeSpecs)
4471 static const char *
const CXXExprs[] = {
4472 "delete",
"new",
"operator",
"throw",
"typeid" 4474 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4475 for (
unsigned I = 0; I != NumCXXExprs; ++I)
4478 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4479 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4498 static const char *
const CStmts[] = {
4499 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4500 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4501 for (
unsigned I = 0; I != NumCStmts; ++I)
4545 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4548 std::unique_ptr<CorrectionCandidateCallback> CCC,
4552 if (Diags.hasFatalErrorOccurred() || !getLangOpts().SpellChecking ||
4553 DisableTypoCorrection)
4560 isa<CXXMethodDecl>(CurContext))
4574 if (!CodeSynthesisContexts.empty())
4582 IdentifierSourceLocations::iterator locs = TypoCorrectionFailures.find(Typo);
4583 if (locs != TypoCorrectionFailures.end() &&
4584 locs->second.count(TypoName.
getLoc()))
4590 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->
isStr(
"vector"))
4596 unsigned Limit = getDiagnostics().getDiagnosticOptions().SpellCheckingLimit;
4597 if (Limit && TyposCorrected >= Limit)
4603 if (ErrorRecovery && getLangOpts().Modules &&
4604 getLangOpts().ModulesSearchAll) {
4606 getModuleLoader().lookupMissingImports(Typo->
getName(),
4611 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4612 *
this, TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4616 bool IsUnqualifiedLookup =
false;
4618 if (MemberContext) {
4623 for (
auto *I : OPT->
quals())
4626 }
else if (SS && SS->isSet()) {
4627 QualifiedDC = computeDeclContext(*SS, EnteringContext);
4633 IsUnqualifiedLookup =
true;
4638 bool SearchNamespaces
4639 = getLangOpts().CPlusPlus &&
4640 (IsUnqualifiedLookup || (SS && SS->isSet()));
4642 if (IsUnqualifiedLookup || SearchNamespaces) {
4646 for (
const auto &I : Context.
Idents)
4647 Consumer->FoundName(I.getKey());
4653 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4655 StringRef Name = Iter->Next();
4659 Consumer->FoundName(Name);
4668 if (SearchNamespaces) {
4670 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4672 LoadedExternalKnownNamespaces =
true;
4673 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces);
4674 for (
auto *N : ExternalKnownNamespaces)
4675 KnownNamespaces[N] =
true;
4678 Consumer->addNamespaces(KnownNamespaces);
4718 std::unique_ptr<CorrectionCandidateCallback> CCC,
4721 bool EnteringContext,
4723 bool RecordFailure) {
4724 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4728 if (ExternalSource) {
4730 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4738 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4741 auto Consumer = makeTypoCorrectionConsumer(
4742 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4743 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4749 if (Consumer->empty())
4750 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4754 unsigned ED = Consumer->getBestEditDistance(
true);
4755 unsigned TypoLen = Typo->
getName().size();
4756 if (ED > 0 && TypoLen / ED < 3)
4757 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4762 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4766 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4770 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4774 if (!SecondBestTC ||
4775 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4781 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4787 }
else if (SecondBestTC && ObjCMessageReceiver) {
4791 if (BestTC.getCorrection().getAsString() !=
"super") {
4793 BestTC = SecondBestTC;
4794 else if ((*Consumer)[
"super"].front().isKeyword())
4795 BestTC = (*Consumer)[
"super"].front();
4799 if (BestTC.getEditDistance() == 0 ||
4800 BestTC.getCorrection().getAsString() !=
"super")
4801 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4810 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4854 std::unique_ptr<CorrectionCandidateCallback> CCC,
4858 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4860 auto Consumer = makeTypoCorrectionConsumer(
4861 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4862 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4866 if (ExternalSource && Consumer) {
4867 ExternalTypo = ExternalSource->CorrectTypo(
4868 TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(),
4869 MemberContext, EnteringContext, OPT);
4871 Consumer->addCorrection(ExternalTypo);
4874 if (!Consumer || Consumer->empty())
4879 unsigned ED = Consumer->getBestEditDistance(
true);
4881 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
4884 ExprEvalContexts.back().NumTypos++;
4885 return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC));
4892 CorrectionDecls.clear();
4894 CorrectionDecls.push_back(CDecl);
4896 if (!CorrectionName)
4901 if (CorrectionNameSpec) {
4902 std::string tmpBuffer;
4903 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4905 PrefixOStream << CorrectionName;
4906 return PrefixOStream.str();
4909 return CorrectionName.getAsString();
4918 return WantTypeSpecifiers || WantExpressionKeywords || WantCXXNamedCasts ||
4919 WantRemainingKeywords || WantObjCSuper;
4921 bool HasNonType =
false;
4922 bool HasStaticMethod =
false;
4923 bool HasNonStaticMethod =
false;
4924 for (
Decl *D : candidate) {
4926 D = FTD->getTemplatedDecl();
4928 if (Method->isStatic())
4929 HasStaticMethod =
true;
4931 HasNonStaticMethod =
true;
4933 if (!isa<TypeDecl>(D))
4937 if (IsAddressOfOperand && HasNonStaticMethod && !HasStaticMethod &&
4938 !candidate.getCorrectionSpecifier())
4941 return WantTypeSpecifiers || HasNonType;
4945 bool HasExplicitTemplateArgs,
4947 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4948 CurContext(SemaRef.CurContext), MemberFn(ME) {
4958 for (
auto *
C : candidate) {
4962 FD = FTD->getTemplatedDecl();
4963 if (!HasExplicitTemplateArgs && !FD) {
4964 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4968 QualType ValType = cast<ValueDecl>(ND)->getType();
4972 if (FPT->getNumParams() == NumArgs)
4988 if (MemberFn || !MD->isStatic()) {
4991 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
4992 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
5007 bool ErrorRecovery) {
5008 diagnoseTypo(Correction, TypoDiag, PDiag(diag::note_previous_decl),
5015 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
5016 return VD->getDefinition();
5018 return FD->getDefinition();
5019 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
5020 return TD->getDefinition();
5022 return ID->getDefinition();
5024 return PD->getDefinition();
5038 Module *Owner = getOwningModule(Decl);
5039 assert(Owner &&
"definition of hidden declaration is not in a module");
5042 OwningModules.push_back(Owner);
5044 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5046 diagnoseMissingImport(Loc, Decl, Decl->
getLocation(), OwningModules, MIK,
5057 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
5064 assert(!Modules.empty());
5068 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5069 for (
auto *M : Modules)
5070 if (UniqueModuleSet.insert(M).second)
5071 UniqueModules.push_back(M);
5072 Modules = UniqueModules;
5074 if (Modules.size() > 1) {
5075 std::string ModuleList;
5077 for (
Module *M : Modules) {
5078 ModuleList +=
"\n ";
5079 if (++N == 5 && N != Modules.size()) {
5080 ModuleList +=
"[...]";
5083 ModuleList += M->getFullModuleName();
5086 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5087 << (int)MIK << Decl << ModuleList;
5088 }
else if (
const FileEntry *E = PP.getModuleHeaderToIncludeForDiagnostics(
5089 UseLoc, Modules[0], DeclLoc)) {
5095 Diag(UseLoc, diag::err_module_unimported_use_header)
5096 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5100 Diag(UseLoc, diag::err_module_unimported_use)
5101 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5106 case MissingImportKind::Declaration:
5107 DiagID = diag::note_previous_declaration;
5109 case MissingImportKind::Definition:
5110 DiagID = diag::note_previous_definition;
5112 case MissingImportKind::DefaultArgument:
5113 DiagID = diag::note_default_argument_declared_here;
5115 case MissingImportKind::ExplicitSpecialization:
5116 DiagID = diag::note_explicit_specialization_declared_here;
5118 case MissingImportKind::PartialSpecialization:
5119 DiagID = diag::note_partial_specialization_declared_here;
5122 Diag(DeclLoc, DiagID);
5126 createImplicitModuleImportForErrorRecovery(UseLoc, Modules[0]);
5144 bool ErrorRecovery) {
5145 std::string CorrectedStr = Correction.
getAsString(getLangOpts());
5146 std::string CorrectedQuotedStr = Correction.
getQuoted(getLangOpts());
5153 assert(Decl &&
"import required but no declaration to import");
5156 MissingImportKind::Declaration, ErrorRecovery);
5161 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5166 Diag(ChosenDecl->getLocation(), PrevNote)
5167 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5174 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5177 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5179 auto &
State = DelayedTypos[TE];
5180 State.Consumer = std::move(TCC);
5181 State.DiagHandler = std::move(TDG);
5182 State.RecoveryHandler = std::move(TRC);
5187 auto Entry = DelayedTypos.find(TE);
5188 assert(Entry != DelayedTypos.end() &&
5189 "Failed to get the state for a TypoExpr!");
5190 return Entry->second;
5194 DelayedTypos.erase(TE);
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Defines the clang::ASTContext interface.
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
An instance of this class is created to represent a function declaration or definition.
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Name lookup found a set of overloaded functions that met the criteria.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
SourceRange getCorrectionRange() const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
Template argument deduction was successful.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
AmbiguityKind getAmbiguityKind() const
Look up the name of an Objective-C protocol.
Filter makeFilter()
Create a filter for this result set.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
void erase()
Erase the last element returned from this iterator.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Decl - This represents one declaration (or definition), e.g.
__DEVICE__ long long abs(long long __n)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
Defines the C++ template declaration subclasses.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void swap(CXXBasePaths &Other)
Swap this data structure's contents with another CXXBasePaths object.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules, Filter F)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
The base class of the type hierarchy.
MissingImportKind
Kinds of missing import.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Ambiguous candidates found.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
const NestedNameSpecifier * Specifier
Look up of a name that precedes the '::' scope resolution operator in C++.
void makeKeyword()
Mark this TypoCorrection as being a keyword.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
void setCorrectionSpecifier(NestedNameSpecifier *NNS)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
An identifier, stored as an IdentifierInfo*.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
std::list< CXXBasePath >::iterator paths_iterator
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
static bool LookupBuiltin(Sema &S, LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
DeclarationName getLookupName() const
Gets the name to look up.
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.
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last)
Determine whether the given set of member declarations contains only static members, nested types, and enumerators.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare reduction member wi...
A namespace, stored as a NamespaceDecl*.
unsigned getDiagID() const
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Look up an ordinary name that is going to be redeclared as a name with linkage.
Defines the clang::Expr interface and subclasses for C++ expressions.
void addKeywordResult(StringRef Keyword)
bool WantExpressionKeywords
void setMethod(CXXMethodDecl *MD)
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Types, declared with 'struct foo', typedefs, etc.
RecordDecl - Represents a struct/union/class.
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
std::string getQuoted(const LangOptions &LO) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
The results of name lookup within a DeclContext.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true)
void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
This declaration is a friend function.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
conversion_iterator conversion_end() const
bool isReferenceType() const
The iterator over UnresolvedSets.
void addCorrectionDecl(NamedDecl *CDecl)
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the Decla...
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
LookupResultKind getResultKind() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
Describes a module or submodule.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
SpecialMemberOverloadResult - The overloading result for a special member function.
void setCallbackDistance(unsigned ED)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
DeclClass * getAsSingle() const
bool isModuleVisible(const Module *M)
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
Look up implicit 'self' parameter of an objective-c method.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents the results of name lookup.
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Namespaces, declared with 'namespace foo {}'.
static void LookupPotentialTypoResult(Sema &SemaRef, LookupResult &Res, IdentifierInfo *Name, Scope *S, CXXScopeSpec *SS, DeclContext *MemberContext, bool EnteringContext, bool isObjCIvarLookup, bool FindHidden)
Perform name lookup for a possible result for typo correction.
HeaderSearch & getHeaderSearchInfo() const
void setQualifierDistance(unsigned ED)
bool hasTagIdentifierNamespace() const
Succeeded, but refers to a deleted function.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Look up all declarations in a scope with the given name, including resolved using declarations...
static NamedDecl * getDefinitionToImport(NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
const clang::PrintingPolicy & getPrintingPolicy() const
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
TypeDecl - Represents a declaration of a type.
A set of unresolved declarations.
static unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, bool Redeclaration)
const Type * getClass() const
Look up the name of an OpenMP user-defined reduction operation.
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Scope - A scope is a transient data structure that is used while parsing the program.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
using_directives_range using_directives()
void append(iterator I, iterator E)
Represents a C++ nested-name-specifier or a global scope specifier.
base_class_iterator bases_begin()
Represents an Objective-C protocol declaration.
lookups_range lookups() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
const LangOptions & getLangOpts() const
Labels, declared with 'x:' and referenced with 'goto x'.
const TypoCorrection & getNextCorrection()
Return the next typo correction that passes all internal filters and is deemed valid by the consumer'...
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
Represents an ObjC class declaration.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
ExtInfo withCallingConv(CallingConv cc) const
static const unsigned InvalidDistance
CXXSpecialMember
Kinds of C++ special members.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool WantRemainingKeywords
Sema - This implements semantic analysis and AST building for C.
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
This declaration is a C++ operator declared in a non-class context.
bool hasMergedDefinitionInCurrentModule(NamedDecl *Def)
The return type of classify().
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Provides lookups to, and iteration over, IdentiferInfo objects.
SourceRange getRange() const
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
This declaration is a friend class.
std::string getAsString(const LangOptions &LO) const
static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Callback that looks for any member of a class with the given name.
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr *> Args, ADLResult &Functions)
bool isInlineNamespace() const
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, DeclContext *StartDC)
Perform qualified name lookup in the namespaces nominated by using directives by the given context...
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
Expr - This represents one expression.
Defines the clang::LangOptions interface.
LookupNameKind
Describes the kind of name lookup to perform.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
llvm::StringRef getAsString(SyncScope S)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
const FunctionProtoType * T
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to...
DeclContext * getEntity() const
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location...
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Represents a C++ destructor within a class.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
This declaration is an OpenMP user defined reduction construction.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void setRequiresImport(bool Req)
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFileContext() const
DeclContext * getDeclContext()
static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name that can...
CXXRecordDecl * getDefinition() const
Overload resolution succeeded.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Represents a C++ template name within the type system.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
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.
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionOrMethod() const
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D)
Retrieve the visible declaration corresponding to D, if any.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void addCorrection(TypoCorrection Correction)
QualType getRecordType(const RecordDecl *Decl) const
static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name...
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A type, stored as a Type*.
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
RecordDecl * getDecl() const
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
const CXXBaseSpecifier * Base
The base specifier that states the link from a derived class to a base class, which will be followed ...
static Module * getDefiningModule(Sema &S, Decl *Entity)
Find the module in which the given declaration was defined.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
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.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
param_type_range param_types() const
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
void addVolatile()
Add the volatile type qualifier to this QualType.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
Members, declared with object declarations within tag definitions.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr *> Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
DeclarationName getName() const
getName - Returns the embedded declaration name.
TagDecl - Represents the declaration of a struct/union/class/enum.
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)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Name lookup found an unresolvable value declaration and cannot yet complete.
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
ObjCCategoryDecl - Represents a category declaration.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Look up any declaration with any name.
bool isAnyPointerType() const
A class for iterating through a result set and possibly filtering out results.
const TypoExprState & getTypoExprState(TypoExpr *TE) const
Represents one property declaration in an Objective-C interface.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
No entity found met the criteria.
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
const SmallVectorImpl< Type * > & getTypes() const
static bool canHideTag(NamedDecl *D)
Determine whether D can hide a tag declaration.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
A POD class for pairing a NamedDecl* with an access specifier.
StringRef getName() const
Return the actual identifier string.
A class for storing results from argument-dependent lookup.
Represents an element in a path from a derived class to a base class.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Represents a template argument.
static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces, DeclContext *Ctx)
static DeclContext * getContextForScopeMatching(Decl *D)
Get a representative context for a declaration such that two declarations will have the same context ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
bool hasVisibleExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if there is a visible declaration of D that is an explicit specialization declaration for a...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
std::list< CXXBasePath >::const_iterator const_paths_iterator
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
SourceLocation getLocStart() const LLVM_READONLY
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier *NNS, SmallVectorImpl< const IdentifierInfo *> &Identifiers)
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC)
Check whether the declarations found for a typo correction are visible.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static void AddKeywordsToConsumer(Sema &SemaRef, TypoCorrectionConsumer &Consumer, Scope *S, CorrectionCandidateCallback &CCC, bool AfterNestedNameSpecifier)
Add keywords to the consumer as possible typo corrections.
The base class of all kinds of template declarations (e.g., class, function, etc.).
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
void setContextRange(SourceRange SR)
Sets a 'context' source range.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
The template argument is a pack expansion of a template name that was provided for a template templat...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
AccessSpecifier getAccess() const
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
conversion_iterator conversion_begin() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
DeclarationName - The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
EnumDecl - Represents an enum.
static const unsigned MaxTypoDistanceResultSets
A pointer to member type per C++ 8.3.3 - Pointers to members.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
Name lookup found a single declaration that met the criteria.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
BuiltinTemplateDecl * getTypePackElementDecl() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
QualType getCanonicalTypeInternal() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, SourceLocation Loc, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
The template argument is a type.
static bool FindTagMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a tag with the given name...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
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 isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
llvm::iterator_range< decls_iterator > decls() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isSet() const
Deprecated.
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
ArgKind getKind() const
Return the kind of stored template argument.
static bool isNamespaceOrTranslationUnitScope(Scope *S)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
void setCorrectionDecls(ArrayRef< NamedDecl *> Decls)
Clears the list of NamedDecls and adds the given set.
Represents a C++ struct/union/class.
IdentifierInfo * getTypePackElementName() const
void ClearCorrectionDecls()
Clears the list of NamedDecls.
The template argument is a template name that was provided for a template template parameter...
sema::FunctionScopeInfo * getCurFunction() const
Look up a friend of a local class.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
IdentifierInfo * getMakeIntegerSeqName() const
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ObjCIvarDecl - Represents an ObjC instance variable.
base_class_iterator bases_end()
void setCorrectionRange(CXXScopeSpec *SS, const DeclarationNameInfo &TypoName)
void print(raw_ostream &)
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
static bool isPreferredLookupResult(Sema &S, Sema::LookupNameKind Kind, NamedDecl *D, NamedDecl *Existing)
Determine whether D is a better lookup result than Existing, given that they declare the same entity...
AccessSpecifier Access
The access along this inheritance path.
void addNamespaces(const llvm::MapVector< NamespaceDecl *, bool > &KnownNamespaces)
Set-up method to add to the consumer the set of namespaces to use in performing corrections to nested...
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
This declaration is a function-local extern declaration of a variable or function.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
Represents a type template specialization; the template must be a class template, a type alias templa...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
bool isDeleted() const
Whether this function has been deleted.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
No viable function found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static std::pair< DeclContext *, bool > findOuterContext(Scope *S)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
bool setUseQualifiedLookup(bool use=true)
A trivial tuple used to represent a source range.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
NamedDecl - This represents a decl with a name.
bool isTranslationUnit() const
Represents C++ using-directive.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Look up of an operator name (e.g., operator+) for use with operator overloading.
static bool CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, DeclContext *NS, UnqualUsingDirectiveSet &UDirs)
The global specifier '::'. There is no stored value.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getBegin() const
void WillReplaceSpecifier(bool ForceReplacement)
bool WantFunctionLikeCasts
ExceptionSpecInfo ExceptionSpec
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
iterator - Iterate over the decls of a specified declaration name.
void setFindLocalExtern(bool FindLocalExtern)
SourceLocation getLocation() const
QualType getPointeeType() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
static bool isCandidateViable(CorrectionCandidateCallback &CCC, TypoCorrection &Candidate)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
This declaration is a using declaration.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on #pragma clang __debug dump II.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
ArrayRef< PartialDiagnostic > getExtraDiagnostics() const
QualType getType() const
Retrieves the type of the base class.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.