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"
57 #include "OpenCLBuiltins.inc"
58 #include "SPIRVBuiltins.inc"
60 using namespace clang;
64 class UnqualUsingEntry {
71 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
75 return CommonAncestor;
84 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
85 return L.getCommonAncestor() < R.getCommonAncestor();
88 bool operator()(
const UnqualUsingEntry &E,
const DeclContext *DC) {
89 return E.getCommonAncestor() < DC;
92 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
93 return DC < E.getCommonAncestor();
100 class UnqualUsingDirectiveSet {
109 UnqualUsingDirectiveSet(
Sema &SemaRef) : SemaRef(SemaRef) {}
111 void visitScopeChain(
Scope *S,
Scope *InnermostFileScope) {
119 for (; S; S = S->getParent()) {
127 for (
auto *I : S->using_directives())
129 visit(I, InnermostFileDC);
142 if (!visited.insert(DC).second)
145 addUsingDirectives(DC, EffectiveDC);
153 if (!visited.insert(NS).second)
156 addUsingDirective(UD, EffectiveDC);
157 addUsingDirectives(NS, EffectiveDC);
168 if (SemaRef.
isVisible(UD) && visited.insert(NS).second) {
169 addUsingDirective(UD, EffectiveDC);
177 DC = queue.pop_back_val();
192 while (!Common->
Encloses(EffectiveDC))
199 void done() { llvm::sort(list, UnqualUsingEntry::Comparator()); }
201 typedef ListTy::const_iterator const_iterator;
203 const_iterator begin()
const {
return list.begin(); }
204 const_iterator end()
const {
return list.end(); }
206 llvm::iterator_range<const_iterator>
208 return llvm::make_range(std::equal_range(begin(), end(),
210 UnqualUsingEntry::Comparator()));
219 bool Redeclaration) {
240 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
279 assert(Redeclaration &&
"should only be used for redecl lookup");
306 void LookupResult::configure() {
308 isForRedeclaration());
313 switch (NameInfo.getName().getCXXOverloadedOperator()) {
317 case OO_Array_Delete:
318 getSema().DeclareGlobalNewDelete();
328 if (
unsigned BuiltinID =
Id->getBuiltinID()) {
335 bool LookupResult::checkDebugAssumptions()
const {
337 assert(ResultKind != NotFound || Decls.size() == 0);
338 assert(ResultKind != Found || Decls.size() == 1);
339 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
340 (Decls.size() == 1 &&
341 isa<FunctionTemplateDecl>((*begin())->getUnderlyingDecl())));
342 assert(ResultKind != FoundUnresolvedValue || checkUnresolved());
343 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
344 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
345 Ambiguity == AmbiguousBaseSubobjectTypes)));
346 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
347 (Ambiguity == AmbiguousBaseSubobjectTypes ||
348 Ambiguity == AmbiguousBaseSubobjects)));
380 !isa<UsingShadowDecl>(Existing))
394 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
395 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
396 bool HaveTag = isa<TagDecl>(EUnderlying);
399 return HaveTag != WantTag;
406 if (
const auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
407 const auto *EFD = cast<FunctionDecl>(EUnderlying);
408 unsigned DMin = DFD->getMinRequiredArguments();
409 unsigned EMin = EFD->getMinRequiredArguments();
418 if (
const auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
419 const auto *ETD = cast<TemplateDecl>(EUnderlying);
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)) {
443 const auto *EVD = cast<VarDecl>(EUnderlying);
444 if (EVD->getType()->isIncompleteType() &&
445 !DVD->getType()->isIncompleteType()) {
453 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
462 if (Prev == EUnderlying)
482 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
483 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D) ||
484 isa<UnresolvedUsingValueDecl>(D);
489 unsigned N = Decls.size();
493 assert(ResultKind == NotFound ||
494 ResultKind == NotFoundInCurrentInstantiation);
501 const NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
502 if (isa<FunctionTemplateDecl>(D))
503 ResultKind = FoundOverloaded;
504 else if (isa<UnresolvedUsingValueDecl>(D))
505 ResultKind = FoundUnresolvedValue;
510 if (ResultKind == Ambiguous)
return;
512 llvm::SmallDenseMap<const NamedDecl *, unsigned, 16> Unique;
513 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
515 bool Ambiguous =
false;
516 bool ReferenceToPlaceHolderVariable =
false;
517 bool HasTag =
false, HasFunction =
false;
518 bool HasFunctionTemplate =
false, HasUnresolved =
false;
519 const NamedDecl *HasNonFunction =
nullptr;
522 llvm::BitVector RemovedDecls(N);
524 for (
unsigned I = 0; I < N; I++) {
531 N - RemovedDecls.count() > 1) {
543 if (HideTags && isa<TagDecl>(D)) {
545 for (
auto *OtherDecl : Decls) {
546 if (
canHideTag(OtherDecl) && !OtherDecl->isInvalidDecl() &&
558 std::optional<unsigned> ExistingI;
564 if (
const auto *TD = dyn_cast<TypeDecl>(D)) {
565 QualType T = getSema().Context.getTypeDeclType(TD);
566 auto UniqueResult = UniqueTypes.insert(
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];
596 if (isa<UnresolvedUsingValueDecl>(D)) {
597 HasUnresolved =
true;
598 }
else if (isa<TagDecl>(D)) {
602 }
else if (isa<FunctionTemplateDecl>(D)) {
604 HasFunctionTemplate =
true;
605 }
else if (isa<FunctionDecl>(D)) {
608 if (HasNonFunction) {
613 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
615 EquivalentNonFunctions.push_back(D);
622 ReferenceToPlaceHolderVariable =
true;
632 if (!EquivalentNonFunctions.empty() && !Ambiguous)
633 getSema().diagnoseEquivalentInternalLinkageDeclarations(
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)
659 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
661 for (I =
P.begin(), E =
P.end(); I != E; ++I)
670 addDeclsFromBasePaths(*Paths);
672 setAmbiguous(AmbiguousBaseSubobjects);
678 addDeclsFromBasePaths(*Paths);
680 setAmbiguous(AmbiguousBaseSubobjectTypes);
684 Out << Decls.size() <<
" result(s)";
685 if (isAmbiguous()) Out <<
", ambiguous";
686 if (Paths) Out <<
", base paths present";
688 for (
iterator I = begin(), E = end(); I != E; ++I) {
695 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
707 llvm::StringRef Name) {
709 << TypeClass << Name;
750 template <
typename ProgModel>
752 Sema &S,
const typename ProgModel::BuiltinStruct &Builtin,
756 unsigned Sig = ProgModel::SignatureTable[Builtin.SigTableIndex];
757 ProgModel::Bultin2Qual(S, ProgModel::TypeTable[Sig], RetTypes);
758 GenTypeMaxCnt = RetTypes.size();
762 for (
unsigned Index = 1; Index < Builtin.NumTypes; Index++) {
764 ProgModel::Bultin2Qual(
766 ProgModel::TypeTable[ProgModel::SignatureTable[Builtin.SigTableIndex +
769 GenTypeMaxCnt = (Ty.size() > GenTypeMaxCnt) ? Ty.size() : GenTypeMaxCnt;
770 ArgTypes.push_back(std::move(Ty));
793 if (RetTypes.size() == 0)
797 for (
unsigned IGenType = 0; IGenType < GenTypeMaxCnt; IGenType++) {
800 for (
unsigned A = 0; A < ArgTypes.size(); A++) {
802 if (ArgTypes[A].size() == 0)
808 assert(GenTypeMaxCnt % ArgTypes[A].size() == 0 &&
809 "argument type count not compatible with gentype type count");
810 unsigned Idx = IGenType % ArgTypes[A].size();
811 ArgList.push_back(ArgTypes[A][Idx]);
815 RetTypes[(RetTypes.size() != 1) ? IGenType : 0], ArgList, PI));
819 template <
typename ProgModel>
823 return isOpenCLVersionContainedInMask(LO, Mask);
842 template <
typename ProgModel>
846 std::function<
void(
const typename ProgModel::BuiltinStruct &,
848 ProgModelFinalizer) {
850 bool HasGenType =
false;
854 unsigned GenTypeMaxCnt;
858 for (
unsigned SignatureIndex = 0; SignatureIndex < Len; SignatureIndex++) {
859 const typename ProgModel::BuiltinStruct &Builtin =
860 ProgModel::BuiltinTable[FctIndex + SignatureIndex];
864 if (!isVersionInMask<ProgModel>(Context.
getLangOpts(), Builtin.Versions))
870 StringRef Extensions = ProgModel::FunctionExtensionTable[Builtin.Extension];
871 if (!Extensions.empty()) {
873 Extensions.split(ExtVec,
" ");
874 bool AllExtensionsDefined =
true;
875 for (StringRef Ext : ExtVec) {
877 AllExtensionsDefined =
false;
881 if (!AllExtensionsDefined)
889 GetQualTypesForProgModelBuiltin<ProgModel>(S, Builtin, GenTypeMaxCnt,
891 if (GenTypeMaxCnt > 1) {
896 std::vector<QualType> FunctionList;
898 RetTypes, ArgTypes, Builtin.IsVariadic);
904 for (
const auto &FTy : FunctionList) {
908 FTy->isFunctionProtoType());
913 const auto *FP = cast<FunctionProtoType>(FTy);
915 for (
unsigned IParm = 0, e = FP->getNumParams(); IParm != e; ++IParm) {
918 nullptr, FP->getParamType(IParm),
nullptr,
SC_None,
nullptr);
920 ParmList.push_back(Parm);
922 NewBuiltin->setParams(ParmList);
926 NewBuiltin->
addAttr(PureAttr::CreateImplicit(Context));
928 NewBuiltin->
addAttr(ConstAttr::CreateImplicit(Context));
930 NewBuiltin->
addAttr(ConvergentAttr::CreateImplicit(Context));
932 NewBuiltin->
addAttr(OverloadableAttr::CreateImplicit(Context));
934 ProgModelFinalizer(Builtin, *NewBuiltin);
940 if (Len > 1 || HasGenType)
957 if (II == getASTContext().getMakeIntegerSeqName()) {
958 R.
addDecl(getASTContext().getMakeIntegerSeqDecl());
960 }
else if (II == getASTContext().getTypePackElementName()) {
961 R.
addDecl(getASTContext().getTypePackElementDecl());
967 if (getLangOpts().
OpenCL && getLangOpts().DeclareOpenCLBuiltins) {
968 auto Index = OpenCLBuiltin::isBuiltin(II->
getName());
970 InsertBuiltinDeclarationsFromTable<OpenCLBuiltin>(
971 *
this, R, II, Index.first - 1, Index.second,
972 [
this](
const OpenCLBuiltin::BuiltinStruct &OpenCLBuiltin,
974 if (!this->getLangOpts().OpenCLCPlusPlus)
975 NewOpenCLBuiltin.addAttr(
976 OverloadableAttr::CreateImplicit(Context));
983 if (getLangOpts().DeclareSPIRVBuiltins) {
984 auto Index = SPIRVBuiltin::isBuiltin(II->
getName());
986 InsertBuiltinDeclarationsFromTable<SPIRVBuiltin>(
987 *
this, R, II, Index.first - 1, Index.second,
988 [
this](
const SPIRVBuiltin::BuiltinStruct &,
990 if (!this->getLangOpts().CPlusPlus)
991 NewBuiltin.addAttr(OverloadableAttr::CreateImplicit(Context));
992 if (this->getLangOpts().SYCLIsDevice)
994 SYCLDeviceAttr::CreateImplicit(this->Context));
1000 if (RISCV().DeclareRVVBuiltins || RISCV().DeclareSiFiveVectorBuiltins) {
1001 if (!RISCV().IntrinsicManager)
1004 RISCV().IntrinsicManager->InitIntrinsicList();
1006 if (RISCV().IntrinsicManager->CreateIntrinsicIfFound(R, II, PP))
1019 LazilyCreateBuiltin(II, BuiltinID, TUScope,
1045 if (
ID == Builtin::BIobjc_msgSendSuper)
1053 if (!
Class->getDefinition() ||
Class->isDependentContext())
1057 return !
Class->isBeingDefined();
1065 if (
Class->needsImplicitDefaultConstructor())
1066 DeclareImplicitDefaultConstructor(
Class);
1069 if (
Class->needsImplicitCopyConstructor())
1070 DeclareImplicitCopyConstructor(
Class);
1073 if (
Class->needsImplicitCopyAssignment())
1074 DeclareImplicitCopyAssignment(
Class);
1078 if (
Class->needsImplicitMoveConstructor())
1079 DeclareImplicitMoveConstructor(
Class);
1082 if (
Class->needsImplicitMoveAssignment())
1083 DeclareImplicitMoveAssignment(
Class);
1087 if (
Class->needsImplicitDestructor())
1088 DeclareImplicitDestructor(
Class);
1094 switch (Name.getNameKind()) {
1100 return Name.getCXXOverloadedOperator() == OO_Equal;
1118 switch (Name.getNameKind()) {
1123 if (
Record->needsImplicitDefaultConstructor())
1125 if (
Record->needsImplicitCopyConstructor())
1128 Record->needsImplicitMoveConstructor())
1135 if (
Record->getDefinition() &&
Record->needsImplicitDestructor() &&
1141 if (Name.getCXXOverloadedOperator() != OO_Equal)
1147 if (
Record->needsImplicitCopyAssignment())
1150 Record->needsImplicitMoveAssignment())
1190 !isa<CXXRecordDecl>(DC))
1198 if (!
Record->isCompleteDefinition())
1204 auto *ContainedDeducedType =
1208 ContainedDeducedType && ContainedDeducedType->isUndeducedType())
1212 UEnd =
Record->conversion_end();
U != UEnd; ++
U) {
1242 assert(ConvProto &&
"Nonsensical conversion function template type");
1269 UnqualUsingDirectiveSet &UDirs) {
1271 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
1278 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
1297 for (
Scope *OuterS = S->getParent(); OuterS; OuterS = OuterS->getParent())
1306 struct FindLocalExternScope {
1308 : R(R), OldFindLocalExtern(R.getIdentifierNamespace() &
1309 Decl::IDNS_LocalExtern) {
1316 ~FindLocalExternScope() {
1320 bool OldFindLocalExtern;
1325 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1345 Name.getCXXNameType()->isDependentType()) {
1355 I = IdResolver.begin(Name),
1356 IEnd = IdResolver.end();
1376 UnqualUsingDirectiveSet UDirs(*
this);
1377 bool VisitedUsingDirectives =
false;
1378 bool LeftStartingScope =
false;
1381 FindLocalExternScope FindLocals(R);
1384 bool SearchNamespaceScope =
true;
1386 for (; I != IEnd && S->isDeclScope(*I); ++I) {
1388 if (NameKind == LookupRedeclarationWithLinkage &&
1389 !(*I)->isTemplateParameter()) {
1395 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1396 LeftStartingScope =
true;
1400 if (LeftStartingScope && !((*I)->hasLinkage())) {
1407 SearchNamespaceScope =
false;
1412 if (!SearchNamespaceScope) {
1414 if (S->isClassScope())
1415 if (
auto *
Record = dyn_cast_if_present<CXXRecordDecl>(S->getEntity()))
1420 if (NameKind == LookupLocalFriendName && !S->isClassScope()) {
1445 if (Method->isInstanceMethod() && Name.getAsIdentifierInfo())
1449 Name.getAsIdentifierInfo(),
1467 if (!VisitedUsingDirectives) {
1470 if (UCtx->isTransparentContext())
1473 UDirs.visit(UCtx, UCtx);
1478 Scope *InnermostFileScope = S;
1479 while (InnermostFileScope &&
1481 InnermostFileScope = InnermostFileScope->
getParent();
1482 UDirs.visitScopeChain(Initial, InnermostFileScope);
1486 VisitedUsingDirectives =
true;
1503 if (LookupQualifiedName(R, Ctx,
true))
1511 if (!S)
return false;
1514 if (NameKind == LookupMemberName)
1522 if (!VisitedUsingDirectives) {
1523 UDirs.visitScopeChain(Initial, S);
1530 FindLocals.restore();
1536 for (; S; S = S->getParent()) {
1539 for (; I != IEnd && S->isDeclScope(*I); ++I) {
1550 if (Found && S->isTemplateParamScope()) {
1568 if (!(Found && S->isTemplateParamScope())) {
1570 "We should have been looking only at file context here already.");
1595 if (
auto *M = getCurrentModule())
1603 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1604 for (
auto *Param : *TD->getTemplateParameters())
1605 makeMergedDefinitionVisible(Param);
1610 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1615 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1618 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1619 if (
auto *Pattern = ED->getTemplateInstantiationPattern())
1621 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1629 if (Context->isFileContext())
1635 unsigned N = CodeSynthesisContexts.size();
1636 for (
unsigned I = CodeSynthesisContextLookupModules.size();
1638 Module *M = CodeSynthesisContexts[I].Entity ?
1641 if (M && !LookupModulesCache.insert(M).second)
1643 CodeSynthesisContextLookupModules.push_back(M);
1645 return LookupModulesCache;
1649 bool Sema::isUsableModule(
const Module *M) {
1650 assert(M &&
"We shouldn't check nullness for module here");
1652 if (UsableModuleUnitsCache.count(M))
1660 if (M == TheGlobalModuleFragment || M == TheImplicitGlobalModuleFragment ||
1668 M == getCurrentModule() ||
1675 llvm::StringRef(getLangOpts().CurrentModule).split(
':').first) {
1676 UsableModuleUnitsCache.insert(M);
1685 if (isModuleVisible(Merged))
1692 if (isUsableModule(Merged))
1697 template <
typename ParmDecl>
1702 if (!D->hasDefaultArgument())
1706 while (D &&
Visited.insert(D).second) {
1707 auto &DefaultArg = D->getDefaultArgStorage();
1711 if (!DefaultArg.isInherited() && Modules) {
1712 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1718 D = DefaultArg.getInheritedFrom();
1726 if (
auto *
P = dyn_cast<TemplateTypeParmDecl>(D))
1729 if (
auto *
P = dyn_cast<NonTypeTemplateParmDecl>(D))
1733 *
this, cast<TemplateTemplateParmDecl>(D), Modules,
Kind);
1748 template <
typename Filter>
1753 bool HasFilteredRedecls =
false;
1755 for (
auto *Redecl : D->
redecls()) {
1756 auto *R = cast<NamedDecl>(Redecl);
1763 HasFilteredRedecls =
true;
1766 Modules->push_back(R->getOwningModule());
1770 if (HasFilteredRedecls)
1783 if (
auto *RD = dyn_cast<CXXRecordDecl>(D))
1784 return RD->getTemplateSpecializationKind() ==
1786 if (
auto *FD = dyn_cast<FunctionDecl>(D))
1787 return FD->getTemplateSpecializationKind() ==
1789 if (
auto *VD = dyn_cast<VarDecl>(D))
1790 return VD->getTemplateSpecializationKind() ==
1792 llvm_unreachable(
"unknown explicit specialization kind");
1814 "not a member specialization");
1852 bool LookupResult::isAcceptableSlow(
Sema &SemaRef,
NamedDecl *D,
1855 "should not call this: not in slow case");
1858 assert(DeclModule &&
"hidden decl has no owning module");
1868 auto IsEffectivelyFileContext = [](
const DeclContext *DC) {
1870 isa<ExportDecl>(DC);
1876 if (DC && !IsEffectivelyFileContext(DC)) {
1884 bool AcceptableWithinParent;
1886 bool SearchDefinitions =
true;
1887 if (
const auto *DCD = dyn_cast<Decl>(DC)) {
1888 if (
const auto *TD = DCD->getDescribedTemplate()) {
1891 SearchDefinitions = Index >= TPL->
size() || TPL->
getParam(Index) != D;
1894 if (SearchDefinitions)
1895 AcceptableWithinParent =
1898 AcceptableWithinParent =
1899 isAcceptable(SemaRef, cast<NamedDecl>(DC),
Kind);
1900 }
else if (isa<ParmVarDecl>(D) ||
1901 (isa<FunctionDecl>(DC) && !SemaRef.
getLangOpts().CPlusPlus))
1902 AcceptableWithinParent = isAcceptable(SemaRef, cast<NamedDecl>(DC),
Kind);
1906 AcceptableWithinParent =
false;
1909 AcceptableWithinParent =
true;
1913 }
while (!IsEffectivelyFileContext(DC));
1915 AcceptableWithinParent =
1927 return AcceptableWithinParent;
1934 "Additional Sema::AcceptableKind?");
1935 return isReachableSlow(SemaRef, D);
1941 if (ModulePrivate && isUsableModule(M))
1946 if (!ModulePrivate && VisibleModules.isVisible(M))
1953 const auto &LookupModules = getLookupModules();
1954 if (LookupModules.empty())
1958 if (LookupModules.count(M))
1972 return llvm::any_of(LookupModules, [&](
const Module *LookupM) {
1979 bool LookupResult::isReachableSlow(
Sema &SemaRef,
NamedDecl *D) {
1980 assert(!isVisible(SemaRef, D) &&
"Shouldn't call the slow case.\n");
1983 assert(DeclModule &&
"hidden decl has no owning module");
2053 "should not have hidden, non-externally-declarable result here");
2087 for (
auto *RD : D->
redecls()) {
2092 auto ND = cast<NamedDecl>(RD);
2096 if (ND->isInIdentifierNamespace(IDNS) &&
2106 assert(!isVisible(D) &&
"not in slow case");
2108 *
this, D, Modules, [](
const NamedDecl *) {
return true; },
2114 assert(!isReachable(D) &&
"not in slow case");
2116 *
this, D, Modules, [](
const NamedDecl *) {
return true; },
2121 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
2129 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
2131 auto *Acceptable = isVisible(getSema(), Key)
2135 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
2161 if (isVisible(SemaRef, ND))
2183 if (
auto *FD = dyn_cast<FunctionDecl>(ND);
2184 FD && FD->isReservedGlobalPlacementOperator())
2213 if (
auto *TD = dyn_cast<TagDecl>(DC))
2248 bool ForceNoCPlusPlus) {
2250 if (!Name)
return false;
2254 if (!getLangOpts().
CPlusPlus || ForceNoCPlusPlus) {
2260 (S->getEntity() && S->getEntity()->isTransparentContext()))
2265 FindLocalExternScope FindLocals(R);
2271 bool LeftStartingScope =
false;
2274 IEnd = IdResolver.end();
2277 if (NameKind == LookupRedeclarationWithLinkage) {
2280 if (!LeftStartingScope && !S->isDeclScope(*I))
2281 LeftStartingScope =
true;
2285 if (LeftStartingScope && !((*I)->hasLinkage())) {
2290 else if (NameKind == LookupObjCImplicitSelfParam &&
2291 !isa<ImplicitParamDecl>(*I))
2301 while (S && !S->isDeclScope(D))
2316 for (++LastI; LastI != IEnd; ++LastI) {
2319 if (!S->isDeclScope(*LastI))
2341 if (CppLookupName(R, S))
2348 if (AllowBuiltinCreation && LookupBuiltin(R))
2387 assert(StartDC->
isFileContext() &&
"start context is not a file context");
2400 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
2402 Queue.push_back(ND);
2409 bool FoundTag =
false;
2410 bool FoundNonTag =
false;
2415 while (!Queue.empty()) {
2420 bool UseLocal = !R.
empty();
2450 Queue.push_back(Nom);
2455 if (FoundTag && FoundNonTag)
2487 bool InUnqualifiedLookup) {
2488 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
2494 assert((!isa<TagDecl>(LookupCtx) ||
2496 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
2497 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
2498 "Declaration context must already be complete!");
2500 struct QualifiedLookupInScope {
2508 ~QualifiedLookupInScope() {
2509 Context->setUseQualifiedLookup(oldVal);
2513 CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
2528 Name.getCXXNameType()->isDependentType()) {
2591 for (Path.Decls = BaseRecord->
lookup(Name).
begin();
2592 Path.Decls != Path.Decls.
end(); ++Path.Decls) {
2593 if ((*Path.Decls)->isInIdentifierNamespace(IDNS))
2600 Paths.setOrigin(LookupRec);
2613 int SubobjectNumber = 0;
2619 if ((*I)->isInIdentifierNamespace(IDNS) && (*I)->isCXXInstanceMember())
2631 using Result =
const void *;
2633 auto Next = [&](Iterator &It, Iterator
End) -> Result {
2647 if (TemplateNameLookup)
2648 if (
auto *TD = getAsTemplateNameDecl(ND))
2656 return T.getCanonicalType().getAsOpaquePtr();
2666 Iterator AIt = A, BIt = B, AEnd, BEnd;
2668 Result AResult = Next(AIt, AEnd);
2669 Result BResult = Next(BIt, BEnd);
2670 if (!AResult && !BResult)
2672 if (!AResult || !BResult)
2674 if (AResult != BResult) {
2677 llvm::SmallDenseMap<Result, bool, 32> AResults;
2678 for (; AResult; AResult = Next(AIt, AEnd))
2679 AResults.insert({AResult,
false});
2681 for (; BResult; BResult = Next(BIt, BEnd)) {
2682 auto It = AResults.find(BResult);
2683 if (It == AResults.end())
2690 return AResults.size() == Found;
2696 Path != PathEnd; ++Path) {
2701 SubobjectAccess =
std::min(SubobjectAccess, Path->Access);
2704 if (SubobjectType.isNull()) {
2711 if (SubobjectType !=
2719 if (HasOnlyStaticMembers(Path->Decls) &&
2720 HasSameDeclarations(Paths.begin()->Decls, Path->Decls))
2723 R.setAmbiguousBaseSubobjectTypes(Paths);
2737 if (HasOnlyStaticMembers(Path->Decls))
2742 R.setAmbiguousBaseSubobjects(Paths);
2753 if (
NamedDecl *ND = R.getAcceptableDecl(*I))
2805 QualType ObjectType,
bool AllowBuiltinCreation,
2806 bool EnteringContext) {
2813 bool IsDependent =
false;
2814 if (!ObjectType.
isNull()) {
2817 assert((!SS || SS->
isEmpty()) &&
2818 "ObjectType and scope specifier cannot coexist");
2824 "Caller should have completed object type");
2843 return LookupName(R, S, AllowBuiltinCreation);
2850 else if (IsDependent)
2872 for (
const auto &BaseSpec :
Class->bases()) {
2881 for (
auto I = Result.begin(), E = Result.end(); I != E; ++I) {
2887 Result.suppressDiagnostics();
2901 assert(Result.isAmbiguous() &&
"Lookup result must be ambiguous");
2905 SourceRange LookupRange = Result.getContextRange();
2907 switch (Result.getAmbiguityKind()) {
2910 QualType SubobjectType = Paths->front().back().Base->getType();
2911 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2916 while (isa<CXXMethodDecl>(*Found) &&
2917 cast<CXXMethodDecl>(*Found)->isStatic())
2920 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2925 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2926 << Name << LookupRange;
2929 std::set<const NamedDecl *> DeclsPrinted;
2931 PathEnd = Paths->end();
2932 Path != PathEnd; ++Path) {
2936 if (DeclsPrinted.insert(D).second) {
2939 << TD->getUnderlyingType();
2951 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2955 for (
auto *D : Result)
2956 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2957 TagDecls.insert(TD);
2958 Diag(TD->getLocation(), diag::note_hidden_tag);
2961 for (
auto *D : Result)
2962 if (!isa<TagDecl>(D))
2968 if (TagDecls.count(F.
next()))
2976 Diag(NameLoc, diag::err_using_placeholder_variable) << Name << LookupRange;
2978 for (
auto *D : Result) {
2988 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2990 for (
auto *D : Result)
2998 struct AssociatedLookup {
3002 : S(S), Namespaces(Namespaces), Classes(Classes),
3003 InstantiationLoc(InstantiationLoc) {
3008 return ClassesTransitive.insert(RD);
3076 DeclContext *Ctx = ClassTemplate->getDeclContext();
3077 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3078 Result.Classes.insert(EnclosingClass);
3108 if (
Class->getDeclName() == Result.S.VAListTagName)
3121 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3122 Result.Classes.insert(EnclosingClass);
3137 = dyn_cast<ClassTemplateSpecializationDecl>(
Class)) {
3138 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
3139 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3140 Result.Classes.insert(EnclosingClass);
3145 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
3151 if (!Result.addClassTransitive(
Class))
3155 if (!Result.S.isCompleteType(Result.InstantiationLoc,
3156 Result.S.Context.getRecordType(
Class)))
3162 Bases.push_back(
Class);
3163 while (!Bases.empty()) {
3165 Class = Bases.pop_back_val();
3168 for (
const auto &
Base :
Class->bases()) {
3179 if (Result.addClassTransitive(BaseDecl)) {
3186 Bases.push_back(BaseDecl);
3214 #define TYPE(Class, Base)
3215 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
3216 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3217 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3218 #define ABSTRACT_TYPE(Class, Base)
3219 #include "clang/AST/TypeNodes.inc"
3232 case Type::ConstantArray:
3233 case Type::IncompleteArray:
3234 case Type::VariableArray:
3235 T = cast<ArrayType>(
T)->getElementType().getTypePtr();
3250 cast<CXXRecordDecl>(cast<RecordType>(
T)->getDecl());
3260 EnumDecl *Enum = cast<EnumType>(
T)->getDecl();
3263 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
3264 Result.Classes.insert(EnclosingClass);
3275 case Type::FunctionProto: {
3278 Queue.push_back(Arg.getTypePtr());
3282 case Type::FunctionNoProto: {
3297 case Type::MemberPointer: {
3301 Queue.push_back(MemberPtr->
getClass());
3309 case Type::BlockPointer:
3315 case Type::LValueReference:
3316 case Type::RValueReference:
3322 case Type::ExtVector:
3323 case Type::ConstantMatrix:
3330 case Type::DeducedTemplateSpecialization:
3336 case Type::ObjCObject:
3337 case Type::ObjCInterface:
3338 case Type::ObjCObjectPointer:
3345 T = cast<AtomicType>(
T)->getValueType().getTypePtr();
3348 T = cast<PipeType>(
T)->getElementType().getTypePtr();
3352 case Type::ArrayParameter:
3358 T = Queue.pop_back_val();
3373 AssociatedNamespaces.clear();
3374 AssociatedClasses.clear();
3376 AssociatedLookup Result(*
this, InstantiationLoc,
3377 AssociatedNamespaces, AssociatedClasses);
3386 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
3387 Expr *Arg = Args[ArgIdx];
3435 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
3441 bool ConstArg,
bool VolatileArg,
bool RValueThis,
3442 bool ConstThis,
bool VolatileThis) {
3444 "doing special member lookup into record that isn't fully complete");
3446 if (RValueThis || ConstThis || VolatileThis)
3449 "constructors and destructors always have unqualified lvalue this");
3450 if (ConstArg || VolatileArg)
3453 "parameter-less special members can't have qualified arguments");
3458 llvm::FoldingSetNodeID
ID;
3460 ID.AddInteger(llvm::to_underlying(
SM));
3461 ID.AddInteger(ConstArg);
3462 ID.AddInteger(VolatileArg);
3463 ID.AddInteger(RValueThis);
3464 ID.AddInteger(ConstThis);
3465 ID.AddInteger(VolatileThis);
3482 DeclareImplicitDestructor(RD);
3486 Result->setMethod(DD);
3497 Expr *Arg =
nullptr;
3508 DeclareImplicitDefaultConstructor(RD);
3517 DeclareImplicitCopyConstructor(RD);
3522 DeclareImplicitMoveConstructor(RD);
3529 DeclareImplicitCopyAssignment(RD);
3534 DeclareImplicitMoveAssignment(RD);
3587 "lookup for a constructor or assignment operator was empty");
3588 Result->setMethod(
nullptr);
3597 for (
NamedDecl *CandDecl : Candidates) {
3598 if (CandDecl->isInvalidDecl())
3624 CtorInfo.FoundDecl,
nullptr,
3630 assert(isa<UsingDecl>(Cand.
getDecl()) &&
3631 "illegal Kind of operator = Decl");
3638 Result->setMethod(cast<CXXMethodDecl>(Best->Function));
3643 Result->setMethod(cast<CXXMethodDecl>(Best->Function));
3648 Result->setMethod(
nullptr);
3653 Result->setMethod(
nullptr);
3665 false,
false,
false,
false,
false);
3667 return cast_or_null<CXXConstructorDecl>(Result.getMethod());
3674 "non-const, non-volatile qualifiers for copy ctor arg");
3679 return cast_or_null<CXXConstructorDecl>(Result.getMethod());
3689 return cast_or_null<CXXConstructorDecl>(Result.getMethod());
3697 if (Class->needsImplicitDefaultConstructor())
3698 DeclareImplicitDefaultConstructor(Class);
3699 if (Class->needsImplicitCopyConstructor())
3700 DeclareImplicitCopyConstructor(Class);
3701 if (getLangOpts().CPlusPlus11 && Class->needsImplicitMoveConstructor())
3702 DeclareImplicitMoveConstructor(Class);
3708 return Class->lookup(Name);
3713 unsigned Quals,
bool RValueThis,
3714 unsigned ThisQuals) {
3716 "non-const, non-volatile qualifiers for copy assignment arg");
3718 "non-const, non-volatile qualifiers for copy assignment this");
3724 return Result.getMethod();
3731 unsigned ThisQuals) {
3733 "non-const, non-volatile qualifiers for copy assignment this");
3739 return Result.getMethod();
3749 return cast_or_null<CXXDestructorDecl>(
3751 false,
false,
false)
3764 bool AllowTemplate,
bool AllowStringTemplatePack,
3768 "literal operator lookup can't be ambiguous");
3773 bool AllowCooked =
true;
3774 bool FoundRaw =
false;
3775 bool FoundTemplate =
false;
3776 bool FoundStringTemplatePack =
false;
3777 bool FoundCooked =
false;
3782 D = USD->getTargetDecl();
3791 bool IsTemplate =
false;
3792 bool IsStringTemplatePack =
false;
3793 bool IsCooked =
false;
3796 if (FD->getNumParams() == 1 &&
3797 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3799 else if (FD->getNumParams() == ArgTys.size()) {
3801 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3802 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3812 if (Params->
size() == 1) {
3835 IsStringTemplatePack =
true;
3839 if (AllowTemplate && StringLit && IsTemplate) {
3840 FoundTemplate =
true;
3842 AllowCooked =
false;
3843 AllowStringTemplatePack =
false;
3844 if (FoundRaw || FoundCooked || FoundStringTemplatePack) {
3846 FoundRaw = FoundCooked = FoundStringTemplatePack =
false;
3848 }
else if (AllowCooked && IsCooked) {
3851 AllowTemplate = StringLit;
3852 AllowStringTemplatePack =
false;
3853 if (FoundRaw || FoundTemplate || FoundStringTemplatePack) {
3857 FoundRaw = FoundTemplate = FoundStringTemplatePack =
false;
3859 }
else if (AllowRaw && IsRaw) {
3861 }
else if (AllowTemplate && IsTemplate) {
3862 FoundTemplate =
true;
3863 }
else if (AllowStringTemplatePack && IsStringTemplatePack) {
3864 FoundStringTemplatePack =
true;
3874 if (StringLit && FoundTemplate)
3885 if (FoundRaw && FoundTemplate) {
3898 if (FoundStringTemplatePack)
3902 if (DiagnoseMissing) {
3905 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3906 << (AllowTemplate || AllowStringTemplatePack);
3918 if (Old ==
nullptr || Old == New) {
3936 if (
Cursor == OldFD)
break;
3951 AssociatedNamespaces,
3965 for (
auto *NS : AssociatedNamespaces) {
3985 auto *Underlying = D;
3986 if (
auto *USD = dyn_cast<UsingShadowDecl>(D))
3987 Underlying = USD->getTargetDecl();
3989 if (!isa<FunctionDecl>(Underlying) &&
3990 !isa<FunctionTemplateDecl>(Underlying))
3996 bool Visible =
false;
4015 "bad export context");
4019 llvm::any_of(AssociatedClasses, [&](
auto *E) {
4023 if (E->getOwningModule() != FM)
4027 DeclContext *Ctx = E->getDeclContext();
4028 while (!Ctx->isFileContext() || Ctx->isInlineNamespace())
4029 Ctx = Ctx->getParent();
4047 if (AssociatedClasses.count(RD) &&
isReachable(D)) {
4056 Result.insert(Underlying);
4070 class ShadowContextRAII;
4072 class VisibleDeclsRecord {
4077 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
4082 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
4085 std::list<ShadowMap> ShadowMaps;
4090 friend class ShadowContextRAII;
4096 return !VisitedContexts.insert(Ctx).second;
4100 return VisitedContexts.count(Ctx);
4112 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
4117 class ShadowContextRAII {
4118 VisibleDeclsRecord &Visible;
4120 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
4123 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
4124 Visible.ShadowMaps.emplace_back();
4127 ~ShadowContextRAII() {
4128 Visible.ShadowMaps.pop_back();
4136 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
4137 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
4138 SM != SMEnd; ++
SM) {
4140 if (Pos ==
SM->end())
4143 for (
auto *D : Pos->second) {
4161 SM == ShadowMaps.rbegin())
4166 if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D) &&
4167 cast<UsingShadowDecl>(ND)->getIntroducer() == D)
4179 class LookupVisibleHelper {
4183 : Consumer(Consumer), IncludeDependentBases(IncludeDependentBases),
4184 LoadExternal(LoadExternal) {}
4187 bool IncludeGlobalScope) {
4191 UnqualUsingDirectiveSet UDirs(SemaRef);
4197 UDirs.visitScopeChain(Initial, S);
4203 Result.setAllowHidden(Consumer.includeHiddenDecls());
4204 if (!IncludeGlobalScope)
4206 ShadowContextRAII Shadow(
Visited);
4207 lookupInScope(Initial, Result, UDirs);
4213 Result.setAllowHidden(Consumer.includeHiddenDecls());
4214 if (!IncludeGlobalScope)
4217 ShadowContextRAII Shadow(
Visited);
4218 lookupInDeclContext(Ctx, Result,
true,
4224 bool QualifiedNameLookup,
bool InBaseClass) {
4232 Consumer.EnteredContext(Ctx);
4235 if (isa<TranslationUnitDecl>(Ctx) &&
4237 auto &S = Result.getSema();
4243 Idents.getExternalIdentifierLookup()) {
4244 std::unique_ptr<IdentifierIterator>
Iter(
External->getIdentifiers());
4245 for (StringRef Name =
Iter->Next(); !Name.empty();
4246 Name =
Iter->Next())
4251 for (
const auto &Ident : Idents) {
4256 if (
NamedDecl *ND = Result.getAcceptableDecl(*I)) {
4257 Consumer.FoundDecl(ND,
Visited.checkHidden(ND), Ctx, InBaseClass);
4268 Result.getSema().ForceDeclarationOfImplicitMembers(Class);
4272 bool Load = LoadExternal ||
4273 !(isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx));
4284 DeclsToVisit.push_back(D);
4286 for (
auto *D : DeclsToVisit)
4287 if (
auto *ND = Result.getAcceptableDecl(D)) {
4288 Consumer.FoundDecl(ND,
Visited.checkHidden(ND), Ctx, InBaseClass);
4292 DeclsToVisit.clear();
4295 if (QualifiedNameLookup) {
4296 ShadowContextRAII Shadow(
Visited);
4298 if (!Result.getSema().isVisible(I))
4300 lookupInDeclContext(I->getNominatedNamespace(), Result,
4301 QualifiedNameLookup, InBaseClass);
4307 if (!
Record->hasDefinition())
4310 for (
const auto &B :
Record->bases()) {
4315 if (!IncludeDependentBases) {
4328 RD = TD->getTemplatedDecl();
4356 ShadowContextRAII Shadow(
Visited);
4357 lookupInDeclContext(RD, Result, QualifiedNameLookup,
4365 for (
auto *Cat : IFace->visible_categories()) {
4366 ShadowContextRAII Shadow(
Visited);
4367 lookupInDeclContext(Cat, Result, QualifiedNameLookup,
4372 for (
auto *I : IFace->all_referenced_protocols()) {
4373 ShadowContextRAII Shadow(
Visited);
4374 lookupInDeclContext(I, Result, QualifiedNameLookup,
4379 if (IFace->getSuperClass()) {
4380 ShadowContextRAII Shadow(
Visited);
4381 lookupInDeclContext(IFace->getSuperClass(), Result, QualifiedNameLookup,
4387 if (IFace->getImplementation()) {
4388 ShadowContextRAII Shadow(
Visited);
4389 lookupInDeclContext(IFace->getImplementation(), Result,
4390 QualifiedNameLookup, InBaseClass);
4393 for (
auto *I :
Protocol->protocols()) {
4394 ShadowContextRAII Shadow(
Visited);
4395 lookupInDeclContext(I, Result, QualifiedNameLookup,
4399 for (
auto *I :
Category->protocols()) {
4400 ShadowContextRAII Shadow(
Visited);
4401 lookupInDeclContext(I, Result, QualifiedNameLookup,
4406 if (
Category->getImplementation()) {
4407 ShadowContextRAII Shadow(
Visited);
4408 lookupInDeclContext(
Category->getImplementation(), Result,
4409 QualifiedNameLookup,
true);
4415 UnqualUsingDirectiveSet &UDirs) {
4418 assert(!IncludeDependentBases &&
"Unsupported flag for lookupInScope");
4423 if (!S->getEntity() ||
4424 (!S->getParent() && !
Visited.alreadyVisitedContext(S->getEntity())) ||
4425 (S->getEntity())->isFunctionOrMethod()) {
4426 FindLocalExternScope FindLocals(Result);
4430 for (
Decl *D : ScopeDecls) {
4431 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
4432 if ((ND = Result.getAcceptableDecl(ND))) {
4433 Consumer.FoundDecl(ND,
Visited.checkHidden(ND),
nullptr,
false);
4449 if (Method->isInstanceMethod()) {
4451 LookupResult IvarResult(Result.getSema(), Result.getLookupName(),
4452 Result.getNameLoc(),
4455 lookupInDeclContext(IFace, IvarResult,
4470 lookupInDeclContext(Ctx, Result,
false,
4473 }
else if (!S->getParent()) {
4485 lookupInDeclContext(Entity, Result,
false,
4492 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
4493 lookupInDeclContext(
4494 const_cast<DeclContext *
>(UUE.getNominatedNamespace()), Result,
4500 ShadowContextRAII Shadow(
Visited);
4501 lookupInScope(S->getParent(), Result, UDirs);
4507 bool IncludeDependentBases;
4514 bool IncludeGlobalScope,
bool LoadExternal) {
4515 LookupVisibleHelper H(
Consumer,
false,
4517 H.lookupVisibleDecls(*
this, S,
Kind, IncludeGlobalScope);
4522 bool IncludeGlobalScope,
4523 bool IncludeDependentBases,
bool LoadExternal) {
4524 LookupVisibleHelper H(
Consumer, IncludeDependentBases, LoadExternal);
4525 H.lookupVisibleDecls(*
this, Ctx,
Kind, IncludeGlobalScope);
4540 Scope *S = CurScope;
4542 return cast<LabelDecl>(Res);
4556 assert(S &&
"Not in a function?");
4559 return cast<LabelDecl>(Res);
4577 bool EnteringContext,
4578 bool isObjCIvarLookup,
4587 for (; DI != DE; ++DI)
4597 bool AnyVisibleDecls = !NewDecls.empty();
4599 for (; DI != DE; ++DI) {
4601 if (!AnyVisibleDecls) {
4603 AnyVisibleDecls =
true;
4606 NewDecls.push_back(*DI);
4607 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
4608 NewDecls.push_back(*DI);
4611 if (NewDecls.empty())
4628 Identifiers.clear();
4658 Identifiers.push_back(II);
4685 addName(Name,
nullptr);
4691 addName(Keyword,
nullptr,
nullptr,
true);
4694 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
4698 StringRef TypoStr = Typo->
getName();
4699 unsigned MinED =
abs((
int)Name.size() - (
int)TypoStr.size());
4700 if (MinED && TypoStr.size() / MinED < 3)
4705 unsigned UpperBound = (TypoStr.size() + 2) / 3;
4706 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
4707 if (ED > UpperBound)
return;
4710 if (isKeyword) TC.makeKeyword();
4711 TC.setCorrectionRange(
nullptr, Result.getLookupNameInfo());
4718 StringRef TypoStr = Typo->
getName();
4724 if (TypoStr.size() < 3 &&
4725 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
4738 if (!CList.empty() && !CList.back().isResolved())
4741 auto RI = llvm::find_if(CList, [NewND](
const TypoCorrection &TypoCorr) {
4744 if (RI != CList.end()) {
4748 auto IsDeprecated = [](
Decl *D) {
4759 std::pair<bool, std::string> NewKey = {
4763 std::pair<bool, std::string> PrevKey = {
4764 IsDeprecated(RI->getFoundDecl()),
4767 if (NewKey < PrevKey)
4772 if (CList.empty() || Correction.
isResolved())
4773 CList.push_back(Correction);
4776 CorrectionResults.erase(std::prev(CorrectionResults.end()));
4780 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
4781 SearchNamespaces =
true;
4783 for (
auto KNPair : KnownNamespaces)
4784 Namespaces.addNameSpecifier(KNPair.first);
4786 bool SSIsTemplate =
false;
4788 (SS && SS->isValid()) ? SS->getScopeRep() :
nullptr) {
4790 SSIsTemplate =
T->
getTypeClass() == Type::TemplateSpecialization;
4796 for (
unsigned I = 0; I != Types.size(); ++I) {
4797 const auto *TI = Types[I];
4799 CD = CD->getCanonicalDecl();
4800 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
4801 !CD->isUnion() && CD->getIdentifier() &&
4802 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
4803 (CD->isBeingDefined() || CD->isCompleteDefinition()))
4804 Namespaces.addNameSpecifier(CD);
4810 if (++CurrentTCIndex < ValidatedCorrections.size())
4811 return ValidatedCorrections[CurrentTCIndex];
4813 CurrentTCIndex = ValidatedCorrections.size();
4814 while (!CorrectionResults.empty()) {
4815 auto DI = CorrectionResults.begin();
4816 if (DI->second.empty()) {
4817 CorrectionResults.erase(DI);
4821 auto RI = DI->second.begin();
4822 if (RI->second.empty()) {
4823 DI->second.erase(RI);
4824 performQualifiedLookups();
4830 ValidatedCorrections.push_back(TC);
4831 return ValidatedCorrections[CurrentTCIndex];
4834 return ValidatedCorrections[0];
4837 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4844 CorrectionValidator->IsObjCIvarLookup,
4846 switch (Result.getResultKind()) {
4856 if (TempMemberContext) {
4859 TempMemberContext =
nullptr;
4862 if (SearchNamespaces)
4863 QualifiedResults.push_back(Candidate);
4873 for (
auto *TRD : Result)
4877 if (SearchNamespaces)
4878 QualifiedResults.push_back(Candidate);
4887 void TypoCorrectionConsumer::performQualifiedLookups() {
4888 unsigned TypoLen = Typo->
getName().size();
4890 for (
const auto &NSI : Namespaces) {
4892 const Type *NSType = NSI.NameSpecifier->getAsType();
4900 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4905 TC.ClearCorrectionDecls();
4906 TC.setCorrectionSpecifier(NSI.NameSpecifier);
4907 TC.setQualifierDistance(NSI.EditDistance);
4908 TC.setCallbackDistance(0);
4913 unsigned TmpED = TC.getEditDistance(
true);
4914 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4915 TypoLen / TmpED < 3)
4919 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4925 switch (Result.getResultKind()) {
4928 if (SS && SS->isValid()) {
4929 std::string NewQualified = TC.getAsString(SemaRef.
getLangOpts());
4930 std::string OldQualified;
4931 llvm::raw_string_ostream OldOStream(OldQualified);
4933 OldOStream << Typo->
getName();
4937 if (OldOStream.str() == NewQualified)
4941 TRD != TRDEnd; ++TRD) {
4946 TC.addCorrectionDecl(*TRD);
4948 if (TC.isResolved()) {
4949 TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
4962 QualifiedResults.clear();
4965 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4967 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4969 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4970 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4978 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4979 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4986 DistanceMap[1].push_back(SI);
4989 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4991 assert(Start &&
"Building a context chain from a null context");
4992 DeclContextList Chain;
5004 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
5006 unsigned NumSpecifiers = 0;
5008 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
5011 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
5017 return NumSpecifiers;
5020 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
5023 unsigned NumSpecifiers = 0;
5024 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
5025 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
5028 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
5029 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() != C)
5031 NamespaceDeclChain.pop_back();
5035 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
5038 if (NamespaceDeclChain.empty()) {
5042 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
5044 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
5046 bool SameNameSpecifier =
false;
5047 if (llvm::is_contained(CurNameSpecifierIdentifiers, Name)) {
5048 std::string NewNameSpecifier;
5049 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
5053 SpecifierOStream.flush();
5054 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
5056 if (SameNameSpecifier || llvm::is_contained(CurContextIdentifiers, Name)) {
5060 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
5068 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
5072 llvm::ComputeEditDistance(
llvm::ArrayRef(CurNameSpecifierIdentifiers),
5076 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
5077 DistanceMap[NumSpecifiers].push_back(SI);
5086 bool EnteringContext,
5087 bool isObjCIvarLookup,
5093 if (MemberContext) {
5095 if (isObjCIvarLookup) {
5117 false, EnteringContext);
5122 if (Method->isInstanceMethod() && Method->getClassInterface() &&
5127 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
5139 bool AfterNestedNameSpecifier) {
5140 if (AfterNestedNameSpecifier) {
5153 static const char *
const CTypeSpecs[] = {
5154 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
5155 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
5156 "_Complex",
"_Imaginary",
5158 "extern",
"inline",
"static",
"typedef"
5161 for (
const auto *CTS : CTypeSpecs)
5188 static const char *
const CastableTypeSpecs[] = {
5189 "char",
"double",
"float",
"int",
"long",
"short",
5190 "signed",
"unsigned",
"void"
5192 for (
auto *kw : CastableTypeSpecs)
5211 static const char *
const CXXExprs[] = {
5212 "delete",
"new",
"operator",
"throw",
"typeid"
5214 for (
const auto *CE : CXXExprs)
5217 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
5218 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
5237 static const char *
const CStmts[] = {
5238 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
5239 for (
const auto *CS : CStmts)
5247 if (S && S->getBreakParent())
5250 if (S && S->getContinueParent())
5264 if (S && S->isClassScope()) {
5284 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
5322 locs->second.count(TypoName.
getLoc()))
5352 std::unique_ptr<CorrectionCandidateCallback> ClonedCCC = CCC.
clone();
5353 auto Consumer = std::make_unique<TypoCorrectionConsumer>(
5354 *
this, TypoName, LookupKind, S, SS, std::move(ClonedCCC), MemberContext,
5358 bool IsUnqualifiedLookup =
false;
5360 if (MemberContext) {
5365 for (
auto *I : OPT->
quals())
5368 }
else if (SS && SS->
isSet()) {
5375 IsUnqualifiedLookup =
true;
5380 bool SearchNamespaces
5382 (IsUnqualifiedLookup || (SS && SS->
isSet()));
5384 if (IsUnqualifiedLookup || SearchNamespaces) {
5395 std::unique_ptr<IdentifierIterator>
Iter(
External->getIdentifiers());
5397 StringRef Name =
Iter->Next();
5407 *
Consumer->getCorrectionValidator(),
5412 if (SearchNamespaces) {
5416 LoadedExternalKnownNamespaces =
true;
5418 for (
auto *N : ExternalKnownNamespaces)
5419 KnownNamespaces[N] =
true;
5422 Consumer->addNamespaces(KnownNamespaces);
5465 bool EnteringContext,
5467 bool RecordFailure) {
5473 MemberContext, EnteringContext, OPT))
5484 auto Consumer = makeTypoCorrectionConsumer(TypoName, LookupKind, S, SS, CCC,
5485 MemberContext, EnteringContext,
5493 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5497 unsigned ED =
Consumer->getBestEditDistance(
true);
5498 unsigned TypoLen = Typo->getName().size();
5499 if (ED > 0 && TypoLen / ED < 3)
5500 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5505 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5509 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
5513 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5517 if (!SecondBestTC ||
5523 if (ED == 0 && Result.isKeyword())
5524 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5530 }
else if (SecondBestTC && ObjCMessageReceiver) {
5536 BestTC = SecondBestTC;
5537 else if ((*
Consumer)[
"super"].front().isKeyword())
5538 BestTC = (*Consumer)[
"super"].front();
5544 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
5553 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
5600 auto Consumer = makeTypoCorrectionConsumer(TypoName, LookupKind, S, SS, CCC,
5601 MemberContext, EnteringContext,
5608 TypoName, LookupKind, S, SS, *
Consumer->getCorrectionValidator(),
5609 MemberContext, EnteringContext, OPT);
5611 Consumer->addCorrection(ExternalTypo);
5619 unsigned ED =
Consumer->getBestEditDistance(
true);
5621 if (!ExternalTypo && ED > 0 && Typo->getName().size() / ED < 3)
5624 return createDelayedTypo(std::move(
Consumer), std::move(TDG), std::move(TRC),
5632 CorrectionDecls.clear();
5634 CorrectionDecls.push_back(CDecl);
5636 if (!CorrectionName)
5641 if (CorrectionNameSpec) {
5642 std::string tmpBuffer;
5643 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
5645 PrefixOStream << CorrectionName;
5646 return PrefixOStream.str();
5661 bool HasNonType =
false;
5662 bool HasStaticMethod =
false;
5663 bool HasNonStaticMethod =
false;
5664 for (
Decl *D : candidate) {
5666 D = FTD->getTemplatedDecl();
5668 if (Method->isStatic())
5669 HasStaticMethod =
true;
5671 HasNonStaticMethod =
true;
5673 if (!isa<TypeDecl>(D))
5685 bool HasExplicitTemplateArgs,
5687 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
5688 CurContext(SemaRef.CurContext), MemberFn(ME) {
5691 !HasExplicitTemplateArgs && NumArgs == 1;
5700 for (
auto *C : candidate) {
5704 FD = FTD->getTemplatedDecl();
5705 if (!HasExplicitTemplateArgs && !FD) {
5706 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
5710 QualType ValType = cast<ValueDecl>(ND)->getType();
5716 if (FPT->getNumParams() == NumArgs)
5723 : isa<TypeDecl>(ND)) &&
5726 return NumArgs <= 1 || HasExplicitTemplateArgs || isa<CXXRecordDecl>(ND);
5738 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
5739 if (MemberFn || !MD->isStatic()) {
5742 ? dyn_cast_if_present<CXXMethodDecl>(MemberFn->
getMemberDecl())
5743 : dyn_cast_if_present<CXXMethodDecl>(CurContext);
5745 CurMD ? CurMD->
getParent()->getCanonicalDecl() :
nullptr;
5758 bool ErrorRecovery) {
5766 if (
const auto *VD = dyn_cast<VarDecl>(D))
5767 return VD->getDefinition();
5768 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
5769 return FD->getDefinition();
5770 if (
const auto *TD = dyn_cast<TagDecl>(D))
5771 return TD->getDefinition();
5772 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(D))
5773 return ID->getDefinition();
5774 if (
const auto *PD = dyn_cast<ObjCProtocolDecl>(D))
5775 return PD->getDefinition();
5776 if (
const auto *TD = dyn_cast<TemplateDecl>(D))
5777 if (
const NamedDecl *TTD = TD->getTemplatedDecl())
5791 assert(Owner &&
"definition of hidden declaration is not in a module");
5794 OwningModules.push_back(Owner);
5796 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
5805 llvm::StringRef IncludingFile) {
5806 bool IsAngled =
false;
5808 E, IncludingFile, &IsAngled);
5809 return (IsAngled ?
'<' :
'"') + Path + (IsAngled ?
'>' :
'"');
5816 assert(!Modules.empty());
5820 if (isa<NamespaceDecl>(
Decl))
5823 auto NotePrevious = [&] {
5827 Diag(DeclLoc, diag::note_unreachable_entity) << (
int)MIK;
5832 llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;
5833 for (
auto *M : Modules) {
5836 if (UniqueModuleSet.insert(M).second)
5837 UniqueModules.push_back(M);
5841 std::string HeaderName;
5852 if (!HeaderName.empty() || UniqueModules.empty()) {
5855 Diag(UseLoc, diag::err_module_unimported_use_header)
5856 << (
int)MIK <<
Decl << !HeaderName.empty() << HeaderName;
5864 Modules = UniqueModules;
5866 auto GetModuleNameForDiagnostic = [
this](
const Module *M) -> std::string {
5875 bool IsInTheSameModule =
5882 if (IsInTheSameModule)
5888 if (Modules.size() > 1) {
5889 std::string ModuleList;
5891 for (
const auto *M : Modules) {
5892 ModuleList +=
"\n ";
5893 if (++N == 5 && N != Modules.size()) {
5894 ModuleList +=
"[...]";
5897 ModuleList += GetModuleNameForDiagnostic(M);
5900 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5901 << (
int)MIK <<
Decl << ModuleList;
5904 Diag(UseLoc, diag::err_module_unimported_use)
5905 << (
int)MIK <<
Decl << GetModuleNameForDiagnostic(Modules[0]);
5930 bool ErrorRecovery) {
5939 assert(
Decl &&
"import required but no declaration to import");
5947 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5954 if (
const auto *FD = dyn_cast_if_present<FunctionDecl>(ChosenDecl);
5955 FD && FD->getBuiltinID() &&
5956 PrevNote.
getDiagID() == diag::note_previous_decl &&
5958 ChosenDecl =
nullptr;
5962 Diag(ChosenDecl->getLocation(), PrevNote)
5963 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5970 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5971 TypoDiagnosticGenerator TDG,
5972 TypoRecoveryCallback TRC,
5974 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5976 auto &
State = DelayedTypos[TE];
5977 State.Consumer = std::move(TCC);
5978 State.DiagHandler = std::move(TDG);
5979 State.RecoveryHandler = std::move(TRC);
5986 auto Entry = DelayedTypos.find(TE);
5987 assert(Entry != DelayedTypos.end() &&
5988 "Failed to get the state for a TypoExpr!");
5989 return Entry->second;
5993 DelayedTypos.erase(TE);
6015 if (cast<Decl>(
CurContext)->getOwningModuleForLinkage(
true))
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....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::FileManager interface and associated types.
llvm::DenseSet< const void * > Visited
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
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 DeclContext * findOuterContext(Scope *S)
Find the outer declaration context from this scope.
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D, unsigned IDNS)
Retrieve the visible declaration corresponding to D, if any.
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 #incl...
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
static QualType getOpenCLTypedefType(Sema &S, llvm::StringRef Name)
Lookup an OpenCL typedef type.
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 bool isVersionInMask(const LangOptions &O, unsigned Mask)
bool isVersionInMask< OpenCLBuiltin >(const LangOptions &LO, unsigned Mask)
static void GetProgModelBuiltinFctOverloads(ASTContext &Context, unsigned GenTypeMaxCnt, std::vector< QualType > &FunctionList, SmallVector< QualType, 1 > &RetTypes, SmallVector< SmallVector< QualType, 1 >, 5 > &ArgTypes, bool IsVariadic)
Create a list of the candidate function overloads for a ProgModel builtin function.
static const NamedDecl * getDefinitionToImport(const NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
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 Module * getDefiningModule(Sema &S, Decl *Entity)
Find the module in which the given declaration was defined.
static void InsertBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR, IdentifierInfo *II, const unsigned FctIndex, const unsigned Len, std::function< void(const typename ProgModel::BuiltinStruct &, FunctionDecl &)> ProgModelFinalizer)
When trying to resolve a function name, if ProgModel::isBuiltin() returns a non-null <Index,...
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
static void GetQualTypesForProgModelBuiltin(Sema &S, const typename ProgModel::BuiltinStruct &Builtin, unsigned &GenTypeMaxCnt, SmallVector< QualType, 1 > &RetTypes, SmallVector< SmallVector< QualType, 1 >, 5 > &ArgTypes)
Get the QualType instances of the return type and arguments for a ProgModel builtin function signatur...
static clang::QualType GetFloat16Type(clang::ASTContext &Context)
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 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 const unsigned MaxTypoDistanceResultSets
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier *NNS, SmallVectorImpl< const IdentifierInfo * > &Identifiers)
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)
bool isVersionInMask< SPIRVBuiltin >(const LangOptions &LO, unsigned Mask)
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.
const NestedNameSpecifier * Specifier
__DEVICE__ long long abs(long long __n)
__DEVICE__ int min(int __a, int __b)
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 ...
const clang::PrintingPolicy & getPrintingPolicy() const
const SmallVectorImpl< Type * > & getTypes() const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getEnumType(const EnumDecl *Decl) const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
void setObjCSuperType(QualType ST)
const LangOptions & getLangOpts() const
ArrayRef< Module * > getModulesWithMergedDefinition(const NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
TranslationUnitDecl * getTranslationUnitDecl() 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...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
std::list< CXXBasePath >::iterator paths_iterator
std::list< CXXBasePath >::const_iterator const_paths_iterator
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.
base_class_iterator bases_end()
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...
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...
base_class_iterator bases_begin()
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.
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.
CXXRecordDecl * getDefinition() const
Represents a C++ nested-name-specifier or a global scope specifier.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
SourceRange getRange() const
bool isSet() const
Deprecated.
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
virtual std::unique_ptr< CorrectionCandidateCallback > clone()=0
Clone this CorrectionCandidateCallback.
bool WantRemainingKeywords
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
The results of name lookup within a DeclContext.
DeclListNode::iterator iterator
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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.
bool isFileContext() const
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 * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
ASTContext & getParentASTContext() const
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
lookups_range lookups() const
bool shouldUseQualifiedLookup() const
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
void setUseQualifiedLookup(bool use=true) const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
bool isInlineNamespace() const
bool isFunctionOrMethod() const
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 encloses the declaration context DC.
Decl - This represents one declaration (or definition), e.g.
bool isTemplateDecl() const
returns true if this declaration is a template
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.
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.
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.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
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...
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
TranslationUnitDecl * getTranslationUnitDecl()
bool hasTagIdentifierNamespace() const
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
DeclContext * getDeclContext()
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.
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.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
@ 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.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
bool hasFatalErrorOccurred() const
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.
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.
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.
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, Expr *TrailingRequiresClause=nullptr)
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.
ArrayRef< QualType > param_types() const
ExtProtoInfo getExtProtoInfo() 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
Provides lookups to, and iteration over, IdentiferInfo objects.
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.
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
iterator end()
Returns the end iterator.
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ 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.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
void setShadowed()
Note that we found and ignored a declaration while performing 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 setFindLocalExtern(bool FindLocalExtern)
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
void setContextRange(SourceRange SR)
Sets a 'context' source range.
static bool isAcceptable(Sema &SemaRef, NamedDecl *D, Sema::AcceptableKind Kind)
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
bool isTemplateNameLookup() const
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type.
DeclClass * getAsSingle() const
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.
Filter makeFilter()
Create a filter for this result set.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
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.
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
LookupResultKind getResultKind() const
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.
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
@ AmbiguousBaseSubobjectTypes
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
@ 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...
@ AmbiguousBaseSubobjects
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
const Type * getClass() const
QualType getPointeeType() const
virtual bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)=0
Check global module index for missing imports.
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.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this 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?
This represents a decl that may have a name.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
bool isPlaceholderVar(const LangOptions &LangOpts) const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
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>::".
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
ObjCCategoryDecl - Represents a category declaration.
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.
Represents an Objective-C protocol declaration.
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.
llvm::iterator_range< decls_iterator > decls() const
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
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.
HeaderSearch & getHeaderSearchInfo() const
bool isMacroDefined(StringRef Id)
OptionalFileEntryRef getHeaderToIncludeForDiagnostics(SourceLocation IncLoc, SourceLocation MLoc)
We want to produce a diagnostic at location IncLoc concerning an unreachable effect at location MLoc ...
A (possibly-)qualified type.
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base 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 struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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.
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.
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.
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.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
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.
IdentifierInfo * getSuperIdentifier() const
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
bool hasMergedDefinitionInCurrentModule(const NamedDecl *Def)
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations,...
Preprocessor & getPreprocessor() const
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.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
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...
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...
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
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...
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
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...
const LangOptions & getLangOpts() const
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
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,...
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
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.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
llvm::SmallVector< TypoExpr *, 2 > TypoExprs
Holds TypoExprs that are created from createDelayedTypo.
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.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
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...
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=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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...
RedeclarationKind forRedeclarationInCurContext() const
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
ASTContext & getASTContext() const
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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.
FPOptions & getCurFPFeatures()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
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...
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
DiagnosticsEngine & Diags
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.
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
llvm::BumpPtrAllocator BumpAlloc
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
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)
sema::FunctionScopeInfo * getCurFunction() const
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
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.
DiagnosticsEngine & getDiagnostics() const
IdentifierResolver IdResolver
const TypoExprState & getTypoExprState(TypoExpr *TE) const
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.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
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.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
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.
@ 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.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
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() const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
Represents a declaration of a type.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
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...
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
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.
ArrayRef< PartialDiagnostic > getExtraDiagnostics() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
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
IdentifierInfo * getCorrectionAsIdentifierInfo() 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)
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.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setRequiresImport(bool Req)
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
std::string getQuoted(const LangOptions &LO) const
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
A set of unresolved declarations.
void append(iterator I, iterator E)
The iterator over UnresolvedSets.
Represents C++ using-directive.
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...
bool Load(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ 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...
std::unique_ptr< sema::RISCVIntrinsicManager > CreateRISCVIntrinsicManager(Sema &S)
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
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.
const FunctionProtoType * T
@ Success
Template argument deduction was successful.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ EST_None
no exception specification
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
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.