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