53 #include "llvm/ADT/APSInt.h" 54 #include "llvm/ADT/ArrayRef.h" 55 #include "llvm/ADT/None.h" 56 #include "llvm/ADT/Optional.h" 57 #include "llvm/ADT/STLExtras.h" 58 #include "llvm/ADT/SmallVector.h" 59 #include "llvm/ADT/StringRef.h" 60 #include "llvm/ADT/StringSwitch.h" 61 #include "llvm/ADT/Triple.h" 62 #include "llvm/Support/Casting.h" 63 #include "llvm/Support/ErrorHandling.h" 64 #include "llvm/Support/raw_ostream.h" 72 #include <type_traits> 74 using namespace clang;
89 if (
auto *ND = dyn_cast_or_null<NamedDecl>(TheDecl)) {
100 return !getLexicalDeclContext()->Equals(getDeclContext());
103 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
174 "asking for explicit visibility when we shouldn't be");
181 return isa<TypeDecl>(D) ||
182 isa<ClassTemplateDecl>(D) ||
183 isa<ObjCInterfaceDecl>(D);
188 template <
class T>
static typename 189 std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value,
bool>
::type 192 D->getMemberSpecializationInfo()) {
193 return member->isExplicitSpecialization();
209 switch (attr->getVisibility()) {
217 llvm_unreachable(
"bad visibility kind");
226 if (
const auto *A = D->
getAttr<TypeVisibilityAttr>()) {
232 if (
const auto *A = D->
getAttr<VisibilityAttr>()) {
243 return getTypeLinkageAndVisibility(&T);
249 LinkageInfo LinkageComputer::getLVForTemplateParameterList(
255 if (isa<TemplateTypeParmDecl>(
P))
262 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
264 if (!NTTP->isExpandedParameterPack()) {
265 if (!NTTP->getType()->isDependentType()) {
266 LV.
merge(getLVForType(*NTTP->getType(), computation));
272 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
275 LV.
merge(getTypeLinkageAndVisibility(type));
282 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
285 if (!TTP->isExpandedParameterPack()) {
286 LV.
merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),
292 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
294 LV.
merge(getLVForTemplateParameterList(
295 TTP->getExpansionTemplateParameters(i), computation));
305 while (DC->
getDeclKind() != Decl::TranslationUnit) {
306 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
307 Ret = cast<Decl>(DC);
324 switch (Arg.getKind()) {
331 LV.
merge(getLVForType(*Arg.getAsType(), computation));
337 LV.
merge(getLVForDecl(ND, computation));
342 LV.
merge(getTypeLinkageAndVisibility(Arg.getNullPtrType()));
348 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
349 LV.
merge(getLVForDecl(Template, computation));
353 LV.
merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));
356 llvm_unreachable(
"bad template argument kind");
365 return getLVForTemplateArgumentList(TArgs.
asArray(), computation);
377 return !fn->
hasAttr<VisibilityAttr>();
387 void LinkageComputer::mergeTemplateLV(
391 bool considerVisibility =
402 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
455 void LinkageComputer::mergeTemplateLV(
473 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
474 if (considerVisibility)
507 void LinkageComputer::mergeTemplateLV(
LinkageInfo &LV,
525 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);
526 if (considerVisibility)
534 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
543 = FD->getTemplateSpecializationInfo()) {
546 FD->getMemberSpecializationInfo()) {
547 TSK = MSI->getTemplateSpecializationKind();
560 const T *
First = D->getFirstDecl();
561 return First->isInExternCContext();
565 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.
getDeclContext()))
566 if (!SD->hasBraces())
574 return M->isModulePurview();
588 llvm_unreachable(
"unexpected module ownership kind");
615 if (
auto *TD = dyn_cast<TemplateDecl>(D))
616 D = TD->getTemplatedDecl();
618 if (
auto *VD = dyn_cast<VarDecl>(D))
619 return VD->getStorageClass();
620 if (
auto *FD = dyn_cast<FunctionDecl>(D))
621 return FD->getStorageClass();
627 LinkageComputer::getLVForNamespaceScopeDecl(
const NamedDecl *D,
629 bool IgnoreVarTypeLinkage) {
631 "Not a name having namespace scope");
645 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
652 if (Context.getLangOpts().CPlusPlus &&
653 Var->getType().isConstQualified() &&
654 !Var->getType().isVolatileQualified() &&
657 !isa<VarTemplateSpecializationDecl>(Var) &&
658 !Var->getDescribedVarTemplate()) {
661 return getLVForDecl(PrevVar, computation);
663 if (Var->getStorageClass() !=
SC_Extern &&
672 Var->getStorageClass() ==
SC_None)
673 return getDeclLinkageAndVisibility(PrevVar);
675 if (PrevVar->getStorageClass() ==
SC_Static)
678 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
680 const VarDecl *VD = IFD->getVarDecl();
681 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
682 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);
684 assert(!isa<FieldDecl>(D) &&
"Didn't expect a FieldDecl!");
689 const auto *Var = dyn_cast<
VarDecl>(D);
718 !isa<TranslationUnitDecl>(DC);
734 ? Context.getLangOpts().getValueVisibilityMode()
735 : Context.getLangOpts().getTypeVisibilityMode();
761 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
784 !IgnoreVarTypeLinkage) {
785 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
802 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
803 mergeTemplateLV(LV, spec, computation);
807 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
827 QualType TypeAsWritten = Function->getType();
829 TypeAsWritten = TSI->getType();
838 = Function->getTemplateSpecializationInfo()) {
839 mergeTemplateLV(LV, Function, specInfo, computation);
848 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
850 if (!Tag->hasNameForLinkage())
856 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
857 mergeTemplateLV(LV, spec, computation);
862 }
else if (isa<EnumConstantDecl>(D)) {
870 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
873 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
881 }
else if (isa<NamespaceDecl>(D)) {
886 }
else if (isa<ObjCInterfaceDecl>(D)) {
889 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
892 if (!TD->getAnonDeclWithTypedefName(
true))
906 if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice)
913 LinkageComputer::getLVForClassMember(
const NamedDecl *D,
915 bool IgnoreVarTypeLinkage) {
926 if (!(isa<CXXMethodDecl>(D) ||
929 isa<IndirectFieldDecl>(D) ||
931 isa<TemplateDecl>(D)))
957 getLVForDecl(cast<RecordDecl>(D->
getDeclContext()), classComputation);
969 const NamedDecl *explicitSpecSuppressor =
nullptr;
971 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
974 QualType TypeAsWritten = MD->getType();
976 TypeAsWritten = TSI->getType();
983 = MD->getTemplateSpecializationInfo()) {
984 mergeTemplateLV(LV, MD, spec, computation);
986 explicitSpecSuppressor = MD;
988 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
991 explicitSpecSuppressor = MD;
994 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
995 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
996 mergeTemplateLV(LV, spec, computation);
998 explicitSpecSuppressor = spec;
1006 explicitSpecSuppressor = RD;
1010 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
1011 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
1012 mergeTemplateLV(LV, spec, computation);
1016 if (!IgnoreVarTypeLinkage) {
1017 LinkageInfo typeLV = getLVForType(*VD->getType(), computation);
1026 explicitSpecSuppressor = VD;
1030 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
1031 bool considerVisibility =
1036 getLVForTemplateParameterList(temp->getTemplateParameters(), computation);
1039 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
1041 explicitSpecSuppressor = temp->getTemplatedDecl();
1047 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
1051 bool considerClassVisibility =
true;
1052 if (explicitSpecSuppressor &&
1057 considerClassVisibility =
false;
1065 void NamedDecl::anchor() {}
1068 if (!hasCachedLinkage())
1074 return L == getCachedLinkage();
1081 if (name.front() ==
'C')
1082 if (name ==
"CFStringCreateWithFormat" ||
1083 name ==
"CFStringCreateWithFormatAndArguments" ||
1084 name ==
"CFStringAppendFormat" ||
1085 name ==
"CFStringAppendFormatAndArguments")
1105 bool IsMostRecent) {
1114 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1116 if (InstantiatedFrom)
1123 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND)) {
1127 while (TD !=
nullptr) {
1131 TD = TD->getPreviousDecl();
1137 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1139 if (MostRecent != ND)
1143 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1144 if (Var->isStaticDataMember()) {
1146 if (InstantiatedFrom)
1150 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1151 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1157 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1162 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1168 if (InstantiatedFrom)
1175 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1193 else if (isa<ParmVarDecl>(ContextDecl))
1197 Owner = cast<NamedDecl>(ContextDecl);
1206 auto *VD = dyn_cast<
VarDecl>(Owner);
1208 VD && VD->getType()->getContainedDeducedType()
1209 ? computeLVForDecl(Owner, computation,
true)
1210 : getLVForDecl(Owner, computation);
1217 OwnerLV.isVisibilityExplicit());
1222 if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
1223 if (Function->isInAnonymousNamespace() &&
1228 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
1245 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1246 if (Var->hasExternalStorage()) {
1259 LinkageInfo PrevLV = getLVForDecl(Prev, computation);
1268 if (!Var->isStaticLocal())
1281 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1282 if (!BD->getBlockManglingNumber())
1285 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),
1286 BD->getBlockManglingContextDecl(), computation);
1288 const auto *FD = cast<FunctionDecl>(OuterD);
1289 if (!FD->isInlined() &&
1296 LV = getLVForDecl(FD, computation);
1299 assert(cast<VarDecl>(D)->isStaticLocal());
1303 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1304 LV = getLVForDecl(MD->getParent(), computation);
1324 while (Record && Record->
isLambda()) {
1328 Record = dyn_cast_or_null<CXXRecordDecl>(
1336 bool IgnoreVarTypeLinkage) {
1338 if (D->
hasAttr<InternalLinkageAttr>())
1353 case Decl::ImplicitParam:
1355 case Decl::NamespaceAlias:
1358 case Decl::UsingShadow:
1359 case Decl::UsingDirective:
1362 case Decl::EnumConstant:
1365 return getLVForDecl(cast<EnumDecl>(D->
getDeclContext()), computation);
1369 case Decl::TypeAlias:
1372 if (!cast<TypedefNameDecl>(D)
1373 ->getAnonDeclWithTypedefName(
true))
1377 case Decl::TemplateTemplateParm:
1378 case Decl::NonTypeTemplateParm:
1379 case Decl::ObjCAtDefsField:
1380 case Decl::ObjCCategory:
1381 case Decl::ObjCCategoryImpl:
1382 case Decl::ObjCCompatibleAlias:
1383 case Decl::ObjCImplementation:
1384 case Decl::ObjCMethod:
1385 case Decl::ObjCProperty:
1386 case Decl::ObjCPropertyImpl:
1387 case Decl::ObjCProtocol:
1390 case Decl::CXXRecord: {
1391 const auto *Record = cast<CXXRecordDecl>(D);
1392 if (Record->isLambda()) {
1393 if (Record->hasKnownLambdaInternalLinkage() ||
1394 !Record->getLambdaManglingNumber()) {
1415 return getLVForClosure(
1426 return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);
1436 return getLVForClassMember(D, computation, IgnoreVarTypeLinkage);
1450 return getLVForLocalDecl(D, computation);
1461 if (D->
hasAttr<InternalLinkageAttr>())
1470 LinkageInfo LV = computeLVForDecl(D, computation);
1475 cache(D, computation, LV);
1482 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1490 auto *T = cast<NamedDecl>(I);
1493 if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
1505 return getLVForDecl(D,
1512 Module *M = getOwningModule();
1532 if (
auto *ND = dyn_cast<NamedDecl>(
this))
1533 InternalLinkage = !ND->hasExternalFormalLinkage();
1536 InternalLinkage = (NSD && NSD->isAnonymousNamespace()) ||
1537 isInAnonymousNamespace();
1539 return InternalLinkage ? M->
Parent :
nullptr;
1548 llvm_unreachable(
"unknown module kind");
1556 std::string QualName;
1557 llvm::raw_string_ostream OS(QualName);
1558 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1563 printQualifiedName(OS, getASTContext().getPrintingPolicy());
1573 printNestedNameSpecifier(OS, P);
1574 if (getDeclName() || isa<DecompositionDecl>(
this))
1577 OS <<
"(anonymous)";
1581 printNestedNameSpecifier(OS, getASTContext().getPrintingPolicy());
1590 if (
auto *MD = dyn_cast<ObjCMethodDecl>(
this))
1591 if (
auto *
ID = MD->getClassInterface())
1593 if (
auto *PD = dyn_cast<ObjCPropertyDecl>(
this)) {
1594 if (
auto *MD = PD->getGetterMethodDecl())
1595 if (
auto *
ID = MD->getClassInterface())
1603 ContextsTy Contexts;
1607 if (isa<NamedDecl>(Ctx))
1608 Contexts.push_back(Ctx);
1612 for (
const DeclContext *DC : llvm::reverse(Contexts)) {
1613 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1614 OS << Spec->getName();
1617 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1619 (ND->isAnonymousNamespace() || ND->isInline()))
1621 if (ND->isAnonymousNamespace()) {
1623 :
"(anonymous namespace)");
1627 }
else if (
const auto *RD = dyn_cast<RecordDecl>(DC)) {
1628 if (!RD->getIdentifier())
1629 OS <<
"(anonymous " << RD->getKindName() <<
')';
1632 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1634 if (FD->hasWrittenPrototype())
1635 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1640 for (
unsigned i = 0; i < NumParams; ++i) {
1643 OS << FD->getParamDecl(i)->getType().stream(P);
1653 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1666 OS << *cast<NamedDecl>(DC);
1674 bool Qualified)
const {
1676 printQualifiedName(OS, Policy);
1687 #define DECL(Type, Base) \ 1689 return isRedeclarableImpl((Type##Decl *)nullptr); 1690 #define ABSTRACT_DECL(DECL) 1691 #include "clang/AST/DeclNodes.inc" 1693 llvm_unreachable(
"unknown decl kind");
1697 assert(getDeclName() == OldD->
getDeclName() &&
"Declaration name mismatch");
1709 if (isa<ObjCMethodDecl>(
this))
1714 if (isa<ParmVarDecl>(
this))
1720 if (!this->getDeclContext()->getRedeclContext()->Equals(
1726 if (
auto *UD = dyn_cast<UsingDecl>(
this)) {
1730 cast<UsingDecl>(OldD)->getQualifier());
1732 if (
auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this)) {
1736 cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
1749 for (
auto D : redecls()) {
1776 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1778 while (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1779 ND = UD->getTargetDecl();
1781 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1782 return AD->getClassInterface();
1784 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1785 return AD->getNamespace();
1791 if (!isCXXClassMember())
1795 if (isa<UsingShadowDecl>(D))
1796 D = cast<UsingShadowDecl>(D)->getTargetDecl();
1798 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<MSPropertyDecl>(D))
1800 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(D->
getAsFunction()))
1801 return MD->isInstance();
1809 template <
typename DeclT>
1811 if (decl->getNumTemplateParameterLists() > 0)
1812 return decl->getTemplateParameterList(0)->getTemplateLoc();
1814 return decl->getInnerLocStart();
1832 if (!hasExtInfo()) {
1836 DeclInfo =
new (getASTContext()) ExtInfo;
1838 getExtInfo()->TInfo = savedTInfo;
1841 getExtInfo()->QualifierLoc = QualifierLoc;
1842 }
else if (hasExtInfo()) {
1844 getExtInfo()->QualifierLoc = QualifierLoc;
1849 assert(TrailingRequiresClause);
1851 if (!hasExtInfo()) {
1855 DeclInfo =
new (getASTContext()) ExtInfo;
1857 getExtInfo()->TInfo = savedTInfo;
1860 getExtInfo()->TrailingRequiresClause = TrailingRequiresClause;
1865 assert(!TPLists.empty());
1867 if (!hasExtInfo()) {
1871 DeclInfo =
new (getASTContext()) ExtInfo;
1873 getExtInfo()->TInfo = savedTInfo;
1876 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
1892 QT = cast<PointerType>(T)->getPointeeType();
1894 case Type::BlockPointer:
1895 QT = cast<BlockPointerType>(T)->getPointeeType();
1897 case Type::MemberPointer:
1898 QT = cast<MemberPointerType>(T)->getPointeeType();
1900 case Type::LValueReference:
1901 case Type::RValueReference:
1902 QT = cast<ReferenceType>(T)->getPointeeType();
1904 case Type::PackExpansion:
1905 QT = cast<PackExpansionType>(T)->getPattern();
1908 case Type::ConstantArray:
1909 case Type::DependentSizedArray:
1910 case Type::IncompleteArray:
1911 case Type::VariableArray:
1912 case Type::FunctionProto:
1913 case Type::FunctionNoProto:
1925 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
1933 if (NumTemplParamLists > 0) {
1935 TemplParamLists =
nullptr;
1936 NumTemplParamLists = 0;
1939 if (!TPLists.empty()) {
1941 NumTemplParamLists = TPLists.size();
1942 std::copy(TPLists.begin(), TPLists.end(), TemplParamLists);
1960 llvm_unreachable(
"Invalid storage class");
1969 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(
unsigned),
1970 "VarDeclBitfields too large!");
1972 "ParmVarDeclBitfields too large!");
1974 "NonParmVarDeclBitfields too large!");
1984 return new (
C, DC)
VarDecl(Var, C, DC, StartL, IdL, Id, T, TInfo, S);
2001 if (!hasAttr<ThreadAttr>() &&
2004 hasAttr<OMPThreadPrivateDeclAttr>()))
2006 return ((
getASTContext().getLangOpts().isCompatibleWithMSVC(
2008 hasAttr<OMPThreadPrivateDeclAttr>())
2017 llvm_unreachable(
"Unknown thread storage class specifier!");
2031 template<
typename T>
2035 if (!D.hasExternalFormalLinkage())
2059 template<
typename T>
2065 assert(D.getASTContext().getLangOpts().CPlusPlus);
2120 isa<VarTemplatePartialSpecializationDecl>(
this)))
2140 if (
const auto *SAA = getAttr<SelectAnyAttr>())
2141 if (!SAA->isInherited())
2147 if (
auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2149 !isa<VarTemplatePartialSpecializationDecl>(VTSD) &&
2150 !VTSD->IsCompleteDefinition)
2182 VarDecl *LastTentative =
nullptr;
2184 for (
auto I : First->
redecls()) {
2185 Kind = I->isThisDeclarationADefinition();
2191 return LastTentative;
2196 for (
auto I : First->
redecls()) {
2197 if (I->isThisDeclarationADefinition(C) ==
Definition)
2207 for (
auto I : First->
redecls()) {
2208 Kind =
std::max(Kind, I->isThisDeclarationADefinition(C));
2218 if (
auto Expr = I->getInit()) {
2227 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2228 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2231 return !
Init.isNull();
2238 if (
auto *S =
Init.dyn_cast<
Stmt *>())
2239 return cast<Expr>(S);
2248 return Init.getAddrOfPtr1();
2257 if (I->isThisDeclarationADefinition()) {
2278 return VD->isOutOfLine();
2285 Eval->~EvaluatedStmt();
2295 if (!Lang.CPlusPlus)
2299 if (isa<ParmVarDecl>(
this))
2304 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2310 if (!
getType().isConstQualified() ||
getType().isVolatileQualified())
2315 if (
getType()->isIntegralOrEnumerationType())
2327 const VarDecl *DefVD =
nullptr;
2371 const auto *
Init = cast<Expr>(Eval->
Value);
2372 assert(!
Init->isValueDependent());
2377 Eval->
IsICE =
false;
2401 Eval->
IsICE = Result && Notes.empty();
2404 return Result ? &Eval->
Evaluated :
nullptr;
2409 if (Eval->WasEvaluated)
2410 return &Eval->Evaluated;
2417 return Eval->CheckedICE;
2424 "Check whether we already know that the initializer is an ICE");
2439 const auto *
Init = cast<Expr>(Eval->
Value);
2440 assert(!
Init->isValueDependent());
2465 return isa<PackExpansionType>(
getType());
2468 template<
typename DeclT>
2471 if (
auto *Def = D->getDefinition())
2499 if (
auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
2501 auto From = VDTemplSpec->getInstantiatedFrom();
2503 while (!VTD->isMemberSpecialization()) {
2504 auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
2513 while (!VTPSD->isMemberSpecialization()) {
2514 auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
2519 return getDefinitionOrSelf<VarDecl>(VTPSD);
2527 while (!VarTemplate->isMemberSpecialization()) {
2528 auto *NewVT = VarTemplate->getInstantiatedFromMemberTemplate();
2531 VarTemplate = NewVT;
2544 return cast<VarDecl>(MSI->getInstantiatedFrom());
2550 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2551 return Spec->getSpecializationKind();
2554 return MSI->getTemplateSpecializationKind();
2562 return MSI->getTemplateSpecializationKind();
2564 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2565 return Spec->getSpecializationKind();
2571 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2572 return Spec->getPointOfInstantiation();
2575 return MSI->getPointOfInstantiation();
2598 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&
2600 isa<IncompleteArrayType>(
getType()))
2609 !hasAttr<AlwaysDestroyAttr>()));
2615 if (Eval->HasConstantDestruction)
2635 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2637 "not a variable or static data member template specialization");
2640 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2641 Spec->setSpecializationKind(TSK);
2643 PointOfInstantiation.
isValid() &&
2644 Spec->getPointOfInstantiation().isInvalid()) {
2645 Spec->setPointOfInstantiation(PointOfInstantiation);
2647 L->InstantiationRequested(
this);
2650 MSI->setTemplateSpecializationKind(TSK);
2652 MSI->getPointOfInstantiation().isInvalid()) {
2653 MSI->setPointOfInstantiation(PointOfInstantiation);
2655 L->InstantiationRequested(
this);
2663 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2664 "Previous template or instantiation?");
2677 return new (
C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
2684 if (
const auto *DT = dyn_cast<DecayedType>(T))
2685 return DT->getOriginalType();
2696 if (!hasInheritedDefaultArg()) {
2711 assert(!hasUnparsedDefaultArg() &&
"Default argument is not yet parsed!");
2712 assert(!hasUninstantiatedDefaultArg() &&
2713 "Default argument is not yet instantiated!");
2716 if (
auto *E = dyn_cast_or_null<FullExpr>(Arg))
2717 return E->getSubExpr();
2735 return getUninstantiatedDefaultArg()->getSourceRange();
2739 return E->getSourceRange();
2744 llvm_unreachable(
"Invalid default argument kind.");
2753 assert(hasUninstantiatedDefaultArg() &&
2754 "Wrong kind of initialization expression!");
2755 return cast_or_null<Expr>(
Init.get<
Stmt *>());
2762 return hasUnparsedDefaultArg() || hasUninstantiatedDefaultArg() ||
2766 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
2771 unsigned ParmVarDecl::getParameterIndexLarge()
const {
2785 Expr *TrailingRequiresClause)
2815 if (TrailingRequiresClause)
2820 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
2828 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
2829 return FT->isVariadic();
2837 totalSizeToAlloc<DeclAccessPair>(Lookups.size()),
2840 Info->NumLookups = Lookups.size();
2841 std::uninitialized_copy(Lookups.begin(), Lookups.end(),
2848 assert(!
Body &&
"can't replace function body with defaulted function info");
2861 if (I->doesThisDeclarationHaveABody()) {
2878 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
2885 if (I->isThisDeclarationADefinition()) {
2899 "definition should not have a body");
2900 if (Definition->
Body)
2917 Parent->markedVirtualFunctionPure();
2920 template<std::
size_t Len>
2923 return II && II->
isStr(Str);
2951 return llvm::StringSwitch<bool>(
getName())
2963 assert(
getDeclName().getCXXOverloadedOperator() == OO_New ||
2964 getDeclName().getCXXOverloadedOperator() == OO_Delete ||
2965 getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
2966 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
2972 if (proto->getNumParams() != 2 || proto->isVariadic())
2981 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
2987 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
2988 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
2989 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
2990 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
3001 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 3 || FPT->isVariadic())
3006 if (FPT->getNumParams() == 1)
3009 unsigned Params = 1;
3010 QualType Ty = FPT->getParamType(Params);
3013 auto Consume = [&] {
3015 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) :
QualType();
3019 bool IsSizedDelete =
false;
3024 IsSizedDelete =
true;
3046 return Params == FPT->getNumParams();
3068 RD->getIdentifier()->isStr(
"destroying_delete_t");
3080 if (hasAttr<OpenCLKernelAttr>())
3090 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
3091 return Method->isStatic();
3099 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
3100 if (!Namespace->getDeclName())
3110 if (hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
3111 hasAttr<C11NoReturnAttr>())
3114 if (
auto *FnTy =
getType()->getAs<FunctionType>())
3115 return FnTy->getNoReturnAttr();
3122 if (hasAttr<TargetAttr>())
3124 if (hasAttr<CPUDispatchAttr>())
3126 if (hasAttr<CPUSpecificAttr>())
3150 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
3151 FunTmpl->setPreviousDecl(PrevFunTmpl);
3176 if (
const auto *AMAA = getAttr<ArmMveAliasAttr>()) {
3177 BuiltinID = AMAA->getBuiltinName()->getBuiltinID();
3190 const auto *LinkageDecl =
3197 if (BuiltinID == Builtin::BI__GetExceptionInfo &&
3199 return Builtin::BI__GetExceptionInfo;
3208 if (!ConsiderWrapperFunctions && hasAttr<OverloadableAttr>() &&
3209 !hasAttr<ArmMveAliasAttr>())
3231 if (Context.
getLangOpts().CUDA && hasAttr<CUDADeviceAttr>() &&
3232 !hasAttr<CUDAHostAttr>() &&
3233 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))
3249 assert(!ParamInfo &&
"Already has param info!");
3250 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
3253 if (!NewParamInfo.empty()) {
3255 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3267 unsigned NumRequiredArgs = 0;
3269 if (!Param->isParameterPack() && !Param->hasDefaultArg())
3271 return NumRequiredArgs;
3280 assert(
isInlined() &&
"expected to get called on an inlined function!");
3284 !hasAttr<DLLExportAttr>())
3289 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3301 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
3331 "Must have a declaration without a body.");
3345 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3355 bool FoundBody =
false;
3380 bool FoundBody =
false;
3451 hasAttr<AliasAttr>()) &&
3452 "Must be a function definition");
3453 assert(
isInlined() &&
"Function must be inline");
3456 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
3470 for (
auto Redecl :
redecls()) {
3471 if (Redecl->isInlineSpecified() &&
3481 "should not use C inline rules in C++");
3487 for (
auto Redecl :
redecls()) {
3518 if (TemplateOrSpecialization.isNull())
3526 if (TemplateOrSpecialization.is
3530 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
3535 return cast<FunctionDecl>(Info->getInstantiatedFrom());
3544 if (
auto *FTSI = TemplateOrSpecialization
3545 .dyn_cast<FunctionTemplateSpecializationInfo *>())
3546 return FTSI->getMemberSpecializationInfo();
3551 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
3554 assert(TemplateOrSpecialization.isNull() &&
3555 "Member function is already a specialization");
3558 TemplateOrSpecialization = Info;
3566 assert(TemplateOrSpecialization.isNull() &&
3567 "Member function is already a specialization");
3568 TemplateOrSpecialization = Template;
3592 bool HasPattern =
false;
3594 HasPattern = PatternDecl->
hasBody(PatternDecl);
3600 if (!HasPattern || !PatternDecl)
3623 dyn_cast<CXXMethodDecl>(
this))) {
3640 while (!Primary->isMemberSpecialization()) {
3641 auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();
3644 Primary = NewPrimary;
3655 = TemplateOrSpecialization
3656 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3657 return Info->getTemplate();
3664 return TemplateOrSpecialization
3671 = TemplateOrSpecialization
3672 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3673 return Info->TemplateArguments;
3681 = TemplateOrSpecialization
3682 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3683 return Info->TemplateArgumentsAsWritten;
3689 FunctionDecl::setFunctionTemplateSpecialization(
ASTContext &C,
3696 assert((TemplateOrSpecialization.isNull() ||
3698 "Member function is already a specialization");
3700 "Must specify the type of function template specialization");
3701 assert((TemplateOrSpecialization.isNull() ||
3703 "Member specialization must be an explicit specialization");
3706 C,
this, Template, TSK, TemplateArgs, TemplateArgsAsWritten,
3707 PointOfInstantiation,
3709 TemplateOrSpecialization = Info;
3717 assert(TemplateOrSpecialization.isNull());
3721 TemplateOrSpecialization = Info;
3726 return TemplateOrSpecialization
3735 totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
3740 DependentFunctionTemplateSpecializationInfo::
3744 NumTemplates = Ts.
size();
3745 NumArgs = TArgs.
size();
3748 for (
unsigned I = 0, E = Ts.
size(); I != E; ++I)
3752 for (
unsigned I = 0, E = TArgs.
size(); I != E; ++I)
3760 TemplateOrSpecialization
3761 .dyn_cast<FunctionTemplateSpecializationInfo *>())
3762 return FTSInfo->getTemplateSpecializationKind();
3766 return MSInfo->getTemplateSpecializationKind();
3791 TemplateOrSpecialization
3792 .dyn_cast<FunctionTemplateSpecializationInfo *>()) {
3793 if (
auto *MSInfo = FTSInfo->getMemberSpecializationInfo())
3794 return MSInfo->getTemplateSpecializationKind();
3795 return FTSInfo->getTemplateSpecializationKind();
3800 return MSInfo->getTemplateSpecializationKind();
3809 = TemplateOrSpecialization.dyn_cast<
3811 FTSInfo->setTemplateSpecializationKind(TSK);
3813 PointOfInstantiation.
isValid() &&
3814 FTSInfo->getPointOfInstantiation().isInvalid()) {
3815 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
3817 L->InstantiationRequested(
this);
3821 MSInfo->setTemplateSpecializationKind(TSK);
3823 PointOfInstantiation.
isValid() &&
3824 MSInfo->getPointOfInstantiation().isInvalid()) {
3825 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3827 L->InstantiationRequested(
this);
3830 llvm_unreachable(
"Function cannot have a template specialization kind");
3835 = TemplateOrSpecialization.dyn_cast<
3837 return FTSInfo->getPointOfInstantiation();
3840 return MSInfo->getPointOfInstantiation();
3861 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
3880 case Builtin::BI__builtin_memset:
3881 case Builtin::BI__builtin___memset_chk:
3882 case Builtin::BImemset:
3883 return Builtin::BImemset;
3885 case Builtin::BI__builtin_memcpy:
3886 case Builtin::BI__builtin___memcpy_chk:
3887 case Builtin::BImemcpy:
3888 return Builtin::BImemcpy;
3890 case Builtin::BI__builtin_mempcpy:
3891 case Builtin::BI__builtin___mempcpy_chk:
3892 case Builtin::BImempcpy:
3893 return Builtin::BImempcpy;
3895 case Builtin::BI__builtin_memmove:
3896 case Builtin::BI__builtin___memmove_chk:
3897 case Builtin::BImemmove:
3898 return Builtin::BImemmove;
3900 case Builtin::BIstrlcpy:
3901 case Builtin::BI__builtin___strlcpy_chk:
3902 return Builtin::BIstrlcpy;
3904 case Builtin::BIstrlcat:
3905 case Builtin::BI__builtin___strlcat_chk:
3906 return Builtin::BIstrlcat;
3908 case Builtin::BI__builtin_memcmp:
3909 case Builtin::BImemcmp:
3910 return Builtin::BImemcmp;
3912 case Builtin::BI__builtin_bcmp:
3913 case Builtin::BIbcmp:
3914 return Builtin::BIbcmp;
3916 case Builtin::BI__builtin_strncpy:
3917 case Builtin::BI__builtin___strncpy_chk:
3918 case Builtin::BIstrncpy:
3919 return Builtin::BIstrncpy;
3921 case Builtin::BI__builtin_strncmp:
3922 case Builtin::BIstrncmp:
3923 return Builtin::BIstrncmp;
3925 case Builtin::BI__builtin_strncasecmp:
3926 case Builtin::BIstrncasecmp:
3927 return Builtin::BIstrncasecmp;
3929 case Builtin::BI__builtin_strncat:
3930 case Builtin::BI__builtin___strncat_chk:
3931 case Builtin::BIstrncat:
3932 return Builtin::BIstrncat;
3934 case Builtin::BI__builtin_strndup:
3935 case Builtin::BIstrndup:
3936 return Builtin::BIstrndup;
3938 case Builtin::BI__builtin_strlen:
3939 case Builtin::BIstrlen:
3940 return Builtin::BIstrlen;
3942 case Builtin::BI__builtin_bzero:
3943 case Builtin::BIbzero:
3944 return Builtin::BIbzero;
3948 if (FnInfo->
isStr(
"memset"))
3949 return Builtin::BImemset;
3950 else if (FnInfo->
isStr(
"memcpy"))
3951 return Builtin::BImemcpy;
3952 else if (FnInfo->
isStr(
"mempcpy"))
3953 return Builtin::BImempcpy;
3954 else if (FnInfo->
isStr(
"memmove"))
3955 return Builtin::BImemmove;
3956 else if (FnInfo->
isStr(
"memcmp"))
3957 return Builtin::BImemcmp;
3958 else if (FnInfo->
isStr(
"bcmp"))
3959 return Builtin::BIbcmp;
3960 else if (FnInfo->
isStr(
"strncpy"))
3961 return Builtin::BIstrncpy;
3962 else if (FnInfo->
isStr(
"strncmp"))
3963 return Builtin::BIstrncmp;
3964 else if (FnInfo->
isStr(
"strncasecmp"))
3965 return Builtin::BIstrncasecmp;
3966 else if (FnInfo->
isStr(
"strncat"))
3967 return Builtin::BIstrncat;
3968 else if (FnInfo->
isStr(
"strndup"))
3969 return Builtin::BIstrndup;
3970 else if (FnInfo->
isStr(
"strlen"))
3971 return Builtin::BIstrlen;
3972 else if (FnInfo->
isStr(
"bzero"))
3973 return Builtin::BIbzero;
3981 assert(hasODRHash());
3990 setHasODRHash(
true);
3997 setHasODRHash(
true);
4011 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
4012 BW, Mutable, InitStyle);
4025 if (
const auto *Record =
getType()->getAs<RecordType>())
4026 return Record->getDecl()->isAnonymousStructOrUnion();
4032 assert(isBitField() &&
"not a bitfield");
4033 return getBitWidth()->EvaluateKnownConstInt(Ctx).getZExtValue();
4037 return isUnnamedBitfield() && !getBitWidth()->isValueDependent() &&
4038 getBitWidthValue(Ctx) == 0;
4042 if (isZeroLengthBitField(Ctx))
4048 if (!hasAttr<NoUniqueAddressAttr>())
4057 assert(
isInvalidDecl() &&
"valid field has incomplete type");
4063 const auto *CXXRD = cast<CXXRecordDecl>(RD);
4064 if (!CXXRD->isEmpty())
4076 if (Canonical !=
this)
4079 if (CachedFieldIndex)
return CachedFieldIndex - 1;
4083 assert(RD &&
"requested index for field of struct with no definition");
4085 for (
auto *Field : RD->
fields()) {
4086 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
4090 assert(CachedFieldIndex &&
"failed to find field in parent");
4091 return CachedFieldIndex - 1;
4095 const Expr *FinalExpr = getInClassInitializer();
4097 FinalExpr = getBitWidth();
4105 "capturing type in non-lambda or captured record.");
4106 assert(InitStorage.getInt() == ISK_NoInit &&
4107 InitStorage.getPointer() ==
nullptr &&
4108 "bit width, initializer or captured type already set");
4109 InitStorage.setPointerAndInt(const_cast<VariableArrayType *>(VLAType),
4110 ISK_CapturedVLAType);
4123 "EnumDecl not matched with TTK_Enum");
4146 TypedefNameDeclOrQualifier = TDD;
4157 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
4158 struct CXXRecordDecl::DefinitionData *Data =
4159 new (
getASTContext())
struct CXXRecordDecl::DefinitionData(D);
4161 cast<CXXRecordDecl>(I)->DefinitionData = Data;
4166 assert((!isa<CXXRecordDecl>(
this) ||
4168 "definition completed but not started");
4174 L->CompletedTagDefinition(
this);
4179 return const_cast<TagDecl *
>(
this);
4184 if (II->isOutOfDate()) {
4190 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
4191 return CXXRD->getDefinition();
4194 if (R->isCompleteDefinition())
4210 if (getExtInfo()->NumTemplParamLists == 0) {
4222 assert(!TPLists.empty());
4237 bool Scoped,
bool ScopedUsingClassTag,
bool Fixed)
4239 assert(Scoped || !ScopedUsingClassTag);
4240 IntegerType =
nullptr;
4241 setNumPositiveBits(0);
4242 setNumNegativeBits(0);
4244 setScopedUsingClassTag(ScopedUsingClassTag);
4246 setHasODRHash(
false);
4250 void EnumDecl::anchor() {}
4256 bool IsScopedUsingClassTag,
bool IsFixed) {
4257 auto *
Enum =
new (
C, DC)
EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
4258 IsScoped, IsScopedUsingClassTag, IsFixed);
4267 nullptr,
nullptr,
false,
false,
false);
4274 return TI->getTypeLoc().getSourceRange();
4280 unsigned NumPositiveBits,
4281 unsigned NumNegativeBits) {
4285 PromotionType = NewPromotionType;
4286 setNumPositiveBits(NumPositiveBits);
4287 setNumNegativeBits(NumNegativeBits);
4292 if (
const auto *A = getAttr<EnumExtensibilityAttr>())
4293 return A->getExtensibility() == EnumExtensibilityAttr::Closed;
4298 return isClosed() && hasAttr<FlagEnumAttr>();
4302 return isClosed() && !hasAttr<FlagEnumAttr>();
4307 return MSI->getTemplateSpecializationKind();
4315 assert(MSI &&
"Not an instantiated member enumeration?");
4318 PointOfInstantiation.
isValid() &&
4326 EnumDecl *ED = getInstantiatedFromMemberEnum();
4334 "couldn't find pattern for enum instantiation");
4339 if (SpecializationInfo)
4340 return cast<EnumDecl>(SpecializationInfo->getInstantiatedFrom());
4347 assert(!SpecializationInfo &&
"Member enum is already a specialization");
4357 setHasODRHash(
true);
4370 :
TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
4371 assert(
classof(static_cast<Decl *>(
this)) &&
"Invalid Kind!");
4391 StartLoc, IdLoc, Id, PrevDecl);
4412 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
4413 return RD->isLambda();
4418 return hasAttr<CapturedRecordAttr>();
4427 LoadFieldsFromExternalStorage();
4443 return hasAttr<MSStructAttr>() || C.
getLangOpts().MSBitfields == 1;
4446 void RecordDecl::LoadFieldsFromExternalStorage()
const {
4461 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
4462 assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
4475 (SanitizerKind::Address | SanitizerKind::KernelAddress);
4476 if (!EnabledAsanMask || !Context.
getLangOpts().SanitizeAddressFieldPadding)
4481 int ReasonToReject = -1;
4482 if (!CXXRD || CXXRD->isExternCContext())
4484 else if (CXXRD->hasAttr<PackedAttr>())
4486 else if (CXXRD->isUnion())
4488 else if (CXXRD->isTriviallyCopyable())
4490 else if (CXXRD->hasTrivialDestructor())
4492 else if (CXXRD->isStandardLayout())
4494 else if (Blacklist.isBlacklistedLocation(EnabledAsanMask,
getLocation(),
4497 else if (Blacklist.isBlacklistedType(EnabledAsanMask,
4503 if (ReasonToReject >= 0)
4506 diag::remark_sanitize_address_insert_extra_padding_rejected)
4511 diag::remark_sanitize_address_insert_extra_padding_accepted)
4514 return ReasonToReject < 0;
4518 for (
const auto *I :
fields()) {
4519 if (I->getIdentifier())
4522 if (
const auto *RT = I->getType()->getAs<
RecordType>())
4524 RT->getDecl()->findFirstNamedDataMember())
4525 return NamedDataMember;
4547 assert(!ParamInfo &&
"Already has param info!");
4550 if (!NewParamInfo.empty()) {
4551 NumParams = NewParamInfo.size();
4553 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
4558 bool CapturesCXXThis) {
4560 this->NumCaptures = Captures.size();
4562 if (Captures.empty()) {
4563 this->Captures =
nullptr;
4567 this->Captures = Captures.copy(Context).data();
4573 if (I.getVariable() == variable)
4587 void TranslationUnitDecl::anchor() {}
4593 void PragmaCommentDecl::anchor() {}
4601 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
4603 memcpy(PCD->getTrailingObjects<
char>(), Arg.data(), Arg.size());
4604 PCD->getTrailingObjects<
char>()[Arg.size()] =
'\0';
4611 return new (
C,
ID, additionalSizeToAlloc<char>(ArgSize + 1))
4615 void PragmaDetectMismatchDecl::anchor() {}
4621 size_t ValueStart = Name.size() + 1;
4623 new (
C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1))
4625 memcpy(PDMD->getTrailingObjects<
char>(), Name.data(), Name.size());
4626 PDMD->getTrailingObjects<
char>()[Name.size()] =
'\0';
4627 memcpy(PDMD->getTrailingObjects<
char>() + ValueStart, Value.data(),
4629 PDMD->getTrailingObjects<
char>()[ValueStart + Value.size()] =
'\0';
4635 unsigned NameValueSize) {
4636 return new (
C,
ID, additionalSizeToAlloc<char>(NameValueSize + 1))
4640 void ExternCContextDecl::anchor() {}
4647 void LabelDecl::anchor() {}
4651 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
4657 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
4658 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
4667 char *Buffer =
new (
getASTContext(), 1)
char[Name.size() + 1];
4668 memcpy(Buffer, Name.data(), Name.size());
4669 Buffer[Name.size()] =
'\0';
4673 void ValueDecl::anchor() {}
4676 for (
const auto *I :
attrs())
4677 if (isa<WeakAttr>(I) || isa<WeakRefAttr>(I))
4683 void ImplicitParamDecl::anchor() {}
4707 bool hasWrittenPrototype,
4709 Expr *TrailingRequiresClause) {
4712 SC, isInlineSpecified, ConstexprKind,
4713 TrailingRequiresClause);
4732 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
4734 NumParams(NumParams), ContextParam(0), BodyAndNothrow(
nullptr,
false) {}
4737 unsigned NumParams) {
4738 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4743 unsigned NumParams) {
4744 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4767 void IndirectFieldDecl::anchor() {}
4773 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),
4774 ChainingSize(CH.size()) {
4797 End = Init->getEndLoc();
4801 void TypeDecl::anchor() {}
4806 return new (
C, DC)
TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4809 void TypedefNameDecl::anchor() {}
4812 if (
auto *TT = getTypeSourceInfo()->getType()->getAs<TagType>()) {
4814 auto *ThisTypedef =
this;
4815 if (AnyRedecl && OwningTypedef) {
4819 if (OwningTypedef == ThisTypedef)
4820 return TT->getDecl();
4826 bool TypedefNameDecl::isTransparentTagSlow()
const {
4827 auto determineIsTransparent = [&]() {
4829 if (
auto *TD = TT->getDecl()) {
4830 if (TD->getName() !=
getName())
4843 bool isTransparent = determineIsTransparent();
4844 MaybeModedTInfo.setInt((isTransparent << 1) | 1);
4845 return isTransparent;
4857 return new (
C, DC)
TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4869 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4877 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4881 void FileScopeAsmDecl::anchor() {}
4896 void EmptyDecl::anchor() {}
4924 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
true) {
4926 auto *StoredLocs = getTrailingObjects<SourceLocation>();
4927 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
4933 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
false) {
4934 *getTrailingObjects<SourceLocation>() = EndLoc;
4941 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
4942 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
4949 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
4956 unsigned NumLocations) {
4957 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
4962 if (!ImportedAndComplete.getInt())
4965 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
4966 return llvm::makeArrayRef(StoredLocs,
4971 if (!ImportedAndComplete.getInt())
4981 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.
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.
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
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, Expr *TrailingRequiresClause=nullptr)
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...
void setTrailingRequiresClause(Expr *TrailingRequiresClause)
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)
SourceLocation getEndLoc() const
Get the end source location.
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++.
bool isInlineBuiltinDeclaration() const
Determine if this function provides an inline implementation of a builtin.
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
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
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.
LazyDeclStmtPtr Body
The body of the function.
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
bool hasKnownLambdaInternalLinkage() const
The lambda is known to has internal linkage no matter whether it has name mangling number...
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.
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
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...
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
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.
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
bool isExplicitSpecialization() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec...
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
bool isExternalFormalLinkage(Linkage L)
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
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
DefaultedFunctionInfo * DefaultedInfo
Information about a future defaulted function definition.
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.
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
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...
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
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.
Defines the clang::Module class, which describes a module in the source code.
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...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
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.
SourceLocation getEllipsisLoc() const
Returns the location of the ellipsis of a variadic function.
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.
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.
A POD class for pairing a NamedDecl* with an access specifier.
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.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
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)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
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 printNestedNameSpecifier(raw_ostream &OS) const
Print only the nested name specifier part of a fully-qualified name, including the '::' at the end...
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 getTypeSpecEndLoc() const
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.
LazyOffsetPtr< Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt > LazyDeclStmtPtr
A lazy pointer to a statement.
Stashed information about a defaulted function definition whose body has not yet been lazily generate...
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.
FunctionTypeLoc getFunctionTypeLoc() const
Find the source location information for how the type of this function was written.
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 getBegin() const
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
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...