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