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/ADT/iterator_range.h"
62#include "llvm/Support/Casting.h"
63#include "llvm/Support/ErrorHandling.h"
64#include "llvm/Support/Path.h"
65#include "llvm/Support/raw_ostream.h"
66#include "llvm/TargetParser/Triple.h"
84 if (!Loc.isValid() && TheDecl) Loc = TheDecl->getLocation();
86 Loc.print(OS, Context.getSourceManager());
91 if (
auto *ND = dyn_cast_if_present<NamedDecl>(TheDecl)) {
93 ND->getNameForDiagnostic(OS, Context.getPrintingPolicy(),
true);
105TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
107 DeclContext(TranslationUnit), redeclarable_base(ctx), Ctx(ctx) {}
175 assert(!
kind.IgnoreExplicitVisibility &&
176 "asking for explicit visibility when we shouldn't be");
191static std::enable_if_t<!std::is_base_of_v<RedeclarableTemplateDecl, T>,
bool>
194 D->getMemberSpecializationInfo()) {
195 return member->isExplicitSpecialization();
211 switch (
attr->getVisibility()) {
219 llvm_unreachable(
"bad visibility kind");
223static std::optional<Visibility>
228 if (
const auto *A = D->
getAttr<TypeVisibilityAttr>()) {
234 if (
const auto *A = D->
getAttr<VisibilityAttr>()) {
251LinkageInfo LinkageComputer::getLVForTemplateParameterList(
254 for (
const NamedDecl *P : *Params) {
264 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
266 if (!NTTP->isExpandedParameterPack()) {
267 if (!NTTP->getType()->isDependentType()) {
268 LV.
merge(getLVForType(*NTTP->getType(), computation));
274 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
275 QualType
type = NTTP->getExpansionType(i);
276 if (!
type->isDependentType())
287 if (!TTP->isExpandedParameterPack()) {
288 LV.
merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),
294 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
296 LV.
merge(getLVForTemplateParameterList(
297 TTP->getExpansionTemplateParameters(i), computation));
305 const Decl *Ret =
nullptr;
307 while (DC->
getDeclKind() != Decl::TranslationUnit) {
325 for (
const TemplateArgument &Arg : Args) {
326 switch (Arg.getKind()) {
333 LV.
merge(getLVForType(*Arg.getAsType(), computation));
337 const NamedDecl *ND = Arg.getAsDecl();
348 LV.
merge(getLVForValue(Arg.getAsStructuralValue(), computation));
354 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl(
360 LV.
merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));
363 llvm_unreachable(
"bad template argument kind");
372 return getLVForTemplateArgumentList(TArgs.
asArray(), computation);
384 return !fn->
hasAttr<VisibilityAttr>();
394void LinkageComputer::mergeTemplateLV(
398 bool considerVisibility =
401 FunctionTemplateDecl *temp = specInfo->
getTemplate();
409 LinkageInfo paramsLV =
415 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
468void LinkageComputer::mergeTemplateLV(
482 LinkageInfo paramsLV =
491 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
492 if (considerVisibility)
525void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV,
542 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
543 if (considerVisibility)
551 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
554 const auto *FD = dyn_cast<FunctionDecl>(D);
560 = FD->getTemplateSpecializationInfo()) {
563 FD->getMemberSpecializationInfo()) {
564 TSK = MSI->getTemplateSpecializationKind();
577 const T *
First = D->getFirstDecl();
578 return First->isInExternCContext();
582 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.
getDeclContext()))
583 if (!SD->hasBraces())
593 if (
auto *TD = dyn_cast<TemplateDecl>(D))
594 D = TD->getTemplatedDecl();
596 if (
auto *VD = dyn_cast<VarDecl>(D))
597 return VD->getStorageClass();
598 if (
auto *FD = dyn_cast<FunctionDecl>(D))
599 return FD->getStorageClass();
605LinkageComputer::getLVForNamespaceScopeDecl(
const NamedDecl *D,
607 bool IgnoreVarTypeLinkage) {
609 "Not a name having namespace scope");
611 const auto *Var = dyn_cast<VarDecl>(D);
618 (Context.
getLangOpts().C23 && Var && Var->isConstexpr())) {
639 if (Context.
getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&
640 !Var->getType().isVolatileQualified() && !Var->isInline() &&
644 if (auto *M = Var->getOwningModule())
645 return M->isInterfaceOrPartition() || M->isImplicitGlobalModule();
649 !Var->getDescribedVarTemplate()) {
650 const VarDecl *PrevVar = Var->getPreviousDecl();
654 if (Var->getStorageClass() !=
SC_Extern &&
660 for (
const VarDecl *PrevVar = Var->getPreviousDecl(); PrevVar;
663 Var->getStorageClass() ==
SC_None)
669 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
671 const VarDecl *VD = IFD->getVarDecl();
672 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
673 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
680 const auto *Var = dyn_cast<VarDecl>(D);
681 const auto *
Func = dyn_cast<FunctionDecl>(D);
710 DC = DC->getParent()) {
711 const auto *ND = dyn_cast<NamespaceDecl>(DC);
713 if (std::optional<Visibility> Vis =
753 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
777 !IgnoreVarTypeLinkage) {
778 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
795 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
796 mergeTemplateLV(LV, spec, computation);
800 }
else if (
const auto *
Function = dyn_cast<FunctionDecl>(D)) {
815 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(
Function)))
829 QualType TypeAsWritten =
Function->getType();
830 if (TypeSourceInfo *TSI =
Function->getTypeSourceInfo())
831 TypeAsWritten = TSI->getType();
839 if (FunctionTemplateSpecializationInfo *specInfo
840 =
Function->getTemplateSpecializationInfo()) {
841 mergeTemplateLV(LV,
Function, specInfo, computation);
850 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
852 if (!
Tag->hasNameForLinkage())
858 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
859 mergeTemplateLV(LV, spec, computation);
872 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
891 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
894 if (!TD->getAnonDeclWithTypedefName(
true))
915LinkageComputer::getLVForClassMember(
const NamedDecl *D,
917 bool IgnoreVarTypeLinkage) {
954 LVComputationKind classComputation = computation;
958 LinkageInfo classLV =
971 const NamedDecl *explicitSpecSuppressor =
nullptr;
973 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
976 QualType TypeAsWritten = MD->getType();
977 if (TypeSourceInfo *TSI = MD->getTypeSourceInfo())
978 TypeAsWritten = TSI->getType();
984 if (FunctionTemplateSpecializationInfo *spec
985 = MD->getTemplateSpecializationInfo()) {
986 mergeTemplateLV(LV, MD, spec, computation);
988 explicitSpecSuppressor = MD;
990 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
993 explicitSpecSuppressor = MD;
1004 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(MD)))
1007 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
1008 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
1009 mergeTemplateLV(LV, spec, computation);
1011 explicitSpecSuppressor = spec;
1019 explicitSpecSuppressor = RD;
1023 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
1024 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
1025 mergeTemplateLV(LV, spec, computation);
1029 if (!IgnoreVarTypeLinkage) {
1030 LinkageInfo typeLV = getLVForType(*VD->
getType(), computation);
1039 explicitSpecSuppressor = VD;
1043 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
1044 bool considerVisibility =
1048 LinkageInfo tempLV =
1052 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
1055 }
else if (
const RedeclarableTemplateDecl *from =
1056 redeclTemp->getInstantiatedFromMemberTemplate()) {
1060 LinkageInfo fromLV = from->getLinkageAndVisibility();
1071 bool considerClassVisibility =
true;
1072 if (explicitSpecSuppressor &&
1077 considerClassVisibility =
false;
1085void NamedDecl::anchor() {}
1110 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
this)) {
1114 const VarDecl *VD = IFD->getVarDecl();
1118 if (
const auto *VD = dyn_cast<VarDecl>(
this)) {
1125 if (
const auto *BD = dyn_cast<BindingDecl>(
this);
1127 const VarDecl *VD = BD->getHoldingVar();
1159 if (
auto *VD = dyn_cast<VarDecl>(
this))
1162 if (
auto *FD = dyn_cast<FunctionDecl>(
this))
1163 if (FD->isExternC())
1175 if (name.front() ==
'C')
1176 if (name ==
"CFStringCreateWithFormat" ||
1177 name ==
"CFStringCreateWithFormatAndArguments" ||
1178 name ==
"CFStringAppendFormat" ||
1179 name ==
"CFStringAppendFormatAndArguments")
1204 llvm_unreachable(
"unexpected module ownership kind");
1233static std::optional<Visibility>
1236 bool IsMostRecent) {
1248 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1250 if (InstantiatedFrom)
1257 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1261 while (TD !=
nullptr) {
1263 if (Vis != std::nullopt)
1265 TD = TD->getPreviousDecl();
1267 return std::nullopt;
1273 if (MostRecent != ND)
1277 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1278 if (Var->isStaticDataMember()) {
1280 if (InstantiatedFrom)
1284 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1285 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1288 return std::nullopt;
1291 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1296 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1302 if (InstantiatedFrom)
1305 return std::nullopt;
1309 if (
const auto *TD = dyn_cast<TemplateDecl>(ND)) {
1310 if (
const NamedDecl *Templated = TD->getTemplatedDecl())
1314 return std::nullopt;
1317std::optional<Visibility>
1328 Owner = dyn_cast<NamedDecl>(DC);
1347 auto *VD = dyn_cast<VarDecl>(Owner);
1348 LinkageInfo OwnerLV =
1363 if (
const auto *
Function = dyn_cast<FunctionDecl>(D)) {
1364 if (
Function->isInAnonymousNamespace() &&
1374 if (std::optional<Visibility> Vis =
1386 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1387 if (Var->hasExternalStorage()) {
1395 if (std::optional<Visibility> Vis =
1400 if (
const VarDecl *Prev = Var->getPreviousDecl()) {
1410 if (!Var->isStaticLocal())
1423 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1424 if (!BD->getBlockManglingNumber())
1427 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),
1428 BD->getBlockManglingContextDecl(), computation);
1431 if (!FD->isInlined() &&
1441 !Context.
getLangOpts().VisibilityInlinesHiddenStaticLocalVar) {
1446 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1466 bool IgnoreVarTypeLinkage) {
1468 if (D->
hasAttr<InternalLinkageAttr>())
1483 case Decl::ImplicitParam:
1485 case Decl::NamespaceAlias:
1488 case Decl::UsingEnum:
1489 case Decl::UsingShadow:
1490 case Decl::UsingDirective:
1493 case Decl::EnumConstant:
1500 case Decl::TypeAlias:
1504 ->getAnonDeclWithTypedefName(
true))
1508 case Decl::TemplateTemplateParm:
1509 case Decl::NonTypeTemplateParm:
1510 case Decl::ObjCAtDefsField:
1511 case Decl::ObjCCategory:
1512 case Decl::ObjCCategoryImpl:
1513 case Decl::ObjCCompatibleAlias:
1514 case Decl::ObjCImplementation:
1515 case Decl::ObjCMethod:
1516 case Decl::ObjCProperty:
1517 case Decl::ObjCPropertyImpl:
1518 case Decl::ObjCProtocol:
1521 case Decl::CXXRecord: {
1523 if (
Record->isLambda()) {
1524 if (
Record->hasKnownLambdaInternalLinkage() ||
1525 !
Record->getLambdaManglingNumber()) {
1530 return getLVForClosure(
1531 Record->getDeclContext()->getRedeclContext(),
1532 Record->getLambdaContextDecl(), computation);
1538 case Decl::TemplateParamObject: {
1542 LinkageInfo LV = getLVForType(*TPO->getType(), computation);
1543 LV.
merge(getLVForValue(TPO->getValue(), computation));
1550 return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);
1560 return getLVForClassMember(D, computation, IgnoreVarTypeLinkage);
1574 return getLVForLocalDecl(D, computation);
1585 if (D->
hasAttr<InternalLinkageAttr>())
1591 if (std::optional<LinkageInfo> LI = lookup(D, computation))
1599 cache(D, computation, LV);
1606 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1616 if (!AlreadyVisited.insert(D).second)
1674 llvm_unreachable(
"unknown module kind");
1678 Name.print(OS, Policy);
1686 std::string QualName;
1687 llvm::raw_string_ostream OS(QualName);
1710 llvm::raw_svector_ostream NameOS(NameBuffer);
1712 if (NameBuffer.empty())
1713 OS <<
"(anonymous)";
1729 if (
auto *MD = dyn_cast<ObjCMethodDecl>(
this)) {
1730 if (
auto *ID = MD->getClassInterface())
1732 }
else if (
auto *PD = dyn_cast<ObjCPropertyDecl>(
this)) {
1733 if (
auto *MD = PD->getGetterMethodDecl())
1734 if (
auto *ID = MD->getClassInterface())
1736 }
else if (
auto *ID = dyn_cast<ObjCIvarDecl>(
this)) {
1737 if (
auto *CI = ID->getContainingInterface())
1745 ContextsTy Contexts;
1761 llvm::to_underlying(
1764 llvm::to_underlying(
1777 const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx);
1781 Contexts.push_back(Ctx);
1785 for (
const DeclContext *DC : llvm::reverse(Contexts)) {
1786 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1787 OS << Spec->getName();
1789 printTemplateArgumentList(
1790 OS, TemplateArgs.
asArray(), P,
1791 Spec->getSpecializedTemplate()->getTemplateParameters());
1792 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1793 if (ND->isAnonymousNamespace()) {
1794 OS << (P.MSVCFormatting ?
"`anonymous namespace\'"
1795 :
"(anonymous namespace)");
1799 }
else if (
const auto *RD = llvm::dyn_cast<RecordDecl>(DC)) {
1806 Copy.SuppressTagKeyword =
true;
1807 Copy.SuppressTagKeywordInAnonNames =
false;
1808 Copy.AnonymousTagNameStyle =
1810 RD->printName(OS,
Copy);
1811 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1813 if (FD->hasWrittenPrototype())
1814 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1818 unsigned NumParams = FD->getNumParams();
1819 for (
unsigned i = 0; i < NumParams; ++i) {
1822 OS << FD->getParamDecl(i)->getType().stream(P);
1832 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1845 OS << *cast<NamedDecl>(DC);
1866#define DECL(Type, Base) \
1868 return isRedeclarableImpl((Type##Decl *)nullptr);
1869#define ABSTRACT_DECL(DECL)
1870#include "clang/AST/DeclNodes.inc"
1872 llvm_unreachable(
"unknown decl kind");
1876 bool IsKnownNewer)
const {
1906 if (
const auto *UD = dyn_cast<UsingDecl>(
this))
1907 return UD->getQualifier().getCanonical() ==
1910 if (
const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this))
1911 return UUVD->getQualifier().getCanonical() ==
1924 for (
const auto *D :
redecls()) {
1950 llvm_unreachable(
"Linkage hasn't been computed!");
1957 llvm_unreachable(
"Non-formal linkage is not allowed here!");
1962 llvm_unreachable(
"Unhandled Linkage enum");
1965NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1967 if (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1968 ND = UD->getTargetDecl();
1970 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1971 return AD->getClassInterface();
1973 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1974 return AD->getNamespace();
1989 if (
const auto *MD = dyn_cast_if_present<CXXMethodDecl>(D->
getAsFunction()))
1990 return MD->isInstance();
1998template <
typename DeclT>
2001 decl->getTemplateParameterLists();
2003 return TPLs.front()->getTemplateLoc();
2004 return decl->getInnerLocStart();
2022 if (!hasExtInfo()) {
2028 getExtInfo()->TInfo = savedTInfo;
2031 getExtInfo()->QualifierLoc = QualifierLoc;
2032 }
else if (hasExtInfo()) {
2034 getExtInfo()->QualifierLoc = QualifierLoc;
2041 if (!hasExtInfo()) {
2047 getExtInfo()->TInfo = savedTInfo;
2050 getExtInfo()->TrailingRequiresClause = AC;
2055 assert(!TPLists.empty());
2057 if (!hasExtInfo()) {
2063 getExtInfo()->TInfo = savedTInfo;
2066 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
2078 if (!
getDeclName() || TInfo->getType().hasPostfixDeclaratorSyntax())
2079 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
2093 if (!TPLists.empty()) {
2114 llvm_unreachable(
"Invalid storage class");
2123 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(unsigned),
2124 "VarDeclBitfields too large!");
2126 "ParmVarDeclBitfields too large!");
2128 "NonParmVarDeclBitfields too large!");
2137 return new (
C, DC)
VarDecl(Var,
C, DC, StartL, IdL, Id, T, TInfo, S);
2170 llvm_unreachable(
"Unknown thread storage class specifier!");
2188 if (!D.hasExternalFormalLinkage())
2193 if (!D.getASTContext().getLangOpts().CPlusPlus)
2217 assert(D.getASTContext().getLangOpts().CPlusPlus);
2308 if (!SAA->isInherited())
2314 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2317 !VTSD->IsCompleteDefinition)
2354 VarDecl *LastTentative =
nullptr;
2359 Kind =
Decl->isThisDeclarationADefinition();
2364 LastTentative =
Decl;
2367 return LastTentative;
2372 for (
auto *I :
First->redecls()) {
2373 if (I->isThisDeclarationADefinition(
C) ==
Definition)
2383 for (
auto *I :
First->redecls()) {
2384 Kind = std::max(
Kind, I->isThisDeclarationADefinition(
C));
2394 if (
auto Expr = I->getInit()) {
2403 if (
auto *P = dyn_cast<ParmVarDecl>(
this))
2404 if (P->hasUnparsedDefaultArg() || P->hasUninstantiatedDefaultArg())
2408 return Eval->Value.isValid();
2410 return !
Init.isNull();
2417 if (
auto *S = dyn_cast<Stmt *>(
Init))
2423 Eval->Value.isOffset() ?
getASTContext().getExternalSource() :
nullptr));
2427 if (
auto *ES = dyn_cast<EvaluatedStmt *>(
Init))
2428 return ES->Value.getAddressOfPointer(
getASTContext().getExternalSource());
2430 return Init.getAddrOfPtr1();
2439 if (I->isThisDeclarationADefinition()) {
2473 if (
auto *Eval = dyn_cast_if_present<EvaluatedStmt *>(
Init)) {
2474 Eval->~EvaluatedStmt();
2486 if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)
2499 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2510 if (
getType()->isIntegralOrEnumerationType() && !Lang.C23)
2520 return (Lang.CPlusPlus11 || Lang.C23) &&
isConstexpr();
2527 const VarDecl *DefVD =
nullptr;
2529 if (!
Init ||
Init->isValueDependent() ||
getType()->isDependentType())
2543 if ((Context.getLangOpts().CPlusPlus || Context.getLangOpts().OpenCL) &&
2553 auto *Eval = dyn_cast_if_present<EvaluatedStmt *>(
Init);
2567 return dyn_cast_if_present<EvaluatedStmt *>(
Init);
2571 return evaluateValueImpl(
nullptr,
nullptr,
2578 bool IsConstantInitialization)
const {
2582 assert(!
Init->isValueDependent());
2600 EStatus.
Diag = Notes;
2607 ?
Init->EvaluateAsMandatedConstantInitializer(EStatus, Ctx, *SProxy,
2609 :
Init->EvaluateAsInitializer(Ctx,
this, EStatus,
2610 IsConstantInitialization);
2617 if (IsConstantInitialization &&
2629 if (!MSWarning.empty())
2630 for (
auto &Info : MSWarning)
2632 Info.second.getDiagID());
2653 assert(
Init &&
"no initializer");
2686 "already evaluated var value before checking for constant init");
2689 "only meaningful in C++/C23");
2691 assert(!
getInit()->isValueDependent());
2695 evaluateValueImpl(&Notes, &SProxy,
true) && Notes.empty();
2715 return T->isDependentType() || T->isUndeducedType() ||
2717 return AA->isAlignmentDependent();
2736 if (
auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
2738 auto From = VDTemplSpec->getInstantiatedFrom();
2739 if (
auto *VTD = dyn_cast<VarTemplateDecl *>(From)) {
2740 while (!VTD->isMemberSpecialization()) {
2741 auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
2746 return VTD->getTemplatedDecl();
2749 dyn_cast<VarTemplatePartialSpecializationDecl *>(From)) {
2750 while (!VTPSD->isMemberSpecialization()) {
2751 auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
2763 return const_cast<VarDecl *
>(VD);
2774 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2775 return Spec->getSpecializationKind();
2778 return MSI->getTemplateSpecializationKind();
2786 return MSI->getTemplateSpecializationKind();
2788 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2789 return Spec->getSpecializationKind();
2795 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2796 return Spec->getPointOfInstantiation();
2799 return MSI->getPointOfInstantiation();
2805 return dyn_cast_if_present<VarTemplateDecl *>(
2822 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&
2839 RSDKind K = Ctx.
getLangOpts().getRegisterStaticDestructors();
2840 return K == RSDKind::None ||
2857 assert(
hasInit() &&
"Expect initializer to check for flexible array init");
2859 if (!D || !D->hasFlexibleArrayMember())
2861 auto *List = dyn_cast<InitListExpr>(
getInit()->IgnoreParens());
2864 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
2872 assert(
hasInit() &&
"Expect initializer to check for flexible array init");
2874 if (!RD || !RD->hasFlexibleArrayMember())
2876 auto *List = dyn_cast<InitListExpr>(
getInit()->IgnoreParens());
2877 if (!List || List->getNumInits() == 0)
2879 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);
2887 if (FlexibleArrayOffset + FlexibleArraySize < RL.
getSize())
2889 return FlexibleArrayOffset + FlexibleArraySize - RL.
getSize();
2894 return dyn_cast_if_present<MemberSpecializationInfo *>(
2903 "not a variable or static data member template specialization");
2906 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2907 Spec->setSpecializationKind(TSK);
2909 PointOfInstantiation.
isValid() &&
2910 Spec->getPointOfInstantiation().isInvalid()) {
2911 Spec->setPointOfInstantiation(PointOfInstantiation);
2913 L->InstantiationRequested(
this);
2916 MSI->setTemplateSpecializationKind(TSK);
2918 MSI->getPointOfInstantiation().isInvalid()) {
2919 MSI->setPointOfInstantiation(PointOfInstantiation);
2921 L->InstantiationRequested(
this);
2929 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2930 "Previous template or instantiation?");
2936 if (
Type.hasAddressSpace())
2970 return new (
C, DC)
ParmVarDecl(ParmVar,
C, DC, StartLoc, IdLoc, Id, T, TInfo,
2977 if (
const auto *DT = dyn_cast<DecayedType>(T))
2978 return DT->getOriginalType();
3011 if (RT && RT->getDecl()->getDefinitionOrSelf()->isParamDestroyedInCallee() &&
3021 "Default argument is not yet instantiated!");
3024 if (
auto *E = dyn_cast_if_present<FullExpr>(Arg))
3025 return E->getSubExpr();
3047 return E->getSourceRange();
3052 llvm_unreachable(
"Invalid default argument kind.");
3062 "Wrong kind of initialization expression!");
3074void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
3079unsigned ParmVarDecl::getParameterIndexLarge()
const {
3098 assert(T.isNull() || T->isFunctionType());
3127 if (TrailingRequiresClause)
3136 printTemplateArgumentList(OS, TemplateArgs->
asArray(), Policy);
3140 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
3141 return FT->isVariadic();
3149 static constexpr size_t Alignment =
3152 size_t Size = totalSizeToAlloc<DeclAccessPair, StringLiteral *>(
3153 Lookups.size(), DeletedMessage !=
nullptr);
3157 Info->NumLookups = Lookups.size();
3158 Info->HasDeletedMessage = DeletedMessage !=
nullptr;
3159 Info->FPFeatures = FPFeatures;
3161 llvm::uninitialized_copy(Lookups, Info->getTrailingObjects<
DeclAccessPair>());
3163 *Info->getTrailingObjects<
StringLiteral *>() = DeletedMessage;
3169 assert(Info &&
"expected defaulted or deleted function info");
3170 assert(!
FunctionDeclBits.HasDefaultedOrDeletedInfo &&
"already have this");
3171 assert(!
Body &&
"can't replace function body with defaulted function info");
3196 assert(HasDeletedMessage &&
3197 "No space to store a delete message in this DefaultedOrDeletedInfo");
3198 *getTrailingObjects<StringLiteral *>() = Message;
3208 for (
const auto *I :
redecls()) {
3209 if (I->doesThisDeclarationHaveABody()) {
3239 return InstantiatedFrom->getFriendObjectKind() &&
3240 InstantiatedFrom->isThisDeclarationADefinition();
3246 Template->getInstantiatedFromMemberTemplate())
3247 return InstantiatedFrom->getFriendObjectKind() &&
3248 InstantiatedFrom->isThisDeclarationADefinition();
3255 bool CheckForPendingFriendDefinition)
const {
3257 if (FD->isThisDeclarationADefinition()) {
3277 if (CheckForPendingFriendDefinition &&
3278 FD->isThisDeclarationInstantiatedFromAFriendDefinition()) {
3291 assert(!
Definition->FunctionDeclBits.HasDefaultedOrDeletedInfo &&
3292 "definition should not have a body");
3308 if (
auto *MD = dyn_cast<CXXMethodDecl>(
this)) {
3310 if (Ctor->isDefaultConstructor())
3313 if (Ctor->isCopyConstructor())
3316 if (Ctor->isMoveConstructor())
3320 if (MD->isCopyAssignmentOperator())
3323 if (MD->isMoveAssignmentOperator())
3333 switch (
getDeclName().getCXXOverloadedOperator()) {
3347 case OO_ExclaimEqual:
3360 case OO_GreaterEqual:
3378 Parent->markedVirtualFunctionPure();
3381template<std::
size_t Len>
3384 return II && II->
isStr(Str);
3399 if (
auto *CD = dyn_cast<CXXConstructorDecl>(
this);
3400 CD && CD->isInheritingConstructor())
3401 return CD->getInheritedConstructor().getConstructor();
3427 if (
auto *CD = dyn_cast<CXXConstructorDecl>(
this);
3428 CD && CD->isInheritingConstructor())
3429 return CD->getInheritedConstructor()
3431 ->isImmediateFunction();
3437 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
this);
3438 MD && MD->isLambdaStaticInvoker())
3439 return MD->getParent()->getLambdaCallOperator()->isImmediateFunction();
3469 return llvm::StringSwitch<bool>(
getName())
3490 if (proto->getNumParams() != 2 || proto->isVariadic())
3499 return (proto->getParamType(1).getCanonicalType() == Context.VoidPtrTy);
3519 unsigned RequiredParameterCount =
3538 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 4)
3543 if (FPT->getNumParams() == 1)
3546 unsigned Params = 1;
3547 QualType Ty = FPT->getParamType(Params);
3550 auto Consume = [&] {
3552 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) :
QualType();
3556 bool IsSizedDelete =
false;
3560 IsSizedDelete =
true;
3569 *AlignmentParam = Params;
3592 T = TD->getDecl()->getUnderlyingType();
3594 T->castAsCanonical<EnumType>()->getDecl()->getIdentifier();
3595 if (II && II->
isStr(
"__hot_cold_t"))
3599 return Params == FPT->getNumParams();
3615 switch (Context.GetGVALinkageForFunction(
Definition)) {
3624 llvm_unreachable(
"Unknown GVALinkage");
3686 assert(AI == AE &&
"unexpected usual deallocation function parameter");
3709 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
this))
3710 return Method->isStatic();
3719 if (!Namespace->getDeclName())
3732 if (
auto *FnTy =
getType()->getAs<FunctionType>())
3733 return FnTy->getNoReturnAttr();
3815 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
3816 FunTmpl->setPreviousDecl(PrevFunTmpl);
3839 unsigned BuiltinID = 0;
3842 BuiltinID = ABAA->getBuiltinName()->getBuiltinID();
3844 BuiltinID = BAA->getBuiltinName()->getBuiltinID();
3846 BuiltinID = A->getID();
3859 BuiltinID == Builtin::BI__builtin_counted_by_ref)
3863 if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
3876 if (Context.getLangOpts().OpenCL &&
3877 Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
3884 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3890 if (Context.getTargetInfo().getTriple().isAMDGCN() &&
3891 Context.getLangOpts().OpenMPIsTargetDevice &&
3892 Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID) &&
3893 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3908 const auto *MD = dyn_cast<CXXMethodDecl>(
this);
3909 return getNumParams() + (MD && MD->isImplicitObjectMemberFunction());
3914 assert(!ParamInfo &&
"Already has param info!");
3915 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
3918 if (!NewParamInfo.empty()) {
3920 llvm::copy(NewParamInfo, ParamInfo);
3934 unsigned NumRequiredArgs = 0;
3935 unsigned MinParamsSoFar = 0;
3937 if (!Param->isParameterPack()) {
3939 if (!Param->hasDefaultArg())
3940 NumRequiredArgs = MinParamsSoFar;
3943 return NumRequiredArgs;
3973 assert(
isInlined() &&
"expected to get called on an inlined function!");
3976 if (!Context.getTargetInfo().getCXXABI().isMicrosoft() &&
3982 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3994 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
4024 "Must have a declaration without a body.");
4028 if (Context.getLangOpts().MSVCCompat) {
4035 if (Context.getLangOpts().CPlusPlus)
4048 bool FoundBody =
false;
4073 bool FoundBody =
false;
4093 TL = PTL.getInnerLoc();
4095 TL = ATL.getEquivalentTypeLoc();
4097 TL = MQTL.getInnerLoc();
4126 NP > 0 ? ParamInfo[0]->getSourceRange().getBegin() : EllipsisLoc;
4129 : ParamInfo[NP - 1]->getSourceRange().getEnd();
4159 "Must be a function definition");
4160 assert(
isInlined() &&
"Function must be inline");
4170 if (Context.getLangOpts().CPlusPlus)
4177 for (
auto *Redecl :
redecls()) {
4178 if (Redecl->isInlineSpecified() &&
4187 assert(!Context.getLangOpts().CPlusPlus &&
4188 "should not use C inline rules in C++");
4194 for (
auto *Redecl :
redecls()) {
4223 if (TemplateOrSpecialization.isNull())
4225 if (
const auto *ND = dyn_cast<NamedDecl *>(TemplateOrSpecialization)) {
4229 "No other valid types in NamedDecl");
4237 TemplateOrSpecialization))
4240 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
4251 if (
auto *MSI = dyn_cast_if_present<MemberSpecializationInfo *>(
4252 TemplateOrSpecialization))
4254 if (
auto *FTSI = dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4255 TemplateOrSpecialization))
4256 return FTSI->getMemberSpecializationInfo();
4261FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &
C,
4264 assert(TemplateOrSpecialization.isNull() &&
4265 "Member function is already a specialization");
4268 TemplateOrSpecialization = Info;
4272 return dyn_cast_if_present<FunctionTemplateDecl>(
4273 dyn_cast_if_present<NamedDecl *>(TemplateOrSpecialization));
4278 assert(TemplateOrSpecialization.isNull() &&
4279 "Member function is already a specialization");
4280 TemplateOrSpecialization =
Template;
4286 TemplateOrSpecialization);
4290 assert(TemplateOrSpecialization.isNull() &&
4291 "Function is already a specialization");
4292 TemplateOrSpecialization = FD;
4296 return dyn_cast_if_present<FunctionDecl>(
4297 dyn_cast<NamedDecl *>(TemplateOrSpecialization));
4321 bool HasPattern =
false;
4323 HasPattern = PatternDecl->
hasBody(PatternDecl);
4329 if (!HasPattern || !PatternDecl)
4353 dyn_cast<CXXMethodDecl>(
this))) {
4365 if (ForDefinition &&
4371 if (ForDefinition &&
4378 while (!ForDefinition || !Primary->isMemberSpecialization()) {
4379 auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();
4382 Primary = NewPrimary;
4385 return Primary->getTemplatedDecl();
4393 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4394 TemplateOrSpecialization)) {
4395 return Info->getTemplate();
4402 return dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4403 TemplateOrSpecialization);
4409 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4410 TemplateOrSpecialization)) {
4411 return Info->TemplateArguments;
4419 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4420 TemplateOrSpecialization)) {
4421 return Info->TemplateArgumentsAsWritten;
4424 dyn_cast_if_present<DependentFunctionTemplateSpecializationInfo *>(
4425 TemplateOrSpecialization)) {
4426 return Info->TemplateArgumentsAsWritten;
4431void FunctionDecl::setFunctionTemplateSpecialization(
4437 assert((TemplateOrSpecialization.isNull() ||
4439 "Member function is already a specialization");
4441 "Must specify the type of function template specialization");
4442 assert((TemplateOrSpecialization.isNull() ||
4445 "Member specialization must be an explicit specialization");
4448 C,
this,
Template, TSK, TemplateArgs, TemplateArgsAsWritten,
4449 PointOfInstantiation,
4450 dyn_cast_if_present<MemberSpecializationInfo *>(
4451 TemplateOrSpecialization));
4452 TemplateOrSpecialization = Info;
4453 Template->addSpecialization(Info, InsertToken);
4459 assert(TemplateOrSpecialization.isNull());
4463 TemplateOrSpecialization = Info;
4468 return dyn_cast_if_present<DependentFunctionTemplateSpecializationInfo *>(
4469 TemplateOrSpecialization);
4476 const auto *TArgsWritten =
4478 return new (Context.Allocate(
4479 totalSizeToAlloc<FunctionTemplateDecl *>(Candidates.
size())))
4480 DependentFunctionTemplateSpecializationInfo(Candidates, TArgsWritten);
4483DependentFunctionTemplateSpecializationInfo::
4484 DependentFunctionTemplateSpecializationInfo(
4487 : NumCandidates(Candidates.size()),
4488 TemplateArgumentsAsWritten(TemplateArgsWritten) {
4489 std::transform(Candidates.
begin(), Candidates.
end(), getTrailingObjects(),
4499 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4500 TemplateOrSpecialization))
4501 return FTSInfo->getTemplateSpecializationKind();
4504 dyn_cast_if_present<MemberSpecializationInfo *>(
4505 TemplateOrSpecialization))
4506 return MSInfo->getTemplateSpecializationKind();
4511 TemplateOrSpecialization) &&
4543 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4544 TemplateOrSpecialization)) {
4545 if (
auto *MSInfo = FTSInfo->getMemberSpecializationInfo())
4546 return MSInfo->getTemplateSpecializationKind();
4547 return FTSInfo->getTemplateSpecializationKind();
4551 dyn_cast_if_present<MemberSpecializationInfo *>(
4552 TemplateOrSpecialization))
4553 return MSInfo->getTemplateSpecializationKind();
4556 TemplateOrSpecialization) &&
4567 dyn_cast<FunctionTemplateSpecializationInfo *>(
4568 TemplateOrSpecialization)) {
4569 FTSInfo->setTemplateSpecializationKind(TSK);
4571 PointOfInstantiation.
isValid() &&
4572 FTSInfo->getPointOfInstantiation().isInvalid()) {
4573 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
4575 L->InstantiationRequested(
this);
4578 dyn_cast<MemberSpecializationInfo *>(
4579 TemplateOrSpecialization)) {
4580 MSInfo->setTemplateSpecializationKind(TSK);
4582 PointOfInstantiation.
isValid() &&
4583 MSInfo->getPointOfInstantiation().isInvalid()) {
4584 MSInfo->setPointOfInstantiation(PointOfInstantiation);
4586 L->InstantiationRequested(
this);
4589 llvm_unreachable(
"Function cannot have a template specialization kind");
4593 auto HasImplicitAttr = [
this](
const Attr *A) {
4605 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
this))
4606 if (
const auto *Spec =
4607 dyn_cast<ClassTemplateSpecializationDecl>(MD->getParent()))
4608 return IsExplicitInstTSK(Spec->getTemplateSpecializationKind());
4614 dyn_cast_if_present<FunctionTemplateSpecializationInfo *>(
4615 TemplateOrSpecialization))
4616 return FTSInfo->getPointOfInstantiation();
4618 dyn_cast_if_present<MemberSpecializationInfo *>(
4619 TemplateOrSpecialization))
4620 return MSInfo->getPointOfInstantiation();
4641 if (FunTmpl->getTemplatedDecl()->hasBody(
Definition))
4660 case Builtin::BI__builtin_memset:
4661 case Builtin::BI__builtin___memset_chk:
4662 case Builtin::BImemset:
4663 return Builtin::BImemset;
4665 case Builtin::BI__builtin_memcpy:
4666 case Builtin::BI__builtin___memcpy_chk:
4667 case Builtin::BImemcpy:
4668 return Builtin::BImemcpy;
4670 case Builtin::BI__builtin_mempcpy:
4671 case Builtin::BI__builtin___mempcpy_chk:
4672 case Builtin::BImempcpy:
4673 return Builtin::BImempcpy;
4675 case Builtin::BI__builtin_trivially_relocate:
4676 case Builtin::BI__builtin_memmove:
4677 case Builtin::BI__builtin___memmove_chk:
4678 case Builtin::BImemmove:
4679 return Builtin::BImemmove;
4681 case Builtin::BI__builtin_strlcpy:
4682 case Builtin::BIstrlcpy:
4683 case Builtin::BI__builtin___strlcpy_chk:
4684 return Builtin::BIstrlcpy;
4686 case Builtin::BI__builtin_strlcat:
4687 case Builtin::BIstrlcat:
4688 case Builtin::BI__builtin___strlcat_chk:
4689 return Builtin::BIstrlcat;
4691 case Builtin::BI__builtin_memcmp:
4692 case Builtin::BImemcmp:
4693 return Builtin::BImemcmp;
4695 case Builtin::BI__builtin_bcmp:
4696 case Builtin::BIbcmp:
4697 return Builtin::BIbcmp;
4699 case Builtin::BI__builtin_strncpy:
4700 case Builtin::BI__builtin___strncpy_chk:
4701 case Builtin::BIstrncpy:
4702 return Builtin::BIstrncpy;
4704 case Builtin::BI__builtin_strncmp:
4705 case Builtin::BIstrncmp:
4706 return Builtin::BIstrncmp;
4708 case Builtin::BI__builtin_strncasecmp:
4709 case Builtin::BIstrncasecmp:
4710 return Builtin::BIstrncasecmp;
4712 case Builtin::BI__builtin_strncat:
4713 case Builtin::BI__builtin___strncat_chk:
4714 case Builtin::BIstrncat:
4715 return Builtin::BIstrncat;
4717 case Builtin::BI__builtin_strndup:
4718 case Builtin::BIstrndup:
4719 return Builtin::BIstrndup;
4721 case Builtin::BI__builtin_strlen:
4722 case Builtin::BIstrlen:
4723 return Builtin::BIstrlen;
4725 case Builtin::BI__builtin_bzero:
4726 case Builtin::BIbzero:
4727 return Builtin::BIbzero;
4729 case Builtin::BI__builtin_bcopy:
4730 case Builtin::BIbcopy:
4731 return Builtin::BIbcopy;
4733 case Builtin::BIfree:
4734 return Builtin::BIfree;
4738 if (FnInfo->
isStr(
"memset"))
4739 return Builtin::BImemset;
4740 if (FnInfo->
isStr(
"memcpy"))
4741 return Builtin::BImemcpy;
4742 if (FnInfo->
isStr(
"mempcpy"))
4743 return Builtin::BImempcpy;
4744 if (FnInfo->
isStr(
"memmove"))
4745 return Builtin::BImemmove;
4746 if (FnInfo->
isStr(
"memcmp"))
4747 return Builtin::BImemcmp;
4748 if (FnInfo->
isStr(
"bcmp"))
4749 return Builtin::BIbcmp;
4750 if (FnInfo->
isStr(
"strncpy"))
4751 return Builtin::BIstrncpy;
4752 if (FnInfo->
isStr(
"strncmp"))
4753 return Builtin::BIstrncmp;
4754 if (FnInfo->
isStr(
"strncasecmp"))
4755 return Builtin::BIstrncasecmp;
4756 if (FnInfo->
isStr(
"strncat"))
4757 return Builtin::BIstrncat;
4758 if (FnInfo->
isStr(
"strndup"))
4759 return Builtin::BIstrndup;
4760 if (FnInfo->
isStr(
"strlen"))
4761 return Builtin::BIstrlen;
4762 if (FnInfo->
isStr(
"bzero"))
4763 return Builtin::BIbzero;
4764 if (FnInfo->
isStr(
"bcopy"))
4765 return Builtin::BIbcopy;
4766 if (FnInfo->
isStr(
"strlcat"))
4767 return Builtin::BIstrlcat;
4768 if (FnInfo->
isStr(
"strlcpy"))
4769 return Builtin::BIstrlcpy;
4771 if (FnInfo->
isStr(
"free"))
4772 return Builtin::BIfree;
4780 assert(hasODRHash());
4789 setHasODRHash(
true);
4790 ODRHash = FT->getODRHash();
4796 setHasODRHash(
true);
4810 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
4811 BW, Mutable, InitStyle);
4824 if (
const auto *
Record =
getType()->getAsCanonical<RecordType>())
4825 return Record->getDecl()->isAnonymousStructOrUnion();
4835 return cast_if_present<Expr>(
4837 : InitPtr.
get(
nullptr));
4853 const auto *CE = dyn_cast_if_present<ConstantExpr>(
getBitWidth());
4854 return CE && CE->getAPValueResult().isInt();
4861 ->getAPValueResult()
4887 assert(
isInvalidDecl() &&
"valid field has incomplete type");
4894 if (!CXXRD->isEmpty())
4904 return !llvm::any_of(CXXRD->fields(), [](
const FieldDecl *Field) {
4905 return Field->getType()->isRecordType();
4913void FieldDecl::setCachedFieldIndex()
const {
4915 "should be called on the canonical decl");
4919 assert(RD &&
"requested index for field of struct with no definition");
4921 for (
auto *Field : RD->
fields()) {
4922 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
4923 assert(Field->getCanonicalDecl()->CachedFieldIndex == Index + 1 &&
4924 "overflow in field numbering");
4928 assert(CachedFieldIndex &&
"failed to find field in parent");
4942 "capturing type in non-lambda or captured record.");
4943 assert(StorageKind == ISK_NoInit && !BitField &&
4944 "bit-field or field with default member initializer cannot capture "
4946 StorageKind = ISK_CapturedVLAType;
4969 const auto *CountDRE = dyn_cast<DeclRefExpr>(CAT->getCountExpr());
4972 const auto *CountDecl = CountDRE->getDecl();
4973 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl))
4974 CountDecl = IFD->getAnonField();
4976 return dyn_cast<FieldDecl>(CountDecl);
4989 "EnumDecl not matched with TagTypeKind::Enum");
4997 TagDeclBits.IsThisDeclarationADemotedDefinition =
false;
5013 TypedefNameDeclOrQualifier = TDD;
5020 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
5021 struct CXXRecordDecl::DefinitionData *
Data =
5022 new (
getASTContext())
struct CXXRecordDecl::DefinitionData(D);
5031 "definition completed but not started");
5037 L->CompletedTagDefinition(
this);
5042 return const_cast<TagDecl *
>(
this);
5044 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
5045 return CXXRD->getDefinition();
5049 if (R->isCompleteDefinition() || R->isBeingDefined())
5060 getExtInfo()->QualifierLoc = QualifierLoc;
5064 if (getExtInfo()->NumTemplParamLists == 0) {
5069 getExtInfo()->QualifierLoc = QualifierLoc;
5085 WrittenFile = Callbacks->remapPath(
File);
5089 llvm::sys::path::Style Style =
5090 llvm::sys::path::is_absolute(WrittenFile)
5091 ? llvm::sys::path::Style::native
5092 : (Policy.MSVCFormatting ? llvm::sys::path::Style::windows_backslash
5093 : llvm::sys::path::Style::posix);
5094 llvm::sys::path::native(WrittenFile, Style);
5101 assert(
Typedef->getIdentifier() &&
"Typedef without identifier?");
5102 OS <<
Typedef->getIdentifier()->getName();
5112 SuppressTagKeywordInName =
true;
5117 OS << (Policy.MSVCFormatting ?
'`' :
'(');
5121 SuppressTagKeywordInName =
true;
5129 if (!SuppressTagKeywordInName)
5136 OS << (Policy.MSVCFormatting ?
'\'' :
')');
5143 if (Name.isIdentifier() && !Name.getAsIdentifierInfo()) {
5150 Name.print(OS, Policy);
5155 assert(!TPLists.empty());
5161 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
5170 bool Scoped,
bool ScopedUsingClassTag,
bool Fixed)
5172 assert(Scoped || !ScopedUsingClassTag);
5173 IntegerType =
nullptr;
5174 setNumPositiveBits(0);
5175 setNumNegativeBits(0);
5177 setScopedUsingClassTag(ScopedUsingClassTag);
5179 setHasODRHash(
false);
5183void EnumDecl::anchor() {}
5188 EnumDecl *PrevDecl,
bool IsScoped,
5189 bool IsScopedUsingClassTag,
bool IsFixed) {
5190 return new (
C, DC) EnumDecl(
C, DC, StartLoc, IdLoc, Id, PrevDecl, IsScoped,
5191 IsScopedUsingClassTag, IsFixed);
5196 nullptr,
nullptr,
false,
false,
false);
5201 return TI->getTypeLoc().getSourceRange();
5207 unsigned NumPositiveBits,
5208 unsigned NumNegativeBits) {
5212 PromotionType = NewPromotionType;
5213 setNumPositiveBits(NumPositiveBits);
5214 setNumNegativeBits(NumNegativeBits);
5220 return A->getExtensibility() == EnumExtensibilityAttr::Closed;
5234 return MSI->getTemplateSpecializationKind();
5242 assert(MSI &&
"Not an instantiated member enumeration?");
5245 PointOfInstantiation.
isValid() &&
5261 "couldn't find pattern for enum instantiation");
5266 if (SpecializationInfo)
5267 return cast<EnumDecl>(SpecializationInfo->getInstantiatedFrom());
5274 assert(!SpecializationInfo &&
"Member enum is already a specialization");
5284 setHasODRHash(
true);
5295 Res.setEnd(TSI->getTypeLoc().getEndLoc());
5305 if (NumNegativeBits) {
5306 unsigned NumBits = std::max(NumNegativeBits, NumPositiveBits + 1);
5307 Max = llvm::APInt(Bitwidth, 1) << (NumBits - 1);
5310 Max = llvm::APInt(Bitwidth, 1) << NumPositiveBits;
5311 Min = llvm::APInt::getZero(Bitwidth);
5323 :
TagDecl(DK, TK,
C, DC, IdLoc, Id, PrevDecl, StartLoc) {
5324 assert(
classof(
static_cast<Decl *
>(
this)) &&
"Invalid Kind!");
5358 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
5376 for (
const FieldDecl *FD : Def->fields()) {
5378 if (RT && RT->getDecl()->isOrContainsUnion())
5388 LoadFieldsFromExternalStorage();
5392 return D->field_begin();
5428 auto LayoutCompatibility =
C.getLangOpts().getLayoutCompatibility();
5430 return C.defaultsToMsStruct();
5436 LastDecl->NextInContextAndBits.setPointer(
nullptr);
5440void RecordDecl::LoadFieldsFromExternalStorage()
const {
5449 Source->FindExternalLexicalDecls(
this, [](
Decl::Kind K) {
5455 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
5462 auto [ExternalFirst, ExternalLast] =
5465 ExternalLast->NextInContextAndBits.setPointer(
FirstDecl);
5473 const SanitizerMask EnabledAsanMask = Context.getLangOpts().Sanitize.Mask &
5474 (SanitizerKind::Address | SanitizerKind::KernelAddress);
5475 if (!EnabledAsanMask || !Context.getLangOpts().SanitizeAddressFieldPadding)
5478 const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this);
5480 int ReasonToReject = -1;
5481 if (!CXXRD || CXXRD->isExternCContext())
5483 else if (CXXRD->hasAttr<PackedAttr>())
5485 else if (CXXRD->isUnion())
5487 else if (CXXRD->isTriviallyCopyable())
5489 else if (CXXRD->hasTrivialDestructor())
5491 else if (CXXRD->isStandardLayout())
5501 if (ReasonToReject >= 0)
5502 Context.getDiagnostics().Report(
5504 diag::remark_sanitize_address_insert_extra_padding_rejected)
5507 Context.getDiagnostics().Report(
5509 diag::remark_sanitize_address_insert_extra_padding_accepted)
5512 return ReasonToReject < 0;
5516 for (
const auto *I :
fields()) {
5517 if (I->getIdentifier())
5520 if (
const auto *RD = I->getType()->getAsRecordDecl())
5522 return NamedDataMember;
5557 assert(!ParamInfo &&
"Already has param info!");
5560 if (!NewParamInfo.empty()) {
5561 NumParams = NewParamInfo.size();
5563 llvm::copy(NewParamInfo, ParamInfo);
5569 this->CXXThisType = CXXThisType;
5570 this->NumCaptures = Captures.size();
5572 if (Captures.empty()) {
5573 this->Captures =
nullptr;
5577 this->Captures = Captures.copy(Context).data();
5583 if (I.getVariable() == variable)
5597void TranslationUnitDecl::anchor() {}
5600 return new (
C, (
DeclContext *)
nullptr) TranslationUnitDecl(
C);
5604 AnonymousNamespace = D;
5607 Listener->AddedAnonymousNamespace(
this, D);
5610void PragmaCommentDecl::anchor() {}
5617 PragmaCommentDecl *PCD =
5618 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
5619 PragmaCommentDecl(DC, CommentLoc, CommentKind);
5620 llvm::copy(Arg, PCD->getTrailingObjects());
5621 PCD->getTrailingObjects()[Arg.size()] =
'\0';
5628 return new (
C, ID, additionalSizeToAlloc<char>(ArgSize + 1))
5632void PragmaDetectMismatchDecl::anchor() {}
5638 size_t ValueStart = Name.size() + 1;
5639 PragmaDetectMismatchDecl *PDMD =
5640 new (
C, DC, additionalSizeToAlloc<char>(ValueStart +
Value.size() + 1))
5641 PragmaDetectMismatchDecl(DC, Loc, ValueStart);
5642 llvm::copy(Name, PDMD->getTrailingObjects());
5643 PDMD->getTrailingObjects()[Name.size()] =
'\0';
5644 llvm::copy(
Value, PDMD->getTrailingObjects() + ValueStart);
5645 PDMD->getTrailingObjects()[ValueStart +
Value.size()] =
'\0';
5651 unsigned NameValueSize) {
5652 return new (
C, ID, additionalSizeToAlloc<char>(NameValueSize + 1))
5656void ExternCContextDecl::anchor() {}
5660 return new (
C, DC) ExternCContextDecl(DC);
5663void LabelDecl::anchor() {}
5667 return new (
C, DC) LabelDecl(DC, IdentL, II,
nullptr, IdentL);
5673 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
5674 return new (
C, DC) LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
5678 return new (
C, ID) LabelDecl(
nullptr,
SourceLocation(),
nullptr,
nullptr,
5683char *Buffer =
new (
getASTContext(), 1)
char[Name.size() + 1];
5684llvm::copy(Name, Buffer);
5685Buffer[Name.size()] =
'\0';
5689void ValueDecl::anchor() {}
5693 return MostRecent->hasAttr<WeakAttr>() ||
5698 if (
auto *Var = llvm::dyn_cast<VarDecl>(
this))
5699 return Var->isInitCapture();
5704 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
this))
5705 return NTTP->isParameterPack();
5707 return isa_and_nonnull<PackExpansionType>(
getType().getTypePtrOrNull());
5710void ImplicitParamDecl::anchor() {}
5768OutlinedFunctionDecl::OutlinedFunctionDecl(
DeclContext *DC,
unsigned NumParams)
5770 DeclContext(OutlinedFunction), NumParams(NumParams),
5775 unsigned NumParams) {
5776 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5777 OutlinedFunctionDecl(DC, NumParams);
5782 unsigned NumParams) {
5783 return new (
C, ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5784 OutlinedFunctionDecl(
nullptr, NumParams);
5788 return BodyAndNothrow.getPointer();
5794 BodyAndNothrow.setInt(Nothrow);
5797CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
5799 NumParams(NumParams), ContextParam(0), BodyAndNothrow(
nullptr,
false) {}
5802 unsigned NumParams) {
5803 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5804 CapturedDecl(DC, NumParams);
5808 unsigned NumParams) {
5809 return new (
C, ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
5810 CapturedDecl(
nullptr, NumParams);
5829 Expr *E,
const llvm::APSInt &
V) {
5836 QualType(),
nullptr, llvm::APSInt());
5839void IndirectFieldDecl::anchor() {}
5845 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),
5846 ChainingSize(CH.size()) {
5849 if (
C.getLangOpts().CPlusPlus)
5858 return new (
C, DC) IndirectFieldDecl(
C, DC, L, Id, T, CH);
5870 End = Init->getEndLoc();
5874void TypeDecl::anchor() {}
5880 return new (
C, DC) TypedefDecl(
C, DC, StartLoc, IdLoc, Id, TInfo);
5883void TypedefNameDecl::anchor() {}
5887 auto *OwningTypedef = TT->getDecl()->getTypedefNameForAnonDecl();
5888 auto *ThisTypedef =
this;
5889 if (AnyRedecl && OwningTypedef) {
5890 OwningTypedef = OwningTypedef->getCanonicalDecl();
5891 ThisTypedef = ThisTypedef->getCanonicalDecl();
5893 if (OwningTypedef == ThisTypedef)
5894 return TT->getDecl()->getDefinitionOrSelf();
5900bool TypedefNameDecl::isTransparentTagSlow()
const {
5901 auto determineIsTransparent = [&]() {
5903 if (
auto *TD = TT->getDecl()) {
5904 if (TD->getName() !=
getName())
5917 bool isTransparent = determineIsTransparent();
5918 MaybeModedTInfo.setInt((isTransparent << 1) | 1);
5919 return isTransparent;
5932 return new (
C, DC) TypeAliasDecl(
C, DC, StartLoc, IdLoc, Id, TInfo);
5944 if (TInfo->getType().hasPostfixDeclaratorSyntax())
5945 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
5953 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
5957void FileScopeAsmDecl::anchor() {}
5962 return new (
C, DC) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc);
5967 return new (
C, ID) FileScopeAsmDecl(
nullptr,
nullptr,
SourceLocation(),
5975void TopLevelStmtDecl::anchor() {}
5978 assert(
C.getLangOpts().IncrementalExtensions &&
5979 "Must be used only in incremental mode");
5984 auto *D =
new (
C, DC) TopLevelStmtDecl(DC, Loc, Statement);
5985 D->Ordinal =
C.NumTopLevelStmtDecls++;
6005void EmptyDecl::anchor() {}
6008 return new (
C, DC) EmptyDecl(DC, L);
6015HLSLBufferDecl::HLSLBufferDecl(
DeclContext *DC,
bool CBuffer,
6020 IsCBuffer(CBuffer), HasValidPackoffset(
false), LayoutStruct(
nullptr) {}
6040 new (
C, DC) HLSLBufferDecl(DC, CBuffer, KwLoc, ID, IDLoc, LBrace);
6048 IdentifierInfo *II = &
C.Idents.get(
"$Globals", tok::TokenKind::identifier);
6049 HLSLBufferDecl *
Result =
new (
C, DC) HLSLBufferDecl(
6051 Result->setImplicit(
true);
6052 Result->setDefaultBufferDecls(DefaultCBufferDecls);
6058 return new (
C, ID) HLSLBufferDecl(
nullptr,
false,
SourceLocation(),
nullptr,
6063 assert(LayoutStruct ==
nullptr &&
"layout struct has already been set");
6069 assert(!Decls.empty());
6070 assert(DefaultBufferDecls.empty() &&
"default decls are already set");
6072 "default decls can only be added to the implicit/default constant "
6077 llvm::copy(Decls, DeclsArray);
6084 DefaultBufferDecls.end()),
6090 llvm::iterator_range(DefaultBufferDecls.end(), DefaultBufferDecls.end()),
6095 return DefaultBufferDecls.empty() &&
decls_empty();
6102HLSLRootSignatureDecl::HLSLRootSignatureDecl(
6104 llvm::dxbc::RootSignatureVersion Version,
unsigned NumElems)
6106 Version(Version), NumElems(NumElems) {}
6110 llvm::dxbc::RootSignatureVersion Version,
6112 HLSLRootSignatureDecl *RSDecl =
6114 additionalSizeToAlloc<llvm::hlsl::rootsig::RootElement>(
6115 RootElements.size()))
6116 HLSLRootSignatureDecl(DC, Loc, ID, Version, RootElements.size());
6117 auto *StoredElems = RSDecl->getElems();
6118 llvm::uninitialized_copy(RootElements, StoredElems);
6124 HLSLRootSignatureDecl *
Result =
new (
C, ID)
6126 llvm::dxbc::RootSignatureVersion::V1_1,
6149 :
Decl(
Import, DC, StartLoc), ImportedModule(Imported),
6152 auto *StoredLocs = getTrailingObjects();
6153 llvm::uninitialized_copy(IdentifierLocs, StoredLocs);
6158 :
Decl(
Import, DC, StartLoc), ImportedModule(Imported),
6160 *getTrailingObjects() = EndLoc;
6167 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
6168 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
6175 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
6176 ImportDecl(DC, StartLoc, Imported, EndLoc);
6177 Import->setImplicit();
6182 unsigned NumLocations) {
6183 return new (
C, ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
6188 if (!isImportComplete())
6195 if (!isImportComplete())
6205void ExportDecl::anchor() {}
6209 return new (
C, DC) ExportDecl(DC, ExportLoc);
6217 bool IncludeLocallyStreaming) {
6218 if (IncludeLocallyStreaming)
6219 if (FD->
hasAttr<ArmLocallyStreamingAttr>())
6222 assert(!FD->
getType().
isNull() &&
"Expected a valid FunctionDecl");
6234 (FD->
hasAttr<ArmNewAttr>() && FD->
getAttr<ArmNewAttr>()->isNewZA());
6241 (FD->
hasAttr<ArmNewAttr>() && FD->
getAttr<ArmNewAttr>()->isNewZT0());
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.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static bool isFirstInExternCContext(T *D)
static bool isRedeclarableImpl(Redeclarable< T > *)
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 isStaticDataMemberOutOfLine(const VarDecl *VD)
static bool isRedeclarable(Decl::Kind K)
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 std::optional< Visibility > getVisibilityOf(const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind)
Return the explicit visibility of the given declaration.
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::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 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 const Decl * getOutermostFuncOrBlockContext(const Decl *D)
static LinkageInfo getExternalLinkageFor(const NamedDecl *D)
static StorageClass getStorageClass(const Decl *D)
static std::optional< Visibility > getExplicitVisibilityAux(const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent)
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)
static bool isNamed(const NamedDecl *ND, const char(&Str)[Len])
static std::optional< Visibility > getExplicitVisibility(const NamedDecl *D, LVComputationKind kind)
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.
Result
Implement __builtin_bit_cast and related operations.
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,...
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::SanitizerKind enum.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
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.
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 ...
SourceManager & getSourceManager()
const ConstantArrayType * getAsConstantArrayType(QualType T) const
unsigned getIntWidth(QualType T) const
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
void setIsTypeAwareOperatorNewOrDelete(const FunctionDecl *FD, bool IsTypeAware)
void Deallocate(void *Ptr) const
const LangOptions & getLangOpts() 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...
Decl * getPrimaryMergedDecl(Decl *D)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isDestroyingOperatorDelete(const FunctionDecl *FD) const
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 ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
DiagnosticsEngine & getDiagnostics() const
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() 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.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
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...
void setIsDestroyingOperatorDelete(const FunctionDecl *FD, bool IsDestroying)
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.
Attr - This represents one attribute.
Type source information for an attributed type.
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
void setDoesNotEscape(bool B=true)
void setCanAvoidCopyToHeap(bool B=true)
void setIsConversionFromLambda(bool val=true)
void setBlockMissingReturnType(bool val=true)
ArrayRef< Capture > captures() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static BlockDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
void setIsVariadic(bool value)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, QualType CXXThisType)
bool capturesVariable(const VarDecl *var) const
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
Represents a C++ constructor within a class.
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...
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...
This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Construct a CharUnits quantity of zero.
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.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
TagDeclBitfields TagDeclBits
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
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.
DeclContext(Decl::Kind K)
void addDecl(Decl *D)
Add the declaration D into this context.
llvm::iterator_range< decl_iterator > decl_range
decl_iterator decls_end() const
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.
friend class Decl
All declarations that can appear in a module declaration.
bool isInlineNamespace() const
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Decl::Kind getDeclKind() const
decl_iterator decls_begin() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
bool isInStdNamespace() const
SourceLocation getEndLoc() const LLVM_READONLY
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.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool 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.
bool isInvalidDecl() const
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
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'.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
void setLocation(SourceLocation L)
friend class LinkageComputer
DeclContext * getDeclContext()
bool isInAnonymousNamespace() const
void setCachedLinkage(Linkage L) const
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
@ VisiblePromoted
This declaration has an owning module, and is not visible to the current TU but we promoted it to be ...
@ 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.
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.
bool isAnyOperatorDelete() const
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getTypeSpecEndLoc() const
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
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTrailingRequiresClause(const AssociatedConstraint &AC)
TypeSourceInfo * getTypeSourceInfo() const
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.
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
static EmptyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
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.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
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,...
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
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.
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.
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.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
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.
Represents difference between two FPOptions values.
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 getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
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 hasConstantIntegerBitWidth() const
Determines whether the bit width of this field is a constant integer.
static FieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
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)
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
static bool classofKind(Kind K)
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
bool isZeroLengthBitField() const
Is this a zero-length bit-field?
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
const FieldDecl * findCountedByField() const
Find the FieldDecl specified in a FAM's "counted_by" attribute.
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
std::string getAsmString() const
const Expr * getAsmStringExpr() const
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, Expr *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
For a defaulted function, the kind of defaulted function that it is.
Stashed information about a defaulted/deleted function body, including the active FP pragma overrides...
void setDeletedMessage(StringLiteral *Message)
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, FPOptionsOverride FPFeatures, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
static constexpr unsigned RequiredTypeAwareDeleteParameterCount
Count of mandatory parameters for type aware operator delete.
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.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
const ParmVarDecl * getParamDecl(unsigned i) const
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
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)
unsigned getNumParamsIncludingThis() const
Return the number of parameters, including the implicit 'this' parameter if this function has one.
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...
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
ArrayRef< ParmVarDecl * > parameters() const
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...
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause)
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
UsualDeleteParams getUsualDeleteParams() const
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.
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.
static constexpr unsigned RequiredTypeAwareNewParameterCount
Count of mandatory parameters for type aware operator new.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
LazyDeclStmtPtr Body
The body of the function.
bool isImmediateEscalating() const
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
bool isUsableAsGlobalAllocationFunctionInConstantEvaluation(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions described in i...
DefaultedOrDeletedFunctionInfo * DefaultedOrDeletedInfo
Information about a future defaulted function definition.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
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...
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
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.
bool isReferenceableKernel() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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 isAnalyzerNoReturn() const
Determines whether this function is known to be 'noreturn' for analyzer, through an analyzer_noreturn...
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
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 isImplicitHDExplicitInstantiation() const
True if both host and device are implicit attributes and this is (or is a member of) an explicit temp...
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
Redeclarable< FunctionDecl > redeclarable_base
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...
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
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.
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.
Represents a prototype with parameter type info, e.g.
param_type_iterator param_type_begin() const
unsigned getNumParams() const
bool isVariadic() const
Whether this function prototype is variadic.
param_type_iterator param_type_end() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
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
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
static std::string ExtractStringFromGCCAsmStmtComponent(const Expr *E)
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
buffer_decl_iterator buffer_decls_begin() const
static HLSLBufferDecl * Create(ASTContext &C, DeclContext *LexicalParent, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *ID, SourceLocation IDLoc, SourceLocation LBrace)
void addLayoutStruct(CXXRecordDecl *LS)
bool buffer_decls_empty()
llvm::concat_iterator< Decl *const, SmallVector< Decl * >::const_iterator, decl_iterator > buffer_decl_iterator
static HLSLBufferDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
buffer_decl_iterator buffer_decls_end() const
static HLSLBufferDecl * CreateDefaultCBuffer(ASTContext &C, DeclContext *LexicalParent, ArrayRef< Decl * > DefaultCBufferDecls)
static HLSLRootSignatureDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID, llvm::dxbc::RootSignatureVersion Version, ArrayRef< llvm::hlsl::rootsig::RootElement > RootElements)
static HLSLRootSignatureDecl * 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, const IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
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.
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
static bool classofKind(Kind K)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, MutableArrayRef< NamedDecl * > CH)
void setMSAsmLabel(StringRef Name)
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
static LabelDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
@ Microsoft
Use Microsoft C++ ABI rules for bit-field layout and fundamental types alignment.
@ Default
Use default layout rules of the target.
RegisterStaticDestructorsKind
Controls which variables have static destructors registered.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
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.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
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.
std::string getQualifiedNameAsString() const
std::optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
NamedDecl * getMostRecentDecl()
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.
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 partial function definition.
static OutlinedFunctionDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
void setNothrow(bool Nothrow=true)
static OutlinedFunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, 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...
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)
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
void print(raw_ostream &OS) const override
virtual bool isScopeVisible(const DeclContext *DC) const
When printing type to be inserted into code in specific context, this callback can be used to avoid p...
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.
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)
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl)
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
field_iterator noload_field_begin() const
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)
void setHasObjectMember(bool val)
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
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.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
specific_decl_iterator< FieldDecl > field_iterator
void setHasUninitializedExplicitInitFields(bool V)
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
RecordDecl * getDefinitionOrSelf() const
void setHasLoadedFieldsFromExternalStorage(bool val) const
field_iterator field_begin() const
Declaration of a redeclarable template.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Provides common interface for the Decls that can be redeclared.
TagDecl * getNextRedeclaration() const
void setPreviousDecl(FunctionDecl *PrevDecl)
Classes implementing SemaProxy present a restricted view of the (possibly mutating) actions and queri...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getEnd() 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...
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
bool isBeingDefined() const
Return true if this decl is currently being defined.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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...
StringRef getKindName() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
redeclarable_base::redecl_iterator redecl_iterator
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
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 printAnonymousTagDeclLocation(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
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.
Redeclarable< TagDecl > redeclarable_base
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
redeclarable_base::redecl_range redecl_range
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void printAnonymousTagDecl(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
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.
@ 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,...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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)
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.
TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation StartL=SourceLocation())
SourceLocation getBeginLoc() const LLVM_READONLY
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
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...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
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.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
Linkage getLinkage() const
Determine the linkage of this type.
const T * getAs() const
Member-template getAs<specific type>'.
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.
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 ...
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
void setType(QualType newType)
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
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
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
DefinitionKind hasDefinition() const
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
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?
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
const APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or nullptr if the value is not yet...
void setStorageClass(StorageClass SC)
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
bool isStaticDataMember() const
Determines whether this is a static data member.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
void assignAddressSpace(const ASTContext &Ctxt, LangAS AS)
Apply a deduced address space, if one isn't already set.
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,...
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.
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 isInline() const
Whether this variable is (C++1z) inline.
const Expr * getInit() const
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 checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes, SemaProxy &SProxy) const
Evaluate the initializer of this variable to determine whether it's a constant initializer.
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.
const APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
Redeclarable< VarDecl > redeclarable_base
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)
void deduceParmAddressSpace(const ASTContext &Ctxt)
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.
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first 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.
VarDecl * getDefinition()
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
bool isKnownToBeDefined() const
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...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
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
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< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
LazyOffsetPtr< Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt > LazyDeclStmtPtr
A lazy pointer to a statement.
@ 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.
Linkage getFormalLinkage(Linkage L)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
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...
@ Default
Set to the current date and time.
@ SD_Automatic
Automatic storage duration (most local variables).
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
OptionalUnsigned< unsigned > UnsignedOrNone
@ Template
We are parsing a template declaration.
bool hasArmZT0State(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZT0 state.
TagTypeKind
The kind of a tag type.
@ Struct
The "struct" keyword.
@ Enum
The "enum" keyword.
bool isTypeAwareAllocation(TypeAwareAllocationMode Mode)
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
@ Equal
This is an operator== that should be implemented as a series of subobject comparisons.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ 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.
bool isReservedAtGlobalScope(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved for use as a name at global scope.
bool isExternalFormalLinkage(Linkage L)
@ Decrement
This is a postfix decrement operator, 'operator--(int)'.
@ Increment
This is a postfix increment operator, 'operator++(int)'.
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,...
U cast(CodeGen::Address addr)
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
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)
bool hasArmZAState(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZA state.
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),...
unsigned CheckedForICEInit
unsigned WasEvaluated
Whether this statement was already evaluated.
unsigned HasConstantInitialization
Whether this variable is known to have constant initialization.
unsigned HasICEInit
In C++98, whether the initializer is an ICE.
unsigned CheckedForSideEffects
unsigned IsEvaluating
Whether this statement is being evaluated.
unsigned HasConstantDestruction
Whether this variable is known to have constant destruction.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
bool DiagEmitted
Whether any diagnostic has been emitted.
SmallVectorImpl< PartialDiagnosticAt > * ExtendedDiag
Location where we spot ptr to int cast or null subobject while evaluating constant expression in MS c...
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.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
unsigned SuppressInlineNamespace
Suppress printing parts of scope specifiers that correspond to inline namespaces.
const PrintingCallbacks * Callbacks
Callbacks to use to allow the behavior of printing to be customized.
@ Plain
E.g., (anonymous enum)/(unnamed struct)/etc.
@ SourceLocation
When printing an anonymous tag name, also print the location of that entity (e.g.,...
unsigned SuppressTagKeywordInAnonNames
Whether type printing should skip printing the tag keyword of anonymous entities.
unsigned AnonymousTagNameStyle
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Sets info about "outer" template parameter lists.
The parameters to pass to a usual operator delete.
TypeAwareAllocationMode TypeAwareDelete
AlignedAllocationMode Alignment