52 #include "llvm/ADT/APSInt.h" 53 #include "llvm/ADT/ArrayRef.h" 54 #include "llvm/ADT/None.h" 55 #include "llvm/ADT/Optional.h" 56 #include "llvm/ADT/STLExtras.h" 57 #include "llvm/ADT/SmallVector.h" 58 #include "llvm/ADT/StringSwitch.h" 59 #include "llvm/ADT/StringRef.h" 60 #include "llvm/ADT/Triple.h" 61 #include "llvm/Support/Casting.h" 62 #include "llvm/Support/ErrorHandling.h" 63 #include "llvm/Support/raw_ostream.h" 71 #include <type_traits> 73 using namespace clang;
88 if (
auto *ND = dyn_cast_or_null<NamedDecl>(TheDecl)) {
99 return !getLexicalDeclContext()->Equals(getDeclContext());
102 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
173 "asking for explicit visibility when we shouldn't be");
180 return isa<TypeDecl>(D) ||
181 isa<ClassTemplateDecl>(D) ||
182 isa<ObjCInterfaceDecl>(D);
187 template <
class T>
static typename 188 std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value,
bool>
::type 191 D->getMemberSpecializationInfo()) {
192 return member->isExplicitSpecialization();
208 switch (attr->getVisibility()) {
216 llvm_unreachable(
"bad visibility kind");
225 if (
const auto *A = D->
getAttr<TypeVisibilityAttr>()) {
231 if (
const auto *A = D->
getAttr<VisibilityAttr>()) {
242 return getTypeLinkageAndVisibility(&T);
248 LinkageInfo LinkageComputer::getLVForTemplateParameterList(
254 if (isa<TemplateTypeParmDecl>(
P))
261 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
263 if (!NTTP->isExpandedParameterPack()) {
264 if (!NTTP->getType()->isDependentType()) {
265 LV.
merge(getLVForType(*NTTP->getType(), computation));
271 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes();
i != n; ++
i) {
274 LV.
merge(getTypeLinkageAndVisibility(type));
281 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
284 if (!TTP->isExpandedParameterPack()) {
285 LV.
merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),
291 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
293 LV.
merge(getLVForTemplateParameterList(
294 TTP->getExpansionTemplateParameters(
i), computation));
302 const Decl *Ret =
nullptr;
304 while (DC->
getDeclKind() != Decl::TranslationUnit) {
305 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
306 Ret = cast<Decl>(DC);
323 switch (Arg.getKind()) {
330 LV.
merge(getLVForType(*Arg.getAsType(), computation));
336 LV.
merge(getLVForDecl(ND, computation));
341 LV.
merge(getTypeLinkageAndVisibility(Arg.getNullPtrType()));
347 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
348 LV.
merge(getLVForDecl(Template, computation));
352 LV.
merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));
355 llvm_unreachable(
"bad template argument kind");
364 return getLVForTemplateArgumentList(TArgs.
asArray(), computation);
376 return !fn->
hasAttr<VisibilityAttr>();
386 void LinkageComputer::mergeTemplateLV(
390 bool considerVisibility =
401 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
454 void LinkageComputer::mergeTemplateLV(
472 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
473 if (considerVisibility)
506 void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV,
524 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
525 if (considerVisibility)
533 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
542 = FD->getTemplateSpecializationInfo()) {
545 FD->getMemberSpecializationInfo()) {
546 TSK = MSI->getTemplateSpecializationKind();
559 const T *
First = D->getFirstDecl();
560 return First->isInExternCContext();
564 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.
getDeclContext()))
565 if (!SD->hasBraces())
573 return M->isModulePurview();
587 llvm_unreachable(
"unexpected module ownership kind");
614 if (
auto *TD = dyn_cast<TemplateDecl>(D))
615 D = TD->getTemplatedDecl();
617 if (
auto *VD = dyn_cast<VarDecl>(D))
618 return VD->getStorageClass();
619 if (
auto *FD = dyn_cast<FunctionDecl>(D))
620 return FD->getStorageClass();
626 LinkageComputer::getLVForNamespaceScopeDecl(
const NamedDecl *D,
628 bool IgnoreVarTypeLinkage) {
630 "Not a name having namespace scope");
644 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
651 if (Context.getLangOpts().CPlusPlus &&
652 Var->getType().isConstQualified() &&
653 !Var->getType().isVolatileQualified() &&
656 !isa<VarTemplateSpecializationDecl>(Var) &&
657 !Var->getDescribedVarTemplate()) {
660 return getLVForDecl(PrevVar, computation);
662 if (Var->getStorageClass() !=
SC_Extern &&
671 Var->getStorageClass() ==
SC_None)
672 return getDeclLinkageAndVisibility(PrevVar);
674 if (PrevVar->getStorageClass() ==
SC_Static)
677 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
679 const VarDecl *VD = IFD->getVarDecl();
680 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
681 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
683 assert(!isa<FieldDecl>(D) &&
"Didn't expect a FieldDecl!");
688 const auto *Var = dyn_cast<
VarDecl>(D);
717 !isa<TranslationUnitDecl>(DC);
733 ? Context.getLangOpts().getValueVisibilityMode()
734 : Context.getLangOpts().getTypeVisibilityMode();
760 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
783 !IgnoreVarTypeLinkage) {
784 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
801 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
802 mergeTemplateLV(LV, spec, computation);
806 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
826 QualType TypeAsWritten = Function->getType();
828 TypeAsWritten = TSI->getType();
837 = Function->getTemplateSpecializationInfo()) {
838 mergeTemplateLV(LV, Function, specInfo, computation);
847 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
849 if (!Tag->hasNameForLinkage())
855 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
856 mergeTemplateLV(LV, spec, computation);
861 }
else if (isa<EnumConstantDecl>(D)) {
869 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
872 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
880 }
else if (isa<NamespaceDecl>(D)) {
885 }
else if (isa<ObjCInterfaceDecl>(D)) {
888 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
891 if (!TD->getAnonDeclWithTypedefName(
true))
908 LinkageComputer::getLVForClassMember(
const NamedDecl *D,
910 bool IgnoreVarTypeLinkage) {
921 if (!(isa<CXXMethodDecl>(D) ||
924 isa<IndirectFieldDecl>(D) ||
926 isa<TemplateDecl>(D)))
952 getLVForDecl(cast<RecordDecl>(D->
getDeclContext()), classComputation);
964 const NamedDecl *explicitSpecSuppressor =
nullptr;
966 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
969 QualType TypeAsWritten = MD->getType();
971 TypeAsWritten = TSI->getType();
978 = MD->getTemplateSpecializationInfo()) {
979 mergeTemplateLV(LV, MD, spec, computation);
981 explicitSpecSuppressor = MD;
983 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
986 explicitSpecSuppressor = MD;
989 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
990 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
991 mergeTemplateLV(LV, spec, computation);
993 explicitSpecSuppressor = spec;
1001 explicitSpecSuppressor = RD;
1005 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
1006 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
1007 mergeTemplateLV(LV, spec, computation);
1011 if (!IgnoreVarTypeLinkage) {
1012 LinkageInfo typeLV = getLVForType(*VD->getType(), computation);
1021 explicitSpecSuppressor = VD;
1025 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
1026 bool considerVisibility =
1031 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
1034 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
1036 explicitSpecSuppressor = temp->getTemplatedDecl();
1042 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
1046 bool considerClassVisibility =
true;
1047 if (explicitSpecSuppressor &&
1052 considerClassVisibility =
false;
1060 void NamedDecl::anchor() {}
1063 if (!hasCachedLinkage())
1069 return L == getCachedLinkage();
1076 if (name.front() ==
'C')
1077 if (name ==
"CFStringCreateWithFormat" ||
1078 name ==
"CFStringCreateWithFormatAndArguments" ||
1079 name ==
"CFStringAppendFormat" ||
1080 name ==
"CFStringAppendFormatAndArguments")
1100 bool IsMostRecent) {
1109 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1111 if (InstantiatedFrom)
1118 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1122 while (TD !=
nullptr) {
1126 TD = TD->getPreviousDecl();
1132 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1134 if (MostRecent != ND)
1138 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1139 if (Var->isStaticDataMember()) {
1141 if (InstantiatedFrom)
1145 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1146 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1152 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1157 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1163 if (InstantiatedFrom)
1170 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1188 else if (isa<ParmVarDecl>(ContextDecl))
1192 Owner = cast<NamedDecl>(ContextDecl);
1201 auto *VD = dyn_cast<
VarDecl>(Owner);
1203 VD && VD->getType()->getContainedDeducedType()
1204 ? computeLVForDecl(Owner, computation,
true)
1205 : getLVForDecl(Owner, computation);
1212 OwnerLV.isVisibilityExplicit());
1217 if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
1218 if (Function->isInAnonymousNamespace() &&
1223 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
1240 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1241 if (Var->hasExternalStorage()) {
1254 LinkageInfo PrevLV = getLVForDecl(Prev, computation);
1263 if (!Var->isStaticLocal())
1276 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1277 if (!BD->getBlockManglingNumber())
1280 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),
1281 BD->getBlockManglingContextDecl(), computation);
1283 const auto *FD = cast<FunctionDecl>(OuterD);
1284 if (!FD->isInlined() &&
1291 LV = getLVForDecl(FD, computation);
1294 assert(cast<VarDecl>(D)->isStaticLocal());
1298 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1299 LV = getLVForDecl(MD->getParent(), computation);
1319 while (Record && Record->
isLambda()) {
1323 Record = dyn_cast_or_null<CXXRecordDecl>(
1331 bool IgnoreVarTypeLinkage) {
1333 if (D->
hasAttr<InternalLinkageAttr>())
1348 case Decl::ImplicitParam:
1350 case Decl::NamespaceAlias:
1353 case Decl::UsingShadow:
1354 case Decl::UsingDirective:
1357 case Decl::EnumConstant:
1360 return getLVForDecl(cast<EnumDecl>(D->
getDeclContext()), computation);
1364 case Decl::TypeAlias:
1367 if (!cast<TypedefNameDecl>(D)
1368 ->getAnonDeclWithTypedefName(
true))
1372 case Decl::TemplateTemplateParm:
1373 case Decl::NonTypeTemplateParm:
1374 case Decl::ObjCAtDefsField:
1375 case Decl::ObjCCategory:
1376 case Decl::ObjCCategoryImpl:
1377 case Decl::ObjCCompatibleAlias:
1378 case Decl::ObjCImplementation:
1379 case Decl::ObjCMethod:
1380 case Decl::ObjCProperty:
1381 case Decl::ObjCPropertyImpl:
1382 case Decl::ObjCProtocol:
1385 case Decl::CXXRecord: {
1386 const auto *Record = cast<CXXRecordDecl>(D);
1387 if (Record->isLambda()) {
1388 if (!Record->getLambdaManglingNumber()) {
1408 return getLVForClosure(
1419 return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);
1429 return getLVForClassMember(D, computation, IgnoreVarTypeLinkage);
1443 return getLVForLocalDecl(D, computation);
1454 if (D->
hasAttr<InternalLinkageAttr>())
1463 LinkageInfo LV = computeLVForDecl(D, computation);
1468 cache(D, computation, LV);
1475 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1483 auto *T = cast<NamedDecl>(I);
1486 if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
1498 return getLVForDecl(D,
1505 Module *M = getOwningModule();
1525 if (
auto *ND = dyn_cast<NamedDecl>(
this))
1526 InternalLinkage = !ND->hasExternalFormalLinkage();
1529 InternalLinkage = (NSD && NSD->isAnonymousNamespace()) ||
1530 isInAnonymousNamespace();
1532 return InternalLinkage ? M->
Parent :
nullptr;
1541 llvm_unreachable(
"unknown module kind");
1549 std::string QualName;
1550 llvm::raw_string_ostream OS(QualName);
1551 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1556 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1565 if (
auto *MD = dyn_cast<ObjCMethodDecl>(
this))
1566 if (
auto *
ID = MD->getClassInterface())
1568 if (
auto *PD = dyn_cast<ObjCPropertyDecl>(
this)) {
1569 if (
auto *MD = PD->getGetterMethodDecl())
1570 if (
auto *
ID = MD->getClassInterface())
1580 ContextsTy Contexts;
1584 if (isa<NamedDecl>(Ctx))
1585 Contexts.push_back(Ctx);
1589 for (
const DeclContext *DC : llvm::reverse(Contexts)) {
1590 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1591 OS << Spec->getName();
1594 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1596 (ND->isAnonymousNamespace() || ND->isInline()))
1598 if (ND->isAnonymousNamespace()) {
1600 :
"(anonymous namespace)");
1604 }
else if (
const auto *RD = dyn_cast<RecordDecl>(DC)) {
1605 if (!RD->getIdentifier())
1606 OS <<
"(anonymous " << RD->getKindName() <<
')';
1609 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1611 if (FD->hasWrittenPrototype())
1612 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1617 for (
unsigned i = 0;
i < NumParams; ++
i) {
1620 OS << FD->getParamDecl(
i)->getType().stream(P);
1630 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1643 OS << *cast<NamedDecl>(DC);
1648 if (getDeclName() || isa<DecompositionDecl>(
this))
1651 OS <<
"(anonymous)";
1656 bool Qualified)
const {
1658 printQualifiedName(OS, Policy);
1669 #define DECL(Type, Base) \ 1671 return isRedeclarableImpl((Type##Decl *)nullptr); 1672 #define ABSTRACT_DECL(DECL) 1673 #include "clang/AST/DeclNodes.inc" 1675 llvm_unreachable(
"unknown decl kind");
1679 assert(getDeclName() == OldD->
getDeclName() &&
"Declaration name mismatch");
1691 if (isa<ObjCMethodDecl>(
this))
1696 if (isa<ParmVarDecl>(
this))
1702 if (!this->getDeclContext()->getRedeclContext()->Equals(
1708 if (
auto *UD = dyn_cast<UsingDecl>(
this)) {
1712 cast<UsingDecl>(OldD)->getQualifier());
1714 if (
auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this)) {
1718 cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
1731 for (
auto D : redecls()) {
1758 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1760 while (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1761 ND = UD->getTargetDecl();
1763 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1764 return AD->getClassInterface();
1766 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1767 return AD->getNamespace();
1773 if (!isCXXClassMember())
1777 if (isa<UsingShadowDecl>(D))
1778 D = cast<UsingShadowDecl>(D)->getTargetDecl();
1780 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<MSPropertyDecl>(D))
1782 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(D->
getAsFunction()))
1783 return MD->isInstance();
1791 template <
typename DeclT>
1793 if (decl->getNumTemplateParameterLists() > 0)
1794 return decl->getTemplateParameterList(0)->getTemplateLoc();
1796 return decl->getInnerLocStart();
1808 if (!hasExtInfo()) {
1812 DeclInfo =
new (getASTContext()) ExtInfo;
1814 getExtInfo()->TInfo = savedTInfo;
1817 getExtInfo()->QualifierLoc = QualifierLoc;
1821 if (getExtInfo()->NumTemplParamLists == 0) {
1825 getASTContext().Deallocate(getExtInfo());
1827 DeclInfo = savedTInfo;
1830 getExtInfo()->QualifierLoc = QualifierLoc;
1837 assert(!TPLists.empty());
1839 if (!hasExtInfo()) {
1843 DeclInfo =
new (getASTContext()) ExtInfo;
1845 getExtInfo()->TInfo = savedTInfo;
1848 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
1864 QT = cast<PointerType>(T)->getPointeeType();
1866 case Type::BlockPointer:
1867 QT = cast<BlockPointerType>(T)->getPointeeType();
1869 case Type::MemberPointer:
1870 QT = cast<MemberPointerType>(T)->getPointeeType();
1872 case Type::LValueReference:
1873 case Type::RValueReference:
1874 QT = cast<ReferenceType>(T)->getPointeeType();
1876 case Type::PackExpansion:
1877 QT = cast<PackExpansionType>(T)->getPattern();
1880 case Type::ConstantArray:
1881 case Type::DependentSizedArray:
1882 case Type::IncompleteArray:
1883 case Type::VariableArray:
1884 case Type::FunctionProto:
1885 case Type::FunctionNoProto:
1897 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
1905 if (NumTemplParamLists > 0) {
1907 TemplParamLists =
nullptr;
1908 NumTemplParamLists = 0;
1911 if (!TPLists.empty()) {
1913 NumTemplParamLists = TPLists.size();
1914 std::copy(TPLists.begin(), TPLists.end(), TemplParamLists);
1932 llvm_unreachable(
"Invalid storage class");
1941 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(
unsigned),
1942 "VarDeclBitfields too large!");
1944 "ParmVarDeclBitfields too large!");
1946 "NonParmVarDeclBitfields too large!");
1956 return new (
C, DC)
VarDecl(Var, C, DC, StartL, IdL, Id, T, TInfo, S);
1973 if (!hasAttr<ThreadAttr>() &&
1976 hasAttr<OMPThreadPrivateDeclAttr>()))
1978 return ((
getASTContext().getLangOpts().isCompatibleWithMSVC(
1980 hasAttr<OMPThreadPrivateDeclAttr>())
1989 llvm_unreachable(
"Unknown thread storage class specifier!");
2003 template<
typename T>
2007 if (!D.hasExternalFormalLinkage())
2031 template<
typename T>
2037 assert(D.getASTContext().getLangOpts().CPlusPlus);
2092 isa<VarTemplatePartialSpecializationDecl>(
this)))
2112 if (
const auto *SAA = getAttr<SelectAnyAttr>())
2113 if (!SAA->isInherited())
2119 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2121 !isa<VarTemplatePartialSpecializationDecl>(VTSD) &&
2122 !VTSD->IsCompleteDefinition)
2154 VarDecl *LastTentative =
nullptr;
2156 for (
auto I : First->
redecls()) {
2157 Kind = I->isThisDeclarationADefinition();
2163 return LastTentative;
2168 for (
auto I : First->
redecls()) {
2169 if (I->isThisDeclarationADefinition(C) ==
Definition)
2179 for (
auto I : First->
redecls()) {
2180 Kind =
std::max(Kind, I->isThisDeclarationADefinition(C));
2190 if (
auto Expr = I->getInit()) {
2199 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2200 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2203 return !
Init.isNull();
2210 if (
auto *S =
Init.dyn_cast<
Stmt *>())
2211 return cast<Expr>(S);
2220 return Init.getAddrOfPtr1();
2234 return VD->isOutOfLine();
2241 Eval->~EvaluatedStmt();
2251 if (!Lang.CPlusPlus)
2255 if (isa<ParmVarDecl>(
this))
2260 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2266 if (!
getType().isConstQualified() ||
getType().isVolatileQualified())
2271 if (
getType()->isIntegralOrEnumerationType())
2283 const VarDecl *DefVD =
nullptr;
2327 const auto *
Init = cast<Expr>(Eval->
Value);
2328 assert(!
Init->isValueDependent());
2333 Eval->
IsICE =
false;
2357 Eval->
IsICE = Result && Notes.empty();
2360 return Result ? &Eval->
Evaluated :
nullptr;
2365 if (Eval->WasEvaluated)
2366 return &Eval->Evaluated;
2373 return Eval->CheckedICE;
2380 "Check whether we already know that the initializer is an ICE");
2395 const auto *
Init = cast<Expr>(Eval->
Value);
2396 assert(!
Init->isValueDependent());
2421 return isa<PackExpansionType>(
getType());
2424 template<
typename DeclT>
2427 if (
auto *Def = D->getDefinition())
2455 if (
auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
2457 auto From = VDTemplSpec->getInstantiatedFrom();
2459 while (!VTD->isMemberSpecialization()) {
2460 auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
2469 while (!VTPSD->isMemberSpecialization()) {
2470 auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
2475 return getDefinitionOrSelf<VarDecl>(VTPSD);
2483 while (!VarTemplate->isMemberSpecialization()) {
2484 auto *NewVT = VarTemplate->getInstantiatedFromMemberTemplate();
2487 VarTemplate = NewVT;
2500 return cast<VarDecl>(MSI->getInstantiatedFrom());
2506 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2507 return Spec->getSpecializationKind();
2510 return MSI->getTemplateSpecializationKind();
2518 return MSI->getTemplateSpecializationKind();
2520 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2521 return Spec->getSpecializationKind();
2527 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2528 return Spec->getPointOfInstantiation();
2531 return MSI->getPointOfInstantiation();
2554 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&
2556 isa<IncompleteArrayType>(
getType()))
2565 !hasAttr<AlwaysDestroyAttr>()));
2579 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2581 "not a variable or static data member template specialization");
2584 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2585 Spec->setSpecializationKind(TSK);
2587 PointOfInstantiation.
isValid() &&
2588 Spec->getPointOfInstantiation().isInvalid()) {
2589 Spec->setPointOfInstantiation(PointOfInstantiation);
2591 L->InstantiationRequested(
this);
2594 MSI->setTemplateSpecializationKind(TSK);
2596 MSI->getPointOfInstantiation().isInvalid()) {
2597 MSI->setPointOfInstantiation(PointOfInstantiation);
2599 L->InstantiationRequested(
this);
2607 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2608 "Previous template or instantiation?");
2621 return new (
C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
2628 if (
const auto *DT = dyn_cast<DecayedType>(T))
2629 return DT->getOriginalType();
2640 if (!hasInheritedDefaultArg()) {
2655 assert(!hasUnparsedDefaultArg() &&
"Default argument is not yet parsed!");
2656 assert(!hasUninstantiatedDefaultArg() &&
2657 "Default argument is not yet instantiated!");
2660 if (
auto *E = dyn_cast_or_null<FullExpr>(Arg))
2661 return E->getSubExpr();
2679 return getUninstantiatedDefaultArg()->getSourceRange();
2683 return E->getSourceRange();
2688 llvm_unreachable(
"Invalid default argument kind.");
2697 assert(hasUninstantiatedDefaultArg() &&
2698 "Wrong kind of initialization expression!");
2699 return cast_or_null<Expr>(
Init.get<
Stmt *>());
2706 return hasUnparsedDefaultArg() || hasUninstantiatedDefaultArg() ||
2710 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
2715 unsigned ParmVarDecl::getParameterIndexLarge()
const {
2759 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
2767 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
2768 return FT->isVariadic();
2774 if (I->doesThisDeclarationHaveABody()) {
2792 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
2799 if (I->isThisDeclarationADefinition()) {
2812 if (Definition->Body)
2828 Parent->markedVirtualFunctionPure();
2831 template<std::
size_t Len>
2834 return II && II->
isStr(Str);
2862 return llvm::StringSwitch<bool>(
getName())
2874 assert(
getDeclName().getCXXOverloadedOperator() == OO_New ||
2875 getDeclName().getCXXOverloadedOperator() == OO_Delete ||
2876 getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
2877 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
2883 if (proto->getNumParams() != 2 || proto->isVariadic())
2892 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
2898 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
2899 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
2900 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
2901 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
2912 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 3 || FPT->isVariadic())
2917 if (FPT->getNumParams() == 1)
2920 unsigned Params = 1;
2921 QualType Ty = FPT->getParamType(Params);
2924 auto Consume = [&] {
2926 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) :
QualType();
2930 bool IsSizedDelete =
false;
2935 IsSizedDelete =
true;
2958 return Params == FPT->getNumParams();
2972 RD->getIdentifier()->isStr(
"destroying_delete_t");
2984 if (hasAttr<OpenCLKernelAttr>())
2994 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
2995 return Method->isStatic();
3003 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
3004 if (!Namespace->getDeclName())
3014 if (hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
3015 hasAttr<C11NoReturnAttr>())
3018 if (
auto *FnTy =
getType()->getAs<FunctionType>())
3019 return FnTy->getNoReturnAttr();
3026 if (hasAttr<TargetAttr>())
3028 if (hasAttr<CPUDispatchAttr>())
3030 if (hasAttr<CPUSpecificAttr>())
3054 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
3055 FunTmpl->setPreviousDecl(PrevFunTmpl);
3087 const auto *LinkageDecl =
3094 if (BuiltinID == Builtin::BI__GetExceptionInfo &&
3096 return Builtin::BI__GetExceptionInfo;
3105 if (!ConsiderWrapperFunctions && hasAttr<OverloadableAttr>())
3127 if (Context.
getLangOpts().CUDA && hasAttr<CUDADeviceAttr>() &&
3128 !hasAttr<CUDAHostAttr>() &&
3129 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3145 assert(!ParamInfo &&
"Already has param info!");
3146 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
3149 if (!NewParamInfo.empty()) {
3151 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3163 unsigned NumRequiredArgs = 0;
3165 if (!Param->isParameterPack() && !Param->hasDefaultArg())
3167 return NumRequiredArgs;
3176 assert(
isInlined() &&
"expected to get called on an inlined function!");
3180 !hasAttr<DLLExportAttr>())
3185 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3197 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3227 "Must have a declaration without a body.");
3238 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3248 bool FoundBody =
false;
3250 FoundBody |= Prev->Body.
isValid();
3276 bool FoundBody =
false;
3278 FoundBody |= Prev->Body.
isValid();
3336 hasAttr<AliasAttr>()) &&
3337 "Must be a function definition");
3338 assert(
isInlined() &&
"Function must be inline");
3341 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3353 for (
auto Redecl :
redecls()) {
3354 if (Redecl->isInlineSpecified() &&
3364 "should not use C inline rules in C++");
3370 for (
auto Redecl :
redecls()) {
3401 if (TemplateOrSpecialization.isNull())
3409 if (TemplateOrSpecialization.is
3413 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
3418 return cast<FunctionDecl>(Info->getInstantiatedFrom());
3427 if (
auto *FTSI = TemplateOrSpecialization
3428 .dyn_cast<FunctionTemplateSpecializationInfo *>())
3429 return FTSI->getMemberSpecializationInfo();
3434 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
3437 assert(TemplateOrSpecialization.isNull() &&
3438 "Member function is already a specialization");
3441 TemplateOrSpecialization = Info;
3449 assert(TemplateOrSpecialization.isNull() &&
3450 "Member function is already a specialization");
3451 TemplateOrSpecialization = Template;
3475 bool HasPattern =
false;
3477 HasPattern = PatternDecl->
hasBody(PatternDecl);
3483 if (!HasPattern || !PatternDecl)
3506 dyn_cast<CXXMethodDecl>(
this))) {
3523 while (!Primary->isMemberSpecialization()) {
3524 auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();
3527 Primary = NewPrimary;
3538 = TemplateOrSpecialization
3539 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3540 return Info->getTemplate();
3547 return TemplateOrSpecialization
3554 = TemplateOrSpecialization
3555 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3556 return Info->TemplateArguments;
3564 = TemplateOrSpecialization
3565 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3566 return Info->TemplateArgumentsAsWritten;
3572 FunctionDecl::setFunctionTemplateSpecialization(
ASTContext &C,
3579 assert((TemplateOrSpecialization.isNull() ||
3581 "Member function is already a specialization");
3583 "Must specify the type of function template specialization");
3584 assert((TemplateOrSpecialization.isNull() ||
3586 "Member specialization must be an explicit specialization");
3589 C,
this, Template, TSK, TemplateArgs, TemplateArgsAsWritten,
3590 PointOfInstantiation,
3592 TemplateOrSpecialization = Info;
3600 assert(TemplateOrSpecialization.isNull());
3604 TemplateOrSpecialization = Info;
3609 return TemplateOrSpecialization
3618 totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
3623 DependentFunctionTemplateSpecializationInfo::
3627 NumTemplates = Ts.
size();
3628 NumArgs = TArgs.
size();
3631 for (
unsigned I = 0, E = Ts.
size(); I != E; ++I)
3635 for (
unsigned I = 0, E = TArgs.
size(); I != E; ++I)
3643 TemplateOrSpecialization
3644 .dyn_cast<FunctionTemplateSpecializationInfo *>())
3645 return FTSInfo->getTemplateSpecializationKind();
3649 return MSInfo->getTemplateSpecializationKind();
3674 TemplateOrSpecialization
3675 .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
3676 if (
auto *MSInfo = FTSInfo->getMemberSpecializationInfo())
3677 return MSInfo->getTemplateSpecializationKind();
3678 return FTSInfo->getTemplateSpecializationKind();
3683 return MSInfo->getTemplateSpecializationKind();
3692 = TemplateOrSpecialization.dyn_cast<
3694 FTSInfo->setTemplateSpecializationKind(TSK);
3696 PointOfInstantiation.
isValid() &&
3697 FTSInfo->getPointOfInstantiation().isInvalid()) {
3698 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
3700 L->InstantiationRequested(
this);
3704 MSInfo->setTemplateSpecializationKind(TSK);
3706 PointOfInstantiation.
isValid() &&
3707 MSInfo->getPointOfInstantiation().isInvalid()) {
3708 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3710 L->InstantiationRequested(
this);
3713 llvm_unreachable(
"Function cannot have a template specialization kind");
3718 = TemplateOrSpecialization.dyn_cast<
3720 return FTSInfo->getPointOfInstantiation();
3723 return MSInfo->getPointOfInstantiation();
3744 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
3763 case Builtin::BI__builtin_memset:
3764 case Builtin::BI__builtin___memset_chk:
3765 case Builtin::BImemset:
3766 return Builtin::BImemset;
3768 case Builtin::BI__builtin_memcpy:
3769 case Builtin::BI__builtin___memcpy_chk:
3770 case Builtin::BImemcpy:
3771 return Builtin::BImemcpy;
3773 case Builtin::BI__builtin_memmove:
3774 case Builtin::BI__builtin___memmove_chk:
3775 case Builtin::BImemmove:
3776 return Builtin::BImemmove;
3778 case Builtin::BIstrlcpy:
3779 case Builtin::BI__builtin___strlcpy_chk:
3780 return Builtin::BIstrlcpy;
3782 case Builtin::BIstrlcat:
3783 case Builtin::BI__builtin___strlcat_chk:
3784 return Builtin::BIstrlcat;
3786 case Builtin::BI__builtin_memcmp:
3787 case Builtin::BImemcmp:
3788 return Builtin::BImemcmp;
3790 case Builtin::BI__builtin_bcmp:
3791 case Builtin::BIbcmp:
3792 return Builtin::BIbcmp;
3794 case Builtin::BI__builtin_strncpy:
3795 case Builtin::BI__builtin___strncpy_chk:
3796 case Builtin::BIstrncpy:
3797 return Builtin::BIstrncpy;
3799 case Builtin::BI__builtin_strncmp:
3800 case Builtin::BIstrncmp:
3801 return Builtin::BIstrncmp;
3803 case Builtin::BI__builtin_strncasecmp:
3804 case Builtin::BIstrncasecmp:
3805 return Builtin::BIstrncasecmp;
3807 case Builtin::BI__builtin_strncat:
3808 case Builtin::BI__builtin___strncat_chk:
3809 case Builtin::BIstrncat:
3810 return Builtin::BIstrncat;
3812 case Builtin::BI__builtin_strndup:
3813 case Builtin::BIstrndup:
3814 return Builtin::BIstrndup;
3816 case Builtin::BI__builtin_strlen:
3817 case Builtin::BIstrlen:
3818 return Builtin::BIstrlen;
3820 case Builtin::BI__builtin_bzero:
3821 case Builtin::BIbzero:
3822 return Builtin::BIbzero;
3826 if (FnInfo->
isStr(
"memset"))
3827 return Builtin::BImemset;
3828 else if (FnInfo->
isStr(
"memcpy"))
3829 return Builtin::BImemcpy;
3830 else if (FnInfo->
isStr(
"memmove"))
3831 return Builtin::BImemmove;
3832 else if (FnInfo->
isStr(
"memcmp"))
3833 return Builtin::BImemcmp;
3834 else if (FnInfo->
isStr(
"bcmp"))
3835 return Builtin::BIbcmp;
3836 else if (FnInfo->
isStr(
"strncpy"))
3837 return Builtin::BIstrncpy;
3838 else if (FnInfo->
isStr(
"strncmp"))
3839 return Builtin::BIstrncmp;
3840 else if (FnInfo->
isStr(
"strncasecmp"))
3841 return Builtin::BIstrncasecmp;
3842 else if (FnInfo->
isStr(
"strncat"))
3843 return Builtin::BIstrncat;
3844 else if (FnInfo->
isStr(
"strndup"))
3845 return Builtin::BIstrndup;
3846 else if (FnInfo->
isStr(
"strlen"))
3847 return Builtin::BIstrlen;
3848 else if (FnInfo->
isStr(
"bzero"))
3849 return Builtin::BIbzero;
3857 assert(hasODRHash());
3866 setHasODRHash(
true);
3873 setHasODRHash(
true);
3887 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
3888 BW, Mutable, InitStyle);
3901 if (
const auto *Record =
getType()->getAs<RecordType>())
3902 return Record->getDecl()->isAnonymousStructOrUnion();
3908 assert(isBitField() &&
"not a bitfield");
3909 return getBitWidth()->EvaluateKnownConstInt(Ctx).getZExtValue();
3913 return isUnnamedBitfield() && !getBitWidth()->isValueDependent() &&
3914 getBitWidthValue(Ctx) == 0;
3918 if (isZeroLengthBitField(Ctx))
3924 if (!hasAttr<NoUniqueAddressAttr>())
3933 assert(
isInvalidDecl() &&
"valid field has incomplete type");
3939 const auto *CXXRD = cast<CXXRecordDecl>(RD);
3940 if (!CXXRD->isEmpty())
3952 if (Canonical !=
this)
3955 if (CachedFieldIndex)
return CachedFieldIndex - 1;
3959 assert(RD &&
"requested index for field of struct with no definition");
3961 for (
auto *Field : RD->
fields()) {
3962 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
3966 assert(CachedFieldIndex &&
"failed to find field in parent");
3967 return CachedFieldIndex - 1;
3971 const Expr *FinalExpr = getInClassInitializer();
3973 FinalExpr = getBitWidth();
3981 "capturing type in non-lambda or captured record.");
3982 assert(InitStorage.getInt() == ISK_NoInit &&
3983 InitStorage.getPointer() ==
nullptr &&
3984 "bit width, initializer or captured type already set");
3985 InitStorage.setPointerAndInt(const_cast<VariableArrayType *>(VLAType),
3986 ISK_CapturedVLAType);
3999 "EnumDecl not matched with TTK_Enum");
4022 TypedefNameDeclOrQualifier = TDD;
4033 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
4034 struct CXXRecordDecl::DefinitionData *Data =
4035 new (
getASTContext())
struct CXXRecordDecl::DefinitionData(D);
4037 cast<CXXRecordDecl>(I)->DefinitionData = Data;
4042 assert((!isa<CXXRecordDecl>(
this) ||
4044 "definition completed but not started");
4050 L->CompletedTagDefinition(
this);
4055 return const_cast<TagDecl *
>(
this);
4060 if (II->isOutOfDate()) {
4066 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
4067 return CXXRD->getDefinition();
4070 if (R->isCompleteDefinition())
4086 if (getExtInfo()->NumTemplParamLists == 0) {
4098 assert(!TPLists.empty());
4113 bool Scoped,
bool ScopedUsingClassTag,
bool Fixed)
4115 assert(Scoped || !ScopedUsingClassTag);
4116 IntegerType =
nullptr;
4117 setNumPositiveBits(0);
4118 setNumNegativeBits(0);
4120 setScopedUsingClassTag(ScopedUsingClassTag);
4122 setHasODRHash(
false);
4126 void EnumDecl::anchor() {}
4132 bool IsScopedUsingClassTag,
bool IsFixed) {
4133 auto *
Enum =
new (
C, DC)
EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
4134 IsScoped, IsScopedUsingClassTag, IsFixed);
4143 nullptr,
nullptr,
false,
false,
false);
4150 return TI->getTypeLoc().getSourceRange();
4156 unsigned NumPositiveBits,
4157 unsigned NumNegativeBits) {
4161 PromotionType = NewPromotionType;
4162 setNumPositiveBits(NumPositiveBits);
4163 setNumNegativeBits(NumNegativeBits);
4168 if (
const auto *A = getAttr<EnumExtensibilityAttr>())
4169 return A->getExtensibility() == EnumExtensibilityAttr::Closed;
4174 return isClosed() && hasAttr<FlagEnumAttr>();
4178 return isClosed() && !hasAttr<FlagEnumAttr>();
4183 return MSI->getTemplateSpecializationKind();
4191 assert(MSI &&
"Not an instantiated member enumeration?");
4194 PointOfInstantiation.
isValid() &&
4202 EnumDecl *ED = getInstantiatedFromMemberEnum();
4210 "couldn't find pattern for enum instantiation");
4215 if (SpecializationInfo)
4216 return cast<EnumDecl>(SpecializationInfo->getInstantiatedFrom());
4223 assert(!SpecializationInfo &&
"Member enum is already a specialization");
4233 setHasODRHash(
true);
4246 :
TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
4247 assert(
classof(static_cast<Decl *>(
this)) &&
"Invalid Kind!");
4267 StartLoc, IdLoc, Id, PrevDecl);
4288 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
4289 return RD->isLambda();
4294 return hasAttr<CapturedRecordAttr>();
4303 LoadFieldsFromExternalStorage();
4319 return hasAttr<MSStructAttr>() || C.
getLangOpts().MSBitfields == 1;
4322 void RecordDecl::LoadFieldsFromExternalStorage()
const {
4337 for (
unsigned i=0, e=Decls.size();
i != e; ++
i)
4338 assert(isa<FieldDecl>(Decls[
i]) || isa<IndirectFieldDecl>(Decls[
i]));
4351 (SanitizerKind::Address | SanitizerKind::KernelAddress);
4352 if (!EnabledAsanMask || !Context.
getLangOpts().SanitizeAddressFieldPadding)
4357 int ReasonToReject = -1;
4358 if (!CXXRD || CXXRD->isExternCContext())
4360 else if (CXXRD->hasAttr<PackedAttr>())
4362 else if (CXXRD->isUnion())
4364 else if (CXXRD->isTriviallyCopyable())
4366 else if (CXXRD->hasTrivialDestructor())
4368 else if (CXXRD->isStandardLayout())
4370 else if (Blacklist.isBlacklistedLocation(EnabledAsanMask,
getLocation(),
4373 else if (Blacklist.isBlacklistedType(EnabledAsanMask,
4379 if (ReasonToReject >= 0)
4382 diag::remark_sanitize_address_insert_extra_padding_rejected)
4387 diag::remark_sanitize_address_insert_extra_padding_accepted)
4390 return ReasonToReject < 0;
4394 for (
const auto *I :
fields()) {
4395 if (I->getIdentifier())
4398 if (
const auto *RT = I->getType()->getAs<
RecordType>())
4400 RT->getDecl()->findFirstNamedDataMember())
4401 return NamedDataMember;
4423 assert(!ParamInfo &&
"Already has param info!");
4426 if (!NewParamInfo.empty()) {
4427 NumParams = NewParamInfo.size();
4429 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
4434 bool CapturesCXXThis) {
4436 this->NumCaptures = Captures.size();
4438 if (Captures.empty()) {
4439 this->Captures =
nullptr;
4443 this->Captures = Captures.copy(Context).data();
4449 if (I.getVariable() == variable)
4463 void TranslationUnitDecl::anchor() {}
4469 void PragmaCommentDecl::anchor() {}
4477 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
4479 memcpy(PCD->getTrailingObjects<
char>(), Arg.data(), Arg.size());
4480 PCD->getTrailingObjects<
char>()[Arg.size()] =
'\0';
4487 return new (
C,
ID, additionalSizeToAlloc<char>(ArgSize + 1))
4491 void PragmaDetectMismatchDecl::anchor() {}
4497 size_t ValueStart = Name.size() + 1;
4499 new (
C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1))
4501 memcpy(PDMD->getTrailingObjects<
char>(), Name.data(), Name.size());
4502 PDMD->getTrailingObjects<
char>()[Name.size()] =
'\0';
4503 memcpy(PDMD->getTrailingObjects<
char>() + ValueStart, Value.data(),
4505 PDMD->getTrailingObjects<
char>()[ValueStart + Value.size()] =
'\0';
4511 unsigned NameValueSize) {
4512 return new (
C,
ID, additionalSizeToAlloc<char>(NameValueSize + 1))
4516 void ExternCContextDecl::anchor() {}
4523 void LabelDecl::anchor() {}
4527 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
4533 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
4534 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
4543 char *Buffer =
new (
getASTContext(), 1)
char[Name.size() + 1];
4544 memcpy(Buffer, Name.data(), Name.size());
4545 Buffer[Name.size()] =
'\0';
4549 void ValueDecl::anchor() {}
4552 for (
const auto *I :
attrs())
4553 if (isa<WeakAttr>(I) || isa<WeakRefAttr>(I))
4559 void ImplicitParamDecl::anchor() {}
4583 bool hasWrittenPrototype,
4587 SC, isInlineSpecified, ConstexprKind);
4606 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
4608 NumParams(NumParams), ContextParam(0), BodyAndNothrow(
nullptr,
false) {}
4611 unsigned NumParams) {
4612 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4617 unsigned NumParams) {
4618 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4631 Expr *E,
const llvm::APSInt &
V) {
4638 QualType(),
nullptr, llvm::APSInt());
4641 void IndirectFieldDecl::anchor() {}
4647 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),
4648 ChainingSize(CH.size()) {
4671 End = Init->getEndLoc();
4675 void TypeDecl::anchor() {}
4680 return new (
C, DC)
TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4683 void TypedefNameDecl::anchor() {}
4686 if (
auto *TT = getTypeSourceInfo()->getType()->getAs<TagType>()) {
4688 auto *ThisTypedef =
this;
4689 if (AnyRedecl && OwningTypedef) {
4693 if (OwningTypedef == ThisTypedef)
4694 return TT->getDecl();
4700 bool TypedefNameDecl::isTransparentTagSlow()
const {
4701 auto determineIsTransparent = [&]() {
4703 if (
auto *TD = TT->getDecl()) {
4704 if (TD->getName() !=
getName())
4717 bool isTransparent = determineIsTransparent();
4718 MaybeModedTInfo.setInt((isTransparent << 1) | 1);
4719 return isTransparent;
4731 return new (
C, DC)
TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4743 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4751 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4755 void FileScopeAsmDecl::anchor() {}
4770 void EmptyDecl::anchor() {}
4798 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
true) {
4800 auto *StoredLocs = getTrailingObjects<SourceLocation>();
4801 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
4807 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
false) {
4808 *getTrailingObjects<SourceLocation>() = EndLoc;
4815 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
4816 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
4823 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
4830 unsigned NumLocations) {
4831 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
4836 if (!ImportedAndComplete.getInt())
4839 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
4840 return llvm::makeArrayRef(StoredLocs,
4845 if (!ImportedAndComplete.getInt())
4855 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)
bool mightBeUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
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.
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, ConstexprSpecKind ConstexprKind=CSK_unspecified)
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.
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 FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)
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
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. ...
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.
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.
This is the private module fragment within some C++ module.
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?
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
field_range fields() const
static unsigned getNumModuleIdentifiers(Module *Mod)
Retrieve the number of module identifiers needed to name the given module.
static bool isInModulePurview(const NamedDecl *D)
Determine whether D is declared in the purview of a named 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.
__DEVICE__ int max(int __a, int __b)
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.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Represents a linkage specification.
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
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
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.
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, ConstexprSpecKind ConstexprKind)
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...
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)
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.
Represents 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)
static StorageClass getStorageClass(const Decl *D)
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)
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
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.
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++ module.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
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)
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.
ConstexprSpecKind
Define the kind of constexpr specifier.
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.).
static std::string getName(const CallEvent &Call)
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)
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
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...
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Get the template specialization kind of this variable for the purposes of template instantiation...
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.
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
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...
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
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...
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...
void setCanAvoidCopyToHeap(bool B=true)
No linkage according to the standard, but is visible from other translation units because of types de...
void setMSAsmLabel(StringRef Name)
VarDecl * getDefinition()
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
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)
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.
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
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.
bool isZeroSize(const ASTContext &Ctx) const
Determine if this field is a subobject of zero size, that is, either a zero-length bit-field or a fie...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
const LangOptions & getLangOpts() const
static LinkageInfo uniqueExternal()
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
static bool isExportedFromModuleInterfaceUnit(const NamedDecl *D)
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?