24 #include "llvm/Support/raw_ostream.h" 25 using namespace clang;
28 class DeclPrinter :
public DeclVisitor<DeclPrinter> {
33 bool PrintInstantiation;
35 raw_ostream& Indent() {
return Indent(Indentation); }
36 raw_ostream& Indent(
unsigned Indentation);
54 const ASTContext &Context,
unsigned Indentation = 0,
55 bool PrintInstantiation =
false)
56 : Out(Out), Policy(Policy), Context(Context), Indentation(Indentation),
57 PrintInstantiation(PrintInstantiation) {}
59 void VisitDeclContext(
DeclContext *DC,
bool Indent =
true);
85 void VisitClassTemplateSpecializationDecl(
87 void VisitClassTemplatePartialSpecializationDecl(
109 void prettyPrintAttributes(
Decl *D);
110 void prettyPrintPragmas(
Decl *D);
111 void printDeclType(
QualType T, StringRef DeclName,
bool Pack =
false);
116 bool PrintInstantiation)
const {
117 print(Out, getASTContext().getPrintingPolicy(), Indentation, PrintInstantiation);
121 unsigned Indentation,
bool PrintInstantiation)
const {
122 DeclPrinter Printer(Out, Policy, getASTContext(), Indentation,
124 Printer.Visit(const_cast<Decl*>(
this));
135 else if (
const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
136 BaseType = ATy->getElementType();
138 BaseType = FTy->getReturnType();
140 BaseType = VTy->getElementType();
144 BaseType = ATy->getDeducedType();
146 BaseType = PTy->desugar();
156 return TDD->getUnderlyingType();
157 if (
ValueDecl* VD = dyn_cast<ValueDecl>(D))
158 return VD->getType();
164 unsigned Indentation) {
166 (*Begin)->print(Out, Policy, Indentation);
185 if (!isFirst) Out <<
", ";
190 (*Begin)->print(Out, SubPolicy, Indentation);
200 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
202 Printer.VisitDeclContext(const_cast<DeclContext *>(
this),
false);
205 raw_ostream& DeclPrinter::Indent(
unsigned Indentation) {
206 for (
unsigned i = 0; i != Indentation; ++i)
211 void DeclPrinter::prettyPrintAttributes(
Decl *D) {
212 if (Policy.PolishForDeclaration)
217 for (
auto *A : Attrs) {
218 if (A->isInherited() || A->isImplicit())
220 switch (A->getKind()) {
222 #define PRAGMA_SPELLING_ATTR(X) case attr::X: 223 #include "clang/Basic/AttrList.inc" 226 A->printPretty(Out, Policy);
233 void DeclPrinter::prettyPrintPragmas(
Decl *D) {
234 if (Policy.PolishForDeclaration)
239 for (
auto *A : Attrs) {
240 switch (A->getKind()) {
242 #define PRAGMA_SPELLING_ATTR(X) case attr::X: 243 #include "clang/Basic/AttrList.inc" 244 A->printPretty(Out, Policy);
254 void DeclPrinter::printDeclType(
QualType T, StringRef DeclName,
bool Pack) {
260 T = PET->getPattern();
262 T.
print(Out, Policy, (Pack ?
"..." :
"") + DeclName, Indentation);
275 case AS_none: llvm_unreachable(
"No access specifier!");
283 std::string &Proto) {
284 bool HasInitializerList =
false;
285 for (
const auto *BMInitializer : CDecl->
inits()) {
286 if (BMInitializer->isInClassMemberInitializer())
289 if (!HasInitializerList) {
293 HasInitializerList =
true;
297 if (BMInitializer->isAnyMemberInitializer()) {
298 FieldDecl *FD = BMInitializer->getAnyMember();
305 if (!BMInitializer->getInit()) {
308 Expr *Init = BMInitializer->getInit();
310 Init = Tmp->getSubExpr();
314 Expr *SimpleInit =
nullptr;
315 Expr **Args =
nullptr;
316 unsigned NumArgs = 0;
317 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
318 Args = ParenList->getExprs();
319 NumArgs = ParenList->getNumExprs();
321 dyn_cast<CXXConstructExpr>(Init)) {
322 Args = Construct->getArgs();
323 NumArgs = Construct->getNumArgs();
328 SimpleInit->
printPretty(Out,
nullptr, Policy, Indentation);
330 for (
unsigned I = 0; I != NumArgs; ++I) {
331 assert(Args[I] !=
nullptr &&
"Expected non-null Expr");
332 if (isa<CXXDefaultArgExpr>(Args[I]))
337 Args[I]->
printPretty(Out,
nullptr, Policy, Indentation);
342 if (BMInitializer->isPackExpansion())
351 void DeclPrinter::VisitDeclContext(
DeclContext *DC,
bool Indent) {
352 if (Policy.TerseOutput)
356 Indentation += Policy.Indentation;
364 if (isa<ObjCIvarDecl>(*D))
373 if (
auto FD = dyn_cast<FunctionDecl>(*D))
375 !isa<ClassTemplateSpecializationDecl>(DC))
391 if (!Decls.empty() && !CurDeclType.
isNull()) {
393 if (!BaseType.
isNull() && isa<ElaboratedType>(BaseType) &&
394 cast<ElaboratedType>(BaseType)->getOwnedTagDecl() == Decls[0]) {
402 ProcessDeclGroup(Decls);
406 if (isa<TagDecl>(*D) && !cast<TagDecl>(*D)->isFreeStanding()) {
411 if (isa<AccessSpecDecl>(*D)) {
412 Indentation -= Policy.Indentation;
416 Indentation += Policy.Indentation;
424 const char *Terminator =
nullptr;
425 if (isa<OMPThreadPrivateDecl>(*D) || isa<OMPDeclareReductionDecl>(*D))
426 Terminator =
nullptr;
427 else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->hasBody())
428 Terminator =
nullptr;
429 else if (
auto FD = dyn_cast<FunctionDecl>(*D)) {
430 if (FD->isThisDeclarationADefinition())
431 Terminator =
nullptr;
434 }
else if (
auto TD = dyn_cast<FunctionTemplateDecl>(*D)) {
435 if (TD->getTemplatedDecl()->isThisDeclarationADefinition())
436 Terminator =
nullptr;
439 }
else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) ||
440 isa<ObjCImplementationDecl>(*D) ||
441 isa<ObjCInterfaceDecl>(*D) ||
442 isa<ObjCProtocolDecl>(*D) ||
443 isa<ObjCCategoryImplDecl>(*D) ||
444 isa<ObjCCategoryDecl>(*D))
445 Terminator =
nullptr;
446 else if (isa<EnumConstantDecl>(*D)) {
456 if (!Policy.TerseOutput &&
457 ((isa<FunctionDecl>(*D) &&
458 cast<FunctionDecl>(*D)->doesThisDeclarationHaveABody()) ||
459 (isa<FunctionTemplateDecl>(*D) &&
460 cast<FunctionTemplateDecl>(*D)->getTemplatedDecl()->doesThisDeclarationHaveABody())))
467 if (D->
hasAttr<OMPDeclareTargetDeclAttr>())
468 Out <<
"#pragma omp end declare target\n";
472 ProcessDeclGroup(Decls);
475 Indentation -= Policy.Indentation;
479 VisitDeclContext(D,
false);
482 void DeclPrinter::VisitTypedefDecl(
TypedefDecl *D) {
483 if (!Policy.SuppressSpecifiers) {
487 Out <<
"__module_private__ ";
491 prettyPrintAttributes(D);
495 Out <<
"using " << *D;
496 prettyPrintAttributes(D);
497 Out <<
" = " << D->getTypeSourceInfo()->getType().getAsString(Policy);
500 void DeclPrinter::VisitEnumDecl(
EnumDecl *D) {
502 Out <<
"__module_private__ ";
511 prettyPrintAttributes(D);
515 if (D->isFixed() && D->getASTContext().getLangOpts().CPlusPlus11)
518 if (D->isCompleteDefinition()) {
525 void DeclPrinter::VisitRecordDecl(
RecordDecl *D) {
527 Out <<
"__module_private__ ";
530 prettyPrintAttributes(D);
544 prettyPrintAttributes(D);
545 if (
Expr *Init = D->getInitExpr()) {
547 Init->printPretty(Out,
nullptr, Policy, Indentation, &Context);
554 prettyPrintPragmas(D);
557 Out <<
"template<> ";
560 I < NumTemplateParams; ++I)
567 if (!Policy.SuppressSpecifiers) {
574 llvm_unreachable(
"invalid for functions");
582 (ConversionDecl && ConversionDecl->isExplicitSpecified()) ||
583 (GuideDecl && GuideDecl->isExplicitSpecified()))
591 if (Policy.FullyQualifiedName) {
594 if (!Policy.SuppressScope) {
596 llvm::raw_string_ostream OS(Proto);
597 NS->print(OS, Policy);
604 Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
606 llvm::raw_string_ostream POut(Proto);
607 DeclPrinter TArgPrinter(POut, SubPolicy, Context, Indentation);
608 TArgPrinter.printTemplateArguments(*TArgs);
612 while (
const ParenType *PT = dyn_cast<ParenType>(Ty)) {
613 Proto =
'(' + Proto +
')';
614 Ty = PT->getInnerType();
620 FT = dyn_cast<FunctionProtoType>(AFT);
624 llvm::raw_string_ostream POut(Proto);
625 DeclPrinter ParamPrinter(POut, SubPolicy, Context, Indentation);
626 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
636 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
649 Proto +=
" volatile";
651 Proto +=
" restrict";
678 Proto +=
" noexcept";
681 llvm::raw_string_ostream EOut(Proto);
691 if (!Policy.TerseOutput)
692 PrintConstructorInitializers(CDecl, Proto);
693 }
else if (!ConversionDecl && !isa<CXXDestructorDecl>(D)) {
697 Out << Proto <<
" -> ";
700 AFT->getReturnType().print(Out, Policy, Proto);
705 Ty.
print(Out, Policy, Proto);
708 prettyPrintAttributes(D);
717 if (!Policy.TerseOutput) {
722 DeclPrinter ParamPrinter(Out, SubPolicy, Context, Indentation);
723 Indentation += Policy.Indentation;
724 for (
unsigned i = 0, e = D->
getNumParams(); i != e; ++i) {
729 Indentation -= Policy.Indentation;
736 if (!Policy.TerseOutput && isa<CXXConstructorDecl>(*D))
742 void DeclPrinter::VisitFriendDecl(
FriendDecl *D) {
745 for (
unsigned i = 0; i < NumTPLists; ++i)
748 Out <<
" " << TSI->getType().getAsString(Policy);
753 VisitFunctionDecl(FD);
758 VisitFunctionTemplateDecl(FTD);
763 VisitRedeclarableTemplateDecl(CTD);
767 void DeclPrinter::VisitFieldDecl(
FieldDecl *D) {
769 if (!Policy.SuppressSpecifiers && D->
isMutable())
772 Out <<
"__module_private__ ";
775 stream(Policy, D->
getName(), Indentation);
783 if (!Policy.SuppressInitializers && Init) {
788 Init->
printPretty(Out,
nullptr, Policy, Indentation);
790 prettyPrintAttributes(D);
793 void DeclPrinter::VisitLabelDecl(
LabelDecl *D) {
797 void DeclPrinter::VisitVarDecl(
VarDecl *D) {
798 prettyPrintPragmas(D);
804 if (!Policy.SuppressSpecifiers) {
816 Out <<
"_Thread_local ";
819 Out <<
"thread_local ";
824 Out <<
"__module_private__ ";
832 printDeclType(T, D->
getName());
834 if (!Policy.SuppressInitializers && Init) {
835 bool ImplicitInit =
false;
837 dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
839 !Construct->isListInitialization()) {
840 ImplicitInit = Construct->getNumArgs() == 0 ||
853 Init->printPretty(Out,
nullptr, SubPolicy, Indentation);
858 prettyPrintAttributes(D);
861 void DeclPrinter::VisitParmVarDecl(
ParmVarDecl *D) {
871 void DeclPrinter::VisitImportDecl(
ImportDecl *D) {
877 Out <<
"static_assert(";
881 SL->printPretty(Out,
nullptr, Policy, Indentation);
892 Out <<
"namespace " << *D <<
" {\n";
898 Out <<
"using namespace ";
905 Out <<
"namespace " << *D <<
" = ";
906 if (D->getQualifier())
908 Out << *D->getAliasedNamespace();
911 void DeclPrinter::VisitEmptyDecl(
EmptyDecl *D) {
912 prettyPrintAttributes(D);
918 Out <<
"__module_private__ ";
921 prettyPrintAttributes(D);
926 if (
auto S = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
927 printTemplateArguments(S->getTemplateArgs(), S->getTemplateParameters());
928 else if (
auto S = dyn_cast<ClassTemplateSpecializationDecl>(D))
929 printTemplateArguments(S->getTemplateArgs());
941 if (
Base->isVirtual())
949 Out <<
Base->getType().getAsString(Policy);
951 if (
Base->isPackExpansion())
958 if (Policy.TerseOutput) {
974 "unknown language in linkage specification");
978 Out <<
"extern \"" << l <<
"\" ";
992 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
997 if (
auto TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
999 if (TTP->wasDeclaredWithTypename())
1004 if (TTP->isParameterPack())
1009 if (TTP->hasDefaultArgument()) {
1011 Out << TTP->getDefaultArgument().getAsString(Policy);
1013 }
else if (
auto NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
1016 Name = II->getName();
1017 printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
1019 if (NTTP->hasDefaultArgument()) {
1021 NTTP->getDefaultArgument()->printPretty(Out,
nullptr, Policy,
1024 }
else if (
auto TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
1025 VisitTemplateDecl(TTPD);
1036 for (
size_t I = 0, E = Args.
size(); I < E; ++I) {
1043 auto P = cast<TemplateTypeParmDecl>(Params->
getParam(T->getIndex()));
1049 if (
auto TD = dyn_cast<TemplateTemplateParmDecl>(T)) {
1050 auto P = cast<TemplateTemplateParmDecl>(
1057 if (
auto E = dyn_cast<DeclRefExpr>(A.
getAsExpr()))
1058 if (
auto N = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl())) {
1059 auto P = cast<NonTypeTemplateParmDecl>(
1066 A.
print(Policy, Out);
1071 void DeclPrinter::VisitTemplateDecl(
const TemplateDecl *D) {
1075 dyn_cast<TemplateTemplateParmDecl>(D)) {
1077 if (TTP->isParameterPack())
1089 for (
unsigned I = 0, NumTemplateParams = FD->getNumTemplateParameterLists();
1090 I < NumTemplateParams; ++I)
1091 printTemplateParameters(FD->getTemplateParameterList(I));
1093 VisitRedeclarableTemplateDecl(D);
1097 Out <<
"#pragma omp end declare target\n";
1101 if (PrintInstantiation &&
1105 if (PrevDecl->
isDefined(Def) && Def != PrevDecl)
1112 prettyPrintPragmas(I);
1119 VisitRedeclarableTemplateDecl(D);
1121 if (PrintInstantiation) {
1132 void DeclPrinter::VisitClassTemplateSpecializationDecl(
1134 Out <<
"template<> ";
1135 VisitCXXRecordDecl(D);
1138 void DeclPrinter::VisitClassTemplatePartialSpecializationDecl(
1141 VisitCXXRecordDecl(D);
1148 void DeclPrinter::PrintObjCMethodType(
ASTContext &Ctx,
1152 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
1154 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Inout)
1156 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Out)
1158 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Bycopy)
1160 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Byref)
1162 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_Oneway)
1164 if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_CSNullability) {
1175 unsigned First =
true;
1176 for (
auto *Param : *Params) {
1183 switch (Param->getVariance()) {
1188 Out <<
"__covariant ";
1192 Out <<
"__contravariant ";
1196 Out << Param->getDeclName().getAsString();
1198 if (Param->hasExplicitBound()) {
1199 Out <<
" : " << Param->getUnderlyingType().getAsString(Policy);
1216 std::string::size_type pos, lastPos = 0;
1219 pos = name.find_first_of(
':', lastPos);
1222 Out << name.substr(lastPos, pos - lastPos) <<
':';
1224 PI->getObjCDeclQualifier(),
1236 prettyPrintAttributes(OMD);
1238 if (OMD->
getBody() && !Policy.TerseOutput) {
1242 else if (Policy.PolishForDeclaration)
1250 bool eolnOut =
false;
1252 Out <<
"@implementation " << I <<
" : " << *SID;
1254 Out <<
"@implementation " << I;
1259 Indentation += Policy.Indentation;
1260 for (
const auto *I : OID->
ivars()) {
1261 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1264 Indentation -= Policy.Indentation;
1271 VisitDeclContext(OID,
false);
1282 Out <<
"@class " << I;
1285 PrintObjCTypeParams(TypeParams);
1291 bool eolnOut =
false;
1292 Out <<
"@interface " << I;
1295 PrintObjCTypeParams(TypeParams);
1303 if (!Protocols.
empty()) {
1305 E = Protocols.
end(); I != E; ++I)
1306 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1313 Indentation += Policy.Indentation;
1314 for (
const auto *I : OID->
ivars()) {
1315 Indent() << I->getASTContext()
1316 .getUnqualifiedObjCPointerType(I->getType())
1319 Indentation -= Policy.Indentation;
1327 VisitDeclContext(OID,
false);
1336 Out <<
"@protocol " << *PID <<
";\n";
1341 if (!Protocols.
empty()) {
1342 Out <<
"@protocol " << *PID;
1344 E = Protocols.
end(); I != E; ++I)
1345 Out << (I == Protocols.
begin() ?
'<' :
',') << **I;
1348 Out <<
"@protocol " << *PID <<
'\n';
1349 VisitDeclContext(PID,
false);
1356 VisitDeclContext(PID,
false);
1364 PrintObjCTypeParams(TypeParams);
1366 Out <<
"(" << *PID <<
")\n";
1367 if (PID->ivar_size() > 0) {
1369 Indentation += Policy.Indentation;
1370 for (
const auto *I : PID->ivars())
1371 Indent() << I->getASTContext().getUnqualifiedObjCPointerType(I->getType()).
1373 Indentation -= Policy.Indentation;
1377 VisitDeclContext(PID,
false);
1384 Out <<
"@compatibility_alias " << *AID
1392 Out <<
"@required\n";
1394 Out <<
"@optional\n";
1404 Out << (first ?
' ' :
',') <<
"readonly";
1409 Out << (first ?
' ' :
',') <<
"getter = ";
1414 Out << (first ?
' ' :
',') <<
"setter = ";
1420 Out << (first ?
' ' :
',') <<
"assign";
1426 Out << (first ?
' ' :
',') <<
"readwrite";
1431 Out << (first ?
' ' :
',') <<
"retain";
1436 Out << (first ?
' ' :
',') <<
"strong";
1441 Out << (first ?
' ' :
',') <<
"copy";
1447 Out << (first ?
' ' :
',') <<
"nonatomic";
1452 Out << (first ?
' ' :
',') <<
"atomic";
1462 Out << (first ?
' ' :
',') <<
"null_resettable";
1464 Out << (first ?
' ' :
',')
1472 Out << (first ?
' ' :
',') <<
"class";
1481 if (Policy.PolishForDeclaration)
1487 Out <<
"@synthesize ";
1495 void DeclPrinter::VisitUsingDecl(
UsingDecl *D) {
1504 for (
const auto *Shadow : D->
shadows()) {
1505 if (
const auto *ConstructorShadow =
1506 dyn_cast<ConstructorUsingShadowDecl>(Shadow)) {
1507 assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
1508 Out << *ConstructorShadow->getNominatedBaseClass();
1517 Out <<
"using typename ";
1534 Out <<
"#pragma omp threadprivate";
1540 NamedDecl *ND = cast<DeclRefExpr>(*I)->getDecl();
1549 Out <<
"#pragma omp declare reduction (";
1553 #define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \ 1555 #include "clang/Basic/OperatorKinds.def" 1557 const char *OpName =
1559 assert(OpName &&
"not an overloaded operator");
1571 Out <<
" initializer(";
1577 Out <<
"omp_priv = ";
1582 Init->printPretty(Out,
nullptr, Policy, 0);
Defines the clang::ASTContext interface.
Represents a function declaration or definition.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
unsigned getFriendTypeNumTemplateParameterLists() const
ObjCInterfaceDecl * getClassInterface()
unsigned getNumBases() const
Retrieves the number of base classes of this class.
unsigned getNumExceptions() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
ObjCIvarDecl * getPropertyIvarDecl() const
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Expr * getBitWidth() const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
An instance of this object exists for each enum constant that is defined.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
spec_range specializations() const
The template argument is an expression, and we've not resolved it to one of the other forms yet...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
ThreadStorageClassSpecifier getTSCSpec() const
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
QualType getUnqualifiedObjCPointerType(QualType type) const
getUnqualifiedObjCPointerType - Returns version of Objective-C pointer type with lifetime qualifier r...
Represents a C++11 auto or C++14 decltype(auto) type.
bool hasWrittenPrototype() 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.
Represent a C++ namespace.
Represents a call to a C++ constructor.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
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)
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
param_const_iterator param_end() const
Represents a C++ constructor within a class.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Represents a variable declaration or definition.
const T * getAs() const
Member-template getAs<specific type>'.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isExplicitSpecified() const
Whether this function is marked as explicit explicitly.
bool isNoexceptExceptionSpec(ExceptionSpecificationType ESpecType)
const ObjCInterfaceDecl * getSuperClass() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
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...
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
StringLiteral * getMessage()
const ObjCProtocolList & getReferencedProtocols() const
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool isInline() const
Returns true if this is an inline namespace declaration.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
Represents a member of a struct/union/class.
InitKind getInitializerKind() const
Get initializer kind.
std::string getNameAsString() const
Get the name of the class associated with this interface.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
Represents a C++ using-declaration.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
bool isBitField() const
Determines whether this field is a bitfield.
An lvalue ref-qualifier was provided (&).
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
static QualType getDeclType(Decl *D)
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Microsoft throw(...) extension.
QualType getExceptionType(unsigned i) const
unsigned ivar_size() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Whether values of this type can be null is (explicitly) unspecified.
PropertyAttributeKind getPropertyAttributes() const
NamedDecl * getNominatedNamespaceAsWritten()
const clang::PrintingPolicy & getPrintingPolicy() const
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, const ASTContext *Context=nullptr) const
spec_range specializations() const
bool hasDynamicExceptionSpec() const
Return whether this function has a dynamic (throw) exception spec.
TemplateParameterList * getFriendTypeTemplateParameterList(unsigned N) const
base_class_iterator bases_begin()
Represents an Objective-C protocol declaration.
PropertyControl getPropertyImplementation() const
Represents an ObjC class declaration.
Represents a linkage specification.
QualType getReturnType() const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of the namespace.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
Represents a prototype with parameter type info, e.g.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
MutableArrayRef< Expr * >::iterator varlist_iterator
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
unsigned ivar_size() const
TypeSourceInfo * getTypeSourceInfo() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
StringRef getKindName() const
Selector getSetterName() const
llvm::StringRef getAsString(SyncScope S)
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
bool IncludeTagDefinition
When true, include the body of a tag definition.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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
ObjCInterfaceDecl * getSuperClass() const
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
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.
StorageClass
Storage classes.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
bool isSpecifierType() const
Returns true if this type can be represented by some set of type specifiers.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isInstanceMethod() const
Represents a GCC generic vector type.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a C++ deduction guide declaration.
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
Selector getSelector() const
Represents a C++ conversion function within a class.
This template specialization was implicitly instantiated from a template.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
bool hasTrailingReturn() const
virtual void printName(raw_ostream &os) const
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
std::string getAsString() const
Derive the full selector name (e.g.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Sugar for parentheses used when specifying types.
bool isPure() const
Whether this virtual function is pure, i.e.
This represents '#pragma omp declare reduction ...' directive.
decl_iterator decls_begin() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Pseudo declaration for capturing expressions.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
bool SuppressSpecifiers
Whether we should suppress printing of the actual specifiers for the given type or declaration...
Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
Represents the declaration of a label.
Represents a dependent using declaration which was not marked with typename.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
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.
const ParmVarDecl * getParamDecl(unsigned i) const
ObjCCategoryDecl - Represents a category declaration.
Expr * getNoexceptExpr() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Direct list-initialization.
Represents one property declaration in an Objective-C interface.
A simple visitor class that helps create declaration visitors.
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
ObjCDeclQualifier getObjCDeclQualifier() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
DeclarationNameInfo getNameInfo() const
Represents a C++11 static_assert declaration.
An rvalue ref-qualifier was provided (&&).
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a pack expansion of types.
bool varlist_empty() const
static const char * getStorageClassSpecifierString(StorageClass SC)
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 ObjCInterfaceDecl * getClassInterface() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Dataflow Directional Tag Classes.
std::string getAsString() const
getAsString - Retrieve the human-readable string for this name.
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.).
Kind getPropertyImplementation() const
bool isAccessDeclaration() const
Return true if it is a C++03 access declaration (no 'using').
const ObjCProtocolList & getReferencedProtocols() const
const Expr * getInit() const
AccessSpecifier getAccess() const
Represents a dependent using declaration which was marked with typename.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
unsigned getNumTemplateParameterLists() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
TypeSourceInfo * getTypeSourceInfo() const
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
The template argument is a type.
Represents a base class of a C++ class.
bool hasTypename() const
Return true if the using declaration has 'typename'.
A template argument list.
ArgKind getKind() const
Return the kind of stored template argument.
shadow_range shadows() 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)
bool isMutable() const
Determines whether this field is mutable (C++ only).
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...
base_class_iterator bases_end()
Declaration of a class template.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
StringLiteral - This represents a string literal expression, e.g.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
std::string getQualifiedNameAsString() const
The top declaration context.
QualType getAsType() const
Retrieve the type for a type template argument.
ObjCPropertyDecl * getPropertyDecl() const
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
This represents a decl that may have a name.
bool isTranslationUnit() const
Represents a C++ namespace alias.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Selector getGetterName() const
Represents C++ using-directive.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
This represents '#pragma omp threadprivate ...' directive.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
The parameter is invariant: must match exactly.
void dumpDeclContext() const
Declaration of a template function.
bool isDeletedAsWritten() const
const StringLiteral * getAsmString() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< ParmVarDecl * > parameters() const
ObjCCompatibleAliasDecl - Represents alias of a class.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
decl_iterator decls_end() const