26 #include "llvm/Support/raw_ostream.h"
27 using namespace clang;
28 using namespace clang::comments;
38 struct TerminalColor {
39 raw_ostream::Colors Color;
54 static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN,
true };
56 static const TerminalColor AttrColor = { raw_ostream::BLUE,
true };
58 static const TerminalColor StmtColor = { raw_ostream::MAGENTA,
true };
60 static const TerminalColor CommentColor = { raw_ostream::BLUE,
false };
63 static const TerminalColor TypeColor = { raw_ostream::GREEN,
false };
66 static const TerminalColor AddressColor = { raw_ostream::YELLOW,
false };
68 static const TerminalColor LocationColor = { raw_ostream::YELLOW,
false };
71 static const TerminalColor ValueKindColor = { raw_ostream::CYAN,
false };
73 static const TerminalColor ObjectKindColor = { raw_ostream::CYAN,
false };
76 static const TerminalColor NullColor = { raw_ostream::BLUE,
false };
79 static const TerminalColor UndeserializedColor = { raw_ostream::GREEN,
true };
82 static const TerminalColor CastColor = { raw_ostream::RED,
false };
85 static const TerminalColor ValueColor = { raw_ostream::CYAN,
true };
87 static const TerminalColor DeclNameColor = { raw_ostream::CYAN,
true };
90 static const TerminalColor IndentColor = { raw_ostream::BLUE,
false };
113 const char *LastLocFilename;
114 unsigned LastLocLine;
122 template<
typename Fn>
void dumpChild(Fn doDumpChild) {
128 while (!Pending.empty()) {
129 Pending.back()(
true);
139 auto dumpWithIndent = [
this, doDumpChild, OrigFC](
bool isLastChild) {
154 ColorScope Color(*
this, IndentColor);
155 OS << Prefix << (isLastChild ?
'`' :
'|') <<
'-';
156 this->Prefix.push_back(isLastChild ?
' ' :
'|');
157 this->Prefix.push_back(
' ');
161 unsigned Depth = Pending.size();
168 while (Depth < Pending.size()) {
169 Pending.back()(
true);
170 this->Pending.pop_back();
174 this->Prefix.resize(Prefix.size() - 2);
178 Pending.push_back(std::move(dumpWithIndent));
180 Pending.back()(
false);
181 Pending.back() = std::move(dumpWithIndent);
189 ColorScope(ASTDumper &Dumper, TerminalColor Color)
191 if (Dumper.ShowColors)
192 Dumper.OS.changeColor(Color.Color, Color.Bold);
195 if (Dumper.ShowColors)
196 Dumper.OS.resetColor();
203 : OS(OS), Traits(Traits), SM(SM), TopLevel(
true), FirstChild(
true),
204 LastLocFilename(
""), LastLocLine(~0U), FC(nullptr),
205 ShowColors(SM && SM->getDiagnostics().getShowColors()) { }
209 : OS(OS), Traits(Traits), SM(SM), TopLevel(
true), FirstChild(
true),
210 LastLocFilename(
""), LastLocLine(~0U),
211 ShowColors(ShowColors) { }
213 void dumpDecl(
const Decl *D);
214 void dumpStmt(
const Stmt *
S);
218 void dumpPointer(
const void *Ptr);
224 void dumpTypeAsChild(
const Type *T);
225 void dumpBareDeclRef(
const Decl *
Node);
226 void dumpDeclRef(
const Decl *
Node,
const char *Label =
nullptr);
230 void dumpLookups(
const DeclContext *DC,
bool DumpDecls);
231 void dumpAttr(
const Attr *A);
261 OS <<
" written as lvalue reference";
262 VisitReferenceType(T);
268 void VisitArrayType(
const ArrayType *T) {
293 void VisitDependentSizedExtVectorType(
314 if (EI.getNoReturn()) OS <<
" noreturn";
315 if (EI.getProducesResult()) OS <<
" produces_result";
316 if (EI.getHasRegParm()) OS <<
" regparm " << EI.
getRegParm();
322 if (EPI.HasTrailingReturn) OS <<
" trailing_return";
323 if (T->
isConst()) OS <<
" const";
326 switch (EPI.RefQualifier) {
333 VisitFunctionType(T);
337 dumpChild([=] { OS <<
"..."; });
354 OS <<
" underlying_type";
359 void VisitTagType(
const TagType *T) {
374 void VisitSubstTemplateTypeParmPackType(
379 void VisitAutoType(
const AutoType *T) {
388 dumpTemplateArgument(Arg);
389 if (T->isTypeAlias())
390 dumpTypeAsChild(T->getAliasedType());
418 void VisitEnumDecl(
const EnumDecl *D);
424 void VisitVarDecl(
const VarDecl *D);
436 template<
typename SpecializationDecl>
437 void VisitTemplateDeclSpecialization(
const SpecializationDecl *D,
438 bool DumpExplicitInst,
440 template<
typename TemplateDecl>
441 void VisitTemplateDecl(
const TemplateDecl *D,
bool DumpExplicitInst);
444 void VisitClassTemplateSpecializationDecl(
446 void VisitClassTemplatePartialSpecializationDecl(
448 void VisitClassScopeFunctionSpecializationDecl(
451 void VisitVarTemplateSpecializationDecl(
453 void VisitVarTemplatePartialSpecializationDecl(
540 const char *getCommandName(
unsigned CommandID);
563 void ASTDumper::dumpPointer(
const void *Ptr) {
564 ColorScope Color(*
this, AddressColor);
572 ColorScope Color(*
this, LocationColor);
580 OS <<
"<invalid sloc>";
584 if (strcmp(PLoc.
getFilename(), LastLocFilename) != 0) {
589 }
else if (PLoc.
getLine() != LastLocLine) {
590 OS <<
"line" <<
':' << PLoc.
getLine()
616 ColorScope Color(*
this, TypeColor);
621 if (Desugar && !T.
isNull()) {
624 if (T_split != D_split)
629 void ASTDumper::dumpType(
QualType T) {
634 void ASTDumper::dumpTypeAsChild(
QualType T) {
637 return dumpTypeAsChild(SQT.
Ty);
643 dumpBareType(T,
false);
649 void ASTDumper::dumpTypeAsChild(
const Type *T) {
652 ColorScope Color(*
this, NullColor);
658 ColorScope Color(*
this, TypeColor);
663 dumpBareType(
QualType(T, 0),
false);
667 if (SingleStepDesugar !=
QualType(T, 0))
672 OS <<
" instantiation_dependent";
674 OS <<
" variably_modified";
676 OS <<
" contains_unexpanded_pack";
682 if (SingleStepDesugar !=
QualType(T, 0))
683 dumpTypeAsChild(SingleStepDesugar);
687 void ASTDumper::dumpBareDeclRef(
const Decl *D) {
689 ColorScope Color(*
this, DeclKindNameColor);
694 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
695 ColorScope Color(*
this, DeclNameColor);
696 OS <<
" '" << ND->getDeclName() <<
'\'';
699 if (
const ValueDecl *VD = dyn_cast<ValueDecl>(D))
700 dumpType(VD->getType());
703 void ASTDumper::dumpDeclRef(
const Decl *D,
const char *Label) {
714 void ASTDumper::dumpName(
const NamedDecl *ND) {
716 ColorScope Color(*
this, DeclNameColor);
729 void ASTDumper::dumpDeclContext(
const DeclContext *DC) {
738 ColorScope Color(*
this, UndeserializedColor);
739 OS <<
"<undeserialized declarations>";
744 void ASTDumper::dumpLookups(
const DeclContext *DC,
bool DumpDecls) {
746 OS <<
"StoredDeclsMap ";
747 dumpBareDeclRef(cast<Decl>(DC));
752 dumpPointer(cast<Decl>(Primary));
764 OS <<
"DeclarationName ";
766 ColorScope Color(*
this, DeclNameColor);
767 OS <<
'\'' << Name <<
'\'';
773 dumpBareDeclRef(*RI);
775 if ((*RI)->isHidden())
781 std::function<void(Decl *)> DumpWithPrev = [&](
Decl *D) {
793 if (HasUndeserializedLookups) {
795 ColorScope Color(*
this, UndeserializedColor);
796 OS <<
"<undeserialized lookups>";
802 void ASTDumper::dumpAttr(
const Attr *A) {
805 ColorScope Color(*
this, AttrColor);
808 #define ATTR(X) case attr::X: OS << #X; break;
809 #include "clang/Basic/AttrList.inc"
811 llvm_unreachable(
"unexpected attribute kind");
821 #include "clang/AST/AttrDump.inc"
831 OS <<
" first " << First;
838 OS <<
" prev " << Prev;
845 #define DECL(DERIVED, BASE) \
846 case Decl::DERIVED: \
847 return dumpPreviousDeclImpl(OS, cast<DERIVED##Decl>(D));
848 #define ABSTRACT_DECL(DECL)
849 #include "clang/AST/DeclNodes.inc"
851 llvm_unreachable(
"Decl that isn't part of DeclNodes.inc!");
876 OS <<
"CXXCtorInitializer";
885 llvm_unreachable(
"Unknown initializer type");
900 void ASTDumper::dumpTemplateArgumentListInfo(
902 for (
unsigned i = 0, e = TALI.
size(); i < e; ++i)
903 dumpTemplateArgumentLoc(TALI[i]);
911 for (
unsigned i = 0, e = TAL.
size(); i < e; ++i)
912 dumpTemplateArgument(TAL[i]);
917 OS <<
"TemplateArgument";
944 OS <<
" template expansion";
955 dumpTemplateArgument(*I);
968 for (
auto typeParam : *typeParams) {
977 void ASTDumper::dumpDecl(
const Decl *D) {
980 ColorScope Color(*
this, NullColor);
986 ColorScope Color(*
this, DeclKindNameColor);
997 OS <<
" in " << M->getFullModuleName();
999 OS <<
" in (local) " << M->getFullModuleName();
1000 if (
auto *ND = dyn_cast<NamedDecl>(D))
1002 const_cast<NamedDecl *>(ND)))
1003 dumpChild([=] { OS <<
"also in " << M->getFullModuleName(); });
1004 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D))
1012 OS <<
" referenced";
1015 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
1016 if (FD->isConstexpr())
1031 if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D) &&
1032 hasNodes(dyn_cast<DeclContext>(D)))
1033 dumpDeclContext(cast<DeclContext>(D));
1037 void ASTDumper::VisitLabelDecl(
const LabelDecl *D) {
1041 void ASTDumper::VisitTypedefDecl(
const TypedefDecl *D) {
1045 OS <<
" __module_private__";
1048 void ASTDumper::VisitEnumDecl(
const EnumDecl *D) {
1057 OS <<
" __module_private__";
1062 void ASTDumper::VisitRecordDecl(
const RecordDecl *D) {
1066 OS <<
" __module_private__";
1068 OS <<
" definition";
1082 for (
auto *Child : D->
chain())
1086 void ASTDumper::VisitFunctionDecl(
const FunctionDecl *D) {
1098 OS <<
" __module_private__";
1120 dumpTemplateArgumentList(*FTSI->TemplateArguments);
1128 dumpChild([=] { OS <<
"<<NULL params x " << D->
getNumParams() <<
">>"; });
1139 dumpCXXCtorInitializer(*I);
1145 void ASTDumper::VisitFieldDecl(
const FieldDecl *D) {
1151 OS <<
" __module_private__";
1159 void ASTDumper::VisitVarDecl(
const VarDecl *D) {
1171 OS <<
" __module_private__";
1188 void ASTDumper::VisitImportDecl(
const ImportDecl *D) {
1196 void ASTDumper::VisitNamespaceDecl(
const NamespaceDecl *D) {
1214 void ASTDumper::VisitTypeAliasDecl(
const TypeAliasDecl *D) {
1225 void ASTDumper::VisitCXXRecordDecl(
const CXXRecordDecl *D) {
1230 for (
const auto &I : D->
bases()) {
1234 dumpAccessSpecifier(I.getAccessSpecifier());
1235 dumpType(I.getType());
1236 if (I.isPackExpansion())
1247 template<
typename SpecializationDecl>
1248 void ASTDumper::VisitTemplateDeclSpecialization(
const SpecializationDecl *D,
1249 bool DumpExplicitInst,
1251 bool DumpedAny =
false;
1252 for (
auto *RedeclWithBadType : D->redecls()) {
1256 auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
1260 assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
1261 "expected an injected-class-name");
1265 switch (Redecl->getTemplateSpecializationKind()) {
1268 if (!DumpExplicitInst)
1274 dumpDeclRef(Redecl);
1289 template<
typename TemplateDecl>
1290 void ASTDumper::VisitTemplateDecl(
const TemplateDecl *D,
1291 bool DumpExplicitInst) {
1297 for (
auto *Child : D->specializations())
1298 VisitTemplateDeclSpecialization(Child, DumpExplicitInst,
1306 VisitTemplateDecl(D,
true);
1310 VisitTemplateDecl(D,
false);
1313 void ASTDumper::VisitClassTemplateSpecializationDecl(
1315 VisitCXXRecordDecl(D);
1319 void ASTDumper::VisitClassTemplatePartialSpecializationDecl(
1321 VisitClassTemplateSpecializationDecl(D);
1325 void ASTDumper::VisitClassScopeFunctionSpecializationDecl(
1333 VisitTemplateDecl(D,
false);
1336 void ASTDumper::VisitVarTemplateSpecializationDecl(
1342 void ASTDumper::VisitVarTemplatePartialSpecializationDecl(
1345 VisitVarTemplateSpecializationDecl(D);
1369 void ASTDumper::VisitTemplateTemplateParmDecl(
1379 void ASTDumper::VisitUsingDecl(
const UsingDecl *D) {
1385 void ASTDumper::VisitUnresolvedUsingTypenameDecl(
1416 void ASTDumper::VisitFriendDecl(
const FriendDecl *D) {
1418 dumpType(T->getType());
1427 void ASTDumper::VisitObjCIvarDecl(
const ObjCIvarDecl *D) {
1431 OS <<
" synthesize";
1470 dumpChild([=] { OS <<
"..."; });
1487 OS <<
" contravariant";
1537 dumpCXXCtorInitializer(*I);
1575 OS <<
" unsafe_unretained";
1586 OS <<
" synthesize";
1593 void ASTDumper::VisitBlockDecl(
const BlockDecl *D) {
1594 for (
auto I : D->
params())
1598 dumpChild([=]{ OS <<
"..."; });
1601 dumpChild([=]{ OS <<
"capture this"; });
1603 for (
const auto &I : D->
captures()) {
1610 if (I.getVariable()) {
1612 dumpBareDeclRef(I.getVariable());
1614 if (I.hasCopyExpr())
1615 dumpStmt(I.getCopyExpr());
1625 void ASTDumper::dumpStmt(
const Stmt *
S) {
1628 ColorScope Color(*
this, NullColor);
1633 if (
const DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
1640 for (
const Stmt *SubStmt : S->children())
1645 void ASTDumper::VisitStmt(
const Stmt *
Node) {
1647 ColorScope Color(*
this, StmtColor);
1648 OS << Node->getStmtClassName();
1651 dumpSourceRange(Node->getSourceRange());
1654 void ASTDumper::VisitDeclStmt(
const DeclStmt *Node) {
1662 void ASTDumper::VisitAttributedStmt(
const AttributedStmt *Node) {
1670 void ASTDumper::VisitLabelStmt(
const LabelStmt *Node) {
1672 OS <<
" '" << Node->
getName() <<
"'";
1675 void ASTDumper::VisitGotoStmt(
const GotoStmt *Node) {
1681 void ASTDumper::VisitCXXCatchStmt(
const CXXCatchStmt *Node) {
1690 void ASTDumper::VisitExpr(
const Expr *Node) {
1695 ColorScope Color(*
this, ValueKindColor);
1709 ColorScope Color(*
this, ObjectKindColor);
1717 OS <<
" objcproperty";
1720 OS <<
" objcsubscript";
1723 OS <<
" vectorcomponent";
1754 void ASTDumper::VisitCastExpr(
const CastExpr *Node) {
1758 ColorScope Color(*
this, CastColor);
1765 void ASTDumper::VisitDeclRefExpr(
const DeclRefExpr *Node) {
1769 dumpBareDeclRef(Node->
getDecl());
1782 OS <<
"ADL) = '" << Node->
getName() <<
'\'';
1796 ColorScope Color(*
this, DeclKindNameColor);
1799 OS <<
"='" << *Node->
getDecl() <<
"'";
1802 OS <<
" isFreeIvar";
1805 void ASTDumper::VisitPredefinedExpr(
const PredefinedExpr *Node) {
1812 ColorScope Color(*
this, ValueColor);
1816 void ASTDumper::VisitIntegerLiteral(
const IntegerLiteral *Node) {
1820 ColorScope Color(*
this, ValueColor);
1821 OS <<
" " << Node->
getValue().toString(10, isSigned);
1826 ColorScope Color(*
this, ValueColor);
1830 void ASTDumper::VisitStringLiteral(
const StringLiteral *Str) {
1832 ColorScope Color(*
this, ValueColor);
1837 void ASTDumper::VisitInitListExpr(
const InitListExpr *ILE) {
1841 OS <<
"array filler";
1847 dumpBareDeclRef(Field);
1851 void ASTDumper::VisitUnaryOperator(
const UnaryOperator *Node) {
1853 OS <<
" " << (Node->
isPostfix() ?
"postfix" :
"prefix")
1857 void ASTDumper::VisitUnaryExprOrTypeTraitExpr(
1871 OS <<
" __builtin_omp_required_simd_align";
1878 void ASTDumper::VisitMemberExpr(
const MemberExpr *Node) {
1889 void ASTDumper::VisitBinaryOperator(
const BinaryOperator *Node) {
1894 void ASTDumper::VisitCompoundAssignOperator(
1898 <<
"' ComputeLHSTy=";
1900 OS <<
" ComputeResultTy=";
1904 void ASTDumper::VisitBlockExpr(
const BlockExpr *Node) {
1918 void ASTDumper::VisitAddrLabelExpr(
const AddrLabelExpr *Node) {
1939 OS <<
" " << (Node->
getValue() ?
"true" :
"false");
1942 void ASTDumper::VisitCXXThisExpr(
const CXXThisExpr *Node) {
1969 void ASTDumper::VisitCXXNewExpr(
const CXXNewExpr *Node) {
1983 void ASTDumper::VisitCXXDeleteExpr(
const CXXDeleteExpr *Node) {
1999 OS <<
" extended by ";
2000 dumpBareDeclRef(VD);
2006 for (
unsigned i = 0, e = Node->
getNumObjects(); i != e; ++i)
2007 dumpDeclRef(Node->
getObject(i),
"cleanup");
2010 void ASTDumper::dumpCXXTemporary(
const CXXTemporary *Temporary) {
2011 OS <<
"(CXXTemporary";
2012 dumpPointer(Temporary);
2016 void ASTDumper::VisitSizeOfPackExpr(
const SizeOfPackExpr *Node) {
2041 OS <<
" super (instance)";
2045 OS <<
" super (class)";
2050 void ASTDumper::VisitObjCBoxedExpr(
const ObjCBoxedExpr *Node) {
2059 dumpDecl(CatchParam);
2064 void ASTDumper::VisitObjCEncodeExpr(
const ObjCEncodeExpr *Node) {
2085 OS <<
" Kind=MethodRef Getter=\"";
2091 OS <<
"\" Setter=\"";
2093 Setter->getSelector().print(OS);
2104 OS <<
" Messaging=";
2106 OS <<
"Getter&Setter";
2116 OS <<
" Kind=ArraySubscript GetterForArray=\"";
2118 OS <<
" Kind=DictionarySubscript GetterForDictionary=\"";
2125 OS <<
"\" SetterForArray=\"";
2127 OS <<
"\" SetterForDictionary=\"";
2136 OS <<
" " << (Node->
getValue() ?
"__objc_yes" :
"__objc_no");
2143 const char *ASTDumper::getCommandName(
unsigned CommandID) {
2145 return Traits->getCommandInfo(CommandID)->Name;
2149 return "<not a builtin command>";
2152 void ASTDumper::dumpFullComment(
const FullComment *
C) {
2161 void ASTDumper::dumpComment(
const Comment *C) {
2164 ColorScope Color(*
this, NullColor);
2170 ColorScope Color(*
this, CommentColor);
2182 void ASTDumper::visitTextComment(
const TextComment *C) {
2183 OS <<
" Text=\"" << C->
getText() <<
"\"";
2187 OS <<
" Name=\"" << getCommandName(C->
getCommandID()) <<
"\"";
2190 OS <<
" RenderNormal";
2193 OS <<
" RenderBold";
2196 OS <<
" RenderMonospaced";
2199 OS <<
" RenderEmphasized";
2203 for (
unsigned i = 0, e = C->
getNumArgs(); i != e; ++i)
2204 OS <<
" Arg[" << i <<
"]=\"" << C->
getArgText(i) <<
"\"";
2211 for (
unsigned i = 0, e = C->
getNumAttrs(); i != e; ++i) {
2213 OS <<
" \"" << Attr.
Name <<
"=\"" << Attr.
Value <<
"\"";
2217 OS <<
" SelfClosing";
2225 OS <<
" Name=\"" << getCommandName(C->
getCommandID()) <<
"\"";
2226 for (
unsigned i = 0, e = C->
getNumArgs(); i != e; ++i)
2227 OS <<
" Arg[" << i <<
"]=\"" << C->
getArgText(i) <<
"\"";
2234 OS <<
" explicitly";
2236 OS <<
" implicitly";
2258 OS <<
" Position=<";
2259 for (
unsigned i = 0, e = C->
getDepth(); i != e; ++i) {
2269 OS <<
" Name=\"" << getCommandName(C->
getCommandID()) <<
"\""
2273 void ASTDumper::visitVerbatimBlockLineComment(
2275 OS <<
" Text=\"" << C->
getText() <<
"\"";
2279 OS <<
" Text=\"" << C->
getText() <<
"\"";
2288 llvm::errs() << msg <<
": ";
2293 ASTDumper Dumper(llvm::errs(),
nullptr,
nullptr);
2294 Dumper.dumpTypeAsChild(*
this);
2306 ASTDumper
P(OS, &getASTContext().getCommentCommandTraits(),
2307 &getASTContext().getSourceManager());
2312 ASTDumper
P(llvm::errs(), &getASTContext().getCommentCommandTraits(),
2313 &getASTContext().getSourceManager(),
true);
2318 dumpLookups(llvm::errs());
2322 bool DumpDecls)
const {
2326 ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
2328 P.dumpLookups(
this, DumpDecls);
2336 dump(llvm::errs(), SM);
2340 ASTDumper
P(OS,
nullptr, &SM);
2344 LLVM_DUMP_METHOD
void Stmt::dump(raw_ostream &OS)
const {
2345 ASTDumper
P(OS,
nullptr,
nullptr);
2350 ASTDumper
P(llvm::errs(),
nullptr,
nullptr);
2354 LLVM_DUMP_METHOD
void Stmt::dumpColor()
const {
2355 ASTDumper
P(llvm::errs(),
nullptr,
nullptr,
true);
2364 dump(llvm::errs(),
nullptr,
nullptr);
2375 ASTDumper D(OS, Traits, SM);
2376 D.dumpFullComment(FC);
2381 ASTDumper D(llvm::errs(),
nullptr,
nullptr,
true);
2382 D.dumpFullComment(FC);
decl_iterator noload_decls_end() const
unsigned getNumElements() const
The receiver is the instance of the superclass object.
param_const_iterator param_begin() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
Expr * getSizeExpr() const
const Type * Ty
The locally-unqualified type.
ObjCInterfaceDecl * getDecl() const
getDecl - Get the declaration of this interface.
ExprObjectKind getObjectKind() const
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
The receiver is an object instance.
StringRef getName() const
unsigned getDepth() const
protocol_range protocols() const
ParmVarDecl *const * param_const_iterator
Represents the dependent type named by a dependently-scoped typename using declaration, e.g. using typename Base<T>::foo; Template instantiation turns these into the underlying type.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
SourceRange getBracketsRange() const
unsigned getColumn() const
Return the presumed column number of this location.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
ObjCInterfaceDecl * getClassInterface()
bool isBitField() const
Determines whether this field is a bitfield.
QualType getType() const
Retrieves the type of the base class.
bool isElidable() const
Whether this construction is elidable.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
PropertyControl getPropertyImplementation() const
CXXMethodDecl * getSpecialization() const
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
bool isParameterPack() const
Returns whether this is a parameter pack.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
const Expr * getInitExpr() const
bool isArgumentType() const
bool isGlobalDelete() const
bool isMessagingGetter() const
True if the property reference will result in a message to the getter. This applies to both implicit ...
Defines the SourceManager interface.
CXXRecordDecl * getDecl() const
QualType getUnderlyingType() const
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Defines the clang::Module class, which describes a module in the source code.
ObjCMethodDecl * getAtIndexMethodDecl() const
chain_range chain() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Represents a C++11 auto or C++1y decltype(auto) type.
Represents an attribute applied to a statement.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
std::string getAsString() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
const char * getCastKindName() const
QualType getPointeeType() const
bool isThisDeclarationReferenced() const
Whether this declaration was referenced. This should not be relied upon for anything other than debug...
Declaration of a variable template.
const Expr * getInit() const
NamespaceDecl - Represent a C++ namespace.
Represents a call to a C++ constructor.
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
bool isDecltypeAuto() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isMessagingSetter() const
True if the property reference will result in a message to the setter. This applies to both implicit ...
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
bool isSpelledAsLValue() const
Expr * getInClassInitializer() const
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
IdentType getIdentType() const
const llvm::APInt & getSize() const
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
void * getAsOpaquePtr() const
bool hasExplicitTemplateArgs() const
const CXXBaseSpecifier *const * path_const_iterator
const TemplateArgumentListInfo & templateArgs() const
Expr * getInit() const
Get the initializer.
bool capturesCXXThis() const
TLSKind getTLSKind() const
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Represents an empty template argument, e.g., one that has not been deduced.
ExtProtoInfo - Extra information about a function prototype.
AccessSpecifier getAccess() const
std::string getAsString() const
Represents a variable template specialization, which refers to a variable template with a given set o...
TemplateTypeParmDecl * getDecl() const
QualType getOriginalType() const
UnaryExprOrTypeTrait getKind() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
Qualifiers getIndexTypeQualifiers() const
unsigned getValue() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Represents the result of substituting a type for a template type parameter.
void dump(const char *s) const
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
TypeSourceInfo * getFriendType() const
Kind getPropertyImplementation() const
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
ObjCTypeParamList * getTypeParamListAsWritten() const
Provides common interface for the Decls that can be redeclared.
QualType getElementType() const
Represents a class template specialization, which refers to a class template with a given set of temp...
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
ObjCProtocolDecl * getProtocol() const
comments::CommandTraits & getCommentCommandTraits() const
StringLiteral * getMessage()
A vector component is an element or range of elements on a vector.
Expr * getSizeExpr() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
ArrayRef< QualType > getParamTypes() const
protocol_iterator protocol_begin() const
bool isCompleteDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Represents the result of substituting a set of types for a template type parameter pack...
IdentifierInfo & getAccessor() const
Stmt * getBody() const override
Represents an access specifier followed by colon ':'.
unsigned getRegParm() const
Declaration of a function specialization at template class scope.
SourceRange getSourceRange() const LLVM_READONLY
Fetches the full source range of the argument.
Describes a module or submodule.
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
Expr * getUnderlyingExpr() const
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
const VarDecl * getCatchParamDecl() const
Represents Objective-C's @catch statement.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Describes an C or C++ initializer list.
Represents a C++ using-declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
TemplateArgument getArgumentPack() const
ObjCMethodDecl * getBoxingMethod() const
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
An lvalue ref-qualifier was provided (&).
bool isInline() const
Returns true if this is an inline namespace declaration.
ObjCTypeParamList * getTypeParamList() const
const ValueDecl * getExtendingDecl() const
Get the declaration which triggered the lifetime-extension of this temporary, if any.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
protocol_iterator protocol_end() const
QualType getReturnType() const
bool isSuperReceiver() const
UnresolvedUsingTypenameDecl * getDecl() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
path_iterator path_begin()
TypeOfExprType (GCC extension).
A builtin binary operation expression such as "x + y" or "x <= y".
Selector getSelector() const
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
std::string getNameAsString() const
QualType getDefaultArgument() const
Retrieve the default argument, if any.
QualType getTypeAsWritten() const
const Type * getBaseClass() const
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Represents an Objective-C protocol declaration.
Represents binding an expression to a temporary.
DeclContext * getLexicalDeclContext()
CXXTemporary * getTemporary()
void print(llvm::raw_ostream &OS) const
Prints the full selector name (e.g. "foo:bar:").
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
unsigned getLine() const
Return the presumed line number of this location.
Module * getLocalOwningModule() const
Get the local owning module, if known. Returns nullptr if owner is not yet known or declaration is no...
An ordinary object is located at an address in memory.
Represents an ObjC class declaration.
CleanupObject getObject(unsigned i) const
Represents a linkage specification.
ObjCMethodDecl * setAtIndexMethodDecl() const
PropertyAttributeKind getPropertyAttributes() const
FunctionDecl * SourceDecl
bool isFromAST() const
Whether this type comes from an AST file.
bool hasExplicitBound() const
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
param_iterator param_begin()
static void dumpPreviousDeclImpl(raw_ostream &OS,...)
Represents the this expression in C++.
FunctionDecl * getOperatorDelete() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
QualType getValueType() const
const ParmVarDecl *const * param_const_iterator
ExtInfo getExtInfo() const
llvm::APInt getValue() const
unsigned getNumObjects() const
ArrayRef< Module * > getModulesWithMergedDefinition(NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
decl_range noload_decls() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ArrayRef< NamedDecl * > getDeclsInPrototypeScope() const
SourceRange getRange() const
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
SplitQualType split() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
QualType getPointeeType() const
void outputString(raw_ostream &OS) const
static void dumpBasePath(raw_ostream &OS, const CastExpr *Node)
bool isDeletedAsWritten() const
decls_iterator decls_end() const
Declaration of a template type parameter.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
ObjCIvarDecl * getPropertyIvarDecl() const
double getValueAsApproximateDouble() const
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Expr * getBitWidth() const
bool isTypeAlias() const
Determine if this template specialization type is for a type alias template that has been substituted...
Expr * getUnderlyingExpr() const
ObjCMethodDecl * getImplicitPropertyGetter() const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
DeclContext * getDeclContext()
ObjCSelectorExpr used for @selector in Objective-C.
const char * getDeclKindName() const
Represents an expression that computes the length of a parameter pack.
Selector getSelector() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
SourceLocation getAttributeLoc() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
StorageClass
Storage classes.
bool isDependentType() const
bool isInstanceMethod() const
Direct list-initialization (C++11)
Qualifiers Quals
The local qualifiers.
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
An expression that sends a message to the given Objective-C object or class.
Represents an unpacked "presumed" location which can be presented to the user.
DeclarationName getDeclName() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
QualType getElementType() const
QualType getComputationLHSType() const
static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA)
DeclarationName getLookupName() const
UnresolvedSetImpl::iterator decls_iterator
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace. This is false for non-original (subsequent) namespace declarations and anonymous namespaces.
const clang::PrintingPolicy & getPrintingPolicy() const
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
ObjCCategoryDecl * getCategoryDecl() const
SourceRange getBracketsRange() const
param_const_iterator param_end() const
QualType getComputationResultType() const
LabelDecl * getLabel() const
decls_iterator decls_begin() const
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Stmt * getBody(const FunctionDecl *&Definition) const
bool doesThisDeclarationHaveABody() const
ExceptionSpecificationType Type
The kind of exception specification this is.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
const char * getFilename() const
Return the presumed filename of this location.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
unsigned getNumParams() const
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getElementType() const
Expr * getSourceExpr() const
Represents a C++ temporary.
const ObjCInterfaceDecl * getClassInterface() const
FieldDecl * getAnyMember() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
ASTContext & getASTContext() const LLVM_READONLY
decl_iterator noload_decls_begin() const
VectorKind getVectorKind() const
Represents a dependent using declaration which was not marked with typename.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
bool getSynthesize() const
No ref-qualifier was provided.
C-style initialization with assignment.
all_lookups_iterator noload_lookups_end() const
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
all_lookups_iterator noload_lookups_begin() const
Iterators over all possible lookups within this context that are currently loaded; don't attempt to r...
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
const ObjCInterfaceDecl * getClassInterface() const
NamedDecl * getPack() const
Retrieve the parameter pack.
decl_iterator decl_begin()
SplitQualType getSplitDesugaredType() const
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Represents one property declaration in an Objective-C interface.
TypedefNameDecl * getDecl() const
QualType getReturnType() const
SourceLocation getBegin() const
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 (&&).
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
const BlockDecl * getBlockDecl() const
QualType getType() const
Return the type wrapped by this type source info.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
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...
The injected class name of a C++ class template or class template partial specialization. Used to record that a type was spelled with a bare identifier rather than as a template-id; the equivalent for non-templated classes is just RecordType.
QualType getPointeeType() const
Represents a pack expansion of types.
static const char * getStorageClassSpecifierString(StorageClass SC)
const char * getCastName() const
const char * getTypeClassName() const
Expr * getSizeExpr() const
AddrLabelExpr - The GNU address of label extension, representing &&label.
attr::Kind getKind() const
ast_type_traits::DynTypedNode Node
TLS with a dynamic initializer.
Represents a template argument.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
QualType getAsType() const
Retrieve the type for a type template argument.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
bool isImplicitProperty() const
StringRef getOpcodeStr() const
ObjCCategoryImplDecl * getImplementation() const
not evaluated yet, for special member function
[C99 6.4.2.2] - A predefined identifier such as func.
Represents a delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray"...
The base class of all kinds of template declarations (e.g., class, function, etc.).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
bool isInvalidDecl() const
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user...
bool isParameterPack() const
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Represents a dependent using declaration which was marked with typename.
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Selector getSelector() const
QualType getModifiedType() const
attr_iterator attr_end() const
param_iterator param_end()
QualType getPointeeType() const
ObjCMethodDecl * getGetterMethodDecl() const
FunctionDecl * SourceTemplate
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
FunctionDecl * getOperatorNew() const
NamedDecl * getFriendDecl() const
Represents a C++ base or member initializer.
static StringRef getIdentTypeName(IdentType IT)
void dump(raw_ostream &OS) const
Debugging aid that dumps the template name.
ObjCMethodDecl * getSetterMethodDecl() const
ObjCProtocolList::iterator protocol_iterator
QualType getIntegerType() const
bool hasBody() const override
Determine whether this method has a body.
DeclGroupRef::const_iterator const_decl_iterator
CXXConstructorDecl * getConstructor() const
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
The template argument is a type.
protocol_range protocols() const
ObjCImplementationDecl * getImplementation() const
LabelDecl * getLabel() const
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Represents a base class of a C++ class.
ObjCPropertyDecl * getExplicitProperty() const
A bitfield object is a bitfield on a C or C++ record.
bool isAnyMemberInitializer() const
QualType getPointeeType() const
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
ArrayRef< const Attr * > getAttrs() const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
const Type * getClass() const
ObjCPropertyDecl * getPropertyDecl() const
AccessControl getAccessControl() const
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Call-style initialization (C++98)
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Represents a C++ struct/union/class.
bool hasQualifiers() const
hasQualifiers - Return true if the set contains any qualifiers.
QualType getEncodedType() const
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
ArraySizeModifier getSizeModifier() const
Declaration of a class template.
static void dumpPreviousDecl(raw_ostream &OS, const Decl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
DeclarationName getName() const
Gets the name looked up.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
TLS with a known-constant initializer.
ObjCInterfaceDecl * getSuperClass() const
TagDecl * getDecl() const
Abstract class common to all of the C++ "named"/"keyword" casts.
VarDecl * getExceptionDecl() const
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Represents a type template specialization; the template must be a class template, a type alias templa...
QualType getElementType() const
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
DeclContext * getPrimaryContext()
bool isArraySubscriptRefExpr() const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
attr_iterator attr_begin() const
static StringRef getNameForCallConv(CallingConv CC)
An l-value expression is a reference to an object with independent storage.
StringRef getKindName() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
static StringRef getOpcodeStr(Opcode Op)
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a C++ namespace alias.
bool isSignedIntegerType() const
Represents C++ using-directive.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
The receiver is a superclass.
const char * getName() const
A simple visitor class that helps create declaration visitors.
const TemplateArgument & getArgument() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
This class handles loading and caching of source files into memory.
The parameter is invariant: must match exactly.
ExceptionSpecInfo ExceptionSpec
Declaration of a template function.
AttrVec::const_iterator attr_iterator
ObjCMethodDecl * getImplicitPropertySetter() const
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Attr - This represents one attribute.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
const ObjCInterfaceDecl * getSuperClass() const
const StringLiteral * getAsmString() const
QualType getArgumentType() const
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.