clang  3.8.0
ASTDumper.cpp
Go to the documentation of this file.
1 //===--- ASTDumper.cpp - Dumping implementation for ASTs ------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AST dump methods, which dump out the
11 // AST in a form that exposes type details and other fields.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Attr.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclLookups.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "clang/AST/DeclVisitor.h"
22 #include "clang/AST/StmtVisitor.h"
23 #include "clang/AST/TypeVisitor.h"
24 #include "clang/Basic/Builtins.h"
25 #include "clang/Basic/Module.h"
27 #include "clang/Sema/LocInfoType.h"
28 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
30 using namespace clang::comments;
31 
32 //===----------------------------------------------------------------------===//
33 // ASTDumper Visitor
34 //===----------------------------------------------------------------------===//
35 
36 namespace {
37  // Colors used for various parts of the AST dump
38  // Do not use bold yellow for any text. It is hard to read on white screens.
39 
40  struct TerminalColor {
41  raw_ostream::Colors Color;
42  bool Bold;
43  };
44 
45  // Red - CastColor
46  // Green - TypeColor
47  // Bold Green - DeclKindNameColor, UndeserializedColor
48  // Yellow - AddressColor, LocationColor
49  // Blue - CommentColor, NullColor, IndentColor
50  // Bold Blue - AttrColor
51  // Bold Magenta - StmtColor
52  // Cyan - ValueKindColor, ObjectKindColor
53  // Bold Cyan - ValueColor, DeclNameColor
54 
55  // Decl kind names (VarDecl, FunctionDecl, etc)
56  static const TerminalColor DeclKindNameColor = { raw_ostream::GREEN, true };
57  // Attr names (CleanupAttr, GuardedByAttr, etc)
58  static const TerminalColor AttrColor = { raw_ostream::BLUE, true };
59  // Statement names (DeclStmt, ImplicitCastExpr, etc)
60  static const TerminalColor StmtColor = { raw_ostream::MAGENTA, true };
61  // Comment names (FullComment, ParagraphComment, TextComment, etc)
62  static const TerminalColor CommentColor = { raw_ostream::BLUE, false };
63 
64  // Type names (int, float, etc, plus user defined types)
65  static const TerminalColor TypeColor = { raw_ostream::GREEN, false };
66 
67  // Pointer address
68  static const TerminalColor AddressColor = { raw_ostream::YELLOW, false };
69  // Source locations
70  static const TerminalColor LocationColor = { raw_ostream::YELLOW, false };
71 
72  // lvalue/xvalue
73  static const TerminalColor ValueKindColor = { raw_ostream::CYAN, false };
74  // bitfield/objcproperty/objcsubscript/vectorcomponent
75  static const TerminalColor ObjectKindColor = { raw_ostream::CYAN, false };
76 
77  // Null statements
78  static const TerminalColor NullColor = { raw_ostream::BLUE, false };
79 
80  // Undeserialized entities
81  static const TerminalColor UndeserializedColor = { raw_ostream::GREEN, true };
82 
83  // CastKind from CastExpr's
84  static const TerminalColor CastColor = { raw_ostream::RED, false };
85 
86  // Value of the statement
87  static const TerminalColor ValueColor = { raw_ostream::CYAN, true };
88  // Decl names
89  static const TerminalColor DeclNameColor = { raw_ostream::CYAN, true };
90 
91  // Indents ( `, -. | )
92  static const TerminalColor IndentColor = { raw_ostream::BLUE, false };
93 
94  class ASTDumper
95  : public ConstDeclVisitor<ASTDumper>, public ConstStmtVisitor<ASTDumper>,
96  public ConstCommentVisitor<ASTDumper>, public TypeVisitor<ASTDumper> {
97  raw_ostream &OS;
98  const CommandTraits *Traits;
99  const SourceManager *SM;
100 
101  /// Pending[i] is an action to dump an entity at level i.
103 
104  /// Indicates whether we're at the top level.
105  bool TopLevel;
106 
107  /// Indicates if we're handling the first child after entering a new depth.
108  bool FirstChild;
109 
110  /// Prefix for currently-being-dumped entity.
111  std::string Prefix;
112 
113  /// Keep track of the last location we print out so that we can
114  /// print out deltas from then on out.
115  const char *LastLocFilename;
116  unsigned LastLocLine;
117 
118  /// The \c FullComment parent of the comment being dumped.
119  const FullComment *FC;
120 
121  bool ShowColors;
122 
123  /// Dump a child of the current node.
124  template<typename Fn> void dumpChild(Fn doDumpChild) {
125  // If we're at the top level, there's nothing interesting to do; just
126  // run the dumper.
127  if (TopLevel) {
128  TopLevel = false;
129  doDumpChild();
130  while (!Pending.empty()) {
131  Pending.back()(true);
132  Pending.pop_back();
133  }
134  Prefix.clear();
135  OS << "\n";
136  TopLevel = true;
137  return;
138  }
139 
140  const FullComment *OrigFC = FC;
141  auto dumpWithIndent = [this, doDumpChild, OrigFC](bool isLastChild) {
142  // Print out the appropriate tree structure and work out the prefix for
143  // children of this node. For instance:
144  //
145  // A Prefix = ""
146  // |-B Prefix = "| "
147  // | `-C Prefix = "| "
148  // `-D Prefix = " "
149  // |-E Prefix = " | "
150  // `-F Prefix = " "
151  // G Prefix = ""
152  //
153  // Note that the first level gets no prefix.
154  {
155  OS << '\n';
156  ColorScope Color(*this, IndentColor);
157  OS << Prefix << (isLastChild ? '`' : '|') << '-';
158  this->Prefix.push_back(isLastChild ? ' ' : '|');
159  this->Prefix.push_back(' ');
160  }
161 
162  FirstChild = true;
163  unsigned Depth = Pending.size();
164 
165  FC = OrigFC;
166  doDumpChild();
167 
168  // If any children are left, they're the last at their nesting level.
169  // Dump those ones out now.
170  while (Depth < Pending.size()) {
171  Pending.back()(true);
172  this->Pending.pop_back();
173  }
174 
175  // Restore the old prefix.
176  this->Prefix.resize(Prefix.size() - 2);
177  };
178 
179  if (FirstChild) {
180  Pending.push_back(std::move(dumpWithIndent));
181  } else {
182  Pending.back()(false);
183  Pending.back() = std::move(dumpWithIndent);
184  }
185  FirstChild = false;
186  }
187 
188  class ColorScope {
189  ASTDumper &Dumper;
190  public:
191  ColorScope(ASTDumper &Dumper, TerminalColor Color)
192  : Dumper(Dumper) {
193  if (Dumper.ShowColors)
194  Dumper.OS.changeColor(Color.Color, Color.Bold);
195  }
196  ~ColorScope() {
197  if (Dumper.ShowColors)
198  Dumper.OS.resetColor();
199  }
200  };
201 
202  public:
203  ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
204  const SourceManager *SM)
205  : OS(OS), Traits(Traits), SM(SM), TopLevel(true), FirstChild(true),
206  LastLocFilename(""), LastLocLine(~0U), FC(nullptr),
207  ShowColors(SM && SM->getDiagnostics().getShowColors()) { }
208 
209  ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
210  const SourceManager *SM, bool ShowColors)
211  : OS(OS), Traits(Traits), SM(SM), TopLevel(true), FirstChild(true),
212  LastLocFilename(""), LastLocLine(~0U),
213  ShowColors(ShowColors) { }
214 
215  void dumpDecl(const Decl *D);
216  void dumpStmt(const Stmt *S);
217  void dumpFullComment(const FullComment *C);
218 
219  // Utilities
220  void dumpPointer(const void *Ptr);
221  void dumpSourceRange(SourceRange R);
222  void dumpLocation(SourceLocation Loc);
223  void dumpBareType(QualType T, bool Desugar = true);
224  void dumpType(QualType T);
225  void dumpTypeAsChild(QualType T);
226  void dumpTypeAsChild(const Type *T);
227  void dumpBareDeclRef(const Decl *Node);
228  void dumpDeclRef(const Decl *Node, const char *Label = nullptr);
229  void dumpName(const NamedDecl *D);
230  bool hasNodes(const DeclContext *DC);
231  void dumpDeclContext(const DeclContext *DC);
232  void dumpLookups(const DeclContext *DC, bool DumpDecls);
233  void dumpAttr(const Attr *A);
234 
235  // C++ Utilities
236  void dumpAccessSpecifier(AccessSpecifier AS);
237  void dumpCXXCtorInitializer(const CXXCtorInitializer *Init);
238  void dumpTemplateParameters(const TemplateParameterList *TPL);
239  void dumpTemplateArgumentListInfo(const TemplateArgumentListInfo &TALI);
240  void dumpTemplateArgumentLoc(const TemplateArgumentLoc &A);
241  void dumpTemplateArgumentList(const TemplateArgumentList &TAL);
242  void dumpTemplateArgument(const TemplateArgument &A,
243  SourceRange R = SourceRange());
244 
245  // Objective-C utilities.
246  void dumpObjCTypeParamList(const ObjCTypeParamList *typeParams);
247 
248  // Types
249  void VisitComplexType(const ComplexType *T) {
250  dumpTypeAsChild(T->getElementType());
251  }
252  void VisitPointerType(const PointerType *T) {
253  dumpTypeAsChild(T->getPointeeType());
254  }
255  void VisitBlockPointerType(const BlockPointerType *T) {
256  dumpTypeAsChild(T->getPointeeType());
257  }
258  void VisitReferenceType(const ReferenceType *T) {
259  dumpTypeAsChild(T->getPointeeType());
260  }
261  void VisitRValueReferenceType(const ReferenceType *T) {
262  if (T->isSpelledAsLValue())
263  OS << " written as lvalue reference";
264  VisitReferenceType(T);
265  }
266  void VisitMemberPointerType(const MemberPointerType *T) {
267  dumpTypeAsChild(T->getClass());
268  dumpTypeAsChild(T->getPointeeType());
269  }
270  void VisitArrayType(const ArrayType *T) {
271  switch (T->getSizeModifier()) {
272  case ArrayType::Normal: break;
273  case ArrayType::Static: OS << " static"; break;
274  case ArrayType::Star: OS << " *"; break;
275  }
276  OS << " " << T->getIndexTypeQualifiers().getAsString();
277  dumpTypeAsChild(T->getElementType());
278  }
279  void VisitConstantArrayType(const ConstantArrayType *T) {
280  OS << " " << T->getSize();
281  VisitArrayType(T);
282  }
283  void VisitVariableArrayType(const VariableArrayType *T) {
284  OS << " ";
285  dumpSourceRange(T->getBracketsRange());
286  VisitArrayType(T);
287  dumpStmt(T->getSizeExpr());
288  }
289  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
290  VisitArrayType(T);
291  OS << " ";
292  dumpSourceRange(T->getBracketsRange());
293  dumpStmt(T->getSizeExpr());
294  }
295  void VisitDependentSizedExtVectorType(
296  const DependentSizedExtVectorType *T) {
297  OS << " ";
298  dumpLocation(T->getAttributeLoc());
299  dumpTypeAsChild(T->getElementType());
300  dumpStmt(T->getSizeExpr());
301  }
302  void VisitVectorType(const VectorType *T) {
303  switch (T->getVectorKind()) {
304  case VectorType::GenericVector: break;
305  case VectorType::AltiVecVector: OS << " altivec"; break;
306  case VectorType::AltiVecPixel: OS << " altivec pixel"; break;
307  case VectorType::AltiVecBool: OS << " altivec bool"; break;
308  case VectorType::NeonVector: OS << " neon"; break;
309  case VectorType::NeonPolyVector: OS << " neon poly"; break;
310  }
311  OS << " " << T->getNumElements();
312  dumpTypeAsChild(T->getElementType());
313  }
314  void VisitFunctionType(const FunctionType *T) {
315  auto EI = T->getExtInfo();
316  if (EI.getNoReturn()) OS << " noreturn";
317  if (EI.getProducesResult()) OS << " produces_result";
318  if (EI.getHasRegParm()) OS << " regparm " << EI.getRegParm();
319  OS << " " << FunctionType::getNameForCallConv(EI.getCC());
320  dumpTypeAsChild(T->getReturnType());
321  }
322  void VisitFunctionProtoType(const FunctionProtoType *T) {
323  auto EPI = T->getExtProtoInfo();
324  if (EPI.HasTrailingReturn) OS << " trailing_return";
325  if (T->isConst()) OS << " const";
326  if (T->isVolatile()) OS << " volatile";
327  if (T->isRestrict()) OS << " restrict";
328  switch (EPI.RefQualifier) {
329  case RQ_None: break;
330  case RQ_LValue: OS << " &"; break;
331  case RQ_RValue: OS << " &&"; break;
332  }
333  // FIXME: Exception specification.
334  // FIXME: Consumed parameters.
335  VisitFunctionType(T);
336  for (QualType PT : T->getParamTypes())
337  dumpTypeAsChild(PT);
338  if (EPI.Variadic)
339  dumpChild([=] { OS << "..."; });
340  }
341  void VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
342  dumpDeclRef(T->getDecl());
343  }
344  void VisitTypedefType(const TypedefType *T) {
345  dumpDeclRef(T->getDecl());
346  }
347  void VisitTypeOfExprType(const TypeOfExprType *T) {
348  dumpStmt(T->getUnderlyingExpr());
349  }
350  void VisitDecltypeType(const DecltypeType *T) {
351  dumpStmt(T->getUnderlyingExpr());
352  }
353  void VisitUnaryTransformType(const UnaryTransformType *T) {
354  switch (T->getUTTKind()) {
356  OS << " underlying_type";
357  break;
358  }
359  dumpTypeAsChild(T->getBaseType());
360  }
361  void VisitTagType(const TagType *T) {
362  dumpDeclRef(T->getDecl());
363  }
364  void VisitAttributedType(const AttributedType *T) {
365  // FIXME: AttrKind
366  dumpTypeAsChild(T->getModifiedType());
367  }
368  void VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
369  OS << " depth " << T->getDepth() << " index " << T->getIndex();
370  if (T->isParameterPack()) OS << " pack";
371  dumpDeclRef(T->getDecl());
372  }
373  void VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
374  dumpTypeAsChild(T->getReplacedParameter());
375  }
376  void VisitSubstTemplateTypeParmPackType(
378  dumpTypeAsChild(T->getReplacedParameter());
379  dumpTemplateArgument(T->getArgumentPack());
380  }
381  void VisitAutoType(const AutoType *T) {
382  if (T->isDecltypeAuto()) OS << " decltype(auto)";
383  if (!T->isDeduced())
384  OS << " undeduced";
385  }
386  void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
387  if (T->isTypeAlias()) OS << " alias";
388  OS << " "; T->getTemplateName().dump(OS);
389  for (auto &Arg : *T)
390  dumpTemplateArgument(Arg);
391  if (T->isTypeAlias())
392  dumpTypeAsChild(T->getAliasedType());
393  }
394  void VisitInjectedClassNameType(const InjectedClassNameType *T) {
395  dumpDeclRef(T->getDecl());
396  }
397  void VisitObjCInterfaceType(const ObjCInterfaceType *T) {
398  dumpDeclRef(T->getDecl());
399  }
400  void VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
401  dumpTypeAsChild(T->getPointeeType());
402  }
403  void VisitAtomicType(const AtomicType *T) {
404  dumpTypeAsChild(T->getValueType());
405  }
406  void VisitAdjustedType(const AdjustedType *T) {
407  dumpTypeAsChild(T->getOriginalType());
408  }
409  void VisitPackExpansionType(const PackExpansionType *T) {
410  if (auto N = T->getNumExpansions()) OS << " expansions " << *N;
411  if (!T->isSugared())
412  dumpTypeAsChild(T->getPattern());
413  }
414  // FIXME: ElaboratedType, DependentNameType,
415  // DependentTemplateSpecializationType, ObjCObjectType
416 
417  // Decls
418  void VisitLabelDecl(const LabelDecl *D);
419  void VisitTypedefDecl(const TypedefDecl *D);
420  void VisitEnumDecl(const EnumDecl *D);
421  void VisitRecordDecl(const RecordDecl *D);
422  void VisitEnumConstantDecl(const EnumConstantDecl *D);
423  void VisitIndirectFieldDecl(const IndirectFieldDecl *D);
424  void VisitFunctionDecl(const FunctionDecl *D);
425  void VisitFieldDecl(const FieldDecl *D);
426  void VisitVarDecl(const VarDecl *D);
427  void VisitFileScopeAsmDecl(const FileScopeAsmDecl *D);
428  void VisitImportDecl(const ImportDecl *D);
429 
430  // C++ Decls
431  void VisitNamespaceDecl(const NamespaceDecl *D);
432  void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D);
433  void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D);
434  void VisitTypeAliasDecl(const TypeAliasDecl *D);
435  void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D);
436  void VisitCXXRecordDecl(const CXXRecordDecl *D);
437  void VisitStaticAssertDecl(const StaticAssertDecl *D);
438  template<typename SpecializationDecl>
439  void VisitTemplateDeclSpecialization(const SpecializationDecl *D,
440  bool DumpExplicitInst,
441  bool DumpRefOnly);
442  template<typename TemplateDecl>
443  void VisitTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
444  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
445  void VisitClassTemplateDecl(const ClassTemplateDecl *D);
446  void VisitClassTemplateSpecializationDecl(
448  void VisitClassTemplatePartialSpecializationDecl(
450  void VisitClassScopeFunctionSpecializationDecl(
452  void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
453  void VisitVarTemplateDecl(const VarTemplateDecl *D);
454  void VisitVarTemplateSpecializationDecl(
456  void VisitVarTemplatePartialSpecializationDecl(
458  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
459  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
460  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
461  void VisitUsingDecl(const UsingDecl *D);
462  void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D);
463  void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
464  void VisitUsingShadowDecl(const UsingShadowDecl *D);
465  void VisitLinkageSpecDecl(const LinkageSpecDecl *D);
466  void VisitAccessSpecDecl(const AccessSpecDecl *D);
467  void VisitFriendDecl(const FriendDecl *D);
468 
469  // ObjC Decls
470  void VisitObjCIvarDecl(const ObjCIvarDecl *D);
471  void VisitObjCMethodDecl(const ObjCMethodDecl *D);
472  void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D);
473  void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
474  void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D);
475  void VisitObjCProtocolDecl(const ObjCProtocolDecl *D);
476  void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
477  void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
478  void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
479  void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
480  void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
481  void VisitBlockDecl(const BlockDecl *D);
482 
483  // Stmts.
484  void VisitStmt(const Stmt *Node);
485  void VisitDeclStmt(const DeclStmt *Node);
486  void VisitAttributedStmt(const AttributedStmt *Node);
487  void VisitLabelStmt(const LabelStmt *Node);
488  void VisitGotoStmt(const GotoStmt *Node);
489  void VisitCXXCatchStmt(const CXXCatchStmt *Node);
490 
491  // Exprs
492  void VisitExpr(const Expr *Node);
493  void VisitCastExpr(const CastExpr *Node);
494  void VisitDeclRefExpr(const DeclRefExpr *Node);
495  void VisitPredefinedExpr(const PredefinedExpr *Node);
496  void VisitCharacterLiteral(const CharacterLiteral *Node);
497  void VisitIntegerLiteral(const IntegerLiteral *Node);
498  void VisitFloatingLiteral(const FloatingLiteral *Node);
499  void VisitStringLiteral(const StringLiteral *Str);
500  void VisitInitListExpr(const InitListExpr *ILE);
501  void VisitUnaryOperator(const UnaryOperator *Node);
502  void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
503  void VisitMemberExpr(const MemberExpr *Node);
504  void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node);
505  void VisitBinaryOperator(const BinaryOperator *Node);
506  void VisitCompoundAssignOperator(const CompoundAssignOperator *Node);
507  void VisitAddrLabelExpr(const AddrLabelExpr *Node);
508  void VisitBlockExpr(const BlockExpr *Node);
509  void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
510 
511  // C++
512  void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node);
513  void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node);
514  void VisitCXXThisExpr(const CXXThisExpr *Node);
515  void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node);
516  void VisitCXXConstructExpr(const CXXConstructExpr *Node);
517  void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
518  void VisitCXXNewExpr(const CXXNewExpr *Node);
519  void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
520  void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
521  void VisitExprWithCleanups(const ExprWithCleanups *Node);
522  void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
523  void dumpCXXTemporary(const CXXTemporary *Temporary);
524  void VisitLambdaExpr(const LambdaExpr *Node) {
525  VisitExpr(Node);
526  dumpDecl(Node->getLambdaClass());
527  }
528  void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
529 
530  // ObjC
531  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
532  void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node);
533  void VisitObjCMessageExpr(const ObjCMessageExpr *Node);
534  void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node);
535  void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node);
536  void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node);
537  void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node);
538  void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
539  void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
540  void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
541 
542  // Comments.
543  const char *getCommandName(unsigned CommandID);
544  void dumpComment(const Comment *C);
545 
546  // Inline comments.
547  void visitTextComment(const TextComment *C);
548  void visitInlineCommandComment(const InlineCommandComment *C);
549  void visitHTMLStartTagComment(const HTMLStartTagComment *C);
550  void visitHTMLEndTagComment(const HTMLEndTagComment *C);
551 
552  // Block comments.
553  void visitBlockCommandComment(const BlockCommandComment *C);
554  void visitParamCommandComment(const ParamCommandComment *C);
555  void visitTParamCommandComment(const TParamCommandComment *C);
556  void visitVerbatimBlockComment(const VerbatimBlockComment *C);
557  void visitVerbatimBlockLineComment(const VerbatimBlockLineComment *C);
558  void visitVerbatimLineComment(const VerbatimLineComment *C);
559  };
560 }
561 
562 //===----------------------------------------------------------------------===//
563 // Utilities
564 //===----------------------------------------------------------------------===//
565 
566 void ASTDumper::dumpPointer(const void *Ptr) {
567  ColorScope Color(*this, AddressColor);
568  OS << ' ' << Ptr;
569 }
570 
571 void ASTDumper::dumpLocation(SourceLocation Loc) {
572  if (!SM)
573  return;
574 
575  ColorScope Color(*this, LocationColor);
576  SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
577 
578  // The general format we print out is filename:line:col, but we drop pieces
579  // that haven't changed since the last loc printed.
580  PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
581 
582  if (PLoc.isInvalid()) {
583  OS << "<invalid sloc>";
584  return;
585  }
586 
587  if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
588  OS << PLoc.getFilename() << ':' << PLoc.getLine()
589  << ':' << PLoc.getColumn();
590  LastLocFilename = PLoc.getFilename();
591  LastLocLine = PLoc.getLine();
592  } else if (PLoc.getLine() != LastLocLine) {
593  OS << "line" << ':' << PLoc.getLine()
594  << ':' << PLoc.getColumn();
595  LastLocLine = PLoc.getLine();
596  } else {
597  OS << "col" << ':' << PLoc.getColumn();
598  }
599 }
600 
601 void ASTDumper::dumpSourceRange(SourceRange R) {
602  // Can't translate locations if a SourceManager isn't available.
603  if (!SM)
604  return;
605 
606  OS << " <";
607  dumpLocation(R.getBegin());
608  if (R.getBegin() != R.getEnd()) {
609  OS << ", ";
610  dumpLocation(R.getEnd());
611  }
612  OS << ">";
613 
614  // <t2.c:123:421[blah], t2.c:412:321>
615 
616 }
617 
618 void ASTDumper::dumpBareType(QualType T, bool Desugar) {
619  ColorScope Color(*this, TypeColor);
620 
621  SplitQualType T_split = T.split();
622  OS << "'" << QualType::getAsString(T_split) << "'";
623 
624  if (Desugar && !T.isNull()) {
625  // If the type is sugared, also dump a (shallow) desugared type.
626  SplitQualType D_split = T.getSplitDesugaredType();
627  if (T_split != D_split)
628  OS << ":'" << QualType::getAsString(D_split) << "'";
629  }
630 }
631 
632 void ASTDumper::dumpType(QualType T) {
633  OS << ' ';
634  dumpBareType(T);
635 }
636 
637 void ASTDumper::dumpTypeAsChild(QualType T) {
638  SplitQualType SQT = T.split();
639  if (!SQT.Quals.hasQualifiers())
640  return dumpTypeAsChild(SQT.Ty);
641 
642  dumpChild([=] {
643  OS << "QualType";
644  dumpPointer(T.getAsOpaquePtr());
645  OS << " ";
646  dumpBareType(T, false);
647  OS << " " << T.split().Quals.getAsString();
648  dumpTypeAsChild(T.split().Ty);
649  });
650 }
651 
652 void ASTDumper::dumpTypeAsChild(const Type *T) {
653  dumpChild([=] {
654  if (!T) {
655  ColorScope Color(*this, NullColor);
656  OS << "<<<NULL>>>";
657  return;
658  }
659  if (const LocInfoType *LIT = llvm::dyn_cast<LocInfoType>(T)) {
660  {
661  ColorScope Color(*this, TypeColor);
662  OS << "LocInfo Type";
663  }
664  dumpPointer(T);
665  dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
666  return;
667  }
668 
669  {
670  ColorScope Color(*this, TypeColor);
671  OS << T->getTypeClassName() << "Type";
672  }
673  dumpPointer(T);
674  OS << " ";
675  dumpBareType(QualType(T, 0), false);
676 
677  QualType SingleStepDesugar =
679  if (SingleStepDesugar != QualType(T, 0))
680  OS << " sugar";
681  if (T->isDependentType())
682  OS << " dependent";
683  else if (T->isInstantiationDependentType())
684  OS << " instantiation_dependent";
685  if (T->isVariablyModifiedType())
686  OS << " variably_modified";
688  OS << " contains_unexpanded_pack";
689  if (T->isFromAST())
690  OS << " imported";
691 
693 
694  if (SingleStepDesugar != QualType(T, 0))
695  dumpTypeAsChild(SingleStepDesugar);
696  });
697 }
698 
699 void ASTDumper::dumpBareDeclRef(const Decl *D) {
700  {
701  ColorScope Color(*this, DeclKindNameColor);
702  OS << D->getDeclKindName();
703  }
704  dumpPointer(D);
705 
706  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
707  ColorScope Color(*this, DeclNameColor);
708  OS << " '" << ND->getDeclName() << '\'';
709  }
710 
711  if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))
712  dumpType(VD->getType());
713 }
714 
715 void ASTDumper::dumpDeclRef(const Decl *D, const char *Label) {
716  if (!D)
717  return;
718 
719  dumpChild([=]{
720  if (Label)
721  OS << Label << ' ';
722  dumpBareDeclRef(D);
723  });
724 }
725 
726 void ASTDumper::dumpName(const NamedDecl *ND) {
727  if (ND->getDeclName()) {
728  ColorScope Color(*this, DeclNameColor);
729  OS << ' ' << ND->getNameAsString();
730  }
731 }
732 
733 bool ASTDumper::hasNodes(const DeclContext *DC) {
734  if (!DC)
735  return false;
736 
737  return DC->hasExternalLexicalStorage() ||
738  DC->noload_decls_begin() != DC->noload_decls_end();
739 }
740 
741 void ASTDumper::dumpDeclContext(const DeclContext *DC) {
742  if (!DC)
743  return;
744 
745  for (auto *D : DC->noload_decls())
746  dumpDecl(D);
747 
748  if (DC->hasExternalLexicalStorage()) {
749  dumpChild([=]{
750  ColorScope Color(*this, UndeserializedColor);
751  OS << "<undeserialized declarations>";
752  });
753  }
754 }
755 
756 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
757  dumpChild([=] {
758  OS << "StoredDeclsMap ";
759  dumpBareDeclRef(cast<Decl>(DC));
760 
761  const DeclContext *Primary = DC->getPrimaryContext();
762  if (Primary != DC) {
763  OS << " primary";
764  dumpPointer(cast<Decl>(Primary));
765  }
766 
767  bool HasUndeserializedLookups = Primary->hasExternalVisibleStorage();
768 
770  E = Primary->noload_lookups_end();
771  while (I != E) {
773  DeclContextLookupResult R = *I++;
774 
775  dumpChild([=] {
776  OS << "DeclarationName ";
777  {
778  ColorScope Color(*this, DeclNameColor);
779  OS << '\'' << Name << '\'';
780  }
781 
782  for (DeclContextLookupResult::iterator RI = R.begin(), RE = R.end();
783  RI != RE; ++RI) {
784  dumpChild([=] {
785  dumpBareDeclRef(*RI);
786 
787  if ((*RI)->isHidden())
788  OS << " hidden";
789 
790  // If requested, dump the redecl chain for this lookup.
791  if (DumpDecls) {
792  // Dump earliest decl first.
793  std::function<void(Decl *)> DumpWithPrev = [&](Decl *D) {
794  if (Decl *Prev = D->getPreviousDecl())
795  DumpWithPrev(Prev);
796  dumpDecl(D);
797  };
798  DumpWithPrev(*RI);
799  }
800  });
801  }
802  });
803  }
804 
805  if (HasUndeserializedLookups) {
806  dumpChild([=] {
807  ColorScope Color(*this, UndeserializedColor);
808  OS << "<undeserialized lookups>";
809  });
810  }
811  });
812 }
813 
814 void ASTDumper::dumpAttr(const Attr *A) {
815  dumpChild([=] {
816  {
817  ColorScope Color(*this, AttrColor);
818 
819  switch (A->getKind()) {
820 #define ATTR(X) case attr::X: OS << #X; break;
821 #include "clang/Basic/AttrList.inc"
822  default:
823  llvm_unreachable("unexpected attribute kind");
824  }
825  OS << "Attr";
826  }
827  dumpPointer(A);
828  dumpSourceRange(A->getRange());
829  if (A->isInherited())
830  OS << " Inherited";
831  if (A->isImplicit())
832  OS << " Implicit";
833 #include "clang/AST/AttrDump.inc"
834  });
835 }
836 
837 static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {}
838 
839 template<typename T>
840 static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
841  const T *First = D->getFirstDecl();
842  if (First != D)
843  OS << " first " << First;
844 }
845 
846 template<typename T>
847 static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
848  const T *Prev = D->getPreviousDecl();
849  if (Prev)
850  OS << " prev " << Prev;
851 }
852 
853 /// Dump the previous declaration in the redeclaration chain for a declaration,
854 /// if any.
855 static void dumpPreviousDecl(raw_ostream &OS, const Decl *D) {
856  switch (D->getKind()) {
857 #define DECL(DERIVED, BASE) \
858  case Decl::DERIVED: \
859  return dumpPreviousDeclImpl(OS, cast<DERIVED##Decl>(D));
860 #define ABSTRACT_DECL(DECL)
861 #include "clang/AST/DeclNodes.inc"
862  }
863  llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
864 }
865 
866 //===----------------------------------------------------------------------===//
867 // C++ Utilities
868 //===----------------------------------------------------------------------===//
869 
870 void ASTDumper::dumpAccessSpecifier(AccessSpecifier AS) {
871  switch (AS) {
872  case AS_none:
873  break;
874  case AS_public:
875  OS << "public";
876  break;
877  case AS_protected:
878  OS << "protected";
879  break;
880  case AS_private:
881  OS << "private";
882  break;
883  }
884 }
885 
886 void ASTDumper::dumpCXXCtorInitializer(const CXXCtorInitializer *Init) {
887  dumpChild([=] {
888  OS << "CXXCtorInitializer";
889  if (Init->isAnyMemberInitializer()) {
890  OS << ' ';
891  dumpBareDeclRef(Init->getAnyMember());
892  } else if (Init->isBaseInitializer()) {
893  dumpType(QualType(Init->getBaseClass(), 0));
894  } else if (Init->isDelegatingInitializer()) {
895  dumpType(Init->getTypeSourceInfo()->getType());
896  } else {
897  llvm_unreachable("Unknown initializer type");
898  }
899  dumpStmt(Init->getInit());
900  });
901 }
902 
903 void ASTDumper::dumpTemplateParameters(const TemplateParameterList *TPL) {
904  if (!TPL)
905  return;
906 
907  for (TemplateParameterList::const_iterator I = TPL->begin(), E = TPL->end();
908  I != E; ++I)
909  dumpDecl(*I);
910 }
911 
912 void ASTDumper::dumpTemplateArgumentListInfo(
913  const TemplateArgumentListInfo &TALI) {
914  for (unsigned i = 0, e = TALI.size(); i < e; ++i)
915  dumpTemplateArgumentLoc(TALI[i]);
916 }
917 
918 void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A) {
919  dumpTemplateArgument(A.getArgument(), A.getSourceRange());
920 }
921 
922 void ASTDumper::dumpTemplateArgumentList(const TemplateArgumentList &TAL) {
923  for (unsigned i = 0, e = TAL.size(); i < e; ++i)
924  dumpTemplateArgument(TAL[i]);
925 }
926 
927 void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R) {
928  dumpChild([=] {
929  OS << "TemplateArgument";
930  if (R.isValid())
931  dumpSourceRange(R);
932 
933  switch (A.getKind()) {
935  OS << " null";
936  break;
938  OS << " type";
939  dumpType(A.getAsType());
940  break;
942  OS << " decl";
943  dumpDeclRef(A.getAsDecl());
944  break;
946  OS << " nullptr";
947  break;
949  OS << " integral " << A.getAsIntegral();
950  break;
952  OS << " template ";
953  A.getAsTemplate().dump(OS);
954  break;
956  OS << " template expansion";
958  break;
960  OS << " expr";
961  dumpStmt(A.getAsExpr());
962  break;
964  OS << " pack";
966  I != E; ++I)
967  dumpTemplateArgument(*I);
968  break;
969  }
970  });
971 }
972 
973 //===----------------------------------------------------------------------===//
974 // Objective-C Utilities
975 //===----------------------------------------------------------------------===//
976 void ASTDumper::dumpObjCTypeParamList(const ObjCTypeParamList *typeParams) {
977  if (!typeParams)
978  return;
979 
980  for (auto typeParam : *typeParams) {
981  dumpDecl(typeParam);
982  }
983 }
984 
985 //===----------------------------------------------------------------------===//
986 // Decl dumping methods.
987 //===----------------------------------------------------------------------===//
988 
989 void ASTDumper::dumpDecl(const Decl *D) {
990  dumpChild([=] {
991  if (!D) {
992  ColorScope Color(*this, NullColor);
993  OS << "<<<NULL>>>";
994  return;
995  }
996 
997  {
998  ColorScope Color(*this, DeclKindNameColor);
999  OS << D->getDeclKindName() << "Decl";
1000  }
1001  dumpPointer(D);
1002  if (D->getLexicalDeclContext() != D->getDeclContext())
1003  OS << " parent " << cast<Decl>(D->getDeclContext());
1004  dumpPreviousDecl(OS, D);
1005  dumpSourceRange(D->getSourceRange());
1006  OS << ' ';
1007  dumpLocation(D->getLocation());
1008  if (Module *M = D->getImportedOwningModule())
1009  OS << " in " << M->getFullModuleName();
1010  else if (Module *M = D->getLocalOwningModule())
1011  OS << " in (local) " << M->getFullModuleName();
1012  if (auto *ND = dyn_cast<NamedDecl>(D))
1014  const_cast<NamedDecl *>(ND)))
1015  dumpChild([=] { OS << "also in " << M->getFullModuleName(); });
1016  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
1017  if (ND->isHidden())
1018  OS << " hidden";
1019  if (D->isImplicit())
1020  OS << " implicit";
1021  if (D->isUsed())
1022  OS << " used";
1023  else if (D->isThisDeclarationReferenced())
1024  OS << " referenced";
1025  if (D->isInvalidDecl())
1026  OS << " invalid";
1027  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
1028  if (FD->isConstexpr())
1029  OS << " constexpr";
1030 
1031 
1033 
1034  for (Decl::attr_iterator I = D->attr_begin(), E = D->attr_end(); I != E;
1035  ++I)
1036  dumpAttr(*I);
1037 
1038  if (const FullComment *Comment =
1040  dumpFullComment(Comment);
1041 
1042  // Decls within functions are visited by the body.
1043  if (!isa<FunctionDecl>(*D) && !isa<ObjCMethodDecl>(*D) &&
1044  hasNodes(dyn_cast<DeclContext>(D)))
1045  dumpDeclContext(cast<DeclContext>(D));
1046  });
1047 }
1048 
1049 void ASTDumper::VisitLabelDecl(const LabelDecl *D) {
1050  dumpName(D);
1051 }
1052 
1053 void ASTDumper::VisitTypedefDecl(const TypedefDecl *D) {
1054  dumpName(D);
1055  dumpType(D->getUnderlyingType());
1056  if (D->isModulePrivate())
1057  OS << " __module_private__";
1058  dumpTypeAsChild(D->getUnderlyingType());
1059 }
1060 
1061 void ASTDumper::VisitEnumDecl(const EnumDecl *D) {
1062  if (D->isScoped()) {
1063  if (D->isScopedUsingClassTag())
1064  OS << " class";
1065  else
1066  OS << " struct";
1067  }
1068  dumpName(D);
1069  if (D->isModulePrivate())
1070  OS << " __module_private__";
1071  if (D->isFixed())
1072  dumpType(D->getIntegerType());
1073 }
1074 
1075 void ASTDumper::VisitRecordDecl(const RecordDecl *D) {
1076  OS << ' ' << D->getKindName();
1077  dumpName(D);
1078  if (D->isModulePrivate())
1079  OS << " __module_private__";
1080  if (D->isCompleteDefinition())
1081  OS << " definition";
1082 }
1083 
1084 void ASTDumper::VisitEnumConstantDecl(const EnumConstantDecl *D) {
1085  dumpName(D);
1086  dumpType(D->getType());
1087  if (const Expr *Init = D->getInitExpr())
1088  dumpStmt(Init);
1089 }
1090 
1091 void ASTDumper::VisitIndirectFieldDecl(const IndirectFieldDecl *D) {
1092  dumpName(D);
1093  dumpType(D->getType());
1094 
1095  for (auto *Child : D->chain())
1096  dumpDeclRef(Child);
1097 }
1098 
1099 void ASTDumper::VisitFunctionDecl(const FunctionDecl *D) {
1100  dumpName(D);
1101  dumpType(D->getType());
1102 
1103  StorageClass SC = D->getStorageClass();
1104  if (SC != SC_None)
1105  OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
1106  if (D->isInlineSpecified())
1107  OS << " inline";
1108  if (D->isVirtualAsWritten())
1109  OS << " virtual";
1110  if (D->isModulePrivate())
1111  OS << " __module_private__";
1112 
1113  if (D->isPure())
1114  OS << " pure";
1115  else if (D->isDeletedAsWritten())
1116  OS << " delete";
1117 
1118  if (const FunctionProtoType *FPT = D->getType()->getAs<FunctionProtoType>()) {
1119  FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
1120  switch (EPI.ExceptionSpec.Type) {
1121  default: break;
1122  case EST_Unevaluated:
1123  OS << " noexcept-unevaluated " << EPI.ExceptionSpec.SourceDecl;
1124  break;
1125  case EST_Uninstantiated:
1126  OS << " noexcept-uninstantiated " << EPI.ExceptionSpec.SourceTemplate;
1127  break;
1128  }
1129  }
1130 
1131  if (const FunctionTemplateSpecializationInfo *FTSI =
1133  dumpTemplateArgumentList(*FTSI->TemplateArguments);
1134 
1136  I = D->getDeclsInPrototypeScope().begin(),
1137  E = D->getDeclsInPrototypeScope().end(); I != E; ++I)
1138  dumpDecl(*I);
1139 
1140  if (!D->param_begin() && D->getNumParams())
1141  dumpChild([=] { OS << "<<NULL params x " << D->getNumParams() << ">>"; });
1142  else
1144  E = D->param_end();
1145  I != E; ++I)
1146  dumpDecl(*I);
1147 
1148  if (const CXXConstructorDecl *C = dyn_cast<CXXConstructorDecl>(D))
1149  for (CXXConstructorDecl::init_const_iterator I = C->init_begin(),
1150  E = C->init_end();
1151  I != E; ++I)
1152  dumpCXXCtorInitializer(*I);
1153 
1155  dumpStmt(D->getBody());
1156 }
1157 
1158 void ASTDumper::VisitFieldDecl(const FieldDecl *D) {
1159  dumpName(D);
1160  dumpType(D->getType());
1161  if (D->isMutable())
1162  OS << " mutable";
1163  if (D->isModulePrivate())
1164  OS << " __module_private__";
1165 
1166  if (D->isBitField())
1167  dumpStmt(D->getBitWidth());
1168  if (Expr *Init = D->getInClassInitializer())
1169  dumpStmt(Init);
1170 }
1171 
1172 void ASTDumper::VisitVarDecl(const VarDecl *D) {
1173  dumpName(D);
1174  dumpType(D->getType());
1175  StorageClass SC = D->getStorageClass();
1176  if (SC != SC_None)
1177  OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
1178  switch (D->getTLSKind()) {
1179  case VarDecl::TLS_None: break;
1180  case VarDecl::TLS_Static: OS << " tls"; break;
1181  case VarDecl::TLS_Dynamic: OS << " tls_dynamic"; break;
1182  }
1183  if (D->isModulePrivate())
1184  OS << " __module_private__";
1185  if (D->isNRVOVariable())
1186  OS << " nrvo";
1187  if (D->hasInit()) {
1188  switch (D->getInitStyle()) {
1189  case VarDecl::CInit: OS << " cinit"; break;
1190  case VarDecl::CallInit: OS << " callinit"; break;
1191  case VarDecl::ListInit: OS << " listinit"; break;
1192  }
1193  dumpStmt(D->getInit());
1194  }
1195 }
1196 
1197 void ASTDumper::VisitFileScopeAsmDecl(const FileScopeAsmDecl *D) {
1198  dumpStmt(D->getAsmString());
1199 }
1200 
1201 void ASTDumper::VisitImportDecl(const ImportDecl *D) {
1202  OS << ' ' << D->getImportedModule()->getFullModuleName();
1203 }
1204 
1205 //===----------------------------------------------------------------------===//
1206 // C++ Declarations
1207 //===----------------------------------------------------------------------===//
1208 
1209 void ASTDumper::VisitNamespaceDecl(const NamespaceDecl *D) {
1210  dumpName(D);
1211  if (D->isInline())
1212  OS << " inline";
1213  if (!D->isOriginalNamespace())
1214  dumpDeclRef(D->getOriginalNamespace(), "original");
1215 }
1216 
1217 void ASTDumper::VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
1218  OS << ' ';
1219  dumpBareDeclRef(D->getNominatedNamespace());
1220 }
1221 
1222 void ASTDumper::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
1223  dumpName(D);
1224  dumpDeclRef(D->getAliasedNamespace());
1225 }
1226 
1227 void ASTDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
1228  dumpName(D);
1229  dumpType(D->getUnderlyingType());
1230  dumpTypeAsChild(D->getUnderlyingType());
1231 }
1232 
1233 void ASTDumper::VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D) {
1234  dumpName(D);
1235  dumpTemplateParameters(D->getTemplateParameters());
1236  dumpDecl(D->getTemplatedDecl());
1237 }
1238 
1239 void ASTDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
1240  VisitRecordDecl(D);
1241  if (!D->isCompleteDefinition())
1242  return;
1243 
1244  for (const auto &I : D->bases()) {
1245  dumpChild([=] {
1246  if (I.isVirtual())
1247  OS << "virtual ";
1248  dumpAccessSpecifier(I.getAccessSpecifier());
1249  dumpType(I.getType());
1250  if (I.isPackExpansion())
1251  OS << "...";
1252  });
1253  }
1254 }
1255 
1256 void ASTDumper::VisitStaticAssertDecl(const StaticAssertDecl *D) {
1257  dumpStmt(D->getAssertExpr());
1258  dumpStmt(D->getMessage());
1259 }
1260 
1261 template<typename SpecializationDecl>
1262 void ASTDumper::VisitTemplateDeclSpecialization(const SpecializationDecl *D,
1263  bool DumpExplicitInst,
1264  bool DumpRefOnly) {
1265  bool DumpedAny = false;
1266  for (auto *RedeclWithBadType : D->redecls()) {
1267  // FIXME: The redecls() range sometimes has elements of a less-specific
1268  // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
1269  // us TagDecls, and should give CXXRecordDecls).
1270  auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
1271  if (!Redecl) {
1272  // Found the injected-class-name for a class template. This will be dumped
1273  // as part of its surrounding class so we don't need to dump it here.
1274  assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
1275  "expected an injected-class-name");
1276  continue;
1277  }
1278 
1279  switch (Redecl->getTemplateSpecializationKind()) {
1282  if (!DumpExplicitInst)
1283  break;
1284  // Fall through.
1285  case TSK_Undeclared:
1287  if (DumpRefOnly)
1288  dumpDeclRef(Redecl);
1289  else
1290  dumpDecl(Redecl);
1291  DumpedAny = true;
1292  break;
1294  break;
1295  }
1296  }
1297 
1298  // Ensure we dump at least one decl for each specialization.
1299  if (!DumpedAny)
1300  dumpDeclRef(D);
1301 }
1302 
1303 template<typename TemplateDecl>
1304 void ASTDumper::VisitTemplateDecl(const TemplateDecl *D,
1305  bool DumpExplicitInst) {
1306  dumpName(D);
1307  dumpTemplateParameters(D->getTemplateParameters());
1308 
1309  dumpDecl(D->getTemplatedDecl());
1310 
1311  for (auto *Child : D->specializations())
1312  VisitTemplateDeclSpecialization(Child, DumpExplicitInst,
1313  !D->isCanonicalDecl());
1314 }
1315 
1316 void ASTDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
1317  // FIXME: We don't add a declaration of a function template specialization
1318  // to its context when it's explicitly instantiated, so dump explicit
1319  // instantiations when we dump the template itself.
1320  VisitTemplateDecl(D, true);
1321 }
1322 
1323 void ASTDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
1324  VisitTemplateDecl(D, false);
1325 }
1326 
1327 void ASTDumper::VisitClassTemplateSpecializationDecl(
1329  VisitCXXRecordDecl(D);
1330  dumpTemplateArgumentList(D->getTemplateArgs());
1331 }
1332 
1333 void ASTDumper::VisitClassTemplatePartialSpecializationDecl(
1335  VisitClassTemplateSpecializationDecl(D);
1336  dumpTemplateParameters(D->getTemplateParameters());
1337 }
1338 
1339 void ASTDumper::VisitClassScopeFunctionSpecializationDecl(
1341  dumpDeclRef(D->getSpecialization());
1342  if (D->hasExplicitTemplateArgs())
1343  dumpTemplateArgumentListInfo(D->templateArgs());
1344 }
1345 
1346 void ASTDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) {
1347  VisitTemplateDecl(D, false);
1348 }
1349 
1350 void ASTDumper::VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D) {
1351  dumpName(D);
1352  dumpTemplateParameters(D->getTemplateParameters());
1353 }
1354 
1355 void ASTDumper::VisitVarTemplateSpecializationDecl(
1356  const VarTemplateSpecializationDecl *D) {
1357  dumpTemplateArgumentList(D->getTemplateArgs());
1358  VisitVarDecl(D);
1359 }
1360 
1361 void ASTDumper::VisitVarTemplatePartialSpecializationDecl(
1363  dumpTemplateParameters(D->getTemplateParameters());
1364  VisitVarTemplateSpecializationDecl(D);
1365 }
1366 
1367 void ASTDumper::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
1368  if (D->wasDeclaredWithTypename())
1369  OS << " typename";
1370  else
1371  OS << " class";
1372  if (D->isParameterPack())
1373  OS << " ...";
1374  dumpName(D);
1375  if (D->hasDefaultArgument())
1376  dumpTemplateArgument(D->getDefaultArgument());
1377 }
1378 
1379 void ASTDumper::VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D) {
1380  dumpType(D->getType());
1381  if (D->isParameterPack())
1382  OS << " ...";
1383  dumpName(D);
1384  if (D->hasDefaultArgument())
1385  dumpTemplateArgument(D->getDefaultArgument());
1386 }
1387 
1388 void ASTDumper::VisitTemplateTemplateParmDecl(
1389  const TemplateTemplateParmDecl *D) {
1390  if (D->isParameterPack())
1391  OS << " ...";
1392  dumpName(D);
1393  dumpTemplateParameters(D->getTemplateParameters());
1394  if (D->hasDefaultArgument())
1395  dumpTemplateArgumentLoc(D->getDefaultArgument());
1396 }
1397 
1398 void ASTDumper::VisitUsingDecl(const UsingDecl *D) {
1399  OS << ' ';
1400  if (D->getQualifier())
1402  OS << D->getNameAsString();
1403 }
1404 
1405 void ASTDumper::VisitUnresolvedUsingTypenameDecl(
1406  const UnresolvedUsingTypenameDecl *D) {
1407  OS << ' ';
1408  if (D->getQualifier())
1410  OS << D->getNameAsString();
1411 }
1412 
1413 void ASTDumper::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
1414  OS << ' ';
1415  if (D->getQualifier())
1417  OS << D->getNameAsString();
1418  dumpType(D->getType());
1419 }
1420 
1421 void ASTDumper::VisitUsingShadowDecl(const UsingShadowDecl *D) {
1422  OS << ' ';
1423  dumpBareDeclRef(D->getTargetDecl());
1424  if (auto *TD = dyn_cast<TypeDecl>(D->getUnderlyingDecl()))
1425  dumpTypeAsChild(TD->getTypeForDecl());
1426 }
1427 
1428 void ASTDumper::VisitLinkageSpecDecl(const LinkageSpecDecl *D) {
1429  switch (D->getLanguage()) {
1430  case LinkageSpecDecl::lang_c: OS << " C"; break;
1431  case LinkageSpecDecl::lang_cxx: OS << " C++"; break;
1432  }
1433 }
1434 
1435 void ASTDumper::VisitAccessSpecDecl(const AccessSpecDecl *D) {
1436  OS << ' ';
1437  dumpAccessSpecifier(D->getAccess());
1438 }
1439 
1440 void ASTDumper::VisitFriendDecl(const FriendDecl *D) {
1441  if (TypeSourceInfo *T = D->getFriendType())
1442  dumpType(T->getType());
1443  else
1444  dumpDecl(D->getFriendDecl());
1445 }
1446 
1447 //===----------------------------------------------------------------------===//
1448 // Obj-C Declarations
1449 //===----------------------------------------------------------------------===//
1450 
1451 void ASTDumper::VisitObjCIvarDecl(const ObjCIvarDecl *D) {
1452  dumpName(D);
1453  dumpType(D->getType());
1454  if (D->getSynthesize())
1455  OS << " synthesize";
1456 
1457  switch (D->getAccessControl()) {
1458  case ObjCIvarDecl::None:
1459  OS << " none";
1460  break;
1461  case ObjCIvarDecl::Private:
1462  OS << " private";
1463  break;
1465  OS << " protected";
1466  break;
1467  case ObjCIvarDecl::Public:
1468  OS << " public";
1469  break;
1470  case ObjCIvarDecl::Package:
1471  OS << " package";
1472  break;
1473  }
1474 }
1475 
1476 void ASTDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
1477  if (D->isInstanceMethod())
1478  OS << " -";
1479  else
1480  OS << " +";
1481  dumpName(D);
1482  dumpType(D->getReturnType());
1483 
1484  if (D->isThisDeclarationADefinition()) {
1485  dumpDeclContext(D);
1486  } else {
1488  E = D->param_end();
1489  I != E; ++I)
1490  dumpDecl(*I);
1491  }
1492 
1493  if (D->isVariadic())
1494  dumpChild([=] { OS << "..."; });
1495 
1496  if (D->hasBody())
1497  dumpStmt(D->getBody());
1498 }
1499 
1500 void ASTDumper::VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D) {
1501  dumpName(D);
1502  switch (D->getVariance()) {
1504  break;
1505 
1507  OS << " covariant";
1508  break;
1509 
1511  OS << " contravariant";
1512  break;
1513  }
1514 
1515  if (D->hasExplicitBound())
1516  OS << " bounded";
1517  dumpType(D->getUnderlyingType());
1518 }
1519 
1520 void ASTDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
1521  dumpName(D);
1522  dumpDeclRef(D->getClassInterface());
1523  dumpObjCTypeParamList(D->getTypeParamList());
1524  dumpDeclRef(D->getImplementation());
1526  E = D->protocol_end();
1527  I != E; ++I)
1528  dumpDeclRef(*I);
1529 }
1530 
1531 void ASTDumper::VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
1532  dumpName(D);
1533  dumpDeclRef(D->getClassInterface());
1534  dumpDeclRef(D->getCategoryDecl());
1535 }
1536 
1537 void ASTDumper::VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
1538  dumpName(D);
1539 
1540  for (auto *Child : D->protocols())
1541  dumpDeclRef(Child);
1542 }
1543 
1544 void ASTDumper::VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
1545  dumpName(D);
1546  dumpObjCTypeParamList(D->getTypeParamListAsWritten());
1547  dumpDeclRef(D->getSuperClass(), "super");
1548 
1549  dumpDeclRef(D->getImplementation());
1550  for (auto *Child : D->protocols())
1551  dumpDeclRef(Child);
1552 }
1553 
1554 void ASTDumper::VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {
1555  dumpName(D);
1556  dumpDeclRef(D->getSuperClass(), "super");
1557  dumpDeclRef(D->getClassInterface());
1559  E = D->init_end();
1560  I != E; ++I)
1561  dumpCXXCtorInitializer(*I);
1562 }
1563 
1564 void ASTDumper::VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D) {
1565  dumpName(D);
1566  dumpDeclRef(D->getClassInterface());
1567 }
1568 
1569 void ASTDumper::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
1570  dumpName(D);
1571  dumpType(D->getType());
1572 
1574  OS << " required";
1576  OS << " optional";
1577 
1579  if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
1581  OS << " readonly";
1583  OS << " assign";
1585  OS << " readwrite";
1587  OS << " retain";
1588  if (Attrs & ObjCPropertyDecl::OBJC_PR_copy)
1589  OS << " copy";
1591  OS << " nonatomic";
1593  OS << " atomic";
1594  if (Attrs & ObjCPropertyDecl::OBJC_PR_weak)
1595  OS << " weak";
1597  OS << " strong";
1599  OS << " unsafe_unretained";
1601  dumpDeclRef(D->getGetterMethodDecl(), "getter");
1603  dumpDeclRef(D->getSetterMethodDecl(), "setter");
1604  }
1605 }
1606 
1607 void ASTDumper::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
1608  dumpName(D->getPropertyDecl());
1610  OS << " synthesize";
1611  else
1612  OS << " dynamic";
1613  dumpDeclRef(D->getPropertyDecl());
1614  dumpDeclRef(D->getPropertyIvarDecl());
1615 }
1616 
1617 void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
1618  for (auto I : D->params())
1619  dumpDecl(I);
1620 
1621  if (D->isVariadic())
1622  dumpChild([=]{ OS << "..."; });
1623 
1624  if (D->capturesCXXThis())
1625  dumpChild([=]{ OS << "capture this"; });
1626 
1627  for (const auto &I : D->captures()) {
1628  dumpChild([=] {
1629  OS << "capture";
1630  if (I.isByRef())
1631  OS << " byref";
1632  if (I.isNested())
1633  OS << " nested";
1634  if (I.getVariable()) {
1635  OS << ' ';
1636  dumpBareDeclRef(I.getVariable());
1637  }
1638  if (I.hasCopyExpr())
1639  dumpStmt(I.getCopyExpr());
1640  });
1641  }
1642  dumpStmt(D->getBody());
1643 }
1644 
1645 //===----------------------------------------------------------------------===//
1646 // Stmt dumping methods.
1647 //===----------------------------------------------------------------------===//
1648 
1649 void ASTDumper::dumpStmt(const Stmt *S) {
1650  dumpChild([=] {
1651  if (!S) {
1652  ColorScope Color(*this, NullColor);
1653  OS << "<<<NULL>>>";
1654  return;
1655  }
1656 
1657  if (const DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
1658  VisitDeclStmt(DS);
1659  return;
1660  }
1661 
1663 
1664  for (const Stmt *SubStmt : S->children())
1665  dumpStmt(SubStmt);
1666  });
1667 }
1668 
1669 void ASTDumper::VisitStmt(const Stmt *Node) {
1670  {
1671  ColorScope Color(*this, StmtColor);
1672  OS << Node->getStmtClassName();
1673  }
1674  dumpPointer(Node);
1675  dumpSourceRange(Node->getSourceRange());
1676 }
1677 
1678 void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
1679  VisitStmt(Node);
1680  for (DeclStmt::const_decl_iterator I = Node->decl_begin(),
1681  E = Node->decl_end();
1682  I != E; ++I)
1683  dumpDecl(*I);
1684 }
1685 
1686 void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
1687  VisitStmt(Node);
1688  for (ArrayRef<const Attr *>::iterator I = Node->getAttrs().begin(),
1689  E = Node->getAttrs().end();
1690  I != E; ++I)
1691  dumpAttr(*I);
1692 }
1693 
1694 void ASTDumper::VisitLabelStmt(const LabelStmt *Node) {
1695  VisitStmt(Node);
1696  OS << " '" << Node->getName() << "'";
1697 }
1698 
1699 void ASTDumper::VisitGotoStmt(const GotoStmt *Node) {
1700  VisitStmt(Node);
1701  OS << " '" << Node->getLabel()->getName() << "'";
1702  dumpPointer(Node->getLabel());
1703 }
1704 
1705 void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {
1706  VisitStmt(Node);
1707  dumpDecl(Node->getExceptionDecl());
1708 }
1709 
1710 //===----------------------------------------------------------------------===//
1711 // Expr dumping methods.
1712 //===----------------------------------------------------------------------===//
1713 
1714 void ASTDumper::VisitExpr(const Expr *Node) {
1715  VisitStmt(Node);
1716  dumpType(Node->getType());
1717 
1718  {
1719  ColorScope Color(*this, ValueKindColor);
1720  switch (Node->getValueKind()) {
1721  case VK_RValue:
1722  break;
1723  case VK_LValue:
1724  OS << " lvalue";
1725  break;
1726  case VK_XValue:
1727  OS << " xvalue";
1728  break;
1729  }
1730  }
1731 
1732  {
1733  ColorScope Color(*this, ObjectKindColor);
1734  switch (Node->getObjectKind()) {
1735  case OK_Ordinary:
1736  break;
1737  case OK_BitField:
1738  OS << " bitfield";
1739  break;
1740  case OK_ObjCProperty:
1741  OS << " objcproperty";
1742  break;
1743  case OK_ObjCSubscript:
1744  OS << " objcsubscript";
1745  break;
1746  case OK_VectorComponent:
1747  OS << " vectorcomponent";
1748  break;
1749  }
1750  }
1751 }
1752 
1753 static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
1754  if (Node->path_empty())
1755  return;
1756 
1757  OS << " (";
1758  bool First = true;
1759  for (CastExpr::path_const_iterator I = Node->path_begin(),
1760  E = Node->path_end();
1761  I != E; ++I) {
1762  const CXXBaseSpecifier *Base = *I;
1763  if (!First)
1764  OS << " -> ";
1765 
1766  const CXXRecordDecl *RD =
1767  cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
1768 
1769  if (Base->isVirtual())
1770  OS << "virtual ";
1771  OS << RD->getName();
1772  First = false;
1773  }
1774 
1775  OS << ')';
1776 }
1777 
1778 void ASTDumper::VisitCastExpr(const CastExpr *Node) {
1779  VisitExpr(Node);
1780  OS << " <";
1781  {
1782  ColorScope Color(*this, CastColor);
1783  OS << Node->getCastKindName();
1784  }
1785  dumpBasePath(OS, Node);
1786  OS << ">";
1787 }
1788 
1789 void ASTDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
1790  VisitExpr(Node);
1791 
1792  OS << " ";
1793  dumpBareDeclRef(Node->getDecl());
1794  if (Node->getDecl() != Node->getFoundDecl()) {
1795  OS << " (";
1796  dumpBareDeclRef(Node->getFoundDecl());
1797  OS << ")";
1798  }
1799 }
1800 
1801 void ASTDumper::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node) {
1802  VisitExpr(Node);
1803  OS << " (";
1804  if (!Node->requiresADL())
1805  OS << "no ";
1806  OS << "ADL) = '" << Node->getName() << '\'';
1807 
1809  I = Node->decls_begin(), E = Node->decls_end();
1810  if (I == E)
1811  OS << " empty";
1812  for (; I != E; ++I)
1813  dumpPointer(*I);
1814 }
1815 
1816 void ASTDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) {
1817  VisitExpr(Node);
1818 
1819  {
1820  ColorScope Color(*this, DeclKindNameColor);
1821  OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
1822  }
1823  OS << "='" << *Node->getDecl() << "'";
1824  dumpPointer(Node->getDecl());
1825  if (Node->isFreeIvar())
1826  OS << " isFreeIvar";
1827 }
1828 
1829 void ASTDumper::VisitPredefinedExpr(const PredefinedExpr *Node) {
1830  VisitExpr(Node);
1831  OS << " " << PredefinedExpr::getIdentTypeName(Node->getIdentType());
1832 }
1833 
1834 void ASTDumper::VisitCharacterLiteral(const CharacterLiteral *Node) {
1835  VisitExpr(Node);
1836  ColorScope Color(*this, ValueColor);
1837  OS << " " << Node->getValue();
1838 }
1839 
1840 void ASTDumper::VisitIntegerLiteral(const IntegerLiteral *Node) {
1841  VisitExpr(Node);
1842 
1843  bool isSigned = Node->getType()->isSignedIntegerType();
1844  ColorScope Color(*this, ValueColor);
1845  OS << " " << Node->getValue().toString(10, isSigned);
1846 }
1847 
1848 void ASTDumper::VisitFloatingLiteral(const FloatingLiteral *Node) {
1849  VisitExpr(Node);
1850  ColorScope Color(*this, ValueColor);
1851  OS << " " << Node->getValueAsApproximateDouble();
1852 }
1853 
1854 void ASTDumper::VisitStringLiteral(const StringLiteral *Str) {
1855  VisitExpr(Str);
1856  ColorScope Color(*this, ValueColor);
1857  OS << " ";
1858  Str->outputString(OS);
1859 }
1860 
1861 void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) {
1862  VisitExpr(ILE);
1863  if (auto *Filler = ILE->getArrayFiller()) {
1864  dumpChild([=] {
1865  OS << "array filler";
1866  dumpStmt(Filler);
1867  });
1868  }
1869  if (auto *Field = ILE->getInitializedFieldInUnion()) {
1870  OS << " field ";
1871  dumpBareDeclRef(Field);
1872  }
1873 }
1874 
1875 void ASTDumper::VisitUnaryOperator(const UnaryOperator *Node) {
1876  VisitExpr(Node);
1877  OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
1878  << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
1879 }
1880 
1881 void ASTDumper::VisitUnaryExprOrTypeTraitExpr(
1882  const UnaryExprOrTypeTraitExpr *Node) {
1883  VisitExpr(Node);
1884  switch(Node->getKind()) {
1885  case UETT_SizeOf:
1886  OS << " sizeof";
1887  break;
1888  case UETT_AlignOf:
1889  OS << " alignof";
1890  break;
1891  case UETT_VecStep:
1892  OS << " vec_step";
1893  break;
1895  OS << " __builtin_omp_required_simd_align";
1896  break;
1897  }
1898  if (Node->isArgumentType())
1899  dumpType(Node->getArgumentType());
1900 }
1901 
1902 void ASTDumper::VisitMemberExpr(const MemberExpr *Node) {
1903  VisitExpr(Node);
1904  OS << " " << (Node->isArrow() ? "->" : ".") << *Node->getMemberDecl();
1905  dumpPointer(Node->getMemberDecl());
1906 }
1907 
1908 void ASTDumper::VisitExtVectorElementExpr(const ExtVectorElementExpr *Node) {
1909  VisitExpr(Node);
1910  OS << " " << Node->getAccessor().getNameStart();
1911 }
1912 
1913 void ASTDumper::VisitBinaryOperator(const BinaryOperator *Node) {
1914  VisitExpr(Node);
1915  OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
1916 }
1917 
1918 void ASTDumper::VisitCompoundAssignOperator(
1919  const CompoundAssignOperator *Node) {
1920  VisitExpr(Node);
1921  OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
1922  << "' ComputeLHSTy=";
1923  dumpBareType(Node->getComputationLHSType());
1924  OS << " ComputeResultTy=";
1925  dumpBareType(Node->getComputationResultType());
1926 }
1927 
1928 void ASTDumper::VisitBlockExpr(const BlockExpr *Node) {
1929  VisitExpr(Node);
1930  dumpDecl(Node->getBlockDecl());
1931 }
1932 
1933 void ASTDumper::VisitOpaqueValueExpr(const OpaqueValueExpr *Node) {
1934  VisitExpr(Node);
1935 
1936  if (Expr *Source = Node->getSourceExpr())
1937  dumpStmt(Source);
1938 }
1939 
1940 // GNU extensions.
1941 
1942 void ASTDumper::VisitAddrLabelExpr(const AddrLabelExpr *Node) {
1943  VisitExpr(Node);
1944  OS << " " << Node->getLabel()->getName();
1945  dumpPointer(Node->getLabel());
1946 }
1947 
1948 //===----------------------------------------------------------------------===//
1949 // C++ Expressions
1950 //===----------------------------------------------------------------------===//
1951 
1952 void ASTDumper::VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node) {
1953  VisitExpr(Node);
1954  OS << " " << Node->getCastName()
1955  << "<" << Node->getTypeAsWritten().getAsString() << ">"
1956  << " <" << Node->getCastKindName();
1957  dumpBasePath(OS, Node);
1958  OS << ">";
1959 }
1960 
1961 void ASTDumper::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node) {
1962  VisitExpr(Node);
1963  OS << " " << (Node->getValue() ? "true" : "false");
1964 }
1965 
1966 void ASTDumper::VisitCXXThisExpr(const CXXThisExpr *Node) {
1967  VisitExpr(Node);
1968  OS << " this";
1969 }
1970 
1971 void ASTDumper::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node) {
1972  VisitExpr(Node);
1973  OS << " functional cast to " << Node->getTypeAsWritten().getAsString()
1974  << " <" << Node->getCastKindName() << ">";
1975 }
1976 
1977 void ASTDumper::VisitCXXConstructExpr(const CXXConstructExpr *Node) {
1978  VisitExpr(Node);
1979  CXXConstructorDecl *Ctor = Node->getConstructor();
1980  dumpType(Ctor->getType());
1981  if (Node->isElidable())
1982  OS << " elidable";
1983  if (Node->requiresZeroInitialization())
1984  OS << " zeroing";
1985 }
1986 
1987 void ASTDumper::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node) {
1988  VisitExpr(Node);
1989  OS << " ";
1990  dumpCXXTemporary(Node->getTemporary());
1991 }
1992 
1993 void ASTDumper::VisitCXXNewExpr(const CXXNewExpr *Node) {
1994  VisitExpr(Node);
1995  if (Node->isGlobalNew())
1996  OS << " global";
1997  if (Node->isArray())
1998  OS << " array";
1999  if (Node->getOperatorNew()) {
2000  OS << ' ';
2001  dumpBareDeclRef(Node->getOperatorNew());
2002  }
2003  // We could dump the deallocation function used in case of error, but it's
2004  // usually not that interesting.
2005 }
2006 
2007 void ASTDumper::VisitCXXDeleteExpr(const CXXDeleteExpr *Node) {
2008  VisitExpr(Node);
2009  if (Node->isGlobalDelete())
2010  OS << " global";
2011  if (Node->isArrayForm())
2012  OS << " array";
2013  if (Node->getOperatorDelete()) {
2014  OS << ' ';
2015  dumpBareDeclRef(Node->getOperatorDelete());
2016  }
2017 }
2018 
2019 void
2020 ASTDumper::VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node) {
2021  VisitExpr(Node);
2022  if (const ValueDecl *VD = Node->getExtendingDecl()) {
2023  OS << " extended by ";
2024  dumpBareDeclRef(VD);
2025  }
2026 }
2027 
2028 void ASTDumper::VisitExprWithCleanups(const ExprWithCleanups *Node) {
2029  VisitExpr(Node);
2030  for (unsigned i = 0, e = Node->getNumObjects(); i != e; ++i)
2031  dumpDeclRef(Node->getObject(i), "cleanup");
2032 }
2033 
2034 void ASTDumper::dumpCXXTemporary(const CXXTemporary *Temporary) {
2035  OS << "(CXXTemporary";
2036  dumpPointer(Temporary);
2037  OS << ")";
2038 }
2039 
2040 void ASTDumper::VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {
2041  VisitExpr(Node);
2042  dumpPointer(Node->getPack());
2043  dumpName(Node->getPack());
2044  if (Node->isPartiallySubstituted())
2045  for (const auto &A : Node->getPartialArguments())
2046  dumpTemplateArgument(A);
2047 }
2048 
2049 
2050 //===----------------------------------------------------------------------===//
2051 // Obj-C Expressions
2052 //===----------------------------------------------------------------------===//
2053 
2054 void ASTDumper::VisitObjCMessageExpr(const ObjCMessageExpr *Node) {
2055  VisitExpr(Node);
2056  OS << " selector=";
2057  Node->getSelector().print(OS);
2058  switch (Node->getReceiverKind()) {
2060  break;
2061 
2063  OS << " class=";
2064  dumpBareType(Node->getClassReceiver());
2065  break;
2066 
2068  OS << " super (instance)";
2069  break;
2070 
2072  OS << " super (class)";
2073  break;
2074  }
2075 }
2076 
2077 void ASTDumper::VisitObjCBoxedExpr(const ObjCBoxedExpr *Node) {
2078  VisitExpr(Node);
2079  OS << " selector=";
2080  Node->getBoxingMethod()->getSelector().print(OS);
2081 }
2082 
2083 void ASTDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
2084  VisitStmt(Node);
2085  if (const VarDecl *CatchParam = Node->getCatchParamDecl())
2086  dumpDecl(CatchParam);
2087  else
2088  OS << " catch all";
2089 }
2090 
2091 void ASTDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *Node) {
2092  VisitExpr(Node);
2093  dumpType(Node->getEncodedType());
2094 }
2095 
2096 void ASTDumper::VisitObjCSelectorExpr(const ObjCSelectorExpr *Node) {
2097  VisitExpr(Node);
2098 
2099  OS << " ";
2100  Node->getSelector().print(OS);
2101 }
2102 
2103 void ASTDumper::VisitObjCProtocolExpr(const ObjCProtocolExpr *Node) {
2104  VisitExpr(Node);
2105 
2106  OS << ' ' << *Node->getProtocol();
2107 }
2108 
2109 void ASTDumper::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node) {
2110  VisitExpr(Node);
2111  if (Node->isImplicitProperty()) {
2112  OS << " Kind=MethodRef Getter=\"";
2113  if (Node->getImplicitPropertyGetter())
2115  else
2116  OS << "(null)";
2117 
2118  OS << "\" Setter=\"";
2119  if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter())
2120  Setter->getSelector().print(OS);
2121  else
2122  OS << "(null)";
2123  OS << "\"";
2124  } else {
2125  OS << " Kind=PropertyRef Property=\"" << *Node->getExplicitProperty() <<'"';
2126  }
2127 
2128  if (Node->isSuperReceiver())
2129  OS << " super";
2130 
2131  OS << " Messaging=";
2132  if (Node->isMessagingGetter() && Node->isMessagingSetter())
2133  OS << "Getter&Setter";
2134  else if (Node->isMessagingGetter())
2135  OS << "Getter";
2136  else if (Node->isMessagingSetter())
2137  OS << "Setter";
2138 }
2139 
2140 void ASTDumper::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node) {
2141  VisitExpr(Node);
2142  if (Node->isArraySubscriptRefExpr())
2143  OS << " Kind=ArraySubscript GetterForArray=\"";
2144  else
2145  OS << " Kind=DictionarySubscript GetterForDictionary=\"";
2146  if (Node->getAtIndexMethodDecl())
2147  Node->getAtIndexMethodDecl()->getSelector().print(OS);
2148  else
2149  OS << "(null)";
2150 
2151  if (Node->isArraySubscriptRefExpr())
2152  OS << "\" SetterForArray=\"";
2153  else
2154  OS << "\" SetterForDictionary=\"";
2155  if (Node->setAtIndexMethodDecl())
2156  Node->setAtIndexMethodDecl()->getSelector().print(OS);
2157  else
2158  OS << "(null)";
2159 }
2160 
2161 void ASTDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) {
2162  VisitExpr(Node);
2163  OS << " " << (Node->getValue() ? "__objc_yes" : "__objc_no");
2164 }
2165 
2166 //===----------------------------------------------------------------------===//
2167 // Comments
2168 //===----------------------------------------------------------------------===//
2169 
2170 const char *ASTDumper::getCommandName(unsigned CommandID) {
2171  if (Traits)
2172  return Traits->getCommandInfo(CommandID)->Name;
2173  const CommandInfo *Info = CommandTraits::getBuiltinCommandInfo(CommandID);
2174  if (Info)
2175  return Info->Name;
2176  return "<not a builtin command>";
2177 }
2178 
2179 void ASTDumper::dumpFullComment(const FullComment *C) {
2180  if (!C)
2181  return;
2182 
2183  FC = C;
2184  dumpComment(C);
2185  FC = nullptr;
2186 }
2187 
2188 void ASTDumper::dumpComment(const Comment *C) {
2189  dumpChild([=] {
2190  if (!C) {
2191  ColorScope Color(*this, NullColor);
2192  OS << "<<<NULL>>>";
2193  return;
2194  }
2195 
2196  {
2197  ColorScope Color(*this, CommentColor);
2198  OS << C->getCommentKindName();
2199  }
2200  dumpPointer(C);
2201  dumpSourceRange(C->getSourceRange());
2203  for (Comment::child_iterator I = C->child_begin(), E = C->child_end();
2204  I != E; ++I)
2205  dumpComment(*I);
2206  });
2207 }
2208 
2209 void ASTDumper::visitTextComment(const TextComment *C) {
2210  OS << " Text=\"" << C->getText() << "\"";
2211 }
2212 
2213 void ASTDumper::visitInlineCommandComment(const InlineCommandComment *C) {
2214  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
2215  switch (C->getRenderKind()) {
2217  OS << " RenderNormal";
2218  break;
2220  OS << " RenderBold";
2221  break;
2223  OS << " RenderMonospaced";
2224  break;
2226  OS << " RenderEmphasized";
2227  break;
2228  }
2229 
2230  for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
2231  OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
2232 }
2233 
2234 void ASTDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
2235  OS << " Name=\"" << C->getTagName() << "\"";
2236  if (C->getNumAttrs() != 0) {
2237  OS << " Attrs: ";
2238  for (unsigned i = 0, e = C->getNumAttrs(); i != e; ++i) {
2240  OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
2241  }
2242  }
2243  if (C->isSelfClosing())
2244  OS << " SelfClosing";
2245 }
2246 
2247 void ASTDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C) {
2248  OS << " Name=\"" << C->getTagName() << "\"";
2249 }
2250 
2251 void ASTDumper::visitBlockCommandComment(const BlockCommandComment *C) {
2252  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
2253  for (unsigned i = 0, e = C->getNumArgs(); i != e; ++i)
2254  OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
2255 }
2256 
2257 void ASTDumper::visitParamCommandComment(const ParamCommandComment *C) {
2259 
2260  if (C->isDirectionExplicit())
2261  OS << " explicitly";
2262  else
2263  OS << " implicitly";
2264 
2265  if (C->hasParamName()) {
2266  if (C->isParamIndexValid())
2267  OS << " Param=\"" << C->getParamName(FC) << "\"";
2268  else
2269  OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
2270  }
2271 
2272  if (C->isParamIndexValid() && !C->isVarArgParam())
2273  OS << " ParamIndex=" << C->getParamIndex();
2274 }
2275 
2276 void ASTDumper::visitTParamCommandComment(const TParamCommandComment *C) {
2277  if (C->hasParamName()) {
2278  if (C->isPositionValid())
2279  OS << " Param=\"" << C->getParamName(FC) << "\"";
2280  else
2281  OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
2282  }
2283 
2284  if (C->isPositionValid()) {
2285  OS << " Position=<";
2286  for (unsigned i = 0, e = C->getDepth(); i != e; ++i) {
2287  OS << C->getIndex(i);
2288  if (i != e - 1)
2289  OS << ", ";
2290  }
2291  OS << ">";
2292  }
2293 }
2294 
2295 void ASTDumper::visitVerbatimBlockComment(const VerbatimBlockComment *C) {
2296  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\""
2297  " CloseName=\"" << C->getCloseName() << "\"";
2298 }
2299 
2300 void ASTDumper::visitVerbatimBlockLineComment(
2301  const VerbatimBlockLineComment *C) {
2302  OS << " Text=\"" << C->getText() << "\"";
2303 }
2304 
2305 void ASTDumper::visitVerbatimLineComment(const VerbatimLineComment *C) {
2306  OS << " Text=\"" << C->getText() << "\"";
2307 }
2308 
2309 //===----------------------------------------------------------------------===//
2310 // Type method implementations
2311 //===----------------------------------------------------------------------===//
2312 
2313 void QualType::dump(const char *msg) const {
2314  if (msg)
2315  llvm::errs() << msg << ": ";
2316  dump();
2317 }
2318 
2319 LLVM_DUMP_METHOD void QualType::dump() const {
2320  ASTDumper Dumper(llvm::errs(), nullptr, nullptr);
2321  Dumper.dumpTypeAsChild(*this);
2322 }
2323 
2324 LLVM_DUMP_METHOD void Type::dump() const { QualType(this, 0).dump(); }
2325 
2326 //===----------------------------------------------------------------------===//
2327 // Decl method implementations
2328 //===----------------------------------------------------------------------===//
2329 
2330 LLVM_DUMP_METHOD void Decl::dump() const { dump(llvm::errs()); }
2331 
2332 LLVM_DUMP_METHOD void Decl::dump(raw_ostream &OS) const {
2333  ASTDumper P(OS, &getASTContext().getCommentCommandTraits(),
2334  &getASTContext().getSourceManager());
2335  P.dumpDecl(this);
2336 }
2337 
2338 LLVM_DUMP_METHOD void Decl::dumpColor() const {
2339  ASTDumper P(llvm::errs(), &getASTContext().getCommentCommandTraits(),
2340  &getASTContext().getSourceManager(), /*ShowColors*/true);
2341  P.dumpDecl(this);
2342 }
2343 
2344 LLVM_DUMP_METHOD void DeclContext::dumpLookups() const {
2345  dumpLookups(llvm::errs());
2346 }
2347 
2348 LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream &OS,
2349  bool DumpDecls) const {
2350  const DeclContext *DC = this;
2351  while (!DC->isTranslationUnit())
2352  DC = DC->getParent();
2353  ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
2354  ASTDumper P(OS, &Ctx.getCommentCommandTraits(), &Ctx.getSourceManager());
2355  P.dumpLookups(this, DumpDecls);
2356 }
2357 
2358 //===----------------------------------------------------------------------===//
2359 // Stmt method implementations
2360 //===----------------------------------------------------------------------===//
2361 
2362 LLVM_DUMP_METHOD void Stmt::dump(SourceManager &SM) const {
2363  dump(llvm::errs(), SM);
2364 }
2365 
2366 LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS, SourceManager &SM) const {
2367  ASTDumper P(OS, nullptr, &SM);
2368  P.dumpStmt(this);
2369 }
2370 
2371 LLVM_DUMP_METHOD void Stmt::dump(raw_ostream &OS) const {
2372  ASTDumper P(OS, nullptr, nullptr);
2373  P.dumpStmt(this);
2374 }
2375 
2376 LLVM_DUMP_METHOD void Stmt::dump() const {
2377  ASTDumper P(llvm::errs(), nullptr, nullptr);
2378  P.dumpStmt(this);
2379 }
2380 
2381 LLVM_DUMP_METHOD void Stmt::dumpColor() const {
2382  ASTDumper P(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
2383  P.dumpStmt(this);
2384 }
2385 
2386 //===----------------------------------------------------------------------===//
2387 // Comment method implementations
2388 //===----------------------------------------------------------------------===//
2389 
2390 LLVM_DUMP_METHOD void Comment::dump() const {
2391  dump(llvm::errs(), nullptr, nullptr);
2392 }
2393 
2394 LLVM_DUMP_METHOD void Comment::dump(const ASTContext &Context) const {
2395  dump(llvm::errs(), &Context.getCommentCommandTraits(),
2396  &Context.getSourceManager());
2397 }
2398 
2399 void Comment::dump(raw_ostream &OS, const CommandTraits *Traits,
2400  const SourceManager *SM) const {
2401  const FullComment *FC = dyn_cast<FullComment>(this);
2402  ASTDumper D(OS, Traits, SM);
2403  D.dumpFullComment(FC);
2404 }
2405 
2406 LLVM_DUMP_METHOD void Comment::dumpColor() const {
2407  const FullComment *FC = dyn_cast<FullComment>(this);
2408  ASTDumper D(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
2409  D.dumpFullComment(FC);
2410 }
decl_iterator noload_decls_end() const
Definition: DeclBase.h:1451
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:539
unsigned getNumElements() const
Definition: Type.h:2749
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:1009
param_const_iterator param_begin() const
Definition: DeclObjC.h:359
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2393
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
Expr * getSizeExpr() const
Definition: Type.h:2699
const Type * Ty
The locally-unqualified type.
Definition: Type.h:520
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.h:4778
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:407
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1483
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1044
bool isVarArgParam() const LLVM_READONLY
Definition: Comment.h:782
The receiver is an object instance.
Definition: ExprObjC.h:1005
iterator begin() const
Definition: DeclBase.h:1090
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:169
unsigned getDepth() const
Definition: Type.h:3779
protocol_range protocols() const
Definition: DeclObjC.h:1785
ParmVarDecl *const * param_const_iterator
Definition: Decl.h:1902
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2147
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:3332
A (possibly-)qualified type.
Definition: Type.h:575
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition: DeclCXX.h:206
base_class_range bases()
Definition: DeclCXX.h:713
SourceRange getBracketsRange() const
Definition: Type.h:2596
unsigned getColumn() const
Return the presumed column number of this location.
bool getValue() const
Definition: ExprCXX.h:467
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:282
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:1974
bool isVariadic() const
Definition: Decl.h:3445
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2277
QualType getType() const
Retrieves the type of the base class.
Definition: DeclCXX.h:252
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1218
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:187
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Definition: ExprObjC.h:1174
QualType getBaseType() const
Definition: Type.h:3512
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
Definition: Type.h:1757
bool isPositionValid() const LLVM_READONLY
Definition: Comment.h:848
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:2575
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...
Definition: Decl.h:3116
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: Type.h:2847
bool isInvalid() const
Return true if this object is invalid or uninitialized.
const Expr * getInitExpr() const
Definition: Decl.h:2414
bool isArgumentType() const
Definition: Expr.h:1996
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2397
bool isGlobalDelete() const
Definition: ExprCXX.h:1960
bool isMessagingGetter() const
True if the property reference will result in a message to the getter.
Definition: ExprObjC.h:663
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Definition: Decl.h:2598
Defines the SourceManager interface.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
Definition: TemplateBase.h:69
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3060
QualType getUnderlyingType() const
Definition: Decl.h:2566
CXXCtorInitializer *const * init_const_iterator
init_const_iterator - Iterates through the ivar initializer list.
Definition: DeclObjC.h:2270
Defines the clang::Module class, which describes a module in the source code.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:813
chain_range chain() const
Definition: Decl.h:2457
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2586
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:3918
Represents an attribute applied to a statement.
Definition: Stmt.h:818
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:834
std::string getAsString() const
Definition: Type.h:901
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:315
const char * getCastKindName() const
Definition: Expr.cpp:1598
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
Definition: Type.cpp:3118
QualType getPointeeType() const
Definition: Type.h:2388
The base class of the type hierarchy.
Definition: Type.h:1249
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition: DeclBase.h:541
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2424
const Expr * getInit() const
Definition: Decl.h:1070
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:51
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:402
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1149
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:760
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:69
bool isDecltypeAuto() const
Definition: Type.h:3933
param_range params()
Definition: Decl.h:3469
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:90
bool isMessagingSetter() const
True if the property reference will result in a message to the setter.
Definition: ExprObjC.h:670
A container of type source information.
Definition: Decl.h:61
unsigned getIndex() const
Definition: Type.h:3780
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:305
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2134
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:3864
bool isSpelledAsLValue() const
Definition: Type.h:2304
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
Definition: Decl.h:2332
NamedDecl *const * const_iterator
Iterates through the template parameters in this list.
Definition: DeclTemplate.h:84
IdentType getIdentType() const
Definition: Expr.h:1173
const llvm::APInt & getSize() const
Definition: Type.h:2495
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Definition: DeclObjC.h:577
void * getAsOpaquePtr() const
Definition: Type.h:623
const CXXBaseSpecifier *const * path_const_iterator
Definition: Expr.h:2675
const TemplateArgumentListInfo & templateArgs() const
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:40
An Objective-C array/dictionary subscripting which reads an object or writes at the subscripted array...
Definition: Specifiers.h:133
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
Definition: ExprCXX.h:3648
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2119
bool capturesCXXThis() const
Definition: Decl.h:3521
TLSKind getTLSKind() const
Definition: Decl.cpp:1818
comments::FullComment * getLocalCommentForDeclUncached(const Decl *D) const
Return parsed documentation comment attached to a given declaration.
Definition: ASTContext.cpp:436
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:46
Extra information about a function prototype.
Definition: Type.h:3067
AccessSpecifier getAccess() const
Definition: DeclBase.h:428
std::string getAsString() const
Represents a variable template specialization, which refers to a variable template with a given set o...
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:113
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:319
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:3783
QualType getOriginalType() const
Definition: Type.h:2211
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:1991
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:48
capture_range captures()
Definition: Decl.h:3509
Not a TLS variable.
Definition: Decl.h:716
Qualifiers getIndexTypeQualifiers() const
Definition: Type.h:2462
unsigned getValue() const
Definition: Expr.h:1324
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:2847
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1521
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:3817
void dump(const char *s) const
Definition: ASTDumper.cpp:2313
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition: DeclCXX.h:1965
Represents the builtin template declaration which is used to implement __make_integer_seq.
QualType getType() const
Definition: DeclObjC.h:2497
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:2826
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:107
StringRef getArgText(unsigned Idx) const
Definition: Comment.h:678
Information about a single command.
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:777
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2667
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
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. ...
Definition: DeclObjC.h:986
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:27
QualType getElementType() const
Definition: Type.h:2700
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.
Definition: Decl.h:3110
ObjCProtocolDecl * getProtocol() const
Definition: ExprObjC.h:453
comments::CommandTraits & getCommentCommandTraits() const
Definition: ASTContext.h:760
StringRef getParamNameAsWritten() const
Definition: Comment.h:770
StringLiteral * getMessage()
Definition: DeclCXX.h:3169
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
A vector component is an element or range of elements on a vector.
Definition: Specifiers.h:124
Expr * getSizeExpr() const
Definition: Type.h:2591
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Definition: Type.h:1766
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
is ARM Neon vector
Definition: Type.h:2731
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1054
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:1742
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3165
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:57
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2008
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2209
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:2788
An operation on a type.
Definition: TypeVisitor.h:65
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1748
StringRef getText() const LLVM_READONLY
Definition: Comment.h:889
bool isTranslationUnit() const
Definition: DeclBase.h:1269
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:232
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:374
Represents the result of substituting a set of types for a template type parameter pack...
Definition: Type.h:3872
StringRef getParamNameAsWritten() const
Definition: Comment.h:840
IdentifierInfo & getAccessor() const
Definition: Expr.h:4544
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:4522
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: Decl.h:3449
Represents an access specifier followed by colon ':'.
Definition: DeclCXX.h:101
unsigned getRegParm() const
Definition: Type.h:2916
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.
Definition: Basic/Module.h:47
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:875
Expr * getUnderlyingExpr() const
Definition: Type.h:3457
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:102
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
Represents Objective-C's @catch statement.
Definition: StmtObjC.h:74
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Definition: DeclTemplate.h:391
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
A command with word-like arguments that is considered inline content.
Definition: Comment.h:303
Describes an C or C++ initializer list.
Definition: Expr.h:3724
Represents a C++ using-declaration.
Definition: DeclCXX.h:2858
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:497
TemplateArgument getArgumentPack() const
Definition: Type.cpp:3078
ObjCMethodDecl * getBoxingMethod() const
Definition: ExprObjC.h:111
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
An lvalue ref-qualifier was provided (&).
Definition: Type.h:1208
A line of text contained in a verbatim block.
Definition: Comment.h:869
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:514
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:457
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:1979
A verbatim line command.
Definition: Comment.h:949
A convenient class for passing around template argument information.
Definition: TemplateBase.h:517
const ValueDecl * getExtendingDecl() const
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:3921
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition: DeclCXX.h:2743
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2011
QualType getReturnType() const
Definition: Type.h:2977
bool isSuperReceiver() const
Definition: ExprObjC.h:700
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:3342
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"...
Definition: Specifiers.h:111
path_iterator path_begin()
Definition: Expr.h:2678
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:3384
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2875
Selector getSelector() const
Definition: ExprObjC.cpp:306
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:2662
static bool isPostfix(Opcode Op)
isPostfix - Return true if this is a postfix operation, like x++.
Definition: Expr.h:1689
Any part of the comment.
Definition: Comment.h:53
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Definition: Decl.h:184
QualType getDefaultArgument() const
Retrieve the default argument, if any.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Definition: Expr.h:2801
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Definition: DeclCXX.cpp:1714
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Definition: DeclCXX.h:1993
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2610
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:1728
unsigned getParamIndex() const LLVM_READONLY
Definition: Comment.h:791
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1106
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:708
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1126
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...
Definition: ExprCXX.h:1422
unsigned getLine() const
Return the presumed line number of this location.
decl_iterator decl_end()
Definition: Stmt.h:484
Module * getLocalOwningModule() const
Get the local owning module, if known.
Definition: DeclBase.h:671
An ordinary object is located at an address in memory.
Definition: Specifiers.h:118
Represents an ObjC class declaration.
Definition: DeclObjC.h:853
CleanupObject getObject(unsigned i) const
Definition: ExprCXX.h:2880
Represents a linkage specification.
Definition: DeclCXX.h:2454
unsigned getCommandID() const
Definition: Comment.h:656
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:817
detail::InMemoryDirectory::const_iterator I
is ARM Neon polynomial vector
Definition: Type.h:2732
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:2508
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
Definition: Type.h:3060
bool isFromAST() const
Whether this type comes from an AST file.
Definition: Type.h:1504
QualType getType() const
Definition: Decl.h:530
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
Definition: DeclObjC.h:594
Represents an extended vector type where either the type or size is dependent.
Definition: Type.h:2686
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:3893
param_iterator param_begin()
Definition: Decl.h:1906
static void dumpPreviousDeclImpl(raw_ostream &OS,...)
Definition: ASTDumper.cpp:837
Represents the this expression in C++.
Definition: ExprCXX.h:860
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:505
AnnotatingParser & P
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2605
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:1972
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Definition: Redeclarable.h:263
A verbatim block command (e.
Definition: Comment.h:897
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:5003
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition: Decl.cpp:3178
const ParmVarDecl *const * param_const_iterator
Definition: DeclObjC.h:349
ExtInfo getExtInfo() const
Definition: Type.h:2986
StringRef getText() const LLVM_READONLY
Definition: Comment.h:287
llvm::APInt getValue() const
Definition: Expr.h:1234
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2618
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3041
Holds a QualType and a TypeSourceInfo* that came out of a declarator parsing.
Definition: LocInfoType.h:29
unsigned getNumObjects() const
Definition: ExprCXX.h:2878
ArrayRef< Module * > getModulesWithMergedDefinition(NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
Definition: ASTContext.h:868
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:1960
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:1447
ASTContext * Context
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ArrayRef< NamedDecl * > getDeclsInPrototypeScope() const
Definition: Decl.h:1945
SourceRange getRange() const
Definition: Attr.h:94
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1979
SourceManager & SM
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1239
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:128
Represents an array type in C++ whose size is a value-dependent expression.
Definition: Type.h:2627
int * Depth
SplitQualType split() const
Divides a QualType into its unqualified type and a set of local qualifiers.
Definition: Type.h:5097
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3369
QualType getPointeeType() const
Definition: Type.h:2268
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:521
Expr - This represents one expression.
Definition: Expr.h:104
bool isSugared() const
Definition: Type.h:4509
void dumpColor() const
Definition: ASTDumper.cpp:2338
void outputString(raw_ostream &OS) const
Definition: Expr.cpp:863
static void dumpBasePath(raw_ostream &OS, const CastExpr *Node)
Definition: ASTDumper.cpp:1753
bool isDeletedAsWritten() const
Definition: Decl.h:1821
decls_iterator decls_end() const
Definition: ExprCXX.h:2492
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
Definition: DeclObjC.h:2671
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
Definition: Expr.cpp:794
QualType getLocallyUnqualifiedSingleStepDesugaredType() const
Pull a single level of sugar off of this locally-unqualified type.
Definition: Type.cpp:224
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:54
Expr * getBitWidth() const
Definition: Decl.h:2291
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:4580
child_iterator child_end() const
Definition: Comment.cpp:83
Expr * getUnderlyingExpr() const
Definition: Type.h:3391
bool isInherited() const
Definition: Attr.h:97
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:638
Kind getKind() const
Definition: DeclBase.h:387
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:216
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3169
A command that has zero or more word-like arguments (number of word-like arguments depends on command...
Definition: Comment.h:602
DeclContext * getDeclContext()
Definition: DeclBase.h:393
ObjCSelectorExpr used for @selector in Objective-C.
Definition: ExprObjC.h:397
const char * getDeclKindName() const
Definition: DeclBase.cpp:102
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:3555
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents the type decltype(expr) (C++11).
Definition: Type.h:3449
Selector getSelector() const
Definition: ExprObjC.h:409
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
Definition: Type.h:518
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
SourceLocation getAttributeLoc() const
Definition: Type.h:2701
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3105
StorageClass
Storage classes.
Definition: Specifiers.h:198
A unary type transform, which is a type constructed from another.
Definition: Type.h:3490
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1751
bool isInstanceMethod() const
Definition: DeclObjC.h:419
Direct list-initialization (C++11)
Definition: Decl.h:711
Qualifiers Quals
The local qualifiers.
Definition: Type.h:523
bool isDirectionExplicit() const LLVM_READONLY
Definition: Comment.h:755
Declaration of an alias template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:1200
StringRef getParamName(const FullComment *FC) const
Definition: Comment.cpp:331
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:662
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.
Definition: TemplateBase.h:269
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
Represents an unpacked "presumed" location which can be presented to the user.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1654
Represents a GCC generic vector type.
Definition: Type.h:2724
An opening HTML tag with attributes.
Definition: Comment.h:419
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:190
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
ValueDecl * getDecl()
Definition: Expr.h:1007
QualType getElementType() const
Definition: Type.h:2748
QualType getComputationLHSType() const
Definition: Expr.h:3093
static QualType Desugar(ASTContext &Context, QualType QT, bool &ShouldAKA)
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:144
DeclarationName getLookupName() const
Definition: DeclLookups.h:40
UnresolvedSetImpl::iterator decls_iterator
Definition: ExprCXX.h:2490
child_iterator child_begin() const
Definition: Comment.cpp:69
static const char * getDirectionAsString(PassDirection D)
Definition: Comment.cpp:117
void dump() const
Definition: ASTDumper.cpp:2330
const clang::PrintingPolicy & getPrintingPolicy() const
Definition: ASTContext.h:545
init_iterator init_begin()
init_begin() - Retrieve an iterator to the first initializer.
Definition: DeclObjC.h:2281
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:1743
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:1963
SourceRange getBracketsRange() const
Definition: Type.h:2652
param_const_iterator param_end() const
Definition: DeclObjC.h:362
QualType getComputationResultType() const
Definition: Expr.h:3096
LabelDecl * getLabel() const
Definition: Stmt.h:1213
This class provides information about commands that can be used in comments.
decls_iterator decls_begin() const
Definition: ExprCXX.h:2491
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:3832
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
Definition: Decl.cpp:2497
bool isArray() const
Definition: ExprCXX.h:1813
bool isArrayForm() const
Definition: ExprCXX.h:1961
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
Definition: Decl.h:1732
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:840
is AltiVec 'vector Pixel'
Definition: Type.h:2729
not a target-specific vector type
Definition: Type.h:2727
RenderKind getRenderKind() const
Definition: Comment.h:358
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3053
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Definition: Redeclarable.h:144
bool getValue() const
Definition: ExprObjC.h:71
const char * getFilename() const
Return the presumed filename of this location.
Encodes a location in the source.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
Definition: Decl.cpp:2743
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:262
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
Definition: DeclLookups.h:26
QualType getElementType() const
Definition: Type.h:2099
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:892
Represents a C++ temporary.
Definition: ExprCXX.h:1075
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:4766
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2401
FieldDecl * getAnyMember() const
Definition: DeclCXX.h:2037
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3121
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1723
SourceRange getSourceRange() const LLVM_READONLY
Definition: Comment.h:216
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:311
bool isValid() const
decl_iterator noload_decls_begin() const
Definition: DeclBase.h:1450
bool isFreeIvar() const
Definition: ExprObjC.h:514
bool isParamIndexValid() const LLVM_READONLY
Definition: Comment.h:778
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:431
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:355
bool isVariadic() const
Definition: DeclObjC.h:421
VectorKind getVectorKind() const
Definition: Type.h:2757
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3004
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.
Definition: DeclObjC.cpp:756
bool getSynthesize() const
Definition: DeclObjC.h:1655
bool isRestrict() const
Definition: Type.h:2989
const Attribute & getAttr(unsigned Idx) const
Definition: Comment.h:482
No ref-qualifier was provided.
Definition: Type.h:1206
C-style initialization with assignment.
Definition: Decl.h:709
all_lookups_iterator noload_lookups_end() const
Definition: DeclLookups.h:109
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...
Definition: DeclLookups.h:104
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:1931
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:3702
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2085
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:3626
unsigned getIndex(unsigned Depth) const
Definition: Comment.h:857
decl_iterator decl_begin()
Definition: Stmt.h:483
ObjCProtocolExpr used for protocol expression in Objective-C.
Definition: ExprObjC.h:441
Comment *const * child_iterator
Definition: Comment.h:228
SplitQualType getSplitDesugaredType() const
Definition: Type.h:873
is AltiVec 'vector bool ...'
Definition: Type.h:2730
init_iterator init_end()
init_end() - Retrieve an iterator past the last initializer.
Definition: DeclObjC.h:2289
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:2416
TypedefNameDecl * getDecl() const
Definition: Type.h:3375
PassDirection getDirection() const LLVM_READONLY
Definition: Comment.h:751
is AltiVec vector
Definition: Type.h:2728
QualType getReturnType() const
Definition: DeclObjC.h:330
SourceLocation getBegin() const
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:156
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Definition: Specifiers.h:141
void dump() const
Definition: ASTDumper.cpp:2319
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3146
A closing HTML tag.
Definition: Comment.h:513
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:1983
An rvalue ref-qualifier was provided (&&).
Definition: Type.h:1210
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:94
UTTKind getUTTKind() const
Definition: Type.h:3514
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition: Expr.h:3809
const BlockDecl * getBlockDecl() const
Definition: Expr.h:4594
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:69
Opcode getOpcode() const
Definition: Expr.h:1678
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:245
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:3043
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:3658
Doxygen \tparam command, describes a template parameter.
Definition: Comment.h:805
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4128
QualType getPointeeType() const
Definition: Type.h:2161
Represents a pack expansion of types.
Definition: Type.h:4471
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3070
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:3643
static const char * getStorageClassSpecifierString(StorageClass SC)
getStorageClassSpecifierString - Return the string used to specify the storage class SC...
Definition: Decl.cpp:1770
const char * getCastName() const
getCastName - Get the name of the C++ cast being used, e.g., "static_cast", "dynamic_cast", "reinterpret_cast", or "const_cast".
Definition: ExprCXX.cpp:573
const char * getTypeClassName() const
Definition: Type.cpp:2503
Expr * getSizeExpr() const
Definition: Type.h:2647
bool isArrow() const
Definition: Expr.h:2488
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3317
attr::Kind getKind() const
Definition: Attr.h:86
ast_type_traits::DynTypedNode Node
QualType getType() const
Definition: Expr.h:125
TLS with a dynamic initializer.
Definition: Decl.h:718
Represents a template argument.
Definition: TemplateBase.h:40
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
Definition: Type.h:2195
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:238
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
Definition: DeclCXX.h:2026
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:1999
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
bool isImplicitProperty() const
Definition: ExprObjC.h:630
StringRef getOpcodeStr() const
Definition: Expr.h:2937
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:1918
not evaluated yet, for special member function
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1146
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1121
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:1927
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:331
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:759
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:63
bool isInvalidDecl() const
Definition: DeclBase.h:509
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user...
Definition: Attr.h:101
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2437
NamespaceDecl * getOriginalNamespace()
Get the original (first) namespace declaration.
Definition: DeclCXX.cpp:2031
void dump() const
Definition: ASTDumper.cpp:2324
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:152
bool isParameterPack() const
Definition: Type.h:3781
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2495
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3087
DeclarationName - The name of a declaration.
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:537
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Definition: DeclBase.cpp:332
Selector getSelector() const
Definition: DeclObjC.h:328
EnumDecl - Represents an enum.
Definition: Decl.h:2930
bool path_empty() const
Definition: Expr.h:2676
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2369
const char * getCommentKindName() const
Definition: Comment.cpp:22
QualType getModifiedType() const
Definition: Type.h:3665
attr_iterator attr_end() const
Definition: DeclBase.h:466
param_iterator param_end()
Definition: Decl.h:1907
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:4836
path_iterator path_end()
Definition: Expr.h:2679
Represents a pointer to an Objective C object.
Definition: Type.h:4821
StringRef getTagName() const LLVM_READONLY
Definition: Comment.h:401
Pointer to a block type.
Definition: Type.h:2254
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2220
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:2565
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition: Type.h:3063
Provides common interface for the Decls that cannot be redeclared, but can be merged if the same decl...
Definition: Redeclarable.h:257
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3544
Complex values, per C99 6.2.5p11.
Definition: Type.h:2087
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:421
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:1808
static const CommandInfo * getBuiltinCommandInfo(StringRef Name)
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:5675
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:120
Represents a C++ base or member initializer.
Definition: DeclCXX.h:1885
static StringRef getIdentTypeName(IdentType IT)
Definition: Expr.cpp:450
This template specialization was declared or defined by an explicit specialization (C++ [temp...
Definition: Specifiers.h:148
void dump(raw_ostream &OS) const
Debugging aid that dumps the template name.
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:2568
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:355
bool isDeduced() const
Definition: Type.h:3948
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2002
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3054
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:486
DeclGroupRef::const_iterator const_decl_iterator
Definition: Stmt.h:475
StringRef getParamName(const FullComment *FC) const
Definition: Comment.cpp:324
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2287
CXXConstructorDecl * getConstructor() const
Definition: ExprCXX.h:1211
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
Definition: Decl.h:1158
bool isOriginalNamespace() const
Return true if this declaration is an original (first) declaration of the namespace.
Definition: DeclCXX.cpp:2045
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1129
The template argument is a type.
Definition: TemplateBase.h:48
protocol_range protocols() const
Definition: DeclObjC.h:1040
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1447
The template argument is actually a parameter pack.
Definition: TemplateBase.h:72
LabelDecl * getLabel() const
Definition: Expr.h:3339
Represents a base class of a C++ class.
Definition: DeclCXX.h:157
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:633
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:121
bool isAnyMemberInitializer() const
Definition: DeclCXX.h:1973
QualType getPointeeType() const
Definition: Type.h:2308
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:479
SourceManager & getSourceManager()
Definition: ASTContext.h:553
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1202
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:850
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
Definition: DeclCXX.h:2898
A template argument list.
Definition: DeclTemplate.h:172
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
const Type * getClass() const
Definition: Type.h:2402
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2662
AccessControl getAccessControl() const
Definition: DeclObjC.h:1648
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:3598
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Call-style initialization (C++98)
Definition: Decl.h:710
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2297
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:360
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
bool hasQualifiers() const
Return true if the set contains any qualifiers.
Definition: Type.h:358
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:60
bool isGlobalNew() const
Definition: ExprCXX.h:1838
Opcode getOpcode() const
Definition: Expr.h:2918
QualType getEncodedType() const
Definition: ExprObjC.h:376
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1315
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1609
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2459
Declaration of a class template.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:615
static void dumpPreviousDecl(raw_ostream &OS, const Decl *D)
Dump the previous declaration in the redeclaration chain for a declaration, if any.
Definition: ASTDumper.cpp:855
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:355
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
Definition: TemplateBase.h:322
The receiver is a class.
Definition: ExprObjC.h:1003
StringRef getArgText(unsigned Idx) const
Definition: Comment.h:366
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1452
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:2506
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:4498
TLS with a known-constant initializer.
Definition: Decl.h:717
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:289
TagDecl * getDecl() const
Definition: Type.cpp:2961
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:187
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:60
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:50
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:922
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:400
StringRef getCloseName() const
Definition: Comment.h:933
Doxygen \param command.
Definition: Comment.h:717
QualType getElementType() const
Definition: Type.h:2458
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
Definition: DeclCXX.h:2182
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:953
bool isArraySubscriptRefExpr() const
Definition: ExprObjC.h:821
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition: Expr.h:3827
attr_iterator attr_begin() const
Definition: DeclBase.h:463
static StringRef getNameForCallConv(CallingConv CC)
Definition: Type.cpp:2643
#define true
Definition: stdbool.h:32
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:106
StringRef getKindName() const
Definition: Decl.h:2843
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
Definition: DeclBase.h:384
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
Definition: Expr.cpp:1085
bool isVolatile() const
Definition: Type.h:2988
NamedDecl - This represents a decl with a name.
Definition: Decl.h:145
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:455
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2575
Represents a C++ namespace alias.
Definition: DeclCXX.h:2649
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
Definition: Type.cpp:1700
Represents C++ using-directive.
Definition: DeclCXX.h:2546
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:642
The receiver is a superclass.
Definition: ExprObjC.h:1007
const char * getName() const
Definition: Stmt.cpp:309
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:74
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:464
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1136
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2139
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:4502
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
Definition: DeclBase.h:563
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2480
This class handles loading and caching of source files into memory.
The parameter is invariant: must match exactly.
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3087
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
Definition: DeclTemplate.h:830
AttrVec::const_iterator attr_iterator
Definition: DeclBase.h:456
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:643
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1063
Attr - This represents one attribute.
Definition: Attr.h:44
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:2766
A full comment attached to a declaration, contains block content.
Definition: Comment.h:1097
ObjCCompatibleAliasDecl - Represents alias of a class.
Definition: DeclObjC.h:2385
void dumpLookups() const
Definition: ASTDumper.cpp:2344
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2274
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
Definition: Decl.h:237
bool isConst() const
Definition: Type.h:2987
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:1752
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2346
const StringLiteral * getAsmString() const
Definition: Decl.h:3357
bool hasInit() const
Definition: Decl.cpp:2034
QualType getArgumentType() const
Definition: Expr.h:1997
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.