55 #include "llvm/ADT/APSInt.h"
56 #include "llvm/ADT/ArrayRef.h"
57 #include "llvm/ADT/STLExtras.h"
58 #include "llvm/ADT/SmallVector.h"
59 #include "llvm/ADT/StringRef.h"
60 #include "llvm/ADT/StringSwitch.h"
61 #include "llvm/Support/Casting.h"
62 #include "llvm/Support/ErrorHandling.h"
63 #include "llvm/Support/raw_ostream.h"
64 #include "llvm/TargetParser/Triple.h"
73 #include <type_traits>
75 using namespace clang;
90 if (
auto *ND = dyn_cast_if_present<NamedDecl>(TheDecl)) {
104 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
106 DeclContext(TranslationUnit), redeclarable_base(ctx), Ctx(ctx) {}
168 Kind.IgnoreExplicitVisibility =
true;
174 assert(!
kind.IgnoreExplicitVisibility &&
175 "asking for explicit visibility when we shouldn't be");
176 return D->getExplicitVisibility(
kind.getExplicitVisibilityKind());
182 return isa<TypeDecl>(
D) ||
183 isa<ClassTemplateDecl>(
D) ||
184 isa<ObjCInterfaceDecl>(
D);
190 static std::enable_if_t<!std::is_base_of_v<RedeclarableTemplateDecl, T>,
bool>
193 D->getMemberSpecializationInfo()) {
194 return member->isExplicitSpecialization();
203 return D->isMemberSpecialization();
210 switch (
attr->getVisibility()) {
218 llvm_unreachable(
"bad visibility kind");
222 static std::optional<Visibility>
227 if (
const auto *A =
D->
getAttr<TypeVisibilityAttr>()) {
233 if (
const auto *A =
D->
getAttr<VisibilityAttr>()) {
250 LinkageInfo LinkageComputer::getLVForTemplateParameterList(
256 if (isa<TemplateTypeParmDecl>(
P))
263 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
265 if (!NTTP->isExpandedParameterPack()) {
266 if (!NTTP->getType()->isDependentType()) {
267 LV.
merge(getLVForType(*NTTP->getType(), computation));
273 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
275 if (!
type->isDependentType())
283 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
286 if (!TTP->isExpandedParameterPack()) {
287 LV.
merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),
293 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
295 LV.
merge(getLVForTemplateParameterList(
296 TTP->getExpansionTemplateParameters(i), computation));
306 while (DC->
getDeclKind() != Decl::TranslationUnit) {
307 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
308 Ret = cast<Decl>(DC);
325 switch (Arg.getKind()) {
332 LV.
merge(getLVForType(*Arg.getAsType(), computation));
347 LV.
merge(getLVForValue(Arg.getAsStructuralValue(), computation));
353 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
358 LV.
merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));
361 llvm_unreachable(
"bad template argument kind");
370 return getLVForTemplateArgumentList(TArgs.
asArray(), computation);
382 return !fn->
hasAttr<VisibilityAttr>();
392 void LinkageComputer::mergeTemplateLV(
396 bool considerVisibility =
413 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
466 void LinkageComputer::mergeTemplateLV(
489 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
490 if (considerVisibility)
523 void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV,
540 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
541 if (considerVisibility)
549 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
552 const auto *FD = dyn_cast<FunctionDecl>(
D);
558 = FD->getTemplateSpecializationInfo()) {
561 FD->getMemberSpecializationInfo()) {
562 TSK = MSI->getTemplateSpecializationKind();
575 const T *
First =
D->getFirstDecl();
576 return First->isInExternCContext();
581 if (!SD->hasBraces())
591 if (
auto *TD = dyn_cast<TemplateDecl>(
D))
592 D = TD->getTemplatedDecl();
594 if (
auto *VD = dyn_cast<VarDecl>(
D))
595 return VD->getStorageClass();
596 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
597 return FD->getStorageClass();
603 LinkageComputer::getLVForNamespaceScopeDecl(
const NamedDecl *
D,
605 bool IgnoreVarTypeLinkage) {
607 "Not a name having namespace scope");
609 const auto *Var = dyn_cast<VarDecl>(
D);
616 (Context.
getLangOpts().C23 && Var && Var->isConstexpr())) {
637 if (Context.
getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&
638 !Var->getType().isVolatileQualified() && !Var->isInline() &&
642 if (auto *M = Var->getOwningModule())
643 return M->isInterfaceOrPartition() || M->isImplicitGlobalModule();
646 !isa<VarTemplateSpecializationDecl>(Var) &&
647 !Var->getDescribedVarTemplate()) {
652 if (Var->getStorageClass() !=
SC_Extern &&
661 Var->getStorageClass() ==
SC_None)
667 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
D)) {
669 const VarDecl *VD = IFD->getVarDecl();
670 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
671 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
673 assert(!isa<FieldDecl>(
D) &&
"Didn't expect a FieldDecl!");
678 const auto *Var = dyn_cast<VarDecl>(
D);
679 const auto *
Func = dyn_cast<FunctionDecl>(
D);
707 !isa<TranslationUnitDecl>(DC);
709 const auto *ND = dyn_cast<NamespaceDecl>(DC);
711 if (std::optional<Visibility> Vis =
751 if (
const auto *Var = dyn_cast<VarDecl>(
D)) {
775 !IgnoreVarTypeLinkage) {
776 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
793 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
794 mergeTemplateLV(LV, spec, computation);
798 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(
D)) {
814 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Function)))
830 TypeAsWritten = TSI->getType();
839 =
Function->getTemplateSpecializationInfo()) {
840 mergeTemplateLV(LV, Function, specInfo, computation);
849 }
else if (
const auto *Tag = dyn_cast<TagDecl>(
D)) {
851 if (!
Tag->hasNameForLinkage())
857 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
858 mergeTemplateLV(LV, spec, computation);
863 }
else if (isa<EnumConstantDecl>(
D)) {
871 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(
D)) {
882 }
else if (isa<NamespaceDecl>(
D)) {
887 }
else if (isa<ObjCInterfaceDecl>(
D)) {
890 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(
D)) {
893 if (!TD->getAnonDeclWithTypedefName(
true))
896 }
else if (isa<MSGuidDecl>(
D)) {
914 LinkageComputer::getLVForClassMember(
const NamedDecl *
D,
916 bool IgnoreVarTypeLinkage) {
927 if (!(isa<CXXMethodDecl>(
D) ||
930 isa<IndirectFieldDecl>(
D) ||
932 isa<TemplateDecl>(
D)))
970 const NamedDecl *explicitSpecSuppressor =
nullptr;
972 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
975 QualType TypeAsWritten = MD->getType();
977 TypeAsWritten = TSI->getType();
984 = MD->getTemplateSpecializationInfo()) {
985 mergeTemplateLV(LV, MD, spec, computation);
987 explicitSpecSuppressor = MD;
989 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
992 explicitSpecSuppressor = MD;
1003 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(MD)))
1006 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(
D)) {
1007 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
1008 mergeTemplateLV(LV, spec, computation);
1010 explicitSpecSuppressor = spec;
1018 explicitSpecSuppressor = RD;
1022 }
else if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
1023 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
1024 mergeTemplateLV(LV, spec, computation);
1028 if (!IgnoreVarTypeLinkage) {
1038 explicitSpecSuppressor = VD;
1042 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(
D)) {
1043 bool considerVisibility =
1051 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
1059 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
1063 bool considerClassVisibility =
true;
1064 if (explicitSpecSuppressor &&
1069 considerClassVisibility =
false;
1077 void NamedDecl::anchor() {}
1100 if (isa<FieldDecl>(
this))
1102 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
this)) {
1106 const VarDecl *VD = IFD->getVarDecl();
1110 if (
const auto *VD = dyn_cast<VarDecl>(
this)) {
1111 if (isa<ParmVarDecl>(VD))
1117 if (
const auto *BD = dyn_cast<BindingDecl>(
this);
1119 const VarDecl *VD = BD->getHoldingVar();
1151 if (
auto *VD = dyn_cast<VarDecl>(
this))
1154 if (
auto *FD = dyn_cast<FunctionDecl>(
this))
1155 if (FD->isExternC())
1167 if (
name.front() ==
'C')
1168 if (
name ==
"CFStringCreateWithFormat" ||
1169 name ==
"CFStringCreateWithFormatAndArguments" ||
1170 name ==
"CFStringAppendFormat" ||
1171 name ==
"CFStringAppendFormatAndArguments")
1195 llvm_unreachable(
"unexpected module ownership kind");
1214 !isa<NamespaceDecl>(
this))
1224 static std::optional<Visibility>
1227 bool IsMostRecent) {
1236 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1238 if (InstantiatedFrom)
1245 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1249 while (TD !=
nullptr) {
1251 if (Vis != std::nullopt)
1253 TD = TD->getPreviousDecl();
1255 return std::nullopt;
1259 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1261 if (MostRecent != ND)
1265 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1266 if (Var->isStaticDataMember()) {
1268 if (InstantiatedFrom)
1272 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1273 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1276 return std::nullopt;
1279 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1284 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1290 if (InstantiatedFrom)
1293 return std::nullopt;
1297 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1300 return std::nullopt;
1303 std::optional<Visibility>
1314 Owner = dyn_cast<NamedDecl>(DC);
1315 else if (isa<ParmVarDecl>(ContextDecl))
1318 else if (isa<ImplicitConceptSpecializationDecl>(ContextDecl)) {
1323 Owner = cast<NamedDecl>(ContextDecl);
1333 auto *VD = dyn_cast<VarDecl>(Owner);
1349 if (
const auto *Function = dyn_cast<FunctionDecl>(
D)) {
1350 if (
Function->isInAnonymousNamespace() &&
1360 if (std::optional<Visibility> Vis =
1372 if (
const auto *Var = dyn_cast<VarDecl>(
D)) {
1373 if (Var->hasExternalStorage()) {
1381 if (std::optional<Visibility> Vis =
1396 if (!Var->isStaticLocal())
1409 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1410 if (!BD->getBlockManglingNumber())
1413 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),
1414 BD->getBlockManglingContextDecl(), computation);
1416 const auto *FD = cast<FunctionDecl>(OuterD);
1417 if (!FD->isInlined() &&
1427 !Context.
getLangOpts().VisibilityInlinesHiddenStaticLocalVar) {
1428 assert(cast<VarDecl>(
D)->isStaticLocal());
1432 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1452 bool IgnoreVarTypeLinkage) {
1454 if (
D->
hasAttr<InternalLinkageAttr>())
1469 case Decl::ImplicitParam:
1471 case Decl::NamespaceAlias:
1474 case Decl::UsingEnum:
1475 case Decl::UsingShadow:
1476 case Decl::UsingDirective:
1479 case Decl::EnumConstant:
1486 case Decl::TypeAlias:
1489 if (!cast<TypedefNameDecl>(
D)
1490 ->getAnonDeclWithTypedefName(
true))
1494 case Decl::TemplateTemplateParm:
1495 case Decl::NonTypeTemplateParm:
1496 case Decl::ObjCAtDefsField:
1497 case Decl::ObjCCategory:
1498 case Decl::ObjCCategoryImpl:
1499 case Decl::ObjCCompatibleAlias:
1500 case Decl::ObjCImplementation:
1501 case Decl::ObjCMethod:
1502 case Decl::ObjCProperty:
1503 case Decl::ObjCPropertyImpl:
1504 case Decl::ObjCProtocol:
1507 case Decl::CXXRecord: {
1508 const auto *
Record = cast<CXXRecordDecl>(
D);
1509 if (
Record->isLambda()) {
1510 if (
Record->hasKnownLambdaInternalLinkage() ||
1511 !
Record->getLambdaManglingNumber()) {
1516 return getLVForClosure(
1517 Record->getDeclContext()->getRedeclContext(),
1518 Record->getLambdaContextDecl(), computation);
1524 case Decl::TemplateParamObject: {
1527 auto *TPO = cast<TemplateParamObjectDecl>(
D);
1528 LinkageInfo LV = getLVForType(*TPO->getType(), computation);
1529 LV.
merge(getLVForValue(TPO->getValue(), computation));
1536 return getLVForNamespaceScopeDecl(
D, computation, IgnoreVarTypeLinkage);
1546 return getLVForClassMember(
D, computation, IgnoreVarTypeLinkage);
1560 return getLVForLocalDecl(
D, computation);
1571 if (
D->
hasAttr<InternalLinkageAttr>())
1577 if (std::optional<LinkageInfo> LI = lookup(
D, computation))
1585 cache(
D, computation, LV);
1592 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1600 auto *
T = cast<NamedDecl>(I);
1603 if (!
T->isInvalidDecl() &&
T->hasCachedLinkage()) {
1625 if (isa<NamespaceDecl>(
this))
1657 llvm_unreachable(
"unknown module kind");
1661 Name.
print(OS, Policy);
1669 std::string QualName;
1670 llvm::raw_string_ostream OS(QualName);
1672 WithGlobalNsPrefix);
1681 bool WithGlobalNsPrefix)
const {
1694 llvm::raw_svector_ostream NameOS(NameBuffer);
1696 if (NameBuffer.empty())
1697 OS <<
"(anonymous)";
1709 bool WithGlobalNsPrefix)
const {
1714 if (
auto *MD = dyn_cast<ObjCMethodDecl>(
this)) {
1715 if (
auto *
ID = MD->getClassInterface())
1717 }
else if (
auto *PD = dyn_cast<ObjCPropertyDecl>(
this)) {
1718 if (
auto *MD = PD->getGetterMethodDecl())
1719 if (
auto *
ID = MD->getClassInterface())
1721 }
else if (
auto *
ID = dyn_cast<ObjCIvarDecl>(
this)) {
1722 if (
auto *CI =
ID->getContainingInterface())
1730 ContextsTy Contexts;
1736 if (
P.SuppressUnwrittenScope && isa<NamespaceDecl>(Ctx) &&
1737 cast<NamespaceDecl>(Ctx)->isAnonymousNamespace())
1742 cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(NameInScope))
1746 const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx);
1750 Contexts.push_back(Ctx);
1754 if (WithGlobalNsPrefix)
1757 for (
const DeclContext *DC : llvm::reverse(Contexts)) {
1758 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1759 OS << Spec->getName();
1763 Spec->getSpecializedTemplate()->getTemplateParameters());
1764 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1765 if (ND->isAnonymousNamespace()) {
1766 OS << (
P.MSVCFormatting ?
"`anonymous namespace\'"
1767 :
"(anonymous namespace)");
1770 }
else if (
const auto *RD = dyn_cast<RecordDecl>(DC)) {
1771 if (!RD->getIdentifier())
1772 OS <<
"(anonymous " << RD->getKindName() <<
')';
1775 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1777 if (FD->hasWrittenPrototype())
1778 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1782 unsigned NumParams = FD->getNumParams();
1783 for (
unsigned i = 0; i < NumParams; ++i) {
1786 OS << FD->getParamDecl(i)->getType().stream(
P);
1796 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1809 OS << *cast<NamedDecl>(DC);
1817 bool Qualified)
const {
1830 #define DECL(Type, Base) \
1832 return isRedeclarableImpl((Type##Decl *)nullptr);
1833 #define ABSTRACT_DECL(DECL)
1834 #include "clang/AST/DeclNodes.inc"
1836 llvm_unreachable(
"unknown decl kind");
1840 bool IsKnownNewer)
const {
1853 if (isa<ObjCMethodDecl>(
this))
1858 if (isa<ParmVarDecl>(
this))
1870 if (
const auto *UD = dyn_cast<UsingDecl>(
this)) {
1874 cast<UsingDecl>(OldD)->getQualifier());
1876 if (
const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this)) {
1880 cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
1919 llvm_unreachable(
"Linkage hasn't been computed!");
1926 llvm_unreachable(
"Non-formal linkage is not allowed here!");
1931 llvm_unreachable(
"Unhandled Linkage enum");
1934 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1936 if (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1937 ND = UD->getTargetDecl();
1939 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1940 return AD->getClassInterface();
1942 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1943 return AD->getNamespace();
1953 if (isa<UsingShadowDecl>(
D))
1954 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
1956 if (isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D) || isa<MSPropertyDecl>(
D))
1958 if (
const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
D->
getAsFunction()))
1959 return MD->isInstance();
1967 template <
typename DeclT>
1969 if (
decl->getNumTemplateParameterLists() > 0)
1970 return decl->getTemplateParameterList(0)->getTemplateLoc();
1971 return decl->getInnerLocStart();
1989 if (!hasExtInfo()) {
1995 getExtInfo()->TInfo = savedTInfo;
1998 getExtInfo()->QualifierLoc = QualifierLoc;
1999 }
else if (hasExtInfo()) {
2001 getExtInfo()->QualifierLoc = QualifierLoc;
2006 assert(TrailingRequiresClause);
2008 if (!hasExtInfo()) {
2014 getExtInfo()->TInfo = savedTInfo;
2017 getExtInfo()->TrailingRequiresClause = TrailingRequiresClause;
2022 assert(!TPLists.empty());
2024 if (!hasExtInfo()) {
2030 getExtInfo()->TInfo = savedTInfo;
2033 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
2051 case Type::BlockPointer:
2054 case Type::MemberPointer:
2057 case Type::LValueReference:
2058 case Type::RValueReference:
2061 case Type::PackExpansion:
2062 QT = cast<PackExpansionType>(
T)->getPattern();
2065 case Type::ConstantArray:
2066 case Type::DependentSizedArray:
2067 case Type::IncompleteArray:
2068 case Type::VariableArray:
2069 case Type::FunctionProto:
2070 case Type::FunctionNoProto:
2082 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
2096 if (!TPLists.empty()) {
2117 llvm_unreachable(
"Invalid storage class");
2126 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(
unsigned),
2127 "VarDeclBitfields too large!");
2129 "ParmVarDeclBitfields too large!");
2131 "NonParmVarDeclBitfields too large!");
2140 return new (C, DC)
VarDecl(Var, C, DC, StartL, IdL,
Id,
T, TInfo, S);
2157 if (!hasAttr<ThreadAttr>() &&
2160 hasAttr<OMPThreadPrivateDeclAttr>()))
2164 hasAttr<OMPThreadPrivateDeclAttr>())
2173 llvm_unreachable(
"Unknown thread storage class specifier!");
2187 template<
typename T>
2191 if (!
D.hasExternalFormalLinkage())
2214 template<
typename T>
2275 isa<VarTemplatePartialSpecializationDecl>(
this)))
2294 if (
const auto *SAA = getAttr<SelectAnyAttr>())
2295 if (!SAA->isInherited())
2301 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2303 !isa<VarTemplatePartialSpecializationDecl>(VTSD) &&
2304 !VTSD->IsCompleteDefinition)
2336 VarDecl *LastTentative =
nullptr;
2341 Kind =
Decl->isThisDeclarationADefinition();
2346 LastTentative =
Decl;
2349 return LastTentative;
2355 if (I->isThisDeclarationADefinition(C) ==
Definition)
2376 if (
auto Expr = I->getInit()) {
2385 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2386 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2390 return Eval->Value.isValid();
2392 return !
Init.isNull();
2399 if (
auto *S =
Init.dyn_cast<
Stmt *>())
2400 return cast<Expr>(S);
2404 return cast<Expr>(Eval->Value.get(
2405 Eval->Value.isOffset() ?
getASTContext().getExternalSource() :
nullptr));
2410 return ES->Value.getAddressOfPointer(
getASTContext().getExternalSource());
2412 return Init.getAddrOfPtr1();
2421 if (I->isThisDeclarationADefinition()) {
2448 Eval->~EvaluatedStmt();
2464 if (isa<ParmVarDecl>(
this))
2473 if (
Lang.CPlusPlus11 &&
getType()->isReferenceType())
2484 if (
getType()->isIntegralOrEnumerationType() && !
Lang.C23)
2501 const VarDecl *DefVD =
nullptr;
2503 if (!
Init ||
Init->isValueDependent() ||
getType()->isDependentType())
2549 bool IsConstantInitialization)
const {
2553 assert(!
Init->isValueDependent());
2569 bool Result =
Init->EvaluateAsInitializer(Eval->
Evaluated, Ctx,
this, Notes,
2570 IsConstantInitialization);
2576 if (IsConstantInitialization &&
2593 return Result ? &Eval->
Evaluated :
nullptr;
2606 assert(
Init &&
"no initializer");
2636 "already evaluated var value before checking for constant init");
2639 "only meaningful in C++/C23");
2641 assert(!
getInit()->isValueDependent());
2645 evaluateValueImpl(Notes,
true) && Notes.empty();
2656 return isa<PackExpansionType>(
getType());
2659 template<
typename DeclT>
2662 if (
auto *Def =
D->getDefinition())
2678 llvm::any_of(specific_attrs<AlignedAttr>(), [](
const AlignedAttr *AA) {
2679 return AA->isAlignmentDependent();
2698 if (
auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
2700 auto From = VDTemplSpec->getInstantiatedFrom();
2702 while (!VTD->isMemberSpecialization()) {
2703 auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
2712 while (!VTPSD->isMemberSpecialization()) {
2713 auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
2718 return getDefinitionOrSelf<VarDecl>(VTPSD);
2726 while (!VarTemplate->isMemberSpecialization()) {
2727 auto *NewVT = VarTemplate->getInstantiatedFromMemberTemplate();
2730 VarTemplate = NewVT;
2743 return cast<VarDecl>(MSI->getInstantiatedFrom());
2749 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2750 return Spec->getSpecializationKind();
2753 return MSI->getTemplateSpecializationKind();
2761 return MSI->getTemplateSpecializationKind();
2763 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2764 return Spec->getSpecializationKind();
2770 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2771 return Spec->getPointOfInstantiation();
2774 return MSI->getPointOfInstantiation();
2797 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&
2799 isa<IncompleteArrayType>(
getType()))
2808 !hasAttr<AlwaysDestroyAttr>()));
2824 assert(
hasInit() &&
"Expect initializer to check for flexible array init");
2826 if (!Ty || !Ty->getDecl()->hasFlexibleArrayMember())
2828 auto *List = dyn_cast<InitListExpr>(
getInit()->IgnoreParens());
2831 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
2839 assert(
hasInit() &&
"Expect initializer to check for flexible array init");
2841 if (!Ty || !Ty->getDecl()->hasFlexibleArrayMember())
2843 auto *List = dyn_cast<InitListExpr>(
getInit()->IgnoreParens());
2844 if (!List || List->getNumInits() == 0)
2846 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
2854 if (FlexibleArrayOffset + FlexibleArraySize < RL.
getSize())
2856 return FlexibleArrayOffset + FlexibleArraySize - RL.
getSize();
2870 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2872 "not a variable or static data member template specialization");
2875 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2876 Spec->setSpecializationKind(TSK);
2878 PointOfInstantiation.
isValid() &&
2879 Spec->getPointOfInstantiation().isInvalid()) {
2880 Spec->setPointOfInstantiation(PointOfInstantiation);
2882 L->InstantiationRequested(
this);
2885 MSI->setTemplateSpecializationKind(TSK);
2887 MSI->getPointOfInstantiation().isInvalid()) {
2888 MSI->setPointOfInstantiation(PointOfInstantiation);
2890 L->InstantiationRequested(
this);
2898 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2899 "Previous template or instantiation?");
2912 return new (C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc,
Id,
T, TInfo,
2919 if (
const auto *DT = dyn_cast<DecayedType>(
T))
2920 return DT->getOriginalType();
2947 if (hasAttr<NSConsumedAttr>())
2953 if (RT && RT->getDecl()->isParamDestroyedInCallee() &&
2963 "Default argument is not yet instantiated!");
2966 if (
auto *
E = dyn_cast_if_present<FullExpr>(Arg))
2967 return E->getSubExpr();
2994 llvm_unreachable(
"Invalid default argument kind.");
3004 "Wrong kind of initialization expression!");
3005 return cast_if_present<Expr>(
Init.get<
Stmt *>());
3016 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
3021 unsigned ParmVarDecl::getParameterIndexLarge()
const {
3033 bool UsesFPIntrin,
bool isInlineSpecified,
3035 Expr *TrailingRequiresClause)
3039 EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.
getInfo()) {
3069 if (TrailingRequiresClause)
3074 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
3082 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
3083 return FT->isVariadic();
3091 static constexpr
size_t Alignment =
3094 size_t Size = totalSizeToAlloc<DeclAccessPair, StringLiteral *>(
3095 Lookups.size(), DeletedMessage !=
nullptr);
3099 Info->NumLookups = Lookups.size();
3100 Info->HasDeletedMessage = DeletedMessage !=
nullptr;
3102 std::uninitialized_copy(Lookups.begin(), Lookups.end(),
3105 *Info->getTrailingObjects<
StringLiteral *>() = DeletedMessage;
3111 assert(!
FunctionDeclBits.HasDefaultedOrDeletedInfo &&
"already have this");
3112 assert(!
Body &&
"can't replace function body with defaulted function info");
3137 assert(HasDeletedMessage &&
3138 "No space to store a delete message in this DefaultedOrDeletedInfo");
3139 *getTrailingObjects<StringLiteral *>() = Message;
3149 for (
const auto *I :
redecls()) {
3150 if (I->doesThisDeclarationHaveABody()) {
3167 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
3180 return InstantiatedFrom->getFriendObjectKind() &&
3181 InstantiatedFrom->isThisDeclarationADefinition();
3188 return InstantiatedFrom->getFriendObjectKind() &&
3189 InstantiatedFrom->isThisDeclarationADefinition();
3196 bool CheckForPendingFriendDefinition)
const {
3198 if (FD->isThisDeclarationADefinition()) {
3218 if (CheckForPendingFriendDefinition &&
3219 FD->isThisDeclarationInstantiatedFromAFriendDefinition()) {
3232 assert(!Definition->FunctionDeclBits.HasDefaultedOrDeletedInfo &&
3233 "definition should not have a body");
3234 if (Definition->Body)
3235 return Definition->Body.get(
getASTContext().getExternalSource());
3251 Parent->markedVirtualFunctionPure();
3254 template<std::
size_t Len>
3257 return II && II->
isStr(Str);
3291 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
this);
3292 MD && MD->isLambdaStaticInvoker())
3293 return MD->getParent()->getLambdaCallOperator()->isImmediateFunction();
3321 return llvm::StringSwitch<bool>(
getName())
3334 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
3335 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
3336 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
3337 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
3344 if (proto->getNumParams() != 2 || proto->isVariadic())
3353 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
3357 std::optional<unsigned> *AlignmentParam,
bool *IsNothrow)
const {
3360 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
3361 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
3362 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
3363 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
3374 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 4 || FPT->isVariadic())
3379 if (FPT->getNumParams() == 1)
3382 unsigned Params = 1;
3383 QualType Ty = FPT->getParamType(Params);
3386 auto Consume = [&] {
3388 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) :
QualType();
3392 bool IsSizedDelete =
false;
3394 (
getDeclName().getCXXOverloadedOperator() == OO_Delete ||
3395 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete) &&
3397 IsSizedDelete =
true;
3406 *AlignmentParam = Params;
3429 T = TD->getDecl()->getUnderlyingType();
3432 if (II && II->
isStr(
"__hot_cold_t"))
3436 return Params == FPT->getNumParams();
3447 if (!Definition->isInlineSpecified() ||
3448 !Definition->hasAttr<AlwaysInlineAttr>())
3461 llvm_unreachable(
"Unknown GVALinkage");
3475 RD->getIdentifier()->isStr(
"destroying_delete_t");
3487 if (hasAttr<OpenCLKernelAttr>())
3497 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
3498 return Method->isStatic();
3506 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
3507 if (!Namespace->getDeclName())
3516 if (hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
3517 hasAttr<C11NoReturnAttr>())
3520 if (
auto *FnTy =
getType()->getAs<FunctionType>())
3521 return FnTy->getNoReturnAttr();
3549 if (hasAttr<TargetAttr>())
3551 if (hasAttr<TargetVersionAttr>())
3553 if (hasAttr<CPUDispatchAttr>())
3555 if (hasAttr<CPUSpecificAttr>())
3557 if (hasAttr<TargetClonesAttr>())
3572 (hasAttr<TargetAttr>() || hasAttr<TargetVersionAttr>());
3578 if (hasAttr<TargetAttr>())
3579 return getAttr<TargetAttr>()->isDefaultVersion();
3580 return hasAttr<TargetVersionAttr>() &&
3581 getAttr<TargetVersionAttr>()->isDefaultVersion();
3599 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
3600 FunTmpl->setPreviousDecl(PrevFunTmpl);
3623 unsigned BuiltinID = 0;
3625 if (
const auto *ABAA = getAttr<ArmBuiltinAliasAttr>()) {
3626 BuiltinID = ABAA->getBuiltinName()->getBuiltinID();
3627 }
else if (
const auto *BAA = getAttr<BuiltinAliasAttr>()) {
3628 BuiltinID = BAA->getBuiltinName()->getBuiltinID();
3629 }
else if (
const auto *A = getAttr<BuiltinAttr>()) {
3630 BuiltinID = A->getID();
3638 if (!ConsiderWrapperFunctions && hasAttr<OverloadableAttr>() &&
3639 (!hasAttr<ArmBuiltinAliasAttr>() && !hasAttr<BuiltinAliasAttr>()))
3662 if (Context.
getLangOpts().CUDA && hasAttr<CUDADeviceAttr>() &&
3663 !hasAttr<CUDAHostAttr>() &&
3664 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3673 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3689 assert(!ParamInfo &&
"Already has param info!");
3690 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
3693 if (!NewParamInfo.empty()) {
3694 ParamInfo =
new (C)
ParmVarDecl*[NewParamInfo.size()];
3695 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3709 unsigned NumRequiredArgs = 0;
3710 unsigned MinParamsSoFar = 0;
3712 if (!Param->isParameterPack()) {
3714 if (!Param->hasDefaultArg())
3715 NumRequiredArgs = MinParamsSoFar;
3718 return NumRequiredArgs;
3748 assert(
isInlined() &&
"expected to get called on an inlined function!");
3752 !hasAttr<DLLExportAttr>())
3757 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3769 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3799 "Must have a declaration without a body.");
3805 if (
hasBody(Definition) && Definition->isInlined() &&
3813 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3823 bool FoundBody =
false;
3848 bool FoundBody =
false;
3873 !
SM.isBeforeInTranslationUnit(RTRange.
getEnd(), Boundary))
3919 hasAttr<AliasAttr>()) &&
3920 "Must be a function definition");
3921 assert(
isInlined() &&
"Function must be inline");
3924 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3938 for (
auto *Redecl :
redecls()) {
3939 if (Redecl->isInlineSpecified() &&
3949 "should not use C inline rules in C++");
3955 for (
auto *Redecl :
redecls()) {
3984 if (TemplateOrSpecialization.isNull())
3986 if (
const auto *ND = TemplateOrSpecialization.dyn_cast<
NamedDecl *>()) {
3987 if (isa<FunctionDecl>(ND))
3989 assert(isa<FunctionTemplateDecl>(ND) &&
3990 "No other valid types in NamedDecl");
3997 if (TemplateOrSpecialization.is
4001 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
4006 return cast<FunctionDecl>(Info->getInstantiatedFrom());
4015 if (
auto *FTSI = TemplateOrSpecialization
4016 .dyn_cast<FunctionTemplateSpecializationInfo *>())
4017 return FTSI->getMemberSpecializationInfo();
4022 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
4025 assert(TemplateOrSpecialization.isNull() &&
4026 "Member function is already a specialization");
4029 TemplateOrSpecialization = Info;
4033 return dyn_cast_if_present<FunctionTemplateDecl>(
4034 TemplateOrSpecialization.dyn_cast<
NamedDecl *>());
4039 assert(TemplateOrSpecialization.isNull() &&
4040 "Member function is already a specialization");
4041 TemplateOrSpecialization = Template;
4046 TemplateOrSpecialization
4047 .is<DependentFunctionTemplateSpecializationInfo *>();
4051 assert(TemplateOrSpecialization.isNull() &&
4052 "Function is already a specialization");
4053 TemplateOrSpecialization = FD;
4057 return dyn_cast_if_present<FunctionDecl>(
4058 TemplateOrSpecialization.dyn_cast<
NamedDecl *>());
4082 bool HasPattern =
false;
4084 HasPattern = PatternDecl->
hasBody(PatternDecl);
4090 if (!HasPattern || !PatternDecl)
4114 dyn_cast<CXXMethodDecl>(
this))) {
4139 while (!
ForDefinition || !Primary->isMemberSpecialization()) {
4140 auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();
4143 Primary = NewPrimary;
4154 = TemplateOrSpecialization
4155 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
4156 return Info->getTemplate();
4163 return TemplateOrSpecialization
4170 = TemplateOrSpecialization
4171 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
4172 return Info->TemplateArguments;
4180 = TemplateOrSpecialization
4181 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
4182 return Info->TemplateArgumentsAsWritten;
4185 TemplateOrSpecialization
4186 .dyn_cast<DependentFunctionTemplateSpecializationInfo *>()) {
4187 return Info->TemplateArgumentsAsWritten;
4192 void FunctionDecl::setFunctionTemplateSpecialization(
4198 assert((TemplateOrSpecialization.isNull() ||
4200 "Member function is already a specialization");
4202 "Must specify the type of function template specialization");
4203 assert((TemplateOrSpecialization.isNull() ||
4206 "Member specialization must be an explicit specialization");
4209 C,
this, Template, TSK, TemplateArgs, TemplateArgsAsWritten,
4210 PointOfInstantiation,
4212 TemplateOrSpecialization = Info;
4219 assert(TemplateOrSpecialization.isNull());
4223 TemplateOrSpecialization = Info;
4228 return TemplateOrSpecialization
4236 const auto *TArgsWritten =
4239 totalSizeToAlloc<FunctionTemplateDecl *>(Candidates.
size())))
4243 DependentFunctionTemplateSpecializationInfo::
4244 DependentFunctionTemplateSpecializationInfo(
4247 : NumCandidates(Candidates.size()),
4248 TemplateArgumentsAsWritten(TemplateArgsWritten) {
4249 std::transform(Candidates.
begin(), Candidates.
end(),
4250 getTrailingObjects<FunctionTemplateDecl *>(),
4252 return cast<FunctionTemplateDecl>(ND->getUnderlyingDecl());
4260 TemplateOrSpecialization
4261 .dyn_cast<FunctionTemplateSpecializationInfo *>())
4262 return FTSInfo->getTemplateSpecializationKind();
4266 return MSInfo->getTemplateSpecializationKind();
4270 if (TemplateOrSpecialization
4271 .is<DependentFunctionTemplateSpecializationInfo *>() &&
4303 TemplateOrSpecialization
4304 .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
4305 if (
auto *MSInfo = FTSInfo->getMemberSpecializationInfo())
4306 return MSInfo->getTemplateSpecializationKind();
4307 return FTSInfo->getTemplateSpecializationKind();
4312 return MSInfo->getTemplateSpecializationKind();
4314 if (TemplateOrSpecialization
4315 .is<DependentFunctionTemplateSpecializationInfo *>() &&
4326 = TemplateOrSpecialization.dyn_cast<
4328 FTSInfo->setTemplateSpecializationKind(TSK);
4330 PointOfInstantiation.
isValid() &&
4331 FTSInfo->getPointOfInstantiation().isInvalid()) {
4332 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
4334 L->InstantiationRequested(
this);
4338 MSInfo->setTemplateSpecializationKind(TSK);
4340 PointOfInstantiation.
isValid() &&
4341 MSInfo->getPointOfInstantiation().isInvalid()) {
4342 MSInfo->setPointOfInstantiation(PointOfInstantiation);
4344 L->InstantiationRequested(
this);
4347 llvm_unreachable(
"Function cannot have a template specialization kind");
4352 = TemplateOrSpecialization.dyn_cast<
4354 return FTSInfo->getPointOfInstantiation();
4357 return MSInfo->getPointOfInstantiation();
4371 return Definition->isOutOfLine();
4378 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
4379 return Definition->isOutOfLine();
4397 case Builtin::BI__builtin_memset:
4398 case Builtin::BI__builtin___memset_chk:
4399 case Builtin::BImemset:
4400 return Builtin::BImemset;
4402 case Builtin::BI__builtin_memcpy:
4403 case Builtin::BI__builtin___memcpy_chk:
4404 case Builtin::BImemcpy:
4405 return Builtin::BImemcpy;
4407 case Builtin::BI__builtin_mempcpy:
4408 case Builtin::BI__builtin___mempcpy_chk:
4409 case Builtin::BImempcpy:
4410 return Builtin::BImempcpy;
4412 case Builtin::BI__builtin_memmove:
4413 case Builtin::BI__builtin___memmove_chk:
4414 case Builtin::BImemmove:
4415 return Builtin::BImemmove;
4417 case Builtin::BIstrlcpy:
4418 case Builtin::BI__builtin___strlcpy_chk:
4419 return Builtin::BIstrlcpy;
4421 case Builtin::BIstrlcat:
4422 case Builtin::BI__builtin___strlcat_chk:
4423 return Builtin::BIstrlcat;
4425 case Builtin::BI__builtin_memcmp:
4426 case Builtin::BImemcmp:
4427 return Builtin::BImemcmp;
4429 case Builtin::BI__builtin_bcmp:
4430 case Builtin::BIbcmp:
4431 return Builtin::BIbcmp;
4433 case Builtin::BI__builtin_strncpy:
4434 case Builtin::BI__builtin___strncpy_chk:
4435 case Builtin::BIstrncpy:
4436 return Builtin::BIstrncpy;
4438 case Builtin::BI__builtin_strncmp:
4439 case Builtin::BIstrncmp:
4440 return Builtin::BIstrncmp;
4442 case Builtin::BI__builtin_strncasecmp:
4443 case Builtin::BIstrncasecmp:
4444 return Builtin::BIstrncasecmp;
4446 case Builtin::BI__builtin_strncat:
4447 case Builtin::BI__builtin___strncat_chk:
4448 case Builtin::BIstrncat:
4449 return Builtin::BIstrncat;
4451 case Builtin::BI__builtin_strndup:
4452 case Builtin::BIstrndup:
4453 return Builtin::BIstrndup;
4455 case Builtin::BI__builtin_strlen:
4456 case Builtin::BIstrlen:
4457 return Builtin::BIstrlen;
4459 case Builtin::BI__builtin_bzero:
4460 case Builtin::BIbzero:
4461 return Builtin::BIbzero;
4463 case Builtin::BI__builtin_bcopy:
4464 case Builtin::BIbcopy:
4465 return Builtin::BIbcopy;
4467 case Builtin::BIfree:
4468 return Builtin::BIfree;
4472 if (FnInfo->
isStr(
"memset"))
4473 return Builtin::BImemset;
4474 if (FnInfo->
isStr(
"memcpy"))
4475 return Builtin::BImemcpy;
4476 if (FnInfo->
isStr(
"mempcpy"))
4477 return Builtin::BImempcpy;
4478 if (FnInfo->
isStr(
"memmove"))
4479 return Builtin::BImemmove;
4480 if (FnInfo->
isStr(
"memcmp"))
4481 return Builtin::BImemcmp;
4482 if (FnInfo->
isStr(
"bcmp"))
4483 return Builtin::BIbcmp;
4484 if (FnInfo->
isStr(
"strncpy"))
4485 return Builtin::BIstrncpy;
4486 if (FnInfo->
isStr(
"strncmp"))
4487 return Builtin::BIstrncmp;
4488 if (FnInfo->
isStr(
"strncasecmp"))
4489 return Builtin::BIstrncasecmp;
4490 if (FnInfo->
isStr(
"strncat"))
4491 return Builtin::BIstrncat;
4492 if (FnInfo->
isStr(
"strndup"))
4493 return Builtin::BIstrndup;
4494 if (FnInfo->
isStr(
"strlen"))
4495 return Builtin::BIstrlen;
4496 if (FnInfo->
isStr(
"bzero"))
4497 return Builtin::BIbzero;
4498 if (FnInfo->
isStr(
"bcopy"))
4499 return Builtin::BIbcopy;
4501 if (FnInfo->
isStr(
"free"))
4502 return Builtin::BIfree;
4510 assert(hasODRHash());
4519 setHasODRHash(
true);
4526 setHasODRHash(
true);
4540 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc,
Id,
T, TInfo,
4541 BW, Mutable, InitStyle);
4555 return Record->getDecl()->isAnonymousStructOrUnion();
4565 return cast_if_present<Expr>(
4567 : InitPtr.
get(
nullptr));
4599 if (!hasAttr<NoUniqueAddressAttr>())
4608 assert(
isInvalidDecl() &&
"valid field has incomplete type");
4614 const auto *CXXRD = cast<CXXRecordDecl>(RD);
4615 if (!CXXRD->isEmpty())
4625 return !llvm::any_of(CXXRD->fields(), [](
const FieldDecl *Field) {
4626 return Field->getType()->getAs<RecordType>();
4636 if (Canonical !=
this)
4639 if (CachedFieldIndex)
return CachedFieldIndex - 1;
4643 assert(RD &&
"requested index for field of struct with no definition");
4645 for (
auto *Field : RD->
fields()) {
4646 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
4647 assert(Field->getCanonicalDecl()->CachedFieldIndex == Index + 1 &&
4648 "overflow in field numbering");
4652 assert(CachedFieldIndex &&
"failed to find field in parent");
4653 return CachedFieldIndex - 1;
4667 "capturing type in non-lambda or captured record.");
4668 assert(StorageKind == ISK_NoInit && !BitField &&
4669 "bit-field or field with default member initializer cannot capture "
4671 StorageKind = ISK_CapturedVLAType;
4690 const auto *CountDRE = cast<DeclRefExpr>(CAT->getCountExpr());
4691 const auto *CountDecl = CountDRE->getDecl();
4692 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl))
4693 CountDecl = IFD->getAnonField();
4695 return dyn_cast<FieldDecl>(CountDecl);
4708 "EnumDecl not matched with TagTypeKind::Enum");
4716 TagDeclBits.IsThisDeclarationADemotedDefinition =
false;
4732 TypedefNameDeclOrQualifier = TDD;
4743 if (
auto *
D = dyn_cast<CXXRecordDecl>(
this)) {
4744 struct CXXRecordDecl::DefinitionData *
Data =
4747 cast<CXXRecordDecl>(I)->DefinitionData =
Data;
4752 assert((!isa<CXXRecordDecl>(
this) ||
4754 "definition completed but not started");
4760 L->CompletedTagDefinition(
this);
4765 return const_cast<TagDecl *
>(
this);
4770 if (II->isOutOfDate()) {
4776 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
4777 return CXXRD->getDefinition();
4780 if (R->isCompleteDefinition())
4796 if (getExtInfo()->NumTemplParamLists == 0) {
4810 if (Name.isIdentifier() && !Name.getAsIdentifierInfo()) {
4815 Copy.SuppressScope =
true;
4820 Name.print(
OS, Policy);
4825 assert(!TPLists.empty());
4840 bool Scoped,
bool ScopedUsingClassTag,
bool Fixed)
4842 assert(Scoped || !ScopedUsingClassTag);
4843 IntegerType =
nullptr;
4844 setNumPositiveBits(0);
4845 setNumNegativeBits(0);
4847 setScopedUsingClassTag(ScopedUsingClassTag);
4849 setHasODRHash(
false);
4853 void EnumDecl::anchor() {}
4859 bool IsScopedUsingClassTag,
bool IsFixed) {
4861 IsScoped, IsScopedUsingClassTag, IsFixed);
4862 Enum->setMayHaveOutOfDateDef(
C.getLangOpts().Modules);
4863 C.getTypeDeclType(
Enum, PrevDecl);
4870 nullptr,
nullptr,
false,
false,
false);
4871 Enum->setMayHaveOutOfDateDef(
C.getLangOpts().Modules);
4877 return TI->getTypeLoc().getSourceRange();
4883 unsigned NumPositiveBits,
4884 unsigned NumNegativeBits) {
4888 PromotionType = NewPromotionType;
4889 setNumPositiveBits(NumPositiveBits);
4890 setNumNegativeBits(NumNegativeBits);
4895 if (
const auto *A = getAttr<EnumExtensibilityAttr>())
4896 return A->getExtensibility() == EnumExtensibilityAttr::Closed;
4901 return isClosed() && hasAttr<FlagEnumAttr>();
4905 return isClosed() && !hasAttr<FlagEnumAttr>();
4910 return MSI->getTemplateSpecializationKind();
4918 assert(MSI &&
"Not an instantiated member enumeration?");
4921 PointOfInstantiation.
isValid() &&
4937 "couldn't find pattern for enum instantiation");
4942 if (SpecializationInfo)
4950 assert(!SpecializationInfo &&
"Member enum is already a specialization");
4960 setHasODRHash(
true);
4971 Res.setEnd(TSI->getTypeLoc().getEndLoc());
4981 if (NumNegativeBits) {
4982 unsigned NumBits =
std::max(NumNegativeBits, NumPositiveBits + 1);
4987 Min = llvm::APInt::getZero(Bitwidth);
4999 :
TagDecl(DK, TK,
C, DC, IdLoc,
Id, PrevDecl, StartLoc) {
5000 assert(
classof(
static_cast<Decl *
>(
this)) &&
"Invalid Kind!");
5022 StartLoc, IdLoc,
Id, PrevDecl);
5025 C.getTypeDeclType(R, PrevDecl);
5044 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
5045 return RD->isLambda();
5050 return hasAttr<CapturedRecordAttr>();
5062 for (
const FieldDecl *FD : Def->fields()) {
5074 LoadFieldsFromExternalStorage();
5078 return D->field_begin();
5106 return hasAttr<MSStructAttr>() ||
C.getLangOpts().MSBitfields == 1;
5115 void RecordDecl::LoadFieldsFromExternalStorage()
const {
5130 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
5131 assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
5137 auto [ExternalFirst, ExternalLast] =
5140 ExternalLast->NextInContextAndBits.setPointer(
FirstDecl);
5149 (SanitizerKind::Address | SanitizerKind::KernelAddress);
5150 if (!EnabledAsanMask || !Context.
getLangOpts().SanitizeAddressFieldPadding)
5153 const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this);
5155 int ReasonToReject = -1;
5156 if (!CXXRD || CXXRD->isExternCContext())
5158 else if (CXXRD->hasAttr<PackedAttr>())
5160 else if (CXXRD->isUnion())
5162 else if (CXXRD->isTriviallyCopyable())
5164 else if (CXXRD->hasTrivialDestructor())
5166 else if (CXXRD->isStandardLayout())
5176 if (ReasonToReject >= 0)
5179 diag::remark_sanitize_address_insert_extra_padding_rejected)
5184 diag::remark_sanitize_address_insert_extra_padding_accepted)
5187 return ReasonToReject < 0;
5191 for (
const auto *I :
fields()) {
5192 if (I->getIdentifier())
5195 if (
const auto *RT = I->getType()->getAs<
RecordType>())
5197 RT->getDecl()->findFirstNamedDataMember())
5198 return NamedDataMember;
5233 assert(!ParamInfo &&
"Already has param info!");
5236 if (!NewParamInfo.empty()) {
5237 NumParams = NewParamInfo.size();
5239 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
5244 bool CapturesCXXThis) {
5246 this->NumCaptures = Captures.size();
5248 if (Captures.empty()) {
5249 this->Captures =
nullptr;
5253 this->Captures = Captures.copy(Context).data();
5259 if (I.getVariable() == variable)
5273 void TranslationUnitDecl::anchor() {}
5280 AnonymousNamespace =
D;
5283 Listener->AddedAnonymousNamespace(
this,
D);
5286 void PragmaCommentDecl::anchor() {}
5294 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
5296 memcpy(PCD->getTrailingObjects<
char>(), Arg.data(), Arg.size());
5297 PCD->getTrailingObjects<
char>()[Arg.size()] =
'\0';
5304 return new (
C,
ID, additionalSizeToAlloc<char>(ArgSize + 1))
5308 void PragmaDetectMismatchDecl::anchor() {}
5314 size_t ValueStart = Name.size() + 1;
5316 new (
C, DC, additionalSizeToAlloc<char>(ValueStart +
Value.size() + 1))
5318 memcpy(PDMD->getTrailingObjects<
char>(), Name.data(), Name.size());
5319 PDMD->getTrailingObjects<
char>()[Name.size()] =
'\0';
5320 memcpy(PDMD->getTrailingObjects<
char>() + ValueStart,
Value.data(),
5322 PDMD->getTrailingObjects<
char>()[ValueStart +
Value.size()] =
'\0';
5328 unsigned NameValueSize) {
5329 return new (
C,
ID, additionalSizeToAlloc<char>(NameValueSize + 1))
5333 void ExternCContextDecl::anchor() {}
5340 void LabelDecl::anchor() {}
5344 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
5350 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
5351 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
5360 char *Buffer =
new (
getASTContext(), 1)
char[Name.size() + 1];
5361 memcpy(Buffer, Name.data(), Name.size());
5362 Buffer[Name.size()] =
'\0';
5366 void ValueDecl::anchor() {}
5370 return MostRecent->hasAttr<WeakAttr>() ||
5375 if (
auto *Var = llvm::dyn_cast<VarDecl>(
this))
5376 return Var->isInitCapture();
5380 void ImplicitParamDecl::anchor() {}
5403 bool isInlineSpecified,
bool hasWrittenPrototype,
5405 Expr *TrailingRequiresClause) {
5427 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
5429 NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr,
false) {}
5432 unsigned NumParams) {
5433 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5438 unsigned NumParams) {
5439 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5469 void IndirectFieldDecl::anchor() {}
5475 :
ValueDecl(IndirectField, DC, L, N,
T), Chaining(CH.data()),
5476 ChainingSize(CH.size()) {
5479 if (
C.getLangOpts().CPlusPlus)
5504 void TypeDecl::anchor() {}
5513 void TypedefNameDecl::anchor() {}
5518 auto *ThisTypedef =
this;
5519 if (AnyRedecl && OwningTypedef) {
5523 if (OwningTypedef == ThisTypedef)
5524 return TT->getDecl();
5530 bool TypedefNameDecl::isTransparentTagSlow()
const {
5531 auto determineIsTransparent = [&]() {
5533 if (
auto *TD = TT->getDecl()) {
5534 if (TD->getName() !=
getName())
5541 return SM.getSpellingLoc(TTLoc) ==
SM.getSpellingLoc(TDLoc);
5547 bool isTransparent = determineIsTransparent();
5548 MaybeModedTInfo.setInt((isTransparent << 1) | 1);
5549 return isTransparent;
5575 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
5583 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
5587 void FileScopeAsmDecl::anchor() {}
5602 void TopLevelStmtDecl::anchor() {}
5605 assert(
C.getLangOpts().IncrementalExtensions &&
5606 "Must be used only in incremental mode");
5630 void EmptyDecl::anchor() {}
5640 HLSLBufferDecl::HLSLBufferDecl(
DeclContext *DC,
bool CBuffer,
5645 IsCBuffer(CBuffer) {}
5682 unsigned Result = 1;
5693 :
Decl(
Import, DC, StartLoc), ImportedModule(Imported),
5694 NextLocalImportAndComplete(nullptr,
true) {
5696 auto *StoredLocs = getTrailingObjects<SourceLocation>();
5697 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
5703 :
Decl(
Import, DC, StartLoc), ImportedModule(Imported),
5704 NextLocalImportAndComplete(nullptr,
false) {
5705 *getTrailingObjects<SourceLocation>() = EndLoc;
5712 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
5713 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
5720 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
5722 Import->setImplicit();
5727 unsigned NumLocations) {
5728 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
5733 if (!isImportComplete())
5734 return std::nullopt;
5736 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
5742 if (!isImportComplete())
5752 void ExportDecl::anchor() {}
5764 bool IncludeLocallyStreaming) {
5765 if (IncludeLocallyStreaming)
5766 if (FD->
hasAttr<ArmLocallyStreamingAttr>())
5771 if (FPT->getAArch64SMEAttributes() &
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1659::IndirectLocalPathEntry::EntryKind Kind
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
static bool isFirstInExternCContext(T *D)
static bool isRedeclarableImpl(Redeclarable< T > *)
static const Decl * getOutermostFuncOrBlockContext(const Decl *D)
static bool isDeclExternC(const T &D)
static bool hasExplicitVisibilityAlready(LVComputationKind computation)
Does this computation kind permit us to consider additional visibility settings from attributes and t...
static bool RedeclForcesDefC99(const FunctionDecl *Redecl)
static bool isExportedFromModuleInterfaceUnit(const NamedDecl *D)
static bool isRedeclarable(Decl::Kind K)
static std::optional< Visibility > getExplicitVisibilityAux(const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent)
static bool redeclForcesDefMSVC(const FunctionDecl *Redecl)
static bool usesTypeVisibility(const NamedDecl *D)
Is the given declaration a "type" or a "value" for the purposes of visibility computation?
static LanguageLinkage getDeclLanguageLinkage(const T &D)
static LVComputationKind withExplicitVisibilityAlready(LVComputationKind Kind)
Given an LVComputationKind, return one of the same type/value sort that records that it already has e...
static std::optional< Visibility > getVisibilityOf(const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind)
Return the explicit visibility of the given declaration.
static unsigned getNumModuleIdentifiers(Module *Mod)
Retrieve the number of module identifiers needed to name the given module.
static bool isSingleLineLanguageLinkage(const Decl &D)
static bool useInlineVisibilityHidden(const NamedDecl *D)
static bool shouldConsiderTemplateVisibility(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo)
static bool hasDirectVisibilityAttribute(const NamedDecl *D, LVComputationKind computation)
Does the given declaration have a direct visibility attribute that would match the given rules?
static Visibility getVisibilityFromAttr(const T *attr)
Given a visibility attribute, return the explicit visibility associated with it.
static std::optional< Visibility > getExplicitVisibility(const NamedDecl *D, LVComputationKind kind)
static bool typeIsPostfix(QualType QT)
static LinkageInfo getExternalLinkageFor(const NamedDecl *D)
static StorageClass getStorageClass(const Decl *D)
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)
static DeclT * getDefinitionOrSelf(DeclT *D)
static bool isNamed(const NamedDecl *ND, const char(&Str)[Len])
static std::enable_if_t<!std::is_base_of_v< RedeclarableTemplateDecl, T >, bool > isExplicitMemberSpecialization(const T *D)
Does the given declaration have member specialization information, and if so, is it an explicit speci...
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
Defines the clang::Module class, which describes a module in the source code.
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
static std::string getName(const CallEvent &Call)
Defines the clang::SanitizerKind enum.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
static const TypeInfo & getInfo(unsigned id)
Defines the clang::Visibility enumeration and various utility functions.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ int max(int __a, int __b)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool needsCleanup() const
Returns whether the object performed allocations.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const clang::PrintingPolicy & getPrintingPolicy() const
SourceManager & getSourceManager()
unsigned getIntWidth(QualType T) const
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
const NoSanitizeList & getNoSanitizeList() const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void * Allocate(size_t Size, unsigned Align=8) const
void Deallocate(void *Ptr) const
Builtin::Context & BuiltinInfo
const ConstantArrayType * getAsConstantArrayType(QualType T) const
void setParameterIndex(const ParmVarDecl *D, unsigned index)
Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...
const LangOptions & getLangOpts() const
Decl * getPrimaryMergedDecl(Decl *D)
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...
const TargetInfo & getTargetInfo() const
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any.
DiagnosticsEngine & getDiagnostics() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
unsigned getParameterIndex(const ParmVarDecl *D) const
Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getSize() const
getSize - Get the record size in characters.
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
void setDoesNotEscape(bool B=true)
void setCapturesCXXThis(bool B=true)
ArrayRef< Capture > captures() const
void setCanAvoidCopyToHeap(bool B=true)
void setIsConversionFromLambda(bool val=true)
void setBlockMissingReturnType(bool val=true)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static BlockDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
void setIsVariadic(bool value)
bool capturesVariable(const VarDecl *var) const
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
Represents a C++ struct/union/class.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Represents the body of a CapturedStmt, and serves as its DeclContext.
static CapturedDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)
void setNothrow(bool Nothrow=true)
static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Represents a class template specialization, which refers to a class template with a given set of temp...
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
bool isExplicitSpecialization() const
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
bool isZeroSize() const
Return true if the size is zero.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
A POD class for pairing a NamedDecl* with an access specifier.
decl_iterator - Iterates through the declarations stored within this context.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
FunctionDeclBitfields FunctionDeclBits
bool isFileContext() const
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
TagDeclBitfields TagDeclBits
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
RecordDeclBitfields RecordDeclBits
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
bool isInlineNamespace() const
bool isFunctionOrMethod() const
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Decl::Kind getDeclKind() const
Decl - This represents one declaration (or definition), e.g.
bool isInStdNamespace() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInNamedModule() const
Whether this declaration comes from a named module.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
ASTMutationListener * getASTMutationListener() const
bool hasCachedLinkage() const
Kind
Lists the kind of concrete classes of Decl.
@ FOK_None
Not a friend object.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
llvm::PointerIntPair< Decl *, 3, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Linkage getCachedLinkage() const
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
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
SourceLocation getLocation() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
void setLocation(SourceLocation L)
bool isInAnonymousNamespace() const
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
void setCachedLinkage(Linkage L) const
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
@ Unowned
This declaration is not owned by a module.
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
@ Visible
This declaration has an owning module, but is globally visible (typically because its owning module i...
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
DeclContext * getDeclContext()
The name of a declaration.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Represents a ValueDecl that came out of a declarator.
SourceLocation getTypeSpecEndLoc() const
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypeSourceInfo * getTypeSourceInfo() const
void setTrailingRequiresClause(Expr *TrailingRequiresClause)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Provides information about a dependent function-template specialization declaration.
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Candidates, const TemplateArgumentListInfo *TemplateArgs)
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents an empty-declaration.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
static EmptyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
An instance of this object exists for each enum constant that is defined.
EnumConstantDecl(const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
static EnumConstantDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
void setInitVal(const ASTContext &C, const llvm::APSInt &V)
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class,...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
static EnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
SourceRange getSourceRange() const override LLVM_READONLY
Overrides to provide correct range when there's an enum-base specifier with forward declarations.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
EnumDecl * getTemplateInstantiationPattern() const
Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantia...
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
void getValueRange(llvm::APInt &Max, llvm::APInt &Min) const
Calculates the [Min,Max) values the enum can store based on the NumPositiveBits and NumNegativeBits.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
Represents a standard C++ module export declaration.
static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)
static ExportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Declaration context for names declared as extern "C" in C++.
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
Abstract interface for external sources of AST nodes.
virtual void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Result)
Finds all declarations lexically contained within the given DeclContext, after applying an optional f...
Represents a member of a struct/union/class.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool isBitField() const
Determines whether this field is a bitfield.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
static FieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
unsigned getBitWidthValue(const ASTContext &Ctx) const
Computes the bit width of this field, if this is a bit field.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
bool isZeroSize(const ASTContext &Ctx) const
Determine if this field is a subobject of zero size, that is, either a zero-length bit-field or a fie...
InitAndBitWidthStorage * InitAndBitWidth
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
static bool classofKind(Kind K)
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
const FieldDecl * findCountedByField() const
Find the FieldDecl specified in a FAM's "counted_by" attribute.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
bool isPotentiallyOverlapping() const
Determine if this field is of potentially-overlapping class type, that is, subobject with the [[no_un...
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
const VariableArrayType * CapturedVLAType
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Stashed information about a defaulted/deleted function body.
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
void setDeletedMessage(StringLiteral *Message)
Represents a function declaration or definition.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
bool isTargetClonesMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target-clones functional...
bool isMultiVersion() const
True if this function is considered a multiversioned function.
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void setPreviousDeclaration(FunctionDecl *PrevDecl)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
bool isImmediateFunction() const
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
SourceLocation getEllipsisLoc() const
Returns the location of the ellipsis of a variadic function.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
static FunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
bool hasCXXExplicitFunctionObjectParameter() const
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
void setHasWrittenPrototype(bool P=true)
State that this function has a written prototype.
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
unsigned getMinRequiredExplicitArguments() const
Returns the minimum number of non-object arguments needed to call this function.
bool BodyContainsImmediateEscalatingExpressions() const
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
bool hasWrittenPrototype() const
Whether this function has a written prototype.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionTypeLoc getFunctionTypeLoc() const
Find the source location information for how the type of this function was written.
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isConstexprSpecified() const
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
SourceRange getExceptionSpecSourceRange() const
Attempt to compute an informative source range covering the function exception specification,...
bool hasBody() const override
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
unsigned getODRHash()
Returns ODRHash of the function.
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
unsigned getNumNonObjectParams() const
TemplatedKind
The kind of templated function a FunctionDecl can be.
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
bool isInlineBuiltinDeclaration() const
Determine if this function provides an inline implementation of a builtin.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
bool FriendConstraintRefersToEnclosingTemplate() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
bool isDeletedAsWritten() const
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
bool isInExternCContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C" linkage spec.
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
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)
bool isExternC() const
Determines whether this function is a function with external, C linkage.
LazyDeclStmtPtr Body
The body of the function.
bool isImmediateEscalating() const
DefaultedOrDeletedFunctionInfo * DefaultedOrDeletedInfo
Information about a future defaulted function definition.
bool isInExternCXXContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C++" linkage spec.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
bool isTargetVersionMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target-version functiona...
bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getInstantiatedFromDecl() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool doesDeclarationForceExternallyVisibleDefinition() const
For a function declaration in C or C++, determine whether this declaration causes the definition to b...
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality.
bool isGlobal() const
Determines whether this is a global function.
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
bool isTargetMultiVersionDefault() const
True if this function is the default version of a multiversioned dispatch function as a part of the t...
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
const ParmVarDecl * getParamDecl(unsigned i) const
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
Wrapper for source info for functions.
SourceRange getExceptionSpecRange() const
TypeLoc getReturnLoc() const
FunctionType - C99 6.7.5.3 - Function Declarators.
@ SME_PStateSMEnabledMask
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
static HLSLBufferDecl * Create(ASTContext &C, DeclContext *LexicalParent, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *ID, SourceLocation IDLoc, SourceLocation LBrace)
static HLSLBufferDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
One of these records is kept for each identifier that is lexed.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine whether this is a name reserved for the implementation (C99 7.1.3, C++ [lib....
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, const IdentifierInfo *Id, QualType Type, ImplicitParamKind ParamKind)
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static ImportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
Represents a field injected from an anonymous union/struct into the parent scope.
static bool classofKind(Kind K)
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Represents the declaration of a label.
void setMSAsmLabel(StringRef Name)
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
static LabelDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SanitizerSet Sanitize
Set of enabled sanitizers.
LinkageInfo getTypeLinkageAndVisibility(const Type *T)
LinkageInfo computeLVForDecl(const NamedDecl *D, LVComputationKind computation, bool IgnoreVarTypeLinkage=false)
LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
getLVForDecl - Get the linkage and visibility for the given declaration.
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
Visibility getVisibility() const
static LinkageInfo external()
static LinkageInfo none()
void setLinkage(Linkage L)
void mergeExternalVisibility(Linkage L)
void mergeMaybeWithVisibility(LinkageInfo other, bool withVis)
Merge linkage and conditionally merge visibility.
Linkage getLinkage() const
static LinkageInfo internal()
static LinkageInfo visible_none()
static LinkageInfo uniqueExternal()
void mergeVisibility(Visibility newVis, bool newExplicit)
Merge in the visibility 'newVis'.
bool isVisibilityExplicit() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
Provides information a specialization of a member of a class template, which may be a member function...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
Describes a module or submodule.
Module * Parent
The parent of this module.
ModuleKind Kind
The kind of this module.
@ ModuleImplementationUnit
This is a C++20 module implementation unit.
@ ModuleMapModule
This is a module that was defined by a module map and built out of header files.
@ ImplicitGlobalModuleFragment
This is an implicit fragment of the global module which contains only language linkage declarations (...
@ ModulePartitionInterface
This is a C++20 module partition interface.
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
@ ModuleHeaderUnit
This is a C++20 header unit.
@ ModulePartitionImplementation
This is a C++20 module partition implementation.
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
@ ExplicitGlobalModuleFragment
This is the explicit Global Module Fragment of a modular TU.
This represents a decl that may have a name.
ExplicitVisibilityKind
Kinds of explicit visibility.
@ VisibilityForValue
Do an LV computation for, ultimately, a non-type declaration.
@ VisibilityForType
Do an LV computation for, ultimately, a type.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
bool isLinkageValid() const
True if the computed linkage is valid.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
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.
std::optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
std::string getQualifiedNameAsString(bool WithGlobalNsPrefix=false) const
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
bool declarationReplaces(const NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool hasLinkage() const
Determine whether this declaration has linkage.
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
NamedDecl * getMostRecentDecl()
void printNestedNameSpecifier(raw_ostream &OS) const
Print only the nested name specifier part of a fully-qualified name, including the '::' at the end.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
bool containsType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
bool containsLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const
void AddEnumDecl(const EnumDecl *Enum)
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
void AddRecordDecl(const RecordDecl *Record)
Represents a parameter to a function.
void setDefaultArg(Expr *defarg)
static ParmVarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
void setUninstantiatedDefaultArg(Expr *arg)
bool hasUninstantiatedDefaultArg() const
bool isDestroyedInCallee() const
Determines whether this parameter is destroyed in the callee function.
bool hasInheritedDefaultArg() const
bool isExplicitObjectParameter() const
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a #pragma detect_mismatch line.
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NameValueSize)
void print(raw_ostream &OS) const override
A (possibly-)qualified type.
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 print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
const Type * getTypePtrOrNull() const
Represents a struct/union/class.
bool hasLoadedFieldsFromExternalStorage() const
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma,...
void setAnonymousStructOrUnion(bool Anon)
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
void setArgPassingRestrictions(RecordArgPassingKind Kind)
void setNonTrivialToPrimitiveCopy(bool V)
bool isCapturedRecord() const
Determine whether this record is a record for captured variables in CapturedStmt construct.
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
field_range fields() const
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
void setHasFlexibleArrayMember(bool V)
void setParamDestroyedInCallee(bool V)
void setNonTrivialToPrimitiveDestroy(bool V)
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
void setHasObjectMember(bool val)
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
void setHasVolatileMember(bool val)
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
void reorderDecls(const SmallVectorImpl< Decl * > &Decls)
void setIsRandomized(bool V)
static RecordDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
static bool classof(const Decl *D)
bool isOrContainsUnion() const
Returns whether this record is a union, or contains (at any nesting level) a union member.
virtual void completeDefinition()
Note that the definition of this type is now complete.
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
specific_decl_iterator< FieldDecl > field_iterator
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
void setHasLoadedFieldsFromExternalStorage(bool val) const
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Declaration of a redeclarable template.
Provides common interface for the Decls that can be redeclared.
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
VarDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(FunctionDecl *PrevDecl)
Set the previous declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
void print(raw_ostream &OS, const SourceManager &SM) const
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
Represents the declaration of a struct/union/class/enum.
void setTagKind(TagKind TK)
void setCompleteDefinitionRequired(bool V=true)
True if this complete decl is required to be complete for some existing use.
SourceRange getBraceRange() const
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void setMayHaveOutOfDateDef(bool V=true)
Indicates whether it is possible for declarations of this kind to have an out-of-date definition.
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
bool mayHaveOutOfDateDef() const
Indicates whether it is possible for declarations of this kind to have an out-of-date definition.
SourceLocation getOuterLocStart() const
Return SourceLocation representing start of source range taking into account any outer template decla...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setBeingDefined(bool V=true)
True if this decl is currently being defined.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
void completeDefinition()
Completes the definition of this tag declaration.
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, SourceLocation StartL)
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A convenient class for passing around template argument information.
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Represents a 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,...
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
A declaration that models statements at global scope.
static TopLevelStmtDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static TopLevelStmtDecl * Create(ASTContext &C, Stmt *Statement)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The top declaration context.
static TranslationUnitDecl * Create(ASTContext &C)
ASTContext & getASTContext() const
void setAnonymousNamespace(NamespaceDecl *D)
Represents the declaration of a typedef-name via a C++11 alias-declaration.
static TypeAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a declaration of a type.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
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...
bool isLinkageValid() const
True if the computed linkage is valid.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() 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.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isFunctionType() const
Linkage getLinkage() const
Determine the linkage of this type.
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static TypedefDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Base class for declarations which introduce a typedef-name.
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
A set of unresolved declarations.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
Stmt ** getInitAddress()
Retrieve the address of the initializer expression.
DefinitionKind isThisDeclarationADefinition() const
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
TLSKind getTLSKind() const
bool hasICEInitializer(const ASTContext &Context) const
Determine whether the initializer of this variable is an integer constant expression.
ParmVarDeclBitfields ParmVarDeclBits
DefinitionKind hasDefinition() const
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
VarDecl * getDefinition()
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasFlexibleArrayInit(const ASTContext &Ctx) const
Whether this variable has a flexible array member initialized with one or more elements.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
void setStorageClass(StorageClass SC)
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
static VarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
VarDeclBitfields VarDeclBits
CharUnits getFlexibleArrayInitChars(const ASTContext &Ctx) const
If hasFlexibleArrayInit is true, compute the number of additional bytes necessary to store those elem...
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
EvaluatedStmt * getEvaluatedStmt() const
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
const Expr * getInit() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
bool checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the initializer of this variable to determine whether it's a constant initializer.
bool isInline() const
Whether this variable is (C++1z) inline.
bool isNonEscapingByref() const
Indicates the capture is a __block variable that is never captured by an escaping block.
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec.
NonParmVarDeclBitfields NonParmVarDeclBits
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
InitType Init
The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
TLSKind
Kinds of thread-local storage.
@ TLS_Static
TLS with a known-constant initializer.
@ TLS_Dynamic
TLS with a dynamic initializer.
@ TLS_None
Not a TLS variable.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ TentativeDefinition
This declaration is a tentative definition.
@ DeclarationOnly
This declaration is only a declaration.
@ Definition
This declaration is definitely a definition.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
bool isInExternCXXContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec.
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Get the template specialization kind of this variable for the purposes of template instantiation.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool isKnownToBeDefined() const
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
Represents a variable template specialization, which refers to a variable template with a given set o...
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
bool isExplicitSpecialization() const
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Represents a C array with a specified size that is not an integer-constant-expression.
Defines the Linkage enumeration and various utility functions.
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
bool Init(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.
@ OO_None
Not an overloaded operator.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
@ GVA_AvailableExternally
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
ConstexprSpecKind
Define the kind of constexpr specifier.
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_NoInit
No in-class initializer.
LazyOffsetPtr< Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt > LazyDeclStmtPtr
A lazy pointer to a statement.
Linkage getFormalLinkage(Linkage L)
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
StorageClass
Storage classes.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ VisibleNone
No linkage according to the standard, but is visible from other translation units because of types de...
@ None
No linkage, which means that the entity is unique and can only be referred to from within its scope.
@ UniqueExternal
External linkage within a unique namespace.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ External
External linkage, which indicates that the entity can be referred to from other translation units.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ SD_Automatic
Automatic storage duration (most local variables).
bool isLambdaCallOperator(const CXXMethodDecl *MD)
TagTypeKind
The kind of a tag type.
@ Struct
The "struct" keyword.
@ Enum
The "enum" keyword.
@ CanPassInRegs
The argument of this type can be passed directly in registers.
bool isLegalForVariable(StorageClass SC)
Checks whether the given storage class is legal for variables.
const FunctionProtoType * T
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
bool isReservedAtGlobalScope(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved for use as a name at global scope.
bool isExternalFormalLinkage(Linkage L)
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ StartsWithUnderscoreAndIsExternC
bool isExternallyVisible(Linkage L)
ImplicitParamKind
Defines the kind of the implicit parameter: is this an implicit parameter with pointer to 'this',...
@ Other
Other implicit parameter.
Visibility
Describes the different kinds of visibility that a declaration may have.
@ HiddenVisibility
Objects with "hidden" visibility are not seen by the dynamic linker.
@ ProtectedVisibility
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
@ DefaultVisibility
Objects with "default" visibility are seen by the dynamic linker and act like normal objects.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
Structure used to store a statement, the constant value to which it was evaluated (if any),...
bool HasConstantDestruction
Whether this variable is known to have constant destruction.
bool WasEvaluated
Whether this statement was already evaluated.
bool IsEvaluating
Whether this statement is being evaluated.
bool HasConstantInitialization
Whether this variable is known to have constant initialization.
bool HasICEInit
In C++98, whether the initializer is an ICE.
bool isTypeVisibility() const
unsigned IgnoreExplicitVisibility
Whether explicit visibility attributes should be ignored.
unsigned IgnoreAllVisibility
Whether all visibility should be ignored.
static LVComputationKind forLinkageOnly()
Do an LV computation when we only care about the linkage.
bool isValueVisibility() const
bool isOffset() const
Whether this pointer is currently stored as an offset.
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
Describes how types, statements, expressions, and declarations should be printed.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
NestedNameSpecifierLoc QualifierLoc
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Sets info about "outer" template parameter lists.
SanitizerMask Mask
Bitmask of enabled sanitizers.