;
29 classDeclPrinter :
public DeclVisitor<DeclPrinter> {
34 boolPrintInstantiation;
36raw_ostream& Indent() {
returnIndent(Indentation); }
37raw_ostream& Indent(
unsignedIndentation);
55 const ASTContext&Context,
unsignedIndentation = 0,
56 boolPrintInstantiation =
false)
57: Out(Out), Policy(Policy), Context(Context), Indentation(Indentation),
58PrintInstantiation(PrintInstantiation) {}
60 voidVisitDeclContext(
DeclContext*DC,
boolIndent =
true);
87 voidVisitClassTemplateSpecializationDecl(
89 voidVisitClassTemplatePartialSpecializationDecl(
116 boolOmitTemplateKW =
false);
123prettyPrintAttributes(
const Decl*
D,
124AttrPosAsWritten Pos = AttrPosAsWritten::Default);
125 voidprettyPrintPragmas(
Decl*
D);
126 voidprintDeclType(
QualType T, StringRef DeclName,
boolPack =
false);
131 boolPrintInstantiation)
const{
136 unsignedIndentation,
boolPrintInstantiation)
const{
137DeclPrinter Printer(Out, Policy,
getASTContext(), Indentation,
139Printer.Visit(
const_cast<Decl*
>(
this));
143 boolOmitTemplateKW)
const{
149 boolOmitTemplateKW)
const{
150DeclPrinter Printer(Out, Policy, Context);
151Printer.printTemplateParameters(
this, OmitTemplateKW);
165 else if(
const ArrayType*ATy = dyn_cast<ArrayType>(BaseType))
166BaseType = ATy->getElementType();
168BaseType = FTy->getReturnType();
170BaseType = VTy->getElementType();
174BaseType = ATy->getDeducedType();
176BaseType = PTy->desugar();
186 returnTDD->getUnderlyingType();
187 if(
ValueDecl* VD = dyn_cast<ValueDecl>(
D))
188 returnVD->getType();
194 unsignedIndentation) {
196(*Begin)->print(Out, Policy, Indentation);
207 boolisFirst =
true;
215 if(!isFirst) Out <<
", ";
220(*Begin)->print(Out, SubPolicy, Indentation);
230 ASTContext&Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
232Printer.VisitDeclContext(
const_cast<DeclContext*
>(
this),
false);
235raw_ostream& DeclPrinter::Indent(
unsignedIndentation) {
236 for(
unsignedi = 0; i != Indentation; ++i)
247 returnDeclPrinter::AttrPosAsWritten::Left;
249 if(
C.getSourceManager().isBeforeInTranslationUnit(ALoc, DLoc))
250 returnDeclPrinter::AttrPosAsWritten::Left;
252 returnDeclPrinter::AttrPosAsWritten::Right;
256boolDeclPrinter::prettyPrintAttributes(
const Decl*
D,
257AttrPosAsWritten Pos
) {
258 boolhasPrinted =
false;
262 for(
auto*A : Attrs) {
263 if(A->isInherited() || A->isImplicit())
268 switch(A->getKind()) {
270#define PRAGMA_SPELLING_ATTR(X) case attr::X: 271#include "clang/Basic/AttrList.inc" 275assert(APos != AttrPosAsWritten::Default &&
276 "Default not a valid for an attribute location");
277 if(Pos == AttrPosAsWritten::Default || Pos == APos) {
278 if(Pos != AttrPosAsWritten::Left)
280A->printPretty(Out, Policy);
282 if(Pos == AttrPosAsWritten::Left)
292voidDeclPrinter::prettyPrintPragmas(
Decl*
D) {
298 for(
auto*A : Attrs) {
299 switch(A->getKind()) {
301#define PRAGMA_SPELLING_ATTR(X) case attr::X: 302#include "clang/Basic/AttrList.inc" 303A->printPretty(Out, Policy);
313voidDeclPrinter::printDeclType(
QualType T, StringRef DeclName,
boolPack) {
319 T= PET->getPattern();
321 T.print(Out, Policy, (Pack ?
"...":
"") + DeclName, Indentation);
334 if(AccessSpelling.empty())
335llvm_unreachable(
"No access specifier!");
336Out << AccessSpelling;
340std::string &Proto) {
341 boolHasInitializerList =
false;
342 for(
const auto*BMInitializer : CDecl->
inits()) {
343 if(BMInitializer->isInClassMemberInitializer())
345 if(!BMInitializer->isWritten())
348 if(!HasInitializerList) {
352HasInitializerList =
true;
356 if(BMInitializer->isAnyMemberInitializer()) {
357 FieldDecl*FD = BMInitializer->getAnyMember();
359}
else if(BMInitializer->isDelegatingInitializer()) {
365 if(
Expr*
Init= BMInitializer->getInit()) {
366 boolOutParens = !isa<InitListExpr>(
Init);
372 Init= Tmp->getSubExpr();
376 Expr*SimpleInit =
nullptr;
377 Expr**Args =
nullptr;
378 unsignedNumArgs = 0;
380Args = ParenList->getExprs();
381NumArgs = ParenList->getNumExprs();
383dyn_cast<CXXConstructExpr>(
Init)) {
384Args = Construct->getArgs();
385NumArgs = Construct->getNumArgs();
390SimpleInit->
printPretty(Out,
nullptr, Policy, Indentation,
"\n",
393 for(
unsignedI = 0; I != NumArgs; ++I) {
394assert(Args[I] !=
nullptr&&
"Expected non-null Expr");
395 if(isa<CXXDefaultArgExpr>(Args[I]))
400Args[I]->
printPretty(Out,
nullptr, Policy, Indentation,
"\n",
411 if(BMInitializer->isPackExpansion())
420voidDeclPrinter::VisitDeclContext(
DeclContext*DC,
boolIndent) {
433 if(isa<ObjCIvarDecl>(*
D))
442 if(
autoFD = dyn_cast<FunctionDecl>(*
D))
444!isa<ClassTemplateSpecializationDecl>(DC))
460 if(!Decls.empty() && !CurDeclType.
isNull()) {
462 if(!BaseType.
isNull() && isa<ElaboratedType>(BaseType) &&
463cast<ElaboratedType>(BaseType)->getOwnedTagDecl() == Decls[0]) {
464Decls.push_back(*
D);
471ProcessDeclGroup(Decls);
475 if(isa<TagDecl>(*
D) && !cast<TagDecl>(*D)->isFreeStanding()) {
476Decls.push_back(*
D);
480 if(isa<AccessSpecDecl>(*
D)) {
493 const char*Terminator =
nullptr;
494 if(isa<OMPThreadPrivateDecl>(*
D) || isa<OMPDeclareReductionDecl>(*
D) ||
495isa<OMPDeclareMapperDecl>(*
D) || isa<OMPRequiresDecl>(*
D) ||
496isa<OMPAllocateDecl>(*
D))
497Terminator =
nullptr;
498 else if(isa<ObjCMethodDecl>(*
D) && cast<ObjCMethodDecl>(*D)->hasBody())
499Terminator =
nullptr;
500 else if(
autoFD = dyn_cast<FunctionDecl>(*
D)) {
501 if(FD->doesThisDeclarationHaveABody() && !FD->isDefaulted())
502Terminator =
nullptr;
505}
else if(
autoTD = dyn_cast<FunctionTemplateDecl>(*
D)) {
506 if(TD->getTemplatedDecl()->doesThisDeclarationHaveABody())
507Terminator =
nullptr;
513Terminator =
nullptr;
514 else if(isa<EnumConstantDecl>(*
D)) {
525((isa<FunctionDecl>(*
D) &&
526cast<FunctionDecl>(*D)->doesThisDeclarationHaveABody()) ||
527(isa<FunctionTemplateDecl>(*
D) &&
528cast<FunctionTemplateDecl>(*D)->getTemplatedDecl()->doesThisDeclarationHaveABody())))
535 if(
D->
hasAttr<OMPDeclareTargetDeclAttr>())
536Out <<
"#pragma omp end declare target\n";
540ProcessDeclGroup(Decls);
547VisitDeclContext(
D,
false);
555Out <<
"__module_private__ ";
557 QualTypeTy =
D->getTypeSourceInfo()->getType();
558Ty.
print(Out, Policy,
D->getName(), Indentation);
559prettyPrintAttributes(
D);
563Out <<
"using "<< *
D;
564prettyPrintAttributes(
D);
565Out <<
" = "<<
D->getTypeSourceInfo()->getType().getAsString(Policy);
568voidDeclPrinter::VisitEnumDecl(
EnumDecl*
D) {
570Out <<
"__module_private__ ";
572 if(
D->isScoped()) {
573 if(
D->isScopedUsingClassTag())
579prettyPrintAttributes(
D);
581 if(
D->getDeclName())
582Out <<
' '<<
D->getDeclName();
585Out <<
" : "<<
D->getIntegerType().stream(Policy);
587 if(
D->isCompleteDefinition()) {
589VisitDeclContext(
D);
594voidDeclPrinter::VisitRecordDecl(
RecordDecl*
D) {
596Out <<
"__module_private__ ";
597Out <<
D->getKindName();
599prettyPrintAttributes(
D);
601 if(
D->getIdentifier())
604 if(
D->isCompleteDefinition()) {
606VisitDeclContext(
D);
613prettyPrintAttributes(
D);
616 Init->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
623std::string Proto =
"explicit";
624llvm::raw_string_ostream EOut(Proto);
637llvm::raw_ostream &Out) {
646 if(!
D->getDescribedFunctionTemplate() &&
647!
D->isFunctionTemplateSpecialization()) {
648prettyPrintPragmas(
D);
649prettyPrintAttributes(
D, AttrPosAsWritten::Left);
652 if(
D->isFunctionTemplateSpecialization())
653Out <<
"template<> ";
654 else if(!
D->getDescribedFunctionTemplate()) {
655 for(
unsignedI = 0, NumTemplateParams =
D->getNumTemplateParameterLists();
656I < NumTemplateParams; ++I)
657printTemplateParameters(
D->getTemplateParameterList(I));
664 switch(
D->getStorageClass()) {
666 case SC_Extern: Out <<
"extern ";
break;
667 case SC_Static: Out <<
"static ";
break;
670llvm_unreachable(
"invalid for functions");
673 if(
D->isInlineSpecified()) Out <<
"inline ";
674 if(
D->isVirtualAsWritten()) Out <<
"virtual ";
676 if(
D->isConstexprSpecified() && !
D->isExplicitlyDefaulted())
677Out <<
"constexpr ";
678 if(
D->isConsteval()) Out <<
"consteval ";
679 else if(
D->isImmediateFunction())
680Out <<
"immediate ";
687SubPolicy.SuppressSpecifiers =
false;
691Proto +=
D->getQualifiedNameAsString();
693llvm::raw_string_ostream OS(Proto);
696NS->print(OS, Policy);
699 D->getNameInfo().printName(OS, Policy);
704 if(
D->isFunctionTemplateSpecialization()) {
705llvm::raw_string_ostream POut(Proto);
706DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
707 const auto*TArgAsWritten =
D->getTemplateSpecializationArgsAsWritten();
709TArgPrinter.printTemplateArguments(TArgAsWritten->arguments(),
nullptr);
711 D->getTemplateSpecializationArgs())
712TArgPrinter.printTemplateArguments(TArgs->asArray(),
nullptr);
716 while(
const ParenType*PT = dyn_cast<ParenType>(Ty)) {
717Proto =
'('+ Proto +
')';
718Ty = PT->getInnerType();
723 if(
D->hasWrittenPrototype())
724FT = dyn_cast<FunctionProtoType>(AFT);
728llvm::raw_string_ostream POut(Proto);
729DeclPrinter ParamPrinter(POut, SubPolicy, Context, Indentation);
730 for(
unsignedi = 0, e =
D->getNumParams(); i != e; ++i) {
731 if(i) POut <<
", ";
732ParamPrinter.VisitParmVarDecl(
D->getParamDecl(i));
736 if(
D->getNumParams()) POut <<
", ";
738}
else if(!
D->getNumParams() && !Context.
getLangOpts().CPlusPlus) {
743}
else if(
D->doesThisDeclarationHaveABody() && !
D->hasPrototype()) {
744 for(
unsignedi = 0, e =
D->getNumParams(); i != e; ++i) {
747Proto +=
D->getParamDecl(i)->getNameAsString();
757Proto +=
" volatile";
759Proto +=
" restrict";
786Proto +=
" noexcept";
789llvm::raw_string_ostream EOut(Proto);
791Indentation,
"\n", &Context);
798PrintConstructorInitializers(CDecl, Proto);
799}
else if(!ConversionDecl && !isa<CXXDestructorDecl>(
D)) {
803Out << Proto <<
" -> ";
810AFT->getReturnType().print(Out, Policy, Proto);
815 if(
Expr*TrailingRequiresClause =
D->getTrailingRequiresClause()) {
816Out <<
" requires ";
817TrailingRequiresClause->printPretty(Out,
nullptr, SubPolicy, Indentation,
821Ty.
print(Out, Policy, Proto);
824prettyPrintAttributes(
D, AttrPosAsWritten::Right);
826 if(
D->isPureVirtual())
828 else if(
D->isDeletedAsWritten()) {
832M->outputString(Out);
835}
else if(
D->isExplicitlyDefaulted())
836Out <<
" = default";
837 else if(
D->doesThisDeclarationHaveABody()) {
839 if(!
D->hasPrototype() &&
D->getNumParams()) {
843DeclPrinter ParamPrinter(Out, SubPolicy, Context, Indentation);
845 for(
unsignedi = 0, e =
D->getNumParams(); i != e; ++i) {
847ParamPrinter.VisitParmVarDecl(
D->getParamDecl(i));
857 if(!Policy.
TerseOutput&& isa<CXXConstructorDecl>(*
D))
863voidDeclPrinter::VisitFriendDecl(
FriendDecl*
D) {
865 unsignedNumTPLists =
D->getFriendTypeNumTemplateParameterLists();
866 for(
unsignedi = 0; i < NumTPLists; ++i)
867printTemplateParameters(
D->getFriendTypeTemplateParameterList(i));
869Out << TSI->getType().getAsString(Policy);
872dyn_cast<FunctionDecl>(
D->getFriendDecl())) {
874VisitFunctionDecl(FD);
877dyn_cast<FunctionTemplateDecl>(
D->getFriendDecl())) {
879VisitFunctionTemplateDecl(FTD);
882dyn_cast<ClassTemplateDecl>(
D->getFriendDecl())) {
884VisitRedeclarableTemplateDecl(CTD);
887 if(
D->isPackExpansion())
891voidDeclPrinter::VisitFieldDecl(
FieldDecl*
D) {
896Out <<
"__module_private__ ";
899stream(Policy,
D->getName(), Indentation);
901 if(
D->isBitField()) {
903 D->getBitWidth()->printPretty(Out,
nullptr, Policy, Indentation,
"\n",
907 Expr*
Init=
D->getInClassInitializer();
913 Init->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
915prettyPrintAttributes(
D);
918voidDeclPrinter::VisitLabelDecl(
LabelDecl*
D) {
922voidDeclPrinter::VisitVarDecl(
VarDecl*
D) {
923prettyPrintPragmas(
D);
925prettyPrintAttributes(
D, AttrPosAsWritten::Left);
927 if(
const auto*Param = dyn_cast<ParmVarDecl>(
D);
928Param && Param->isExplicitObjectParameter())
932?
D->getTypeSourceInfo()->getType()
940 switch(
D->getTSCSpec()) {
947Out <<
"_Thread_local ";
950Out <<
"thread_local ";
955Out <<
"__module_private__ ";
957 if(
D->isConstexpr()) {
958Out <<
"constexpr ";
959 T.removeLocalConst();
969?
D->getIdentifier()->deuglifiedName()
972prettyPrintAttributes(
D, AttrPosAsWritten::Right);
976 boolImplicitInit =
false;
977 if(
D->isCXXForRangeDecl()) {
979ImplicitInit =
true;
981dyn_cast<CXXConstructExpr>(
Init->IgnoreImplicit())) {
983!Construct->isListInitialization()) {
984ImplicitInit = Construct->getNumArgs() == 0 ||
985Construct->getArg(0)->isDefaultArgument();
995SubPolicy.SuppressSpecifiers =
false;
996SubPolicy.IncludeTagDefinition =
false;
997 Init->printPretty(Out,
nullptr, SubPolicy, Indentation,
"\n", &Context);
1010 D->getAsmString()->printPretty(Out,
nullptr, Policy, Indentation,
"\n",
1016assert(
D->getStmt());
1017 D->getStmt()->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
1020voidDeclPrinter::VisitImportDecl(
ImportDecl*
D) {
1021Out <<
"@import "<<
D->getImportedModule()->getFullModuleName()
1026Out <<
"static_assert(";
1027 D->getAssertExpr()->printPretty(Out,
nullptr, Policy, Indentation,
"\n",
1029 if(
Expr*
E=
D->getMessage()) {
1031 E->
printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
1040 if(
D->isInline())
1043Out <<
"namespace ";
1044 if(
D->getDeclName())
1045Out <<
D->getDeclName() <<
' ';
1048VisitDeclContext(
D);
1053Out <<
"using namespace ";
1054 if(
D->getQualifier())
1055 D->getQualifier()->
print(Out, Policy);
1056Out << *
D->getNominatedNamespaceAsWritten();
1060Out <<
"namespace "<< *
D<<
" = ";
1061 if(
D->getQualifier())
1062 D->getQualifier()->
print(Out, Policy);
1063Out << *
D->getAliasedNamespace();
1066voidDeclPrinter::VisitEmptyDecl(
EmptyDecl*
D) {
1067prettyPrintAttributes(
D);
1073Out <<
"__module_private__ ";
1075Out <<
D->getKindName() <<
' ';
1079 if(prettyPrintAttributes(
D, AttrPosAsWritten::Left))
1082 if(
D->getIdentifier()) {
1083 if(
auto*NNS =
D->getQualifier())
1084NNS->print(Out, Policy);
1087 if(
auto*S = dyn_cast<ClassTemplateSpecializationDecl>(
D)) {
1089S->getSpecializedTemplate()->getTemplateParameters();
1091S->getTemplateArgsAsWritten();
1093printTemplateArguments(TArgAsWritten->
arguments(), TParams);
1095printTemplateArguments(S->getTemplateArgs().asArray(), TParams);
1099prettyPrintAttributes(
D, AttrPosAsWritten::Right);
1101 if(
D->isCompleteDefinition()) {
1104 if(
D->getNumBases()) {
1107BaseEnd =
D->bases_end();
Base!= BaseEnd; ++
Base) {
1108 if(
Base!=
D->bases_begin())
1111 if(
Base->isVirtual())
1119Out <<
Base->getType().getAsString(Policy);
1121 if(
Base->isPackExpansion())
1133VisitDeclContext(
D);
1145 "unknown language in linkage specification");
1149Out <<
"extern \""<< l <<
"\" ";
1150 if(
D->hasBraces()) {
1152VisitDeclContext(
D);
1155Visit(*
D->decls_begin());
1159 boolOmitTemplateKW) {
1166 if(!OmitTemplateKW)
1167Out <<
"template ";
1170 boolNeedComma =
false;
1171 for(
const Decl*Param : *Params) {
1172 if(Param->isImplicit())
1180 if(
const auto*TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
1181VisitTemplateTypeParmDecl(TTP);
1182}
else if(
autoNTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
1183VisitNonTypeTemplateParmDecl(NTTP);
1184}
else if(
autoTTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1185VisitTemplateDecl(TTPD);
1192 if(
const Expr*RequiresClause = Params->getRequiresClause()) {
1193Out <<
" requires ";
1194RequiresClause->printPretty(Out,
nullptr, Policy, Indentation,
"\n",
1198 if(!OmitTemplateKW)
1205 for(
size_tI = 0,
E= Args.size(); I <
E; ++I) {
1209Args[I].print(Policy, Out,
true);
1211Args[I].print(Policy, Out,
1213Policy, Params, I));
1221 for(
size_tI = 0,
E= Args.size(); I <
E; ++I) {
1225Args[I].getArgument().print(Policy, Out,
true);
1227Args[I].getArgument().print(
1235voidDeclPrinter::VisitTemplateDecl(
const TemplateDecl*
D) {
1236printTemplateParameters(
D->getTemplateParameters());
1239dyn_cast<TemplateTemplateParmDecl>(
D)) {
1240 if(TTP->wasDeclaredWithTypename())
1245 if(TTP->isParameterPack())
1247 else if(TTP->getDeclName())
1250 if(TTP->getDeclName()) {
1252Out << TTP->getIdentifier()->deuglifiedName();
1254Out << TTP->getDeclName();
1256}
else if(
auto*TD =
D->getTemplatedDecl())
1258 else if(
const auto*Concept = dyn_cast<ConceptDecl>(
D)) {
1259Out <<
"concept "<<
Concept->getName() <<
" = ";
1260 Concept->getConstraintExpr()->printPretty(Out,
nullptr, Policy, Indentation,
1266prettyPrintPragmas(
D->getTemplatedDecl());
1270I < NumTemplateParams; ++I)
1273VisitRedeclarableTemplateDecl(
D);
1276 if(
D->getTemplatedDecl()->
hasAttr<OMPDeclareTargetDeclAttr>())
1277Out <<
"#pragma omp end declare target\n";
1281 if(PrintInstantiation &&
1282!isa<CXXDeductionGuideDecl>(
D->getTemplatedDecl())) {
1285 if(PrevDecl->
isDefined(Def) && Def != PrevDecl)
1287 for(
auto*I :
D->specializations())
1292prettyPrintPragmas(I);
1299VisitRedeclarableTemplateDecl(
D);
1301 if(PrintInstantiation) {
1302 for(
auto*I :
D->specializations())
1304 if(
D->isThisDeclarationADefinition())
1313voidDeclPrinter::VisitClassTemplateSpecializationDecl(
1315Out <<
"template<> ";
1316VisitCXXRecordDecl(
D);
1319voidDeclPrinter::VisitClassTemplatePartialSpecializationDecl(
1321printTemplateParameters(
D->getTemplateParameters());
1322VisitCXXRecordDecl(
D);
1329voidDeclPrinter::PrintObjCMethodType(
ASTContext&Ctx,
1356 unsigned First=
true;
1357 for(
auto*Param : *Params) {
1364 switch(Param->getVariance()) {
1369Out <<
"__covariant ";
1373Out <<
"__contravariant ";
1377Out << Param->getDeclName();
1379 if(Param->hasExplicitBound()) {
1380Out <<
" : "<< Param->getUnderlyingType().getAsString(Policy);
1397std::string::size_type pos, lastPos = 0;
1398 for(
const auto*PI : OMD->
parameters()) {
1400pos =
name.find_first_of(
':', lastPos);
1403Out <<
name.substr(lastPos, pos - lastPos) <<
':';
1405PI->getObjCDeclQualifier(),
1417prettyPrintAttributes(OMD);
1432 booleolnOut =
false;
1434Out <<
"@implementation "<< I <<
" : "<< *SID;
1436Out <<
"@implementation "<< I;
1442 for(
const auto*I : OID->
ivars()) {
1443Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1453VisitDeclContext(OID,
false);
1464Out <<
"@class "<< I;
1467PrintObjCTypeParams(TypeParams);
1473 booleolnOut =
false;
1475prettyPrintAttributes(OID);
1479Out <<
"@interface "<< I;
1482PrintObjCTypeParams(TypeParams);
1490 if(!Protocols.
empty()) {
1492 E= Protocols.
end(); I !=
E; ++I)
1493Out << (I == Protocols.
begin() ?
'<':
',') << **I;
1501 for(
const auto*I : OID->
ivars()) {
1502Indent() << I->getASTContext()
1503.getUnqualifiedObjCPointerType(I->getType())
1504.getAsString(Policy) <<
' '<< *I <<
";\n";
1514VisitDeclContext(OID,
false);
1523Out <<
"@protocol "<< *PID <<
";\n";
1528 if(!Protocols.
empty()) {
1529Out <<
"@protocol "<< *PID;
1531 E= Protocols.
end(); I !=
E; ++I)
1532Out << (I == Protocols.
begin() ?
'<':
',') << **I;
1535Out <<
"@protocol "<< *PID <<
'\n';
1536VisitDeclContext(PID,
false);
1541Out <<
"@implementation ";
1545Out <<
"<<error-type>>";
1546Out <<
'('<< *PID <<
")\n";
1548VisitDeclContext(PID,
false);
1554Out <<
"@interface ";
1558Out <<
"<<error-type>>";
1560PrintObjCTypeParams(TypeParams);
1562Out <<
"("<< *PID <<
")\n";
1563 if(PID->ivar_size() > 0) {
1566 for(
const auto*I : PID->ivars())
1567Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1573VisitDeclContext(PID,
false);
1580Out <<
"@compatibility_alias "<< *AID
1595Out <<
"@required\n";
1597Out <<
"@optional\n";
1601Out <<
"@property";
1606Out << (first ?
"":
", ") <<
"class";
1611Out << (first ?
"":
", ") <<
"direct";
1617Out << (first ?
"":
", ") <<
"nonatomic";
1621Out << (first ?
"":
", ") <<
"atomic";
1626Out << (first ?
"":
", ") <<
"assign";
1630Out << (first ?
"":
", ") <<
"retain";
1635Out << (first ?
"":
", ") <<
"strong";
1639Out << (first ?
"":
", ") <<
"copy";
1643Out << (first ?
"":
", ") <<
"weak";
1648Out << (first ?
"":
", ") <<
"unsafe_unretained";
1654Out << (first ?
"":
", ") <<
"readwrite";
1658Out << (first ?
"":
", ") <<
"readonly";
1663Out << (first ?
"":
", ") <<
"getter = ";
1668Out << (first ?
"":
", ") <<
"setter = ";
1679Out << (first ?
"":
", ") <<
"null_resettable";
1681Out << (first ?
"":
", ")
1693Out <<
' '<< TypeStr;
1694 if(!StringRef(TypeStr).ends_with(
"*"))
1703Out <<
"@synthesize ";
1705Out <<
"@dynamic ";
1711voidDeclPrinter::VisitUsingDecl(
UsingDecl*
D) {
1712 if(!
D->isAccessDeclaration())
1714 if(
D->hasTypename())
1715Out <<
"typename ";
1716 D->getQualifier()->
print(Out, Policy);
1720 for(
const auto*Shadow :
D->shadows()) {
1721 if(
const auto*ConstructorShadow =
1722dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1723assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1724Out << *ConstructorShadow->getNominatedBaseClass();
1732Out <<
"using enum "<<
D->getEnumDecl();
1737Out <<
"using typename ";
1738 D->getQualifier()->
print(Out, Policy);
1739Out <<
D->getDeclName();
1743 if(!
D->isAccessDeclaration())
1745 D->getQualifier()->
print(Out, Policy);
1746Out <<
D->getDeclName();
1754Out <<
"#pragma omp threadprivate";
1755 if(!
D->varlist_empty()) {
1757 E=
D->varlist_end();
1759Out << (I ==
D->varlist_begin() ?
'(':
',');
1760 NamedDecl*ND = cast<DeclRefExpr>(*I)->getDecl();
1768 if(
D->isCBuffer())
1775prettyPrintAttributes(
D);
1778VisitDeclContext(
D);
1783Out <<
"#pragma omp allocate";
1784 if(!
D->varlist_empty()) {
1786 E=
D->varlist_end();
1788Out << (I ==
D->varlist_begin() ?
'(':
',');
1789 NamedDecl*ND = cast<DeclRefExpr>(*I)->getDecl();
1794 if(!
D->clauselist_empty()) {
1804Out <<
"#pragma omp requires ";
1805 if(!
D->clauselist_empty()) {
1807 for(
autoI =
D->clauselist_begin(),
E=
D->clauselist_end(); I !=
E; ++I)
1814Out <<
"#pragma omp declare reduction (";
1816 const char*OpName =
1818assert(OpName &&
"not an overloaded operator");
1821assert(
D->getDeclName().isIdentifier());
1822 D->printName(Out, Policy);
1825 D->getType().
print(Out, Policy);
1827 D->getCombiner()->printPretty(Out,
nullptr, Policy, 0,
"\n", &Context);
1829 if(
auto*
Init=
D->getInitializer()) {
1830Out <<
" initializer(";
1831 switch(
D->getInitializerKind()) {
1833Out <<
"omp_priv(";
1836Out <<
"omp_priv = ";
1841 Init->printPretty(Out,
nullptr, Policy, 0,
"\n", &Context);
1851Out <<
"#pragma omp declare mapper (";
1852 D->printName(Out, Policy);
1854 D->getType().
print(Out, Policy);
1856Out <<
D->getVarName();
1858 if(!
D->clauselist_empty()) {
1860 for(
auto*
C:
D->clauselists()) {
1869 D->getInit()->printPretty(Out,
nullptr, Policy, Indentation,
"\n", &Context);
1874TC->
print(Out, Policy);
1899voidDeclPrinter::VisitNonTypeTemplateParmDecl(
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 MaybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy, QualType T, llvm::raw_ostream &Out)
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
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a base class of a C++ class.
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++ struct/union/class.
Declaration of a class template.
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
void dumpDeclContext() const
decl_iterator decls_end() const
decl_iterator decls_begin() const
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
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.
TemplateParameterList * getTemplateParameterList(unsigned index) const
unsigned getNumTemplateParameterLists() const
Represents an empty-declaration.
An instance of this object exists for each enum constant that is defined.
Store information needed for an explicit specifier.
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(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.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Represents a function declaration or definition.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
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.
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...
Represents the declaration of a label.
Represents a linkage specification.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
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...
Represents a C++ namespace alias.
Represent a C++ namespace.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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.
MutableArrayRef< Expr * >::iterator varlist_iterator
Pseudo declaration for capturing expressions.
This is a basic class for representing single OpenMP clause.
This represents '#pragma omp declare mapper ...' directive.
This represents '#pragma omp declare reduction ...' directive.
This represents '#pragma omp requires...' directive.
This represents '#pragma omp threadprivate ...' directive.
MutableArrayRef< Expr * >::iterator varlist_iterator
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
param_const_iterator param_end() const
param_const_iterator param_begin() 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...
Represents a pack expansion of types.
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
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.
Represents the declaration of a struct/union/class/enum.
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.).
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.
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 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.
bool isStructureType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
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.
Represents a dependent using declaration which was marked with typename.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
Represents C++ using-directive.
Represents a C++ using-enum-declaration.
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.
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)
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...
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
The JSON file list parser is used to communicate input to InstallAPI.
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 (&&).
StorageClass
Storage classes.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
const FunctionProtoType * T
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.
@ EST_MSAny
Microsoft throw(...) extension.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned FullyQualifiedName
When true, print the fully qualified name of function declarations.
unsigned PrintCanonicalTypes
Whether to print types as written or canonically.
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 SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
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 IncludeTagDefinition
When true, include the body of a tag definition.
unsigned TerseOutput
Provide a 'terse' output.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4