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 llvm::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 bool HasFilteredRedecls =
false;
1457 for (
auto *Redecl : D->
redecls()) {
1458 auto *R = cast<NamedDecl>(Redecl);
1465 HasFilteredRedecls =
true;
1468 Modules->push_back(R->getOwningModule());
1470 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1475 if (HasFilteredRedecls)
1484 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1486 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1488 if (
auto *VD = dyn_cast<VarDecl>(D))
1490 llvm_unreachable(
"unknown explicit specialization kind");
1497 "not a member specialization");
1518 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1519 assert(D->
isHidden() &&
"should not call this: not in slow case");
1536 ? DeclModule->getTopLevelModuleName() ==
1547 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1549 isa<ExportDecl>(DC);
1555 if (DC && !IsEffectivelyFileContext(DC)) {
1563 bool VisibleWithinParent;
1565 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1566 VisibleWithinParent = isVisible(SemaRef, cast<NamedDecl>(DC));
1570 VisibleWithinParent =
false;
1573 VisibleWithinParent =
true;
1577 }
while (!IsEffectivelyFileContext(DC));
1589 return VisibleWithinParent;
1599 if (LookupModules.empty())
1603 if (LookupModules.count(DeclModule))
1612 return std::any_of(LookupModules.begin(), LookupModules.end(),
1614 return M->isModuleVisible(DeclModule); });
1617 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1635 "should not have hidden, non-externally-declarable result here");
1669 for (
auto RD : D->
redecls()) {
1674 auto ND = cast<NamedDecl>(RD);
1678 if (ND->isInIdentifierNamespace(IDNS) &&
1688 assert(!isVisible(D) &&
"not in slow case");
1690 [](
const NamedDecl *) {
return true; });
1694 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1702 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1704 auto *Acceptable = isVisible(getSema(), Key)
1708 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1745 if (!Name)
return false;
1760 FindLocalExternScope FindLocals(R);
1766 bool LeftStartingScope =
false;
1769 IEnd = IdResolver.end();
1772 if (NameKind == LookupRedeclarationWithLinkage) {
1776 LeftStartingScope =
true;
1780 if (LeftStartingScope && !((*I)->hasLinkage())) {
1785 else if (NameKind == LookupObjCImplicitSelfParam &&
1786 !isa<ImplicitParamDecl>(*I))
1811 for (++LastI; LastI != IEnd; ++LastI) {
1836 if (CppLookupName(R, S))
1850 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1882 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1889 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1890 Visited.insert(StartDC);
1895 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
1896 if (S.
isVisible(I) && Visited.insert(ND).second)
1897 Queue.push_back(ND);
1904 bool FoundTag =
false;
1905 bool FoundNonTag =
false;
1910 while (!Queue.empty()) {
1915 bool UseLocal = !R.
empty();
1944 if (S.
isVisible(I) && Visited.insert(Nom).second)
1945 Queue.push_back(Nom);
1950 if (FoundTag && FoundNonTag)
1970 template<
typename InputIterator>
1973 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1976 if (isa<CXXMethodDecl>(D)) {
1978 bool AllMethodsAreStatic =
true;
1979 for(; First != Last; ++First) {
1980 D = (*First)->getUnderlyingDecl();
1982 if (!isa<CXXMethodDecl>(D)) {
1983 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1987 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1988 AllMethodsAreStatic =
false;
1993 if (AllMethodsAreStatic)
2023 bool InUnqualifiedLookup) {
2024 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2030 assert((!isa<TagDecl>(LookupCtx) ||
2032 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
2033 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
2034 "Declaration context must already be complete!");
2036 struct QualifiedLookupInScope {
2040 QualifiedLookupInScope(
DeclContext *ctx) : Context(ctx) {
2043 ~QualifiedLookupInScope() {
2050 if (isa<CXXRecordDecl>(LookupCtx))
2096 case LookupObjCImplicitSelfParam:
2097 case LookupOrdinaryName:
2098 case LookupMemberName:
2099 case LookupRedeclarationWithLinkage:
2100 case LookupLocalFriendName:
2112 case LookupOMPReductionName:
2116 case LookupUsingDeclName:
2119 case LookupOperatorName:
2120 case LookupNamespaceName:
2121 case LookupObjCProtocolName:
2126 case LookupNestedNameSpecifierName:
2134 return BaseCallback(Specifier, Path, Name);
2148 int SubobjectNumber = 0;
2152 Path != PathEnd; ++Path) {
2160 if (SubobjectType.
isNull()) {
2177 while (FirstD != FirstPath->Decls.end() &&
2179 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2180 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2187 if (FirstD == FirstPath->Decls.end() &&
2243 return LookupInSuper(R, NNS->getAsRecordDecl());
2246 return LookupQualifiedName(R, LookupCtx);
2269 bool AllowBuiltinCreation,
bool EnteringContext) {
2276 if (SS && SS->
isSet()) {
2281 if (
DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
2288 return LookupQualifiedName(R, DC);
2300 return LookupName(R, S, AllowBuiltinCreation);
2317 for (
const auto &BaseSpec : Class->
bases()) {
2319 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2322 LookupQualifiedName(Result, RD);
2326 for (
auto I = Result.begin(), E = Result.end(); I != E; ++I) {
2332 Result.suppressDiagnostics();
2346 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2355 QualType SubobjectType = Paths->
front().back().Base->getType();
2356 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2357 << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths)
2361 while (isa<CXXMethodDecl>(*Found) &&
2362 cast<CXXMethodDecl>(*Found)->isStatic())
2365 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2370 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2371 << Name << LookupRange;
2374 std::set<Decl *> DeclsPrinted;
2376 PathEnd = Paths->
end();
2377 Path != PathEnd; ++Path) {
2378 Decl *D = Path->Decls.front();
2379 if (DeclsPrinted.insert(D).second)
2386 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2388 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2390 for (
auto *D : Result)
2391 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2392 TagDecls.insert(TD);
2393 Diag(TD->getLocation(), diag::note_hidden_tag);
2396 for (
auto *D : Result)
2397 if (!isa<TagDecl>(D))
2403 if (TagDecls.count(F.
next()))
2411 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2413 for (
auto *D : Result)
2421 struct AssociatedLookup {
2425 : S(S), Namespaces(Namespaces), Classes(Classes),
2426 InstantiationLoc(InstantiationLoc) {
2483 DeclContext *Ctx = ClassTemplate->getDeclContext();
2484 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2485 Result.Classes.insert(EnclosingClass);
2515 if (Class->
getDeclName() == Result.S.VAListTagName)
2528 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2529 Result.Classes.insert(EnclosingClass);
2539 if (!Result.Classes.insert(Class))
2552 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2553 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2554 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2555 Result.Classes.insert(EnclosingClass);
2560 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
2565 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2566 Result.S.Context.getRecordType(Class)))
2572 Bases.push_back(Class);
2573 while (!Bases.empty()) {
2575 Class = Bases.pop_back_val();
2578 for (
const auto &
Base : Class->
bases()) {
2589 if (Result.Classes.insert(BaseDecl)) {
2596 Bases.push_back(BaseDecl);
2624 #define TYPE(Class, Base) 2625 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 2626 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 2627 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 2628 #define ABSTRACT_TYPE(Class, Base) 2629 #include "clang/AST/TypeNodes.def" 2640 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2642 case Type::ConstantArray:
2643 case Type::IncompleteArray:
2644 case Type::VariableArray:
2645 T = cast<ArrayType>(T)->getElementType().getTypePtr();
2658 case Type::Record: {
2660 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2670 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2673 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2674 Result.Classes.insert(EnclosingClass);
2685 case Type::FunctionProto: {
2688 Queue.push_back(Arg.getTypePtr());
2692 case Type::FunctionNoProto: {
2707 case Type::MemberPointer: {
2711 Queue.push_back(MemberPtr->
getClass());
2719 case Type::BlockPointer:
2720 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2725 case Type::LValueReference:
2726 case Type::RValueReference:
2727 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2732 case Type::ExtVector:
2738 case Type::DeducedTemplateSpecialization:
2744 case Type::ObjCObject:
2745 case Type::ObjCInterface:
2746 case Type::ObjCObjectPointer:
2747 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2753 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2756 T = cast<PipeType>(T)->getElementType().getTypePtr();
2762 T = Queue.pop_back_val();
2777 AssociatedNamespaces.clear();
2778 AssociatedClasses.clear();
2780 AssociatedLookup Result(*
this, InstantiationLoc,
2781 AssociatedNamespaces, AssociatedClasses);
2790 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2791 Expr *Arg = Args[ArgIdx];
2807 if (unaryOp->getOpcode() == UO_AddrOf)
2808 Arg = unaryOp->getSubExpr();
2813 for (
const auto *D : ULE->
decls()) {
2837 Decl *D = LookupSingleName(TUScope, II, IdLoc,
2838 LookupObjCProtocolName, Redecl);
2839 return cast_or_null<ObjCProtocolDecl>(D);
2853 LookupName(Operators, S);
2855 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2865 bool VolatileThis) {
2867 "doing special member lookup into record that isn't fully complete");
2869 if (RValueThis || ConstThis || VolatileThis)
2870 assert((SM == CXXCopyAssignment || SM == CXXMoveAssignment) &&
2871 "constructors and destructors always have unqualified lvalue this");
2872 if (ConstArg || VolatileArg)
2873 assert((SM != CXXDefaultConstructor && SM != CXXDestructor) &&
2874 "parameter-less special members can't have qualified arguments");
2879 llvm::FoldingSetNodeID
ID;
2882 ID.AddInteger(ConstArg);
2883 ID.AddInteger(VolatileArg);
2884 ID.AddInteger(RValueThis);
2885 ID.AddInteger(ConstThis);
2886 ID.AddInteger(VolatileThis);
2890 SpecialMemberCache.FindNodeOrInsertPos(ID, InsertPoint);
2898 SpecialMemberCache.InsertNode(Result, InsertPoint);
2900 if (SM == CXXDestructor) {
2902 DeclareImplicitDestructor(RD);
2904 assert(DD &&
"record without a destructor");
2907 SpecialMemberOverloadResult::NoMemberOrDeleted :
2908 SpecialMemberOverloadResult::Success);
2916 Expr *Arg =
nullptr;
2922 if (SM == CXXDefaultConstructor) {
2926 DeclareImplicitDefaultConstructor(RD);
2928 if (SM == CXXCopyConstructor || SM == CXXMoveConstructor) {
2931 DeclareImplicitCopyConstructor(RD);
2933 DeclareImplicitMoveConstructor(RD);
2937 DeclareImplicitCopyAssignment(RD);
2939 DeclareImplicitMoveAssignment(RD);
2954 if (SM == CXXCopyConstructor || SM == CXXCopyAssignment)
2962 if (SM != CXXDefaultConstructor) {
2988 assert(SM == CXXDefaultConstructor &&
2989 "lookup for a constructor or assignment operator was empty");
2991 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
2999 for (
NamedDecl *CandDecl : Candidates) {
3000 if (CandDecl->isInvalidDecl())
3006 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3007 AddMethodCandidate(M, Cand, RD, ThisTy, Classification,
3008 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3010 AddOverloadCandidate(CtorInfo.Constructor, CtorInfo.FoundDecl,
3011 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3013 AddOverloadCandidate(M, Cand, llvm::makeArrayRef(&Arg, NumArgs), OCS,
3017 if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
3018 AddMethodTemplateCandidate(
3019 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
3020 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3022 AddTemplateOverloadCandidate(
3023 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
3024 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3026 AddTemplateOverloadCandidate(
3027 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
3029 assert(isa<UsingDecl>(Cand.
getDecl()) &&
3030 "illegal Kind of operator = Decl");
3037 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3038 Result->
setKind(SpecialMemberOverloadResult::Success);
3042 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3043 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3048 Result->
setKind(SpecialMemberOverloadResult::Ambiguous);
3053 Result->
setKind(SpecialMemberOverloadResult::NoMemberOrDeleted);
3063 LookupSpecialMember(Class, CXXDefaultConstructor,
false,
false,
false,
3066 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3073 "non-const, non-volatile qualifiers for copy ctor arg");
3078 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3088 return cast_or_null<CXXConstructorDecl>(Result.
getMethod());
3096 DeclareImplicitDefaultConstructor(Class);
3098 DeclareImplicitCopyConstructor(Class);
3100 DeclareImplicitMoveConstructor(Class);
3105 return Class->
lookup(Name);
3110 unsigned Quals,
bool RValueThis,
3111 unsigned ThisQuals) {
3113 "non-const, non-volatile qualifiers for copy assignment arg");
3115 "non-const, non-volatile qualifiers for copy assignment this");
3119 ThisQuals & Qualifiers::Const,
3120 ThisQuals & Qualifiers::Volatile);
3129 unsigned ThisQuals) {
3131 "non-const, non-volatile qualifiers for copy assignment this");
3135 ThisQuals & Qualifiers::Const,
3136 ThisQuals & Qualifiers::Volatile);
3148 return cast<CXXDestructorDecl>(LookupSpecialMember(Class, CXXDestructor,
3149 false,
false,
false,
3150 false,
false).getMethod());
3162 bool AllowRaw,
bool AllowTemplate,
3163 bool AllowStringTemplate,
bool DiagnoseMissing) {
3166 "literal operator lookup can't be ambiguous");
3171 bool FoundRaw =
false;
3172 bool FoundTemplate =
false;
3173 bool FoundStringTemplate =
false;
3174 bool FoundExactMatch =
false;
3176 while (F.hasNext()) {
3179 D = USD->getTargetDecl();
3188 bool IsTemplate =
false;
3189 bool IsStringTemplate =
false;
3190 bool IsExactMatch =
false;
3193 if (FD->getNumParams() == 1 &&
3194 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3196 else if (FD->getNumParams() == ArgTys.size()) {
3197 IsExactMatch =
true;
3198 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3199 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3201 IsExactMatch =
false;
3209 if (Params->
size() == 1)
3212 IsStringTemplate =
true;
3216 FoundExactMatch =
true;
3218 AllowTemplate =
false;
3219 AllowStringTemplate =
false;
3220 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3224 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3226 }
else if (AllowRaw && IsRaw) {
3228 }
else if (AllowTemplate && IsTemplate) {
3229 FoundTemplate =
true;
3230 }
else if (AllowStringTemplate && IsStringTemplate) {
3231 FoundStringTemplate =
true;
3242 if (FoundExactMatch)
3247 if (FoundRaw && FoundTemplate) {
3250 NoteOverloadCandidate(*I, (*I)->getUnderlyingDecl()->getAsFunction());
3258 return LOLR_Template;
3260 if (FoundStringTemplate)
3261 return LOLR_StringTemplate;
3264 if (DiagnoseMissing) {
3267 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3268 << (AllowTemplate || AllowStringTemplate);
3272 return LOLR_ErrorNoDiagnostic;
3280 if (Old ==
nullptr || Old == New) {
3295 if (!Cursor)
return;
3298 if (Cursor == OldFD)
break;
3312 FindAssociatedClassesAndNamespaces(Loc, Args,
3313 AssociatedNamespaces,
3327 for (
auto *NS : AssociatedNamespaces) {
3341 auto *Underlying = D;
3342 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3343 Underlying = USD->getTargetDecl();
3345 if (!isa<FunctionDecl>(Underlying) &&
3346 !isa<FunctionTemplateDecl>(Underlying))
3349 if (!isVisible(D)) {
3354 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3355 Underlying = USD->getTargetDecl();
3365 bool DeclaredInAssociatedClass =
false;
3368 if (isa<CXXRecordDecl>(LexDC) &&
3369 AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)) &&
3370 isVisible(cast<NamedDecl>(DI))) {
3371 DeclaredInAssociatedClass =
true;
3375 if (!DeclaredInAssociatedClass)
3380 Result.
insert(Underlying);
3394 class ShadowContextRAII;
3396 class VisibleDeclsRecord {
3401 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3406 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3409 std::list<ShadowMap> ShadowMaps;
3412 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3414 friend class ShadowContextRAII;
3420 return !VisitedContexts.insert(Ctx).second;
3424 return VisitedContexts.count(Ctx);
3436 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3441 class ShadowContextRAII {
3442 VisibleDeclsRecord &Visible;
3444 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3447 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3448 Visible.ShadowMaps.emplace_back();
3451 ~ShadowContextRAII() {
3452 Visible.ShadowMaps.pop_back();
3460 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3461 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3462 SM != SMEnd; ++
SM) {
3463 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
3464 if (Pos == SM->end())
3467 for (
auto *D : Pos->second) {
3485 SM == ShadowMaps.rbegin())
3490 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
3491 cast<UsingShadowDecl>(ND)->getUsingDecl() == D)
3503 bool QualifiedNameLookup,
3506 VisibleDeclsRecord &Visited,
3507 bool IncludeDependentBases,
3508 bool LoadExternal) {
3519 if (isa<TranslationUnitDecl>(Ctx) &&
3522 auto &Idents = S.Context.Idents;
3527 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3528 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3533 for (
const auto &Ident : Idents) {
3534 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3535 E = S.IdResolver.end();
3537 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3539 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3553 bool Load = LoadExternal ||
3554 !(isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx));
3561 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3568 if (QualifiedNameLookup) {
3569 ShadowContextRAII Shadow(Visited);
3574 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3575 IncludeDependentBases, LoadExternal);
3581 if (!Record->hasDefinition())
3584 for (
const auto &B : Record->bases()) {
3589 if (!IncludeDependentBases) {
3602 RD = TD->getTemplatedDecl();
3607 RD = Record->getDecl();
3630 ShadowContextRAII Shadow(Visited);
3632 Visited, IncludeDependentBases, LoadExternal);
3639 for (
auto *Cat : IFace->visible_categories()) {
3640 ShadowContextRAII Shadow(Visited);
3642 Visited, IncludeDependentBases, LoadExternal);
3646 for (
auto *I : IFace->all_referenced_protocols()) {
3647 ShadowContextRAII Shadow(Visited);
3649 Visited, IncludeDependentBases, LoadExternal);
3653 if (IFace->getSuperClass()) {
3654 ShadowContextRAII Shadow(Visited);
3656 true, Consumer, Visited, IncludeDependentBases,
3662 if (IFace->getImplementation()) {
3663 ShadowContextRAII Shadow(Visited);
3665 QualifiedNameLookup, InBaseClass, Consumer, Visited,
3666 IncludeDependentBases, LoadExternal);
3669 for (
auto *I : Protocol->protocols()) {
3670 ShadowContextRAII Shadow(Visited);
3672 Visited, IncludeDependentBases, LoadExternal);
3675 for (
auto *I :
Category->protocols()) {
3676 ShadowContextRAII Shadow(Visited);
3678 Visited, IncludeDependentBases, LoadExternal);
3682 if (
Category->getImplementation()) {
3683 ShadowContextRAII Shadow(Visited);
3685 QualifiedNameLookup,
true, Consumer, Visited,
3686 IncludeDependentBases, LoadExternal);
3692 UnqualUsingDirectiveSet &UDirs,
3694 VisibleDeclsRecord &Visited,
3695 bool LoadExternal) {
3701 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3703 FindLocalExternScope FindLocals(Result);
3707 for (
Decl *D : ScopeDecls) {
3708 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3710 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3728 if (Method->isInstanceMethod()) {
3734 false, Consumer, Visited,
3735 false, LoadExternal);
3749 false, Consumer, Visited,
3750 false, LoadExternal);
3764 false, Consumer, Visited,
3765 false, LoadExternal);
3771 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3774 false, Consumer, Visited,
3775 false, LoadExternal);
3779 ShadowContextRAII Shadow(Visited);
3786 bool IncludeGlobalScope,
bool LoadExternal) {
3790 UnqualUsingDirectiveSet UDirs(*
this);
3796 UDirs.visitScopeChain(Initial, S);
3803 VisibleDeclsRecord Visited;
3804 if (!IncludeGlobalScope)
3806 ShadowContextRAII Shadow(Visited);
3812 bool IncludeGlobalScope,
3813 bool IncludeDependentBases,
bool LoadExternal) {
3816 VisibleDeclsRecord Visited;
3817 if (!IncludeGlobalScope)
3819 ShadowContextRAII Shadow(Visited);
3821 false, Consumer, Visited,
3822 IncludeDependentBases, LoadExternal);
3837 Scope *S = CurScope;
3838 PushOnScopeChains(Res, S,
true);
3839 return cast<LabelDecl>(Res);
3843 Res = LookupSingleName(CurScope, II, Loc, LookupLabel, NotForRedeclaration);
3846 if (Res && Res->getDeclContext() != CurContext)
3852 assert(S &&
"Not in a function?");
3853 PushOnScopeChains(Res, S,
true);
3855 return cast<LabelDecl>(Res);
3873 bool EnteringContext,
3874 bool isObjCIvarLookup,
3883 for (; DI != DE; ++DI)
3893 bool AnyVisibleDecls = !NewDecls.empty();
3895 for (; DI != DE; ++DI) {
3897 if (!AnyVisibleDecls) {
3899 AnyVisibleDecls =
true;
3902 NewDecls.push_back(*DI);
3903 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3904 NewDecls.push_back(*DI);
3907 if (NewDecls.empty())
3924 Identifiers.clear();
3954 Identifiers.push_back(II);
3981 addName(Name,
nullptr);
3987 addName(Keyword,
nullptr,
nullptr,
true);
3990 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3994 StringRef TypoStr = Typo->getName();
3995 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
3996 if (MinED && TypoStr.size() / MinED < 3)
4001 unsigned UpperBound = (TypoStr.size() + 2) / 3 + 1;
4002 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
4003 if (ED >= UpperBound)
return;
4007 TC.setCorrectionRange(
nullptr, Result.getLookupNameInfo());
4014 StringRef TypoStr = Typo->getName();
4020 if (TypoStr.size() < 3 &&
4021 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4034 if (!CList.empty() && !CList.back().isResolved())
4038 for (TypoResultList::iterator RI = CList.begin(), RIEnd = CList.end();
4039 RI != RIEnd; ++RI) {
4044 if (RI->getCorrectionDecl() == NewND) {
4051 if (CList.empty() || Correction.
isResolved())
4052 CList.push_back(Correction);
4055 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4059 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4060 SearchNamespaces =
true;
4062 for (
auto KNPair : KnownNamespaces)
4063 Namespaces.addNameSpecifier(KNPair.first);
4065 bool SSIsTemplate =
false;
4069 SSIsTemplate = T->
getTypeClass() == Type::TemplateSpecialization;
4075 for (
unsigned I = 0; I != Types.size(); ++I) {
4076 const auto *TI = Types[I];
4078 CD = CD->getCanonicalDecl();
4079 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4080 !CD->isUnion() && CD->getIdentifier() &&
4081 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4082 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4083 Namespaces.addNameSpecifier(CD);
4089 if (++CurrentTCIndex < ValidatedCorrections.size())
4090 return ValidatedCorrections[CurrentTCIndex];
4092 CurrentTCIndex = ValidatedCorrections.size();
4093 while (!CorrectionResults.empty()) {
4094 auto DI = CorrectionResults.
begin();
4095 if (DI->second.empty()) {
4096 CorrectionResults.erase(DI);
4100 auto RI = DI->second.begin();
4101 if (RI->second.empty()) {
4102 DI->second.erase(RI);
4103 performQualifiedLookups();
4109 ValidatedCorrections.push_back(TC);
4110 return ValidatedCorrections[CurrentTCIndex];
4113 return ValidatedCorrections[0];
4116 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4123 CorrectionValidator->IsObjCIvarLookup,
4125 switch (Result.getResultKind()) {
4135 if (TempMemberContext) {
4138 TempMemberContext =
nullptr;
4141 if (SearchNamespaces)
4142 QualifiedResults.push_back(Candidate);
4152 for (
auto *TRD : Result)
4156 if (SearchNamespaces)
4157 QualifiedResults.push_back(Candidate);
4166 void TypoCorrectionConsumer::performQualifiedLookups() {
4167 unsigned TypoLen = Typo->getName().size();
4169 for (
const auto &NSI : Namespaces) {
4171 const Type *NSType = NSI.NameSpecifier->getAsType();
4179 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4193 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4194 TypoLen / TmpED < 3)
4198 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4204 switch (Result.getResultKind()) {
4209 std::string OldQualified;
4210 llvm::raw_string_ostream OldOStream(OldQualified);
4212 OldOStream << Typo->getName();
4216 if (OldOStream.str() == NewQualified)
4220 TRD != TRDEnd; ++TRD) {
4241 QualifiedResults.clear();
4244 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4246 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4248 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4249 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4257 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4258 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4265 DistanceMap[1].push_back(SI);
4268 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4270 assert(Start &&
"Building a context chain from a null context");
4271 DeclContextList Chain;
4283 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4285 unsigned NumSpecifiers = 0;
4287 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4290 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4292 RD->getTypeForDecl());
4296 return NumSpecifiers;
4299 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4302 unsigned NumSpecifiers = 0;
4303 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4304 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4307 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4308 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C)
4310 NamespaceDeclChain.pop_back();
4314 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4317 if (NamespaceDeclChain.empty()) {
4321 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4323 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4325 bool SameNameSpecifier =
false;
4326 if (std::find(CurNameSpecifierIdentifiers.begin(),
4327 CurNameSpecifierIdentifiers.end(),
4328 Name) != CurNameSpecifierIdentifiers.end()) {
4329 std::string NewNameSpecifier;
4330 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4334 SpecifierOStream.flush();
4335 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4337 if (SameNameSpecifier ||
4338 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4339 Name) != CurContextIdentifiers.end()) {
4343 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4351 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4354 NumSpecifiers = llvm::ComputeEditDistance(
4355 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4356 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4359 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4360 DistanceMap[NumSpecifiers].push_back(SI);
4369 bool EnteringContext,
4370 bool isObjCIvarLookup,
4376 if (MemberContext) {
4378 if (isObjCIvarLookup) {
4379 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4404 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4409 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4421 bool AfterNestedNameSpecifier) {
4422 if (AfterNestedNameSpecifier) {
4435 static const char *
const CTypeSpecs[] = {
4436 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4437 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4438 "_Complex",
"_Imaginary",
4440 "extern",
"inline",
"static",
"typedef" 4443 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4444 for (
unsigned I = 0; I != NumCTypeSpecs; ++I)
4471 static const char *
const CastableTypeSpecs[] = {
4472 "char",
"double",
"float",
"int",
"long",
"short",
4473 "signed",
"unsigned",
"void" 4475 for (
auto *kw : CastableTypeSpecs)
4494 static const char *
const CXXExprs[] = {
4495 "delete",
"new",
"operator",
"throw",
"typeid" 4497 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4498 for (
unsigned I = 0; I != NumCXXExprs; ++I)
4501 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4502 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4521 static const char *
const CStmts[] = {
4522 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4523 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4524 for (
unsigned I = 0; I != NumCStmts; ++I)
4569 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4572 std::unique_ptr<CorrectionCandidateCallback> CCC,
4576 if (Diags.hasFatalErrorOccurred() || !getLangOpts().SpellChecking ||
4577 DisableTypoCorrection)
4584 isa<CXXMethodDecl>(CurContext))
4598 if (!CodeSynthesisContexts.empty())
4606 IdentifierSourceLocations::iterator locs = TypoCorrectionFailures.find(Typo);
4607 if (locs != TypoCorrectionFailures.end() &&
4608 locs->second.count(TypoName.
getLoc()))
4614 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->
isStr(
"vector"))
4620 unsigned Limit = getDiagnostics().getDiagnosticOptions().SpellCheckingLimit;
4621 if (Limit && TyposCorrected >= Limit)
4627 if (ErrorRecovery && getLangOpts().Modules &&
4628 getLangOpts().ModulesSearchAll) {
4630 getModuleLoader().lookupMissingImports(Typo->
getName(),
4635 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4636 *
this, TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4640 bool IsUnqualifiedLookup =
false;
4642 if (MemberContext) {
4647 for (
auto *I : OPT->
quals())
4650 }
else if (SS && SS->isSet()) {
4651 QualifiedDC = computeDeclContext(*SS, EnteringContext);
4657 IsUnqualifiedLookup =
true;
4662 bool SearchNamespaces
4663 = getLangOpts().CPlusPlus &&
4664 (IsUnqualifiedLookup || (SS && SS->isSet()));
4666 if (IsUnqualifiedLookup || SearchNamespaces) {
4670 for (
const auto &I : Context.
Idents)
4671 Consumer->FoundName(I.getKey());
4677 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4679 StringRef Name = Iter->Next();
4683 Consumer->FoundName(Name);
4692 if (SearchNamespaces) {
4694 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4696 LoadedExternalKnownNamespaces =
true;
4697 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces);
4698 for (
auto *N : ExternalKnownNamespaces)
4699 KnownNamespaces[N] =
true;
4702 Consumer->addNamespaces(KnownNamespaces);
4742 std::unique_ptr<CorrectionCandidateCallback> CCC,
4745 bool EnteringContext,
4747 bool RecordFailure) {
4748 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4752 if (ExternalSource) {
4754 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4762 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4765 auto Consumer = makeTypoCorrectionConsumer(
4766 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4767 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4773 if (Consumer->empty())
4774 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4778 unsigned ED = Consumer->getBestEditDistance(
true);
4779 unsigned TypoLen = Typo->
getName().size();
4780 if (ED > 0 && TypoLen / ED < 3)
4781 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4786 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4790 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4794 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4798 if (!SecondBestTC ||
4799 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4805 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4811 }
else if (SecondBestTC && ObjCMessageReceiver) {
4815 if (BestTC.getCorrection().getAsString() !=
"super") {
4817 BestTC = SecondBestTC;
4818 else if ((*Consumer)[
"super"].front().isKeyword())
4819 BestTC = (*Consumer)[
"super"].front();
4823 if (BestTC.getEditDistance() == 0 ||
4824 BestTC.getCorrection().getAsString() !=
"super")
4825 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4834 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4878 std::unique_ptr<CorrectionCandidateCallback> CCC,
4882 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4884 auto Consumer = makeTypoCorrectionConsumer(
4885 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4886 EnteringContext, OPT, Mode == CTK_ErrorRecovery);
4890 if (ExternalSource && Consumer) {
4891 ExternalTypo = ExternalSource->CorrectTypo(
4892 TypoName, LookupKind, S, SS, *Consumer->getCorrectionValidator(),
4893 MemberContext, EnteringContext, OPT);
4895 Consumer->addCorrection(ExternalTypo);
4898 if (!Consumer || Consumer->empty())
4903 unsigned ED = Consumer->getBestEditDistance(
true);
4905 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
4908 ExprEvalContexts.back().NumTypos++;
4909 return createDelayedTypo(std::move(Consumer), std::move(TDG), std::move(TRC));
4916 CorrectionDecls.clear();
4918 CorrectionDecls.push_back(CDecl);
4920 if (!CorrectionName)
4925 if (CorrectionNameSpec) {
4926 std::string tmpBuffer;
4927 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4929 PrefixOStream << CorrectionName;
4930 return PrefixOStream.str();
4933 return CorrectionName.getAsString();
4942 return WantTypeSpecifiers || WantExpressionKeywords || WantCXXNamedCasts ||
4943 WantRemainingKeywords || WantObjCSuper;
4945 bool HasNonType =
false;
4946 bool HasStaticMethod =
false;
4947 bool HasNonStaticMethod =
false;
4948 for (
Decl *D : candidate) {
4950 D = FTD->getTemplatedDecl();
4952 if (Method->isStatic())
4953 HasStaticMethod =
true;
4955 HasNonStaticMethod =
true;
4957 if (!isa<TypeDecl>(D))
4961 if (IsAddressOfOperand && HasNonStaticMethod && !HasStaticMethod &&
4962 !candidate.getCorrectionSpecifier())
4965 return WantTypeSpecifiers || HasNonType;
4969 bool HasExplicitTemplateArgs,
4971 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4972 CurContext(SemaRef.CurContext), MemberFn(ME) {
4982 for (
auto *
C : candidate) {
4986 FD = FTD->getTemplatedDecl();
4987 if (!HasExplicitTemplateArgs && !FD) {
4988 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4992 QualType ValType = cast<ValueDecl>(ND)->getType();
4998 if (FPT->getNumParams() == NumArgs)
5014 if (MemberFn || !MD->isStatic()) {
5017 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
5018 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
5033 bool ErrorRecovery) {
5034 diagnoseTypo(Correction, TypoDiag, PDiag(diag::note_previous_decl),
5041 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
5042 return VD->getDefinition();
5044 return FD->getDefinition();
5045 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
5046 return TD->getDefinition();
5048 return ID->getDefinition();
5050 return PD->getDefinition();
5064 Module *Owner = getOwningModule(Decl);
5065 assert(Owner &&
"definition of hidden declaration is not in a module");
5068 OwningModules.push_back(Owner);
5070 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5072 diagnoseMissingImport(Loc, Decl, Decl->
getLocation(), OwningModules, MIK,
5083 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
5090 assert(!Modules.empty());
5094 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5095 for (
auto *M : Modules)
5096 if (UniqueModuleSet.insert(M).second)
5097 UniqueModules.push_back(M);
5098 Modules = UniqueModules;
5100 if (Modules.size() > 1) {
5101 std::string ModuleList;
5103 for (
Module *M : Modules) {
5104 ModuleList +=
"\n ";
5105 if (++N == 5 && N != Modules.size()) {
5106 ModuleList +=
"[...]";
5109 ModuleList += M->getFullModuleName();
5112 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5113 << (int)MIK << Decl << ModuleList;
5114 }
else if (
const FileEntry *E = PP.getModuleHeaderToIncludeForDiagnostics(
5115 UseLoc, Modules[0], DeclLoc)) {
5121 Diag(UseLoc, diag::err_module_unimported_use_header)
5122 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5126 Diag(UseLoc, diag::err_module_unimported_use)
5127 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5132 case MissingImportKind::Declaration:
5133 DiagID = diag::note_previous_declaration;
5135 case MissingImportKind::Definition:
5136 DiagID = diag::note_previous_definition;
5138 case MissingImportKind::DefaultArgument:
5139 DiagID = diag::note_default_argument_declared_here;
5141 case MissingImportKind::ExplicitSpecialization:
5142 DiagID = diag::note_explicit_specialization_declared_here;
5144 case MissingImportKind::PartialSpecialization:
5145 DiagID = diag::note_partial_specialization_declared_here;
5148 Diag(DeclLoc, DiagID);
5152 createImplicitModuleImportForErrorRecovery(UseLoc, Modules[0]);
5170 bool ErrorRecovery) {
5171 std::string CorrectedStr = Correction.
getAsString(getLangOpts());
5172 std::string CorrectedQuotedStr = Correction.
getQuoted(getLangOpts());
5179 assert(Decl &&
"import required but no declaration to import");
5182 MissingImportKind::Declaration, ErrorRecovery);
5187 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5192 Diag(ChosenDecl->getLocation(), PrevNote)
5193 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5200 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5203 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5205 auto &
State = DelayedTypos[TE];
5206 State.Consumer = std::move(TCC);
5207 State.DiagHandler = std::move(TDG);
5208 State.RecoveryHandler = std::move(TRC);
5213 auto Entry = DelayedTypos.find(TE);
5214 assert(Entry != DelayedTypos.end() &&
5215 "Failed to get the state for a TypoExpr!");
5216 return Entry->second;
5220 DelayedTypos.erase(TE);
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Defines the clang::ASTContext interface.
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
Represents a function declaration or definition.
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Name lookup found a set of overloaded functions that met the criteria.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
SourceRange getCorrectionRange() const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
void setOrigin(CXXRecordDecl *Rec)
CXXMethodDecl * getMethod() const
no exception specification
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules)
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases, bool LoadExternal)
Template argument deduction was successful.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
AmbiguityKind getAmbiguityKind() const
Look up the name of an Objective-C protocol.
Filter makeFilter()
Create a filter for this result set.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
void erase()
Erase the last element returned from this iterator.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Decl - This represents one declaration (or definition), e.g.
__DEVICE__ long long abs(long long __n)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
Defines the C++ template declaration subclasses.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
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.
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
Return true if this decl has its body fully specified.
lookups_range noload_lookups(bool PreserveInternalState) const
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
An identifier, stored as an IdentifierInfo*.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
std::list< CXXBasePath >::iterator paths_iterator
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
static bool LookupBuiltin(Sema &S, LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
Represents a variable declaration or definition.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
DeclarationName getLookupName() const
Gets the name to look up.
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 for diagnostics.
static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last)
Determine whether the given set of member declarations contains only static members, nested types, and enumerators.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare reduction member wi...
A namespace, stored as a NamespaceDecl*.
unsigned getDiagID() const
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
Look up an ordinary name that is going to be redeclared as a name with linkage.
Defines the clang::Expr interface and subclasses for C++ expressions.
void addKeywordResult(StringRef Keyword)
bool WantExpressionKeywords
void setMethod(CXXMethodDecl *MD)
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Types, declared with 'struct foo', typedefs, etc.
Represents a struct/union/class.
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
std::string getQuoted(const LangOptions &LO) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
The results of name lookup within a DeclContext.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
This declaration is a friend function.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
conversion_iterator conversion_end() const
bool isReferenceType() const
The iterator over UnresolvedSets.
void addCorrectionDecl(NamedDecl *CDecl)
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the Decla...
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
LookupResultKind getResultKind() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
Describes a module or submodule.
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.
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
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
Sema - This implements semantic analysis and AST building for C.
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
This declaration is a C++ operator declared in a non-class context.
virtual void EnteredContext(DeclContext *Ctx)
Callback to inform the client that Sema entered into a new context to find a visible declaration...
bool hasMergedDefinitionInCurrentModule(NamedDecl *Def)
The return type of classify().
DeclarationNameTable DeclarationNames
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...
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.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D, unsigned IDNS)
Retrieve the visible declaration corresponding to D, if any.
Defines the clang::Preprocessor interface.
void setRequiresImport(bool Req)
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
bool isFileContext() const
DeclContext * getDeclContext()
static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name that can...
CXXRecordDecl * getDefinition() const
Overload resolution succeeded.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Represents a C++ template name within the type system.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
IdentifierInfo * getAsIdentifierInfo() const
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.
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...
SmallVectorImpl< OverloadCandidate >::iterator iterator
Tag name lookup, which finds the names of enums, classes, structs, and unions.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
param_type_range param_types() const
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
void addVolatile()
Add the volatile type qualifier to this QualType.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
Members, declared with object declarations within tag definitions.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr *> Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
void FoundName(StringRef Name)
Represents the declaration of a label.
Cached information about one file (either on disk or in the virtual file system). ...
bool hasVisibleMergedDefinition(NamedDecl *Def)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module *> *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
Represents a static or instance method of a struct/union/class.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Name lookup found an unresolvable value declaration and cannot yet complete.
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...
static const unsigned MaxTypoDistanceResultSets
A pointer to member type per C++ 8.3.3 - Pointers to members.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
A type that was preceded by the 'template' keyword, stored as a Type*.
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
Name lookup found a single declaration that met the criteria.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
BuiltinTemplateDecl * getTypePackElementDecl() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
QualType getCanonicalTypeInternal() const
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, SourceLocation Loc, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
The template argument is a type.
static bool FindTagMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a tag with the given name...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
Represents a base class of a C++ class.
This is a scope that can contain a declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
llvm::iterator_range< decls_iterator > decls() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isSet() const
Deprecated.
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
ArgKind getKind() const
Return the kind of stored template argument.
static bool isNamespaceOrTranslationUnitScope(Scope *S)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
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.
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...
__DEVICE__ int min(int __a, int __b)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
No viable function found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static std::pair< DeclContext *, bool > findOuterContext(Scope *S)
An l-value expression is a reference to an object with independent storage.
bool empty() const
Return true if no decls were found.
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...
This represents a decl that may have a name.
bool isTranslationUnit() const
Represents C++ using-directive.
SourceLocation getNameLoc() const
Gets the location of the identifier.
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
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.