53 #include "llvm/ADT/APSInt.h" 54 #include "llvm/ADT/ArrayRef.h" 55 #include "llvm/ADT/None.h" 56 #include "llvm/ADT/Optional.h" 57 #include "llvm/ADT/STLExtras.h" 58 #include "llvm/ADT/SmallVector.h" 59 #include "llvm/ADT/StringSwitch.h" 60 #include "llvm/ADT/StringRef.h" 61 #include "llvm/ADT/Triple.h" 62 #include "llvm/Support/Casting.h" 63 #include "llvm/Support/ErrorHandling.h" 64 #include "llvm/Support/raw_ostream.h" 72 #include <type_traits> 74 using namespace clang;
89 if (
auto *ND = dyn_cast_or_null<NamedDecl>(TheDecl)) {
100 return !getLexicalDeclContext()->Equals(getDeclContext());
103 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
174 "asking for explicit visibility when we shouldn't be");
181 return isa<TypeDecl>(D) ||
182 isa<ClassTemplateDecl>(D) ||
183 isa<ObjCInterfaceDecl>(D);
188 template <
class T>
static typename 189 std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value,
bool>
::type 192 D->getMemberSpecializationInfo()) {
193 return member->isExplicitSpecialization();
209 switch (attr->getVisibility()) {
217 llvm_unreachable(
"bad visibility kind");
226 if (
const auto *A = D->
getAttr<TypeVisibilityAttr>()) {
232 if (
const auto *A = D->
getAttr<VisibilityAttr>()) {
243 return getTypeLinkageAndVisibility(&T);
249 LinkageInfo LinkageComputer::getLVForTemplateParameterList(
255 if (isa<TemplateTypeParmDecl>(
P))
262 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
264 if (!NTTP->isExpandedParameterPack()) {
265 if (!NTTP->getType()->isDependentType()) {
266 LV.
merge(getLVForType(*NTTP->getType(), computation));
272 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
275 LV.
merge(getTypeLinkageAndVisibility(type));
282 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
285 if (!TTP->isExpandedParameterPack()) {
286 LV.
merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),
292 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
294 LV.
merge(getLVForTemplateParameterList(
295 TTP->getExpansionTemplateParameters(i), computation));
303 const Decl *Ret =
nullptr;
305 while (DC->
getDeclKind() != Decl::TranslationUnit) {
306 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
307 Ret = cast<Decl>(DC);
324 switch (Arg.getKind()) {
331 LV.
merge(getLVForType(*Arg.getAsType(), computation));
337 LV.
merge(getLVForDecl(ND, computation));
342 LV.
merge(getTypeLinkageAndVisibility(Arg.getNullPtrType()));
348 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
349 LV.
merge(getLVForDecl(Template, computation));
353 LV.
merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));
356 llvm_unreachable(
"bad template argument kind");
365 return getLVForTemplateArgumentList(TArgs.
asArray(), computation);
377 return !fn->
hasAttr<VisibilityAttr>();
387 void LinkageComputer::mergeTemplateLV(
391 bool considerVisibility =
402 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
455 void LinkageComputer::mergeTemplateLV(
473 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
474 if (considerVisibility)
507 void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV,
525 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
526 if (considerVisibility)
534 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
543 = FD->getTemplateSpecializationInfo()) {
546 FD->getMemberSpecializationInfo()) {
547 TSK = MSI->getTemplateSpecializationKind();
560 const T *
First = D->getFirstDecl();
561 return First->isInExternCContext();
565 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.
getDeclContext()))
566 if (!SD->hasBraces())
582 llvm_unreachable(
"unexpected module ownership kind");
612 LinkageComputer::getLVForNamespaceScopeDecl(
const NamedDecl *D,
614 bool IgnoreVarTypeLinkage) {
616 "Not a name having namespace scope");
625 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
635 if (Context.getLangOpts().CPlusPlus &&
636 Var->getType().isConstQualified() &&
637 !Var->getType().isVolatileQualified() &&
642 return getLVForDecl(PrevVar, computation);
644 if (Var->getStorageClass() !=
SC_Extern &&
653 Var->getStorageClass() ==
SC_None)
654 return getDeclLinkageAndVisibility(PrevVar);
656 if (PrevVar->getStorageClass() ==
SC_Static)
665 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
667 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
669 const VarDecl *VD = IFD->getVarDecl();
670 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
671 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
673 assert(!isa<FieldDecl>(D) &&
"Didn't expect a FieldDecl!");
676 const auto *Var = dyn_cast<
VarDecl>(D);
705 !isa<TranslationUnitDecl>(DC);
721 ? Context.getLangOpts().getValueVisibilityMode()
722 : Context.getLangOpts().getTypeVisibilityMode();
738 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
761 !IgnoreVarTypeLinkage) {
762 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
779 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
780 mergeTemplateLV(LV, spec, computation);
784 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
804 QualType TypeAsWritten = Function->getType();
806 TypeAsWritten = TSI->getType();
815 = Function->getTemplateSpecializationInfo()) {
816 mergeTemplateLV(LV, Function, specInfo, computation);
825 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
827 if (!Tag->hasNameForLinkage())
833 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
834 mergeTemplateLV(LV, spec, computation);
838 }
else if (isa<EnumConstantDecl>(D)) {
847 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
850 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
857 }
else if (isa<NamespaceDecl>(D)) {
862 }
else if (isa<ObjCInterfaceDecl>(D)) {
865 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
868 if (!TD->getAnonDeclWithTypedefName(
true))
885 LinkageComputer::getLVForClassMember(
const NamedDecl *D,
887 bool IgnoreVarTypeLinkage) {
898 if (!(isa<CXXMethodDecl>(D) ||
901 isa<IndirectFieldDecl>(D) ||
903 isa<TemplateDecl>(D)))
929 getLVForDecl(cast<RecordDecl>(D->
getDeclContext()), classComputation);
941 const NamedDecl *explicitSpecSuppressor =
nullptr;
943 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
946 QualType TypeAsWritten = MD->getType();
948 TypeAsWritten = TSI->getType();
955 = MD->getTemplateSpecializationInfo()) {
956 mergeTemplateLV(LV, MD, spec, computation);
958 explicitSpecSuppressor = MD;
960 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
963 explicitSpecSuppressor = MD;
966 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
967 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
968 mergeTemplateLV(LV, spec, computation);
970 explicitSpecSuppressor = spec;
978 explicitSpecSuppressor = RD;
982 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
983 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
984 mergeTemplateLV(LV, spec, computation);
988 if (!IgnoreVarTypeLinkage) {
989 LinkageInfo typeLV = getLVForType(*VD->getType(), computation);
998 explicitSpecSuppressor = VD;
1002 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
1003 bool considerVisibility =
1008 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
1011 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
1013 explicitSpecSuppressor = temp->getTemplatedDecl();
1019 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
1023 bool considerClassVisibility =
true;
1024 if (explicitSpecSuppressor &&
1029 considerClassVisibility =
false;
1037 void NamedDecl::anchor() {}
1040 if (!hasCachedLinkage())
1046 return L == getCachedLinkage();
1053 if (name.front() ==
'C')
1054 if (name ==
"CFStringCreateWithFormat" ||
1055 name ==
"CFStringCreateWithFormatAndArguments" ||
1056 name ==
"CFStringAppendFormat" ||
1057 name ==
"CFStringAppendFormatAndArguments")
1077 bool IsMostRecent) {
1086 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1088 if (InstantiatedFrom)
1095 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1099 while (TD !=
nullptr) {
1103 TD = TD->getPreviousDecl();
1109 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1111 if (MostRecent != ND)
1115 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1116 if (Var->isStaticDataMember()) {
1118 if (InstantiatedFrom)
1122 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1123 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1129 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1134 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1140 if (InstantiatedFrom)
1147 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1165 else if (isa<ParmVarDecl>(ContextDecl))
1169 Owner = cast<NamedDecl>(ContextDecl);
1178 auto *VD = dyn_cast<
VarDecl>(Owner);
1180 VD && VD->getType()->getContainedDeducedType()
1181 ? computeLVForDecl(Owner, computation,
true)
1182 : getLVForDecl(Owner, computation);
1189 OwnerLV.isVisibilityExplicit());
1194 if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
1195 if (Function->isInAnonymousNamespace() &&
1200 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
1217 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1218 if (Var->hasExternalStorage()) {
1231 LinkageInfo PrevLV = getLVForDecl(Prev, computation);
1240 if (!Var->isStaticLocal())
1253 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1254 if (!BD->getBlockManglingNumber())
1257 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),
1258 BD->getBlockManglingContextDecl(), computation);
1260 const auto *FD = cast<FunctionDecl>(OuterD);
1261 if (!FD->isInlined() &&
1268 LV = getLVForDecl(FD, computation);
1271 assert(cast<VarDecl>(D)->isStaticLocal());
1275 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1276 LV = getLVForDecl(MD->getParent(), computation);
1296 while (Record && Record->
isLambda()) {
1300 Record = dyn_cast_or_null<CXXRecordDecl>(
1308 bool IgnoreVarTypeLinkage) {
1310 if (D->
hasAttr<InternalLinkageAttr>())
1325 case Decl::ImplicitParam:
1327 case Decl::NamespaceAlias:
1330 case Decl::UsingShadow:
1331 case Decl::UsingDirective:
1334 case Decl::EnumConstant:
1337 return getLVForDecl(cast<EnumDecl>(D->
getDeclContext()), computation);
1341 case Decl::TypeAlias:
1344 if (!cast<TypedefNameDecl>(D)
1345 ->getAnonDeclWithTypedefName(
true))
1349 case Decl::TemplateTemplateParm:
1350 case Decl::NonTypeTemplateParm:
1351 case Decl::ObjCAtDefsField:
1352 case Decl::ObjCCategory:
1353 case Decl::ObjCCategoryImpl:
1354 case Decl::ObjCCompatibleAlias:
1355 case Decl::ObjCImplementation:
1356 case Decl::ObjCMethod:
1357 case Decl::ObjCProperty:
1358 case Decl::ObjCPropertyImpl:
1359 case Decl::ObjCProtocol:
1362 case Decl::CXXRecord: {
1363 const auto *Record = cast<CXXRecordDecl>(D);
1364 if (Record->isLambda()) {
1365 if (!Record->getLambdaManglingNumber()) {
1385 return getLVForClosure(
1396 return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);
1406 return getLVForClassMember(D, computation, IgnoreVarTypeLinkage);
1420 return getLVForLocalDecl(D, computation);
1431 if (D->
hasAttr<InternalLinkageAttr>())
1440 LinkageInfo LV = computeLVForDecl(D, computation);
1445 cache(D, computation, LV);
1452 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1460 auto *T = cast<NamedDecl>(I);
1463 if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
1475 return getLVForDecl(D,
1482 Module *M = getOwningModule();
1502 if (
auto *ND = dyn_cast<NamedDecl>(
this))
1503 InternalLinkage = !ND->hasExternalFormalLinkage();
1506 InternalLinkage = (NSD && NSD->isAnonymousNamespace()) ||
1507 isInAnonymousNamespace();
1509 return InternalLinkage ? M->
Parent :
nullptr;
1513 llvm_unreachable(
"unknown module kind");
1521 std::string QualName;
1522 llvm::raw_string_ostream OS(QualName);
1523 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1528 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1536 if (
auto *MD = dyn_cast<ObjCMethodDecl>(
this))
1537 if (
auto *
ID = MD->getClassInterface())
1546 ContextsTy Contexts;
1550 if (isa<NamedDecl>(Ctx))
1551 Contexts.push_back(Ctx);
1555 for (
const DeclContext *DC : llvm::reverse(Contexts)) {
1556 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1557 OS << Spec->getName();
1560 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1562 (ND->isAnonymousNamespace() || ND->isInline()))
1564 if (ND->isAnonymousNamespace()) {
1566 :
"(anonymous namespace)");
1570 }
else if (
const auto *RD = dyn_cast<RecordDecl>(DC)) {
1571 if (!RD->getIdentifier())
1572 OS <<
"(anonymous " << RD->getKindName() <<
')';
1575 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1577 if (FD->hasWrittenPrototype())
1578 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1583 for (
unsigned i = 0; i < NumParams; ++i) {
1586 OS << FD->getParamDecl(i)->getType().stream(P);
1596 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1609 OS << *cast<NamedDecl>(DC);
1614 if (getDeclName() || isa<DecompositionDecl>(
this))
1617 OS <<
"(anonymous)";
1622 bool Qualified)
const {
1624 printQualifiedName(OS, Policy);
1635 #define DECL(Type, Base) \ 1637 return isRedeclarableImpl((Type##Decl *)nullptr); 1638 #define ABSTRACT_DECL(DECL) 1639 #include "clang/AST/DeclNodes.inc" 1641 llvm_unreachable(
"unknown decl kind");
1645 assert(getDeclName() == OldD->
getDeclName() &&
"Declaration name mismatch");
1657 if (isa<ObjCMethodDecl>(
this))
1662 if (isa<ParmVarDecl>(
this))
1668 if (!this->getDeclContext()->getRedeclContext()->Equals(
1674 if (
auto *UD = dyn_cast<UsingDecl>(
this)) {
1678 cast<UsingDecl>(OldD)->getQualifier());
1680 if (
auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this)) {
1684 cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
1697 for (
auto D : redecls()) {
1724 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1726 while (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1727 ND = UD->getTargetDecl();
1729 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1730 return AD->getClassInterface();
1732 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1733 return AD->getNamespace();
1739 if (!isCXXClassMember())
1743 if (isa<UsingShadowDecl>(D))
1744 D = cast<UsingShadowDecl>(D)->getTargetDecl();
1746 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<MSPropertyDecl>(D))
1748 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(D->
getAsFunction()))
1749 return MD->isInstance();
1757 template <
typename DeclT>
1759 if (decl->getNumTemplateParameterLists() > 0)
1760 return decl->getTemplateParameterList(0)->getTemplateLoc();
1762 return decl->getInnerLocStart();
1774 if (!hasExtInfo()) {
1778 DeclInfo =
new (getASTContext()) ExtInfo;
1780 getExtInfo()->TInfo = savedTInfo;
1783 getExtInfo()->QualifierLoc = QualifierLoc;
1787 if (getExtInfo()->NumTemplParamLists == 0) {
1791 getASTContext().Deallocate(getExtInfo());
1793 DeclInfo = savedTInfo;
1796 getExtInfo()->QualifierLoc = QualifierLoc;
1803 assert(!TPLists.empty());
1805 if (!hasExtInfo()) {
1809 DeclInfo =
new (getASTContext()) ExtInfo;
1811 getExtInfo()->TInfo = savedTInfo;
1814 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
1830 QT = cast<PointerType>(T)->getPointeeType();
1832 case Type::BlockPointer:
1833 QT = cast<BlockPointerType>(T)->getPointeeType();
1835 case Type::MemberPointer:
1836 QT = cast<MemberPointerType>(T)->getPointeeType();
1838 case Type::LValueReference:
1839 case Type::RValueReference:
1840 QT = cast<ReferenceType>(T)->getPointeeType();
1842 case Type::PackExpansion:
1843 QT = cast<PackExpansionType>(T)->getPattern();
1846 case Type::ConstantArray:
1847 case Type::DependentSizedArray:
1848 case Type::IncompleteArray:
1849 case Type::VariableArray:
1850 case Type::FunctionProto:
1851 case Type::FunctionNoProto:
1863 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
1871 if (NumTemplParamLists > 0) {
1873 TemplParamLists =
nullptr;
1874 NumTemplParamLists = 0;
1877 if (!TPLists.empty()) {
1879 NumTemplParamLists = TPLists.size();
1880 std::copy(TPLists.begin(), TPLists.end(), TemplParamLists);
1898 llvm_unreachable(
"Invalid storage class");
1907 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(
unsigned),
1908 "VarDeclBitfields too large!");
1910 "ParmVarDeclBitfields too large!");
1912 "NonParmVarDeclBitfields too large!");
1922 return new (
C, DC)
VarDecl(Var, C, DC, StartL, IdL, Id, T, TInfo, S);
1939 if (!hasAttr<ThreadAttr>() &&
1942 hasAttr<OMPThreadPrivateDeclAttr>()))
1944 return ((
getASTContext().getLangOpts().isCompatibleWithMSVC(
1946 hasAttr<OMPThreadPrivateDeclAttr>())
1955 llvm_unreachable(
"Unknown thread storage class specifier!");
1969 template<
typename T>
1973 if (!D.hasExternalFormalLinkage())
1997 template<
typename T>
2003 assert(D.getASTContext().getLangOpts().CPlusPlus);
2058 isa<VarTemplatePartialSpecializationDecl>(
this)))
2078 if (
const auto *SAA = getAttr<SelectAnyAttr>())
2079 if (!SAA->isInherited())
2085 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2087 !isa<VarTemplatePartialSpecializationDecl>(VTSD) &&
2088 !VTSD->IsCompleteDefinition)
2120 VarDecl *LastTentative =
nullptr;
2122 for (
auto I : First->
redecls()) {
2123 Kind = I->isThisDeclarationADefinition();
2129 return LastTentative;
2134 for (
auto I : First->
redecls()) {
2135 if (I->isThisDeclarationADefinition(C) ==
Definition)
2145 for (
auto I : First->
redecls()) {
2146 Kind =
std::max(Kind, I->isThisDeclarationADefinition(C));
2156 if (
auto Expr = I->getInit()) {
2165 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2166 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2169 return !
Init.isNull();
2176 if (
auto *S =
Init.dyn_cast<
Stmt *>())
2177 return cast<Expr>(S);
2186 return Init.getAddrOfPtr1();
2200 return VD->isOutOfLine();
2207 Eval->~EvaluatedStmt();
2217 if (!Lang.CPlusPlus)
2222 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2228 if (!
getType().isConstQualified() ||
getType().isVolatileQualified())
2233 if (
getType()->isIntegralOrEnumerationType())
2273 const auto *
Init = cast<Expr>(Eval->
Value);
2274 assert(!
Init->isValueDependent());
2279 Eval->
IsICE =
false;
2303 Eval->
IsICE = Result && Notes.empty();
2306 return Result ? &Eval->
Evaluated :
nullptr;
2311 if (Eval->WasEvaluated)
2312 return &Eval->Evaluated;
2319 return Eval->CheckedICE;
2326 "Check whether we already know that the initializer is an ICE");
2341 const auto *
Init = cast<Expr>(Eval->
Value);
2342 assert(!
Init->isValueDependent());
2366 template<
typename DeclT>
2369 if (
auto *Def = D->getDefinition())
2385 if (
auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2386 auto From = VDTemplSpec->getInstantiatedFrom();
2388 while (
auto *NewVTD = VTD->getInstantiatedFromMemberTemplate()) {
2389 if (NewVTD->isMemberSpecialization())
2397 while (
auto *NewVTPSD = VTPSD->getInstantiatedFromMember()) {
2398 if (NewVTPSD->isMemberSpecialization())
2402 return getDefinitionOrSelf<VarDecl>(VTPSD);
2416 while (VarTemplate->getInstantiatedFromMemberTemplate()) {
2417 if (VarTemplate->isMemberSpecialization())
2419 VarTemplate = VarTemplate->getInstantiatedFromMemberTemplate();
2429 return cast<VarDecl>(MSI->getInstantiatedFrom());
2435 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2436 return Spec->getSpecializationKind();
2439 return MSI->getTemplateSpecializationKind();
2445 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2446 return Spec->getPointOfInstantiation();
2449 return MSI->getPointOfInstantiation();
2472 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&
2474 isa<IncompleteArrayType>(
getType()))
2483 !hasAttr<AlwaysDestroyAttr>()));
2497 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2499 "not a variable or static data member template specialization");
2502 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2503 Spec->setSpecializationKind(TSK);
2505 Spec->getPointOfInstantiation().isInvalid()) {
2506 Spec->setPointOfInstantiation(PointOfInstantiation);
2508 L->InstantiationRequested(
this);
2513 MSI->setTemplateSpecializationKind(TSK);
2515 MSI->getPointOfInstantiation().isInvalid()) {
2516 MSI->setPointOfInstantiation(PointOfInstantiation);
2518 L->InstantiationRequested(
this);
2526 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2527 "Previous template or instantiation?");
2540 return new (
C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
2547 if (
const auto *DT = dyn_cast<DecayedType>(T))
2548 return DT->getOriginalType();
2559 if (!hasInheritedDefaultArg()) {
2574 assert(!hasUnparsedDefaultArg() &&
"Default argument is not yet parsed!");
2575 assert(!hasUninstantiatedDefaultArg() &&
2576 "Default argument is not yet instantiated!");
2579 if (
auto *E = dyn_cast_or_null<FullExpr>(Arg))
2580 return E->getSubExpr();
2598 return getUninstantiatedDefaultArg()->getSourceRange();
2602 return E->getSourceRange();
2607 llvm_unreachable(
"Invalid default argument kind.");
2616 assert(hasUninstantiatedDefaultArg() &&
2617 "Wrong kind of initialization expression!");
2618 return cast_or_null<Expr>(
Init.get<
Stmt *>());
2625 return hasUnparsedDefaultArg() || hasUninstantiatedDefaultArg() ||
2630 return isa<PackExpansionType>(
getType());
2633 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
2638 unsigned ParmVarDecl::getParameterIndexLarge()
const {
2682 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
2690 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
2691 return FT->isVariadic();
2697 if (I->doesThisDeclarationHaveABody()) {
2715 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
2722 if (I->isThisDeclarationADefinition()) {
2735 if (Definition->Body)
2751 Parent->markedVirtualFunctionPure();
2754 template<std::
size_t Len>
2757 return II && II->
isStr(Str);
2785 return llvm::StringSwitch<bool>(
getName())
2797 assert(
getDeclName().getCXXOverloadedOperator() == OO_New ||
2798 getDeclName().getCXXOverloadedOperator() == OO_Delete ||
2799 getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
2800 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
2806 if (proto->getNumParams() != 2 || proto->isVariadic())
2815 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
2821 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
2822 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
2823 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
2824 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
2835 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 3 || FPT->isVariadic())
2840 if (FPT->getNumParams() == 1)
2843 unsigned Params = 1;
2844 QualType Ty = FPT->getParamType(Params);
2847 auto Consume = [&] {
2849 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) :
QualType();
2853 bool IsSizedDelete =
false;
2858 IsSizedDelete =
true;
2881 return Params == FPT->getNumParams();
2895 RD->getIdentifier()->isStr(
"destroying_delete_t");
2915 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
2916 return Method->isStatic();
2924 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
2925 if (!Namespace->getDeclName())
2935 if (hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
2936 hasAttr<C11NoReturnAttr>())
2939 if (
auto *FnTy =
getType()->getAs<FunctionType>())
2940 return FnTy->getNoReturnAttr();
2947 if (hasAttr<TargetAttr>())
2949 if (hasAttr<CPUDispatchAttr>())
2951 if (hasAttr<CPUSpecificAttr>())
2975 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
2976 FunTmpl->setPreviousDecl(PrevFunTmpl);
3004 const auto *LinkageDecl =
3011 if (BuiltinID == Builtin::BI__GetExceptionInfo &&
3013 return Builtin::BI__GetExceptionInfo;
3022 if (hasAttr<OverloadableAttr>())
3044 if (Context.
getLangOpts().CUDA && hasAttr<CUDADeviceAttr>() &&
3045 !hasAttr<CUDAHostAttr>() &&
3046 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3062 assert(!ParamInfo &&
"Already has param info!");
3063 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
3066 if (!NewParamInfo.empty()) {
3068 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3080 unsigned NumRequiredArgs = 0;
3082 if (!Param->isParameterPack() && !Param->hasDefaultArg())
3084 return NumRequiredArgs;
3093 assert(
isInlined() &&
"expected to get called on an inlined function!");
3097 !hasAttr<DLLExportAttr>())
3102 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3114 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3144 "Must have a declaration without a body.");
3155 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3165 bool FoundBody =
false;
3167 FoundBody |= Prev->Body.
isValid();
3193 bool FoundBody =
false;
3195 FoundBody |= Prev->Body.
isValid();
3253 "Must be a function definition");
3254 assert(
isInlined() &&
"Function must be inline");
3257 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3269 for (
auto Redecl :
redecls()) {
3270 if (Redecl->isInlineSpecified() &&
3280 "should not use C inline rules in C++");
3286 for (
auto Redecl :
redecls()) {
3317 if (TemplateOrSpecialization.isNull())
3325 if (TemplateOrSpecialization.is
3329 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
3334 return cast<FunctionDecl>(Info->getInstantiatedFrom());
3344 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
3347 assert(TemplateOrSpecialization.isNull() &&
3348 "Member function is already a specialization");
3351 TemplateOrSpecialization = Info;
3359 TemplateOrSpecialization = Template;
3387 bool HasPattern =
false;
3389 HasPattern = PatternDecl->
hasBody(PatternDecl);
3395 if (!HasPattern || !PatternDecl)
3411 llvm_unreachable(
"All TSK values handled.");
3432 dyn_cast<CXXMethodDecl>(
this))) {
3438 while (Primary->getInstantiatedFromMemberTemplate()) {
3441 if (Primary->isMemberSpecialization())
3443 Primary = Primary->getInstantiatedFromMemberTemplate();
3457 = TemplateOrSpecialization
3458 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3459 return Info->Template.getPointer();
3470 return TemplateOrSpecialization
3477 = TemplateOrSpecialization
3478 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3479 return Info->TemplateArguments;
3487 = TemplateOrSpecialization
3488 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3489 return Info->TemplateArgumentsAsWritten;
3495 FunctionDecl::setFunctionTemplateSpecialization(
ASTContext &C,
3503 "Must specify the type of function template specialization");
3509 TemplateArgsAsWritten,
3510 PointOfInstantiation);
3511 TemplateOrSpecialization = Info;
3519 assert(TemplateOrSpecialization.isNull());
3523 TemplateOrSpecialization = Info;
3528 return TemplateOrSpecialization
3537 totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
3542 DependentFunctionTemplateSpecializationInfo::
3546 NumTemplates = Ts.
size();
3547 NumArgs = TArgs.
size();
3550 for (
unsigned I = 0, E = Ts.
size(); I != E; ++I)
3554 for (
unsigned I = 0, E = TArgs.
size(); I != E; ++I)
3578 = TemplateOrSpecialization.dyn_cast<
3580 FTSInfo->setTemplateSpecializationKind(TSK);
3582 PointOfInstantiation.
isValid() &&
3583 FTSInfo->getPointOfInstantiation().isInvalid()) {
3584 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
3586 L->InstantiationRequested(
this);
3590 MSInfo->setTemplateSpecializationKind(TSK);
3592 PointOfInstantiation.
isValid() &&
3593 MSInfo->getPointOfInstantiation().isInvalid()) {
3594 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3596 L->InstantiationRequested(
this);
3599 llvm_unreachable(
"Function cannot have a template specialization kind");
3604 = TemplateOrSpecialization.dyn_cast<
3606 return FTSInfo->getPointOfInstantiation();
3609 return MSInfo->getPointOfInstantiation();
3630 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
3649 case Builtin::BI__builtin_memset:
3650 case Builtin::BI__builtin___memset_chk:
3651 case Builtin::BImemset:
3652 return Builtin::BImemset;
3654 case Builtin::BI__builtin_memcpy:
3655 case Builtin::BI__builtin___memcpy_chk:
3656 case Builtin::BImemcpy:
3657 return Builtin::BImemcpy;
3659 case Builtin::BI__builtin_memmove:
3660 case Builtin::BI__builtin___memmove_chk:
3661 case Builtin::BImemmove:
3662 return Builtin::BImemmove;
3664 case Builtin::BIstrlcpy:
3665 case Builtin::BI__builtin___strlcpy_chk:
3666 return Builtin::BIstrlcpy;
3668 case Builtin::BIstrlcat:
3669 case Builtin::BI__builtin___strlcat_chk:
3670 return Builtin::BIstrlcat;
3672 case Builtin::BI__builtin_memcmp:
3673 case Builtin::BImemcmp:
3674 return Builtin::BImemcmp;
3676 case Builtin::BI__builtin_strncpy:
3677 case Builtin::BI__builtin___strncpy_chk:
3678 case Builtin::BIstrncpy:
3679 return Builtin::BIstrncpy;
3681 case Builtin::BI__builtin_strncmp:
3682 case Builtin::BIstrncmp:
3683 return Builtin::BIstrncmp;
3685 case Builtin::BI__builtin_strncasecmp:
3686 case Builtin::BIstrncasecmp:
3687 return Builtin::BIstrncasecmp;
3689 case Builtin::BI__builtin_strncat:
3690 case Builtin::BI__builtin___strncat_chk:
3691 case Builtin::BIstrncat:
3692 return Builtin::BIstrncat;
3694 case Builtin::BI__builtin_strndup:
3695 case Builtin::BIstrndup:
3696 return Builtin::BIstrndup;
3698 case Builtin::BI__builtin_strlen:
3699 case Builtin::BIstrlen:
3700 return Builtin::BIstrlen;
3702 case Builtin::BI__builtin_bzero:
3703 case Builtin::BIbzero:
3704 return Builtin::BIbzero;
3708 if (FnInfo->
isStr(
"memset"))
3709 return Builtin::BImemset;
3710 else if (FnInfo->
isStr(
"memcpy"))
3711 return Builtin::BImemcpy;
3712 else if (FnInfo->
isStr(
"memmove"))
3713 return Builtin::BImemmove;
3714 else if (FnInfo->
isStr(
"memcmp"))
3715 return Builtin::BImemcmp;
3716 else if (FnInfo->
isStr(
"strncpy"))
3717 return Builtin::BIstrncpy;
3718 else if (FnInfo->
isStr(
"strncmp"))
3719 return Builtin::BIstrncmp;
3720 else if (FnInfo->
isStr(
"strncasecmp"))
3721 return Builtin::BIstrncasecmp;
3722 else if (FnInfo->
isStr(
"strncat"))
3723 return Builtin::BIstrncat;
3724 else if (FnInfo->
isStr(
"strndup"))
3725 return Builtin::BIstrndup;
3726 else if (FnInfo->
isStr(
"strlen"))
3727 return Builtin::BIstrlen;
3728 else if (FnInfo->
isStr(
"bzero"))
3729 return Builtin::BIbzero;
3737 assert(hasODRHash());
3746 setHasODRHash(
true);
3753 setHasODRHash(
true);
3767 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
3768 BW, Mutable, InitStyle);
3781 if (
const auto *Record =
getType()->getAs<RecordType>())
3782 return Record->getDecl()->isAnonymousStructOrUnion();
3788 assert(isBitField() &&
"not a bitfield");
3789 return getBitWidth()->EvaluateKnownConstInt(Ctx).getZExtValue();
3793 return isUnnamedBitfield() && !getBitWidth()->isValueDependent() &&
3794 getBitWidthValue(Ctx) == 0;
3799 if (Canonical !=
this)
3802 if (CachedFieldIndex)
return CachedFieldIndex - 1;
3806 assert(RD &&
"requested index for field of struct with no definition");
3808 for (
auto *Field : RD->
fields()) {
3809 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
3813 assert(CachedFieldIndex &&
"failed to find field in parent");
3814 return CachedFieldIndex - 1;
3818 const Expr *FinalExpr = getInClassInitializer();
3820 FinalExpr = getBitWidth();
3828 "capturing type in non-lambda or captured record.");
3829 assert(InitStorage.getInt() == ISK_NoInit &&
3830 InitStorage.getPointer() ==
nullptr &&
3831 "bit width, initializer or captured type already set");
3832 InitStorage.setPointerAndInt(const_cast<VariableArrayType *>(VLAType),
3833 ISK_CapturedVLAType);
3846 "EnumDecl not matched with TTK_Enum");
3869 TypedefNameDeclOrQualifier = TDD;
3880 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
3881 struct CXXRecordDecl::DefinitionData *Data =
3882 new (
getASTContext())
struct CXXRecordDecl::DefinitionData(D);
3884 cast<CXXRecordDecl>(I)->DefinitionData = Data;
3889 assert((!isa<CXXRecordDecl>(
this) ||
3891 "definition completed but not started");
3897 L->CompletedTagDefinition(
this);
3902 return const_cast<TagDecl *
>(
this);
3907 if (II->isOutOfDate()) {
3913 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
3914 return CXXRD->getDefinition();
3917 if (R->isCompleteDefinition())
3933 if (getExtInfo()->NumTemplParamLists == 0) {
3945 assert(!TPLists.empty());
3960 bool Scoped,
bool ScopedUsingClassTag,
bool Fixed)
3962 assert(Scoped || !ScopedUsingClassTag);
3963 IntegerType =
nullptr;
3964 setNumPositiveBits(0);
3965 setNumNegativeBits(0);
3967 setScopedUsingClassTag(ScopedUsingClassTag);
3969 setHasODRHash(
false);
3973 void EnumDecl::anchor() {}
3979 bool IsScopedUsingClassTag,
bool IsFixed) {
3980 auto *
Enum =
new (
C, DC)
EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
3981 IsScoped, IsScopedUsingClassTag, IsFixed);
3990 nullptr,
nullptr,
false,
false,
false);
3997 return TI->getTypeLoc().getSourceRange();
4003 unsigned NumPositiveBits,
4004 unsigned NumNegativeBits) {
4008 PromotionType = NewPromotionType;
4009 setNumPositiveBits(NumPositiveBits);
4010 setNumNegativeBits(NumNegativeBits);
4015 if (
const auto *A = getAttr<EnumExtensibilityAttr>())
4016 return A->getExtensibility() == EnumExtensibilityAttr::Closed;
4021 return isClosed() && hasAttr<FlagEnumAttr>();
4025 return isClosed() && !hasAttr<FlagEnumAttr>();
4030 return MSI->getTemplateSpecializationKind();
4038 assert(MSI &&
"Not an instantiated member enumeration?");
4041 PointOfInstantiation.
isValid() &&
4049 EnumDecl *ED = getInstantiatedFromMemberEnum();
4057 "couldn't find pattern for enum instantiation");
4062 if (SpecializationInfo)
4063 return cast<EnumDecl>(SpecializationInfo->getInstantiatedFrom());
4070 assert(!SpecializationInfo &&
"Member enum is already a specialization");
4080 setHasODRHash(
true);
4093 :
TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
4094 assert(
classof(static_cast<Decl *>(
this)) &&
"Invalid Kind!");
4111 StartLoc, IdLoc, Id, PrevDecl);
4132 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
4133 return RD->isLambda();
4138 return hasAttr<CapturedRecordAttr>();
4147 LoadFieldsFromExternalStorage();
4163 return hasAttr<MSStructAttr>() || C.
getLangOpts().MSBitfields == 1;
4166 void RecordDecl::LoadFieldsFromExternalStorage()
const {
4181 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
4182 assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
4195 (SanitizerKind::Address | SanitizerKind::KernelAddress);
4196 if (!EnabledAsanMask || !Context.
getLangOpts().SanitizeAddressFieldPadding)
4201 int ReasonToReject = -1;
4202 if (!CXXRD || CXXRD->isExternCContext())
4204 else if (CXXRD->hasAttr<PackedAttr>())
4206 else if (CXXRD->isUnion())
4208 else if (CXXRD->isTriviallyCopyable())
4210 else if (CXXRD->hasTrivialDestructor())
4212 else if (CXXRD->isStandardLayout())
4214 else if (Blacklist.isBlacklistedLocation(EnabledAsanMask,
getLocation(),
4217 else if (Blacklist.isBlacklistedType(EnabledAsanMask,
4223 if (ReasonToReject >= 0)
4226 diag::remark_sanitize_address_insert_extra_padding_rejected)
4231 diag::remark_sanitize_address_insert_extra_padding_accepted)
4234 return ReasonToReject < 0;
4238 for (
const auto *I :
fields()) {
4239 if (I->getIdentifier())
4242 if (
const auto *RT = I->getType()->getAs<
RecordType>())
4244 RT->getDecl()->findFirstNamedDataMember())
4245 return NamedDataMember;
4266 assert(!ParamInfo &&
"Already has param info!");
4269 if (!NewParamInfo.empty()) {
4270 NumParams = NewParamInfo.size();
4272 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
4277 bool CapturesCXXThis) {
4279 this->NumCaptures = Captures.size();
4281 if (Captures.empty()) {
4282 this->Captures =
nullptr;
4286 this->Captures = Captures.copy(Context).data();
4292 if (I.getVariable() == variable)
4306 void TranslationUnitDecl::anchor() {}
4312 void PragmaCommentDecl::anchor() {}
4320 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
4322 memcpy(PCD->getTrailingObjects<
char>(), Arg.data(), Arg.size());
4323 PCD->getTrailingObjects<
char>()[Arg.size()] =
'\0';
4330 return new (
C,
ID, additionalSizeToAlloc<char>(ArgSize + 1))
4334 void PragmaDetectMismatchDecl::anchor() {}
4340 size_t ValueStart = Name.size() + 1;
4342 new (
C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1))
4344 memcpy(PDMD->getTrailingObjects<
char>(), Name.data(), Name.size());
4345 PDMD->getTrailingObjects<
char>()[Name.size()] =
'\0';
4346 memcpy(PDMD->getTrailingObjects<
char>() + ValueStart, Value.data(),
4348 PDMD->getTrailingObjects<
char>()[ValueStart + Value.size()] =
'\0';
4354 unsigned NameValueSize) {
4355 return new (
C,
ID, additionalSizeToAlloc<char>(NameValueSize + 1))
4359 void ExternCContextDecl::anchor() {}
4366 void LabelDecl::anchor() {}
4370 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
4376 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
4377 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
4386 char *Buffer =
new (
getASTContext(), 1)
char[Name.size() + 1];
4387 memcpy(Buffer, Name.data(), Name.size());
4388 Buffer[Name.size()] =
'\0';
4392 void ValueDecl::anchor() {}
4395 for (
const auto *I :
attrs())
4396 if (isa<WeakAttr>(I) || isa<WeakRefAttr>(I))
4402 void ImplicitParamDecl::anchor() {}
4426 bool isInlineSpecified,
4427 bool hasWrittenPrototype,
4428 bool isConstexprSpecified) {
4431 SC, isInlineSpecified, isConstexprSpecified);
4450 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
4452 NumParams(NumParams), ContextParam(0), BodyAndNothrow(
nullptr,
false) {}
4455 unsigned NumParams) {
4456 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4461 unsigned NumParams) {
4462 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4475 Expr *E,
const llvm::APSInt &V) {
4482 QualType(),
nullptr, llvm::APSInt());
4485 void IndirectFieldDecl::anchor() {}
4491 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),
4492 ChainingSize(CH.size()) {
4515 End = Init->getEndLoc();
4519 void TypeDecl::anchor() {}
4524 return new (
C, DC)
TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4527 void TypedefNameDecl::anchor() {}
4530 if (
auto *TT = getTypeSourceInfo()->getType()->getAs<TagType>()) {
4532 auto *ThisTypedef =
this;
4533 if (AnyRedecl && OwningTypedef) {
4537 if (OwningTypedef == ThisTypedef)
4538 return TT->getDecl();
4544 bool TypedefNameDecl::isTransparentTagSlow()
const {
4545 auto determineIsTransparent = [&]() {
4547 if (
auto *TD = TT->getDecl()) {
4548 if (TD->getName() !=
getName())
4561 bool isTransparent = determineIsTransparent();
4562 MaybeModedTInfo.setInt((isTransparent << 1) | 1);
4563 return isTransparent;
4575 return new (
C, DC)
TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4587 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4595 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4599 void FileScopeAsmDecl::anchor() {}
4614 void EmptyDecl::anchor() {}
4642 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
true) {
4644 auto *StoredLocs = getTrailingObjects<SourceLocation>();
4645 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
4651 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
false) {
4652 *getTrailingObjects<SourceLocation>() = EndLoc;
4659 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
4660 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
4667 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
4674 unsigned NumLocations) {
4675 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
4680 if (!ImportedAndComplete.getInt())
4683 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
4684 return llvm::makeArrayRef(StoredLocs,
4689 if (!ImportedAndComplete.getInt())
4699 void ExportDecl::anchor() {}
void setLinkage(Linkage L)
EnumDecl * getTemplateInstantiationPattern() const
Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantia...
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
Defines the clang::ASTContext interface.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static const Decl * getCanonicalDecl(const Decl *D)
void setImplicit(bool I=true)
Represents a function declaration or definition.
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 ...
SourceRange getExceptionSpecRange() const
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
void setNonTrivialToPrimitiveDestroy(bool V)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, bool isConstexprSpecified)
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
void setAnonymousStructOrUnion(bool Anon)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
bool isInExternCXXContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C++" linkage spec...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
A (possibly-)qualified type.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
virtual void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Result)
Finds all declarations lexically contained within the given DeclContext, after applying an optional f...
void setMayHaveOutOfDateDef(bool V=true)
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
Internal linkage according to the Modules TS, but can be referred to from other translation units ind...
bool isExternC() const
Determines whether this function is a function with external, C linkage.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
static VarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
This declaration has an owning module, but is only visible to lookups that occur within that module...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
Stmt - This represents one statement.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
void setPreviousDecl(FunctionDecl *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
SanitizerSet Sanitize
Set of enabled sanitizers.
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
An instance of this object exists for each enum constant that is defined.
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
No linkage, which means that the entity is unique and can only be referred to from within its scope...
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
C Language Family Type Representation.
Defines the SourceManager interface.
bool IsEvaluating
Whether this statement is being evaluated.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
bool isInExternCContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C" linkage spec...
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
Defines the clang::Module class, which describes a module in the source code.
const Type * getTypeForDecl() const
Decl - This represents one declaration (or definition), e.g.
bool isVariadic() const
Whether this function prototype is variadic.
static LinkageInfo getExternalLinkageFor(const NamedDecl *D)
SourceLocation getBeginLoc() const LLVM_READONLY
void setArgPassingRestrictions(ArgPassingKind Kind)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Defines the C++ template declaration subclasses.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
void setPure(bool P=true)
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
void setPreviousDeclaration(FunctionDecl *PrevDecl)
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
static Visibility getVisibilityFromAttr(const T *attr)
Given a visibility attribute, return the explicit visibility associated with it.
bool isExplicitSpecialization() const
ImplicitParamKind
Defines the kind of the implicit parameter: is this an implicit parameter with pointer to 'this'...
The base class of the type hierarchy.
Represents an empty-declaration.
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...
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Declaration of a variable template.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Represent a C++ namespace.
static std::enable_if<!std::is_base_of< RedeclarableTemplateDecl, T >::value, bool >::type isExplicitMemberSpecialization(const T *D)
Does the given declaration have member specialization information, and if so, is it an explicit speci...
virtual void completeDefinition()
Note that the definition of this type is now complete.
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
A container of type source information.
constexpr XRayInstrMask Function
Linkage getLinkage() const
Determine the linkage of this type.
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
bool CheckingICE
Whether we are checking whether this statement is an integral constant expression.
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
SourceLocation getOuterLocStart() const
Return SourceLocation representing start of source range taking into account any outer template decla...
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
Sets info about "outer" template parameter lists.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to...
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
This is a module that was defined by a module map and built out of header files.
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)
void setBeingDefined(bool V=true)
True if this decl is currently being defined.
void setNothrow(bool Nothrow=true)
This file provides some common utility functions for processing Lambda related AST Constructs...
ExplicitVisibilityKind
Kinds of explicit visibility.
Represents a variable declaration or definition.
ASTMutationListener * getASTMutationListener() const
Objects with "hidden" visibility are not seen by the dynamic linker.
bool WasEvaluated
Whether this statement was already evaluated.
Declaration of a redeclarable template.
static LanguageLinkage getDeclLanguageLinkage(const T &D)
unsigned getNumParams() const
void mergeVisibility(Visibility newVis, bool newExplicit)
Merge in the visibility 'newVis'.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Visibility getVisibility() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents an empty template argument, e.g., one that has not been deduced.
Declaration context for names declared as extern "C" in C++.
Represents a variable template specialization, which refers to a variable template with a given set o...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents a parameter to a function.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Defines the clang::Expr interface and subclasses for C++ expressions.
LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
getLVForDecl - Get the linkage and visibility for the given declaration.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
Provides information about a dependent function-template specialization declaration.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
ModuleKind Kind
The kind of this module.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Defines the clang::SanitizerKind enum.
Represents a struct/union/class.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Provides common interface for the Decls that can be redeclared.
static bool isRedeclarable(Decl::Kind K)
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
bool hasBody() const override
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations. ...
static bool typeIsPostfix(QualType QT)
bool isInAnonymousNamespace() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
bool isCapturedRecord() const
Determine whether this record is a record for captured variables in CapturedStmt construct.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
void print(raw_ostream &OS, const SourceManager &SM) const
void setUninstantiatedDefaultArg(Expr *arg)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen...
A C++ nested-name-specifier augmented with source location information.
static bool redeclForcesDefMSVC(const FunctionDecl *Redecl)
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
static LinkageInfo internal()
static bool usesTypeVisibility(const NamedDecl *D)
Is the given declaration a "type" or a "value" for the purposes of visibility computation?
field_range fields() const
static unsigned getNumModuleIdentifiers(Module *Mod)
Retrieve the number of module identifiers needed to name the given module.
static const Decl * getOutermostFuncOrBlockContext(const Decl *D)
Represents a member of a struct/union/class.
void completeDefinition()
Completes the definition of this tag declaration.
void startDefinition()
Starts the definition of this tag declaration.
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
bool isReferenceType() const
SanitizerMask Mask
Bitmask of enabled sanitizers.
Linkage getFormalLinkage(Linkage L)
This declaration is definitely a definition.
bool isLinkageValid() const
True if the computed linkage is valid.
SourceLocation getBeginLoc() const LLVM_READONLY
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool hasLoadedFieldsFromExternalStorage() const
Describes a module or submodule.
specific_decl_iterator< FieldDecl > field_iterator
ArrayRef< ParmVarDecl * > parameters() const
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
virtual bool isDefined() const
Provides information about a function template specialization, which is a FunctionDecl that has been ...
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
The argument of this type can be passed directly in registers.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class...
QualType getOriginalType() const
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
A convenient class for passing around template argument information.
void setParamDestroyedInCallee(bool V)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Wrapper for source info for functions.
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
ASTContext & getASTContext() const
Visibility
Describes the different kinds of visibility that a declaration may have.
DefinitionKind hasDefinition() const
const clang::PrintingPolicy & getPrintingPolicy() const
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a declaration of a type.
void setHasObjectMember(bool val)
A set of unresolved declarations.
Module * Parent
The parent of this module.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isLambda() const
Determine whether this class describes a lambda function object.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
field_iterator field_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality...
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
Defines the Linkage enumeration and various utility functions.
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
bool needsCleanup() const
Returns whether the object performed allocations.
SourceRange getExceptionSpecSourceRange() const
Attempt to compute an informative source range covering the function exception specification, if any.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
Represents the body of a CapturedStmt, and serves as its DeclContext.
Represents a linkage specification.
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceLocation getTypeSpecStartLoc() const
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
LinkageInfo computeLVForDecl(const NamedDecl *D, LVComputationKind computation, bool IgnoreVarTypeLinkage=false)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Decl * getPrimaryMergedDecl(Decl *D)
void setCachedLinkage(Linkage L) const
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Defines the clang::Visibility enumeration and various utility functions.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
bool isExplicitSpecialization() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec...
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
bool isExternalFormalLinkage(Linkage L)
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
static bool isExportedFromModuleIntefaceUnit(const NamedDecl *D)
Represents the declaration of a typedef-name via a C++11 alias-declaration.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
unsigned MSVCFormatting
Use whitespace and punctuation like MSVC does.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
Represents a ValueDecl that came out of a declarator.
TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, SourceLocation StartL)
Module linkage, which indicates that the entity can be referred to from other translation units withi...
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
FunctionDecl * getClassScopeSpecializationPattern() const
Retrieve the class scope template pattern that this function template specialization is instantiated ...
bool isInlineSpecified() const
Stmt ** getInitAddress()
Retrieve the address of the initializer expression.
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma...
SourceLocation getBeginLoc() const
Get the begin source location.
unsigned IgnoreExplicitVisibility
Whether explicit visibility attributes should be ignored.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Defines the clang::LangOptions interface.
bool isTypeVisibility() const
bool isVariadic() const
Whether this function is variadic.
static bool classofKind(Kind K)
void mergeExternalVisibility(Linkage L)
const T * castAs() const
Member-template castAs<specific type>.
static bool hasExplicitVisibilityAlready(LVComputationKind computation)
Does this computation kind permit us to consider additional visibility settings from attributes and t...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isKnownToBeDefined() const
static Optional< Visibility > getVisibilityOf(const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind)
Return the explicit visibility of the given declaration.
static LVComputationKind withExplicitVisibilityAlready(LVComputationKind Kind)
Given an LVComputationKind, return one of the same type/value sort that records that it already has e...
Linkage getLinkage() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isFileContext() const
DeclContext * getDeclContext()
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
This declaration is a tentative definition.
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
TLSKind getTLSKind() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
void setCompleteDefinitionRequired(bool V=true)
True if this complete decl is required to be complete for some existing use.
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Defines the clang::TypeLoc interface and its subclasses.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
static bool RedeclForcesDefC99(const FunctionDecl *Redecl)
static const CXXRecordDecl * getOutermostEnclosingLambda(const CXXRecordDecl *Record)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFunctionOrMethod() const
StorageClass
Storage classes.
static Optional< Visibility > getExplicitVisibility(const NamedDecl *D, LVComputationKind kind)
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
unsigned IgnoreAllVisibility
Whether all visibility should be ignored.
InClassInitStyle
In-class initialization styles for non-static data members.
static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
This declaration has an owning module, and is visible when that module is imported.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isExternallyVisible(Linkage L)
SourceLocation getEnd() const
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
bool capturesVariable(const VarDecl *var) const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isValueVisibility() const
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...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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...
void setStorageClass(StorageClass SC)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void addDestruction(T *Ptr)
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
DefinitionKind isThisDeclarationADefinition() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static LinkageInfo visible_none()
FunctionDeclBitfields FunctionDeclBits
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
void setDoesNotEscape(bool B=true)
TypeLoc getReturnLoc() const
static bool isNamed(const NamedDecl *ND, const char(&Str)[Len])
const SanitizerBlacklist & getSanitizerBlacklist() const
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
static LinkageInfo external()
VarDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
void setIsVariadic(bool value)
Abstract interface for external sources of AST nodes.
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
virtual void printName(raw_ostream &os) const
Represents a C++ Modules TS module export declaration.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
Decl::Kind getDeclKind() const
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
This declaration has an owning module, but is globally visible (typically because its owning module i...
void setIsConversionFromLambda(bool val=true)
static bool classof(const Decl *D)
static EnumConstantDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeLoc IgnoreParens() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Encodes a location in the source.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isLinkageValid() const
True if the computed linkage is valid.
static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)
bool mayHaveOutOfDateDef() const
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
ASTContext & getASTContext() const LLVM_READONLY
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope.
static QualType getUnderlyingType(const SubRegion *R)
Represents the declaration of a label.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList *> TPLists)
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isLegalForVariable(StorageClass SC)
Checks whether the given storage class is legal for variables.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
void setHasFlexibleArrayMember(bool V)
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
const ParmVarDecl * getParamDecl(unsigned i) const
This file defines OpenMP nodes for declarative directives.
bool hasCachedLinkage() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool doesDeclarationForceExternallyVisibleDefinition() const
For a function declaration in C or C++, determine whether this declaration causes the definition to b...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
This is a fragment of the global module within some C++ Modules TS module.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Linkage getCachedLinkage() const
bool isNonEscapingByref() const
Indicates the capture is a __block variable that is never captured by an escaping block...
void setTagKind(TagKind TK)
This declaration is only a declaration.
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
unsigned getODRHash()
Returns ODRHash of the function.
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
DeclarationNameInfo getNameInfo() const
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
FunctionDecl * getClassScopeSpecializationPattern(const FunctionDecl *FD)
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
bool isValid() const
Whether this pointer is non-NULL.
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.
void AddEnumDecl(const EnumDecl *Enum)
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
static bool isDeclExternC(const T &D)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
void setHasWrittenPrototype(bool P=true)
State that this function has a written prototype.
Defines various enumerations that describe declaration and type specifiers.
void * Allocate(size_t Size, unsigned Align=8) const
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
decl_iterator - Iterates through the declarations stored within this context.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Base class for declarations which introduce a typedef-name.
TLS with a dynamic initializer.
Represents a template argument.
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
TagTypeKind
The kind of a tag type.
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Dataflow Directional Tag Classes.
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
bool isValid() const
Return true if this is a valid SourceLocation object.
void setHasVolatileMember(bool val)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ArrayRef< Capture > captures() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
bool isVisibilityExplicit() const
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
bool isInExternCXXContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec...
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
InitType Init
The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
Represents a field injected from an anonymous union/struct into the parent scope. ...
const Expr * getInit() const
static bool shouldConsiderTemplateVisibility(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo)
This template specialization was instantiated from a template due to an explicit instantiation declar...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
TLSKind
Kinds of thread-local storage.
Do an LV computation for, ultimately, a non-type declaration.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
The name of a declaration.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization...
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
ParmVarDeclBitfields ParmVarDeclBits
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
static bool isSingleLineLanguageLinkage(const Decl &D)
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer points to.
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
This declaration is not owned by a module.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
void setCapturesCXXThis(bool B=true)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Do an LV computation for, ultimately, a type.
Not an overloaded operator.
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static ExportDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Location wrapper for a TemplateArgument.
static const TypeInfo & getInfo(unsigned id)
NonParmVarDeclBitfields NonParmVarDeclBits
Expr * getUninstantiatedDefaultArg()
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
bool isFunctionType() const
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
TypeSourceInfo * getTypeSourceInfo() const
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required...
void print(raw_ostream &OS) const override
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static LinkageInfo getInternalLinkageFor(const NamedDecl *D)
The template argument is a type.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool classofKind(Kind K)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
The template argument is actually a parameter pack.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
NamedDecl::ExplicitVisibilityKind getExplicitVisibilityKind() const
void merge(LinkageInfo other)
Merge both linkage and visibility.
SourceManager & getSourceManager()
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
A template argument list.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
static bool isFirstInExternCContext(T *D)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
Optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
NestedNameSpecifierLoc QualifierLoc
static FieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void Deallocate(void *Ptr) const
Defines the clang::SourceLocation class and associated facilities.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void setDefaultArg(Expr *defarg)
Represents a C++ struct/union/class.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
The template argument is a template name that was provided for a template template parameter...
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
static TranslationUnitDecl * Create(ASTContext &C)
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl *> Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Provides information a specialization of a member of a class template, which may be a member function...
No linkage according to the standard, but is visible from other translation units because of types de...
void setMSAsmLabel(StringRef Name)
Decl(Kind DK, DeclContext *DC, SourceLocation L)
VarDecl * getDefinition()
Builtin::Context & BuiltinInfo
Declaration of a class template.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
static DeclT * getDefinitionOrSelf(DeclT *D)
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Kind
Lists the kind of concrete classes of Decl.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
SourceLocation getLAngleLoc() const
static bool isRedeclarableImpl(Redeclarable< T > *)
std::string getQualifiedNameAsString() const
VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
__DEVICE__ int max(int __a, int __b)
static Decl::Kind getKind(const Decl *D)
VarDeclBitfields VarDeclBits
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
NamedDecl * getMostRecentDecl()
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
static bool useInlineVisibilityHidden(const NamedDecl *D)
void setHasLoadedFieldsFromExternalStorage(bool val) const
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
bool isStaticDataMember() const
Determines whether this is a static data member.
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
bool isTranslationUnit() const
void mergeMaybeWithVisibility(LinkageInfo other, bool withVis)
Merge linkage and conditionally merge visibility.
static LinkageInfo none()
Represents a C array with a specified size that is not an integer-constant-expression.
bool isInline() const
Whether this variable is (C++1z) inline.
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity, such as 'alias' or 'ifunc'.
Represents a #pragma detect_mismatch line.
void setBlockMissingReturnType(bool val=true)
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
SourceLocation getRAngleLoc() const
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
bool isInStdNamespace() const
static bool hasDirectVisibilityAttribute(const NamedDecl *D, LVComputationKind computation)
Does the given declaration have a direct visibility attribute that would match the given rules...
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
const LangOptions & getLangOpts() const
static LinkageInfo uniqueExternal()
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
void setNonTrivialToPrimitiveCopy(bool V)
static Optional< Visibility > getExplicitVisibilityAux(const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent)
static LVComputationKind forLinkageOnly()
Do an LV computation when we only care about the linkage.
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
This class handles loading and caching of source files into memory.
bool isGlobal() const
Determines whether this is a global function.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
bool hasLinkage() const
Determine whether this declaration has linkage.
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
This is a C++ Modules TS module interface unit.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Structure used to store a statement, the constant value to which it was evaluated (if any)...
TemplatedKind
The kind of templated function a FunctionDecl can be.
bool isNoDestroy(const ASTContext &) const
Do we need to emit an exit-time destructor for this variable?