25#include "llvm/ADT/StringExtras.h"
26#include "llvm/Support/raw_ostream.h"
30 class DeclPrinter :
public DeclVisitor<DeclPrinter> {
32 PrintingPolicy Policy;
33 const ASTContext &Context;
35 bool PrintInstantiation;
38 raw_ostream&
Indent(
unsigned Indentation);
39 void ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls);
42 void PrintConstructorInitializers(CXXConstructorDecl *CDecl,
52 void PrintObjCTypeParams(ObjCTypeParamList *Params);
53 void PrintOpenACCRoutineOnLambda(Decl *D);
56 DeclPrinter(raw_ostream &Out,
const PrintingPolicy &Policy,
57 const ASTContext &Context,
unsigned Indentation = 0,
58 bool PrintInstantiation =
false)
59 : Out(Out), Policy(Policy), Context(Context), Indentation(Indentation),
60 PrintInstantiation(PrintInstantiation) {}
62 void VisitDeclContext(DeclContext *DC,
bool Indent =
true);
64 void VisitTranslationUnitDecl(TranslationUnitDecl *D);
65 void VisitTypedefDecl(TypedefDecl *D);
66 void VisitTypeAliasDecl(TypeAliasDecl *D);
67 void VisitEnumDecl(EnumDecl *D);
68 void VisitRecordDecl(RecordDecl *D);
69 void VisitEnumConstantDecl(EnumConstantDecl *D);
70 void VisitEmptyDecl(EmptyDecl *D);
71 void VisitFunctionDecl(FunctionDecl *D);
72 void VisitFriendDecl(FriendDecl *D);
73 void VisitFieldDecl(FieldDecl *D);
74 void VisitVarDecl(VarDecl *D);
75 void VisitLabelDecl(LabelDecl *D);
76 void VisitParmVarDecl(ParmVarDecl *D);
77 void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
78 void VisitTopLevelStmtDecl(TopLevelStmtDecl *D);
79 void VisitImportDecl(ImportDecl *D);
80 void VisitStaticAssertDecl(StaticAssertDecl *D);
81 void VisitNamespaceDecl(NamespaceDecl *D);
82 void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
83 void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
84 void VisitCXXRecordDecl(CXXRecordDecl *D);
85 void VisitLinkageSpecDecl(LinkageSpecDecl *D);
86 void VisitTemplateDecl(
const TemplateDecl *D);
87 void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
88 void VisitClassTemplateDecl(ClassTemplateDecl *D);
89 void VisitExplicitInstantiationDecl(ExplicitInstantiationDecl *D);
90 void VisitClassTemplateSpecializationDecl(
91 ClassTemplateSpecializationDecl *D);
92 void VisitClassTemplatePartialSpecializationDecl(
93 ClassTemplatePartialSpecializationDecl *D);
94 void VisitObjCMethodDecl(ObjCMethodDecl *D);
95 void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
96 void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
97 void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
98 void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
99 void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
100 void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
101 void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
102 void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
103 void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
104 void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
105 void VisitUsingDecl(UsingDecl *D);
106 void VisitUsingEnumDecl(UsingEnumDecl *D);
107 void VisitUsingShadowDecl(UsingShadowDecl *D);
108 void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
109 void VisitOMPAllocateDecl(OMPAllocateDecl *D);
110 void VisitOMPRequiresDecl(OMPRequiresDecl *D);
111 void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
112 void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
113 void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
114 void VisitTemplateTypeParmDecl(
const TemplateTypeParmDecl *TTP);
115 void VisitNonTypeTemplateParmDecl(
const NonTypeTemplateParmDecl *NTTP);
116 void VisitTemplateTemplateParmDecl(
const TemplateTemplateParmDecl *);
117 void VisitHLSLBufferDecl(HLSLBufferDecl *D);
118 void VisitCXXExpansionStmtDecl(
const CXXExpansionStmtDecl *D);
120 void VisitOpenACCDeclareDecl(OpenACCDeclareDecl *D);
121 void VisitOpenACCRoutineDecl(OpenACCRoutineDecl *D);
123 void printTemplateParameters(
const TemplateParameterList *Params,
124 bool OmitTemplateKW =
false);
125 void printTemplateArguments(ArrayRef<TemplateArgument> Args,
126 const TemplateParameterList *Params);
127 void printTemplateArguments(ArrayRef<TemplateArgumentLoc> Args,
128 const TemplateParameterList *Params);
130 std::optional<std::string>
131 prettyPrintAttributes(
const Decl *D,
132 AttrPosAsWritten Pos = AttrPosAsWritten::Default);
134 void prettyPrintPragmas(Decl *D);
135 void printDeclType(QualType T, StringRef DeclName,
bool Pack =
false);
140 bool PrintInstantiation)
const {
145 unsigned Indentation,
bool PrintInstantiation)
const {
146 DeclPrinter Printer(Out, Policy,
getASTContext(), Indentation,
148 Printer.Visit(
const_cast<Decl*
>(
this));
152 bool OmitTemplateKW)
const {
153 print(Out, Context, Context.getPrintingPolicy(), OmitTemplateKW);
158 bool OmitTemplateKW)
const {
159 DeclPrinter Printer(Out, Policy, Context);
160 Printer.printTemplateParameters(
this, OmitTemplateKW);
166 while (!BaseType->isSpecifierType()) {
168 BaseType = PTy->getPointeeType();
171 BaseType = OPT->getPointeeType();
173 BaseType = BPy->getPointeeType();
174 else if (
const ArrayType *ATy = dyn_cast<ArrayType>(BaseType))
175 BaseType = ATy->getElementType();
177 BaseType = FTy->getReturnType();
179 BaseType = VTy->getElementType();
181 BaseType = RTy->getPointeeType();
182 else if (
const AutoType *ATy = BaseType->getAs<AutoType>())
183 BaseType = ATy->getDeducedType();
185 BaseType = PTy->desugar();
195 return TDD->getUnderlyingType();
196 if (
ValueDecl* VD = dyn_cast<ValueDecl>(D))
197 return VD->getType();
203 unsigned Indentation) {
205 (*Begin)->print(Out, Policy, Indentation);
209 Decl** End = Begin + NumDecls;
216 for ( ; Begin != End; ++Begin) {
224 (*Begin)->print(Out, SubPolicy, Indentation);
236 Printer.VisitDeclContext(
const_cast<DeclContext *
>(
this),
false);
239raw_ostream& DeclPrinter::Indent(
unsigned Indentation) {
240 for (
unsigned i = 0; i != Indentation; ++i)
251 return DeclPrinter::AttrPosAsWritten::Left;
253 if (
C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
254 return DeclPrinter::AttrPosAsWritten::Left;
256 return DeclPrinter::AttrPosAsWritten::Right;
259std::optional<std::string>
260DeclPrinter::prettyPrintAttributes(
const Decl *D,
261 AttrPosAsWritten Pos ) {
266 llvm::raw_string_ostream AOut(AttrStr);
267 llvm::ListSeparator LS(
" ");
269 if (A->isInherited() || A->isImplicit())
274 switch (A->getKind()) {
276#define PRAGMA_SPELLING_ATTR(X) case attr::X:
277#include "clang/Basic/AttrList.inc"
281 assert(APos != AttrPosAsWritten::Default &&
282 "Default not a valid for an attribute location");
283 if (Pos == AttrPosAsWritten::Default || Pos == APos) {
285 A->printPretty(AOut, Policy);
295void DeclPrinter::PrintOpenACCRoutineOnLambda(
Decl *D) {
297 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
298 if (
const auto *
Init = VD->getInit())
300 :
Init->getType()->getAsCXXRecordDecl();
301 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
303 FD->getType().isNull() ?
nullptr : FD->getType()->getAsCXXRecordDecl();
310 for (
auto *A :
Call->specific_attrs<OpenACCRoutineDeclAttr>()) {
311 A->printPretty(Out, Policy);
317void DeclPrinter::prettyPrintPragmas(
Decl *D) {
321 PrintOpenACCRoutineOnLambda(D);
325 for (
auto *A : Attrs) {
326 switch (A->getKind()) {
328#define PRAGMA_SPELLING_ATTR(X) case attr::X:
329#include "clang/Basic/AttrList.inc"
330 A->printPretty(Out, Policy);
340void DeclPrinter::printDeclType(
QualType T, StringRef DeclName,
bool Pack) {
344 if (
auto *PET = T->
getAs<PackExpansionType>()) {
346 T = PET->getPattern();
348 T.
print(Out, Policy, (Pack ?
"..." :
"") + DeclName, Indentation);
361 if (AccessSpelling.empty())
362 llvm_unreachable(
"No access specifier!");
363 Out << AccessSpelling;
367 std::string &Proto) {
368 bool HasInitializerList =
false;
369 for (
const auto *BMInitializer : CDecl->
inits()) {
370 if (BMInitializer->isInClassMemberInitializer())
372 if (!BMInitializer->isWritten())
375 if (!HasInitializerList) {
379 HasInitializerList =
true;
383 if (BMInitializer->isAnyMemberInitializer()) {
384 FieldDecl *FD = BMInitializer->getAnyMember();
386 }
else if (BMInitializer->isDelegatingInitializer()) {
392 if (
Expr *
Init = BMInitializer->getInit()) {
399 Init = Tmp->getSubExpr();
403 Expr *SimpleInit =
nullptr;
404 Expr **Args =
nullptr;
405 unsigned NumArgs = 0;
407 Args = ParenList->getExprs();
408 NumArgs = ParenList->getNumExprs();
410 dyn_cast<CXXConstructExpr>(
Init)) {
411 Args = Construct->getArgs();
412 NumArgs = Construct->getNumArgs();
417 SimpleInit->
printPretty(Out,
nullptr, Policy, Indentation,
"\n",
420 for (
unsigned I = 0; I != NumArgs; ++I) {
421 assert(Args[I] !=
nullptr &&
"Expected non-null Expr");
427 Args[I]->
printPretty(Out,
nullptr, Policy, Indentation,
"\n",
438 if (BMInitializer->isPackExpansion())
469 if (
auto FD = dyn_cast<FunctionDecl>(*D))
487 if (!Decls.empty() && !CurDeclType.
isNull()) {
489 if (
const auto *TT = dyn_cast_or_null<TagType>(BaseType);
490 TT && TT->isTagOwned()) {
491 if (TT->getDecl() == Decls[0]) {
500 ProcessDeclGroup(Decls);
522 const char *Terminator =
nullptr;
526 Terminator =
nullptr;
528 Terminator =
nullptr;
530 Terminator =
nullptr;
531 else if (
auto FD = dyn_cast<FunctionDecl>(*D)) {
532 if (FD->doesThisDeclarationHaveABody() && !FD->isDefaulted())
533 Terminator =
nullptr;
536 }
else if (
auto TD = dyn_cast<FunctionTemplateDecl>(*D)) {
537 if (TD->getTemplatedDecl()->doesThisDeclarationHaveABody())
538 Terminator =
nullptr;
544 Terminator =
nullptr;
566 if (D->
hasAttr<OMPDeclareTargetDeclAttr>())
567 Out <<
"#pragma omp end declare target\n";
571 ProcessDeclGroup(Decls);
578 VisitDeclContext(D,
false);
581void DeclPrinter::VisitTypedefDecl(
TypedefDecl *D) {
586 Out <<
"__module_private__ ";
591 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
592 Out <<
' ' << *Attrs;
596 Out <<
"using " << *D;
597 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
598 Out <<
' ' << *Attrs;
602void DeclPrinter::VisitEnumDecl(
EnumDecl *D) {
604 Out <<
"__module_private__ ";
613 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
614 Out <<
' ' << *Attrs;
629void DeclPrinter::VisitRecordDecl(
RecordDecl *D) {
631 Out <<
"__module_private__ ";
634 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
635 Out <<
' ' << *Attrs;
640 if (D->isCompleteDefinition()) {
649 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
650 Out <<
' ' << *Attrs;
653 Init->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
660 std::string Proto =
"explicit";
661 llvm::raw_string_ostream EOut(Proto);
675 prettyPrintPragmas(D);
676 if (std::optional<std::string> Attrs =
677 prettyPrintAttributes(D, AttrPosAsWritten::Left))
678 Out << *Attrs <<
' ';
682 Out <<
"template<> ";
685 printTemplateParameters(TPL);
698 llvm_unreachable(
"invalid for functions");
715 SubPolicy.SuppressSpecifiers =
false;
721 llvm::raw_string_ostream
OS(Proto);
730 llvm::raw_string_ostream POut(Proto);
731 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
734 TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(),
nullptr);
737 TArgPrinter.printTemplateArguments(TArgs->asArray(),
nullptr);
741 while (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
742 Proto =
'(' + Proto +
')';
743 Ty = PT->getInnerType();
749 FT = dyn_cast<FunctionProtoType>(AFT);
753 llvm::raw_string_ostream POut(Proto);
754 DeclPrinter ParamPrinter(POut, SubPolicy, Context, Indentation);
755 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
769 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
782 Proto +=
" volatile";
784 Proto +=
" restrict";
811 Proto +=
" noexcept";
814 llvm::raw_string_ostream EOut(Proto);
816 Indentation,
"\n", &Context);
823 PrintConstructorInitializers(CDecl, Proto);
828 Out << Proto <<
" -> ";
831 AFT->getReturnType().print(Out, Policy, Proto);
842 TrailingRequiresClause.ConstraintExpr->printPretty(
843 Out,
nullptr, SubPolicy, Indentation,
"\n", &Context);
846 Ty.
print(Out, Policy, Proto);
849 if (std::optional<std::string> Attrs =
850 prettyPrintAttributes(D, AttrPosAsWritten::Right))
851 Out <<
' ' << *Attrs;
859 M->outputString(Out);
870 DeclPrinter ParamPrinter(Out, SubPolicy, Context, Indentation);
872 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
890void DeclPrinter::VisitFriendDecl(
FriendDecl *D) {
893 for (
unsigned i = 0; i < NumTPLists; ++i)
896 Out << TSI->getType().getAsString(Policy);
901 VisitFunctionDecl(FD);
906 VisitFunctionTemplateDecl(FTD);
911 VisitRedeclarableTemplateDecl(CTD);
918void DeclPrinter::VisitFieldDecl(
FieldDecl *D) {
919 prettyPrintPragmas(D);
924 Out <<
"__module_private__ ";
927 stream(Policy, D->
getName(), Indentation);
941 Init->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
943 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
944 Out <<
' ' << *Attrs;
947void DeclPrinter::VisitLabelDecl(
LabelDecl *D) {
951void DeclPrinter::VisitVarDecl(
VarDecl *D) {
952 prettyPrintPragmas(D);
954 if (std::optional<std::string> Attrs =
955 prettyPrintAttributes(D, AttrPosAsWritten::Left))
956 Out << *Attrs <<
' ';
958 if (
const auto *Param = dyn_cast<ParmVarDecl>(D);
959 Param && Param->isExplicitObjectParameter())
978 Out <<
"_Thread_local ";
981 Out <<
"thread_local ";
986 Out <<
"__module_private__ ";
999 if (std::optional<std::string> Attrs =
1000 prettyPrintAttributes(D, AttrPosAsWritten::Right))
1001 Out <<
' ' << *Attrs;
1005 bool ImplicitInit =
false;
1008 ImplicitInit =
true;
1010 dyn_cast<CXXConstructExpr>(
Init->IgnoreImplicit())) {
1012 !Construct->isListInitialization()) {
1013 ImplicitInit = Construct->getNumArgs() == 0 ||
1014 Construct->getArg(0)->isDefaultArgument();
1017 if (!ImplicitInit) {
1024 SubPolicy.SuppressSpecifiers =
false;
1025 Init->printPretty(Out,
nullptr, SubPolicy, Indentation,
"\n", &Context);
1032void DeclPrinter::VisitParmVarDecl(
ParmVarDecl *D) {
1048void DeclPrinter::VisitImportDecl(
ImportDecl *D) {
1054 Out <<
"static_assert(";
1059 E->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
1071 Out <<
"namespace ";
1076 VisitDeclContext(D);
1081 Out <<
"using namespace ";
1087 Out <<
"namespace " << *D <<
" = ";
1092void DeclPrinter::VisitEmptyDecl(
EmptyDecl *D) {
1093 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
1100 Out <<
"__module_private__ ";
1104 if (std::optional<std::string> Attrs =
1105 prettyPrintAttributes(D, AttrPosAsWritten::Left))
1106 Out << *Attrs <<
' ';
1112 if (
auto *S = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
1114 S->getSpecializedTemplate()->getTemplateParameters();
1116 S->getTemplateArgsAsWritten();
1118 printTemplateArguments(TArgAsWritten->
arguments(), TParams);
1120 printTemplateArguments(S->getTemplateArgs().asArray(), TParams);
1124 if (std::optional<std::string> Attrs =
1125 prettyPrintAttributes(D, AttrPosAsWritten::Right))
1126 Out <<
' ' << *Attrs;
1128 if (D->isCompleteDefinition()) {
1131 if (D->getNumBases()) {
1134 BaseEnd = D->bases_end(); Base != BaseEnd; ++Base) {
1135 if (Base != D->bases_begin())
1138 if (
Base->isVirtual())
1146 Out <<
Base->getType().getAsString(Policy);
1148 if (
Base->isPackExpansion())
1160 VisitDeclContext(D);
1172 "unknown language in linkage specification");
1176 Out <<
"extern \"" << l <<
"\" ";
1179 VisitDeclContext(D);
1186 bool OmitTemplateKW) {
1193 if (!OmitTemplateKW)
1197 bool NeedComma =
false;
1198 for (
const Decl *Param : *Params) {
1199 if (Param->isImplicit())
1207 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
1208 VisitTemplateTypeParmDecl(TTP);
1209 }
else if (
auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
1210 VisitNonTypeTemplateParmDecl(NTTP);
1211 }
else if (
auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1212 VisitTemplateTemplateParmDecl(TTPD);
1218 if (
const Expr *RequiresClause = Params->getRequiresClause()) {
1219 Out <<
" requires ";
1220 RequiresClause->printPretty(Out,
nullptr, Policy, Indentation,
"\n",
1224 if (!OmitTemplateKW)
1231 for (
size_t I = 0, E = Args.size(); I < E; ++I) {
1235 Args[I].print(Policy, Out,
true);
1237 Args[I].print(Policy, Out,
1239 Policy, Params, I));
1247 for (
size_t I = 0, E = Args.size(); I < E; ++I) {
1251 Args[I].getArgument().print(Policy, Out,
true);
1253 Args[I].getArgument().print(
1261void DeclPrinter::VisitTemplateDecl(
const TemplateDecl *D) {
1265 dyn_cast<TemplateTemplateParmDecl>(D)) {
1266 if (TTP->wasDeclaredWithTypename())
1271 if (TTP->isParameterPack())
1273 else if (TTP->getDeclName())
1276 if (TTP->getDeclName()) {
1278 Out << TTP->getIdentifier()->deuglifiedName();
1280 Out << TTP->getDeclName();
1284 else if (
const auto *
Concept = dyn_cast<ConceptDecl>(D)) {
1285 Out <<
"concept " <<
Concept->getName() <<
" = " ;
1286 Concept->getConstraintExpr()->printPretty(Out,
nullptr, Policy, Indentation,
1296 printTemplateParameters(TPL);
1297 VisitRedeclarableTemplateDecl(D);
1301 Out <<
"#pragma omp end declare target\n";
1305 if (PrintInstantiation &&
1309 if (PrevDecl->
isDefined(Def) && Def != PrevDecl)
1316 prettyPrintPragmas(I);
1323 VisitRedeclarableTemplateDecl(D);
1325 if (PrintInstantiation) {
1346 llvm::raw_string_ostream NameOS(Name);
1352 for (
unsigned I = 0; I < *NumArgs; ++I)
1354 printTemplateArgumentList(NameOS, Args, Policy);
1357 if (
auto *RD = dyn_cast<RecordDecl>(Spec)) {
1358 Out << RD->getKindName() <<
" " << Name;
1359 }
else if (
auto *FD = dyn_cast<FunctionDecl>(Spec)) {
1360 FD->getReturnType().
print(Out, Policy);
1361 Out <<
" " << Name <<
"(";
1362 llvm::ListSeparator LS;
1365 P->print(Out, Policy);
1367 if (FD->isVariadic()) {
1373 TSI->getType().print(Out, Policy, Name);
1375 llvm_unreachable(
"unexpected specialization kind");
1379void DeclPrinter::VisitClassTemplateSpecializationDecl(
1381 Out <<
"template<> ";
1382 VisitCXXRecordDecl(D);
1385void DeclPrinter::VisitClassTemplatePartialSpecializationDecl(
1388 VisitCXXRecordDecl(D);
1393 Indentation,
"\n", &Context);
1400void DeclPrinter::PrintObjCMethodType(
ASTContext &Ctx,
1417 if (
auto nullability = AttributedType::stripOuterNullability(T))
1427 unsigned First =
true;
1428 for (
auto *Param : *Params) {
1435 switch (Param->getVariance()) {
1440 Out <<
"__covariant ";
1444 Out <<
"__contravariant ";
1448 Out << Param->getDeclName();
1450 if (Param->hasExplicitBound()) {
1451 Out <<
" : " << Param->getUnderlyingType().getAsString(Policy);
1468 std::string::size_type pos, lastPos = 0;
1471 pos =
name.find_first_of(
':', lastPos);
1474 Out <<
name.substr(lastPos, pos - lastPos) <<
':';
1476 PI->getObjCDeclQualifier(),
1488 if (std::optional<std::string> Attrs = prettyPrintAttributes(OMD))
1489 Out <<
' ' << *Attrs;
1504 bool eolnOut =
false;
1506 Out <<
"@implementation " << I <<
" : " << *SID;
1508 Out <<
"@implementation " << I;
1514 for (
const auto *I : OID->
ivars()) {
1515 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1520 }
else if (SID || !OID->
decls().empty()) {
1524 VisitDeclContext(OID,
false);
1535 Out <<
"@class " << I;
1538 PrintObjCTypeParams(TypeParams);
1544 bool eolnOut =
false;
1545 if (std::optional<std::string> Attrs = prettyPrintAttributes(OID))
1546 Out << *Attrs <<
"\n";
1548 Out <<
"@interface " << I;
1551 PrintObjCTypeParams(TypeParams);
1559 if (!Protocols.
empty()) {
1561 E = Protocols.
end(); I != E; ++I)
1562 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1570 for (
const auto *I : OID->
ivars()) {
1571 Indent() << I->getASTContext()
1572 .getUnqualifiedObjCPointerType(I->getType())
1573 .getAsString(Policy) <<
' ' << *I <<
";\n";
1577 }
else if (SID || !OID->
decls().empty()) {
1582 VisitDeclContext(OID,
false);
1591 Out <<
"@protocol " << *PID <<
";\n";
1596 if (!Protocols.
empty()) {
1597 Out <<
"@protocol " << *PID;
1599 E = Protocols.
end(); I != E; ++I)
1600 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1603 Out <<
"@protocol " << *PID <<
'\n';
1604 VisitDeclContext(PID,
false);
1609 Out <<
"@implementation ";
1613 Out <<
"<<error-type>>";
1614 Out <<
'(' << *PID <<
")\n";
1616 VisitDeclContext(PID,
false);
1622 Out <<
"@interface ";
1626 Out <<
"<<error-type>>";
1628 PrintObjCTypeParams(TypeParams);
1630 Out <<
"(" << *PID <<
")\n";
1631 if (PID->ivar_size() > 0) {
1634 for (
const auto *I : PID->ivars())
1635 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1641 VisitDeclContext(PID,
false);
1648 Out <<
"@compatibility_alias " << *AID
1663 Out <<
"@required\n";
1665 Out <<
"@optional\n";
1674 Out << (first ?
"" :
", ") <<
"class";
1679 Out << (first ?
"" :
", ") <<
"direct";
1685 Out << (first ?
"" :
", ") <<
"nonatomic";
1689 Out << (first ?
"" :
", ") <<
"atomic";
1694 Out << (first ?
"" :
", ") <<
"assign";
1698 Out << (first ?
"" :
", ") <<
"retain";
1703 Out << (first ?
"" :
", ") <<
"strong";
1707 Out << (first ?
"" :
", ") <<
"copy";
1711 Out << (first ?
"" :
", ") <<
"weak";
1716 Out << (first ?
"" :
", ") <<
"unsafe_unretained";
1722 Out << (first ?
"" :
", ") <<
"readwrite";
1726 Out << (first ?
"" :
", ") <<
"readonly";
1731 Out << (first ?
"" :
", ") <<
"getter = ";
1736 Out << (first ?
"" :
", ") <<
"setter = ";
1743 if (
auto nullability = AttributedType::stripOuterNullability(T)) {
1747 Out << (first ?
"" :
", ") <<
"null_resettable";
1749 Out << (first ?
"" :
", ")
1761 Out <<
' ' << TypeStr;
1762 if (!StringRef(TypeStr).ends_with(
"*"))
1771 Out <<
"@synthesize ";
1779void DeclPrinter::VisitUsingDecl(
UsingDecl *D) {
1788 for (
const auto *Shadow : D->
shadows()) {
1789 if (
const auto *ConstructorShadow =
1790 dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1791 assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1792 Out << *ConstructorShadow->getNominatedBaseClass();
1805 Out <<
"using typename ";
1822 Out <<
"#pragma omp threadprivate";
1843 if (std::optional<std::string> Attrs = prettyPrintAttributes(D))
1844 Out <<
' ' << *Attrs;
1847 VisitDeclContext(D);
1852 Out <<
"#pragma omp allocate";
1864 OMPClausePrinter Printer(Out, Policy, Context.
getLangOpts().OpenMP);
1873 Out <<
"#pragma omp requires ";
1875 OMPClausePrinter Printer(Out, Policy, Context.
getLangOpts().OpenMP);
1883 Out <<
"#pragma omp declare reduction (";
1885 const char *OpName =
1887 assert(OpName &&
"not an overloaded operator");
1899 Out <<
" initializer(";
1905 Out <<
"omp_priv = ";
1910 Init->printPretty(Out,
nullptr, Policy, 0,
"\n", &Context);
1920 Out <<
"#pragma omp declare mapper (";
1928 OMPClausePrinter Printer(Out, Policy, Context.
getLangOpts().OpenMP);
1943 TC->print(Out, Policy);
1968void DeclPrinter::VisitNonTypeTemplateParmDecl(
1983void DeclPrinter::VisitTemplateTemplateParmDecl(
1985 VisitTemplateDecl(TTPD);
1995 Out <<
"#pragma acc declare";
1999 Printer.VisitClauseList(D->
clauses());
2005 Out <<
"#pragma acc routine";
2022 Printer.VisitClauseList(D->
clauses());
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A, const Decl *D)
static QualType getDeclType(Decl *D)
static QualType GetBaseType(QualType T)
static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out, PrintingPolicy &Policy, unsigned Indentation, const ASTContext &Context)
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::Module class, which describes a module in the source code.
Defines the SourceManager interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
SourceLocation getLoc() const
shadow_range shadows() const
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ deduction guide declaration.
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
Represents a C++26 expansion statement declaration.
CXXExpansionStmtPattern * getExpansionPattern()
Represents a C++ struct/union/class.
CXXBaseSpecifier * base_class_iterator
Iterator that traverses the base classes of a class.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Declaration of a class template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
spec_range specializations() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
decl_iterator - Iterates through the declarations stored within this context.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
DeclContext(Decl::Kind K)
void dumpDeclContext() const
decl_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
decl_iterator decls_begin() const
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
bool isInvalidDecl() const
SourceLocation getLocation() const
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
AccessSpecifier getAccess() const
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
std::string getAsString() const
Retrieve the human-readable string for this name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TypeSourceInfo * getTypeSourceInfo() const
Represents an empty-declaration.
An instance of this object exists for each enum constant that is defined.
const Expr * getInitExpr() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Represents an explicit instantiation of a template entity in source code.
TypeSourceInfo * getTypeAsWritten() const
The declared type (return type or variable type) for function / variable templates.
std::optional< unsigned > getNumTemplateArgs() const
Returns the number of explicit template arguments, or std::nullopt if this entity has no template arg...
TemplateArgumentLoc getTemplateArg(unsigned I) const
bool isExternTemplate() const
NamedDecl * getSpecialization() const
NestedNameSpecifierLoc getQualifierLoc() const
Returns the qualifier regardless of where it is stored.
Store information needed for an explicit specifier.
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(const FunctionDecl *Function)
bool isSpecified() const
Determine if the declaration had an explicit specifier of any kind.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool isBitField() const
Determines whether this field is a bitfield.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
const Expr * getAsmStringExpr() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
unsigned getFriendTypeNumTemplateParameterLists() const
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
bool isPackExpansion() const
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isImmediateFunction() const
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isConstexprSpecified() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isDeletedAsWritten() const
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
unsigned getNumExceptions() const
Return the number of types in the exception specification.
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
spec_range specializations() const
FunctionType - C99 6.7.5.3 - Function Declarators.
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
One of these records is kept for each identifier that is lexed.
StringRef deuglifiedName() const
If the identifier is an "uglified" reserved name, return a cleaned form.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Represents the declaration of a label.
Represents a linkage specification.
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
Represents a C++ namespace alias.
NamespaceBaseDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Represent a C++ namespace.
bool isInline() const
Returns true if this is an inline namespace declaration.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
This represents 'pragma omp allocate ...' directive.
bool varlist_empty() const
bool clauselist_empty() const
varlist_iterator varlist_begin()
MutableArrayRef< Expr * >::iterator varlist_iterator
clauselist_range clauselists()
varlist_iterator varlist_end()
Pseudo declaration for capturing expressions.
This is a basic class for representing single OpenMP clause.
This represents 'pragma omp declare mapper ...' directive.
clauselist_range clauselists()
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
bool clauselist_empty() const
This represents 'pragma omp declare reduction ...' directive.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
This represents 'pragma omp requires...' directive.
clauselist_iterator clauselist_begin()
bool clauselist_empty() const
clauselist_iterator clauselist_end()
This represents 'pragma omp threadprivate ...' directive.
MutableArrayRef< Expr * >::iterator varlist_iterator
bool varlist_empty() const
varlist_iterator varlist_end()
varlist_iterator varlist_begin()
ObjCCategoryDecl - Represents a category declaration.
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCCompatibleAliasDecl - Represents alias of a class.
const ObjCInterfaceDecl * getClassInterface() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
std::string getNameAsString() const
Get the name of the class associated with this interface.
unsigned ivar_size() const
const ObjCInterfaceDecl * getSuperClass() const
Represents an ObjC class declaration.
unsigned ivar_size() const
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
const ObjCProtocolList & getReferencedProtocols() const
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ObjCInterfaceDecl * getSuperClass() const
ObjCList - This is a simple template class used to hold various lists of decls etc,...
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
ArrayRef< ParmVarDecl * > parameters() const
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
Represents a pointer to an Objective C object.
Represents one property declaration in an Objective-C interface.
Selector getSetterName() const
Selector getGetterName() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
PropertyControl getPropertyImplementation() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
Kind getPropertyImplementation() const
ObjCPropertyDecl * getPropertyDecl() const
Represents an Objective-C protocol declaration.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
const ObjCProtocolList & getReferencedProtocols() const
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
ArrayRef< const OpenACCClause * > clauses() const
const Expr * getFunctionReference() const
Sugar for parentheses used when specifying types.
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Represents a struct/union/class.
Base for LValueReferenceType and RValueReferenceType.
std::string getAsString() const
Derive the full selector name (e.g.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
Encodes a location in the source.
Represents a C++11 static_assert declaration.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
StringLiteral - This represents a string literal expression, e.g.
StringRef getKindName() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
A template argument list.
const TemplateArgument & getArgument() const
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
The base class of all kinds of template declarations (e.g., class, function, etc.).
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
void print(raw_ostream &Out, const ASTContext &Context, bool OmitTemplateKW=false) const
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isParameterPack() const
Returns whether this is a parameter pack.
A declaration that models statements at global scope.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
const T * getAs() const
Member-template getAs<specific type>'.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
Represents a dependent using declaration which was marked with typename.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Represents a dependent using declaration which was not marked with typename.
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Represents C++ using-directive.
NamedDecl * getNominatedNamespaceAsWritten()
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Represents a C++ using-enum-declaration.
EnumDecl * getEnumDecl() const
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
@ CInit
C-style initialization with assignment.
@ CallInit
Call-style initialization (C++98)
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Represents a GCC generic vector type.
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
llvm::StringRef getAccessSpelling(AccessSpecifier AS)
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ ICIS_ListInit
Direct list-initialization.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
StorageClass
Storage classes.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
@ Default
Set to the current date and time.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
@ Concept
The name was classified as a concept name.
llvm::StringRef getAsString(SyncScope S)
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
@ EST_MSAny
Microsoft throw(...) extension.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
ArrayRef< TemplateArgumentLoc > arguments() const
void printName(raw_ostream &OS, PrintingPolicy Policy) const
printName - Print the human-readable name to a stream.
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressDeclAttributes
Whether to suppress attributes in decl printing.
unsigned FullyQualifiedName
When true, print the fully qualified name of function declarations.
unsigned PolishForDeclaration
When true, do certain refinement needed for producing proper declaration tag; such as,...
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned Indentation
The number of spaces to use to indent each line.
unsigned SuppressInitializers
Suppress printing of variable initializers.
unsigned TerseOutput
Provide a 'terse' output.
unsigned PrintAsCanonical
Whether to print entities as written or canonically.