34 #include "llvm/Support/ErrorHandling.h"
37 using namespace clang;
40 return D->getASTContext().getPrimaryMergedDecl(D);
44 bool Decl::isOutOfLine()
const {
45 return !getLexicalDeclContext()->Equals(getDeclContext());
48 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
50 DeclContext(TranslationUnit), Ctx(ctx), AnonymousNamespace(nullptr) {
51 Hidden = Ctx.getLangOpts().ModulesLocalVisibility;
159 "asking for explicit visibility when we shouldn't be");
166 return isa<TypeDecl>(D) ||
167 isa<ClassTemplateDecl>(D) ||
168 isa<ObjCInterfaceDecl>(D);
173 template <
class T>
static typename
174 std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value,
bool>
::type
177 D->getMemberSpecializationInfo()) {
178 return member->isExplicitSpecialization();
194 switch (attr->getVisibility()) {
202 llvm_unreachable(
"bad visibility kind");
210 if (kind == NamedDecl::VisibilityForType) {
211 if (
const auto *A = D->getAttr<TypeVisibilityAttr>()) {
217 if (
const auto *A = D->getAttr<VisibilityAttr>()) {
223 if (D->getASTContext().getTargetInfo().getTriple().isOSDarwin()) {
224 for (
const auto *A : D->specific_attrs<AvailabilityAttr>())
225 if (A->getPlatform()->getName().equals(
"macos"))
249 if (isa<TemplateTypeParmDecl>(
P))
256 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
258 if (!NTTP->isExpandedParameterPack()) {
259 if (!NTTP->getType()->isDependentType()) {
266 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
276 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
279 if (!TTP->isExpandedParameterPack()) {
286 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
289 TTP->getExpansionTemplateParameters(i), computation));
301 const Decl *Ret =
nullptr;
303 while (DC->
getDeclKind() != Decl::TranslationUnit) {
304 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
305 Ret = cast<Decl>(DC);
321 switch (Arg.getKind()) {
322 case TemplateArgument::Null:
323 case TemplateArgument::Integral:
324 case TemplateArgument::Expression:
327 case TemplateArgument::Type:
331 case TemplateArgument::Declaration:
332 if (
const auto *ND = dyn_cast<NamedDecl>(Arg.getAsDecl())) {
338 case TemplateArgument::NullPtr:
339 LV.
merge(Arg.getNullPtrType()->getLinkageAndVisibility());
342 case TemplateArgument::Template:
343 case TemplateArgument::TemplateExpansion:
345 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
349 case TemplateArgument::Pack:
353 llvm_unreachable(
"bad template argument kind");
374 return !fn->hasAttr<VisibilityAttr>();
388 bool considerVisibility =
407 switch (computation) {
410 if (D->hasAttr<TypeVisibilityAttr>())
415 if (D->hasAttr<VisibilityAttr>())
421 llvm_unreachable(
"bad visibility computation kind");
481 if (considerVisibility)
533 if (considerVisibility)
540 const LangOptions &Opts = D->getASTContext().getLangOpts();
541 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
550 = FD->getTemplateSpecializationInfo()) {
551 TSK = spec->getTemplateSpecializationKind();
553 FD->getMemberSpecializationInfo()) {
554 TSK = MSI->getTemplateSpecializationKind();
563 FD->hasBody(Def) && Def->
isInlined() && !Def->hasAttr<GNUInlineAttr>();
567 const T *First = D->getFirstDecl();
568 return First->isInExternCContext();
572 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.getDeclContext()))
573 if (!SD->hasBraces())
580 assert(D->getDeclContext()->getRedeclContext()->isFileContext() &&
581 "Not a name having namespace scope");
590 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
593 return LinkageInfo::internal();
599 if (Context.getLangOpts().CPlusPlus &&
600 Var->getType().isConstQualified() &&
601 !Var->getType().isVolatileQualified() &&
607 if (Var->getStorageClass() !=
SC_Extern &&
610 return LinkageInfo::internal();
616 Var->getStorageClass() ==
SC_None)
617 return PrevVar->getLinkageAndVisibility();
619 if (PrevVar->getStorageClass() ==
SC_Static)
620 return LinkageInfo::internal();
622 }
else if (
const FunctionDecl *Function = D->getAsFunction()) {
628 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
630 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
632 const VarDecl *VD = IFD->getVarDecl();
633 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
636 assert(!isa<FieldDecl>(D) &&
"Didn't expect a FieldDecl!");
638 if (D->isInAnonymousNamespace()) {
639 const auto *Var = dyn_cast<
VarDecl>(D);
645 return LinkageInfo::uniqueExternal();
663 !isa<TranslationUnitDecl>(DC);
664 DC = DC->getParent()) {
679 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
682 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
699 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
724 return LinkageInfo::uniqueExternal();
739 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
744 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
761 if (Context.getLangOpts().CPlusPlus &&
762 !Function->isInExternCContext()) {
770 QualType TypeAsWritten = Function->getType();
772 TypeAsWritten = TSI->getType();
774 return LinkageInfo::uniqueExternal();
781 = Function->getTemplateSpecializationInfo()) {
791 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
793 if (!Tag->hasNameForLinkage())
794 return LinkageInfo::none();
799 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
804 }
else if (isa<EnumConstantDecl>(D)) {
808 return LinkageInfo::none();
813 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
821 }
else if (isa<NamespaceDecl>(D) && !D->isInAnonymousNamespace()) {
826 }
else if (isa<ObjCInterfaceDecl>(D)) {
829 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
832 if (!TD->getAnonDeclWithTypedefName(
true))
833 return LinkageInfo::none();
837 return LinkageInfo::none();
860 if (!(isa<CXXMethodDecl>(D) ||
863 isa<IndirectFieldDecl>(D) ||
865 isa<TemplateDecl>(D)))
866 return LinkageInfo::none();
891 getLVForDecl(cast<RecordDecl>(D->getDeclContext()), classComputation);
894 return LinkageInfo::uniqueExternal();
897 return LinkageInfo::none();
904 const NamedDecl *explicitSpecSuppressor =
nullptr;
906 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
917 QualType TypeAsWritten = MD->getType();
919 TypeAsWritten = TSI->getType();
921 return LinkageInfo::uniqueExternal();
926 = MD->getTemplateSpecializationInfo()) {
928 if (spec->isExplicitSpecialization()) {
929 explicitSpecSuppressor = MD;
931 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
934 explicitSpecSuppressor = MD;
937 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
938 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
940 if (spec->isExplicitSpecialization()) {
941 explicitSpecSuppressor = spec;
949 explicitSpecSuppressor = RD;
953 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
954 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
965 explicitSpecSuppressor = VD;
969 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
970 bool considerVisibility =
978 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
980 explicitSpecSuppressor = temp->getTemplatedDecl();
986 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
990 bool considerClassVisibility =
true;
991 if (explicitSpecSuppressor &&
996 considerClassVisibility =
false;
1004 void NamedDecl::anchor() { }
1010 if (!hasCachedLinkage())
1021 if (name.front() ==
'C')
1022 if (name ==
"CFStringCreateWithFormat" ||
1023 name ==
"CFStringCreateWithFormatAndArguments" ||
1024 name ==
"CFStringAppendFormat" ||
1025 name ==
"CFStringAppendFormatAndArguments")
1045 bool IsMostRecent) {
1054 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1056 if (InstantiatedFrom)
1063 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND))
1064 return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
1068 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1070 if (MostRecent != ND)
1074 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1075 if (Var->isStaticDataMember()) {
1077 if (InstantiatedFrom)
1081 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1082 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1088 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1092 = fn->getTemplateSpecializationInfo())
1093 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1099 if (InstantiatedFrom)
1106 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1112 Optional<Visibility>
1121 if (isa<ParmVarDecl>(ContextDecl))
1122 DC = ContextDecl->getDeclContext()->getRedeclContext();
1124 return getLVForDecl(cast<NamedDecl>(ContextDecl), computation);
1127 if (
const auto *ND = dyn_cast<NamedDecl>(DC))
1135 if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
1136 if (Function->isInAnonymousNamespace() &&
1137 !Function->isInExternCContext())
1141 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
1146 if (Optional<Visibility> Vis =
1158 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1159 if (Var->hasExternalStorage()) {
1160 if (Var->isInAnonymousNamespace() && !Var->isInExternCContext())
1181 if (!Var->isStaticLocal())
1190 if (!OuterD || OuterD->isInvalidDecl())
1194 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1195 if (!BD->getBlockManglingNumber())
1199 BD->getBlockManglingContextDecl(), computation);
1201 const auto *FD = cast<FunctionDecl>(OuterD);
1202 if (!FD->isInlined() &&
1217 while (Record && Record->
isLambda()) {
1221 Record = dyn_cast_or_null<CXXRecordDecl>(
1230 if (D->hasAttr<InternalLinkageAttr>())
1235 switch (D->getKind()) {
1245 case Decl::ImplicitParam:
1247 case Decl::NamespaceAlias:
1250 case Decl::UsingShadow:
1251 case Decl::UsingDirective:
1254 case Decl::EnumConstant:
1256 return getLVForDecl(cast<EnumDecl>(D->getDeclContext()), computation);
1262 if (!D->getASTContext().getLangOpts().CPlusPlus ||
1263 !cast<TypedefNameDecl>(D)
1264 ->getAnonDeclWithTypedefName(
true))
1268 case Decl::TemplateTemplateParm:
1269 case Decl::NonTypeTemplateParm:
1270 case Decl::ObjCAtDefsField:
1271 case Decl::ObjCCategory:
1272 case Decl::ObjCCategoryImpl:
1273 case Decl::ObjCCompatibleAlias:
1274 case Decl::ObjCImplementation:
1275 case Decl::ObjCMethod:
1276 case Decl::ObjCProperty:
1277 case Decl::ObjCPropertyImpl:
1278 case Decl::ObjCProtocol:
1281 case Decl::CXXRecord: {
1282 const auto *Record = cast<CXXRecordDecl>(D);
1283 if (Record->isLambda()) {
1284 if (!Record->getLambdaManglingNumber()) {
1314 if (D->getDeclContext()->getRedeclContext()->isFileContext())
1324 if (D->getDeclContext()->isRecord())
1338 if (D->getDeclContext()->isFunctionOrMethod())
1352 if (D->hasAttr<InternalLinkageAttr>())
1359 if (D->hasCachedLinkage())
1360 assert(D->getCachedLinkage() == LV.
getLinkage());
1368 const LangOptions &Opts = D->getASTContext().getLangOpts();
1369 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1376 for (
auto I : D->redecls()) {
1377 auto *T = cast<NamedDecl>(
I);
1380 if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
1385 assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
1399 std::string QualName;
1400 llvm::raw_string_ostream OS(QualName);
1422 while (Ctx && isa<NamedDecl>(Ctx)) {
1423 Contexts.push_back(Ctx);
1428 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1429 OS << Spec->getName();
1433 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(DC)) {
1435 (ND->isAnonymousNamespace() || ND->isInline()))
1437 if (ND->isAnonymousNamespace()) {
1439 :
"(anonymous namespace)");
1443 }
else if (
const auto *RD = dyn_cast<RecordDecl>(DC)) {
1444 if (!RD->getIdentifier())
1445 OS <<
"(anonymous " << RD->getKindName() <<
')';
1448 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(DC)) {
1450 if (FD->hasWrittenPrototype())
1451 FT = dyn_cast<FunctionProtoType>(FD->getType()->castAs<
FunctionType>());
1456 for (
unsigned i = 0; i < NumParams; ++i) {
1459 OS << FD->getParamDecl(i)->getType().stream(P);
1469 }
else if (
const auto *ED = dyn_cast<EnumDecl>(DC)) {
1474 if (ED->isScoped() || ED->getIdentifier())
1479 OS << *cast<NamedDecl>(DC);
1487 OS <<
"(anonymous)";
1492 bool Qualified)
const {
1505 #define DECL(Type, Base) \
1507 return isRedeclarableImpl((Type##Decl *)nullptr);
1508 #define ABSTRACT_DECL(DECL)
1509 #include "clang/AST/DeclNodes.inc"
1511 llvm_unreachable(
"unknown decl kind");
1519 if (OldD->isFromASTFile() && isFromASTFile())
1523 if (OldD->getKind() !=
getKind())
1527 if (isa<ObjCMethodDecl>(
this))
1532 if (isa<ParmVarDecl>(
this))
1538 if (!this->getDeclContext()->getRedeclContext()->Equals(
1539 OldD->getDeclContext()->getRedeclContext()))
1544 if (
auto *UD = dyn_cast<UsingDecl>(
this)) {
1548 cast<UsingDecl>(OldD)->getQualifier());
1550 if (
auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(
this)) {
1554 cast<UnresolvedUsingValueDecl>(OldD)->getQualifier());
1560 if (
auto *UD = dyn_cast<UsingDirectiveDecl>(
this))
1561 return UD->getNominatedNamespace()->getOriginalNamespace() ==
1562 cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace()
1563 ->getOriginalNamespace();
1575 for (
auto D : redecls()) {
1583 if (D->isCanonicalDecl())
1602 NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
1604 while (
auto *UD = dyn_cast<UsingShadowDecl>(ND))
1605 ND = UD->getTargetDecl();
1607 if (
auto *AD = dyn_cast<ObjCCompatibleAliasDecl>(ND))
1608 return AD->getClassInterface();
1610 if (
auto *AD = dyn_cast<NamespaceAliasDecl>(ND))
1611 return AD->getNamespace();
1621 if (isa<UsingShadowDecl>(D))
1622 D = cast<UsingShadowDecl>(D)->getTargetDecl();
1624 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<MSPropertyDecl>(D))
1626 if (
const auto *MD = dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()))
1627 return MD->isInstance();
1635 template <
typename DeclT>
1637 if (decl->getNumTemplateParameterLists() > 0)
1638 return decl->getTemplateParameterList(0)->getTemplateLoc();
1640 return decl->getInnerLocStart();
1652 if (!hasExtInfo()) {
1656 DeclInfo =
new (getASTContext())
ExtInfo;
1658 getExtInfo()->TInfo = savedTInfo;
1661 getExtInfo()->QualifierLoc = QualifierLoc;
1665 if (getExtInfo()->NumTemplParamLists == 0) {
1669 getASTContext().Deallocate(getExtInfo());
1671 DeclInfo = savedTInfo;
1674 getExtInfo()->QualifierLoc = QualifierLoc;
1681 assert(!TPLists.empty());
1683 if (!hasExtInfo()) {
1687 DeclInfo =
new (getASTContext())
ExtInfo;
1689 getExtInfo()->TInfo = savedTInfo;
1692 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);
1710 QT = cast<PointerType>(T)->getPointeeType();
1712 case Type::BlockPointer:
1713 QT = cast<BlockPointerType>(T)->getPointeeType();
1715 case Type::MemberPointer:
1716 QT = cast<MemberPointerType>(T)->getPointeeType();
1718 case Type::LValueReference:
1719 case Type::RValueReference:
1720 QT = cast<ReferenceType>(T)->getPointeeType();
1722 case Type::PackExpansion:
1723 QT = cast<PackExpansionType>(T)->getPattern();
1726 case Type::ConstantArray:
1727 case Type::DependentSizedArray:
1728 case Type::IncompleteArray:
1729 case Type::VariableArray:
1730 case Type::FunctionProto:
1731 case Type::FunctionNoProto:
1744 if (!
getDeclName() || typeIsPostfix(TInfo->getType()))
1745 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
1759 if (!TPLists.empty()) {
1780 llvm_unreachable(
"Invalid storage class");
1789 static_assert(
sizeof(VarDeclBitfields) <=
sizeof(
unsigned),
1790 "VarDeclBitfields too large!");
1792 "ParmVarDeclBitfields too large!");
1794 "NonParmVarDeclBitfields too large!");
1804 return new (C, DC)
VarDecl(Var, C, DC, StartL, IdL, Id, T, TInfo, S);
1821 if (!hasAttr<ThreadAttr>() &&
1822 !(getASTContext().getLangOpts().OpenMPUseTLS &&
1823 getASTContext().getTargetInfo().isTLSSupported() &&
1824 hasAttr<OMPThreadPrivateDeclAttr>()))
1826 return ((getASTContext().getLangOpts().isCompatibleWithMSVC(
1828 hasAttr<OMPThreadPrivateDeclAttr>())
1837 llvm_unreachable(
"Unknown thread storage class specifier!");
1845 if (InitEnd.
isValid() && InitEnd != getLocation())
1851 template<
typename T>
1855 if (!D.hasExternalFormalLinkage())
1879 template<
typename T>
1885 assert(D.getASTContext().getLangOpts().CPlusPlus);
1901 return getLexicalDeclContext()->isExternCContext();
1905 return getLexicalDeclContext()->isExternCXXContext();
1937 isa<VarTemplatePartialSpecializationDecl>(
this)))
1954 if (hasDefiningAttr())
1957 if (
const auto *SAA = getAttr<SelectAnyAttr>())
1958 if (!SAA->isInherited())
1964 if (isa<VarTemplateSpecializationDecl>(
this) &&
1996 VarDecl *LastTentative =
nullptr;
1999 Kind =
I->isThisDeclarationADefinition();
2005 return LastTentative;
2011 if (
I->isThisDeclarationADefinition(C) ==
Definition)
2022 Kind =
std::max(Kind,
I->isThisDeclarationADefinition(C));
2032 if (
auto Expr =
I->getInit()) {
2041 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2042 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2045 return !
Init.isNull();
2053 return cast<Expr>(
S);
2062 return Init.getAddrOfPtr1();
2066 if (Decl::isOutOfLine())
2076 return VD->isOutOfLine();
2083 Eval->~EvaluatedStmt();
2084 getASTContext().Deallocate(Eval);
2093 if (!Lang.CPlusPlus)
2098 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2104 if (!
getType().isConstQualified() ||
getType().isVolatileQualified())
2109 if (
getType()->isIntegralOrEnumerationType())
2141 void DestroyAPValue(
void* UntypedValue) {
2156 const auto *
Init = cast<Expr>(Eval->
Value);
2157 assert(!
Init->isValueDependent());
2162 Eval->
IsICE =
false;
2177 getASTContext().AddDeallocation(DestroyAPValue, &Eval->
Evaluated);
2186 Eval->
IsICE = Result && Notes.empty();
2189 return Result ? &Eval->
Evaluated :
nullptr;
2194 if (Eval->WasEvaluated)
2195 return &Eval->Evaluated;
2202 return Eval->CheckedICE;
2209 "Check whether we already know that the initializer is an ICE");
2224 const auto *
Init = cast<Expr>(Eval->
Value);
2225 assert(!
Init->isValueDependent());
2229 if (getASTContext().getLangOpts().CPlusPlus11) {
2243 Eval->
IsICE =
Init->isIntegerConstantExpr(getASTContext());
2251 return cast<VarDecl>(MSI->getInstantiatedFrom());
2257 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2258 return Spec->getSpecializationKind();
2261 return MSI->getTemplateSpecializationKind();
2267 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2268 return Spec->getPointOfInstantiation();
2271 return MSI->getPointOfInstantiation();
2277 return getASTContext().getTemplateOrSpecializationInfo(
this)
2282 getASTContext().setTemplateOrSpecializationInfo(
this, Template);
2289 return getASTContext().getTemplateOrSpecializationInfo(
this)
2296 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2298 "not a variable or static data member template specialization");
2301 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2302 Spec->setSpecializationKind(TSK);
2304 Spec->getPointOfInstantiation().isInvalid())
2305 Spec->setPointOfInstantiation(PointOfInstantiation);
2309 MSI->setTemplateSpecializationKind(TSK);
2311 MSI->getPointOfInstantiation().isInvalid())
2312 MSI->setPointOfInstantiation(PointOfInstantiation);
2319 assert(getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2320 "Previous template or instantiation?");
2321 getASTContext().setInstantiatedFromStaticDataMember(
this, VD, TSK);
2333 return new (C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
2340 if (
const auto *DT = dyn_cast<DecayedType>(T))
2341 return DT->getOriginalType();
2360 if (isa<ObjCMethodDecl>(getDeclContext()))
2369 "Default argument is not yet instantiated!");
2372 if (
auto *
E = dyn_cast_or_null<ExprWithCleanups>(Arg))
2373 return E->getSubExpr();
2395 return E->getSourceRange();
2400 llvm_unreachable(
"Invalid default argument kind.");
2410 "Wrong kind of initialization expression!");
2411 return cast_or_null<Expr>(
Init.get<
Stmt *>());
2423 return isa<PackExpansionType>(
getType());
2426 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
2427 getASTContext().setParameterIndex(
this, parameterIndex);
2431 unsigned ParmVarDecl::getParameterIndexLarge()
const {
2432 return getASTContext().getParameterIndex(
this);
2440 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
2445 OS, TemplateArgs->
asArray(), Policy);
2449 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
2450 return FT->isVariadic();
2456 if (
I->Body ||
I->IsLateTemplateParsed) {
2474 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
2481 if (
I->IsDeleted ||
I->IsDefaulted ||
I->Body ||
I->IsLateTemplateParsed ||
2482 I->hasDefiningAttr()) {
2483 Definition =
I->IsDeleted ?
I->getCanonicalDecl() :
I;
2495 if (Definition->Body)
2496 return Definition->Body.
get(getASTContext().getExternalSource());
2504 EndRangeLoc = B->getLocEnd();
2510 if (
auto *Parent = dyn_cast<CXXRecordDecl>(getDeclContext()))
2511 Parent->markedVirtualFunctionPure();
2514 template<std::
size_t Len>
2517 return II && II->
isStr(Str);
2545 return llvm::StringSwitch<bool>(
getName())
2557 assert(
getDeclName().getCXXOverloadedOperator() == OO_New ||
2558 getDeclName().getCXXOverloadedOperator() == OO_Delete ||
2559 getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
2560 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
2566 if (proto->getNumParams() != 2 || proto->isVariadic())
2570 cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext())
2575 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
2581 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
2582 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
2583 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
2584 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
2587 if (isa<CXXRecordDecl>(getDeclContext()))
2595 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 2 || FPT->isVariadic())
2600 if (FPT->getNumParams() == 1)
2605 QualType Ty = FPT->getParamType(1);
2616 return RD &&
isNamed(RD,
"nothrow_t") && RD->isInStdNamespace();
2628 return getLexicalDeclContext()->isExternCContext();
2632 return getLexicalDeclContext()->isExternCXXContext();
2636 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
2637 return Method->isStatic();
2644 DC = DC->getParent()) {
2645 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
2646 if (!Namespace->getDeclName())
2656 return hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
2657 hasAttr<C11NoReturnAttr>() ||
2668 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
2669 FunTmpl->setPreviousDecl(PrevFunTmpl);
2672 if (PrevDecl && PrevDecl->IsInline)
2697 const auto *LinkageDecl =
2704 if (BuiltinID == Builtin::BI__GetExceptionInfo &&
2706 return Builtin::BI__GetExceptionInfo;
2715 if (hasAttr<OverloadableAttr>())
2749 assert(!ParamInfo &&
"Already has param info!");
2750 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
2753 if (!NewParamInfo.empty()) {
2754 ParamInfo =
new (C)
ParmVarDecl*[NewParamInfo.size()];
2755 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
2760 assert(DeclsInPrototypeScope.empty() &&
"Already has prototype decls!");
2762 if (!NewDecls.empty()) {
2764 std::copy(NewDecls.begin(), NewDecls.end(), A);
2765 DeclsInPrototypeScope = llvm::makeArrayRef(A, NewDecls.size());
2767 for (
auto I : NewDecls) {
2774 I->setDeclContext(
this);
2786 if (!getASTContext().getLangOpts().
CPlusPlus)
2789 unsigned NumRequiredArgs = 0;
2791 if (!Param->isParameterPack() && !Param->hasDefaultArg())
2793 return NumRequiredArgs;
2802 assert(
isInlined() &&
"expected to get called on an inlined function!");
2806 !hasAttr<DLLExportAttr>())
2811 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
2823 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
2836 if (Redecl->isImplicit())
2853 "Must have a declaration without a body.");
2864 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
2874 bool FoundBody =
false;
2876 FoundBody |= Prev->Body.
isValid();
2902 bool FoundBody =
false;
2904 FoundBody |= Prev->Body.
isValid();
2936 if (Ret && !(MD && MD->getCorrespondingMethodInClass(Ret,
true))) {
2937 if (
const auto *R = Ret->getAttr<WarnUnusedResultAttr>())
2941 if (
const EnumDecl *ED = ET->getDecl()) {
2942 if (
const auto *R = ED->getAttr<WarnUnusedResultAttr>())
2946 return getAttr<WarnUnusedResultAttr>();
2968 assert(
isInlined() &&
"Function must be inline");
2971 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
2983 for (
auto Redecl :
redecls()) {
2984 if (Redecl->isInlineSpecified() &&
2994 "should not use C inline rules in C++");
3000 for (
auto Redecl :
redecls()) {
3031 if (TemplateOrSpecialization.isNull())
3039 if (TemplateOrSpecialization.is
3043 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
3048 return cast<FunctionDecl>(Info->getInstantiatedFrom());
3058 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
3061 assert(TemplateOrSpecialization.isNull() &&
3062 "Member function is already a specialization");
3065 TemplateOrSpecialization = Info;
3073 TemplateOrSpecialization = Template;
3078 if (isInvalidDecl())
3101 bool HasPattern =
false;
3103 HasPattern = PatternDecl->
hasBody(PatternDecl);
3109 if (!HasPattern || !PatternDecl)
3125 llvm_unreachable(
"All TSK values handled.");
3143 dyn_cast<CXXMethodDecl>(
this))) {
3145 "generated from a primary call operator "
3148 "A generic lambda call operator template must always have a body - "
3149 "even if instantiated from a prototype (i.e. as written) member "
3155 while (Primary->getInstantiatedFromMemberTemplate()) {
3158 if (Primary->isMemberSpecialization())
3160 Primary = Primary->getInstantiatedFromMemberTemplate();
3163 return Primary->getTemplatedDecl();
3171 = TemplateOrSpecialization
3172 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3173 return Info->Template.getPointer();
3184 return TemplateOrSpecialization
3191 = TemplateOrSpecialization
3192 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3193 return Info->TemplateArguments;
3201 = TemplateOrSpecialization
3202 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3203 return Info->TemplateArgumentsAsWritten;
3209 FunctionDecl::setFunctionTemplateSpecialization(
ASTContext &C,
3217 "Must specify the type of function template specialization");
3223 TemplateArgsAsWritten,
3224 PointOfInstantiation);
3225 TemplateOrSpecialization = Info;
3233 assert(TemplateOrSpecialization.isNull());
3237 TemplateOrSpecialization = Info;
3242 return TemplateOrSpecialization
3251 totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
3256 DependentFunctionTemplateSpecializationInfo::
3259 : AngleLocs(TArgs.getLAngleLoc(), TArgs.getRAngleLoc()) {
3261 NumTemplates = Ts.
size();
3262 NumArgs = TArgs.
size();
3265 for (
unsigned I = 0,
E = Ts.
size();
I !=
E; ++
I)
3266 TsArray[
I] = cast<FunctionTemplateDecl>(Ts[
I]->getUnderlyingDecl());
3269 for (
unsigned I = 0,
E = TArgs.
size();
I !=
E; ++
I)
3293 = TemplateOrSpecialization.dyn_cast<
3295 FTSInfo->setTemplateSpecializationKind(TSK);
3297 PointOfInstantiation.
isValid() &&
3298 FTSInfo->getPointOfInstantiation().isInvalid())
3299 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
3302 MSInfo->setTemplateSpecializationKind(TSK);
3304 PointOfInstantiation.
isValid() &&
3305 MSInfo->getPointOfInstantiation().isInvalid())
3306 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3308 llvm_unreachable(
"Function cannot have a template specialization kind");
3313 = TemplateOrSpecialization.dyn_cast<
3315 return FTSInfo->getPointOfInstantiation();
3318 return MSInfo->getPointOfInstantiation();
3324 if (Decl::isOutOfLine())
3339 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
3358 case Builtin::BI__builtin_memset:
3359 case Builtin::BI__builtin___memset_chk:
3360 case Builtin::BImemset:
3361 return Builtin::BImemset;
3363 case Builtin::BI__builtin_memcpy:
3364 case Builtin::BI__builtin___memcpy_chk:
3365 case Builtin::BImemcpy:
3366 return Builtin::BImemcpy;
3368 case Builtin::BI__builtin_memmove:
3369 case Builtin::BI__builtin___memmove_chk:
3370 case Builtin::BImemmove:
3371 return Builtin::BImemmove;
3373 case Builtin::BIstrlcpy:
3374 case Builtin::BI__builtin___strlcpy_chk:
3375 return Builtin::BIstrlcpy;
3377 case Builtin::BIstrlcat:
3378 case Builtin::BI__builtin___strlcat_chk:
3379 return Builtin::BIstrlcat;
3381 case Builtin::BI__builtin_memcmp:
3382 case Builtin::BImemcmp:
3383 return Builtin::BImemcmp;
3385 case Builtin::BI__builtin_strncpy:
3386 case Builtin::BI__builtin___strncpy_chk:
3387 case Builtin::BIstrncpy:
3388 return Builtin::BIstrncpy;
3390 case Builtin::BI__builtin_strncmp:
3391 case Builtin::BIstrncmp:
3392 return Builtin::BIstrncmp;
3394 case Builtin::BI__builtin_strncasecmp:
3395 case Builtin::BIstrncasecmp:
3396 return Builtin::BIstrncasecmp;
3398 case Builtin::BI__builtin_strncat:
3399 case Builtin::BI__builtin___strncat_chk:
3400 case Builtin::BIstrncat:
3401 return Builtin::BIstrncat;
3403 case Builtin::BI__builtin_strndup:
3404 case Builtin::BIstrndup:
3405 return Builtin::BIstrndup;
3407 case Builtin::BI__builtin_strlen:
3408 case Builtin::BIstrlen:
3409 return Builtin::BIstrlen;
3413 if (FnInfo->
isStr(
"memset"))
3414 return Builtin::BImemset;
3415 else if (FnInfo->
isStr(
"memcpy"))
3416 return Builtin::BImemcpy;
3417 else if (FnInfo->
isStr(
"memmove"))
3418 return Builtin::BImemmove;
3419 else if (FnInfo->
isStr(
"memcmp"))
3420 return Builtin::BImemcmp;
3421 else if (FnInfo->
isStr(
"strncpy"))
3422 return Builtin::BIstrncpy;
3423 else if (FnInfo->
isStr(
"strncmp"))
3424 return Builtin::BIstrncmp;
3425 else if (FnInfo->
isStr(
"strncasecmp"))
3426 return Builtin::BIstrncasecmp;
3427 else if (FnInfo->
isStr(
"strncat"))
3428 return Builtin::BIstrncat;
3429 else if (FnInfo->
isStr(
"strndup"))
3430 return Builtin::BIstrndup;
3431 else if (FnInfo->
isStr(
"strlen"))
3432 return Builtin::BIstrlen;
3448 return new (C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
3449 BW, Mutable, InitStyle);
3462 if (
const auto *Record =
getType()->getAs<RecordType>())
3463 return Record->getDecl()->isAnonymousStructOrUnion();
3470 auto *BitWidth =
static_cast<Expr *
>(InitStorage.getPointer());
3476 if (Canonical !=
this)
3479 if (CachedFieldIndex)
return CachedFieldIndex - 1;
3484 for (
auto *Field : RD->
fields()) {
3485 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
3489 assert(CachedFieldIndex &&
"failed to find field in parent");
3490 return CachedFieldIndex - 1;
3494 switch (InitStorage.getInt()) {
3496 case ISK_BitWidthOrNothing:
3497 case ISK_InClassCopyInit:
3498 case ISK_InClassListInit:
3499 if (
const auto *
E = static_cast<const Expr *>(InitStorage.getPointer()))
3503 case ISK_CapturedVLAType:
3506 llvm_unreachable(
"bad init storage kind");
3511 "capturing type in non-lambda or captured record.");
3512 assert(InitStorage.getInt() == ISK_BitWidthOrNothing &&
3513 InitStorage.getPointer() ==
nullptr &&
3514 "bit width, initializer or captured type already set");
3515 InitStorage.setPointerAndInt(const_cast<VariableArrayType *>(VLAType),
3516 ISK_CapturedVLAType);
3536 TypedefNameDeclOrQualifier = TDD;
3539 assert(T->isLinkageValid());
3547 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
3548 struct CXXRecordDecl::DefinitionData *Data =
3549 new (getASTContext())
struct CXXRecordDecl::DefinitionData(D);
3551 cast<CXXRecordDecl>(
I)->DefinitionData = Data;
3556 assert((!isa<CXXRecordDecl>(
this) ||
3558 "definition completed but not started");
3560 IsCompleteDefinition =
true;
3564 L->CompletedTagDefinition(
this);
3569 return const_cast<TagDecl *
>(
this);
3574 if (II->isOutOfDate()) {
3575 updateOutOfDate(*II);
3580 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
3581 return CXXRD->getDefinition();
3584 if (R->isCompleteDefinition())
3594 TypedefNameDeclOrQualifier =
new (getASTContext())
ExtInfo;
3612 assert(!TPLists.empty());
3616 TypedefNameDeclOrQualifier =
new (getASTContext())
ExtInfo;
3625 void EnumDecl::anchor() { }
3631 bool IsScopedUsingClassTag,
bool IsFixed) {
3632 auto *Enum =
new (
C, DC)
EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
3633 IsScoped, IsScopedUsingClassTag, IsFixed);
3634 Enum->MayHaveOutOfDateDef = C.
getLangOpts().Modules;
3642 nullptr,
nullptr,
false,
false,
false);
3649 return TI->getTypeLoc().getSourceRange();
3655 unsigned NumPositiveBits,
3656 unsigned NumNegativeBits) {
3660 PromotionType = NewPromotionType;
3668 return MSI->getTemplateSpecializationKind();
3676 assert(MSI &&
"Not an instantiated member enumeration?");
3679 PointOfInstantiation.
isValid() &&
3695 "couldn't find pattern for enum instantiation");
3700 if (SpecializationInfo)
3708 assert(!SpecializationInfo &&
"Member enum is already a specialization");
3720 :
TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
3721 HasFlexibleArrayMember =
false;
3722 AnonymousStructOrUnion =
false;
3723 HasObjectMember =
false;
3724 HasVolatileMember =
false;
3725 LoadedFieldsFromExternalStorage =
false;
3726 assert(
classof(static_cast<Decl*>(
this)) &&
"Invalid Kind!");
3733 StartLoc, IdLoc, Id, PrevDecl);
3749 return isImplicit() &&
getDeclName() && getDeclContext()->isRecord() &&
3754 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
3755 return RD->isLambda();
3760 return hasAttr<CapturedRecordAttr>();
3764 addAttr(CapturedRecordAttr::CreateImplicit(getASTContext()));
3769 LoadFieldsFromExternalStorage();
3785 return hasAttr<MSStructAttr>() || C.
getLangOpts().MSBitfields == 1;
3788 void RecordDecl::LoadFieldsFromExternalStorage()
const {
3796 LoadedFieldsFromExternalStorage =
true;
3803 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
3804 assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
3817 SanitizerKind::Address | SanitizerKind::KernelAddress) ||
3818 !Context.
getLangOpts().SanitizeAddressFieldPadding)
3823 int ReasonToReject = -1;
3824 if (!CXXRD || CXXRD->isExternCContext())
3826 else if (CXXRD->hasAttr<PackedAttr>())
3828 else if (CXXRD->isUnion())
3830 else if (CXXRD->isTriviallyCopyable())
3832 else if (CXXRD->hasTrivialDestructor())
3834 else if (CXXRD->isStandardLayout())
3836 else if (Blacklist.isBlacklistedLocation(getLocation(),
"field-padding"))
3843 if (ReasonToReject >= 0)
3846 diag::remark_sanitize_address_insert_extra_padding_rejected)
3851 diag::remark_sanitize_address_insert_extra_padding_accepted)
3854 return ReasonToReject < 0;
3858 for (
const auto *
I :
fields()) {
3859 if (
I->getIdentifier())
3862 if (
const auto *RT =
I->getType()->getAs<
RecordType>())
3864 RT->getDecl()->findFirstNamedDataMember())
3865 return NamedDataMember;
3878 assert(!ParamInfo &&
"Already has param info!");
3881 if (!NewParamInfo.empty()) {
3882 NumParams = NewParamInfo.size();
3883 ParamInfo =
new (getASTContext())
ParmVarDecl*[NewParamInfo.size()];
3884 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3889 bool CapturesCXXThis) {
3890 this->CapturesCXXThis = CapturesCXXThis;
3891 this->NumCaptures = Captures.size();
3893 if (Captures.empty()) {
3894 this->Captures =
nullptr;
3898 this->Captures = Captures.copy(Context).data();
3904 if (
I.getVariable() == variable)
3911 return SourceRange(getLocation(), Body? Body->getLocEnd() : getLocation());
3918 void TranslationUnitDecl::anchor() { }
3924 void PragmaCommentDecl::anchor() { }
3932 new (
C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
3934 memcpy(PCD->getTrailingObjects<
char>(), Arg.data(), Arg.size());
3935 PCD->getTrailingObjects<
char>()[Arg.size()] =
'\0';
3942 return new (
C,
ID, additionalSizeToAlloc<char>(ArgSize + 1))
3946 void PragmaDetectMismatchDecl::anchor() { }
3952 size_t ValueStart = Name.size() + 1;
3954 new (
C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1))
3956 memcpy(PDMD->getTrailingObjects<
char>(), Name.data(), Name.size());
3957 PDMD->getTrailingObjects<
char>()[Name.size()] =
'\0';
3958 memcpy(PDMD->getTrailingObjects<
char>() + ValueStart, Value.data(),
3960 PDMD->getTrailingObjects<
char>()[ValueStart + Value.size()] =
'\0';
3966 unsigned NameValueSize) {
3967 return new (
C,
ID, additionalSizeToAlloc<char>(NameValueSize + 1))
3971 void ExternCContextDecl::anchor() { }
3978 void LabelDecl::anchor() { }
3982 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
3988 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
3989 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
3998 char *
Buffer =
new (getASTContext(), 1)
char[Name.size() + 1];
3999 memcpy(Buffer, Name.data(), Name.size());
4000 Buffer[Name.size()] =
'\0';
4004 void ValueDecl::anchor() { }
4007 for (
const auto *
I : attrs())
4008 if (isa<WeakAttr>(
I) || isa<WeakRefAttr>(
I))
4011 return isWeakImported();
4014 void ImplicitParamDecl::anchor() { }
4034 bool isInlineSpecified,
4035 bool hasWrittenPrototype,
4036 bool isConstexprSpecified) {
4038 new (
C, DC)
FunctionDecl(Function, C, DC, StartLoc, NameInfo, T, TInfo,
4039 SC, isInlineSpecified, isConstexprSpecified);
4058 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
4060 NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr,
false) {}
4063 unsigned NumParams) {
4064 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4069 unsigned NumParams) {
4070 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4083 Expr *
E,
const llvm::APSInt &V) {
4090 QualType(),
nullptr, llvm::APSInt());
4093 void IndirectFieldDecl::anchor() { }
4099 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),
4100 ChainingSize(CH.size()) {
4104 IdentifierNamespace |= IDNS_Tag;
4123 End = Init->getLocEnd();
4127 void TypeDecl::anchor() { }
4132 return new (
C, DC)
TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4135 void TypedefNameDecl::anchor() { }
4140 auto *ThisTypedef =
this;
4141 if (AnyRedecl && OwningTypedef) {
4145 if (OwningTypedef == ThisTypedef)
4146 return TT->getDecl();
4161 return new (
C, DC)
TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4172 if (typeIsPostfix(TInfo->getType()))
4173 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4181 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4185 void FileScopeAsmDecl::anchor() { }
4200 void EmptyDecl::anchor() {}
4228 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
true),
4232 auto *StoredLocs = getTrailingObjects<SourceLocation>();
4233 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
4239 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
false),
4242 *getTrailingObjects<SourceLocation>() = EndLoc;
4249 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
4250 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
4257 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
4259 Import->setImplicit();
4264 unsigned NumLocations) {
4265 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
4270 if (!ImportedAndComplete.getInt())
4273 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
4274 return llvm::makeArrayRef(StoredLocs,
4279 if (!ImportedAndComplete.getInt())
4280 return SourceRange(getLocation(), *getTrailingObjects<SourceLocation>());
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 setLinkage(Linkage L)
bool isCapturedRecord() const
Determine whether this record is a record for captured variables in CapturedStmt construct.
Defines the clang::ASTContext interface.
SourceRange getSourceRange() const override LLVM_READONLY
static LinkageInfo computeLVForDecl(const NamedDecl *D, LVComputationKind computation)
SourceLocation getEnd() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static const Decl * getCanonicalDecl(const Decl *D)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
void setDeclsInPrototypeScope(ArrayRef< NamedDecl * > NewDecls)
External linkage, which indicates that the entity can be referred to from other translation units...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
static ImportDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
A (possibly-)qualified type.
ArrayRef< Capture > captures() const
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
bool isReplaceableGlobalAllocationFunction() const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool isBitField() const
Determines whether this field is a bitfield.
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
static VarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
SourceRange getSourceRange() const override LLVM_READONLY
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void setPreviousDecl(FunctionDecl *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
SanitizerSet Sanitize
Set of enabled sanitizers.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
No linkage, which means that the entity is unique and can only be referred to from within its scope...
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
bool IsEvaluating
Whether this statement is being evaluated.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
bool isRecordType() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
Defines the clang::Module class, which describes a module in the source code.
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
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.
SourceRange getSourceRange() const override LLVM_READONLY
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Defines the C++ template declaration subclasses.
void setPure(bool P=true)
void setPreviousDeclaration(FunctionDecl *PrevDecl)
static Visibility getVisibilityFromAttr(const T *attr)
Given a visibility attribute, return the explicit visibility associated with it.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
The base class of the type hierarchy.
Represents an empty-declaration.
bool doesDeclarationForceExternallyVisibleDefinition() const
For a function declaration in C or C++, determine whether this declaration causes the definition to b...
bool hasLinkage() const
Determine whether this declaration has linkage.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
bool capturesVariable(const VarDecl *var) const
std::unique_ptr< llvm::MemoryBuffer > Buffer
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Declaration of a variable template.
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
static std::enable_if<!std::is_base_of< RedeclarableTemplateDecl, T >::value, bool >::type isExplicitMemberSpecialization(const T *D)
Does the given declaration have member specialization information, and if so, is it an explicit speci...
virtual void completeDefinition()
completeDefinition - Notes that the definition of this type is now complete.
A container of type source information.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
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
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
static CapturedDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumParams)
void setNothrow(bool Nothrow=true)
This file provides some common utility functions for processing Lambda related AST Constructs...
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
ExplicitVisibilityKind
Kinds of explicit visibility.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
const unsigned IgnoreAllVisibilityBit
bool isFileVarDecl() const
isFileVarDecl - Returns true for file scoped variable declaration.
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)
void mergeVisibility(Visibility newVis, bool newExplicit)
Merge in the visibility 'newVis'.
TLSKind getTLSKind() const
Declaration context for names declared as extern "C" in C++.
field_iterator field_begin() const
Represents a variable template specialization, which refers to a variable template with a given set o...
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.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Stores a list of template parameters for a TemplateDecl and its derived classes.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Describes how types, statements, expressions, and declarations should be printed. ...
ParmVarDecl - 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.
void removeDecl(Decl *D)
Removes a declaration from this context.
Provides information about a dependent function-template specialization declaration.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
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.
static LinkageInfo getLVForClosure(const DeclContext *DC, Decl *ContextDecl, LVComputationKind computation)
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
Visibility getVisibility() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
bool hasUninstantiatedDefaultArg() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
Provides common interface for the Decls that can be redeclared.
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
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
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
struct ExtInfo & getExtInfo()
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
void setUninstantiatedDefaultArg(Expr *arg)
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
static LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
static bool redeclForcesDefMSVC(const FunctionDecl *Redecl)
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static LinkageInfo internal()
static bool usesTypeVisibility(const NamedDecl *D)
Is the given declaration a "type" or a "value" for the purposes of visibility computation?
bool isReferenceType() const
QualType getReturnType() const
static unsigned getNumModuleIdentifiers(Module *Mod)
Retrieve the number of module identifiers needed to name the given module.
static const Decl * getOutermostFuncOrBlockContext(const Decl *D)
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
void completeDefinition()
Completes the definition of this tag declaration.
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.
void Deallocate(void *Ptr) const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void startDefinition()
Starts the definition of this tag declaration.
bool isTranslationUnit() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
LVComputationKind
Kinds of LV computation.
This declaration is definitely a definition.
static LinkageInfo getLVForClassMember(const NamedDecl *D, LVComputationKind computation)
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
void setNumPositiveBits(unsigned Num)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Linkage getLinkage() const
Describes a module or submodule.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream...
bool isLinkageValid() const
True if the computed linkage is valid.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
SourceLocation getBeginLoc() const
Get the begin source location.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
Stmt * getBody() const override
TemplateParameterList ** TemplParamLists
TemplParamLists - A new-allocated array of size NumTemplParamLists, containing pointers to the "outer...
unsigned getLambdaManglingNumber() const
If this is the closure type of a lambda expression, retrieve the number to be used for name mangling ...
const TargetInfo & getTargetInfo() const
QualType getOriginalType() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class...
const LangOptions & getLangOpts() const
static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)
A convenient class for passing around template argument information.
LinkageInfo getLinkageAndVisibility() const
Determine the linkage and visibility of this type.
Wrapper for source info for functions.
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
static void mergeTemplateLV(LinkageInfo &LV, const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo, LVComputationKind computation)
Merge in template-related linkage and visibility for the given function template specialization.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Visibility
Describes the different kinds of visibility that a declaration may have.
field_range fields() const
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
SourceRange getSourceRange() const override LLVM_READONLY
bool isInitKnownICE() const
Determines whether it is already known whether the initializer is an integral constant expression or ...
A set of unresolved declarations.
bool needsCleanup() const
Returns whether the object performed allocations.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
Module * Parent
The parent of this module.
const SanitizerBlacklist & getSanitizerBlacklist() const
bool isVariadic() const
Whether this function is variadic.
static LinkageInfo getLVForLocalDecl(const NamedDecl *D, LVComputationKind computation)
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
static TypeAliasDecl * CreateDeserialized(ASTContext &C, unsigned ID)
TypeClass getTypeClass() const
void setNumNegativeBits(unsigned Num)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, const TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI)
This represents the body of a CapturedStmt, and serves as its DeclContext.
Represents a linkage specification.
static ParmVarDecl * CreateDeserialized(ASTContext &C, unsigned ID)
detail::InMemoryDirectory::const_iterator I
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
DiagnosticsEngine & getDiagnostics() const
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
bool isExternalFormalLinkage(Linkage L)
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
unsigned NumTemplParamLists
NumTemplParamLists - The number of "outer" template parameter lists.
Represents a prototype with parameter type info, e.g.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
Represents a ValueDecl that came out of a declarator.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
SourceLocation getTypeSpecStartLoc() const
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Stmt ** getInitAddress()
Retrieve the address of the initializer expression.
bool isGlobal() const
Determines whether this is a global function.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
const Type * getTypeForDecl() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
bool isExplicitSpecialization() const
static bool classofKind(Kind K)
void mergeExternalVisibility(Linkage L)
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
static bool hasExplicitVisibilityAlready(LVComputationKind computation)
Does this computation kind permit us to consider additional visibility settings from attributes and t...
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
static Optional< Visibility > getVisibilityOf(const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind)
Return the explicit visibility of the given declaration.
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
This declaration is a tentative definition.
Decl * getPrimaryMergedDecl(Decl *D)
Get the primary declaration for a declaration from an AST file.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec...
Defines the clang::TypeLoc interface and its subclasses.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
static bool RedeclForcesDefC99(const FunctionDecl *Redecl)
static const CXXRecordDecl * getOutermostEnclosingLambda(const CXXRecordDecl *Record)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
StorageClass
Storage classes.
static Optional< Visibility > getExplicitVisibility(const NamedDecl *D, LVComputationKind kind)
Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
InClassInitStyle
In-class initialization styles for non-static data members.
static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)
Do an LV computation for, ultimately, a non-type declaration that already has some sort of explicit v...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isExternallyVisible(Linkage L)
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
specific_decl_iterator< FieldDecl > field_iterator
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
TagDecl * getDefinition() const
getDefinition - Returns the TagDecl that actually defines this struct/union/class/enum.
SourceRange getSourceRange() const override LLVM_READONLY
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setStorageClass(StorageClass SC)
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isInExternCContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C" linkage spec...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
TypeSourceInfo * getTypeSourceInfo() const
static bool isNamed(const NamedDecl *ND, const char(&Str)[Len])
TypedefNameDecl * getTypedefNameForAnonDecl() const
VarDecl * getCanonicalDecl() override
static LinkageInfo external()
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
Optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
VarDecl * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Abstract interface for external sources of AST nodes.
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, unsigned ID, unsigned NameValueSize)
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static bool classof(const Decl *D)
static EnumConstantDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool hasOneOf(SanitizerMask K) const
Check if one or more sanitizers are enabled.
SourceRange getSourceRange() const override LLVM_READONLY
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)
static LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
getLVForDecl - Get the linkage and visibility for the given declaration.
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
Encodes a location in the source.
static EmptyDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static LVComputationKind withExplicitVisibilityAlready(LVComputationKind oldKind)
Given an LVComputationKind, return one of the same type/value sort that records that it already has e...
unsigned getBitWidthValue(const ASTContext &Ctx) const
EnumDecl * getTemplateInstantiationPattern() const
Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantia...
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
TagDecl - 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...
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
LabelDecl - Represents the declaration of a label.
TagDecl * getCanonicalDecl() override
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required...
void printName(raw_ostream &os) const
bool isLegalForVariable(StorageClass SC)
Checks whether the given storage class is legal for variables.
Represents a static or instance method of a struct/union/class.
ArrayRef< ParmVarDecl * > parameters() const
This file defines OpenMP nodes for declarative directives.
SourceRange getSourceRange() const override LLVM_READONLY
ASTContext & getASTContext() const
SourceRange getSourceRange() const override LLVM_READONLY
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool isInlineSpecified, bool isConstexprSpecified)
This declaration is only a declaration.
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
static FunctionDecl * CreateDeserialized(ASTContext &C, unsigned ID)
const T * castAs() const
Member-template castAs<specific type>.
T * get(ExternalASTSource *Source) const
Retrieve the pointer to the AST node that this lazy pointer.
TypeLoc getReturnLoc() const
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.
static void PrintTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
SourceRange getSourceRange() const override LLVM_READONLY
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
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.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
const Attr * getUnusedResultAttr() const
Returns the WarnUnusedResultAttr that is either declared on this function, or its return type declara...
Stmt * getBody() const override
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
unsigned TypeAlias
Whether this template specialization type is a substituted type alias.
QualType getType() const
Return the type wrapped by this type source info.
void printQualifiedName(raw_ostream &OS) const
printQualifiedName - Returns human-readable qualified name for declaration, like A::B::i, for i being member of namespace A::B.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
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)
Defines various enumerations that describe declaration and type specifiers.
static const char * getStorageClassSpecifierString(StorageClass SC)
getStorageClassSpecifierString - 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 LinkageInfo getLVForType(const Type &T, LVComputationKind computation)
static TypedefDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Base class for declarations which introduce a typedef-name.
TLS with a dynamic initializer.
Represents a template argument.
Do an LV computation for, ultimately, a non-type declaration.
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
TagTypeKind
The kind of a tag type.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
External linkage within a unique namespace.
static LinkageInfo getLVForTemplateParameterList(const TemplateParameterList *Params, LVComputationKind computation)
Get the most restrictive linkage for the types in the given template parameter list.
SourceLocation getLocStart() const LLVM_READONLY
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
const unsigned IgnoreExplicitVisibilityBit
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)
Do an LV computation when we only care about the linkage.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
InitType Init
The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
bool isValid() const
Whether this pointer is non-NULL.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
TypeLoc IgnoreParens() const
static bool shouldConsiderTemplateVisibility(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo)
This template specialization was instantiated from a template due to an explicit instantiation declar...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool hasWrittenPrototype() const
TLSKind
Kinds of thread-local storage.
DeclarationName - 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...
ParmVarDeclBitfields ParmVarDeclBits
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
EnumDecl - Represents an enum.
static bool isSingleLineLanguageLinkage(const Decl &D)
detail::InMemoryDirectory::const_iterator E
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
bool isMsStruct(const ASTContext &C) const
isMsStrust - Get whether or not this is an ms_struct which can be turned on with an attribute...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
DefinitionKind hasDefinition() const
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
static LabelDecl * CreateDeserialized(ASTContext &C, unsigned ID)
bool isLambda() const
Determine whether this class describes a lambda function object.
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).
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
SmallVector< Context, 8 > Contexts
bool isVisibilityExplicit() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool hasInheritedDefaultArg() const
bool SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
unsigned MayHaveOutOfDateDef
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
Not an overloaded operator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
Expr * getUninstantiatedDefaultArg()
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, LVComputationKind computation)
const T * getAs() const
Member-template getAs<specific type>'.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
Decl::Kind getDeclKind() const
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, unsigned ID)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
static RecordDecl * CreateDeserialized(const ASTContext &C, unsigned ID)
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
static EnumDecl * CreateDeserialized(ASTContext &C, unsigned ID)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool classofKind(Kind K)
void addDecl(Decl *D)
Add the declaration D into this context.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isStaticDataMember() const
Determines whether this is a static data member.
unsigned IsBeingDefined
IsBeingDefined - True if this is currently being defined.
unsigned getFieldIndex() const
getFieldIndex - Returns the index of this field within its record, as appropriate for passing to ASTR...
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
void merge(LinkageInfo other)
Merge both linkage and visibility.
Linkage getLinkage() const
Determine the linkage of this type.
std::string getQualifiedNameAsString() const
bool isInExternCXXContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C++" linkage spec...
virtual bool isDefined() const
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
static bool isFirstInExternCContext(T *D)
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
NestedNameSpecifierLoc QualifierLoc
static FieldDecl * CreateDeserialized(ASTContext &C, unsigned ID)
Do an LV computation for, ultimately, a type that already has some sort of explicit visibility...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
void setDefaultArg(Expr *defarg)
Represents a C++ struct/union/class.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
void setDescribedVarTemplate(VarTemplateDecl *Template)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
static LinkageInfo getLVForTemplateArgumentList(ArrayRef< TemplateArgument > Args, LVComputationKind computation)
Get the most restrictive linkage for the types and declarations in the given template argument list...
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 TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
void * Allocate(size_t Size, unsigned Align=8) const
ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType Type)
Provides information a specialization of a member of a class template, which may be a member function...
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
bool isInline() const
Whether this variable is (C++1z) inline.
No linkage according to the standard, but is visible from other translation units because of types de...
void setMSAsmLabel(StringRef Name)
VarDecl * getDefinition()
Builtin::Context & BuiltinInfo
Declaration of a class template.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...
unsigned kind
All of the diagnostics that can be emitted by the frontend.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
SourceRange getSourceRange() const override LLVM_READONLY
static BlockDecl * CreateDeserialized(ASTContext &C, unsigned ID)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
static bool isRedeclarableImpl(Redeclarable< T > *)
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.
TranslationUnitDecl - The top declaration context.
bool isInExternCXXContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec...
NamedDecl * getMostRecentDecl()
DefinitionKind isThisDeclarationADefinition() const
bool MSVCFormatting
Use whitespace and punctuation like MSVC does.
EnumConstantDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
static bool useInlineVisibilityHidden(const NamedDecl *D)
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs)
Do an LV computation for, ultimately, a type.
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
NamedDecl - This represents a decl with a name.
DeclarationNameInfo getNameInfo() const
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.
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.
Represents a #pragma detect_mismatch line.
TypeSourceInfo * getTypeSourceInfo() 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.
static bool hasDirectVisibilityAttribute(const NamedDecl *D, LVComputationKind computation)
Does the given declaration have a direct visibility attribute that would match the given rules...
bool hasTrivialBody() const
hasTrivialBody - Returns whether the function has a trivial body that does not require any specific c...
bool isExplicitSpecialization() const
static LinkageInfo uniqueExternal()
static Optional< Visibility > getExplicitVisibilityAux(const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent)
FunctionDecl * getClassScopeSpecializationPattern() const
Retrieve the class scope template pattern that this function template specialization is instantiated ...
This class handles loading and caching of source files into memory.
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
Attr - This represents one attribute.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this method is...
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
setTemplateParameterListsInfo - Sets info about "outer" template parameter lists. ...
Structure used to store a statement, the constant value to which it was evaluated (if any)...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
TemplatedKind
The kind of templated function a FunctionDecl can be.