24 #include "llvm/Support/raw_ostream.h"
25 using namespace clang;
28 class DeclPrinter :
public DeclVisitor<DeclPrinter> {
32 bool PrintInstantiation;
35 raw_ostream&
Indent(
unsigned Indentation);
51 unsigned Indentation = 0,
bool PrintInstantiation =
false)
52 : Out(Out), Policy(Policy), Indentation(Indentation),
53 PrintInstantiation(PrintInstantiation) { }
81 void VisitClassTemplateSpecializationDecl(
83 void VisitClassTemplatePartialSpecializationDecl(
105 void prettyPrintAttributes(
Decl *D);
106 void prettyPrintPragmas(
Decl *D);
107 void printDeclType(
QualType T, StringRef DeclName,
bool Pack =
false);
112 bool PrintInstantiation)
const {
117 unsigned Indentation,
bool PrintInstantiation)
const {
118 DeclPrinter Printer(Out, Policy, Indentation, PrintInstantiation);
119 Printer.Visit(const_cast<Decl*>(
this));
126 if (isa<TypedefType>(BaseType))
132 else if (
const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
133 BaseType = ATy->getElementType();
135 BaseType = FTy->getReturnType();
137 BaseType = VTy->getElementType();
141 BaseType = ATy->getDeducedType();
143 llvm_unreachable(
"Unknown declarator!");
150 return TDD->getUnderlyingType();
151 if (
ValueDecl* VD = dyn_cast<ValueDecl>(D))
152 return VD->getType();
158 unsigned Indentation) {
160 (*Begin)->print(Out, Policy, Indentation);
179 if (!isFirst) Out <<
", ";
184 (*Begin)->print(Out, SubPolicy, Indentation);
194 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
196 Printer.VisitDeclContext(const_cast<DeclContext *>(
this),
false);
200 for (
unsigned i = 0; i != Indentation; ++i)
205 void DeclPrinter::prettyPrintAttributes(
Decl *D) {
206 if (Policy.PolishForDeclaration)
211 for (
auto *A : Attrs) {
212 switch (A->getKind()) {
214 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
215 #include "clang/Basic/AttrList.inc"
218 A->printPretty(Out, Policy);
225 void DeclPrinter::prettyPrintPragmas(
Decl *D) {
226 if (Policy.PolishForDeclaration)
231 for (
auto *A : Attrs) {
232 switch (A->getKind()) {
234 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
235 #include "clang/Basic/AttrList.inc"
236 A->printPretty(Out, Policy);
246 void DeclPrinter::printDeclType(
QualType T, StringRef DeclName,
bool Pack) {
252 T = PET->getPattern();
254 T.
print(Out, Policy, (Pack ?
"..." :
"") + DeclName, Indentation);
267 case AS_none: llvm_unreachable(
"No access specifier!");
279 if (Policy.TerseOutput)
283 Indentation += Policy.Indentation;
291 if (isa<ObjCIvarDecl>(*D))
300 if (
auto FD = dyn_cast<FunctionDecl>(*D))
302 !isa<ClassTemplateSpecializationDecl>(DC))
314 if (!Decls.empty() && !CurDeclType.
isNull()) {
316 if (!BaseType.
isNull() && isa<ElaboratedType>(BaseType))
317 BaseType = cast<ElaboratedType>(BaseType)->getNamedType();
318 if (!BaseType.
isNull() && isa<TagType>(BaseType) &&
319 cast<TagType>(BaseType)->getDecl() == Decls[0]) {
327 ProcessDeclGroup(Decls);
331 if (isa<TagDecl>(*D) && !cast<TagDecl>(*D)->getIdentifier()) {
336 if (isa<AccessSpecDecl>(*D)) {
337 Indentation -= Policy.Indentation;
341 Indentation += Policy.Indentation;
349 const char *Terminator =
nullptr;
350 if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D))
351 Terminator =
nullptr;
352 else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody())
353 Terminator =
nullptr;
354 else if (
auto FD = dyn_cast<FunctionDecl>(*D)) {
355 if (FD->isThisDeclarationADefinition())
356 Terminator =
nullptr;
359 }
else if (
auto TD = dyn_cast<FunctionTemplateDecl>(*D)) {
360 if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
361 Terminator =
nullptr;
364 }
else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) ||
365 isa<ObjCImplementationDecl>(*D) ||
366 isa<ObjCInterfaceDecl>(*D) ||
367 isa<ObjCProtocolDecl>(*D) ||
368 isa<ObjCCategoryImplDecl>(*D) ||
369 isa<ObjCCategoryDecl>(*D))
370 Terminator =
nullptr;
371 else if (isa<EnumConstantDecl>(*D)) {
381 if (!Policy.TerseOutput &&
382 ((isa<FunctionDecl>(*D) &&
383 cast<FunctionDecl>(*D)->doesThisDeclarationHaveABody()) ||
384 (isa<FunctionTemplateDecl>(*D) &&
385 cast<FunctionTemplateDecl>(*D)->getTemplatedDecl()->doesThisDeclarationHaveABody())))
392 if (D->
hasAttr<OMPDeclareTargetDeclAttr>())
393 Out <<
"#pragma omp end declare target\n";
397 ProcessDeclGroup(Decls);
400 Indentation -= Policy.Indentation;
404 VisitDeclContext(D,
false);
407 void DeclPrinter::VisitTypedefDecl(
TypedefDecl *D) {
408 if (!Policy.SuppressSpecifiers) {
412 Out <<
"__module_private__ ";
416 prettyPrintAttributes(D);
420 Out <<
"using " << *D;
421 prettyPrintAttributes(D);
422 Out <<
" = " << D->getTypeSourceInfo()->getType().getAsString(Policy);
425 void DeclPrinter::VisitEnumDecl(
EnumDecl *D) {
427 Out <<
"__module_private__ ";
437 if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
440 if (D->isCompleteDefinition()) {
445 prettyPrintAttributes(D);
448 void DeclPrinter::VisitRecordDecl(
RecordDecl *D) {
450 Out <<
"__module_private__ ";
453 prettyPrintAttributes(D);
467 prettyPrintAttributes(D);
468 if (
Expr *Init = D->getInitExpr()) {
470 Init->printPretty(Out,
nullptr, Policy, Indentation);
477 prettyPrintPragmas(D);
480 Out <<
"template<> ";
483 I < NumTemplateParams; ++
I)
490 if (!Policy.SuppressSpecifiers) {
497 llvm_unreachable(
"invalid for functions");
505 (ConversionDecl && ConversionDecl->isExplicitSpecified()) ||
506 (GuideDecl && GuideDecl->isExplicitSpecified()))
511 SubPolicy.SuppressSpecifiers =
false;
513 if (!Policy.SuppressScope) {
515 llvm::raw_string_ostream OS(Proto);
516 NS->print(OS, Policy);
521 Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
523 llvm::raw_string_ostream POut(Proto);
524 DeclPrinter TArgPrinter(POut, SubPolicy, Indentation);
525 TArgPrinter.printTemplateArguments(*TArgs);
529 while (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
530 Proto =
'(' + Proto +
')';
531 Ty = PT->getInnerType();
537 FT = dyn_cast<FunctionProtoType>(AFT);
541 llvm::raw_string_ostream POut(Proto);
542 DeclPrinter ParamPrinter(POut, SubPolicy, Indentation);
543 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
553 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
566 Proto +=
" volatile";
568 Proto +=
" restrict";
595 Proto +=
" noexcept";
598 llvm::raw_string_ostream EOut(Proto);
608 bool HasInitializerList =
false;
609 for (
const auto *BMInitializer : CDecl->
inits()) {
610 if (BMInitializer->isInClassMemberInitializer())
613 if (!HasInitializerList) {
617 HasInitializerList =
true;
621 if (BMInitializer->isAnyMemberInitializer()) {
622 FieldDecl *FD = BMInitializer->getAnyMember();
625 Out <<
QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
629 if (!BMInitializer->getInit()) {
632 Expr *Init = BMInitializer->getInit();
634 Init = Tmp->getSubExpr();
638 Expr *SimpleInit =
nullptr;
639 Expr **Args =
nullptr;
640 unsigned NumArgs = 0;
641 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
642 Args = ParenList->getExprs();
643 NumArgs = ParenList->getNumExprs();
645 = dyn_cast<CXXConstructExpr>(Init)) {
646 Args = Construct->getArgs();
647 NumArgs = Construct->getNumArgs();
652 SimpleInit->
printPretty(Out,
nullptr, Policy, Indentation);
654 for (
unsigned I = 0;
I != NumArgs; ++
I) {
655 assert(Args[
I] !=
nullptr &&
"Expected non-null Expr");
656 if (isa<CXXDefaultArgExpr>(Args[
I]))
661 Args[
I]->
printPretty(Out,
nullptr, Policy, Indentation);
666 if (BMInitializer->isPackExpansion())
669 }
else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
673 Out << Proto <<
" -> ";
676 AFT->getReturnType().print(Out, Policy, Proto);
681 Ty.
print(Out, Policy, Proto);
684 prettyPrintAttributes(D);
693 if (!Policy.TerseOutput) {
698 DeclPrinter ParamPrinter(Out, SubPolicy, Indentation);
699 Indentation += Policy.Indentation;
700 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
705 Indentation -= Policy.Indentation;
712 if (isa<CXXConstructorDecl>(*D))
718 void DeclPrinter::VisitFriendDecl(
FriendDecl *D) {
721 for (
unsigned i = 0; i < NumTPLists; ++i)
724 Out <<
" " << TSI->getType().getAsString(Policy);
729 VisitFunctionDecl(FD);
734 VisitFunctionTemplateDecl(FTD);
739 VisitRedeclarableTemplateDecl(CTD);
743 void DeclPrinter::VisitFieldDecl(
FieldDecl *D) {
745 if (!Policy.SuppressSpecifiers && D->
isMutable())
748 Out <<
"__module_private__ ";
751 stream(Policy, D->
getName(), Indentation);
759 if (!Policy.SuppressInitializers && Init) {
764 Init->
printPretty(Out,
nullptr, Policy, Indentation);
766 prettyPrintAttributes(D);
769 void DeclPrinter::VisitLabelDecl(
LabelDecl *D) {
773 void DeclPrinter::VisitVarDecl(
VarDecl *D) {
774 prettyPrintPragmas(D);
780 if (!Policy.SuppressSpecifiers) {
792 Out <<
"_Thread_local ";
795 Out <<
"thread_local ";
800 Out <<
"__module_private__ ";
808 printDeclType(T, D->
getName());
810 if (!Policy.SuppressInitializers && Init) {
811 bool ImplicitInit =
false;
813 dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
815 !Construct->isListInitialization()) {
816 ImplicitInit = Construct->getNumArgs() == 0 ||
827 SubPolicy.SuppressSpecifiers =
false;
828 SubPolicy.IncludeTagDefinition =
false;
829 Init->printPretty(Out,
nullptr, SubPolicy, Indentation);
834 prettyPrintAttributes(D);
837 void DeclPrinter::VisitParmVarDecl(
ParmVarDecl *D) {
847 void DeclPrinter::VisitImportDecl(
ImportDecl *D) {
853 Out <<
"static_assert(";
857 SL->printPretty(Out,
nullptr, Policy, Indentation);
868 Out <<
"namespace " << *D <<
" {\n";
874 Out <<
"using namespace ";
881 Out <<
"namespace " << *D <<
" = ";
882 if (D->getQualifier())
884 Out << *D->getAliasedNamespace();
887 void DeclPrinter::VisitEmptyDecl(
EmptyDecl *D) {
888 prettyPrintAttributes(D);
894 Out <<
"__module_private__ ";
897 prettyPrintAttributes(D);
902 if (
auto S = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
903 printTemplateArguments(
S->getTemplateArgs(),
S->getTemplateParameters());
904 else if (
auto S = dyn_cast<ClassTemplateSpecializationDecl>(D))
905 printTemplateArguments(
S->getTemplateArgs());
908 if (D->isCompleteDefinition()) {
910 if (D->getNumBases()) {
913 BaseEnd = D->bases_end();
Base != BaseEnd; ++
Base) {
914 if (
Base != D->bases_begin())
917 if (
Base->isVirtual())
925 Out <<
Base->getType().getAsString(Policy);
927 if (
Base->isPackExpansion())
934 if (Policy.TerseOutput) {
950 "unknown language in linkage specification");
954 Out <<
"extern \"" << l <<
"\" ";
968 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
973 if (
auto TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
975 if (TTP->wasDeclaredWithTypename())
980 if (TTP->isParameterPack())
985 if (TTP->hasDefaultArgument()) {
987 Out << TTP->getDefaultArgument().getAsString(Policy);
989 }
else if (
auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
992 Name = II->getName();
993 printDeclType(NTTP->getType(),
Name, NTTP->isParameterPack());
995 if (NTTP->hasDefaultArgument()) {
997 NTTP->getDefaultArgument()->printPretty(Out,
nullptr, Policy,
1000 }
else if (
auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1001 VisitTemplateDecl(TTPD);
1012 for (
size_t I = 0,
E = Args.
size();
I <
E; ++
I) {
1019 auto P = cast<TemplateTypeParmDecl>(Params->
getParam(T->getIndex()));
1025 if (
auto TD = dyn_cast<TemplateTemplateParmDecl>(T)) {
1026 auto P = cast<TemplateTemplateParmDecl>(
1033 if (
auto E = dyn_cast<DeclRefExpr>(A.
getAsExpr()))
1034 if (
auto N = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl())) {
1035 auto P = cast<NonTypeTemplateParmDecl>(
1042 A.
print(Policy, Out);
1047 void DeclPrinter::VisitTemplateDecl(
const TemplateDecl *D) {
1051 dyn_cast<TemplateTemplateParmDecl>(D)) {
1053 if (TTP->isParameterPack())
1066 I < NumTemplateParams; ++
I)
1069 VisitRedeclarableTemplateDecl(D);
1073 if (PrintInstantiation &&
1077 if (PrevDecl->
isDefined(Def) && Def != PrevDecl)
1084 prettyPrintPragmas(
I);
1091 VisitRedeclarableTemplateDecl(D);
1093 if (PrintInstantiation) {
1104 void DeclPrinter::VisitClassTemplateSpecializationDecl(
1106 Out <<
"template<> ";
1107 VisitCXXRecordDecl(D);
1110 void DeclPrinter::VisitClassTemplatePartialSpecializationDecl(
1113 VisitCXXRecordDecl(D);
1120 void DeclPrinter::PrintObjCMethodType(
ASTContext &Ctx,
1124 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
1126 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Inout)
1128 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Out)
1130 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Bycopy)
1132 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Byref)
1134 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway)
1136 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) {
1147 unsigned First =
true;
1148 for (
auto *Param : *Params) {
1155 switch (Param->getVariance()) {
1160 Out <<
"__covariant ";
1164 Out <<
"__contravariant ";
1168 Out << Param->getDeclName().getAsString();
1170 if (Param->hasExplicitBound()) {
1171 Out <<
" : " << Param->getUnderlyingType().getAsString(Policy);
1188 std::string::size_type pos, lastPos = 0;
1191 pos = name.find_first_of(
':', lastPos);
1194 Out << name.substr(lastPos, pos - lastPos) <<
':';
1196 PI->getObjCDeclQualifier(),
1208 prettyPrintAttributes(OMD);
1210 if (OMD->
getBody() && !Policy.TerseOutput) {
1214 else if (Policy.PolishForDeclaration)
1222 bool eolnOut =
false;
1224 Out <<
"@implementation " << I <<
" : " << *SID;
1226 Out <<
"@implementation " <<
I;
1231 Indentation += Policy.Indentation;
1232 for (
const auto *I : OID->
ivars()) {
1233 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1234 getAsString(Policy) <<
' ' << *I <<
";\n";
1236 Indentation -= Policy.Indentation;
1243 VisitDeclContext(OID,
false);
1254 Out <<
"@class " <<
I;
1257 PrintObjCTypeParams(TypeParams);
1263 bool eolnOut =
false;
1264 Out <<
"@interface " <<
I;
1267 PrintObjCTypeParams(TypeParams);
1275 if (!Protocols.
empty()) {
1277 E = Protocols.
end(); I !=
E; ++
I)
1278 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1285 Indentation += Policy.Indentation;
1286 for (
const auto *I : OID->
ivars()) {
1287 Indent() << I->getASTContext()
1288 .getUnqualifiedObjCPointerType(I->getType())
1289 .getAsString(Policy) <<
' ' << *I <<
";\n";
1291 Indentation -= Policy.Indentation;
1299 VisitDeclContext(OID,
false);
1308 Out <<
"@protocol " << *PID <<
";\n";
1313 if (!Protocols.
empty()) {
1314 Out <<
"@protocol " << *PID;
1316 E = Protocols.
end(); I !=
E; ++
I)
1317 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1320 Out <<
"@protocol " << *PID <<
'\n';
1321 VisitDeclContext(PID,
false);
1328 VisitDeclContext(PID,
false);
1336 PrintObjCTypeParams(TypeParams);
1338 Out <<
"(" << *PID <<
")\n";
1339 if (PID->ivar_size() > 0) {
1341 Indentation += Policy.Indentation;
1342 for (
const auto *I : PID->ivars())
1343 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1344 getAsString(Policy) <<
' ' << *I <<
";\n";
1345 Indentation -= Policy.Indentation;
1349 VisitDeclContext(PID,
false);
1356 Out <<
"@compatibility_alias " << *AID
1364 Out <<
"@required\n";
1366 Out <<
"@optional\n";
1376 Out << (first ?
' ' :
',') <<
"readonly";
1381 Out << (first ?
' ' :
',') <<
"getter = ";
1386 Out << (first ?
' ' :
',') <<
"setter = ";
1392 Out << (first ?
' ' :
',') <<
"assign";
1398 Out << (first ?
' ' :
',') <<
"readwrite";
1403 Out << (first ?
' ' :
',') <<
"retain";
1408 Out << (first ?
' ' :
',') <<
"strong";
1413 Out << (first ?
' ' :
',') <<
"copy";
1419 Out << (first ?
' ' :
',') <<
"nonatomic";
1424 Out << (first ?
' ' :
',') <<
"atomic";
1434 Out << (first ?
' ' :
',') <<
"null_resettable";
1436 Out << (first ?
' ' :
',')
1444 Out << (first ?
' ' :
',') <<
"class";
1452 getAsString(Policy) <<
' ' << *PDecl;
1453 if (Policy.PolishForDeclaration)
1459 Out <<
"@synthesize ";
1467 void DeclPrinter::VisitUsingDecl(
UsingDecl *D) {
1476 for (
const auto *Shadow : D->
shadows()) {
1477 if (
const auto *ConstructorShadow =
1478 dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1479 assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1480 Out << *ConstructorShadow->getNominatedBaseClass();
1489 Out <<
"using typename ";
1506 Out <<
"#pragma omp threadprivate";
1512 NamedDecl *ND = cast<NamedDecl>(cast<DeclRefExpr>(*I)->getDecl());
1521 Out <<
"#pragma omp declare reduction (";
1525 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1527 #include "clang/Basic/OperatorKinds.def"
1529 const char *OpName =
1531 assert(OpName &&
"not an overloaded operator");
1543 Out <<
" initializer(";
1544 Init->printPretty(Out,
nullptr, Policy, 0);
param_const_iterator param_begin() const
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0) const
Defines the clang::ASTContext interface.
QualType getExceptionType(unsigned i) const
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
ObjCInterfaceDecl * getClassInterface()
bool isBitField() const
Determines whether this field is a bitfield.
spec_range specializations() const
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
PropertyControl getPropertyImplementation() const
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
The template argument is an expression, and we've not resolved it to one of the other forms yet...
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
Represents a C++11 auto or C++14 decltype(auto) type.
std::string getAsString() const
Represents an empty-declaration.
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
Represents a call to a C++ constructor.
NamedDecl * getParam(unsigned Idx)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
Expr * getAsExpr() const
Retrieve the template argument as an expression.
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Represents a C++ constructor within a class.
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
InClassInitStyle getInClassInitStyle() const
getInClassInitStyle - Get the kind of (C++11) in-class initializer which this field has...
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
AccessSpecifier getAccess() const
ObjCMethodDecl - Represents an instance or class method declaration.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
decl_iterator decls_end() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Kind getPropertyImplementation() const
unsigned ivar_size() const
RecordDecl - Represents a struct/union/class.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
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 isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
unsigned getFriendTypeNumTemplateParameterLists() const
StringLiteral * getMessage()
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 ...
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
bool isExplicitSpecified() const
Whether this function is marked as explicit explicitly.
std::string getNameAsString() const
Get the name of the class associated with this interface.
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.
bool isPure() const
Whether this virtual function is pure, i.e.
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool varlist_empty() const
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Represents a C++ using-declaration.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
An lvalue ref-qualifier was provided (&).
static QualType getDeclType(Decl *D)
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isInline() const
Returns true if this is an inline namespace declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Microsoft throw(...) extension.
virtual void printName(raw_ostream &os) const
Whether values of this type can be null is (explicitly) unspecified.
NamedDecl * getNominatedNamespaceAsWritten()
Expr * getNoexceptExpr() const
Selector getSetterName() const
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Represents an Objective-C protocol declaration.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Represents an ObjC class declaration.
Represents a linkage specification.
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
ObjCDeclQualifier getObjCDeclQualifier() const
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
MutableArrayRef< Expr * >::iterator varlist_iterator
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...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
bool isDeletedAsWritten() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ObjCIvarDecl * getPropertyIvarDecl() const
bool IncludeTagDefinition
When true, include the body of a tag definition.
Expr * getBitWidth() const
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
static QualType GetBaseType(QualType T)
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
StorageClass
Storage classes.
bool isInstanceMethod() const
bool hasTrailingReturn() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Represents a GCC generic vector type.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a C++ deduction guide declaration.
unsigned ivar_size() const
Represents a C++ conversion function within a class.
This template specialization was implicitly instantiated from a template.
shadow_range shadows() const
TypeSourceInfo * getTypeSourceInfo() const
const clang::PrintingPolicy & getPrintingPolicy() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
param_const_iterator param_end() const
ArrayRef< ParmVarDecl * > parameters() const
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Sugar for parentheses used when specifying types.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
This represents '#pragma omp declare reduction ...' directive.
Pseudo declaration for capturing expressions.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
const ObjCInterfaceDecl * getClassInterface() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
bool SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration...
TagDecl - Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
LabelDecl - Represents the declaration of a label.
Represents a dependent using declaration which was not marked with typename.
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
varlist_iterator varlist_begin()
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
C-style initialization with assignment.
ObjCCategoryDecl - Represents a category declaration.
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
const ObjCInterfaceDecl * getClassInterface() const
Direct list-initialization.
ThreadStorageClassSpecifier getTSCSpec() const
std::string getAsString() const
Derive the full selector name (e.g.
Represents one property declaration in an Objective-C interface.
A simple visitor class that helps create declaration visitors.
QualType getReturnType() const
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
Represents a C++11 static_assert declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
An rvalue ref-qualifier was provided (&&).
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.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a pack expansion of types.
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.
Base class for declarations which introduce a typedef-name.
Represents a template argument.
const ObjCProtocolList & getReferencedProtocols() const
QualType getAsType() const
Retrieve the type for a type template argument.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
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').
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 isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
bool isInvalidDecl() const
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
bool hasWrittenPrototype() const
Represents a dependent using declaration which was marked with typename.
Selector getGetterName() const
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Selector getSelector() const
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
spec_range specializations() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
const T * getAs() const
Member-template getAs<specific type>'.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Base for LValueReferenceType and RValueReferenceType.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
const ObjCProtocolList & getReferencedProtocols() const
The template argument is a type.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Represents a base class of a C++ class.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
A template argument list.
ObjCPropertyDecl * getPropertyDecl() const
varlist_iterator varlist_end()
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Call-style initialization (C++98)
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
The template argument is a template name that was provided for a template template parameter...
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
Declaration of a class template.
void dumpDeclContext() const
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
StringLiteral - This represents a string literal expression, e.g.
ObjCInterfaceDecl * getSuperClass() const
TranslationUnitDecl - The top declaration context.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TemplateParameterList * getTemplateParameterList(unsigned index) const
StringRef getKindName() const
NamedDecl - This represents a decl with a name.
DeclarationNameInfo getNameInfo() const
Represents a C++ namespace alias.
Represents C++ using-directive.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
TypeSourceInfo * getTypeSourceInfo() const
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
This represents '#pragma omp threadprivate ...' directive.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
The parameter is invariant: must match exactly.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
Declaration of a template function.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
ObjCCompatibleAliasDecl - Represents alias of a class.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
unsigned getNumTemplateParameterLists() const
unsigned getNumExceptions() const
const ObjCInterfaceDecl * getSuperClass() const
const StringLiteral * getAsmString() const