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) { }
98 void prettyPrintAttributes(
Decl *D);
99 void prettyPrintPragmas(
Decl *D);
100 void printDeclType(
QualType T, StringRef DeclName,
bool Pack =
false);
105 bool PrintInstantiation)
const {
110 unsigned Indentation,
bool PrintInstantiation)
const {
111 DeclPrinter Printer(Out, Policy, Indentation, PrintInstantiation);
112 Printer.Visit(const_cast<Decl*>(
this));
119 if (isa<TypedefType>(BaseType))
125 else if (
const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
126 BaseType = ATy->getElementType();
128 BaseType = FTy->getReturnType();
130 BaseType = VTy->getElementType();
134 llvm_unreachable(
"Unknown declarator!");
141 return TDD->getUnderlyingType();
142 if (
ValueDecl* VD = dyn_cast<ValueDecl>(D))
143 return VD->getType();
149 unsigned Indentation) {
151 (*Begin)->print(Out, Policy, Indentation);
162 TD->
print(Out, Policy, Indentation);
168 for ( ; Begin !=
End; ++Begin) {
173 if (!isFirst) Out <<
", ";
177 (*Begin)->print(Out, SubPolicy, Indentation);
187 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
189 Printer.VisitDeclContext(const_cast<DeclContext *>(
this),
false);
193 for (
unsigned i = 0; i != Indentation; ++i)
198 void DeclPrinter::prettyPrintAttributes(
Decl *D) {
199 if (Policy.PolishForDeclaration)
204 for (
auto *A : Attrs) {
205 switch (A->getKind()) {
207 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
208 #include "clang/Basic/AttrList.inc"
211 A->printPretty(Out, Policy);
218 void DeclPrinter::prettyPrintPragmas(
Decl *D) {
219 if (Policy.PolishForDeclaration)
224 for (
auto *A : Attrs) {
225 switch (A->getKind()) {
227 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
228 #include "clang/Basic/AttrList.inc"
229 A->printPretty(Out, Policy);
239 void DeclPrinter::printDeclType(
QualType T, StringRef DeclName,
bool Pack) {
245 T = PET->getPattern();
247 T.
print(Out, Policy, (Pack ?
"..." :
"") + DeclName);
260 case AS_none: llvm_unreachable(
"No access specifier!");
272 if (Policy.TerseOutput)
276 Indentation += Policy.Indentation;
284 if (isa<ObjCIvarDecl>(*D))
300 if (!Decls.empty() && !CurDeclType.
isNull()) {
302 if (!BaseType.
isNull() && isa<ElaboratedType>(BaseType))
303 BaseType = cast<ElaboratedType>(BaseType)->getNamedType();
304 if (!BaseType.
isNull() && isa<TagType>(BaseType) &&
305 cast<TagType>(BaseType)->getDecl() == Decls[0]) {
313 ProcessDeclGroup(Decls);
317 if (isa<TagDecl>(*D) && !cast<TagDecl>(*D)->getIdentifier()) {
322 if (isa<AccessSpecDecl>(*D)) {
323 Indentation -= Policy.Indentation;
327 Indentation += Policy.Indentation;
335 const char *Terminator =
nullptr;
336 if (isa<OMPThreadPrivateDecl>(*D))
337 Terminator =
nullptr;
338 else if (isa<FunctionDecl>(*D) &&
339 cast<FunctionDecl>(*D)->isThisDeclarationADefinition())
340 Terminator =
nullptr;
341 else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->getBody())
342 Terminator =
nullptr;
343 else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) ||
344 isa<ObjCImplementationDecl>(*D) ||
345 isa<ObjCInterfaceDecl>(*D) ||
346 isa<ObjCProtocolDecl>(*D) ||
347 isa<ObjCCategoryImplDecl>(*D) ||
348 isa<ObjCCategoryDecl>(*D))
349 Terminator =
nullptr;
350 else if (isa<EnumConstantDecl>(*D)) {
364 ProcessDeclGroup(Decls);
367 Indentation -= Policy.Indentation;
371 VisitDeclContext(D,
false);
374 void DeclPrinter::VisitTypedefDecl(
TypedefDecl *D) {
375 if (!Policy.SuppressSpecifiers) {
379 Out <<
"__module_private__ ";
382 prettyPrintAttributes(D);
386 Out <<
"using " << *D;
387 prettyPrintAttributes(D);
388 Out <<
" = " << D->getTypeSourceInfo()->getType().getAsString(Policy);
391 void DeclPrinter::VisitEnumDecl(
EnumDecl *D) {
393 Out <<
"__module_private__ ";
406 if (D->isCompleteDefinition()) {
411 prettyPrintAttributes(D);
414 void DeclPrinter::VisitRecordDecl(
RecordDecl *D) {
416 Out <<
"__module_private__ ";
419 prettyPrintAttributes(D);
433 if (
Expr *Init = D->getInitExpr()) {
435 Init->printPretty(Out,
nullptr, Policy, Indentation);
442 prettyPrintPragmas(D);
446 if (!Policy.SuppressSpecifiers) {
453 llvm_unreachable(
"invalid for functions");
461 (ConversionDecl && ConversionDecl->isExplicit()))
466 SubPolicy.SuppressSpecifiers =
false;
470 while (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
471 Proto =
'(' + Proto +
')';
472 Ty = PT->getInnerType();
478 FT = dyn_cast<FunctionProtoType>(AFT);
482 llvm::raw_string_ostream POut(Proto);
483 DeclPrinter ParamPrinter(POut, SubPolicy, Indentation);
484 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
494 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
507 Proto +=
" volatile";
509 Proto +=
" restrict";
536 Proto +=
" noexcept";
539 llvm::raw_string_ostream EOut(Proto);
549 bool HasInitializerList =
false;
550 for (
const auto *BMInitializer : CDecl->
inits()) {
551 if (BMInitializer->isInClassMemberInitializer())
554 if (!HasInitializerList) {
558 HasInitializerList =
true;
562 if (BMInitializer->isAnyMemberInitializer()) {
563 FieldDecl *FD = BMInitializer->getAnyMember();
566 Out <<
QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
570 if (!BMInitializer->getInit()) {
573 Expr *Init = BMInitializer->getInit();
575 Init = Tmp->getSubExpr();
579 Expr *SimpleInit =
nullptr;
580 Expr **Args =
nullptr;
582 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
583 Args = ParenList->getExprs();
584 NumArgs = ParenList->getNumExprs();
586 = dyn_cast<CXXConstructExpr>(Init)) {
587 Args = Construct->getArgs();
588 NumArgs = Construct->getNumArgs();
593 SimpleInit->printPretty(Out,
nullptr, Policy, Indentation);
596 assert(Args[
I] !=
nullptr &&
"Expected non-null Expr");
597 if (isa<CXXDefaultArgExpr>(Args[
I]))
602 Args[
I]->printPretty(Out,
nullptr, Policy, Indentation);
607 if (BMInitializer->isPackExpansion())
610 }
else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
612 Out <<
"auto " << Proto <<
" -> ";
615 AFT->getReturnType().print(Out, Policy, Proto);
620 Ty.
print(Out, Policy, Proto);
623 prettyPrintAttributes(D);
636 DeclPrinter ParamPrinter(Out, SubPolicy, Indentation);
637 Indentation += Policy.Indentation;
638 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
643 Indentation -= Policy.Indentation;
648 D->
getBody()->printPretty(Out,
nullptr, SubPolicy, Indentation);
653 void DeclPrinter::VisitFriendDecl(
FriendDecl *D) {
656 for (
unsigned i = 0; i < NumTPLists; ++i)
659 Out <<
" " << TSI->getType().getAsString(Policy);
664 VisitFunctionDecl(FD);
669 VisitFunctionTemplateDecl(FTD);
674 VisitRedeclarableTemplateDecl(CTD);
678 void DeclPrinter::VisitFieldDecl(
FieldDecl *D) {
680 if (!Policy.SuppressSpecifiers && D->
isMutable())
683 Out <<
"__module_private__ ";
690 D->
getBitWidth()->printPretty(Out,
nullptr, Policy, Indentation);
694 if (!Policy.SuppressInitializers && Init) {
699 Init->printPretty(Out,
nullptr, Policy, Indentation);
701 prettyPrintAttributes(D);
704 void DeclPrinter::VisitLabelDecl(
LabelDecl *D) {
708 void DeclPrinter::VisitVarDecl(
VarDecl *D) {
709 prettyPrintPragmas(D);
710 if (!Policy.SuppressSpecifiers) {
722 Out <<
"_Thread_local ";
725 Out <<
"thread_local ";
730 Out <<
"__module_private__ ";
736 printDeclType(T, D->
getName());
738 if (!Policy.SuppressInitializers && Init) {
739 bool ImplicitInit =
false;
741 dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
743 !Construct->isListInitialization()) {
744 ImplicitInit = Construct->getNumArgs() == 0 ||
754 Init->printPretty(Out,
nullptr, Policy, Indentation);
759 prettyPrintAttributes(D);
762 void DeclPrinter::VisitParmVarDecl(
ParmVarDecl *D) {
768 D->
getAsmString()->printPretty(Out,
nullptr, Policy, Indentation);
772 void DeclPrinter::VisitImportDecl(
ImportDecl *D) {
778 Out <<
"static_assert(";
779 D->
getAssertExpr()->printPretty(Out,
nullptr, Policy, Indentation);
782 SL->printPretty(Out,
nullptr, Policy, Indentation);
793 Out <<
"namespace " << *D <<
" {\n";
799 Out <<
"using namespace ";
806 Out <<
"namespace " << *D <<
" = ";
807 if (D->getQualifier())
809 Out << *D->getAliasedNamespace();
812 void DeclPrinter::VisitEmptyDecl(
EmptyDecl *D) {
813 prettyPrintAttributes(D);
819 Out <<
"__module_private__ ";
822 prettyPrintAttributes(D);
836 if (
Base->isVirtual())
844 Out <<
Base->getType().getAsString(Policy);
846 if (
Base->isPackExpansion())
865 "unknown language in linkage specification");
869 Out <<
"extern \"" << l <<
"\" ";
881 assert(!Args || Params->
size() == Args->
size());
885 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
891 dyn_cast<TemplateTypeParmDecl>(Param)) {
893 if (TTP->wasDeclaredWithTypename())
898 if (TTP->isParameterPack())
906 }
else if (TTP->hasDefaultArgument()) {
908 Out << TTP->getDefaultArgument().getAsString(Policy);
911 dyn_cast<NonTypeTemplateParmDecl>(Param)) {
915 printDeclType(NTTP->getType(),
Name, NTTP->isParameterPack());
920 }
else if (NTTP->hasDefaultArgument()) {
922 NTTP->getDefaultArgument()->printPretty(Out,
nullptr, Policy,
926 dyn_cast<TemplateTemplateParmDecl>(Param)) {
927 VisitTemplateDecl(TTPD);
935 void DeclPrinter::VisitTemplateDecl(
const TemplateDecl *D) {
939 dyn_cast<TemplateTemplateParmDecl>(D)) {
941 if (TTP->isParameterPack())
950 if (PrintInstantiation) {
953 prettyPrintPragmas(
I);
954 PrintTemplateParameters(Params,
I->getTemplateSpecializationArgs());
960 return VisitRedeclarableTemplateDecl(D);
964 if (PrintInstantiation) {
967 PrintTemplateParameters(Params, &
I->getTemplateArgs());
973 return VisitRedeclarableTemplateDecl(D);
980 void DeclPrinter::PrintObjCMethodType(
ASTContext &Ctx,
984 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
986 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Inout)
988 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Out)
990 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Bycopy)
992 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Byref)
994 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway)
996 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) {
1007 unsigned First =
true;
1008 for (
auto *Param : *Params) {
1015 switch (Param->getVariance()) {
1020 Out <<
"__covariant ";
1024 Out <<
"__contravariant ";
1028 Out << Param->getDeclName().getAsString();
1030 if (Param->hasExplicitBound()) {
1031 Out <<
" : " << Param->getUnderlyingType().getAsString(Policy);
1048 std::string::size_type pos, lastPos = 0;
1049 for (
const auto *PI : OMD->
params()) {
1051 pos = name.find_first_of(
':', lastPos);
1052 Out <<
" " << name.substr(lastPos, pos - lastPos) <<
':';
1054 PI->getObjCDeclQualifier(),
1066 prettyPrintAttributes(OMD);
1068 if (OMD->
getBody() && !Policy.TerseOutput) {
1070 OMD->
getBody()->printPretty(Out,
nullptr, Policy);
1072 else if (Policy.PolishForDeclaration)
1080 bool eolnOut =
false;
1082 Out <<
"@implementation " << I <<
" : " << *SID;
1084 Out <<
"@implementation " <<
I;
1089 Indentation += Policy.Indentation;
1090 for (
const auto *I : OID->
ivars()) {
1091 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1092 getAsString(Policy) <<
' ' << *I <<
";\n";
1094 Indentation -= Policy.Indentation;
1101 VisitDeclContext(OID,
false);
1112 Out <<
"@class " <<
I;
1115 PrintObjCTypeParams(TypeParams);
1121 bool eolnOut =
false;
1122 Out <<
"@interface " <<
I;
1125 PrintObjCTypeParams(TypeParams);
1133 if (!Protocols.
empty()) {
1135 E = Protocols.
end(); I !=
E; ++
I)
1136 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1143 Indentation += Policy.Indentation;
1144 for (
const auto *I : OID->
ivars()) {
1145 Indent() << I->getASTContext()
1146 .getUnqualifiedObjCPointerType(I->getType())
1147 .getAsString(Policy) <<
' ' << *I <<
";\n";
1149 Indentation -= Policy.Indentation;
1157 VisitDeclContext(OID,
false);
1166 Out <<
"@protocol " << *PID <<
";\n";
1171 if (!Protocols.
empty()) {
1172 Out <<
"@protocol " << *PID;
1174 E = Protocols.
end(); I !=
E; ++
I)
1175 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1178 Out <<
"@protocol " << *PID <<
'\n';
1179 VisitDeclContext(PID,
false);
1186 VisitDeclContext(PID,
false);
1194 PrintObjCTypeParams(TypeParams);
1196 Out <<
"(" << *PID <<
")\n";
1197 if (PID->ivar_size() > 0) {
1199 Indentation += Policy.Indentation;
1200 for (
const auto *I : PID->ivars())
1201 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1202 getAsString(Policy) <<
' ' << *I <<
";\n";
1203 Indentation -= Policy.Indentation;
1207 VisitDeclContext(PID,
false);
1214 Out <<
"@compatibility_alias " << *AID
1222 Out <<
"@required\n";
1224 Out <<
"@optional\n";
1234 Out << (first ?
' ' :
',') <<
"readonly";
1239 Out << (first ?
' ' :
',') <<
"getter = ";
1244 Out << (first ?
' ' :
',') <<
"setter = ";
1250 Out << (first ?
' ' :
',') <<
"assign";
1256 Out << (first ?
' ' :
',') <<
"readwrite";
1261 Out << (first ?
' ' :
',') <<
"retain";
1266 Out << (first ?
' ' :
',') <<
"strong";
1271 Out << (first ?
' ' :
',') <<
"copy";
1277 Out << (first ?
' ' :
',') <<
"nonatomic";
1282 Out << (first ?
' ' :
',') <<
"atomic";
1292 Out << (first ?
' ' :
',') <<
"null_resettable";
1294 Out << (first ?
' ' :
',')
1305 getAsString(Policy) <<
' ' << *PDecl;
1306 if (Policy.PolishForDeclaration)
1312 Out <<
"@synthesize ";
1320 void DeclPrinter::VisitUsingDecl(
UsingDecl *D) {
1331 Out <<
"using typename ";
1348 Out <<
"#pragma omp threadprivate";
1354 NamedDecl *ND = cast<NamedDecl>(cast<DeclRefExpr>(*I)->getDecl());
param_const_iterator param_begin() 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...
void VisitVarDecl(VarDecl *VD)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
PointerType - C99 6.7.5.1 - Pointer Declarators.
void VisitImportDecl(ImportDecl *D)
A (possibly-)qualified type.
void VisitUsingDecl(UsingDecl *D)
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.
void VisitFieldDecl(FieldDecl *FD)
PropertyControl getPropertyImplementation() const
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D)
FunctionType - C99 6.7.5.3 - Function Declarators.
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...
void VisitEnumConstantDecl(EnumConstantDecl *ECD)
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
std::string getAsString() const
void VisitObjCCategoryDecl(ObjCCategoryDecl *D)
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)
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
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...
void VisitStaticAssertDecl(StaticAssertDecl *D)
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.
void VisitClassTemplateDecl(ClassTemplateDecl *D)
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
void VisitTypeAliasDecl(TypeAliasDecl *TD)
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.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
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.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
unsigned getFriendTypeNumTemplateParameterLists() const
StringLiteral * getMessage()
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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
Determine whether this constructor declaration has the explicit keyword specified.
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.
bool varlist_empty() const
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD)
void VisitLabelDecl(LabelDecl *LD)
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.
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
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.
Whether values of this type can be null is (explicitly) unspecified.
NamedDecl * getNominatedNamespaceAsWritten()
void VisitCXXRecordDecl(CXXRecordDecl *D)
Expr * getNoexceptExpr() const
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
Selector getSetterName() const
DeclID VisitTemplateDecl(TemplateDecl *D)
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
base_class_iterator bases_begin()
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 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.
void VisitParmVarDecl(ParmVarDecl *PD)
ObjCDeclQualifier getObjCDeclQualifier() const
void VisitLinkageSpecDecl(LinkageSpecDecl *D)
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...
void VisitUsingShadowDecl(UsingShadowDecl *D)
void VisitFriendDecl(FriendDecl *D)
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
bool isDeletedAsWritten() const
Declaration of a template type parameter.
ObjCIvarDecl * getPropertyIvarDecl() const
Expr * getBitWidth() const
void VisitTypedefDecl(TypedefDecl *TD)
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
const ParmVarDecl * getParamDecl(unsigned i) const
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
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.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine()) const
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.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
unsigned ivar_size() const
Represents a C++ conversion function within a class.
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
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.
void VisitObjCProtocolDecl(ObjCProtocolDecl *D)
param_const_iterator param_end() 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...
bool SuppressTag
Whether type printing should skip printing the actual tag type.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
const ObjCInterfaceDecl * getClassInterface() const
void VisitEmptyDecl(EmptyDecl *D)
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
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()
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.
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
QualType getReturnType() const
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
void VisitRecordDecl(RecordDecl *RD)
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.
void VisitEnumDecl(EnumDecl *ED)
Base class for declarations which introduce a typedef-name.
const ObjCProtocolList & getReferencedProtocols() const
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.).
void VisitFunctionDecl(FunctionDecl *FD)
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.
void VisitObjCMethodDecl(ObjCMethodDecl *D)
Selector getGetterName() const
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
void VisitObjCImplementationDecl(ObjCImplementationDecl *D)
Selector getSelector() const
EnumDecl - Represents an enum.
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D)
detail::InMemoryDirectory::const_iterator E
spec_range specializations() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void VisitObjCPropertyDecl(ObjCPropertyDecl *D)
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.
void VisitNamespaceDecl(NamespaceDecl *D)
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
const ObjCProtocolList & getReferencedProtocols() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Represents a base class of a C++ class.
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
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.
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.
base_class_iterator bases_end()
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...
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.
std::pair< uint64_t, uint64_t > VisitDeclContext(DeclContext *DC)
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
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.
void VisitTranslationUnitDecl(TranslationUnitDecl *TU)
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.
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine()) const
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
unsigned getNumExceptions() const
const ObjCInterfaceDecl * getSuperClass() const
const StringLiteral * getAsmString() const