40#include "llvm/ADT/STLExtras.h"
41#include "llvm/ADT/STLForwardCompat.h"
42#include "llvm/ADT/SmallPtrSet.h"
43#include "llvm/ADT/TinyPtrVector.h"
44#include "llvm/ADT/edit_distance.h"
45#include "llvm/Support/Casting.h"
46#include "llvm/Support/ErrorHandling.h"
55#include "OpenCLBuiltins.inc"
61 class UnqualUsingEntry {
62 const DeclContext *Nominated;
63 const DeclContext *CommonAncestor;
66 UnqualUsingEntry(
const DeclContext *Nominated,
67 const DeclContext *CommonAncestor)
68 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
71 const DeclContext *getCommonAncestor()
const {
72 return CommonAncestor;
75 const DeclContext *getNominatedNamespace()
const {
81 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
82 return L.getCommonAncestor() <
R.getCommonAncestor();
85 bool operator()(
const UnqualUsingEntry &E,
const DeclContext *DC) {
86 return E.getCommonAncestor() < DC;
89 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
90 return DC < E.getCommonAncestor();
97 class UnqualUsingDirectiveSet {
100 typedef SmallVector<UnqualUsingEntry, 8> ListTy;
103 llvm::SmallPtrSet<DeclContext*, 8> visited;
106 UnqualUsingDirectiveSet(Sema &SemaRef) : SemaRef(SemaRef) {}
108 void visitScopeChain(Scope *S, Scope *InnermostFileScope) {
113 DeclContext *InnermostFileDC = InnermostFileScope->
getEntity();
125 if (SemaRef.isVisible(I))
126 visit(I, InnermostFileDC);
138 void visit(DeclContext *DC, DeclContext *EffectiveDC) {
139 if (!visited.insert(DC).second)
142 addUsingDirectives(DC, EffectiveDC);
148 void visit(UsingDirectiveDecl *UD, DeclContext *EffectiveDC) {
150 if (!visited.insert(NS).second)
153 addUsingDirective(UD, EffectiveDC);
154 addUsingDirectives(NS, EffectiveDC);
160 void addUsingDirectives(DeclContext *DC, DeclContext *EffectiveDC) {
161 SmallVector<DeclContext*, 4> queue;
165 if (SemaRef.isVisible(UD) && visited.insert(NS).second) {
166 addUsingDirective(UD, EffectiveDC);
174 DC = queue.pop_back_val();
185 void addUsingDirective(UsingDirectiveDecl *UD, DeclContext *EffectiveDC) {
189 while (!Common->
Encloses(EffectiveDC))
196 void done() { llvm::stable_sort(list, UnqualUsingEntry::Comparator()); }
198 typedef ListTy::const_iterator const_iterator;
200 const_iterator begin()
const {
return list.begin(); }
201 const_iterator end()
const {
return list.end(); }
203 llvm::iterator_range<const_iterator>
204 getNamespacesFor(
const DeclContext *DC)
const {
205 return llvm::make_range(std::equal_range(begin(), end(),
207 UnqualUsingEntry::Comparator()));
237 assert(!
Redeclaration &&
"cannot do redeclaration operator lookup");
276 assert(
Redeclaration &&
"should only be used for redecl lookup");
303void LookupResult::configure() {
310 switch (NameInfo.getName().getCXXOverloadedOperator()) {
314 case OO_Array_Delete:
324 if (IdentifierInfo *Id = NameInfo.getName().getAsIdentifierInfo()) {
325 if (
unsigned BuiltinID = Id->getBuiltinID()) {
332bool LookupResult::checkDebugAssumptions()
const {
337 (Decls.size() == 1 &&
342 (Decls.size() == 1 &&
345 assert((Paths !=
nullptr) ==
394 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
399 return HaveTag != WantTag;
406 if (
const auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
408 unsigned DMin = DFD->getMinRequiredArguments();
409 unsigned EMin = EFD->getMinRequiredArguments();
418 if (
const auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
420 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
421 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
430 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
433 ETD->getTemplateParameters()->getParam(I)) &&
435 DTD->getTemplateParameters()->getParam(I)))
442 if (
const auto *DVD = dyn_cast<VarDecl>(DUnderlying)) {
444 if (EVD->getType()->isIncompleteType() &&
445 !DVD->getType()->isIncompleteType()) {
462 if (Prev == EUnderlying)
489 unsigned N = Decls.size();
513 llvm::SmallDenseMap<const NamedDecl *, unsigned, 16> Unique;
514 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
517 bool ReferenceToPlaceHolderVariable =
false;
518 bool HasTag =
false, HasFunction =
false;
519 bool HasFunctionTemplate =
false, HasUnresolved =
false;
520 const NamedDecl *HasNonFunction =
nullptr;
523 llvm::BitVector RemovedDecls(N);
525 for (
unsigned I = 0; I < N; I++) {
532 N - RemovedDecls.count() > 1) {
546 for (
auto *OtherDecl : Decls) {
547 if (
canHideTag(OtherDecl) && !OtherDecl->isInvalidDecl() &&
559 std::optional<unsigned> ExistingI;
565 if (
const auto *TD = dyn_cast<TypeDecl>(D)) {
566 auto UniqueResult = UniqueTypes.insert(
567 std::make_pair(
getSema().Context.getCanonicalTypeDeclType(TD), I));
568 if (!UniqueResult.second) {
570 ExistingI = UniqueResult.first->second;
577 auto UniqueResult = Unique.insert(std::make_pair(D, I));
578 if (!UniqueResult.second) {
580 ExistingI = UniqueResult.first->second;
589 Decls[*ExistingI] = Decls[I];
597 HasUnresolved =
true;
604 HasFunctionTemplate =
true;
608 if (HasNonFunction) {
613 if (
getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
615 EquivalentNonFunctions.push_back(D);
622 ReferenceToPlaceHolderVariable =
true;
632 if (!EquivalentNonFunctions.empty() && !
Ambiguous)
634 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
639 for (
int I = RemovedDecls.find_last(); I >= 0; I = RemovedDecls.find_prev(I))
640 Decls[I] = Decls[--N];
643 if ((HasNonFunction && (HasFunction || HasUnresolved)) ||
644 (HideTags && HasTag && (HasFunction || HasNonFunction || HasUnresolved)))
647 if (
Ambiguous && ReferenceToPlaceHolderVariable)
651 else if (HasUnresolved)
653 else if (N > 1 || HasFunctionTemplate)
659void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &P) {
661 for (I = P.
begin(), E = P.
end(); I != E; ++I)
670 addDeclsFromBasePaths(*Paths);
678 addDeclsFromBasePaths(*Paths);
684 Out << Decls.size() <<
" result(s)";
686 if (Paths) Out <<
", base paths present";
703 llvm::StringRef Name) {
705 << TypeClass << Name;
748 Sema &S,
const OpenCLBuiltinStruct &OpenCLBuiltin,
unsigned &GenTypeMaxCnt,
752 unsigned Sig = SignatureTable[OpenCLBuiltin.SigTableIndex];
753 OCL2Qual(S, TypeTable[Sig], RetTypes);
754 GenTypeMaxCnt = RetTypes.size();
758 for (
unsigned Index = 1; Index < OpenCLBuiltin.NumTypes; Index++) {
760 OCL2Qual(S, TypeTable[SignatureTable[OpenCLBuiltin.SigTableIndex + Index]],
762 GenTypeMaxCnt = (Ty.size() > GenTypeMaxCnt) ? Ty.size() : GenTypeMaxCnt;
763 ArgTypes.push_back(std::move(Ty));
781 Context.getTargetInfo().getDefaultCallingConv());
786 if (RetTypes.size() == 0)
790 for (
unsigned IGenType = 0; IGenType < GenTypeMaxCnt; IGenType++) {
793 for (
unsigned A = 0; A < ArgTypes.size(); A++) {
795 if (ArgTypes[A].size() == 0)
801 assert(GenTypeMaxCnt % ArgTypes[A].size() == 0 &&
802 "argument type count not compatible with gentype type count");
803 unsigned Idx = IGenType % ArgTypes[A].size();
804 ArgList.push_back(ArgTypes[A][Idx]);
807 FunctionList.push_back(Context.getFunctionType(
808 RetTypes[(RetTypes.size() != 1) ? IGenType : 0], ArgList, PI));
823 const unsigned FctIndex,
824 const unsigned Len) {
826 bool HasGenType =
false;
830 unsigned GenTypeMaxCnt;
834 for (
unsigned SignatureIndex = 0; SignatureIndex < Len; SignatureIndex++) {
835 const OpenCLBuiltinStruct &OpenCLBuiltin =
836 BuiltinTable[FctIndex + SignatureIndex];
840 if (!isOpenCLVersionContainedInMask(Context.getLangOpts(),
841 OpenCLBuiltin.Versions))
847 StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension];
848 if (!Extensions.empty()) {
850 Extensions.split(ExtVec,
" ");
851 bool AllExtensionsDefined =
true;
852 for (StringRef Ext : ExtVec) {
854 AllExtensionsDefined =
false;
858 if (!AllExtensionsDefined)
868 if (GenTypeMaxCnt > 1) {
873 std::vector<QualType> FunctionList;
878 DeclContext *Parent = Context.getTranslationUnitDecl();
881 for (
const auto &FTy : FunctionList) {
883 Context, Parent, Loc, Loc, II, FTy,
nullptr,
SC_Extern,
885 FTy->isFunctionProtoType());
892 for (
unsigned IParm = 0, e = FP->getNumParams(); IParm != e; ++IParm) {
895 nullptr, FP->getParamType(IParm),
nullptr,
SC_None,
nullptr);
897 ParmList.push_back(Parm);
899 NewOpenCLBuiltin->setParams(ParmList);
902 if (OpenCLBuiltin.IsPure)
903 NewOpenCLBuiltin->
addAttr(PureAttr::CreateImplicit(Context));
904 if (OpenCLBuiltin.IsConst)
905 NewOpenCLBuiltin->
addAttr(ConstAttr::CreateImplicit(Context));
906 if (OpenCLBuiltin.IsConv)
907 NewOpenCLBuiltin->
addAttr(ConvergentAttr::CreateImplicit(Context));
910 NewOpenCLBuiltin->
addAttr(OverloadableAttr::CreateImplicit(Context));
917 if (Len > 1 || HasGenType)
933#define BuiltinTemplate(BIName)
934#define CPlusPlusBuiltinTemplate(BIName) \
935 if (II == getASTContext().get##BIName##Name()) { \
936 R.addDecl(getASTContext().get##BIName##Decl()); \
939#include "clang/Basic/BuiltinTemplates.inc"
942#define BuiltinTemplate(BIName)
943#define HLSLBuiltinTemplate(BIName) \
944 if (II == getASTContext().get##BIName##Name()) { \
945 R.addDecl(getASTContext().get##BIName##Decl()); \
948#include "clang/Basic/BuiltinTemplates.inc"
954 auto Index = isOpenCLBuiltin(II->
getName());
962 if (
RISCV().DeclareRVVBuiltins ||
RISCV().DeclareSiFiveVectorBuiltins ||
963 RISCV().DeclareAndesVectorBuiltins) {
964 if (!
RISCV().IntrinsicManager)
969 if (
RISCV().IntrinsicManager->CreateIntrinsicIfFound(R, II,
PP))
978 Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
983 R.isForRedeclaration(), R.getNameLoc())) {
1004 Context.setObjCSuperType(Context.getCanonicalTagType(TD));
1008 if (ID == Builtin::BIobjc_msgSendSuper)
1016 if (!Class->getDefinition() || Class->isDependentContext())
1020 return !Class->isBeingDefined();
1028 if (
Class->needsImplicitDefaultConstructor())
1032 if (
Class->needsImplicitCopyConstructor())
1036 if (
Class->needsImplicitCopyAssignment())
1041 if (
Class->needsImplicitMoveConstructor())
1045 if (
Class->needsImplicitMoveAssignment())
1050 if (
Class->needsImplicitDestructor())
1086 if (
Record->needsImplicitDefaultConstructor())
1088 if (
Record->needsImplicitCopyConstructor())
1091 Record->needsImplicitMoveConstructor())
1098 if (
Record->getDefinition() &&
Record->needsImplicitDestructor() &&
1110 if (
Record->needsImplicitCopyAssignment())
1113 Record->needsImplicitMoveAssignment())
1141 if ((D = R.getAcceptableDecl(D))) {
1150 if (R.getLookupName().getNameKind()
1152 R.getLookupName().getCXXNameType()->isDependentType() ||
1161 if (!
Record->isCompleteDefinition() && !R.isForRedeclaration())
1167 auto *ContainedDeducedType =
1168 R.getLookupName().getCXXNameType()->getContainedDeducedType();
1169 if (R.getLookupName().getNameKind() ==
1171 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
1175 UEnd =
Record->conversion_end();
U != UEnd; ++
U) {
1184 if (R.isForRedeclaration()) {
1185 R.addDecl(ConvTemplate);
1205 assert(ConvProto &&
"Nonsensical conversion function template type");
1214 R.getLookupName().getCXXNameType(), {}, EPI);
1218 if (R.getSema().DeduceTemplateArguments(ConvTemplate,
nullptr,
ExpectedType,
1232 UnqualUsingDirectiveSet &UDirs) {
1234 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
1241 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
1269struct FindLocalExternScope {
1270 FindLocalExternScope(LookupResult &R)
1271 :
R(
R), OldFindLocalExtern(
R.getIdentifierNamespace() &
1272 Decl::IDNS_LocalExtern) {
1273 R.setFindLocalExtern(
R.getIdentifierNamespace() &
1277 R.setFindLocalExtern(OldFindLocalExtern);
1279 ~FindLocalExternScope() {
1283 bool OldFindLocalExtern;
1290 DeclarationName Name =
R.getLookupName();
1296 for (Scope *PreS = S; PreS; PreS = PreS->getParent())
1297 if (DeclContext *DC = PreS->getEntity())
1309 R.setNotFoundInCurrentInstantiation();
1317 IdentifierResolver::iterator
1339 UnqualUsingDirectiveSet UDirs(*
this);
1340 bool VisitedUsingDirectives =
false;
1341 bool LeftStartingScope =
false;
1344 FindLocalExternScope FindLocals(R);
1347 bool SearchNamespaceScope =
true;
1350 if (NamedDecl *ND =
R.getAcceptableDecl(*I)) {
1352 !(*I)->isTemplateParameter()) {
1358 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1359 LeftStartingScope =
true;
1363 if (LeftStartingScope && !((*I)->hasLinkage())) {
1370 SearchNamespaceScope =
false;
1375 if (!SearchNamespaceScope) {
1378 if (
auto *
Record = dyn_cast_if_present<CXXRecordDecl>(S->
getEntity()))
1407 if (ObjCMethodDecl *
Method = dyn_cast<ObjCMethodDecl>(Ctx)) {
1409 if (ObjCInterfaceDecl *
Class =
Method->getClassInterface()) {
1410 ObjCInterfaceDecl *ClassDeclared;
1411 if (ObjCIvarDecl *Ivar =
Class->lookupInstanceVariable(
1414 if (NamedDecl *ND =
R.getAcceptableDecl(Ivar)) {
1430 if (!VisitedUsingDirectives) {
1432 for (DeclContext *UCtx = Ctx; UCtx; UCtx = UCtx->getParent()) {
1433 if (UCtx->isTransparentContext())
1436 UDirs.visit(UCtx, UCtx);
1441 Scope *InnermostFileScope = S;
1442 while (InnermostFileScope &&
1444 InnermostFileScope = InnermostFileScope->
getParent();
1445 UDirs.visitScopeChain(Initial, InnermostFileScope);
1449 VisitedUsingDirectives =
true;
1474 if (!S)
return false;
1485 if (!VisitedUsingDirectives) {
1486 UDirs.visitScopeChain(Initial, S);
1492 if (!
R.isForRedeclaration())
1493 FindLocals.restore();
1503 if (NamedDecl *ND =
R.getAcceptableDecl(*I)) {
1533 "We should have been looking only at file context here already.");
1559 Context.mergeDefinitionIntoModule(ND, M);
1566 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1567 for (
auto *Param : *TD->getTemplateParameters())
1575 if (
auto *ED = dyn_cast<EnumDecl>(ND);
1576 ED && ED->isFromGlobalModule() && !ED->isScoped()) {
1577 for (
auto *ECD : ED->enumerators()) {
1578 ECD->setVisiblePromoted();
1580 if (RedeclCtx->
lookup(ECD->getDeclName()).
empty())
1588 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1592 Entity = Pattern->getDefinition();
1593 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1595 Entity = Pattern->getDefinition();
1596 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1597 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1598 Entity = Pattern->getDefinition();
1599 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1601 Entity = Pattern->getDefinition();
1609 if (Context->isFileContext())
1628bool Sema::isUsableModule(
const Module *M) {
1629 assert(M &&
"We shouldn't check nullness for module here");
1631 if (UsableModuleUnitsCache.count(M))
1639 if (M == TheGlobalModuleFragment || M == TheImplicitGlobalModuleFragment) {
1640 UsableModuleUnitsCache.insert(M);
1669 if (llvm::count_if(ModuleScopes,
1670 [&M](
const ModuleScope &MS) {
return MS.Module == M; }) ||
1672 UsableModuleUnitsCache.insert(M);
1680 for (
const Module *Merged :
Context.getModulesWithMergedDefinition(Def))
1687 for (
const Module *Merged :
Context.getModulesWithMergedDefinition(Def))
1688 if (isUsableModule(Merged))
1693template <
typename ParmDecl>
1698 if (!D->hasDefaultArgument())
1702 while (D && Visited.insert(D).second) {
1703 auto &DefaultArg = D->getDefaultArgStorage();
1704 if (!DefaultArg.isInherited() && S.
isAcceptable(D, Kind))
1707 if (!DefaultArg.isInherited() && Modules) {
1708 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1714 D = DefaultArg.getInheritedFrom();
1722 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1723 return ::hasAcceptableDefaultArgument(*
this, P, Modules, Kind);
1725 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1726 return ::hasAcceptableDefaultArgument(*
this, P, Modules, Kind);
1728 return ::hasAcceptableDefaultArgument(
1744template <
typename Filter>
1749 bool HasFilteredRedecls =
false;
1751 for (
auto *Redecl : D->
redecls()) {
1759 HasFilteredRedecls =
true;
1762 Modules->push_back(R->getOwningModule());
1766 if (HasFilteredRedecls)
1779 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1780 return RD->getTemplateSpecializationKind() ==
1782 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1783 return FD->getTemplateSpecializationKind() ==
1785 if (
auto *VD = dyn_cast<VarDecl>(D))
1786 return VD->getTemplateSpecializationKind() ==
1788 llvm_unreachable(
"unknown explicit specialization kind");
1795 return ::hasAcceptableExplicitSpecialization(*
this, D, Modules,
1801 return ::hasAcceptableExplicitSpecialization(*
this, D, Modules,
1810 "not a member specialization");
1848bool LookupResult::isAcceptableSlow(
Sema &SemaRef,
NamedDecl *D,
1851 "should not call this: not in slow case");
1854 assert(DeclModule &&
"hidden decl has no owning module");
1864 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1872 if (DC && !IsEffectivelyFileContext(DC)) {
1880 bool AcceptableWithinParent;
1882 bool SearchDefinitions =
true;
1883 if (
const auto *DCD = dyn_cast<Decl>(DC)) {
1884 if (
const auto *TD = DCD->getDescribedTemplate()) {
1887 SearchDefinitions = Index >= TPL->
size() || TPL->
getParam(Index) != D;
1890 if (SearchDefinitions)
1891 AcceptableWithinParent =
1894 AcceptableWithinParent =
1902 AcceptableWithinParent =
false;
1905 AcceptableWithinParent =
true;
1909 }
while (!IsEffectivelyFileContext(DC));
1911 AcceptableWithinParent =
1923 return AcceptableWithinParent;
1930 "Additional Sema::AcceptableKind?");
1931 return isReachableSlow(SemaRef, D);
1937 if (ModulePrivate && isUsableModule(M))
1942 if (!ModulePrivate && VisibleModules.isVisible(M))
1950 if (LookupModules.empty())
1954 if (LookupModules.count(M))
1968 return llvm::any_of(LookupModules, [&](
const Module *LookupM) {
1975bool LookupResult::isReachableSlow(
Sema &SemaRef,
NamedDecl *D) {
1976 assert(!
isVisible(SemaRef, D) &&
"Shouldn't call the slow case.\n");
1979 assert(DeclModule &&
"hidden decl has no owning module");
2063 "should not have hidden, non-externally-declarable result here");
2082 return New->isExternallyDeclarable();
2097 for (
auto *RD : D->
redecls()) {
2106 if (ND->isInIdentifierNamespace(IDNS) &&
2116 assert(!
isVisible(D) &&
"not in slow case");
2118 *
this, D, Modules, [](
const NamedDecl *) {
return true; },
2126 *
this, D, Modules, [](
const NamedDecl *) {
return true; },
2131 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
2138 auto *Key = ND->getCanonicalDecl();
2139 if (
auto *Acceptable =
getSema().VisibleNamespaceCache.lookup(Key))
2193 if (
auto *FD = dyn_cast<FunctionDecl>(ND);
2194 FD && FD->isReservedGlobalPlacementOperator())
2211 if (
auto *TD = dyn_cast<TagDecl>(DC))
2218 bool ForceNoCPlusPlus) {
2220 if (!Name)
return false;
2235 FindLocalExternScope FindLocals(R);
2241 bool LeftStartingScope =
false;
2246 if (
NamedDecl *D = R.getAcceptableDecl(*I)) {
2251 LeftStartingScope =
true;
2255 if (LeftStartingScope && !((*I)->hasLinkage())) {
2286 for (++LastI; LastI != IEnd; ++LastI) {
2300 if (
NamedDecl *LastD = R.getAcceptableDecl(*LastI))
2311 if (CppLookupName(R, S))
2357 assert(StartDC->
isFileContext() &&
"start context is not a file context");
2365 Visited.insert(StartDC);
2370 NamespaceDecl *ND = I->getNominatedNamespace()->getFirstDecl();
2371 if (S.
isVisible(I) && Visited.insert(ND).second)
2372 Queue.push_back(ND);
2379 bool FoundTag =
false;
2380 bool FoundNonTag =
false;
2385 while (!Queue.empty()) {
2390 bool UseLocal = !R.empty();
2406 R.addAllDecls(LocalR);
2419 if (S.
isVisible(I) && Visited.insert(Nom).second)
2420 Queue.push_back(Nom);
2425 if (FoundTag && FoundNonTag)
2426 R.setAmbiguousQualifiedTagHiding();
2435 bool InUnqualifiedLookup) {
2436 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2438 if (!R.getLookupName())
2443 if (
const auto *TD = dyn_cast<TagDecl>(LookupCtx);
2444 TD && !TD->isDependentType() && TD->getDefinition() ==
nullptr)
2445 llvm_unreachable(
"Declaration context must already be complete!");
2449 struct QualifiedLookupInScope {
2453 : Source(Source),
Context(Ctx) {
2455 Source->StartedQualifiedLookup(
Context);
2457 ~QualifiedLookupInScope() {
2459 Source->FinishedQualifiedLookup(
Context);
2463 CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2467 if (!InUnqualifiedLookup && !R.isForRedeclaration()) {
2479 R.setNotFoundInCurrentInstantiation();
2487 R.setNamingClass(LookupRec);
2500 if (R.isForRedeclaration())
2526 R.setNotFoundInCurrentInstantiation();
2533 unsigned IDNS = R.getIdentifierNamespace();
2538 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
2541 for (Path.Decls = BaseRecord->
lookup(Name).
begin();
2542 Path.Decls != Path.Decls.
end(); ++Path.Decls) {
2543 if ((*Path.Decls)->isInIdentifierNamespace(IDNS))
2554 R.setNamingClass(LookupRec);
2563 int SubobjectNumber = 0;
2569 if ((*I)->isInIdentifierNamespace(IDNS) && (*I)->isCXXInstanceMember())
2574 bool TemplateNameLookup = R.isTemplateNameLookup();
2581 using Result =
const void *;
2583 auto Next = [&](Iterator &It, Iterator End) ->
Result {
2597 if (TemplateNameLookup)
2605 return Context.getCanonicalTypeDeclType(TD).getAsOpaquePtr();
2614 Iterator AIt = A, BIt = B, AEnd, BEnd;
2618 if (!AResult && !BResult)
2620 if (!AResult || !BResult)
2622 if (AResult != BResult) {
2625 llvm::SmallDenseMap<Result, bool, 32> AResults;
2626 for (; AResult; AResult =
Next(AIt, AEnd))
2627 AResults.insert({AResult, false});
2629 for (; BResult; BResult =
Next(BIt, BEnd)) {
2630 auto It = AResults.find(BResult);
2631 if (It == AResults.end())
2638 return AResults.size() ==
Found;
2644 Path != PathEnd; ++Path) {
2649 SubobjectAccess = std::min(SubobjectAccess, Path->Access);
2652 if (SubobjectType.
isNull()) {
2659 if (SubobjectType !=
2667 if (HasOnlyStaticMembers(Path->Decls) &&
2668 HasSameDeclarations(Paths.
begin()->Decls, Path->Decls))
2671 R.setAmbiguousBaseSubobjectTypes(Paths);
2685 if (HasOnlyStaticMembers(Path->Decls))
2690 R.setAmbiguousBaseSubobjects(Paths);
2701 if (
NamedDecl *ND = R.getAcceptableDecl(*I))
2717 QualType ObjectType,
bool AllowBuiltinCreation,
2718 bool EnteringContext) {
2725 bool IsDependent =
false;
2726 if (!ObjectType.
isNull()) {
2729 assert((!SS || SS->
isEmpty()) &&
2730 "ObjectType and scope specifier cannot coexist");
2735 ObjectType->
castAs<TagType>()->getDecl()->isEntityBeingDefined()) &&
2736 "Caller should have completed object type");
2755 return LookupName(R, S, AllowBuiltinCreation);
2762 else if (IsDependent)
2766 R.setNotFoundInCurrentInstantiation();
2775 for (
const auto &BaseSpec :
Class->bases()) {
2776 auto *RD = BaseSpec.getType()->castAsCXXRecordDecl();
2783 for (
auto I =
Result.begin(), E =
Result.end(); I != E; ++I) {
2784 R.addDecl(I.getDecl(),
2789 Result.suppressDiagnostics();
2793 R.setNamingClass(
Class);
2799 assert(
Result.isAmbiguous() &&
"Lookup result must be ambiguous");
2805 switch (
Result.getAmbiguityKind()) {
2808 QualType SubobjectType = Paths->
front().back().Base->getType();
2809 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2818 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2823 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2824 << Name << LookupRange;
2827 std::set<const NamedDecl *> DeclsPrinted;
2829 PathEnd = Paths->
end();
2830 Path != PathEnd; ++Path) {
2834 if (DeclsPrinted.insert(D).second) {
2837 << TD->getUnderlyingType();
2840 <<
Context.getTypeDeclType(TD);
2849 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2854 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2855 TagDecls.insert(TD);
2856 Diag(TD->getLocation(), diag::note_hidden_tag);
2866 if (TagDecls.count(F.
next()))
2874 Diag(NameLoc, diag::err_using_placeholder_variable) << Name << LookupRange;
2886 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2896 struct AssociatedLookup {
2900 : S(S), Namespaces(Namespaces), Classes(Classes),
2901 InstantiationLoc(InstantiationLoc) {
2906 return ClassesTransitive.insert(RD);
2912 SourceLocation InstantiationLoc;
2993 Namespaces.insert(Ctx);
2995 Namespaces.insert(PrimaryCtx);
3023 = dyn_cast<ClassTemplateDecl>(
Template.getAsTemplateDecl())) {
3024 DeclContext *Ctx = ClassTemplate->getDeclContext();
3025 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3026 Result.Classes.insert(EnclosingClass);
3056 if (Class->getDeclName() ==
Result.S.VAListTagName)
3069 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3070 Result.Classes.insert(EnclosingClass);
3085 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
3086 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
3087 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3088 Result.Classes.insert(EnclosingClass);
3093 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3099 if (!
Result.addClassTransitive(Class))
3104 Result.S.Context.getCanonicalTagType(Class)))
3110 Bases.push_back(Class);
3111 while (!Bases.empty()) {
3113 Class = Bases.pop_back_val();
3116 for (
const auto &
Base : Class->bases()) {
3126 if (
Result.addClassTransitive(BaseDecl)) {
3132 if (!BaseDecl->
bases().empty())
3133 Bases.push_back(BaseDecl);
3159 switch (
T->getTypeClass()) {
3161#define TYPE(Class, Base)
3162#define DEPENDENT_TYPE(Class, Base) case Type::Class:
3163#define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3164#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3165#define ABSTRACT_TYPE(Class, Base)
3166#include "clang/AST/TypeNodes.inc"
3179 case Type::ConstantArray:
3180 case Type::IncompleteArray:
3181 case Type::VariableArray:
3195 case Type::Record: {
3198 ->getDefinitionOrSelf();
3209 auto *
Enum =
T->castAsEnumDecl();
3212 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3213 Result.Classes.insert(EnclosingClass);
3224 case Type::FunctionProto: {
3227 Queue.push_back(Arg.getTypePtr());
3231 case Type::FunctionNoProto: {
3246 case Type::MemberPointer: {
3248 if (
CXXRecordDecl *Class = MemberPtr->getMostRecentCXXRecordDecl())
3250 T = MemberPtr->getPointeeType().getTypePtr();
3255 case Type::BlockPointer:
3261 case Type::LValueReference:
3262 case Type::RValueReference:
3268 case Type::ExtVector:
3269 case Type::ConstantMatrix:
3276 case Type::DeducedTemplateSpecialization:
3282 case Type::ObjCObject:
3283 case Type::ObjCInterface:
3284 case Type::ObjCObjectPointer:
3285 Result.Namespaces.insert(
Result.S.Context.getTranslationUnitDecl());
3298 case Type::ArrayParameter:
3301 case Type::HLSLAttributedResource:
3306 case Type::HLSLInlineSpirv:
3308 case Type::OverflowBehavior:
3314 T = Queue.pop_back_val();
3322 AssociatedNamespaces.clear();
3323 AssociatedClasses.clear();
3325 AssociatedLookup
Result(*
this, InstantiationLoc,
3326 AssociatedNamespaces, AssociatedClasses);
3335 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
3336 Expr *Arg = Args[ArgIdx];
3384 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
3390 bool ConstArg,
bool VolatileArg,
bool RValueThis,
3391 bool ConstThis,
bool VolatileThis) {
3392 unsigned Flags = llvm::to_underlying(SM) << 5;
3393 Flags |= ConstArg << 4;
3394 Flags |= VolatileArg << 3;
3395 Flags |= RValueThis << 2;
3396 Flags |= ConstThis << 1;
3397 Flags |= VolatileThis;
3403 bool ConstArg,
bool VolatileArg,
bool RValueThis,
3404 bool ConstThis,
bool VolatileThis) {
3406 "doing special member lookup into record that isn't fully complete");
3408 if (RValueThis || ConstThis || VolatileThis)
3411 "constructors and destructors always have unqualified lvalue this");
3412 if (ConstArg || VolatileArg)
3415 "parameter-less special members can't have qualified arguments");
3421 RD, SM, ConstArg, VolatileArg, RValueThis, ConstThis, VolatileThis);
3431 DeclareImplicitDestructor(RD);
3446 Expr *Arg =
nullptr;
3453 Name =
Context.DeclarationNames.getCXXConstructorName(CanTy);
3457 DeclareImplicitDefaultConstructor(RD);
3463 Name =
Context.DeclarationNames.getCXXConstructorName(CanTy);
3466 DeclareImplicitCopyConstructor(RD);
3471 DeclareImplicitMoveConstructor(RD);
3475 Name =
Context.DeclarationNames.getCXXOperatorName(OO_Equal);
3478 DeclareImplicitCopyAssignment(RD);
3483 DeclareImplicitMoveAssignment(RD);
3536 "lookup for a constructor or assignment operator was empty");
3537 Result.setMethod(
nullptr);
3546 for (
NamedDecl *CandDecl : Candidates) {
3547 if (CandDecl->isInvalidDecl())
3573 CtorInfo.FoundDecl,
nullptr,
3580 "illegal Kind of operator = Decl");
3597 Result.setMethod(
nullptr);
3602 Result.setMethod(
nullptr);
3613 false,
false,
false,
false,
false);
3615 return cast_or_null<CXXConstructorDecl>(
Result.getMethod());
3621 "non-const, non-volatile qualifiers for copy ctor arg");
3626 return cast_or_null<CXXConstructorDecl>(
Result.getMethod());
3635 return cast_or_null<CXXConstructorDecl>(
Result.getMethod());
3642 if (Class->needsImplicitDefaultConstructor())
3643 DeclareImplicitDefaultConstructor(Class);
3644 if (Class->needsImplicitCopyConstructor())
3645 DeclareImplicitCopyConstructor(Class);
3646 if (getLangOpts().CPlusPlus11 && Class->needsImplicitMoveConstructor())
3647 DeclareImplicitMoveConstructor(Class);
3653 return Class->lookup(Name);
3657 unsigned Quals,
bool RValueThis,
3658 unsigned ThisQuals) {
3660 "non-const, non-volatile qualifiers for copy assignment arg");
3662 "non-const, non-volatile qualifiers for copy assignment this");
3668 return Result.getMethod();
3674 unsigned ThisQuals) {
3676 "non-const, non-volatile qualifiers for copy assignment this");
3682 return Result.getMethod();
3686 return cast_or_null<CXXDestructorDecl>(
3688 false,
false,
false)
3695 bool AllowTemplate,
bool AllowStringTemplatePack,
3699 "literal operator lookup can't be ambiguous");
3704 bool AllowCooked =
true;
3705 bool FoundRaw =
false;
3706 bool FoundTemplate =
false;
3707 bool FoundStringTemplatePack =
false;
3708 bool FoundCooked =
false;
3713 D = USD->getTargetDecl();
3722 bool IsTemplate =
false;
3723 bool IsStringTemplatePack =
false;
3724 bool IsCooked =
false;
3727 if (FD->getNumParams() == 1 &&
3728 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3730 else if (FD->getNumParams() == ArgTys.size()) {
3732 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3733 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3734 if (!
Context.hasSameUnqualifiedType(ArgTys[ArgIdx], ParamTy)) {
3743 if (Params->
size() == 1) {
3761 Params->
getParam(0), Arg, FD, R.getNameLoc(), R.getNameLoc(),
3767 IsStringTemplatePack =
true;
3771 if (AllowTemplate && StringLit && IsTemplate) {
3772 FoundTemplate =
true;
3774 AllowCooked =
false;
3775 AllowStringTemplatePack =
false;
3776 if (FoundRaw || FoundCooked || FoundStringTemplatePack) {
3778 FoundRaw = FoundCooked = FoundStringTemplatePack =
false;
3780 }
else if (AllowCooked && IsCooked) {
3783 AllowTemplate = StringLit;
3784 AllowStringTemplatePack =
false;
3785 if (FoundRaw || FoundTemplate || FoundStringTemplatePack) {
3789 FoundRaw = FoundTemplate = FoundStringTemplatePack =
false;
3791 }
else if (AllowRaw && IsRaw) {
3793 }
else if (AllowTemplate && IsTemplate) {
3794 FoundTemplate =
true;
3795 }
else if (AllowStringTemplatePack && IsStringTemplatePack) {
3796 FoundStringTemplatePack =
true;
3806 if (StringLit && FoundTemplate)
3817 if (FoundRaw && FoundTemplate) {
3818 Diag(R.getNameLoc(), diag::err_ovl_ambiguous_call) << R.getLookupName();
3830 if (FoundStringTemplatePack)
3834 if (DiagnoseMissing) {
3835 Diag(R.getNameLoc(), diag::err_ovl_no_viable_literal_operator)
3836 << R.getLookupName() << (int)ArgTys.size() << ArgTys[0]
3837 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3838 << (AllowTemplate || AllowStringTemplatePack);
3850 if (Old ==
nullptr || Old ==
New) {
3861 Cursor = Cursor->getPreviousDecl();
3865 if (!Cursor)
return;
3868 if (Cursor == OldFD)
break;
3883 AssociatedNamespaces,
3894 if (
Class->hasDefinition() &&
Class->hasLazyFriends())
3895 Class->loadLazyFriends();
3908 for (
auto *
NS : AssociatedNamespaces) {
3928 auto *Underlying = D;
3929 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3930 Underlying = USD->getTargetDecl();
3964 llvm::any_of(AssociatedClasses, [&](
auto *E) {
3968 if (E->getOwningModule() != FM)
3972 DeclContext *Ctx = E->getDeclContext();
3973 while (!Ctx->isFileContext() || Ctx->isInlineNamespace())
3974 Ctx = Ctx->getParent();
3994 if (AssociatedClasses.count(RD) &&
isReachable(D)) {
4003 Result.insert(Underlying);
4017class ShadowContextRAII;
4019class VisibleDeclsRecord {
4024 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
4029 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
4032 std::list<ShadowMap> ShadowMaps;
4037 friend class ShadowContextRAII;
4043 return !VisitedContexts.insert(Ctx).second;
4047 return VisitedContexts.count(Ctx);
4055 NamedDecl *checkHidden(NamedDecl *ND);
4058 void add(NamedDecl *ND) {
4059 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
4064class ShadowContextRAII {
4065 VisibleDeclsRecord &Visible;
4067 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
4070 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
4071 Visible.ShadowMaps.emplace_back();
4074 ~ShadowContextRAII() {
4075 Visible.ShadowMaps.pop_back();
4083 std::list<ShadowMap>::reverse_iterator SM = ShadowMaps.rbegin();
4084 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
4085 SM != SMEnd; ++SM) {
4086 ShadowMap::iterator Pos = SM->find(ND->
getDeclName());
4087 if (Pos == SM->end())
4090 for (
auto *D : Pos->second) {
4108 SM == ShadowMaps.rbegin())
4126class LookupVisibleHelper {
4128 LookupVisibleHelper(VisibleDeclConsumer &Consumer,
bool IncludeDependentBases,
4130 : Consumer(Consumer), IncludeDependentBases(IncludeDependentBases),
4131 LoadExternal(LoadExternal) {}
4134 bool IncludeGlobalScope) {
4138 UnqualUsingDirectiveSet UDirs(SemaRef);
4144 UDirs.visitScopeChain(Initial, S);
4149 LookupResult
Result(SemaRef, DeclarationName(), SourceLocation(), Kind);
4150 Result.setAllowHidden(Consumer.includeHiddenDecls());
4151 if (!IncludeGlobalScope)
4153 ShadowContextRAII Shadow(Visited);
4154 lookupInScope(Initial,
Result, UDirs);
4157 void lookupVisibleDecls(Sema &SemaRef, DeclContext *Ctx,
4159 LookupResult
Result(SemaRef, DeclarationName(), SourceLocation(), Kind);
4160 Result.setAllowHidden(Consumer.includeHiddenDecls());
4161 if (!IncludeGlobalScope)
4164 ShadowContextRAII Shadow(Visited);
4165 lookupInDeclContext(Ctx,
Result,
true,
4170 void lookupInDeclContext(DeclContext *Ctx, LookupResult &
Result,
4171 bool QualifiedNameLookup,
bool InBaseClass) {
4179 Consumer.EnteredContext(Ctx);
4183 !
Result.getSema().getLangOpts().CPlusPlus) {
4184 auto &S =
Result.getSema();
4185 auto &Idents = S.Context.Idents;
4189 if (IdentifierInfoLookup *
External =
4190 Idents.getExternalIdentifierLookup()) {
4191 std::unique_ptr<IdentifierIterator> Iter(
External->getIdentifiers());
4192 for (StringRef Name = Iter->Next(); !Name.empty();
4193 Name = Iter->Next())
4198 for (
const auto &Ident : Idents) {
4199 for (
auto I = S.IdResolver.begin(Ident.getValue()),
4200 E = S.IdResolver.end();
4202 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
4203 if (NamedDecl *ND =
Result.getAcceptableDecl(*I)) {
4204 Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
4214 if (CXXRecordDecl *
Class = dyn_cast<CXXRecordDecl>(Ctx))
4215 Result.getSema().ForceDeclarationOfImplicitMembers(
Class);
4217 llvm::SmallVector<NamedDecl *, 4> DeclsToVisit;
4219 bool Load = LoadExternal ||
4222 for (DeclContextLookupResult R :
4231 DeclsToVisit.push_back(D);
4233 for (
auto *D : DeclsToVisit)
4234 if (
auto *ND =
Result.getAcceptableDecl(D)) {
4235 Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
4239 DeclsToVisit.clear();
4242 if (QualifiedNameLookup) {
4243 ShadowContextRAII Shadow(Visited);
4245 if (!
Result.getSema().isVisible(I))
4247 lookupInDeclContext(I->getNominatedNamespace(),
Result,
4248 QualifiedNameLookup, InBaseClass);
4253 if (CXXRecordDecl *
Record = dyn_cast<CXXRecordDecl>(Ctx)) {
4254 if (!
Record->hasDefinition())
4257 for (
const auto &B :
Record->bases()) {
4258 QualType BaseType = B.getType();
4262 if (!IncludeDependentBases) {
4278 RD = TD->getTemplatedDecl();
4305 ShadowContextRAII Shadow(Visited);
4306 lookupInDeclContext(RD,
Result, QualifiedNameLookup,
4312 if (ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Ctx)) {
4314 for (
auto *Cat : IFace->visible_categories()) {
4315 ShadowContextRAII Shadow(Visited);
4316 lookupInDeclContext(Cat,
Result, QualifiedNameLookup,
4321 for (
auto *I : IFace->all_referenced_protocols()) {
4322 ShadowContextRAII Shadow(Visited);
4323 lookupInDeclContext(I,
Result, QualifiedNameLookup,
4328 if (IFace->getSuperClass()) {
4329 ShadowContextRAII Shadow(Visited);
4330 lookupInDeclContext(IFace->getSuperClass(),
Result, QualifiedNameLookup,
4336 if (IFace->getImplementation()) {
4337 ShadowContextRAII Shadow(Visited);
4338 lookupInDeclContext(IFace->getImplementation(),
Result,
4339 QualifiedNameLookup, InBaseClass);
4341 }
else if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Ctx)) {
4342 for (
auto *I :
Protocol->protocols()) {
4343 ShadowContextRAII Shadow(Visited);
4344 lookupInDeclContext(I,
Result, QualifiedNameLookup,
4347 }
else if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(Ctx)) {
4348 for (
auto *I : Category->protocols()) {
4349 ShadowContextRAII Shadow(Visited);
4350 lookupInDeclContext(I,
Result, QualifiedNameLookup,
4355 if (Category->getImplementation()) {
4356 ShadowContextRAII Shadow(Visited);
4357 lookupInDeclContext(Category->getImplementation(),
Result,
4358 QualifiedNameLookup,
true);
4363 void lookupInScope(Scope *S, LookupResult &
Result,
4364 UnqualUsingDirectiveSet &UDirs) {
4367 assert(!IncludeDependentBases &&
"Unsupported flag for lookupInScope");
4375 FindLocalExternScope FindLocals(
Result);
4378 SmallVector<Decl *, 8> ScopeDecls(S->
decls().begin(), S->
decls().end());
4379 for (Decl *D : ScopeDecls) {
4380 if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
4381 if ((ND =
Result.getAcceptableDecl(ND))) {
4382 Consumer.FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
4395 for (DeclContext *Ctx = Entity; Ctx && !Ctx->
Equals(OuterCtx);
4397 if (ObjCMethodDecl *
Method = dyn_cast<ObjCMethodDecl>(Ctx)) {
4398 if (
Method->isInstanceMethod()) {
4400 LookupResult IvarResult(
Result.getSema(),
Result.getLookupName(),
4403 if (ObjCInterfaceDecl *IFace =
Method->getClassInterface()) {
4404 lookupInDeclContext(IFace, IvarResult,
4419 lookupInDeclContext(Ctx,
Result,
false,
4433 Entity =
Result.getSema().Context.getTranslationUnitDecl();
4434 lookupInDeclContext(Entity,
Result,
false,
4441 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
4442 lookupInDeclContext(
4443 const_cast<DeclContext *
>(UUE.getNominatedNamespace()),
Result,
4449 ShadowContextRAII Shadow(Visited);
4454 VisibleDeclsRecord Visited;
4455 VisibleDeclConsumer &Consumer;
4456 bool IncludeDependentBases;
4463 bool IncludeGlobalScope,
bool LoadExternal) {
4464 LookupVisibleHelper H(
Consumer,
false,
4466 H.lookupVisibleDecls(*
this, S, Kind, IncludeGlobalScope);
4471 bool IncludeGlobalScope,
4472 bool IncludeDependentBases,
bool LoadExternal) {
4473 LookupVisibleHelper H(
Consumer, IncludeDependentBases, LoadExternal);
4474 H.lookupVisibleDecls(*
this, Ctx, Kind, IncludeGlobalScope);
4484 CurContext->getEnclosingNonExpansionStatementContext())
4495 Scope *S = CurScope;
4512 if (IsLabelStmt &&
CurContext->isExpansionStmt()) {
4520 Diag(Loc, diag::err_expansion_stmt_label);
4535 assert(S &&
"Not in a function?");
4555 bool EnteringContext,
4556 bool isObjCIvarLookup,
4565 for (; DI != DE; ++DI)
4575 bool AnyVisibleDecls = !NewDecls.empty();
4577 for (; DI != DE; ++DI) {
4579 if (!AnyVisibleDecls) {
4581 AnyVisibleDecls =
true;
4584 NewDecls.push_back(*DI);
4585 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
4586 NewDecls.push_back(*DI);
4589 if (NewDecls.empty())
4605 Identifiers.clear();
4611 if (
const auto *NS = dyn_cast<NamespaceDecl>(Namespace);
4612 NS && NS->isAnonymousNamespace())
4614 Identifiers.push_back(Namespace->getIdentifier());
4620 switch (
T->getTypeClass()) {
4621 case Type::DependentName: {
4624 Identifiers.push_back(DT->getIdentifier());
4627 case Type::TemplateSpecialization: {
4633 if (
const auto *II = DTN->getName().getIdentifier())
4634 Identifiers.push_back(II);
4640 Name = QTN->getUnderlyingTemplate();
4643 Identifiers.push_back(TD->getIdentifier());
4646 case Type::SubstTemplateTypeParm:
4648 ->getReplacementType()
4651 case Type::TemplateTypeParm:
4654 case Type::Decltype:
4658 case Type::InjectedClassName: {
4661 Identifiers.push_back(TT->getDecl()->getIdentifier());
4664 case Type::Typedef: {
4667 Identifiers.push_back(TT->getDecl()->getIdentifier());
4673 Identifiers.push_back(TT->getDecl()->getIdentifier());
4676 case Type::UnresolvedUsing: {
4679 Identifiers.push_back(TT->getDecl()->getIdentifier());
4683 Identifiers.push_back(
QualType(
T, 0).getBaseTypeIdentifier());
4720 addName(Name,
nullptr);
4726 addName(
Keyword,
nullptr, std::nullopt,
true);
4729void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
4733 StringRef TypoStr = Typo->
getName();
4734 unsigned MinED =
abs((
int)Name.size() - (
int)TypoStr.size());
4735 if (MinED && TypoStr.size() / MinED < 3)
4740 unsigned UpperBound = (TypoStr.size() + 2) / 3;
4741 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
4742 if (ED > UpperBound)
return;
4745 if (isKeyword) TC.makeKeyword();
4746 TC.setCorrectionRange(
nullptr,
Result.getLookupNameInfo());
4753 StringRef TypoStr = Typo->getName();
4759 if (TypoStr.size() < 3 &&
4760 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4770 TypoResultList &CList =
4773 if (!CList.empty() && !CList.back().isResolved())
4776 auto RI = llvm::find_if(CList, [NewND](
const TypoCorrection &TypoCorr) {
4779 if (RI != CList.end()) {
4783 auto IsDeprecated = [](
Decl *D) {
4794 std::pair<bool, std::string> NewKey = {
4798 std::pair<bool, std::string> PrevKey = {
4799 IsDeprecated(RI->getFoundDecl()),
4800 RI->getAsString(SemaRef.getLangOpts())};
4802 if (NewKey < PrevKey)
4803 *RI = std::move(Correction);
4807 if (CList.empty() || Correction.
isResolved())
4808 CList.push_back(Correction);
4811 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4815 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4816 SearchNamespaces =
true;
4818 for (
auto KNPair : KnownNamespaces)
4819 Namespaces.addNameSpecifier(KNPair.first);
4821 bool SSIsTemplate =
false;
4830 auto &Types = SemaRef.getASTContext().getTypes();
4831 for (
unsigned I = 0; I != Types.size(); ++I) {
4832 const auto *TI = Types[I];
4834 CD = CD->getCanonicalDecl();
4835 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4836 !CD->isUnion() && CD->getIdentifier() &&
4838 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4839 Namespaces.addNameSpecifier(CD);
4845 if (++CurrentTCIndex < ValidatedCorrections.size())
4846 return ValidatedCorrections[CurrentTCIndex];
4848 CurrentTCIndex = ValidatedCorrections.size();
4849 while (!CorrectionResults.empty()) {
4850 auto DI = CorrectionResults.begin();
4851 if (DI->second.empty()) {
4852 CorrectionResults.erase(DI);
4856 auto RI = DI->second.begin();
4857 if (RI->second.empty()) {
4858 DI->second.erase(RI);
4859 performQualifiedLookups();
4865 ValidatedCorrections.push_back(TC);
4866 return ValidatedCorrections[CurrentTCIndex];
4869 return ValidatedCorrections[0];
4872bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4879 CorrectionValidator->IsObjCIvarLookup,
4881 switch (
Result.getResultKind()) {
4891 if (TempMemberContext) {
4894 TempMemberContext =
nullptr;
4897 if (SearchNamespaces)
4898 QualifiedResults.push_back(Candidate);
4908 for (
auto *TRD : Result)
4912 if (SearchNamespaces)
4913 QualifiedResults.push_back(Candidate);
4922void TypoCorrectionConsumer::performQualifiedLookups() {
4923 unsigned TypoLen = Typo->getName().size();
4924 for (
const TypoCorrection &QR : QualifiedResults) {
4925 for (
const auto &NSI : Namespaces) {
4926 DeclContext *Ctx = NSI.DeclCtx;
4927 CXXRecordDecl *NamingClass = NSI.NameSpecifier.getAsRecordDecl();
4934 NamingClass->
getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4937 TypoCorrection TC(QR);
4938 TC.ClearCorrectionDecls();
4939 TC.setCorrectionSpecifier(NSI.NameSpecifier);
4940 TC.setQualifierDistance(NSI.EditDistance);
4941 TC.setCallbackDistance(0);
4946 unsigned TmpED = TC.getEditDistance(
true);
4947 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4948 TypoLen / TmpED < 3)
4952 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4953 if (!SemaRef.LookupQualifiedName(Result, Ctx))
4958 switch (Result.getResultKind()) {
4961 if (SS && SS->isValid()) {
4962 std::string NewQualified = TC.getAsString(SemaRef.getLangOpts());
4963 std::string OldQualified;
4964 llvm::raw_string_ostream OldOStream(OldQualified);
4965 SS->getScopeRep().print(OldOStream, SemaRef.getPrintingPolicy());
4966 OldOStream << Typo->getName();
4970 if (OldOStream.str() == NewQualified)
4974 TRD != TRDEnd; ++TRD) {
4975 if (SemaRef.CheckMemberAccess(TC.getCorrectionRange().getBegin(),
4978 TC.addCorrectionDecl(*TRD);
4980 if (TC.isResolved()) {
4981 TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
4994 QualifiedResults.clear();
4997TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4999 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
5000 if (NestedNameSpecifier NNS =
5001 CurScopeSpec ? CurScopeSpec->
getScopeRep() : std::nullopt) {
5002 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
5003 NNS.print(SpecifierOStream, Context.getPrintingPolicy());
5005 getNestedNameSpecifierIdentifiers(NNS, CurNameSpecifierIdentifiers);
5010 for (DeclContext *
C : llvm::reverse(CurContextChain)) {
5011 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(
C))
5018 DistanceMap[1].push_back(SI);
5021auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
5023 assert(Start &&
"Building a context chain from a null context");
5024 DeclContextList Chain;
5036TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
5038 unsigned NumSpecifiers = 0;
5039 for (DeclContext *
C : llvm::reverse(DeclChain)) {
5040 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(
C)) {
5041 NNS = NestedNameSpecifier(Context, ND, NNS);
5043 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(
C)) {
5046 NNS = NestedNameSpecifier(
T.getTypePtr());
5050 return NumSpecifiers;
5053void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
5055 NestedNameSpecifier NNS = std::nullopt;
5056 unsigned NumSpecifiers = 0;
5057 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
5058 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
5061 for (DeclContext *
C : llvm::reverse(CurContextChain)) {
5062 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() !=
C)
5064 NamespaceDeclChain.pop_back();
5068 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
5071 if (NamespaceDeclChain.empty()) {
5075 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
5076 }
else if (NamedDecl *ND =
5077 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
5079 bool SameNameSpecifier =
false;
5080 if (llvm::is_contained(CurNameSpecifierIdentifiers, Name)) {
5081 std::string NewNameSpecifier;
5082 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
5083 SmallVector<const IdentifierInfo *, 4> NewNameSpecifierIdentifiers;
5086 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
5088 if (SameNameSpecifier || llvm::is_contained(CurContextIdentifiers, Name)) {
5092 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
5100 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
5101 SmallVector<const IdentifierInfo*, 4> NewNameSpecifierIdentifiers;
5104 llvm::ComputeEditDistance(llvm::ArrayRef(CurNameSpecifierIdentifiers),
5105 llvm::ArrayRef(NewNameSpecifierIdentifiers));
5108 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
5109 DistanceMap[NumSpecifiers].push_back(SI);
5118 bool EnteringContext,
5119 bool isObjCIvarLookup,
5125 if (MemberContext) {
5127 if (isObjCIvarLookup) {
5128 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
5149 false, EnteringContext);
5154 if (Method->isInstanceMethod() && Method->getClassInterface() &&
5159 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
5171 bool AfterNestedNameSpecifier) {
5172 if (AfterNestedNameSpecifier) {
5185 static const char *
const CTypeSpecs[] = {
5186 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
5187 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
5190 "extern",
"inline",
"static",
"typedef"
5193 for (
const auto *CTS : CTypeSpecs)
5223 static const char *
const CastableTypeSpecs[] = {
5224 "char",
"double",
"float",
"int",
"long",
"short",
5225 "signed",
"unsigned",
"void"
5227 for (
auto *kw : CastableTypeSpecs)
5246 static const char *
const CXXExprs[] = {
5247 "delete",
"new",
"operator",
"throw",
"typeid"
5249 for (
const auto *CE : CXXExprs)
5272 static const char *
const CStmts[] = {
5273 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
5274 for (
const auto *CS : CStmts)
5319std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
5321 Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC,
5322 DeclContext *MemberContext,
bool EnteringContext,
5325 if (Diags.hasFatalErrorOccurred() || !getLangOpts().SpellChecking ||
5326 DisableTypoCorrection)
5343 if (SS && SS->isInvalid())
5347 if (!CodeSynthesisContexts.empty())
5351 if (S && S->isInObjcMethodScope() && Typo == getSuperIdentifier())
5355 IdentifierSourceLocations::iterator locs = TypoCorrectionFailures.find(Typo);
5356 if (locs != TypoCorrectionFailures.end() &&
5357 locs->second.count(TypoName.
getLoc()))
5363 if ((getLangOpts().AltiVec || getLangOpts().ZVector) && Typo->isStr(
"vector"))
5369 unsigned Limit = getDiagnostics().getDiagnosticOptions().SpellCheckingLimit;
5370 if (Limit && TyposCorrected >= Limit)
5377 getLangOpts().ModulesSearchAll) {
5379 getModuleLoader().lookupMissingImports(Typo->getName(),
5387 std::unique_ptr<CorrectionCandidateCallback> ClonedCCC = CCC.
clone();
5388 auto Consumer = std::make_unique<TypoCorrectionConsumer>(
5389 *
this, TypoName, LookupKind, S, SS, std::move(ClonedCCC), MemberContext,
5393 bool IsUnqualifiedLookup =
false;
5394 DeclContext *QualifiedDC = MemberContext;
5395 if (MemberContext) {
5396 LookupVisibleDecls(MemberContext, LookupKind, *Consumer);
5400 for (
auto *I : OPT->
quals())
5401 LookupVisibleDecls(I, LookupKind, *Consumer);
5403 }
else if (SS && SS->isSet()) {
5404 QualifiedDC = computeDeclContext(*SS, EnteringContext);
5408 LookupVisibleDecls(QualifiedDC, LookupKind, *Consumer);
5410 IsUnqualifiedLookup =
true;
5415 bool SearchNamespaces
5416 = getLangOpts().CPlusPlus &&
5417 (IsUnqualifiedLookup || (SS && SS->isSet()));
5419 if (IsUnqualifiedLookup || SearchNamespaces) {
5423 for (
const auto &I : Context.
Idents)
5424 Consumer->FoundName(I.getKey());
5430 std::unique_ptr<IdentifierIterator> Iter(
External->getIdentifiers());
5432 StringRef Name = Iter->Next();
5436 Consumer->FoundName(Name);
5442 *Consumer->getCorrectionValidator(),
5443 SS && SS->isNotEmpty());
5447 if (SearchNamespaces) {
5449 if (ExternalSource && !LoadedExternalKnownNamespaces) {
5450 SmallVector<NamespaceDecl *, 4> ExternalKnownNamespaces;
5451 LoadedExternalKnownNamespaces =
true;
5452 ExternalSource->ReadKnownNamespaces(ExternalKnownNamespaces);
5453 for (
auto *N : ExternalKnownNamespaces)
5454 KnownNamespaces[N] =
true;
5457 Consumer->addNamespaces(KnownNamespaces);
5469 bool EnteringContext,
5471 bool RecordFailure) {
5477 MemberContext, EnteringContext, OPT))
5488 auto Consumer = makeTypoCorrectionConsumer(
5489 TypoName, LookupKind, S, SS, CCC, MemberContext, EnteringContext, OPT,
5497 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5501 unsigned ED =
Consumer->getBestEditDistance(
true);
5502 unsigned TypoLen = Typo->
getName().size();
5503 if (ED > 0 && TypoLen / ED < 3)
5504 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5509 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5513 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
5517 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5521 if (!SecondBestTC ||
5527 if (ED == 0 &&
Result.isKeyword())
5528 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5534 }
else if (SecondBestTC && ObjCMessageReceiver) {
5540 BestTC = std::move(SecondBestTC);
5541 else if ((*
Consumer)[
"super"].front().isKeyword())
5542 BestTC = (*Consumer)[
"super"].front();
5548 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5557 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
5564 CorrectionDecls.clear();
5566 CorrectionDecls.push_back(CDecl);
5568 if (!CorrectionName)
5573 if (CorrectionNameSpec) {
5574 std::string tmpBuffer;
5575 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
5577 PrefixOStream << CorrectionName;
5578 return PrefixOStream.str();
5593 bool HasNonType =
false;
5594 bool HasStaticMethod =
false;
5595 bool HasNonStaticMethod =
false;
5596 for (
Decl *D : candidate) {
5598 D = FTD->getTemplatedDecl();
5601 HasStaticMethod =
true;
5603 HasNonStaticMethod =
true;
5617 bool HasExplicitTemplateArgs,
5619 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
5620 CurContext(SemaRef.CurContext), MemberFn(ME) {
5623 !HasExplicitTemplateArgs && NumArgs == 1;
5632 for (
auto *
C : candidate) {
5636 FD = FTD->getTemplatedDecl();
5637 if (!HasExplicitTemplateArgs && !FD) {
5648 if (FPT->getNumParams() == NumArgs)
5656 CurContext->getParentASTContext().getLangOpts().CPlusPlus)
5658 return NumArgs <= 1 || HasExplicitTemplateArgs || isa<CXXRecordDecl>(ND);
5670 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
5671 if (MemberFn || !MD->isStatic()) {
5674 ? dyn_cast_if_present<CXXMethodDecl>(MemberFn->getMemberDecl())
5675 : dyn_cast_if_present<CXXMethodDecl>(CurContext);
5677 CurMD ? CurMD->
getParent()->getCanonicalDecl() :
nullptr;
5698 if (
const auto *VD = dyn_cast<VarDecl>(D))
5699 return VD->getDefinition();
5700 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
5701 return FD->getDefinition();
5702 if (
const auto *TD = dyn_cast<TagDecl>(D))
5703 return TD->getDefinition();
5704 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(D))
5705 return ID->getDefinition();
5706 if (
const auto *PD = dyn_cast<ObjCProtocolDecl>(D))
5707 return PD->getDefinition();
5708 if (
const auto *TD = dyn_cast<TemplateDecl>(D))
5709 if (
const NamedDecl *TTD = TD->getTemplatedDecl())
5723 assert(Owner &&
"definition of hidden declaration is not in a module");
5726 OwningModules.push_back(Owner);
5727 auto Merged =
Context.getModulesWithMergedDefinition(Def);
5728 llvm::append_range(OwningModules, Merged);
5737 llvm::StringRef IncludingFile) {
5738 bool IsAngled =
false;
5740 E, IncludingFile, &IsAngled);
5741 return (IsAngled ?
'<' :
'"') + Path + (IsAngled ?
'>' :
'"');
5748 assert(!Modules.empty());
5755 auto NotePrevious = [&] {
5759 Diag(DeclLoc, diag::note_unreachable_entity) << (int)MIK;
5764 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5765 for (
auto *M : Modules) {
5768 if (UniqueModuleSet.insert(M).second)
5769 UniqueModules.push_back(M);
5773 std::string HeaderName;
5775 PP.getHeaderToIncludeForDiagnostics(UseLoc, DeclLoc)) {
5784 if (!HeaderName.empty() || UniqueModules.empty()) {
5787 Diag(UseLoc, diag::err_module_unimported_use_header)
5788 << (int)MIK <<
Decl << !HeaderName.empty() << HeaderName;
5796 Modules = UniqueModules;
5798 auto GetModuleNameForDiagnostic = [
this](
const Module *M) -> std::string {
5814 if (Modules.size() > 1) {
5815 std::string ModuleList;
5817 for (
const auto *M : Modules) {
5818 ModuleList +=
"\n ";
5819 if (++N == 5 && N != Modules.size()) {
5820 ModuleList +=
"[...]";
5823 ModuleList += GetModuleNameForDiagnostic(M);
5826 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5827 << (int)MIK <<
Decl << ModuleList;
5830 Diag(UseLoc, diag::err_module_unimported_use)
5831 << (int)MIK <<
Decl << GetModuleNameForDiagnostic(Modules[0]);
5853 assert(
Decl &&
"import required but no declaration to import");
5868 if (
const auto *FD = dyn_cast_if_present<FunctionDecl>(ChosenDecl);
5869 FD && FD->getBuiltinID() &&
5870 PrevNote.
getDiagID() == diag::note_previous_decl &&
5872 ChosenDecl =
nullptr;
5876 Diag(ChosenDecl->getLocation(), PrevNote)
5888 R.suppressDiagnostics();
5889 R.setHideTags(
false);
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
static StringRef getIdentifier(const Token &Tok)
Defines the clang::Preprocessor interface.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
static Module * getDefiningModule(Sema &S, Decl *Entity)
Find the module in which the given declaration was defined.
static bool isPreferredLookupResult(Sema &S, Sema::LookupNameKind Kind, const NamedDecl *D, const NamedDecl *Existing)
Determine whether D is a better lookup result than Existing, given that they declare the same entity.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point.
static bool canHideTag(const NamedDecl *D)
Determine whether D can hide a tag declaration.
static std::string getHeaderNameForHeader(Preprocessor &PP, FileEntryRef E, llvm::StringRef IncludingFile)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a inclu...
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
static QualType getOpenCLTypedefType(Sema &S, llvm::StringRef Name)
Lookup an OpenCL typedef type.
static DeclContext * findOuterContext(Scope *S)
Find the outer declaration context from this scope.
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.
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC)
Check whether the declarations found for a typo correction are visible.
static bool isNamespaceOrTranslationUnitScope(Scope *S)
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, DeclContext *StartDC)
Perform qualified name lookup in the namespaces nominated by using directives by the given context.
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC)
static QualType getOpenCLEnumType(Sema &S, llvm::StringRef Name)
Lookup an OpenCL enum type.
static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces, DeclContext *Ctx)
static bool hasAcceptableDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Sema::AcceptableKind Kind)
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier NNS, SmallVectorImpl< const IdentifierInfo * > &Identifiers)
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 ...
static void AddKeywordsToConsumer(Sema &SemaRef, TypoCorrectionConsumer &Consumer, Scope *S, CorrectionCandidateCallback &CCC, bool AfterNestedNameSpecifier)
Add keywords to the consumer as possible typo corrections.
static void GetQualTypesForOpenCLBuiltin(Sema &S, const OpenCLBuiltinStruct &OpenCLBuiltin, unsigned &GenTypeMaxCnt, SmallVector< QualType, 1 > &RetTypes, SmallVector< SmallVector< QualType, 1 >, 5 > &ArgTypes)
Get the QualType instances of the return type and arguments for an OpenCL builtin function signature.
static QualType diagOpenCLBuiltinTypeError(Sema &S, llvm::StringRef TypeClass, llvm::StringRef Name)
Diagnose a missing builtin type.
static bool hasAcceptableMemberSpecialization(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Sema::AcceptableKind Kind)
static bool hasAcceptableDeclarationImpl(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Filter F, Sema::AcceptableKind Kind)
static bool isCandidateViable(CorrectionCandidateCallback &CCC, TypoCorrection &Candidate)
static const DeclContext * getContextForScopeMatching(const Decl *D)
Get a representative context for a declaration such that two declarations will have the same context ...
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D, unsigned IDNS)
Retrieve the visible declaration corresponding to D, if any.
static void GetOpenCLBuiltinFctOverloads(ASTContext &Context, unsigned GenTypeMaxCnt, std::vector< QualType > &FunctionList, SmallVector< QualType, 1 > &RetTypes, SmallVector< SmallVector< QualType, 1 >, 5 > &ArgTypes)
Create a list of the candidate function overloads for an OpenCL builtin function.
static const unsigned MaxTypoDistanceResultSets
static const NamedDecl * getDefinitionToImport(const NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
static Sema::SpecialMemberCacheKey makeSpecialMemberCacheKey(const CXXRecordDecl *RD, CXXSpecialMemberKind SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
static bool hasAcceptableExplicitSpecialization(Sema &S, const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Sema::AcceptableKind Kind)
static unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, bool Redeclaration)
static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR, IdentifierInfo *II, const unsigned FctIndex, const unsigned Len)
When trying to resolve a function name, if isOpenCLBuiltin() returns a non-null <Index,...
static void LookupPredefedObjCSuperType(Sema &Sema, Scope *S)
Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declar...
static bool CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, const DeclContext *NS, UnqualUsingDirectiveSet &UDirs)
This file declares semantic analysis functions specific to RISC-V.
__DEVICE__ long long abs(long long __n)
A class for storing results from argument-dependent lookup.
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
Builtin::Context & BuiltinInfo
bool isInSameModule(const Module *M1, const Module *M2) const
If the two module M1 and M2 are in the same module.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
DeclContext::lookup_iterator Decls
The declarations found inside this base class subobject.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
void setOrigin(const CXXRecordDecl *Rec)
std::list< CXXBasePath >::iterator paths_iterator
std::list< CXXBasePath >::const_iterator const_paths_iterator
void swap(CXXBasePaths &Other)
Swap this data structure's contents with another CXXBasePaths object.
Represents a base class of a C++ class.
QualType getType() const
Retrieves the type of the base class.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
CXXRecordDecl * getDefinition() const
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
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...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
UnresolvedSetIterator conversion_iterator
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
SourceRange getRange() const
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool WantExpressionKeywords
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
bool WantFunctionLikeCasts
bool WantRemainingKeywords
virtual std::unique_ptr< CorrectionCandidateCallback > clone()=0
Clone this CorrectionCandidateCallback.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclListNode::iterator iterator
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
lookup_result::iterator lookup_iterator
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
lookups_range noload_lookups(bool PreserveInternalState) const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
lookups_range lookups() const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
bool isInlineNamespace() const
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
DeclContext * getEnclosingNonExpansionStatementContext()
Retrieve the innermost enclosing context that doesn't belong to an expansion statement.
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
ASTContext & getASTContext() const LLVM_READONLY
bool isInNamedModule() const
Whether this declaration comes from a named module.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
bool isInIdentifierNamespace(unsigned NS) const
bool isInvisibleOutsideTheOwningModule() const
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
bool isInAnotherModuleUnit() const
Whether this declaration comes from another module unit.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
SourceLocation getLocation() const
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
@ IDNS_TagFriend
This declaration is a friend class.
@ IDNS_Ordinary
Ordinary names.
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
@ IDNS_OMPReduction
This declaration is an OpenMP user defined reduction construction.
@ IDNS_Label
Labels, declared with 'x:' and referenced with 'goto x'.
@ IDNS_Member
Members, declared with object declarations within tag definitions.
@ IDNS_OMPMapper
This declaration is an OpenMP user defined mapper.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
@ IDNS_Using
This declaration is a using declaration.
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setImplicit(bool I=true)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
DeclContext * getDeclContext()
bool hasTagIdentifierNamespace() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
std::string getAsString() const
Retrieve the human-readable string for this name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
The return type of classify().
This represents one expression.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
An abstract interface that should be implemented by external AST sources that also provide informatio...
bool isFPConstrained() const
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Cached information about one file (either on disk or in the virtual file system).
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Represents a function declaration or definition.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
bool isDeleted() const
Whether this function has been deleted.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
ExtInfo withCallingConv(CallingConv cc) const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
StringRef getName() const
Return the actual identifier string.
iterator - Iterate over the decls of a specified declaration name.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
Represents the declaration of a label.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A class for iterating through a result set and possibly filtering out results.
void restart()
Restart the iteration.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
static bool isAvailableForLookup(Sema &SemaRef, NamedDecl *ND)
Determine whether this lookup is permitted to see the declaration.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
static bool isAcceptable(Sema &SemaRef, NamedDecl *D, Sema::AcceptableKind Kind)
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type.
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
UnresolvedSetImpl::iterator iterator
void print(raw_ostream &)
static bool isReachable(Sema &SemaRef, NamedDecl *D)
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
DeclarationName getLookupName() const
Gets the name to look up.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
bool isPrivateModule() const
bool isModuleVisible(const Module *M) const
Determine whether the specified module would be visible to a lookup at the end of this module.
bool isModuleInterfaceUnit() const
bool isModuleMapModule() const
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
bool isExplicitGlobalModule() const
bool isGlobalModule() const
Does this Module scope describe a fragment of the global module within some C++ module.
bool isImplicitGlobalModule() const
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool isNamedModule() const
Does this Module is a named module of a standard named module?
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
llvm::SmallVector< ModuleRef, 2 > Imports
The set of modules imported by this module, and on which this module depends.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NamedDecl * getMostRecentDecl()
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
static constexpr NestedNameSpecifier getGlobal()
NamespaceAndPrefix getAsNamespaceAndPrefix() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
Represents an ObjC class declaration.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents one property declaration in an Objective-C interface.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
llvm::iterator_range< decls_iterator > decls() const
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
unsigned getDiagID() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isMacroDefined(StringRef Id)
HeaderSearch & getHeaderSearchInfo() const
A (possibly-)qualified type.
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void addVolatile()
Add the volatile type qualifier to this QualType.
Represents a template name as written in source code.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
unsigned getFlags() const
getFlags - Return the flags for this scope.
DeclContext * getLookupEntity() const
Get the DeclContext in which to continue unqualified lookup after a lookup in this scope.
using_directives_range using_directives()
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
std::unique_ptr< sema::RISCVIntrinsicManager > IntrinsicManager
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
SpecialMemberOverloadResult - The overloading result for a special member function.
Sema - This implements semantic analysis and AST building for C.
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
bool hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a reachable definition.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupLabel
Label name lookup.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupOMPReductionName
Look up the name of an OpenMP user-defined reduction operation.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
@ LookupObjCImplicitSelfParam
Look up implicit 'self' parameter of an objective-c method.
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupDestructorName
Look up a name following ~ in a destructor name.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
@ LookupOMPMapperName
Look up the name of an OpenMP user-defined mapper.
@ LookupAnyName
Look up any declaration with any name.
std::pair< const CXXRecordDecl *, unsigned > SpecialMemberCacheKey
bool hasReachableDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
MissingImportKind
Kinds of missing import.
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
Preprocessor & getPreprocessor() const
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate, bool DiagnoseMissing, StringLiteral *StringLit=nullptr)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal,...
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...
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
llvm::DenseMap< NamedDecl *, NamedDecl * > VisibleNamespaceCache
Map from the most recent declaration of a namespace to the most recent visible declaration of that na...
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
ASTContext & getASTContext() const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
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...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
FPOptions & getCurFPFeatures()
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, 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...
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...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
sema::FunctionScopeInfo * getCurFunction() const
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool hasReachableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a reachable default argument.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
bool isAcceptable(const NamedDecl *D, AcceptableKind Kind)
Determine whether a declaration is acceptable (visible/reachable).
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
bool isModuleVisible(const Module *M, bool ModulePrivate=false)
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
bool hasVisibleMergedDefinition(const NamedDecl *Def)
void DeclareImplicitDeductionGuides(TemplateDecl *Template, SourceLocation Loc)
Declare implicit deduction guides for a class template if we've not already done so.
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void diagnoseMissingImport(SourceLocation Loc, const 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...
bool hasReachableMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is a member specialization declaration (as op...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation(), bool IsLabelStmt=false)
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
RedeclarationKind forRedeclarationInCurContext() const
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool hasReachableExplicitSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a reachable declaration of D that is an explicit specialization declaration for...
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMemberKind SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
bool hasAcceptableDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules, Sema::AcceptableKind Kind)
Determine if the template parameter D has a reachable default argument.
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
bool hasAcceptableDefinition(NamedDecl *D, NamedDecl **Suggested, AcceptableKind Kind, bool OnlyNeedComplete=false)
llvm::DenseMap< SpecialMemberCacheKey, SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
@ LOLR_ErrorNoDiagnostic
The lookup found no match but no diagnostic was issued.
@ LOLR_Raw
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
@ LOLR_Error
The lookup resulted in an error.
@ LOLR_Cooked
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
@ LOLR_StringTemplatePack
The lookup found an overload set of literal operator templates, which expect the character type and c...
@ LOLR_Template
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on pragma clang __debug dump II.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
IdentifierResolver IdResolver
LabelDecl * LookupExistingLabel(IdentifierInfo *II, SourceLocation IdentLoc)
Perform a name lookup for a label with the specified name; this does not create a new label if the lo...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery,...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Represents a declaration of a type.
The base class of the type hierarchy.
const TemplateSpecializationType * getAsNonAliasTemplateSpecializationType() const
Look through sugar for an instance of TemplateSpecializationType which is not a type alias,...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getCanonicalTypeInternal() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
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...
void addKeywordResult(StringRef Keyword)
void addCorrection(TypoCorrection Correction)
const TypoCorrection & getNextCorrection()
Return the next typo correction that passes all internal filters and is deemed valid by the consumer'...
void FoundName(StringRef Name)
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...
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
ArrayRef< PartialDiagnostic > getExtraDiagnostics() const
static const unsigned InvalidDistance
void addCorrectionDecl(NamedDecl *CDecl)
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the Decla...
void setCorrectionDecls(ArrayRef< NamedDecl * > Decls)
Clears the list of NamedDecls and adds the given set.
std::string getAsString(const LangOptions &LO) const
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
void setCorrectionRange(CXXScopeSpec *SS, const DeclarationNameInfo &TypoName)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SourceRange getCorrectionRange() const
void WillReplaceSpecifier(bool ForceReplacement)
void setCallbackDistance(unsigned ED)
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setRequiresImport(bool Req)
std::string getQuoted(const LangOptions &LO) const
NestedNameSpecifier getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
A set of unresolved declarations.
void append(iterator I, iterator E)
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represents a variable declaration or definition.
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer.
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
bool Load(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ Found
Name lookup found a single declaration that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
std::unique_ptr< sema::RISCVIntrinsicManager > CreateRISCVIntrinsicManager(Sema &S)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ AmbiguousBaseSubobjects
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
@ AmbiguousReferenceToPlaceholderVariable
Name lookup results in an ambiguity because multiple placeholder variables were found in the same sco...
@ AmbiguousReference
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
@ AmbiguousBaseSubobjectTypes
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
@ Result
The result type of a method or function.
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
const FunctionProtoType * T
llvm::Expected< QualType > ExpectedType
@ Template
We are parsing a template declaration.
@ Keyword
The name has been typo-corrected to a keyword.
CXXSpecialMemberKind
Kinds of C++ special members.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
for(const auto &A :T->param_types())
@ Success
Template argument deduction was successful.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ EST_None
no exception specification
Represents an element in a path from a derived class to a base class.
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to.
const CXXBaseSpecifier * Base
The base specifier that states the link from a derived class to a base class, which will be followed ...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionType::ExtInfo ExtInfo
OverloadExpr * Expression
Describes how types, statements, expressions, and declarations should be printed.