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);
44 void PrintObjCMethodType(
ASTContext &Ctx, Decl::ObjCDeclQualifier Quals,
51 unsigned Indentation = 0,
bool PrintInstantiation =
false)
52 : Out(Out), Policy(Policy), Indentation(Indentation),
53 PrintInstantiation(PrintInstantiation) { }
100 void prettyPrintAttributes(
Decl *D);
101 void prettyPrintPragmas(
Decl *D);
102 void printDeclType(
QualType T, StringRef DeclName,
bool Pack =
false);
106 void Decl::print(raw_ostream &Out,
unsigned Indentation,
107 bool PrintInstantiation)
const {
108 print(Out, getASTContext().getPrintingPolicy(), Indentation, PrintInstantiation);
112 unsigned Indentation,
bool PrintInstantiation)
const {
113 DeclPrinter Printer(Out, Policy, Indentation, PrintInstantiation);
114 Printer.Visit(const_cast<Decl*>(
this));
121 if (isa<TypedefType>(BaseType))
127 else if (
const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
128 BaseType = ATy->getElementType();
130 BaseType = FTy->getReturnType();
132 BaseType = VTy->getElementType();
136 BaseType = ATy->getDeducedType();
138 llvm_unreachable(
"Unknown declarator!");
145 return TDD->getUnderlyingType();
146 if (
ValueDecl* VD = dyn_cast<ValueDecl>(D))
147 return VD->getType();
151 void Decl::printGroup(
Decl** Begin,
unsigned NumDecls,
153 unsigned Indentation) {
155 (*Begin)->print(Out, Policy, Indentation);
167 for ( ; Begin !=
End; ++Begin) {
170 SubPolicy.IncludeTagDefinition =
true;
171 SubPolicy.SuppressSpecifiers =
false;
174 if (!isFirst) Out <<
", ";
175 SubPolicy.IncludeTagDefinition =
false;
176 SubPolicy.SuppressSpecifiers =
true;
179 (*Begin)->print(Out, SubPolicy, Indentation);
189 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
191 Printer.VisitDeclContext(const_cast<DeclContext *>(
this),
false);
195 for (
unsigned i = 0; i != Indentation; ++i)
200 void DeclPrinter::prettyPrintAttributes(
Decl *D) {
205 AttrVec &Attrs = D->getAttrs();
206 for (
auto *A : Attrs) {
207 switch (A->getKind()) {
209 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
210 #include "clang/Basic/AttrList.inc"
213 A->printPretty(Out, Policy);
220 void DeclPrinter::prettyPrintPragmas(
Decl *D) {
225 AttrVec &Attrs = D->getAttrs();
226 for (
auto *A : Attrs) {
227 switch (A->getKind()) {
229 #define PRAGMA_SPELLING_ATTR(X) case attr::X:
230 #include "clang/Basic/AttrList.inc"
231 A->printPretty(Out, Policy);
241 void DeclPrinter::printDeclType(
QualType T, StringRef DeclName,
bool Pack) {
247 T = PET->getPattern();
249 T.
print(Out, Policy, (Pack ?
"..." :
"") + DeclName, Indentation);
254 Decl::printGroup(Decls.data(), Decls.size(), Out, Policy, Indentation);
262 case AS_none: llvm_unreachable(
"No access specifier!");
274 if (Policy.TerseOutput)
278 Indentation += Policy.Indentation;
286 if (isa<ObjCIvarDecl>(*D))
302 if (!Decls.empty() && !CurDeclType.
isNull()) {
304 if (!BaseType.
isNull() && isa<ElaboratedType>(BaseType))
305 BaseType = cast<ElaboratedType>(BaseType)->getNamedType();
306 if (!BaseType.
isNull() && isa<TagType>(BaseType) &&
307 cast<TagType>(BaseType)->getDecl() == Decls[0]) {
315 ProcessDeclGroup(Decls);
319 if (isa<TagDecl>(*D) && !cast<TagDecl>(*D)->getIdentifier()) {
324 if (isa<AccessSpecDecl>(*D)) {
325 Indentation -= Policy.Indentation;
327 Print(D->getAccess());
329 Indentation += Policy.Indentation;
337 const char *Terminator =
nullptr;
338 if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D))
339 Terminator =
nullptr;
340 else if (isa<FunctionDecl>(*D) &&
341 cast<FunctionDecl>(*D)->isThisDeclarationADefinition())
342 Terminator =
nullptr;
343 else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->getBody())
344 Terminator =
nullptr;
345 else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) ||
346 isa<ObjCImplementationDecl>(*D) ||
347 isa<ObjCInterfaceDecl>(*D) ||
348 isa<ObjCProtocolDecl>(*D) ||
349 isa<ObjCCategoryImplDecl>(*D) ||
350 isa<ObjCCategoryDecl>(*D))
351 Terminator =
nullptr;
352 else if (isa<EnumConstantDecl>(*D)) {
366 if (D->hasAttr<OMPDeclareTargetDeclAttr>())
367 Out <<
"#pragma omp end declare target\n";
371 ProcessDeclGroup(Decls);
374 Indentation -= Policy.Indentation;
378 VisitDeclContext(D,
false);
381 void DeclPrinter::VisitTypedefDecl(
TypedefDecl *D) {
382 if (!Policy.SuppressSpecifiers) {
385 if (D->isModulePrivate())
386 Out <<
"__module_private__ ";
390 prettyPrintAttributes(D);
394 Out <<
"using " << *D;
395 prettyPrintAttributes(D);
396 Out <<
" = " << D->getTypeSourceInfo()->getType().getAsString(Policy);
399 void DeclPrinter::VisitEnumDecl(
EnumDecl *D) {
400 if (!Policy.SuppressSpecifiers && D->isModulePrivate())
401 Out <<
"__module_private__ ";
414 if (D->isCompleteDefinition()) {
419 prettyPrintAttributes(D);
422 void DeclPrinter::VisitRecordDecl(
RecordDecl *D) {
423 if (!Policy.SuppressSpecifiers && D->isModulePrivate())
424 Out <<
"__module_private__ ";
427 prettyPrintAttributes(D);
441 if (
Expr *Init = D->getInitExpr()) {
443 Init->printPretty(Out,
nullptr, Policy, Indentation);
450 prettyPrintPragmas(D);
454 if (!Policy.SuppressSpecifiers) {
461 llvm_unreachable(
"invalid for functions");
466 if (D->isModulePrivate()) Out <<
"__module_private__ ";
469 (ConversionDecl && ConversionDecl->isExplicit()))
474 SubPolicy.SuppressSpecifiers =
false;
478 while (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
479 Proto =
'(' + Proto +
')';
480 Ty = PT->getInnerType();
486 FT = dyn_cast<FunctionProtoType>(AFT);
490 llvm::raw_string_ostream POut(Proto);
491 DeclPrinter ParamPrinter(POut, SubPolicy, Indentation);
492 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
502 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
515 Proto +=
" volatile";
517 Proto +=
" restrict";
544 Proto +=
" noexcept";
547 llvm::raw_string_ostream EOut(Proto);
557 bool HasInitializerList =
false;
558 for (
const auto *BMInitializer : CDecl->
inits()) {
559 if (BMInitializer->isInClassMemberInitializer())
562 if (!HasInitializerList) {
566 HasInitializerList =
true;
570 if (BMInitializer->isAnyMemberInitializer()) {
571 FieldDecl *FD = BMInitializer->getAnyMember();
574 Out <<
QualType(BMInitializer->getBaseClass(), 0).getAsString(Policy);
578 if (!BMInitializer->getInit()) {
581 Expr *Init = BMInitializer->getInit();
583 Init = Tmp->getSubExpr();
587 Expr *SimpleInit =
nullptr;
588 Expr **Args =
nullptr;
590 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
591 Args = ParenList->getExprs();
592 NumArgs = ParenList->getNumExprs();
594 = dyn_cast<CXXConstructExpr>(Init)) {
595 Args = Construct->getArgs();
596 NumArgs = Construct->getNumArgs();
601 SimpleInit->printPretty(Out,
nullptr, Policy, Indentation);
604 assert(Args[
I] !=
nullptr &&
"Expected non-null Expr");
605 if (isa<CXXDefaultArgExpr>(Args[
I]))
610 Args[
I]->printPretty(Out,
nullptr, Policy, Indentation);
615 if (BMInitializer->isPackExpansion())
618 }
else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
620 Out <<
"auto " << Proto <<
" -> ";
623 AFT->getReturnType().print(Out, Policy, Proto);
628 Ty.
print(Out, Policy, Proto);
631 prettyPrintAttributes(D);
644 DeclPrinter ParamPrinter(Out, SubPolicy, Indentation);
645 Indentation += Policy.Indentation;
646 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
651 Indentation -= Policy.Indentation;
656 D->
getBody()->printPretty(Out,
nullptr, SubPolicy, Indentation);
661 void DeclPrinter::VisitFriendDecl(
FriendDecl *D) {
664 for (
unsigned i = 0; i < NumTPLists; ++i)
667 Out <<
" " << TSI->getType().getAsString(Policy);
672 VisitFunctionDecl(FD);
677 VisitFunctionTemplateDecl(FTD);
682 VisitRedeclarableTemplateDecl(CTD);
686 void DeclPrinter::VisitFieldDecl(
FieldDecl *D) {
688 if (!Policy.SuppressSpecifiers && D->
isMutable())
690 if (!Policy.SuppressSpecifiers && D->isModulePrivate())
691 Out <<
"__module_private__ ";
693 Out << D->getASTContext().getUnqualifiedObjCPointerType(D->
getType()).
694 stream(Policy, D->
getName(), Indentation);
698 D->
getBitWidth()->printPretty(Out,
nullptr, Policy, Indentation);
702 if (!Policy.SuppressInitializers && Init) {
707 Init->printPretty(Out,
nullptr, Policy, Indentation);
709 prettyPrintAttributes(D);
712 void DeclPrinter::VisitLabelDecl(
LabelDecl *D) {
716 void DeclPrinter::VisitVarDecl(
VarDecl *D) {
717 prettyPrintPragmas(D);
721 : D->getASTContext().getUnqualifiedObjCPointerType(D->
getType());
723 if (!Policy.SuppressSpecifiers) {
735 Out <<
"_Thread_local ";
738 Out <<
"thread_local ";
742 if (D->isModulePrivate())
743 Out <<
"__module_private__ ";
751 printDeclType(T, D->
getName());
753 if (!Policy.SuppressInitializers && Init) {
754 bool ImplicitInit =
false;
756 dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
758 !Construct->isListInitialization()) {
759 ImplicitInit = Construct->getNumArgs() == 0 ||
770 SubPolicy.SuppressSpecifiers =
false;
771 SubPolicy.IncludeTagDefinition =
false;
772 Init->printPretty(Out,
nullptr, SubPolicy, Indentation);
777 prettyPrintAttributes(D);
780 void DeclPrinter::VisitParmVarDecl(
ParmVarDecl *D) {
786 D->
getAsmString()->printPretty(Out,
nullptr, Policy, Indentation);
790 void DeclPrinter::VisitImportDecl(
ImportDecl *D) {
796 Out <<
"static_assert(";
797 D->
getAssertExpr()->printPretty(Out,
nullptr, Policy, Indentation);
800 SL->printPretty(Out,
nullptr, Policy, Indentation);
811 Out <<
"namespace " << *D <<
" {\n";
817 Out <<
"using namespace ";
824 Out <<
"namespace " << *D <<
" = ";
825 if (D->getQualifier())
827 Out << *D->getAliasedNamespace();
830 void DeclPrinter::VisitEmptyDecl(
EmptyDecl *D) {
831 prettyPrintAttributes(D);
836 if (!Policy.SuppressSpecifiers && D->isModulePrivate())
837 Out <<
"__module_private__ ";
840 prettyPrintAttributes(D);
854 if (
Base->isVirtual())
862 Out <<
Base->getType().getAsString(Policy);
864 if (
Base->isPackExpansion())
883 "unknown language in linkage specification");
887 Out <<
"extern \"" << l <<
"\" ";
899 assert(!Args || Params->
size() == Args->
size());
903 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
909 dyn_cast<TemplateTypeParmDecl>(Param)) {
911 if (TTP->wasDeclaredWithTypename())
916 if (TTP->isParameterPack())
924 }
else if (TTP->hasDefaultArgument()) {
926 Out << TTP->getDefaultArgument().getAsString(Policy);
929 dyn_cast<NonTypeTemplateParmDecl>(Param)) {
933 printDeclType(NTTP->getType(),
Name, NTTP->isParameterPack());
938 }
else if (NTTP->hasDefaultArgument()) {
940 NTTP->getDefaultArgument()->printPretty(Out,
nullptr, Policy,
944 dyn_cast<TemplateTemplateParmDecl>(Param)) {
945 VisitTemplateDecl(TTPD);
953 void DeclPrinter::VisitTemplateDecl(
const TemplateDecl *D) {
957 dyn_cast<TemplateTemplateParmDecl>(D)) {
959 if (TTP->isParameterPack())
968 if (PrintInstantiation) {
971 prettyPrintPragmas(
I);
972 PrintTemplateParameters(Params,
I->getTemplateSpecializationArgs());
978 return VisitRedeclarableTemplateDecl(D);
982 if (PrintInstantiation) {
985 PrintTemplateParameters(Params, &
I->getTemplateArgs());
991 return VisitRedeclarableTemplateDecl(D);
998 void DeclPrinter::PrintObjCMethodType(
ASTContext &Ctx,
999 Decl::ObjCDeclQualifier Quals,
1002 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
1004 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Inout)
1006 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Out)
1008 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Bycopy)
1010 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Byref)
1012 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway)
1014 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) {
1025 unsigned First =
true;
1026 for (
auto *Param : *Params) {
1033 switch (Param->getVariance()) {
1038 Out <<
"__covariant ";
1042 Out <<
"__contravariant ";
1046 Out << Param->getDeclName().getAsString();
1048 if (Param->hasExplicitBound()) {
1049 Out <<
" : " << Param->getUnderlyingType().getAsString(Policy);
1066 std::string::size_type pos, lastPos = 0;
1069 pos = name.find_first_of(
':', lastPos);
1070 Out <<
" " << name.substr(lastPos, pos - lastPos) <<
':';
1071 PrintObjCMethodType(OMD->getASTContext(),
1084 prettyPrintAttributes(OMD);
1086 if (OMD->
getBody() && !Policy.TerseOutput) {
1088 OMD->
getBody()->printPretty(Out,
nullptr, Policy);
1090 else if (Policy.PolishForDeclaration)
1098 bool eolnOut =
false;
1100 Out <<
"@implementation " << I <<
" : " << *SID;
1102 Out <<
"@implementation " <<
I;
1107 Indentation += Policy.Indentation;
1108 for (
const auto *I : OID->
ivars()) {
1109 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1110 getAsString(Policy) <<
' ' << *I <<
";\n";
1112 Indentation -= Policy.Indentation;
1119 VisitDeclContext(OID,
false);
1130 Out <<
"@class " <<
I;
1133 PrintObjCTypeParams(TypeParams);
1139 bool eolnOut =
false;
1140 Out <<
"@interface " <<
I;
1143 PrintObjCTypeParams(TypeParams);
1151 if (!Protocols.
empty()) {
1153 E = Protocols.
end(); I !=
E; ++
I)
1154 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1161 Indentation += Policy.Indentation;
1162 for (
const auto *I : OID->
ivars()) {
1163 Indent() << I->getASTContext()
1164 .getUnqualifiedObjCPointerType(I->getType())
1165 .getAsString(Policy) <<
' ' << *I <<
";\n";
1167 Indentation -= Policy.Indentation;
1175 VisitDeclContext(OID,
false);
1184 Out <<
"@protocol " << *PID <<
";\n";
1189 if (!Protocols.
empty()) {
1190 Out <<
"@protocol " << *PID;
1192 E = Protocols.
end(); I !=
E; ++
I)
1193 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1196 Out <<
"@protocol " << *PID <<
'\n';
1197 VisitDeclContext(PID,
false);
1204 VisitDeclContext(PID,
false);
1212 PrintObjCTypeParams(TypeParams);
1214 Out <<
"(" << *PID <<
")\n";
1215 if (PID->ivar_size() > 0) {
1217 Indentation += Policy.Indentation;
1218 for (
const auto *I : PID->ivars())
1219 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1220 getAsString(Policy) <<
' ' << *I <<
";\n";
1221 Indentation -= Policy.Indentation;
1225 VisitDeclContext(PID,
false);
1232 Out <<
"@compatibility_alias " << *AID
1240 Out <<
"@required\n";
1242 Out <<
"@optional\n";
1252 Out << (first ?
' ' :
',') <<
"readonly";
1257 Out << (first ?
' ' :
',') <<
"getter = ";
1262 Out << (first ?
' ' :
',') <<
"setter = ";
1268 Out << (first ?
' ' :
',') <<
"assign";
1274 Out << (first ?
' ' :
',') <<
"readwrite";
1279 Out << (first ?
' ' :
',') <<
"retain";
1284 Out << (first ?
' ' :
',') <<
"strong";
1289 Out << (first ?
' ' :
',') <<
"copy";
1295 Out << (first ?
' ' :
',') <<
"nonatomic";
1300 Out << (first ?
' ' :
',') <<
"atomic";
1310 Out << (first ?
' ' :
',') <<
"null_resettable";
1312 Out << (first ?
' ' :
',')
1320 Out << (first ?
' ' :
',') <<
"class";
1327 Out <<
' ' << PDecl->getASTContext().getUnqualifiedObjCPointerType(T).
1328 getAsString(Policy) <<
' ' << *PDecl;
1329 if (Policy.PolishForDeclaration)
1335 Out <<
"@synthesize ";
1343 void DeclPrinter::VisitUsingDecl(
UsingDecl *D) {
1354 Out <<
"using typename ";
1371 Out <<
"#pragma omp threadprivate";
1377 NamedDecl *ND = cast<NamedDecl>(cast<DeclRefExpr>(*I)->getDecl());
1385 if (!D->isInvalidDecl()) {
1386 Out <<
"#pragma omp declare reduction (";
1390 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
1392 #include "clang/Basic/OperatorKinds.def"
1394 const char *OpName =
1396 assert(OpName &&
"not an overloaded operator");
1405 D->
getCombiner()->printPretty(Out,
nullptr, Policy, 0);
1408 Out <<
" initializer(";
1409 Init->printPretty(Out,
nullptr, Policy, 0);
1416 D->
getInit()->printPretty(Out,
nullptr, Policy, Indentation);
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.
Represents a C++11 auto or C++14 decltype(auto) type.
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.
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
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...
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 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
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.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
An lvalue ref-qualifier was provided (&).
static QualType getDeclType(Decl *D)
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 VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D)
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...
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
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
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D)
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)
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...
void VisitUsingShadowDecl(UsingShadowDecl *D)
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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.
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
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...
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
void VisitEmptyDecl(EmptyDecl *D)
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...
TagDecl - Represents the declaration of a struct/union/class/enum.
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.
void printName(raw_ostream &os) const
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)
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.
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...
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.
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)
unsigned PolishForDeclaration
When true, do certain refinement needed for producing proper declaration tag; such as...
This represents '#pragma omp threadprivate ...' directive.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
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 getNumExceptions() const
const ObjCInterfaceDecl * getSuperClass() const
const StringLiteral * getAsmString() const