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