33 #include "llvm/Support/ErrorHandling.h"
36 using namespace clang;
47 TranslationUnitDecl::TranslationUnitDecl(
ASTContext &ctx)
49 DeclContext(TranslationUnit), Ctx(ctx), AnonymousNamespace(nullptr) {
50 Hidden = Ctx.getLangOpts().ModulesLocalVisibility;
158 "asking for explicit visibility when we shouldn't be");
165 return isa<TypeDecl>(D) ||
166 isa<ClassTemplateDecl>(D) ||
167 isa<ObjCInterfaceDecl>(D);
172 template <
class T>
static typename
173 std::enable_if<!std::is_base_of<RedeclarableTemplateDecl, T>::value,
bool>
::type
176 D->getMemberSpecializationInfo()) {
177 return member->isExplicitSpecialization();
193 switch (attr->getVisibility()) {
201 llvm_unreachable(
"bad visibility kind");
210 if (
const auto *A = D->
getAttr<TypeVisibilityAttr>()) {
216 if (
const auto *A = D->
getAttr<VisibilityAttr>()) {
224 if (A->getPlatform()->getName().equals(
"macosx"))
248 if (isa<TemplateTypeParmDecl>(
P))
255 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
P)) {
257 if (!NTTP->isExpandedParameterPack()) {
258 if (!NTTP->getType()->isDependentType()) {
265 for (
unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {
275 const auto *TTP = cast<TemplateTemplateParmDecl>(
P);
278 if (!TTP->isExpandedParameterPack()) {
285 for (
unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();
288 TTP->getExpansionTemplateParameters(i), computation));
300 const Decl *Ret =
nullptr;
302 while (DC->
getDeclKind() != Decl::TranslationUnit) {
303 if (isa<FunctionDecl>(DC) || isa<BlockDecl>(DC))
304 Ret = cast<Decl>(DC);
320 switch (Arg.getKind()) {
331 if (
const auto *ND = dyn_cast<NamedDecl>(Arg.getAsDecl())) {
338 LV.
merge(Arg.getNullPtrType()->getLinkageAndVisibility());
344 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl())
352 llvm_unreachable(
"bad template argument kind");
373 return !fn->
hasAttr<VisibilityAttr>();
387 bool considerVisibility =
406 switch (computation) {
409 if (D->
hasAttr<TypeVisibilityAttr>())
414 if (D->
hasAttr<VisibilityAttr>())
420 llvm_unreachable(
"bad visibility computation kind");
480 if (considerVisibility)
532 if (considerVisibility)
540 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)
549 = FD->getTemplateSpecializationInfo()) {
550 TSK = spec->getTemplateSpecializationKind();
552 FD->getMemberSpecializationInfo()) {
553 TSK = MSI->getTemplateSpecializationKind();
566 const T *First = D->getFirstDecl();
567 return First->isInExternCContext();
571 if (
const auto *SD = dyn_cast<LinkageSpecDecl>(D.
getDeclContext()))
572 if (!SD->hasBraces())
580 "Not a name having namespace scope");
589 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
597 if (Context.getLangOpts().CPlusPlus &&
598 Var->getType().isConstQualified() &&
599 !Var->getType().isVolatileQualified()) {
604 if (Var->getStorageClass() !=
SC_Extern &&
613 Var->getStorageClass() ==
SC_None)
614 return PrevVar->getLinkageAndVisibility();
616 if (PrevVar->getStorageClass() ==
SC_Static)
625 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
627 }
else if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) {
629 const VarDecl *VD = IFD->getVarDecl();
630 assert(VD &&
"Expected a VarDecl in this IndirectFieldDecl!");
633 assert(!isa<FieldDecl>(D) &&
"Didn't expect a FieldDecl!");
636 const auto *Var = dyn_cast<
VarDecl>(D);
660 !isa<TranslationUnitDecl>(DC);
676 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
679 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
696 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
736 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(Var)) {
741 }
else if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
758 if (Context.getLangOpts().CPlusPlus &&
759 !Function->isInExternCContext()) {
767 QualType TypeAsWritten = Function->getType();
769 TypeAsWritten = TSI->getType();
778 = Function->getTemplateSpecializationInfo()) {
788 }
else if (
const auto *Tag = dyn_cast<TagDecl>(D)) {
790 if (!Tag->hasNameForLinkage())
796 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(Tag)) {
801 }
else if (isa<EnumConstantDecl>(D)) {
810 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
823 }
else if (isa<ObjCInterfaceDecl>(D)) {
826 }
else if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
829 if (!TD->getAnonDeclWithTypedefName(
true))
857 if (!(isa<CXXMethodDecl>(D) ||
860 isa<IndirectFieldDecl>(D) ||
862 isa<TemplateDecl>(D)))
901 const NamedDecl *explicitSpecSuppressor =
nullptr;
903 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
914 QualType TypeAsWritten = MD->getType();
916 TypeAsWritten = TSI->getType();
923 = MD->getTemplateSpecializationInfo()) {
925 if (spec->isExplicitSpecialization()) {
926 explicitSpecSuppressor = MD;
928 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();
931 explicitSpecSuppressor = MD;
934 }
else if (
const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
935 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
937 if (spec->isExplicitSpecialization()) {
938 explicitSpecSuppressor = spec;
946 explicitSpecSuppressor = RD;
950 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
951 if (
const auto *spec = dyn_cast<VarTemplateSpecializationDecl>(VD))
962 explicitSpecSuppressor = VD;
966 }
else if (
const auto *temp = dyn_cast<TemplateDecl>(D)) {
967 bool considerVisibility =
975 if (
const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
977 explicitSpecSuppressor = temp->getTemplatedDecl();
983 assert(!explicitSpecSuppressor || !isa<TemplateDecl>(explicitSpecSuppressor));
987 bool considerClassVisibility =
true;
988 if (explicitSpecSuppressor &&
993 considerClassVisibility =
false;
1001 void NamedDecl::anchor() { }
1018 if (name.front() ==
'C')
1019 if (name ==
"CFStringCreateWithFormat" ||
1020 name ==
"CFStringCreateWithFormatAndArguments" ||
1021 name ==
"CFStringAppendFormat" ||
1022 name ==
"CFStringAppendFormatAndArguments")
1042 bool IsMostRecent) {
1051 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
1053 if (InstantiatedFrom)
1060 if (
const auto *spec = dyn_cast<ClassTemplateSpecializationDecl>(ND))
1061 return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
1065 if (!IsMostRecent && !isa<NamespaceDecl>(ND)) {
1067 if (MostRecent != ND)
1071 if (
const auto *Var = dyn_cast<VarDecl>(ND)) {
1072 if (Var->isStaticDataMember()) {
1074 if (InstantiatedFrom)
1078 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Var))
1079 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),
1085 if (
const auto *fn = dyn_cast<FunctionDecl>(ND)) {
1089 = fn->getTemplateSpecializationInfo())
1090 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
1096 if (InstantiatedFrom)
1103 if (
const auto *TD = dyn_cast<TemplateDecl>(ND))
1109 Optional<Visibility>
1118 if (isa<ParmVarDecl>(ContextDecl))
1121 return getLVForDecl(cast<NamedDecl>(ContextDecl), computation);
1124 if (
const auto *ND = dyn_cast<NamedDecl>(DC))
1132 if (
const auto *Function = dyn_cast<FunctionDecl>(D)) {
1133 if (Function->isInAnonymousNamespace() &&
1134 !Function->isInExternCContext())
1138 if (Function->getCanonicalDecl()->getStorageClass() ==
SC_Static)
1143 if (Optional<Visibility> Vis =
1155 if (
const auto *Var = dyn_cast<VarDecl>(D)) {
1156 if (Var->hasExternalStorage()) {
1157 if (Var->isInAnonymousNamespace() && !Var->isInExternCContext())
1178 if (!Var->isStaticLocal())
1191 if (
const auto *BD = dyn_cast<BlockDecl>(OuterD)) {
1192 if (!BD->getBlockManglingNumber())
1196 BD->getBlockManglingContextDecl(), computation);
1198 const auto *FD = cast<FunctionDecl>(OuterD);
1199 if (!FD->isInlined() &&
1214 while (Record && Record->
isLambda()) {
1218 Record = dyn_cast_or_null<CXXRecordDecl>(
1227 if (D->
hasAttr<InternalLinkageAttr>())
1242 case Decl::ImplicitParam:
1244 case Decl::NamespaceAlias:
1247 case Decl::UsingShadow:
1248 case Decl::UsingDirective:
1251 case Decl::EnumConstant:
1260 !cast<TypedefNameDecl>(D)
1261 ->getAnonDeclWithTypedefName(
true))
1265 case Decl::TemplateTemplateParm:
1266 case Decl::NonTypeTemplateParm:
1267 case Decl::ObjCAtDefsField:
1268 case Decl::ObjCCategory:
1269 case Decl::ObjCCategoryImpl:
1270 case Decl::ObjCCompatibleAlias:
1271 case Decl::ObjCImplementation:
1272 case Decl::ObjCMethod:
1273 case Decl::ObjCProperty:
1274 case Decl::ObjCPropertyImpl:
1275 case Decl::ObjCProtocol:
1278 case Decl::CXXRecord: {
1279 const auto *Record = cast<CXXRecordDecl>(D);
1280 if (Record->isLambda()) {
1281 if (!Record->getLambdaManglingNumber()) {
1349 if (D->
hasAttr<InternalLinkageAttr>())
1366 if (!Opts.CPlusPlus || Opts.MicrosoftExt)
1374 auto *T = cast<NamedDecl>(
I);
1377 if (!T->isInvalidDecl() && T->hasCachedLinkage()) {
1396 std::string QualName;
1397 llvm::raw_string_ostream OS(QualName);
1419 while (Ctx && isa<NamedDecl>(Ctx)) {
1420 Contexts.push_back(Ctx);
1424 for (ContextsTy::reverse_iterator
I = Contexts.rbegin(),
E = Contexts.rend();
1426 if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(*
I)) {
1427 OS << Spec->getName();
1430 TemplateArgs.
data(),
1431 TemplateArgs.
size(),
1433 }
else if (
const auto *ND = dyn_cast<NamespaceDecl>(*
I)) {
1435 (ND->isAnonymousNamespace() || ND->isInline()))
1437 if (ND->isAnonymousNamespace()) {
1439 :
"(anonymous namespace)");
1443 }
else if (
const auto *RD = dyn_cast<RecordDecl>(*
I)) {
1444 if (!RD->getIdentifier())
1445 OS <<
"(anonymous " << RD->getKindName() <<
')';
1448 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(*
I)) {
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>(*
I)) {
1474 if (ED->isScoped() || ED->getIdentifier())
1479 OS << *cast<NamedDecl>(*I);
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");
1527 if (isa<ObjCMethodDecl>(
this))
1532 if (isa<ParmVarDecl>(
this))
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();
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()) {
1658 getExtInfo()->TInfo = savedTInfo;
1661 getExtInfo()->QualifierLoc = QualifierLoc;
1665 if (getExtInfo()->NumTemplParamLists == 0) {
1671 DeclInfo = savedTInfo;
1674 getExtInfo()->QualifierLoc = QualifierLoc;
1681 assert(!TPLists.empty());
1683 if (!hasExtInfo()) {
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>() &&
1824 hasAttr<OMPThreadPrivateDeclAttr>()))
1826 return ((
getASTContext().getLangOpts().isCompatibleWithMSVC(
1828 hasAttr<OMPThreadPrivateDeclAttr>())
1837 llvm_unreachable(
"Unknown thread storage class specifier!");
1851 template<
typename T>
1855 if (!D.hasExternalFormalLinkage())
1879 template<
typename T>
1885 assert(D.getASTContext().getLangOpts().CPlusPlus);
1933 isa<VarTemplatePartialSpecializationDecl>(
this)))
1948 if (hasAttr<AliasAttr>())
1951 if (
const auto *SAA = getAttr<SelectAnyAttr>())
1952 if (!SAA->isInherited())
1958 if (isa<VarTemplateSpecializationDecl>(
this) &&
1990 VarDecl *LastTentative =
nullptr;
1993 Kind =
I->isThisDeclarationADefinition();
1999 return LastTentative;
2005 if (
I->isThisDeclarationADefinition(C) ==
Definition)
2016 Kind = std::max(Kind,
I->isThisDeclarationADefinition(C));
2026 if (
auto Expr =
I->getInit()) {
2035 if (
auto *
P = dyn_cast<ParmVarDecl>(
this))
2036 if (
P->hasUnparsedDefaultArg() ||
P->hasUninstantiatedDefaultArg())
2039 return !
Init.isNull();
2047 return cast<Expr>(
S);
2056 return Init.getAddrOfPtr1();
2070 return VD->isOutOfLine();
2080 if (RD->getLexicalDeclContext()->isFileContext())
2089 Eval->~EvaluatedStmt();
2099 if (!Lang.CPlusPlus)
2104 if (Lang.CPlusPlus11 &&
getType()->isReferenceType())
2110 if (!
getType().isConstQualified() ||
getType().isVolatileQualified())
2115 if (
getType()->isIntegralOrEnumerationType())
2147 void DestroyAPValue(
void* UntypedValue) {
2162 const auto *
Init = cast<Expr>(Eval->
Value);
2163 assert(!
Init->isValueDependent());
2168 Eval->
IsICE =
false;
2192 Eval->
IsICE = Result && Notes.empty();
2195 return Result ? &Eval->
Evaluated :
nullptr;
2200 if (Eval->WasEvaluated)
2201 return &Eval->Evaluated;
2208 return Eval->CheckedICE;
2215 "Check whether we already know that the initializer is an ICE");
2230 const auto *
Init = cast<Expr>(Eval->
Value);
2231 assert(!
Init->isValueDependent());
2257 return cast<VarDecl>(MSI->getInstantiatedFrom());
2263 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2264 return Spec->getSpecializationKind();
2267 return MSI->getTemplateSpecializationKind();
2273 if (
const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(
this))
2274 return Spec->getPointOfInstantiation();
2277 return MSI->getPointOfInstantiation();
2302 assert((isa<VarTemplateSpecializationDecl>(
this) ||
2304 "not a variable or static data member template specialization");
2307 dyn_cast<VarTemplateSpecializationDecl>(
this)) {
2308 Spec->setSpecializationKind(TSK);
2310 Spec->getPointOfInstantiation().isInvalid())
2311 Spec->setPointOfInstantiation(PointOfInstantiation);
2315 MSI->setTemplateSpecializationKind(TSK);
2317 MSI->getPointOfInstantiation().isInvalid())
2318 MSI->setPointOfInstantiation(PointOfInstantiation);
2325 assert(
getASTContext().getTemplateOrSpecializationInfo(
this).isNull() &&
2326 "Previous template or instantiation?");
2339 return new (
C, DC)
ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,
2346 if (
const auto *DT = dyn_cast<DecayedType>(T))
2347 return DT->getOriginalType();
2375 "Default argument is not yet instantiated!");
2378 if (
auto *
E = dyn_cast_or_null<ExprWithCleanups>(Arg))
2379 return E->getSubExpr();
2401 return E->getSourceRange();
2406 llvm_unreachable(
"Invalid default argument kind.");
2416 "Wrong kind of initialization expression!");
2417 return cast_or_null<Expr>(
Init.get<
Stmt *>());
2429 return isa<PackExpansionType>(
getType());
2432 void ParmVarDecl::setParameterIndexLarge(
unsigned parameterIndex) {
2437 unsigned ParmVarDecl::getParameterIndexLarge()
const {
2446 raw_ostream &OS,
const PrintingPolicy &Policy,
bool Qualified)
const {
2451 OS, TemplateArgs->
data(), TemplateArgs->
size(), Policy);
2455 if (
const auto *FT =
getType()->getAs<FunctionProtoType>())
2456 return FT->isVariadic();
2462 if (
I->Body ||
I->IsLateTemplateParsed) {
2480 if (isa<CompoundStmt>(S) && cast<CompoundStmt>(S)->body_empty())
2487 if (
I->IsDeleted ||
I->IsDefaulted ||
I->Body ||
I->IsLateTemplateParsed ||
2488 I->hasAttr<AliasAttr>()) {
2489 Definition =
I->IsDeleted ?
I->getCanonicalDecl() :
I;
2501 if (Definition->Body)
2510 EndRangeLoc = B->getLocEnd();
2517 Parent->markedVirtualFunctionPure();
2520 template<std::
size_t Len>
2523 return II && II->
isStr(Str);
2551 return llvm::StringSwitch<bool>(
getName())
2563 assert(
getDeclName().getCXXOverloadedOperator() == OO_New ||
2564 getDeclName().getCXXOverloadedOperator() == OO_Delete ||
2565 getDeclName().getCXXOverloadedOperator() == OO_Array_New ||
2566 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete);
2572 if (proto->getNumParams() != 2 || proto->isVariadic())
2581 return (proto->getParamType(1).getCanonicalType() == Context.
VoidPtrTy);
2587 if (
getDeclName().getCXXOverloadedOperator() != OO_New &&
2588 getDeclName().getCXXOverloadedOperator() != OO_Delete &&
2589 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&
2590 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)
2601 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 2 || FPT->isVariadic())
2606 if (FPT->getNumParams() == 1)
2611 QualType Ty = FPT->getParamType(1);
2642 if (
const auto *Method = dyn_cast<CXXMethodDecl>(
this))
2643 return Method->isStatic();
2650 DC = DC->getParent()) {
2651 if (
const auto *Namespace = cast<NamespaceDecl>(DC)) {
2652 if (!Namespace->getDeclName())
2662 return hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
2663 hasAttr<C11NoReturnAttr>() ||
2674 assert((!PrevDecl || PrevFunTmpl) &&
"Function/function template mismatch");
2675 FunTmpl->setPreviousDecl(PrevFunTmpl);
2678 if (PrevDecl && PrevDecl->IsInline)
2703 const auto *LinkageDecl =
2710 if (BuiltinID == Builtin::BI__GetExceptionInfo &&
2713 return Builtin::BI__GetExceptionInfo;
2722 if (hasAttr<OverloadableAttr>())
2750 assert(!ParamInfo &&
"Already has param info!");
2751 assert(NewParamInfo.size() ==
getNumParams() &&
"Parameter count mismatch!");
2754 if (!NewParamInfo.empty()) {
2756 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
2761 assert(DeclsInPrototypeScope.empty() &&
"Already has prototype decls!");
2763 if (!NewDecls.empty()) {
2765 std::copy(NewDecls.begin(), NewDecls.end(), A);
2766 DeclsInPrototypeScope = llvm::makeArrayRef(A, NewDecls.size());
2768 for (
auto I : NewDecls) {
2775 I->setDeclContext(
this);
2790 unsigned NumRequiredArgs = 0;
2791 for (
auto *Param :
params())
2792 if (!Param->isParameterPack() && !Param->hasDefaultArg())
2794 return NumRequiredArgs;
2803 assert(
isInlined() &&
"expected to get called on an inlined function!");
2807 !hasAttr<DLLExportAttr>())
2812 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
2824 if (!FD->isImplicit() && FD->getStorageClass() ==
SC_Extern)
2854 "Must have a declaration without a body.");
2865 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
2875 bool FoundBody =
false;
2877 FoundBody |= Prev->Body.
isValid();
2903 bool FoundBody =
false;
2905 FoundBody |= Prev->Body.
isValid();
2937 if (Ret && Ret->
hasAttr<WarnUnusedResultAttr>() &&
2938 !(MD && MD->getCorrespondingMethodInClass(Ret,
true)))
2941 return hasAttr<WarnUnusedResultAttr>();
2963 assert(
isInlined() &&
"Function must be inline");
2966 if (Context.
getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
2978 for (
auto Redecl :
redecls()) {
2979 if (Redecl->isInlineSpecified() &&
2989 "should not use C inline rules in C++");
2995 for (
auto Redecl :
redecls()) {
3026 if (TemplateOrSpecialization.isNull())
3034 if (TemplateOrSpecialization.is
3038 llvm_unreachable(
"Did we miss a TemplateOrSpecialization type?");
3043 return cast<FunctionDecl>(Info->getInstantiatedFrom());
3053 FunctionDecl::setInstantiationOfMemberFunction(
ASTContext &C,
3056 assert(TemplateOrSpecialization.isNull() &&
3057 "Member function is already a specialization");
3060 TemplateOrSpecialization = Info;
3068 TemplateOrSpecialization = Template;
3096 bool HasPattern =
false;
3098 HasPattern = PatternDecl->
hasBody(PatternDecl);
3104 if (!HasPattern || !PatternDecl)
3120 llvm_unreachable(
"All TSK values handled.");
3138 dyn_cast<CXXMethodDecl>(
this))) {
3140 "generated from a primary call operator "
3143 "A generic lambda call operator template must always have a body - "
3144 "even if instantiated from a prototype (i.e. as written) member "
3150 while (Primary->getInstantiatedFromMemberTemplate()) {
3153 if (Primary->isMemberSpecialization())
3155 Primary = Primary->getInstantiatedFromMemberTemplate();
3158 return Primary->getTemplatedDecl();
3166 = TemplateOrSpecialization
3167 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3168 return Info->Template.getPointer();
3179 return TemplateOrSpecialization
3186 = TemplateOrSpecialization
3187 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3188 return Info->TemplateArguments;
3196 = TemplateOrSpecialization
3197 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {
3198 return Info->TemplateArgumentsAsWritten;
3204 FunctionDecl::setFunctionTemplateSpecialization(
ASTContext &C,
3212 "Must specify the type of function template specialization");
3218 TemplateArgsAsWritten,
3219 PointOfInstantiation);
3220 TemplateOrSpecialization = Info;
3228 assert(TemplateOrSpecialization.isNull());
3232 TemplateOrSpecialization = Info;
3237 return TemplateOrSpecialization
3246 totalSizeToAlloc<TemplateArgumentLoc, FunctionTemplateDecl *>(
3251 DependentFunctionTemplateSpecializationInfo::
3254 : AngleLocs(TArgs.getLAngleLoc(), TArgs.getRAngleLoc()) {
3256 NumTemplates = Ts.
size();
3257 NumArgs = TArgs.
size();
3260 for (
unsigned I = 0,
E = Ts.
size();
I !=
E; ++
I)
3261 TsArray[
I] = cast<FunctionTemplateDecl>(Ts[
I]->getUnderlyingDecl());
3264 for (
unsigned I = 0,
E = TArgs.
size();
I !=
E; ++
I)
3288 = TemplateOrSpecialization.dyn_cast<
3290 FTSInfo->setTemplateSpecializationKind(TSK);
3292 PointOfInstantiation.
isValid() &&
3293 FTSInfo->getPointOfInstantiation().isInvalid())
3294 FTSInfo->setPointOfInstantiation(PointOfInstantiation);
3297 MSInfo->setTemplateSpecializationKind(TSK);
3299 PointOfInstantiation.
isValid() &&
3300 MSInfo->getPointOfInstantiation().isInvalid())
3301 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3303 llvm_unreachable(
"Function cannot have a template specialization kind");
3308 = TemplateOrSpecialization.dyn_cast<
3310 return FTSInfo->getPointOfInstantiation();
3313 return MSInfo->getPointOfInstantiation();
3334 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
3353 case Builtin::BI__builtin_memset:
3354 case Builtin::BI__builtin___memset_chk:
3355 case Builtin::BImemset:
3356 return Builtin::BImemset;
3358 case Builtin::BI__builtin_memcpy:
3359 case Builtin::BI__builtin___memcpy_chk:
3360 case Builtin::BImemcpy:
3361 return Builtin::BImemcpy;
3363 case Builtin::BI__builtin_memmove:
3364 case Builtin::BI__builtin___memmove_chk:
3365 case Builtin::BImemmove:
3366 return Builtin::BImemmove;
3368 case Builtin::BIstrlcpy:
3369 case Builtin::BI__builtin___strlcpy_chk:
3370 return Builtin::BIstrlcpy;
3372 case Builtin::BIstrlcat:
3373 case Builtin::BI__builtin___strlcat_chk:
3374 return Builtin::BIstrlcat;
3376 case Builtin::BI__builtin_memcmp:
3377 case Builtin::BImemcmp:
3378 return Builtin::BImemcmp;
3380 case Builtin::BI__builtin_strncpy:
3381 case Builtin::BI__builtin___strncpy_chk:
3382 case Builtin::BIstrncpy:
3383 return Builtin::BIstrncpy;
3385 case Builtin::BI__builtin_strncmp:
3386 case Builtin::BIstrncmp:
3387 return Builtin::BIstrncmp;
3389 case Builtin::BI__builtin_strncasecmp:
3390 case Builtin::BIstrncasecmp:
3391 return Builtin::BIstrncasecmp;
3393 case Builtin::BI__builtin_strncat:
3394 case Builtin::BI__builtin___strncat_chk:
3395 case Builtin::BIstrncat:
3396 return Builtin::BIstrncat;
3398 case Builtin::BI__builtin_strndup:
3399 case Builtin::BIstrndup:
3400 return Builtin::BIstrndup;
3402 case Builtin::BI__builtin_strlen:
3403 case Builtin::BIstrlen:
3404 return Builtin::BIstrlen;
3408 if (FnInfo->
isStr(
"memset"))
3409 return Builtin::BImemset;
3410 else if (FnInfo->
isStr(
"memcpy"))
3411 return Builtin::BImemcpy;
3412 else if (FnInfo->
isStr(
"memmove"))
3413 return Builtin::BImemmove;
3414 else if (FnInfo->
isStr(
"memcmp"))
3415 return Builtin::BImemcmp;
3416 else if (FnInfo->
isStr(
"strncpy"))
3417 return Builtin::BIstrncpy;
3418 else if (FnInfo->
isStr(
"strncmp"))
3419 return Builtin::BIstrncmp;
3420 else if (FnInfo->
isStr(
"strncasecmp"))
3421 return Builtin::BIstrncasecmp;
3422 else if (FnInfo->
isStr(
"strncat"))
3423 return Builtin::BIstrncat;
3424 else if (FnInfo->
isStr(
"strndup"))
3425 return Builtin::BIstrndup;
3426 else if (FnInfo->
isStr(
"strlen"))
3427 return Builtin::BIstrlen;
3443 return new (
C, DC)
FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,
3444 BW, Mutable, InitStyle);
3457 if (
const auto *Record =
getType()->getAs<RecordType>())
3458 return Record->getDecl()->isAnonymousStructOrUnion();
3465 auto *BitWidth =
static_cast<Expr *
>(InitStorage.getPointer());
3471 if (Canonical !=
this)
3474 if (CachedFieldIndex)
return CachedFieldIndex - 1;
3479 for (
auto *Field : RD->
fields()) {
3480 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;
3484 assert(CachedFieldIndex &&
"failed to find field in parent");
3485 return CachedFieldIndex - 1;
3489 switch (InitStorage.getInt()) {
3491 case ISK_BitWidthOrNothing:
3492 case ISK_InClassCopyInit:
3493 case ISK_InClassListInit:
3494 if (
const auto *
E = static_cast<const Expr *>(InitStorage.getPointer()))
3498 case ISK_CapturedVLAType:
3501 llvm_unreachable(
"bad init storage kind");
3506 "capturing type in non-lambda or captured record.");
3507 assert(InitStorage.getInt() == ISK_BitWidthOrNothing &&
3508 InitStorage.getPointer() ==
nullptr &&
3509 "bit width, initializer or captured type already set");
3510 InitStorage.setPointerAndInt(const_cast<VariableArrayType *>(VLAType),
3511 ISK_CapturedVLAType);
3530 TypedefNameDeclOrQualifier = TDD;
3533 assert(T->isLinkageValid());
3541 if (
auto *D = dyn_cast<CXXRecordDecl>(
this)) {
3542 struct CXXRecordDecl::DefinitionData *Data =
3543 new (
getASTContext())
struct CXXRecordDecl::DefinitionData(D);
3545 cast<CXXRecordDecl>(
I)->DefinitionData = Data;
3550 assert((!isa<CXXRecordDecl>(
this) ||
3552 "definition completed but not started");
3554 IsCompleteDefinition =
true;
3558 L->CompletedTagDefinition(
this);
3563 return const_cast<TagDecl *
>(
this);
3568 if (II->isOutOfDate()) {
3574 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(
this))
3575 return CXXRD->getDefinition();
3578 if (R->isCompleteDefinition())
3606 assert(!TPLists.empty());
3619 void EnumDecl::anchor() { }
3625 bool IsScopedUsingClassTag,
bool IsFixed) {
3626 auto *Enum =
new (
C, DC)
EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,
3627 IsScoped, IsScopedUsingClassTag, IsFixed);
3636 nullptr,
nullptr,
false,
false,
false);
3643 return TI->getTypeLoc().getSourceRange();
3649 unsigned NumPositiveBits,
3650 unsigned NumNegativeBits) {
3654 PromotionType = NewPromotionType;
3662 return MSI->getTemplateSpecializationKind();
3670 assert(MSI &&
"Not an instantiated member enumeration?");
3673 PointOfInstantiation.
isValid() &&
3679 if (SpecializationInfo)
3687 assert(!SpecializationInfo &&
"Member enum is already a specialization");
3699 :
TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
3700 HasFlexibleArrayMember =
false;
3701 AnonymousStructOrUnion =
false;
3702 HasObjectMember =
false;
3703 HasVolatileMember =
false;
3704 LoadedFieldsFromExternalStorage =
false;
3705 assert(
classof(static_cast<Decl*>(
this)) &&
"Invalid Kind!");
3712 StartLoc, IdLoc, Id, PrevDecl);
3733 if (
auto RD = dyn_cast<CXXRecordDecl>(
this))
3734 return RD->isLambda();
3739 return hasAttr<CapturedRecordAttr>();
3748 LoadFieldsFromExternalStorage();
3764 return hasAttr<MSStructAttr>() || C.
getLangOpts().MSBitfields == 1;
3767 void RecordDecl::LoadFieldsFromExternalStorage()
const {
3775 LoadedFieldsFromExternalStorage =
true;
3782 for (
unsigned i=0, e=Decls.size(); i != e; ++i)
3783 assert(isa<FieldDecl>(Decls[i]) || isa<IndirectFieldDecl>(Decls[i]));
3796 SanitizerKind::Address | SanitizerKind::KernelAddress) ||
3797 !Context.
getLangOpts().SanitizeAddressFieldPadding)
3802 int ReasonToReject = -1;
3803 if (!CXXRD || CXXRD->isExternCContext())
3805 else if (CXXRD->hasAttr<PackedAttr>())
3807 else if (CXXRD->isUnion())
3809 else if (CXXRD->isTriviallyCopyable())
3811 else if (CXXRD->hasTrivialDestructor())
3813 else if (CXXRD->isStandardLayout())
3815 else if (Blacklist.isBlacklistedLocation(
getLocation(),
"field-padding"))
3822 if (ReasonToReject >= 0)
3825 diag::remark_sanitize_address_insert_extra_padding_rejected)
3830 diag::remark_sanitize_address_insert_extra_padding_accepted)
3833 return ReasonToReject < 0;
3837 for (
const auto *
I :
fields()) {
3838 if (
I->getIdentifier())
3841 if (
const auto *RT =
I->getType()->getAs<
RecordType>())
3843 RT->getDecl()->findFirstNamedDataMember())
3844 return NamedDataMember;
3857 assert(!ParamInfo &&
"Already has param info!");
3860 if (!NewParamInfo.empty()) {
3861 NumParams = NewParamInfo.size();
3863 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);
3868 bool CapturesCXXThis) {
3869 this->CapturesCXXThis = CapturesCXXThis;
3870 this->NumCaptures = Captures.size();
3872 if (Captures.empty()) {
3873 this->Captures =
nullptr;
3877 this->Captures = Captures.copy(Context).data();
3883 if (
I.getVariable() == variable)
3897 void TranslationUnitDecl::anchor() { }
3903 void ExternCContextDecl::anchor() { }
3910 void LabelDecl::anchor() { }
3914 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, IdentL);
3920 assert(GnuLabelL != IdentL &&
"Use this only for GNU local labels");
3921 return new (
C, DC)
LabelDecl(DC, IdentL, II,
nullptr, GnuLabelL);
3931 memcpy(Buffer, Name.data(), Name.size());
3932 Buffer[Name.size()] =
'\0';
3936 void ValueDecl::anchor() { }
3939 for (
const auto *
I :
attrs())
3940 if (isa<WeakAttr>(
I) || isa<WeakRefAttr>(
I))
3946 void ImplicitParamDecl::anchor() { }
3966 bool isInlineSpecified,
3967 bool hasWrittenPrototype,
3968 bool isConstexprSpecified) {
3970 new (
C, DC)
FunctionDecl(Function, C, DC, StartLoc, NameInfo, T, TInfo,
3971 SC, isInlineSpecified, isConstexprSpecified);
3990 CapturedDecl::CapturedDecl(
DeclContext *DC,
unsigned NumParams)
3992 NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr,
false) {}
3995 unsigned NumParams) {
3996 return new (
C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4001 unsigned NumParams) {
4002 return new (
C,
ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))
4015 Expr *
E,
const llvm::APSInt &V) {
4022 QualType(),
nullptr, llvm::APSInt());
4025 void IndirectFieldDecl::anchor() { }
4030 :
ValueDecl(IndirectField, DC, L, N, T), Chaining(CH), ChainingSize(CHS) {
4054 End = Init->getLocEnd();
4058 void TypeDecl::anchor() { }
4063 return new (
C, DC)
TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4066 void TypedefNameDecl::anchor() { }
4071 auto *ThisTypedef =
this;
4072 if (AnyRedecl && OwningTypedef) {
4076 if (OwningTypedef == ThisTypedef)
4077 return TT->getDecl();
4092 return new (
C, DC)
TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);
4103 if (typeIsPostfix(TInfo->getType()))
4104 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4112 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();
4116 void FileScopeAsmDecl::anchor() { }
4131 void EmptyDecl::anchor() {}
4159 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
true),
4163 auto *StoredLocs = getTrailingObjects<SourceLocation>();
4164 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
4170 :
Decl(Import, DC, StartLoc), ImportedAndComplete(Imported,
false),
4173 *getTrailingObjects<SourceLocation>() = EndLoc;
4180 additionalSizeToAlloc<SourceLocation>(IdentifierLocs.size()))
4181 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);
4188 ImportDecl *Import =
new (
C, DC, additionalSizeToAlloc<SourceLocation>(1))
4195 unsigned NumLocations) {
4196 return new (
C,
ID, additionalSizeToAlloc<SourceLocation>(NumLocations))
4201 if (!ImportedAndComplete.getInt())
4204 const auto *StoredLocs = getTrailingObjects<SourceLocation>();
4205 return llvm::makeArrayRef(StoredLocs,
4210 if (!ImportedAndComplete.getInt())
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.
void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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...
void setImplicit(bool I=true)
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 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 ...
void setDeclsInPrototypeScope(ArrayRef< NamedDecl * > NewDecls)
External linkage, which indicates that the entity can be referred to from other translation units...
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
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.
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
Source range that this declaration covers.
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
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 isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
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...
bool IsBeingDefined
IsBeingDefined - True if this is currently being defined.
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.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
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.
Decl - This represents one declaration (or definition), e.g.
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
Source range that this declaration covers.
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.
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...
bool doesDeclarationForceExternallyVisibleDefinition() const
For a function declaration in C or C++, determine whether this declaration causes the definition to b...
bool isInStdNamespace() const
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
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
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.
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
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
Represents an empty template argument, e.g., one that has not been deduced.
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. ...
bool MayHaveOutOfDateDef
Indicates whether it is possible for declarations of this kind to have an out-of-date definition...
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
ASTMutationListener * getASTMutationListener() 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
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
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.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
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
unsigned size() const
Retrieve the number of template arguments in this template argument list.
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
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
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
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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
Source range that this declaration covers.
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
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
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)
static void PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
detail::InMemoryDirectory::const_iterator I
Decl * getPrimaryMergedDecl(Decl *D)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
DiagnosticsEngine & getDiagnostics() const
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
bool isExternalFormalLinkage(Linkage L)
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
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.
ID
Defines the set of possible language-specific address spaces.
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)
VarDecl * getOutOfLineDefinition()
If this is a static data member, find its out-of-line definition.
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...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
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...
bool isInAnonymousNamespace() const
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...
DeclContext * getDeclContext()
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.
TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)
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 isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
bool isExternallyVisible(Linkage L)
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)
Creates clause with a list of variables VL and a linear step Step.
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
Source range that this declaration covers.
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
Retrieves the "canonical" declaration of the given declaration.
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)
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
Source range that this declaration covers.
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.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)
static LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
getLVForDecl - Get the linkage and visibility for the given declaration.
void AddDeallocation(void(*Callback)(void *), void *Data)
Add a deallocation callback that will be invoked when the ASTContext is destroyed.
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 ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
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
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...
ASTContext & getASTContext() const LLVM_READONLY
LabelDecl - Represents the declaration of a label.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ASTContext & getASTContext() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
void setCachedLinkage(Linkage L) const
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)
Linkage getCachedLinkage() const
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.
bool isFileContext() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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.
FunctionDecl * getClassScopeSpecializationPattern(const FunctionDecl *FD)
bool hasCachedLinkage() const
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)
Add a specialization of this function template.
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
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.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
Do an LV computation when we only care about the linkage.
The template argument is a pack expansion of a template name that was provided for a template templat...
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.
bool isInvalidDecl() const
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.
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
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...
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
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...
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)
bool TypeAlias
Whether this template specialization type is a substituted type alias.
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...
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)
void addDecl(Decl *D)
Add the declaration D into this context.
The template argument is actually a parameter pack.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
bool isStaticDataMember() const
Determines whether this is a static data member.
unsigned getFieldIndex() const
getFieldIndex - Returns the index of this field within its record, as appropriate for passing to ASTR...
void merge(LinkageInfo other)
Merge both linkage and visibility.
SourceManager & getSourceManager()
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)
unsigned Hidden
Whether this declaration is hidden from normal name lookup, e.g., because it is was loaded from an AS...
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.
The template argument is a template name that was provided for a template template parameter...
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)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
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...
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
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.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, NamedDecl **CH, unsigned CHS)
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Kind
Lists the kind of concrete classes of Decl.
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)
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.
SourceLocation getLocation() const
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
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.
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.