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