Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/TextNodeDumper.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- TextNodeDumper.cpp - Printing of AST nodes -----------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements AST dumping of components of individual AST nodes.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/AST/TextNodeDumper.h"
14
#include "clang/AST/DeclFriend.h"
15
#include "clang/AST/DeclOpenMP.h"
16
#include "clang/AST/DeclTemplate.h"
17
#include "clang/AST/LocInfoType.h"
18
19
using namespace clang;
20
21
1.64k
static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {}
22
23
template <typename T>
24
1.65k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
1.65k
  const T *First = D->getFirstDecl();
26
1.65k
  if (First != D)
27
0
    OS << " first " << First;
28
1.65k
}
Unexecuted instantiation: TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::LifetimeExtendedTemporaryDecl>(llvm::raw_ostream&, clang::Mergeable<clang::LifetimeExtendedTemporaryDecl> const*)
Unexecuted instantiation: TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::ConceptDecl>(llvm::raw_ostream&, clang::Mergeable<clang::ConceptDecl> const*)
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::UnresolvedUsingTypenameDecl>(llvm::raw_ostream&, clang::Mergeable<clang::UnresolvedUsingTypenameDecl> const*)
Line
Count
Source
24
1
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
1
  const T *First = D->getFirstDecl();
26
1
  if (First != D)
27
0
    OS << " first " << First;
28
1
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::UsingDecl>(llvm::raw_ostream&, clang::Mergeable<clang::UsingDecl> const*)
Line
Count
Source
24
18
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
18
  const T *First = D->getFirstDecl();
26
18
  if (First != D)
27
0
    OS << " first " << First;
28
18
}
Unexecuted instantiation: TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::UsingPackDecl>(llvm::raw_ostream&, clang::Mergeable<clang::UsingPackDecl> const*)
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::FieldDecl>(llvm::raw_ostream&, clang::Mergeable<clang::FieldDecl> const*)
Line
Count
Source
24
1.54k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
1.54k
  const T *First = D->getFirstDecl();
26
1.54k
  if (First != D)
27
0
    OS << " first " << First;
28
1.54k
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::EnumConstantDecl>(llvm::raw_ostream&, clang::Mergeable<clang::EnumConstantDecl> const*)
Line
Count
Source
24
63
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
63
  const T *First = D->getFirstDecl();
26
63
  if (First != D)
27
0
    OS << " first " << First;
28
63
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::IndirectFieldDecl>(llvm::raw_ostream&, clang::Mergeable<clang::IndirectFieldDecl> const*)
Line
Count
Source
24
31
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
31
  const T *First = D->getFirstDecl();
26
31
  if (First != D)
27
0
    OS << " first " << First;
28
31
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::UnresolvedUsingValueDecl>(llvm::raw_ostream&, clang::Mergeable<clang::UnresolvedUsingValueDecl> const*)
Line
Count
Source
24
1
static void dumpPreviousDeclImpl(raw_ostream &OS, const Mergeable<T> *D) {
25
1
  const T *First = D->getFirstDecl();
26
1
  if (First != D)
27
0
    OS << " first " << First;
28
1
}
29
30
template <typename T>
31
12.1k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
12.1k
  const T *Prev = D->getPreviousDecl();
33
12.1k
  if (Prev)
34
216
    OS << " prev " << Prev;
35
12.1k
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::NamespaceDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::NamespaceDecl> const*)
Line
Count
Source
31
118
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
118
  const T *Prev = D->getPreviousDecl();
33
118
  if (Prev)
34
3
    OS << " prev " << Prev;
35
118
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::NamespaceAliasDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::NamespaceAliasDecl> const*)
Line
Count
Source
31
4
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
4
  const T *Prev = D->getPreviousDecl();
33
4
  if (Prev)
34
0
    OS << " prev " << Prev;
35
4
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::ObjCInterfaceDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::ObjCInterfaceDecl> const*)
Line
Count
Source
31
70
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
70
  const T *Prev = D->getPreviousDecl();
33
70
  if (Prev)
34
1
    OS << " prev " << Prev;
35
70
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::ObjCProtocolDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::ObjCProtocolDecl> const*)
Line
Count
Source
31
17
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
17
  const T *Prev = D->getPreviousDecl();
33
17
  if (Prev)
34
0
    OS << " prev " << Prev;
35
17
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::RedeclarableTemplateDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::RedeclarableTemplateDecl> const*)
Line
Count
Source
31
260
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
260
  const T *Prev = D->getPreviousDecl();
33
260
  if (Prev)
34
12
    OS << " prev " << Prev;
35
260
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::TagDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::TagDecl> const*)
Line
Count
Source
31
2.00k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
2.00k
  const T *Prev = D->getPreviousDecl();
33
2.00k
  if (Prev)
34
104
    OS << " prev " << Prev;
35
2.00k
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::TypedefNameDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::TypedefNameDecl> const*)
Line
Count
Source
31
1.46k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
1.46k
  const T *Prev = D->getPreviousDecl();
33
1.46k
  if (Prev)
34
2
    OS << " prev " << Prev;
35
1.46k
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::UsingShadowDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::UsingShadowDecl> const*)
Line
Count
Source
31
24
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
24
  const T *Prev = D->getPreviousDecl();
33
24
  if (Prev)
34
0
    OS << " prev " << Prev;
35
24
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::FunctionDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::FunctionDecl> const*)
Line
Count
Source
31
2.11k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
2.11k
  const T *Prev = D->getPreviousDecl();
33
2.11k
  if (Prev)
34
81
    OS << " prev " << Prev;
35
2.11k
}
TextNodeDumper.cpp:void dumpPreviousDeclImpl<clang::VarDecl>(llvm::raw_ostream&, clang::Redeclarable<clang::VarDecl> const*)
Line
Count
Source
31
6.04k
static void dumpPreviousDeclImpl(raw_ostream &OS, const Redeclarable<T> *D) {
32
6.04k
  const T *Prev = D->getPreviousDecl();
33
6.04k
  if (Prev)
34
13
    OS << " prev " << Prev;
35
6.04k
}
36
37
/// Dump the previous declaration in the redeclaration chain for a declaration,
38
/// if any.
39
15.4k
static void dumpPreviousDecl(raw_ostream &OS, const Decl *D) {
40
15.4k
  switch (D->getKind()) {
41
0
#define DECL(DERIVED, BASE)                                                    \
42
15.4k
  case Decl::DERIVED:                                                          \
43
15.4k
    return dumpPreviousDeclImpl(OS, cast<DERIVED##Decl>(D));
44
0
#define ABSTRACT_DECL(DECL)
45
0
#include "clang/AST/DeclNodes.inc"
46
15.4k
  }
47
15.4k
  
llvm_unreachable0
("Decl that isn't part of DeclNodes.inc!");
48
15.4k
}
49
50
TextNodeDumper::TextNodeDumper(raw_ostream &OS, bool ShowColors,
51
                               const SourceManager *SM,
52
                               const PrintingPolicy &PrintPolicy,
53
                               const comments::CommandTraits *Traits)
54
    : TextTreeStructure(OS, ShowColors), OS(OS), ShowColors(ShowColors), SM(SM),
55
1.11k
      PrintPolicy(PrintPolicy), Traits(Traits) {}
56
57
void TextNodeDumper::Visit(const comments::Comment *C,
58
517
                           const comments::FullComment *FC) {
59
517
  if (!C) {
60
0
    ColorScope Color(OS, ShowColors, NullColor);
61
0
    OS << "<<<NULL>>>";
62
0
    return;
63
0
  }
64
517
65
517
  {
66
517
    ColorScope Color(OS, ShowColors, CommentColor);
67
517
    OS << C->getCommentKindName();
68
517
  }
69
517
  dumpPointer(C);
70
517
  dumpSourceRange(C->getSourceRange());
71
517
72
517
  ConstCommentVisitor<TextNodeDumper, void,
73
517
                      const comments::FullComment *>::visit(C, FC);
74
517
}
75
76
1.20k
void TextNodeDumper::Visit(const Attr *A) {
77
1.20k
  {
78
1.20k
    ColorScope Color(OS, ShowColors, AttrColor);
79
1.20k
80
1.20k
    switch (A->getKind()) {
81
0
#define ATTR(X)                                                                \
82
1.20k
  case attr::X:                                                                \
83
1.20k
    OS << #X;                                                                  \
84
1.20k
    break;
85
0
#include "clang/Basic/AttrList.inc"
86
1.20k
    }
87
1.20k
    OS << "Attr";
88
1.20k
  }
89
1.20k
  dumpPointer(A);
90
1.20k
  dumpSourceRange(A->getRange());
91
1.20k
  if (A->isInherited())
92
15
    OS << " Inherited";
93
1.20k
  if (A->isImplicit())
94
894
    OS << " Implicit";
95
1.20k
96
1.20k
  ConstAttrVisitor<TextNodeDumper>::Visit(A);
97
1.20k
}
98
99
void TextNodeDumper::Visit(const TemplateArgument &TA, SourceRange R,
100
320
                           const Decl *From, StringRef Label) {
101
320
  OS << "TemplateArgument";
102
320
  if (R.isValid())
103
4
    dumpSourceRange(R);
104
320
105
320
  if (From)
106
3
    dumpDeclRef(From, Label);
107
320
108
320
  ConstTemplateArgumentVisitor<TextNodeDumper>::Visit(TA);
109
320
}
110
111
18.8k
void TextNodeDumper::Visit(const Stmt *Node) {
112
18.8k
  if (!Node) {
113
755
    ColorScope Color(OS, ShowColors, NullColor);
114
755
    OS << "<<<NULL>>>";
115
755
    return;
116
755
  }
117
18.0k
  {
118
18.0k
    ColorScope Color(OS, ShowColors, StmtColor);
119
18.0k
    OS << Node->getStmtClassName();
120
18.0k
  }
121
18.0k
  dumpPointer(Node);
122
18.0k
  dumpSourceRange(Node->getSourceRange());
123
18.0k
124
18.0k
  if (Node->isOMPStructuredBlock())
125
423
    OS << " openmp_structured_block";
126
18.0k
127
18.0k
  if (const auto *E = dyn_cast<Expr>(Node)) {
128
13.5k
    dumpType(E->getType());
129
13.5k
130
13.5k
    {
131
13.5k
      ColorScope Color(OS, ShowColors, ValueKindColor);
132
13.5k
      switch (E->getValueKind()) {
133
8.93k
      case VK_RValue:
134
8.93k
        break;
135
4.50k
      case VK_LValue:
136
4.50k
        OS << " lvalue";
137
4.50k
        break;
138
104
      case VK_XValue:
139
104
        OS << " xvalue";
140
104
        break;
141
13.5k
      }
142
13.5k
    }
143
13.5k
144
13.5k
    {
145
13.5k
      ColorScope Color(OS, ShowColors, ObjectKindColor);
146
13.5k
      switch (E->getObjectKind()) {
147
13.5k
      case OK_Ordinary:
148
13.5k
        break;
149
0
      case OK_BitField:
150
0
        OS << " bitfield";
151
0
        break;
152
2
      case OK_ObjCProperty:
153
2
        OS << " objcproperty";
154
2
        break;
155
0
      case OK_ObjCSubscript:
156
0
        OS << " objcsubscript";
157
0
        break;
158
8
      case OK_VectorComponent:
159
8
        OS << " vectorcomponent";
160
8
        break;
161
18.0k
      }
162
18.0k
    }
163
18.0k
  }
164
18.0k
165
18.0k
  ConstStmtVisitor<TextNodeDumper>::Visit(Node);
166
18.0k
}
167
168
2.12k
void TextNodeDumper::Visit(const Type *T) {
169
2.12k
  if (!T) {
170
0
    ColorScope Color(OS, ShowColors, NullColor);
171
0
    OS << "<<<NULL>>>";
172
0
    return;
173
0
  }
174
2.12k
  if (isa<LocInfoType>(T)) {
175
0
    {
176
0
      ColorScope Color(OS, ShowColors, TypeColor);
177
0
      OS << "LocInfo Type";
178
0
    }
179
0
    dumpPointer(T);
180
0
    return;
181
0
  }
182
2.12k
183
2.12k
  {
184
2.12k
    ColorScope Color(OS, ShowColors, TypeColor);
185
2.12k
    OS << T->getTypeClassName() << "Type";
186
2.12k
  }
187
2.12k
  dumpPointer(T);
188
2.12k
  OS << " ";
189
2.12k
  dumpBareType(QualType(T, 0), false);
190
2.12k
191
2.12k
  QualType SingleStepDesugar =
192
2.12k
      T->getLocallyUnqualifiedSingleStepDesugaredType();
193
2.12k
  if (SingleStepDesugar != QualType(T, 0))
194
96
    OS << " sugar";
195
2.12k
196
2.12k
  if (T->isDependentType())
197
29
    OS << " dependent";
198
2.09k
  else if (T->isInstantiationDependentType())
199
0
    OS << " instantiation_dependent";
200
2.12k
201
2.12k
  if (T->isVariablyModifiedType())
202
0
    OS << " variably_modified";
203
2.12k
  if (T->containsUnexpandedParameterPack())
204
0
    OS << " contains_unexpanded_pack";
205
2.12k
  if (T->isFromAST())
206
27
    OS << " imported";
207
2.12k
208
2.12k
  TypeVisitor<TextNodeDumper>::Visit(T);
209
2.12k
}
210
211
5
void TextNodeDumper::Visit(QualType T) {
212
5
  OS << "QualType";
213
5
  dumpPointer(T.getAsOpaquePtr());
214
5
  OS << " ";
215
5
  dumpBareType(T, false);
216
5
  OS << " " << T.split().Quals.getAsString();
217
5
}
218
219
15.4k
void TextNodeDumper::Visit(const Decl *D) {
220
15.4k
  if (!D) {
221
2
    ColorScope Color(OS, ShowColors, NullColor);
222
2
    OS << "<<<NULL>>>";
223
2
    return;
224
2
  }
225
15.4k
226
15.4k
  {
227
15.4k
    ColorScope Color(OS, ShowColors, DeclKindNameColor);
228
15.4k
    OS << D->getDeclKindName() << "Decl";
229
15.4k
  }
230
15.4k
  dumpPointer(D);
231
15.4k
  if (D->getLexicalDeclContext() != D->getDeclContext())
232
64
    OS << " parent " << cast<Decl>(D->getDeclContext());
233
15.4k
  dumpPreviousDecl(OS, D);
234
15.4k
  dumpSourceRange(D->getSourceRange());
235
15.4k
  OS << ' ';
236
15.4k
  dumpLocation(D->getLocation());
237
15.4k
  if (D->isFromASTFile())
238
101
    OS << " imported";
239
15.4k
  if (Module *M = D->getOwningModule())
240
74
    OS << " in " << M->getFullModuleName();
241
15.4k
  if (auto *ND = dyn_cast<NamedDecl>(D))
242
14.3k
    for (Module *M : D->getASTContext().getModulesWithMergedDefinition(
243
14.3k
             const_cast<NamedDecl *>(ND)))
244
0
      AddChild([=] { OS << "also in " << M->getFullModuleName(); });
245
15.4k
  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
246
14.3k
    if (ND->isHidden())
247
51
      OS << " hidden";
248
15.4k
  if (D->isImplicit())
249
6.15k
    OS << " implicit";
250
15.4k
251
15.4k
  if (D->isUsed())
252
2.85k
    OS << " used";
253
12.5k
  else if (D->isThisDeclarationReferenced())
254
713
    OS << " referenced";
255
15.4k
256
15.4k
  if (D->isInvalidDecl())
257
12
    OS << " invalid";
258
15.4k
  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
259
2.11k
    if (FD->isConstexprSpecified())
260
393
      OS << " constexpr";
261
2.11k
    if (FD->isConsteval())
262
0
      OS << " consteval";
263
2.11k
  }
264
15.4k
265
15.4k
  if (!isa<FunctionDecl>(*D)) {
266
13.3k
    const auto *MD = dyn_cast<ObjCMethodDecl>(D);
267
13.3k
    if (!MD || 
!MD->isThisDeclarationADefinition()131
) {
268
13.2k
      const auto *DC = dyn_cast<DeclContext>(D);
269
13.2k
      if (DC && 
DC->hasExternalLexicalStorage()3.28k
) {
270
260
        ColorScope Color(OS, ShowColors, UndeserializedColor);
271
260
        OS << " <undeserialized declarations>";
272
260
      }
273
13.2k
    }
274
13.3k
  }
275
15.4k
276
15.4k
  ConstDeclVisitor<TextNodeDumper>::Visit(D);
277
15.4k
}
278
279
86
void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
280
86
  OS << "CXXCtorInitializer";
281
86
  if (Init->isAnyMemberInitializer()) {
282
63
    OS << ' ';
283
63
    dumpBareDeclRef(Init->getAnyMember());
284
63
  } else 
if (23
Init->isBaseInitializer()23
) {
285
22
    dumpType(QualType(Init->getBaseClass(), 0));
286
22
  } else 
if (1
Init->isDelegatingInitializer()1
) {
287
1
    dumpType(Init->getTypeSourceInfo()->getType());
288
1
  } else {
289
0
    llvm_unreachable("Unknown initializer type");
290
0
  }
291
86
}
292
293
5
void TextNodeDumper::Visit(const BlockDecl::Capture &C) {
294
5
  OS << "capture";
295
5
  if (C.isByRef())
296
0
    OS << " byref";
297
5
  if (C.isNested())
298
0
    OS << " nested";
299
5
  if (C.getVariable()) {
300
5
    OS << ' ';
301
5
    dumpBareDeclRef(C.getVariable());
302
5
  }
303
5
}
304
305
158
void TextNodeDumper::Visit(const OMPClause *C) {
306
158
  if (!C) {
307
0
    ColorScope Color(OS, ShowColors, NullColor);
308
0
    OS << "<<<NULL>>> OMPClause";
309
0
    return;
310
0
  }
311
158
  {
312
158
    ColorScope Color(OS, ShowColors, AttrColor);
313
158
    StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
314
158
    OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
315
158
       << ClauseName.drop_front() << "Clause";
316
158
  }
317
158
  dumpPointer(C);
318
158
  dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc()));
319
158
  if (C->isImplicit())
320
65
    OS << " <implicit>";
321
158
}
322
323
9
void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
324
9
  const TypeSourceInfo *TSI = A.getTypeSourceInfo();
325
9
  if (TSI) {
326
6
    OS << "case ";
327
6
    dumpType(TSI->getType());
328
6
  } else {
329
3
    OS << "default";
330
3
  }
331
9
332
9
  if (A.isSelected())
333
5
    OS << " selected";
334
9
}
335
336
42.9k
void TextNodeDumper::dumpPointer(const void *Ptr) {
337
42.9k
  ColorScope Color(OS, ShowColors, AddressColor);
338
42.9k
  OS << ' ' << Ptr;
339
42.9k
}
340
341
66.9k
void TextNodeDumper::dumpLocation(SourceLocation Loc) {
342
66.9k
  if (!SM)
343
0
    return;
344
66.9k
345
66.9k
  ColorScope Color(OS, ShowColors, LocationColor);
346
66.9k
  SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
347
66.9k
348
66.9k
  // The general format we print out is filename:line:col, but we drop pieces
349
66.9k
  // that haven't changed since the last loc printed.
350
66.9k
  PresumedLoc PLoc = SM->getPresumedLoc(SpellingLoc);
351
66.9k
352
66.9k
  if (PLoc.isInvalid()) {
353
7.57k
    OS << "<invalid sloc>";
354
7.57k
    return;
355
7.57k
  }
356
59.3k
357
59.3k
  if (strcmp(PLoc.getFilename(), LastLocFilename) != 0) {
358
1.05k
    OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
359
1.05k
       << PLoc.getColumn();
360
1.05k
    LastLocFilename = PLoc.getFilename();
361
1.05k
    LastLocLine = PLoc.getLine();
362
58.3k
  } else if (PLoc.getLine() != LastLocLine) {
363
14.1k
    OS << "line" << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
364
14.1k
    LastLocLine = PLoc.getLine();
365
44.1k
  } else {
366
44.1k
    OS << "col" << ':' << PLoc.getColumn();
367
44.1k
  }
368
59.3k
}
369
370
35.3k
void TextNodeDumper::dumpSourceRange(SourceRange R) {
371
35.3k
  // Can't translate locations if a SourceManager isn't available.
372
35.3k
  if (!SM)
373
17
    return;
374
35.3k
375
35.3k
  OS << " <";
376
35.3k
  dumpLocation(R.getBegin());
377
35.3k
  if (R.getBegin() != R.getEnd()) {
378
16.1k
    OS << ", ";
379
16.1k
    dumpLocation(R.getEnd());
380
16.1k
  }
381
35.3k
  OS << ">";
382
35.3k
383
35.3k
  // <t2.c:123:421[blah], t2.c:412:321>
384
35.3k
}
385
386
32.2k
void TextNodeDumper::dumpBareType(QualType T, bool Desugar) {
387
32.2k
  ColorScope Color(OS, ShowColors, TypeColor);
388
32.2k
389
32.2k
  SplitQualType T_split = T.split();
390
32.2k
  OS << "'" << QualType::getAsString(T_split, PrintPolicy) << "'";
391
32.2k
392
32.2k
  if (Desugar && 
!T.isNull()30.0k
) {
393
30.0k
    // If the type is sugared, also dump a (shallow) desugared type.
394
30.0k
    SplitQualType D_split = T.getSplitDesugaredType();
395
30.0k
    if (T_split != D_split)
396
1.24k
      OS << ":'" << QualType::getAsString(D_split, PrintPolicy) << "'";
397
30.0k
  }
398
32.2k
}
399
400
30.0k
void TextNodeDumper::dumpType(QualType T) {
401
30.0k
  OS << ' ';
402
30.0k
  dumpBareType(T);
403
30.0k
}
404
405
5.24k
void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
406
5.24k
  if (!D) {
407
24
    ColorScope Color(OS, ShowColors, NullColor);
408
24
    OS << "<<<NULL>>>";
409
24
    return;
410
24
  }
411
5.22k
412
5.22k
  {
413
5.22k
    ColorScope Color(OS, ShowColors, DeclKindNameColor);
414
5.22k
    OS << D->getDeclKindName();
415
5.22k
  }
416
5.22k
  dumpPointer(D);
417
5.22k
418
5.22k
  if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
419
5.21k
    ColorScope Color(OS, ShowColors, DeclNameColor);
420
5.21k
    OS << " '" << ND->getDeclName() << '\'';
421
5.21k
  }
422
5.22k
423
5.22k
  if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))
424
4.37k
    dumpType(VD->getType());
425
5.22k
}
426
427
14.3k
void TextNodeDumper::dumpName(const NamedDecl *ND) {
428
14.3k
  if (ND->getDeclName()) {
429
12.7k
    ColorScope Color(OS, ShowColors, DeclNameColor);
430
12.7k
    OS << ' ' << ND->getNameAsString();
431
12.7k
  }
432
14.3k
}
433
434
146
void TextNodeDumper::dumpAccessSpecifier(AccessSpecifier AS) {
435
146
  switch (AS) {
436
0
  case AS_none:
437
0
    break;
438
124
  case AS_public:
439
124
    OS << "public";
440
124
    break;
441
6
  case AS_protected:
442
6
    OS << "protected";
443
6
    break;
444
16
  case AS_private:
445
16
    OS << "private";
446
16
    break;
447
146
  }
448
146
}
449
450
858
void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) {
451
858
  if (!D)
452
144
    return;
453
714
454
714
  AddChild([=] {
455
714
    if (!Label.empty())
456
34
      OS << Label << ' ';
457
714
    dumpBareDeclRef(D);
458
714
  });
459
714
}
460
461
30
const char *TextNodeDumper::getCommandName(unsigned CommandID) {
462
30
  if (Traits)
463
30
    return Traits->getCommandInfo(CommandID)->Name;
464
0
  const comments::CommandInfo *Info =
465
0
      comments::CommandTraits::getBuiltinCommandInfo(CommandID);
466
0
  if (Info)
467
0
    return Info->Name;
468
0
  return "<not a builtin command>";
469
0
}
470
471
void TextNodeDumper::visitTextComment(const comments::TextComment *C,
472
158
                                      const comments::FullComment *) {
473
158
  OS << " Text=\"" << C->getText() << "\"";
474
158
}
475
476
void TextNodeDumper::visitInlineCommandComment(
477
7
    const comments::InlineCommandComment *C, const comments::FullComment *) {
478
7
  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
479
7
  switch (C->getRenderKind()) {
480
1
  case comments::InlineCommandComment::RenderNormal:
481
1
    OS << " RenderNormal";
482
1
    break;
483
0
  case comments::InlineCommandComment::RenderBold:
484
0
    OS << " RenderBold";
485
0
    break;
486
5
  case comments::InlineCommandComment::RenderMonospaced:
487
5
    OS << " RenderMonospaced";
488
5
    break;
489
0
  case comments::InlineCommandComment::RenderEmphasized:
490
0
    OS << " RenderEmphasized";
491
0
    break;
492
1
  case comments::InlineCommandComment::RenderAnchor:
493
1
    OS << " RenderAnchor";
494
1
    break;
495
7
  }
496
7
497
11
  
for (unsigned i = 0, e = C->getNumArgs(); 7
i != e;
++i4
)
498
4
    OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
499
7
}
500
501
void TextNodeDumper::visitHTMLStartTagComment(
502
16
    const comments::HTMLStartTagComment *C, const comments::FullComment *) {
503
16
  OS << " Name=\"" << C->getTagName() << "\"";
504
16
  if (C->getNumAttrs() != 0) {
505
6
    OS << " Attrs: ";
506
12
    for (unsigned i = 0, e = C->getNumAttrs(); i != e; 
++i6
) {
507
6
      const comments::HTMLStartTagComment::Attribute &Attr = C->getAttr(i);
508
6
      OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
509
6
    }
510
6
  }
511
16
  if (C->isSelfClosing())
512
4
    OS << " SelfClosing";
513
16
}
514
515
void TextNodeDumper::visitHTMLEndTagComment(
516
6
    const comments::HTMLEndTagComment *C, const comments::FullComment *) {
517
6
  OS << " Name=\"" << C->getTagName() << "\"";
518
6
}
519
520
void TextNodeDumper::visitBlockCommandComment(
521
10
    const comments::BlockCommandComment *C, const comments::FullComment *) {
522
10
  OS << " Name=\"" << getCommandName(C->getCommandID()) << "\"";
523
10
  for (unsigned i = 0, e = C->getNumArgs(); i != e; 
++i0
)
524
0
    OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
525
10
}
526
527
void TextNodeDumper::visitParamCommandComment(
528
27
    const comments::ParamCommandComment *C, const comments::FullComment *FC) {
529
27
  OS << " "
530
27
     << comments::ParamCommandComment::getDirectionAsString(C->getDirection());
531
27
532
27
  if (C->isDirectionExplicit())
533
17
    OS << " explicitly";
534
10
  else
535
10
    OS << " implicitly";
536
27
537
27
  if (C->hasParamName()) {
538
26
    if (C->isParamIndexValid())
539
4
      OS << " Param=\"" << C->getParamName(FC) << "\"";
540
22
    else
541
22
      OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
542
26
  }
543
27
544
27
  if (C->isParamIndexValid() && 
!C->isVarArgParam()4
)
545
2
    OS << " ParamIndex=" << C->getParamIndex();
546
27
}
547
548
void TextNodeDumper::visitTParamCommandComment(
549
7
    const comments::TParamCommandComment *C, const comments::FullComment *FC) {
550
7
  if (C->hasParamName()) {
551
6
    if (C->isPositionValid())
552
1
      OS << " Param=\"" << C->getParamName(FC) << "\"";
553
5
    else
554
5
      OS << " Param=\"" << C->getParamNameAsWritten() << "\"";
555
6
  }
556
7
557
7
  if (C->isPositionValid()) {
558
1
    OS << " Position=<";
559
2
    for (unsigned i = 0, e = C->getDepth(); i != e; 
++i1
) {
560
1
      OS << C->getIndex(i);
561
1
      if (i != e - 1)
562
0
        OS << ", ";
563
1
    }
564
1
    OS << ">";
565
1
  }
566
7
}
567
568
void TextNodeDumper::visitVerbatimBlockComment(
569
13
    const comments::VerbatimBlockComment *C, const comments::FullComment *) {
570
13
  OS << " Name=\"" << getCommandName(C->getCommandID())
571
13
     << "\""
572
13
        " CloseName=\""
573
13
     << C->getCloseName() << "\"";
574
13
}
575
576
void TextNodeDumper::visitVerbatimBlockLineComment(
577
    const comments::VerbatimBlockLineComment *C,
578
17
    const comments::FullComment *) {
579
17
  OS << " Text=\"" << C->getText() << "\"";
580
17
}
581
582
void TextNodeDumper::visitVerbatimLineComment(
583
4
    const comments::VerbatimLineComment *C, const comments::FullComment *) {
584
4
  OS << " Text=\"" << C->getText() << "\"";
585
4
}
586
587
0
void TextNodeDumper::VisitNullTemplateArgument(const TemplateArgument &) {
588
0
  OS << " null";
589
0
}
590
591
200
void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument &TA) {
592
200
  OS << " type";
593
200
  dumpType(TA.getAsType());
594
200
}
595
596
void TextNodeDumper::VisitDeclarationTemplateArgument(
597
1
    const TemplateArgument &TA) {
598
1
  OS << " decl";
599
1
  dumpDeclRef(TA.getAsDecl());
600
1
}
601
602
1
void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) {
603
1
  OS << " nullptr";
604
1
}
605
606
59
void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
607
59
  OS << " integral " << TA.getAsIntegral();
608
59
}
609
610
16
void TextNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) {
611
16
  OS << " template ";
612
16
  TA.getAsTemplate().dump(OS);
613
16
}
614
615
void TextNodeDumper::VisitTemplateExpansionTemplateArgument(
616
0
    const TemplateArgument &TA) {
617
0
  OS << " template expansion ";
618
0
  TA.getAsTemplateOrTemplatePattern().dump(OS);
619
0
}
620
621
29
void TextNodeDumper::VisitExpressionTemplateArgument(const TemplateArgument &) {
622
29
  OS << " expr";
623
29
}
624
625
14
void TextNodeDumper::VisitPackTemplateArgument(const TemplateArgument &) {
626
14
  OS << " pack";
627
14
}
628
629
2.90k
static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) {
630
2.90k
  if (Node->path_empty())
631
2.86k
    return;
632
40
633
40
  OS << " (";
634
40
  bool First = true;
635
40
  for (CastExpr::path_const_iterator I = Node->path_begin(),
636
40
                                     E = Node->path_end();
637
80
       I != E; 
++I40
) {
638
40
    const CXXBaseSpecifier *Base = *I;
639
40
    if (!First)
640
0
      OS << " -> ";
641
40
642
40
    const auto *RD =
643
40
        cast<CXXRecordDecl>(Base->getType()->castAs<RecordType>()->getDecl());
644
40
645
40
    if (Base->isVirtual())
646
0
      OS << "virtual ";
647
40
    OS << RD->getName();
648
40
    First = false;
649
40
  }
650
40
651
40
  OS << ')';
652
40
}
653
654
23
void TextNodeDumper::VisitIfStmt(const IfStmt *Node) {
655
23
  if (Node->hasInitStorage())
656
2
    OS << " has_init";
657
23
  if (Node->hasVarStorage())
658
1
    OS << " has_var";
659
23
  if (Node->hasElseStorage())
660
14
    OS << " has_else";
661
23
}
662
663
14
void TextNodeDumper::VisitSwitchStmt(const SwitchStmt *Node) {
664
14
  if (Node->hasInitStorage())
665
2
    OS << " has_init";
666
14
  if (Node->hasVarStorage())
667
0
    OS << " has_var";
668
14
}
669
670
9
void TextNodeDumper::VisitWhileStmt(const WhileStmt *Node) {
671
9
  if (Node->hasVarStorage())
672
1
    OS << " has_var";
673
9
}
674
675
15
void TextNodeDumper::VisitLabelStmt(const LabelStmt *Node) {
676
15
  OS << " '" << Node->getName() << "'";
677
15
}
678
679
8
void TextNodeDumper::VisitGotoStmt(const GotoStmt *Node) {
680
8
  OS << " '" << Node->getLabel()->getName() << "'";
681
8
  dumpPointer(Node->getLabel());
682
8
}
683
684
23
void TextNodeDumper::VisitCaseStmt(const CaseStmt *Node) {
685
23
  if (Node->caseStmtIsGNURange())
686
6
    OS << " gnu_range";
687
23
}
688
689
212
void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) {
690
212
  if (Node->getResultAPValueKind() != APValue::None) {
691
62
    ColorScope Color(OS, ShowColors, ValueColor);
692
62
    OS << " ";
693
62
    Node->getAPValueResult().dump(OS);
694
62
  }
695
212
}
696
697
241
void TextNodeDumper::VisitCallExpr(const CallExpr *Node) {
698
241
  if (Node->usesADL())
699
5
    OS << " adl";
700
241
}
701
702
2.87k
void TextNodeDumper::VisitCastExpr(const CastExpr *Node) {
703
2.87k
  OS << " <";
704
2.87k
  {
705
2.87k
    ColorScope Color(OS, ShowColors, CastColor);
706
2.87k
    OS << Node->getCastKindName();
707
2.87k
  }
708
2.87k
  dumpBasePath(OS, Node);
709
2.87k
  OS << ">";
710
2.87k
}
711
712
2.72k
void TextNodeDumper::VisitImplicitCastExpr(const ImplicitCastExpr *Node) {
713
2.72k
  VisitCastExpr(Node);
714
2.72k
  if (Node->isPartOfExplicitCast())
715
59
    OS << " part_of_explicit_cast";
716
2.72k
}
717
718
4.07k
void TextNodeDumper::VisitDeclRefExpr(const DeclRefExpr *Node) {
719
4.07k
  OS << " ";
720
4.07k
  dumpBareDeclRef(Node->getDecl());
721
4.07k
  if (Node->getDecl() != Node->getFoundDecl()) {
722
47
    OS << " (";
723
47
    dumpBareDeclRef(Node->getFoundDecl());
724
47
    OS << ")";
725
47
  }
726
4.07k
  switch (Node->isNonOdrUse()) {
727
4.02k
  case NOUR_None: break;
728
24
  case NOUR_Unevaluated: OS << " non_odr_use_unevaluated"; break;
729
26
  case NOUR_Constant: OS << " non_odr_use_constant"; break;
730
0
  case NOUR_Discarded: OS << " non_odr_use_discarded"; break;
731
4.07k
  }
732
4.07k
}
733
734
void TextNodeDumper::VisitUnresolvedLookupExpr(
735
13
    const UnresolvedLookupExpr *Node) {
736
13
  OS << " (";
737
13
  if (!Node->requiresADL())
738
9
    OS << "no ";
739
13
  OS << "ADL) = '" << Node->getName() << '\'';
740
13
741
13
  UnresolvedLookupExpr::decls_iterator I = Node->decls_begin(),
742
13
                                       E = Node->decls_end();
743
13
  if (I == E)
744
0
    OS << " empty";
745
27
  for (; I != E; 
++I14
)
746
14
    dumpPointer(*I);
747
13
}
748
749
0
void TextNodeDumper::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node) {
750
0
  {
751
0
    ColorScope Color(OS, ShowColors, DeclKindNameColor);
752
0
    OS << " " << Node->getDecl()->getDeclKindName() << "Decl";
753
0
  }
754
0
  OS << "='" << *Node->getDecl() << "'";
755
0
  dumpPointer(Node->getDecl());
756
0
  if (Node->isFreeIvar())
757
0
    OS << " isFreeIvar";
758
0
}
759
760
18
void TextNodeDumper::VisitPredefinedExpr(const PredefinedExpr *Node) {
761
18
  OS << " " << PredefinedExpr::getIdentKindName(Node->getIdentKind());
762
18
}
763
764
12
void TextNodeDumper::VisitCharacterLiteral(const CharacterLiteral *Node) {
765
12
  ColorScope Color(OS, ShowColors, ValueColor);
766
12
  OS << " " << Node->getValue();
767
12
}
768
769
2.29k
void TextNodeDumper::VisitIntegerLiteral(const IntegerLiteral *Node) {
770
2.29k
  bool isSigned = Node->getType()->isSignedIntegerType();
771
2.29k
  ColorScope Color(OS, ShowColors, ValueColor);
772
2.29k
  OS << " " << Node->getValue().toString(10, isSigned);
773
2.29k
}
774
775
53
void TextNodeDumper::VisitFixedPointLiteral(const FixedPointLiteral *Node) {
776
53
  ColorScope Color(OS, ShowColors, ValueColor);
777
53
  OS << " " << Node->getValueAsString(/*Radix=*/10);
778
53
}
779
780
91
void TextNodeDumper::VisitFloatingLiteral(const FloatingLiteral *Node) {
781
91
  ColorScope Color(OS, ShowColors, ValueColor);
782
91
  OS << " " << Node->getValueAsApproximateDouble();
783
91
}
784
785
87
void TextNodeDumper::VisitStringLiteral(const StringLiteral *Str) {
786
87
  ColorScope Color(OS, ShowColors, ValueColor);
787
87
  OS << " ";
788
87
  Str->outputString(OS);
789
87
}
790
791
96
void TextNodeDumper::VisitInitListExpr(const InitListExpr *ILE) {
792
96
  if (auto *Field = ILE->getInitializedFieldInUnion()) {
793
2
    OS << " field ";
794
2
    dumpBareDeclRef(Field);
795
2
  }
796
96
}
797
798
5
void TextNodeDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
799
5
  if (E->isResultDependent())
800
0
    OS << " result_dependent";
801
5
}
802
803
865
void TextNodeDumper::VisitUnaryOperator(const UnaryOperator *Node) {
804
865
  OS << " " << (Node->isPostfix() ? 
"postfix"706
:
"prefix"159
) << " '"
805
865
     << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
806
865
  if (!Node->canOverflow())
807
97
    OS << " cannot overflow";
808
865
}
809
810
void TextNodeDumper::VisitUnaryExprOrTypeTraitExpr(
811
37
    const UnaryExprOrTypeTraitExpr *Node) {
812
37
  switch (Node->getKind()) {
813
32
  case UETT_SizeOf:
814
32
    OS << " sizeof";
815
32
    break;
816
5
  case UETT_AlignOf:
817
5
    OS << " alignof";
818
5
    break;
819
0
  case UETT_VecStep:
820
0
    OS << " vec_step";
821
0
    break;
822
0
  case UETT_OpenMPRequiredSimdAlign:
823
0
    OS << " __builtin_omp_required_simd_align";
824
0
    break;
825
0
  case UETT_PreferredAlignOf:
826
0
    OS << " __alignof";
827
0
    break;
828
37
  }
829
37
  if (Node->isArgumentType())
830
29
    dumpType(Node->getArgumentType());
831
37
}
832
833
139
void TextNodeDumper::VisitMemberExpr(const MemberExpr *Node) {
834
139
  OS << " " << (Node->isArrow() ? 
"->"71
:
"."68
) << *Node->getMemberDecl();
835
139
  dumpPointer(Node->getMemberDecl());
836
139
  switch (Node->isNonOdrUse()) {
837
125
  case NOUR_None: break;
838
4
  case NOUR_Unevaluated: OS << " non_odr_use_unevaluated"; break;
839
10
  case NOUR_Constant: OS << " non_odr_use_constant"; break;
840
0
  case NOUR_Discarded: OS << " non_odr_use_discarded"; break;
841
139
  }
842
139
}
843
844
void TextNodeDumper::VisitExtVectorElementExpr(
845
8
    const ExtVectorElementExpr *Node) {
846
8
  OS << " " << Node->getAccessor().getNameStart();
847
8
}
848
849
1.15k
void TextNodeDumper::VisitBinaryOperator(const BinaryOperator *Node) {
850
1.15k
  OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
851
1.15k
}
852
853
void TextNodeDumper::VisitCompoundAssignOperator(
854
19
    const CompoundAssignOperator *Node) {
855
19
  OS << " '" << BinaryOperator::getOpcodeStr(Node->getOpcode())
856
19
     << "' ComputeLHSTy=";
857
19
  dumpBareType(Node->getComputationLHSType());
858
19
  OS << " ComputeResultTy=";
859
19
  dumpBareType(Node->getComputationResultType());
860
19
}
861
862
8
void TextNodeDumper::VisitAddrLabelExpr(const AddrLabelExpr *Node) {
863
8
  OS << " " << Node->getLabel()->getName();
864
8
  dumpPointer(Node->getLabel());
865
8
}
866
867
27
void TextNodeDumper::VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node) {
868
27
  OS << " " << Node->getCastName() << "<"
869
27
     << Node->getTypeAsWritten().getAsString() << ">"
870
27
     << " <" << Node->getCastKindName();
871
27
  dumpBasePath(OS, Node);
872
27
  OS << ">";
873
27
}
874
875
29
void TextNodeDumper::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node) {
876
29
  OS << " " << (Node->getValue() ? 
"true"21
:
"false"8
);
877
29
}
878
879
66
void TextNodeDumper::VisitCXXThisExpr(const CXXThisExpr *Node) {
880
66
  if (Node->isImplicit())
881
44
    OS << " implicit";
882
66
  OS << " this";
883
66
}
884
885
void TextNodeDumper::VisitCXXFunctionalCastExpr(
886
19
    const CXXFunctionalCastExpr *Node) {
887
19
  OS << " functional cast to " << Node->getTypeAsWritten().getAsString() << " <"
888
19
     << Node->getCastKindName() << ">";
889
19
}
890
891
void TextNodeDumper::VisitCXXUnresolvedConstructExpr(
892
18
    const CXXUnresolvedConstructExpr *Node) {
893
18
  dumpType(Node->getTypeAsWritten());
894
18
  if (Node->isListInitialization())
895
2
    OS << " list";
896
18
}
897
898
267
void TextNodeDumper::VisitCXXConstructExpr(const CXXConstructExpr *Node) {
899
267
  CXXConstructorDecl *Ctor = Node->getConstructor();
900
267
  dumpType(Ctor->getType());
901
267
  if (Node->isElidable())
902
59
    OS << " elidable";
903
267
  if (Node->isListInitialization())
904
6
    OS << " list";
905
267
  if (Node->isStdInitListInitialization())
906
1
    OS << " std::initializer_list";
907
267
  if (Node->requiresZeroInitialization())
908
25
    OS << " zeroing";
909
267
}
910
911
void TextNodeDumper::VisitCXXBindTemporaryExpr(
912
14
    const CXXBindTemporaryExpr *Node) {
913
14
  OS << " (CXXTemporary";
914
14
  dumpPointer(Node);
915
14
  OS << ")";
916
14
}
917
918
38
void TextNodeDumper::VisitCXXNewExpr(const CXXNewExpr *Node) {
919
38
  if (Node->isGlobalNew())
920
2
    OS << " global";
921
38
  if (Node->isArray())
922
13
    OS << " array";
923
38
  if (Node->getOperatorNew()) {
924
36
    OS << ' ';
925
36
    dumpBareDeclRef(Node->getOperatorNew());
926
36
  }
927
38
  // We could dump the deallocation function used in case of error, but it's
928
38
  // usually not that interesting.
929
38
}
930
931
37
void TextNodeDumper::VisitCXXDeleteExpr(const CXXDeleteExpr *Node) {
932
37
  if (Node->isGlobalDelete())
933
2
    OS << " global";
934
37
  if (Node->isArrayForm())
935
11
    OS << " array";
936
37
  if (Node->getOperatorDelete()) {
937
36
    OS << ' ';
938
36
    dumpBareDeclRef(Node->getOperatorDelete());
939
36
  }
940
37
}
941
942
void TextNodeDumper::VisitMaterializeTemporaryExpr(
943
95
    const MaterializeTemporaryExpr *Node) {
944
95
  if (const ValueDecl *VD = Node->getExtendingDecl()) {
945
5
    OS << " extended by ";
946
5
    dumpBareDeclRef(VD);
947
5
  }
948
95
}
949
950
87
void TextNodeDumper::VisitExprWithCleanups(const ExprWithCleanups *Node) {
951
93
  for (unsigned i = 0, e = Node->getNumObjects(); i != e; 
++i6
)
952
6
    dumpDeclRef(Node->getObject(i), "cleanup");
953
87
}
954
955
11
void TextNodeDumper::VisitSizeOfPackExpr(const SizeOfPackExpr *Node) {
956
11
  dumpPointer(Node->getPack());
957
11
  dumpName(Node->getPack());
958
11
}
959
960
void TextNodeDumper::VisitCXXDependentScopeMemberExpr(
961
19
    const CXXDependentScopeMemberExpr *Node) {
962
19
  OS << " " << (Node->isArrow() ? 
"->"9
:
"."10
) << Node->getMember();
963
19
}
964
965
4
void TextNodeDumper::VisitObjCMessageExpr(const ObjCMessageExpr *Node) {
966
4
  OS << " selector=";
967
4
  Node->getSelector().print(OS);
968
4
  switch (Node->getReceiverKind()) {
969
0
  case ObjCMessageExpr::Instance:
970
0
    break;
971
0
972
0
  case ObjCMessageExpr::Class:
973
0
    OS << " class=";
974
0
    dumpBareType(Node->getClassReceiver());
975
0
    break;
976
0
977
3
  case ObjCMessageExpr::SuperInstance:
978
3
    OS << " super (instance)";
979
3
    break;
980
0
981
1
  case ObjCMessageExpr::SuperClass:
982
1
    OS << " super (class)";
983
1
    break;
984
4
  }
985
4
}
986
987
1
void TextNodeDumper::VisitObjCBoxedExpr(const ObjCBoxedExpr *Node) {
988
1
  if (auto *BoxingMethod = Node->getBoxingMethod()) {
989
0
    OS << " selector=";
990
0
    BoxingMethod->getSelector().print(OS);
991
0
  }
992
1
}
993
994
7
void TextNodeDumper::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node) {
995
7
  if (!Node->getCatchParamDecl())
996
1
    OS << " catch all";
997
7
}
998
999
0
void TextNodeDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *Node) {
1000
0
  dumpType(Node->getEncodedType());
1001
0
}
1002
1003
0
void TextNodeDumper::VisitObjCSelectorExpr(const ObjCSelectorExpr *Node) {
1004
0
  OS << " ";
1005
0
  Node->getSelector().print(OS);
1006
0
}
1007
1008
0
void TextNodeDumper::VisitObjCProtocolExpr(const ObjCProtocolExpr *Node) {
1009
0
  OS << ' ' << *Node->getProtocol();
1010
0
}
1011
1012
2
void TextNodeDumper::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node) {
1013
2
  if (Node->isImplicitProperty()) {
1014
0
    OS << " Kind=MethodRef Getter=\"";
1015
0
    if (Node->getImplicitPropertyGetter())
1016
0
      Node->getImplicitPropertyGetter()->getSelector().print(OS);
1017
0
    else
1018
0
      OS << "(null)";
1019
0
1020
0
    OS << "\" Setter=\"";
1021
0
    if (ObjCMethodDecl *Setter = Node->getImplicitPropertySetter())
1022
0
      Setter->getSelector().print(OS);
1023
0
    else
1024
0
      OS << "(null)";
1025
0
    OS << "\"";
1026
2
  } else {
1027
2
    OS << " Kind=PropertyRef Property=\"" << *Node->getExplicitProperty()
1028
2
       << '"';
1029
2
  }
1030
2
1031
2
  if (Node->isSuperReceiver())
1032
2
    OS << " super";
1033
2
1034
2
  OS << " Messaging=";
1035
2
  if (Node->isMessagingGetter() && Node->isMessagingSetter())
1036
0
    OS << "Getter&Setter";
1037
2
  else if (Node->isMessagingGetter())
1038
2
    OS << "Getter";
1039
0
  else if (Node->isMessagingSetter())
1040
0
    OS << "Setter";
1041
2
}
1042
1043
void TextNodeDumper::VisitObjCSubscriptRefExpr(
1044
0
    const ObjCSubscriptRefExpr *Node) {
1045
0
  if (Node->isArraySubscriptRefExpr())
1046
0
    OS << " Kind=ArraySubscript GetterForArray=\"";
1047
0
  else
1048
0
    OS << " Kind=DictionarySubscript GetterForDictionary=\"";
1049
0
  if (Node->getAtIndexMethodDecl())
1050
0
    Node->getAtIndexMethodDecl()->getSelector().print(OS);
1051
0
  else
1052
0
    OS << "(null)";
1053
0
1054
0
  if (Node->isArraySubscriptRefExpr())
1055
0
    OS << "\" SetterForArray=\"";
1056
0
  else
1057
0
    OS << "\" SetterForDictionary=\"";
1058
0
  if (Node->setAtIndexMethodDecl())
1059
0
    Node->setAtIndexMethodDecl()->getSelector().print(OS);
1060
0
  else
1061
0
    OS << "(null)";
1062
0
}
1063
1064
7
void TextNodeDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) {
1065
7
  OS << " " << (Node->getValue() ? "__objc_yes" : 
"__objc_no"0
);
1066
7
}
1067
1068
0
void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) {
1069
0
  if (T->isSpelledAsLValue())
1070
0
    OS << " written as lvalue reference";
1071
0
}
1072
1073
197
void TextNodeDumper::VisitArrayType(const ArrayType *T) {
1074
197
  switch (T->getSizeModifier()) {
1075
197
  case ArrayType::Normal:
1076
197
    break;
1077
0
  case ArrayType::Static:
1078
0
    OS << " static";
1079
0
    break;
1080
0
  case ArrayType::Star:
1081
0
    OS << " *";
1082
0
    break;
1083
197
  }
1084
197
  OS << " " << T->getIndexTypeQualifiers().getAsString();
1085
197
}
1086
1087
196
void TextNodeDumper::VisitConstantArrayType(const ConstantArrayType *T) {
1088
196
  OS << " " << T->getSize();
1089
196
  VisitArrayType(T);
1090
196
}
1091
1092
0
void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) {
1093
0
  OS << " ";
1094
0
  dumpSourceRange(T->getBracketsRange());
1095
0
  VisitArrayType(T);
1096
0
}
1097
1098
void TextNodeDumper::VisitDependentSizedArrayType(
1099
1
    const DependentSizedArrayType *T) {
1100
1
  VisitArrayType(T);
1101
1
  OS << " ";
1102
1
  dumpSourceRange(T->getBracketsRange());
1103
1
}
1104
1105
void TextNodeDumper::VisitDependentSizedExtVectorType(
1106
0
    const DependentSizedExtVectorType *T) {
1107
0
  OS << " ";
1108
0
  dumpLocation(T->getAttributeLoc());
1109
0
}
1110
1111
5
void TextNodeDumper::VisitVectorType(const VectorType *T) {
1112
5
  switch (T->getVectorKind()) {
1113
5
  case VectorType::GenericVector:
1114
5
    break;
1115
0
  case VectorType::AltiVecVector:
1116
0
    OS << " altivec";
1117
0
    break;
1118
0
  case VectorType::AltiVecPixel:
1119
0
    OS << " altivec pixel";
1120
0
    break;
1121
0
  case VectorType::AltiVecBool:
1122
0
    OS << " altivec bool";
1123
0
    break;
1124
0
  case VectorType::NeonVector:
1125
0
    OS << " neon";
1126
0
    break;
1127
0
  case VectorType::NeonPolyVector:
1128
0
    OS << " neon poly";
1129
0
    break;
1130
5
  }
1131
5
  OS << " " << T->getNumElements();
1132
5
}
1133
1134
0
void TextNodeDumper::VisitFunctionType(const FunctionType *T) {
1135
0
  auto EI = T->getExtInfo();
1136
0
  if (EI.getNoReturn())
1137
0
    OS << " noreturn";
1138
0
  if (EI.getProducesResult())
1139
0
    OS << " produces_result";
1140
0
  if (EI.getHasRegParm())
1141
0
    OS << " regparm " << EI.getRegParm();
1142
0
  OS << " " << FunctionType::getNameForCallConv(EI.getCC());
1143
0
}
1144
1145
0
void TextNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) {
1146
0
  auto EPI = T->getExtProtoInfo();
1147
0
  if (EPI.HasTrailingReturn)
1148
0
    OS << " trailing_return";
1149
0
  if (T->isConst())
1150
0
    OS << " const";
1151
0
  if (T->isVolatile())
1152
0
    OS << " volatile";
1153
0
  if (T->isRestrict())
1154
0
    OS << " restrict";
1155
0
  if (T->getExtProtoInfo().Variadic)
1156
0
    OS << " variadic";
1157
0
  switch (EPI.RefQualifier) {
1158
0
  case RQ_None:
1159
0
    break;
1160
0
  case RQ_LValue:
1161
0
    OS << " &";
1162
0
    break;
1163
0
  case RQ_RValue:
1164
0
    OS << " &&";
1165
0
    break;
1166
0
  }
1167
0
  // FIXME: Exception specification.
1168
0
  // FIXME: Consumed parameters.
1169
0
  VisitFunctionType(T);
1170
0
}
1171
1172
0
void TextNodeDumper::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
1173
0
  dumpDeclRef(T->getDecl());
1174
0
}
1175
1176
23
void TextNodeDumper::VisitTypedefType(const TypedefType *T) {
1177
23
  dumpDeclRef(T->getDecl());
1178
23
}
1179
1180
0
void TextNodeDumper::VisitUnaryTransformType(const UnaryTransformType *T) {
1181
0
  switch (T->getUTTKind()) {
1182
0
  case UnaryTransformType::EnumUnderlyingType:
1183
0
    OS << " underlying_type";
1184
0
    break;
1185
0
  }
1186
0
}
1187
1188
461
void TextNodeDumper::VisitTagType(const TagType *T) {
1189
461
  dumpDeclRef(T->getDecl());
1190
461
}
1191
1192
8
void TextNodeDumper::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
1193
8
  OS << " depth " << T->getDepth() << " index " << T->getIndex();
1194
8
  if (T->isParameterPack())
1195
0
    OS << " pack";
1196
8
  dumpDeclRef(T->getDecl());
1197
8
}
1198
1199
0
void TextNodeDumper::VisitAutoType(const AutoType *T) {
1200
0
  if (T->isDecltypeAuto())
1201
0
    OS << " decltype(auto)";
1202
0
  if (!T->isDeduced())
1203
0
    OS << " undeduced";
1204
0
  if (T->isConstrained()) {
1205
0
    dumpDeclRef(T->getTypeConstraintConcept());
1206
0
    for (const auto &Arg : T->getTypeConstraintArguments())
1207
0
      VisitTemplateArgument(Arg);
1208
0
  }
1209
0
}
1210
1211
void TextNodeDumper::VisitTemplateSpecializationType(
1212
46
    const TemplateSpecializationType *T) {
1213
46
  if (T->isTypeAlias())
1214
4
    OS << " alias";
1215
46
  OS << " ";
1216
46
  T->getTemplateName().dump(OS);
1217
46
}
1218
1219
void TextNodeDumper::VisitInjectedClassNameType(
1220
0
    const InjectedClassNameType *T) {
1221
0
  dumpDeclRef(T->getDecl());
1222
0
}
1223
1224
1
void TextNodeDumper::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
1225
1
  dumpDeclRef(T->getDecl());
1226
1
}
1227
1228
0
void TextNodeDumper::VisitPackExpansionType(const PackExpansionType *T) {
1229
0
  if (auto N = T->getNumExpansions())
1230
0
    OS << " expansions " << *N;
1231
0
}
1232
1233
3
void TextNodeDumper::VisitLabelDecl(const LabelDecl *D) { dumpName(D); }
1234
1235
1.41k
void TextNodeDumper::VisitTypedefDecl(const TypedefDecl *D) {
1236
1.41k
  dumpName(D);
1237
1.41k
  dumpType(D->getUnderlyingType());
1238
1.41k
  if (D->isModulePrivate())
1239
1
    OS << " __module_private__";
1240
1.41k
}
1241
1242
50
void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
1243
50
  if (D->isScoped()) {
1244
7
    if (D->isScopedUsingClassTag())
1245
7
      OS << " class";
1246
0
    else
1247
0
      OS << " struct";
1248
7
  }
1249
50
  dumpName(D);
1250
50
  if (D->isModulePrivate())
1251
1
    OS << " __module_private__";
1252
50
  if (D->isFixed())
1253
9
    dumpType(D->getIntegerType());
1254
50
}
1255
1256
1.95k
void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {
1257
1.95k
  OS << ' ' << D->getKindName();
1258
1.95k
  dumpName(D);
1259
1.95k
  if (D->isModulePrivate())
1260
1
    OS << " __module_private__";
1261
1.95k
  if (D->isCompleteDefinition())
1262
1.20k
    OS << " definition";
1263
1.95k
}
1264
1265
63
void TextNodeDumper::VisitEnumConstantDecl(const EnumConstantDecl *D) {
1266
63
  dumpName(D);
1267
63
  dumpType(D->getType());
1268
63
}
1269
1270
31
void TextNodeDumper::VisitIndirectFieldDecl(const IndirectFieldDecl *D) {
1271
31
  dumpName(D);
1272
31
  dumpType(D->getType());
1273
31
1274
31
  for (const auto *Child : D->chain())
1275
62
    dumpDeclRef(Child);
1276
31
}
1277
1278
2.11k
void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
1279
2.11k
  dumpName(D);
1280
2.11k
  dumpType(D->getType());
1281
2.11k
1282
2.11k
  StorageClass SC = D->getStorageClass();
1283
2.11k
  if (SC != SC_None)
1284
100
    OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
1285
2.11k
  if (D->isInlineSpecified())
1286
737
    OS << " inline";
1287
2.11k
  if (D->isVirtualAsWritten())
1288
38
    OS << " virtual";
1289
2.11k
  if (D->isModulePrivate())
1290
0
    OS << " __module_private__";
1291
2.11k
1292
2.11k
  if (D->isPure())
1293
4
    OS << " pure";
1294
2.11k
  if (D->isDefaulted()) {
1295
648
    OS << " default";
1296
648
    if (D->isDeleted())
1297
39
      OS << "_delete";
1298
648
  }
1299
2.11k
  if (D->isDeletedAsWritten())
1300
10
    OS << " delete";
1301
2.11k
  if (D->isTrivial())
1302
496
    OS << " trivial";
1303
2.11k
1304
2.11k
  if (const auto *FPT = D->getType()->getAs<FunctionProtoType>()) {
1305
1.98k
    FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
1306
1.98k
    switch (EPI.ExceptionSpec.Type) {
1307
1.53k
    default:
1308
1.53k
      break;
1309
456
    case EST_Unevaluated:
1310
456
      OS << " noexcept-unevaluated " << EPI.ExceptionSpec.SourceDecl;
1311
456
      break;
1312
0
    case EST_Uninstantiated:
1313
0
      OS << " noexcept-uninstantiated " << EPI.ExceptionSpec.SourceTemplate;
1314
0
      break;
1315
2.11k
    }
1316
2.11k
  }
1317
2.11k
1318
2.11k
  if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
1319
1.11k
    if (MD->size_overridden_methods() != 0) {
1320
12
      auto dumpOverride = [=](const CXXMethodDecl *D) {
1321
12
        SplitQualType T_split = D->getType().split();
1322
12
        OS << D << " " << D->getParent()->getName()
1323
12
           << "::" << D->getNameAsString() << " '"
1324
12
           << QualType::getAsString(T_split, PrintPolicy) << "'";
1325
12
      };
1326
11
1327
11
      AddChild([=] {
1328
11
        auto Overrides = MD->overridden_methods();
1329
11
        OS << "Overrides: [ ";
1330
11
        dumpOverride(*Overrides.begin());
1331
11
        for (const auto *Override :
1332
11
             llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
1333
1
          OS << ", ";
1334
1
          dumpOverride(Override);
1335
1
        }
1336
11
        OS << " ]";
1337
11
      });
1338
11
    }
1339
1.11k
  }
1340
2.11k
1341
2.11k
  // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
1342
2.11k
  // the Params are set later, it is possible for a dump during debugging to
1343
2.11k
  // encounter a FunctionDecl that has been created but hasn't been assigned
1344
2.11k
  // ParmVarDecls yet.
1345
2.11k
  if (!D->param_empty() && 
!D->param_begin()1.00k
)
1346
0
    OS << " <<<NULL params x " << D->getNumParams() << ">>>";
1347
2.11k
}
1348
1349
void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
1350
0
    const LifetimeExtendedTemporaryDecl *D) {
1351
0
  OS << " extended by ";
1352
0
  dumpBareDeclRef(D->getExtendingDecl());
1353
0
  OS << " mangling ";
1354
0
  {
1355
0
    ColorScope Color(OS, ShowColors, ValueColor);
1356
0
    OS << D->getManglingNumber();
1357
0
  }
1358
0
}
1359
1360
1.50k
void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
1361
1.50k
  dumpName(D);
1362
1.50k
  dumpType(D->getType());
1363
1.50k
  if (D->isMutable())
1364
2
    OS << " mutable";
1365
1.50k
  if (D->isModulePrivate())
1366
1
    OS << " __module_private__";
1367
1.50k
}
1368
1369
5.94k
void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
1370
5.94k
  dumpName(D);
1371
5.94k
  dumpType(D->getType());
1372
5.94k
  StorageClass SC = D->getStorageClass();
1373
5.94k
  if (SC != SC_None)
1374
90
    OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
1375
5.94k
  switch (D->getTLSKind()) {
1376
5.93k
  case VarDecl::TLS_None:
1377
5.93k
    break;
1378
9
  case VarDecl::TLS_Static:
1379
9
    OS << " tls";
1380
9
    break;
1381
3
  case VarDecl::TLS_Dynamic:
1382
3
    OS << " tls_dynamic";
1383
3
    break;
1384
5.94k
  }
1385
5.94k
  if (D->isModulePrivate())
1386
1
    OS << " __module_private__";
1387
5.94k
  if (D->isNRVOVariable())
1388
4
    OS << " nrvo";
1389
5.94k
  if (D->isInline())
1390
1
    OS << " inline";
1391
5.94k
  if (D->isConstexpr())
1392
9
    OS << " constexpr";
1393
5.94k
  if (D->hasInit()) {
1394
1.91k
    switch (D->getInitStyle()) {
1395
1.86k
    case VarDecl::CInit:
1396
1.86k
      OS << " cinit";
1397
1.86k
      break;
1398
46
    case VarDecl::CallInit:
1399
46
      OS << " callinit";
1400
46
      break;
1401
4
    case VarDecl::ListInit:
1402
4
      OS << " listinit";
1403
4
      break;
1404
5.94k
    }
1405
5.94k
  }
1406
5.94k
  if (D->needsDestruction(D->getASTContext()))
1407
29
    OS << " destroyed";
1408
5.94k
  if (D->isParameterPack())
1409
9
    OS << " pack";
1410
5.94k
}
1411
1412
0
void TextNodeDumper::VisitBindingDecl(const BindingDecl *D) {
1413
0
  dumpName(D);
1414
0
  dumpType(D->getType());
1415
0
}
1416
1417
631
void TextNodeDumper::VisitCapturedDecl(const CapturedDecl *D) {
1418
631
  if (D->isNothrow())
1419
585
    OS << " nothrow";
1420
631
}
1421
1422
0
void TextNodeDumper::VisitImportDecl(const ImportDecl *D) {
1423
0
  OS << ' ' << D->getImportedModule()->getFullModuleName();
1424
0
1425
0
  for (Decl *InitD :
1426
0
       D->getASTContext().getModuleInitializers(D->getImportedModule()))
1427
0
    dumpDeclRef(InitD, "initializer");
1428
0
}
1429
1430
0
void TextNodeDumper::VisitPragmaCommentDecl(const PragmaCommentDecl *D) {
1431
0
  OS << ' ';
1432
0
  switch (D->getCommentKind()) {
1433
0
  case PCK_Unknown:
1434
0
    llvm_unreachable("unexpected pragma comment kind");
1435
0
  case PCK_Compiler:
1436
0
    OS << "compiler";
1437
0
    break;
1438
0
  case PCK_ExeStr:
1439
0
    OS << "exestr";
1440
0
    break;
1441
0
  case PCK_Lib:
1442
0
    OS << "lib";
1443
0
    break;
1444
0
  case PCK_Linker:
1445
0
    OS << "linker";
1446
0
    break;
1447
0
  case PCK_User:
1448
0
    OS << "user";
1449
0
    break;
1450
0
  }
1451
0
  StringRef Arg = D->getArg();
1452
0
  if (!Arg.empty())
1453
0
    OS << " \"" << Arg << "\"";
1454
0
}
1455
1456
void TextNodeDumper::VisitPragmaDetectMismatchDecl(
1457
0
    const PragmaDetectMismatchDecl *D) {
1458
0
  OS << " \"" << D->getName() << "\" \"" << D->getValue() << "\"";
1459
0
}
1460
1461
void TextNodeDumper::VisitOMPExecutableDirective(
1462
187
    const OMPExecutableDirective *D) {
1463
187
  if (D->isStandaloneDirective())
1464
10
    OS << " openmp_standalone_directive";
1465
187
}
1466
1467
void TextNodeDumper::VisitOMPDeclareReductionDecl(
1468
6
    const OMPDeclareReductionDecl *D) {
1469
6
  dumpName(D);
1470
6
  dumpType(D->getType());
1471
6
  OS << " combiner";
1472
6
  dumpPointer(D->getCombiner());
1473
6
  if (const auto *Initializer = D->getInitializer()) {
1474
2
    OS << " initializer";
1475
2
    dumpPointer(Initializer);
1476
2
    switch (D->getInitializerKind()) {
1477
0
    case OMPDeclareReductionDecl::DirectInit:
1478
0
      OS << " omp_priv = ";
1479
0
      break;
1480
2
    case OMPDeclareReductionDecl::CopyInit:
1481
2
      OS << " omp_priv ()";
1482
2
      break;
1483
0
    case OMPDeclareReductionDecl::CallInit:
1484
0
      break;
1485
2
    }
1486
2
  }
1487
6
}
1488
1489
0
void TextNodeDumper::VisitOMPRequiresDecl(const OMPRequiresDecl *D) {
1490
0
  for (const auto *C : D->clauselists()) {
1491
0
    AddChild([=] {
1492
0
      if (!C) {
1493
0
        ColorScope Color(OS, ShowColors, NullColor);
1494
0
        OS << "<<<NULL>>> OMPClause";
1495
0
        return;
1496
0
      }
1497
0
      {
1498
0
        ColorScope Color(OS, ShowColors, AttrColor);
1499
0
        StringRef ClauseName(getOpenMPClauseName(C->getClauseKind()));
1500
0
        OS << "OMP" << ClauseName.substr(/*Start=*/0, /*N=*/1).upper()
1501
0
           << ClauseName.drop_front() << "Clause";
1502
0
      }
1503
0
      dumpPointer(C);
1504
0
      dumpSourceRange(SourceRange(C->getBeginLoc(), C->getEndLoc()));
1505
0
    });
1506
0
  }
1507
0
}
1508
1509
96
void TextNodeDumper::VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D) {
1510
96
  dumpName(D);
1511
96
  dumpType(D->getType());
1512
96
}
1513
1514
118
void TextNodeDumper::VisitNamespaceDecl(const NamespaceDecl *D) {
1515
118
  dumpName(D);
1516
118
  if (D->isInline())
1517
3
    OS << " inline";
1518
118
  if (!D->isOriginalNamespace())
1519
3
    dumpDeclRef(D->getOriginalNamespace(), "original");
1520
118
}
1521
1522
15
void TextNodeDumper::VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
1523
15
  OS << ' ';
1524
15
  dumpBareDeclRef(D->getNominatedNamespace());
1525
15
}
1526
1527
4
void TextNodeDumper::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
1528
4
  dumpName(D);
1529
4
  dumpDeclRef(D->getAliasedNamespace());
1530
4
}
1531
1532
46
void TextNodeDumper::VisitTypeAliasDecl(const TypeAliasDecl *D) {
1533
46
  dumpName(D);
1534
46
  dumpType(D->getUnderlyingType());
1535
46
}
1536
1537
void TextNodeDumper::VisitTypeAliasTemplateDecl(
1538
5
    const TypeAliasTemplateDecl *D) {
1539
5
  dumpName(D);
1540
5
}
1541
1542
1.59k
void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
1543
1.59k
  VisitRecordDecl(D);
1544
1.59k
  if (!D->isCompleteDefinition())
1545
738
    return;
1546
853
1547
853
  AddChild([=] {
1548
853
    {
1549
853
      ColorScope Color(OS, ShowColors, DeclKindNameColor);
1550
853
      OS << "DefinitionData";
1551
853
    }
1552
853
#define FLAG(fn, name)                                                         \
1553
56.2k
  
if (2.49k
D->fn()) \
1554
25.4k
    OS << " " #name;
1555
853
    FLAG(isParsingBaseSpecifiers, parsing_base_specifiers);
1556
853
1557
853
    FLAG(isGenericLambda, generic);
1558
853
    FLAG(isLambda, lambda);
1559
853
1560
853
    FLAG(isAnonymousStructOrUnion, is_anonymous);
1561
853
    FLAG(canPassInRegisters, pass_in_registers);
1562
853
    FLAG(isEmpty, empty);
1563
853
    FLAG(isAggregate, aggregate);
1564
853
    FLAG(isStandardLayout, standard_layout);
1565
853
    FLAG(isTriviallyCopyable, trivially_copyable);
1566
853
    FLAG(isPOD, pod);
1567
853
    FLAG(isTrivial, trivial);
1568
853
    FLAG(isPolymorphic, polymorphic);
1569
853
    FLAG(isAbstract, abstract);
1570
853
    FLAG(isLiteral, literal);
1571
853
1572
853
    FLAG(hasUserDeclaredConstructor, has_user_declared_ctor);
1573
853
    FLAG(hasConstexprNonCopyMoveConstructor, has_constexpr_non_copy_move_ctor);
1574
853
    FLAG(hasMutableFields, has_mutable_fields);
1575
853
    FLAG(hasVariantMembers, has_variant_members);
1576
853
    FLAG(allowConstDefaultInit, can_const_default_init);
1577
853
1578
853
    AddChild([=] {
1579
853
      {
1580
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1581
853
        OS << "DefaultConstructor";
1582
853
      }
1583
853
      FLAG(hasDefaultConstructor, exists);
1584
853
      FLAG(hasTrivialDefaultConstructor, trivial);
1585
853
      FLAG(hasNonTrivialDefaultConstructor, non_trivial);
1586
853
      FLAG(hasUserProvidedDefaultConstructor, user_provided);
1587
853
      FLAG(hasConstexprDefaultConstructor, constexpr);
1588
853
      FLAG(needsImplicitDefaultConstructor, needs_implicit);
1589
853
      FLAG(defaultedDefaultConstructorIsConstexpr, defaulted_is_constexpr);
1590
853
    });
1591
853
1592
853
    AddChild([=] {
1593
853
      {
1594
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1595
853
        OS << "CopyConstructor";
1596
853
      }
1597
853
      FLAG(hasSimpleCopyConstructor, simple);
1598
853
      FLAG(hasTrivialCopyConstructor, trivial);
1599
853
      FLAG(hasNonTrivialCopyConstructor, non_trivial);
1600
853
      FLAG(hasUserDeclaredCopyConstructor, user_declared);
1601
853
      FLAG(hasCopyConstructorWithConstParam, has_const_param);
1602
853
      FLAG(needsImplicitCopyConstructor, needs_implicit);
1603
853
      FLAG(needsOverloadResolutionForCopyConstructor,
1604
853
           needs_overload_resolution);
1605
853
      if (!D->needsOverloadResolutionForCopyConstructor())
1606
853
        
FLAG823
(defaultedCopyConstructorIsDeleted, defaulted_is_deleted);
1607
853
      FLAG(implicitCopyConstructorHasConstParam, implicit_has_const_param);
1608
853
    });
1609
853
1610
853
    AddChild([=] {
1611
853
      {
1612
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1613
853
        OS << "MoveConstructor";
1614
853
      }
1615
853
      FLAG(hasMoveConstructor, exists);
1616
853
      FLAG(hasSimpleMoveConstructor, simple);
1617
853
      FLAG(hasTrivialMoveConstructor, trivial);
1618
853
      FLAG(hasNonTrivialMoveConstructor, non_trivial);
1619
853
      FLAG(hasUserDeclaredMoveConstructor, user_declared);
1620
853
      FLAG(needsImplicitMoveConstructor, needs_implicit);
1621
853
      FLAG(needsOverloadResolutionForMoveConstructor,
1622
853
           needs_overload_resolution);
1623
853
      if (!D->needsOverloadResolutionForMoveConstructor())
1624
853
        
FLAG834
(defaultedMoveConstructorIsDeleted, defaulted_is_deleted);
1625
853
    });
1626
853
1627
853
    AddChild([=] {
1628
853
      {
1629
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1630
853
        OS << "CopyAssignment";
1631
853
      }
1632
853
      FLAG(hasTrivialCopyAssignment, trivial);
1633
853
      FLAG(hasNonTrivialCopyAssignment, non_trivial);
1634
853
      FLAG(hasCopyAssignmentWithConstParam, has_const_param);
1635
853
      FLAG(hasUserDeclaredCopyAssignment, user_declared);
1636
853
      FLAG(needsImplicitCopyAssignment, needs_implicit);
1637
853
      FLAG(needsOverloadResolutionForCopyAssignment, needs_overload_resolution);
1638
853
      FLAG(implicitCopyAssignmentHasConstParam, implicit_has_const_param);
1639
853
    });
1640
853
1641
853
    AddChild([=] {
1642
853
      {
1643
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1644
853
        OS << "MoveAssignment";
1645
853
      }
1646
853
      FLAG(hasMoveAssignment, exists);
1647
853
      FLAG(hasSimpleMoveAssignment, simple);
1648
853
      FLAG(hasTrivialMoveAssignment, trivial);
1649
853
      FLAG(hasNonTrivialMoveAssignment, non_trivial);
1650
853
      FLAG(hasUserDeclaredMoveAssignment, user_declared);
1651
853
      FLAG(needsImplicitMoveAssignment, needs_implicit);
1652
853
      FLAG(needsOverloadResolutionForMoveAssignment, needs_overload_resolution);
1653
853
    });
1654
853
1655
853
    AddChild([=] {
1656
853
      {
1657
853
        ColorScope Color(OS, ShowColors, DeclKindNameColor);
1658
853
        OS << "Destructor";
1659
853
      }
1660
853
      FLAG(hasSimpleDestructor, simple);
1661
853
      FLAG(hasIrrelevantDestructor, irrelevant);
1662
853
      FLAG(hasTrivialDestructor, trivial);
1663
853
      FLAG(hasNonTrivialDestructor, non_trivial);
1664
853
      FLAG(hasUserDeclaredDestructor, user_declared);
1665
853
      FLAG(hasConstexprDestructor, constexpr);
1666
853
      FLAG(needsImplicitDestructor, needs_implicit);
1667
853
      FLAG(needsOverloadResolutionForDestructor, needs_overload_resolution);
1668
853
      if (!D->needsOverloadResolutionForDestructor())
1669
853
        
FLAG837
(defaultedDestructorIsDeleted, defaulted_is_deleted);
1670
853
    });
1671
853
  });
1672
853
1673
853
  for (const auto &I : D->bases()) {
1674
78
    AddChild([=] {
1675
78
      if (I.isVirtual())
1676
23
        OS << "virtual ";
1677
78
      dumpAccessSpecifier(I.getAccessSpecifier());
1678
78
      dumpType(I.getType());
1679
78
      if (I.isPackExpansion())
1680
2
        OS << "...";
1681
78
    });
1682
78
  }
1683
853
}
1684
1685
114
void TextNodeDumper::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
1686
114
  dumpName(D);
1687
114
}
1688
1689
137
void TextNodeDumper::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
1690
137
  dumpName(D);
1691
137
}
1692
1693
4
void TextNodeDumper::VisitVarTemplateDecl(const VarTemplateDecl *D) {
1694
4
  dumpName(D);
1695
4
}
1696
1697
4
void TextNodeDumper::VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D) {
1698
4
  dumpName(D);
1699
4
}
1700
1701
264
void TextNodeDumper::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
1702
264
  if (const auto *TC = D->getTypeConstraint()) {
1703
0
    OS << " ";
1704
0
    dumpBareDeclRef(TC->getNamedConcept());
1705
0
    if (TC->getNamedConcept() != TC->getFoundDecl()) {
1706
0
      OS << " (";
1707
0
      dumpBareDeclRef(TC->getFoundDecl());
1708
0
      OS << ")";
1709
0
    }
1710
0
    Visit(TC->getImmediatelyDeclaredConstraint());
1711
264
  } else if (D->wasDeclaredWithTypename())
1712
212
    OS << " typename";
1713
52
  else
1714
52
    OS << " class";
1715
264
  OS << " depth " << D->getDepth() << " index " << D->getIndex();
1716
264
  if (D->isParameterPack())
1717
23
    OS << " ...";
1718
264
  dumpName(D);
1719
264
}
1720
1721
void TextNodeDumper::VisitNonTypeTemplateParmDecl(
1722
65
    const NonTypeTemplateParmDecl *D) {
1723
65
  dumpType(D->getType());
1724
65
  OS << " depth " << D->getDepth() << " index " << D->getIndex();
1725
65
  if (D->isParameterPack())
1726
9
    OS << " ...";
1727
65
  dumpName(D);
1728
65
}
1729
1730
void TextNodeDumper::VisitTemplateTemplateParmDecl(
1731
13
    const TemplateTemplateParmDecl *D) {
1732
13
  OS << " depth " << D->getDepth() << " index " << D->getIndex();
1733
13
  if (D->isParameterPack())
1734
5
    OS << " ...";
1735
13
  dumpName(D);
1736
13
}
1737
1738
18
void TextNodeDumper::VisitUsingDecl(const UsingDecl *D) {
1739
18
  OS << ' ';
1740
18
  if (D->getQualifier())
1741
18
    D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
1742
18
  OS << D->getNameAsString();
1743
18
}
1744
1745
void TextNodeDumper::VisitUnresolvedUsingTypenameDecl(
1746
1
    const UnresolvedUsingTypenameDecl *D) {
1747
1
  OS << ' ';
1748
1
  if (D->getQualifier())
1749
1
    D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
1750
1
  OS << D->getNameAsString();
1751
1
}
1752
1753
void TextNodeDumper::VisitUnresolvedUsingValueDecl(
1754
1
    const UnresolvedUsingValueDecl *D) {
1755
1
  OS << ' ';
1756
1
  if (D->getQualifier())
1757
1
    D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
1758
1
  OS << D->getNameAsString();
1759
1
  dumpType(D->getType());
1760
1
}
1761
1762
12
void TextNodeDumper::VisitUsingShadowDecl(const UsingShadowDecl *D) {
1763
12
  OS << ' ';
1764
12
  dumpBareDeclRef(D->getTargetDecl());
1765
12
}
1766
1767
void TextNodeDumper::VisitConstructorUsingShadowDecl(
1768
12
    const ConstructorUsingShadowDecl *D) {
1769
12
  if (D->constructsVirtualBase())
1770
0
    OS << " virtual";
1771
12
1772
12
  AddChild([=] {
1773
12
    OS << "target ";
1774
12
    dumpBareDeclRef(D->getTargetDecl());
1775
12
  });
1776
12
1777
12
  AddChild([=] {
1778
12
    OS << "nominated ";
1779
12
    dumpBareDeclRef(D->getNominatedBaseClass());
1780
12
    OS << ' ';
1781
12
    dumpBareDeclRef(D->getNominatedBaseClassShadowDecl());
1782
12
  });
1783
12
1784
12
  AddChild([=] {
1785
12
    OS << "constructed ";
1786
12
    dumpBareDeclRef(D->getConstructedBaseClass());
1787
12
    OS << ' ';
1788
12
    dumpBareDeclRef(D->getConstructedBaseClassShadowDecl());
1789
12
  });
1790
12
}
1791
1792
27
void TextNodeDumper::VisitLinkageSpecDecl(const LinkageSpecDecl *D) {
1793
27
  switch (D->getLanguage()) {
1794
26
  case LinkageSpecDecl::lang_c:
1795
26
    OS << " C";
1796
26
    break;
1797
1
  case LinkageSpecDecl::lang_cxx:
1798
1
    OS << " C++";
1799
1
    break;
1800
27
  }
1801
27
}
1802
1803
68
void TextNodeDumper::VisitAccessSpecDecl(const AccessSpecDecl *D) {
1804
68
  OS << ' ';
1805
68
  dumpAccessSpecifier(D->getAccess());
1806
68
}
1807
1808
10
void TextNodeDumper::VisitFriendDecl(const FriendDecl *D) {
1809
10
  if (TypeSourceInfo *T = D->getFriendType())
1810
4
    dumpType(T->getType());
1811
10
}
1812
1813
33
void TextNodeDumper::VisitObjCIvarDecl(const ObjCIvarDecl *D) {
1814
33
  dumpName(D);
1815
33
  dumpType(D->getType());
1816
33
  if (D->getSynthesize())
1817
8
    OS << " synthesize";
1818
33
1819
33
  switch (D->getAccessControl()) {
1820
0
  case ObjCIvarDecl::None:
1821
0
    OS << " none";
1822
0
    break;
1823
14
  case ObjCIvarDecl::Private:
1824
14
    OS << " private";
1825
14
    break;
1826
17
  case ObjCIvarDecl::Protected:
1827
17
    OS << " protected";
1828
17
    break;
1829
1
  case ObjCIvarDecl::Public:
1830
1
    OS << " public";
1831
1
    break;
1832
1
  case ObjCIvarDecl::Package:
1833
1
    OS << " package";
1834
1
    break;
1835
33
  }
1836
33
}
1837
1838
131
void TextNodeDumper::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
1839
131
  if (D->isInstanceMethod())
1840
107
    OS << " -";
1841
24
  else
1842
24
    OS << " +";
1843
131
  dumpName(D);
1844
131
  dumpType(D->getReturnType());
1845
131
1846
131
  if (D->isVariadic())
1847
3
    OS << " variadic";
1848
131
}
1849
1850
3
void TextNodeDumper::VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D) {
1851
3
  dumpName(D);
1852
3
  switch (D->getVariance()) {
1853
3
  case ObjCTypeParamVariance::Invariant:
1854
3
    break;
1855
0
1856
0
  case ObjCTypeParamVariance::Covariant:
1857
0
    OS << " covariant";
1858
0
    break;
1859
0
1860
0
  case ObjCTypeParamVariance::Contravariant:
1861
0
    OS << " contravariant";
1862
0
    break;
1863
3
  }
1864
3
1865
3
  if (D->hasExplicitBound())
1866
1
    OS << " bounded";
1867
3
  dumpType(D->getUnderlyingType());
1868
3
}
1869
1870
16
void TextNodeDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
1871
16
  dumpName(D);
1872
16
  dumpDeclRef(D->getClassInterface());
1873
16
  dumpDeclRef(D->getImplementation());
1874
16
  for (const auto *P : D->protocols())
1875
1
    dumpDeclRef(P);
1876
16
}
1877
1878
3
void TextNodeDumper::VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
1879
3
  dumpName(D);
1880
3
  dumpDeclRef(D->getClassInterface());
1881
3
  dumpDeclRef(D->getCategoryDecl());
1882
3
}
1883
1884
17
void TextNodeDumper::VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
1885
17
  dumpName(D);
1886
17
1887
17
  for (const auto *Child : D->protocols())
1888
0
    dumpDeclRef(Child);
1889
17
}
1890
1891
70
void TextNodeDumper::VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
1892
70
  dumpName(D);
1893
70
  dumpDeclRef(D->getSuperClass(), "super");
1894
70
1895
70
  dumpDeclRef(D->getImplementation());
1896
70
  for (const auto *Child : D->protocols())
1897
3
    dumpDeclRef(Child);
1898
70
}
1899
1900
void TextNodeDumper::VisitObjCImplementationDecl(
1901
16
    const ObjCImplementationDecl *D) {
1902
16
  dumpName(D);
1903
16
  dumpDeclRef(D->getSuperClass(), "super");
1904
16
  dumpDeclRef(D->getClassInterface());
1905
16
}
1906
1907
void TextNodeDumper::VisitObjCCompatibleAliasDecl(
1908
2
    const ObjCCompatibleAliasDecl *D) {
1909
2
  dumpName(D);
1910
2
  dumpDeclRef(D->getClassInterface());
1911
2
}
1912
1913
31
void TextNodeDumper::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
1914
31
  dumpName(D);
1915
31
  dumpType(D->getType());
1916
31
1917
31
  if (D->getPropertyImplementation() == ObjCPropertyDecl::Required)
1918
0
    OS << " required";
1919
31
  else if (D->getPropertyImplementation() == ObjCPropertyDecl::Optional)
1920
0
    OS << " optional";
1921
31
1922
31
  ObjCPropertyDecl::PropertyAttributeKind Attrs = D->getPropertyAttributes();
1923
31
  if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
1924
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_readonly)
1925
8
      OS << " readonly";
1926
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_assign)
1927
21
      OS << " assign";
1928
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_readwrite)
1929
23
      OS << " readwrite";
1930
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_retain)
1931
1
      OS << " retain";
1932
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_copy)
1933
1
      OS << " copy";
1934
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_nonatomic)
1935
3
      OS << " nonatomic";
1936
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_atomic)
1937
24
      OS << " atomic";
1938
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_weak)
1939
0
      OS << " weak";
1940
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_strong)
1941
0
      OS << " strong";
1942
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained)
1943
20
      OS << " unsafe_unretained";
1944
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_class)
1945
1
      OS << " class";
1946
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_direct)
1947
0
      OS << " direct";
1948
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_getter)
1949
6
      dumpDeclRef(D->getGetterMethodDecl(), "getter");
1950
31
    if (Attrs & ObjCPropertyDecl::OBJC_PR_setter)
1951
6
      dumpDeclRef(D->getSetterMethodDecl(), "setter");
1952
31
  }
1953
31
}
1954
1955
14
void TextNodeDumper::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
1956
14
  dumpName(D->getPropertyDecl());
1957
14
  if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize)
1958
13
    OS << " synthesize";
1959
1
  else
1960
1
    OS << " dynamic";
1961
14
  dumpDeclRef(D->getPropertyDecl());
1962
14
  dumpDeclRef(D->getPropertyIvarDecl());
1963
14
}
1964
1965
15
void TextNodeDumper::VisitBlockDecl(const BlockDecl *D) {
1966
15
  if (D->isVariadic())
1967
1
    OS << " variadic";
1968
15
1969
15
  if (D->capturesCXXThis())
1970
1
    OS << " captures_this";
1971
15
}
1972
1973
0
void TextNodeDumper::VisitConceptDecl(const ConceptDecl *D) {
1974
0
  dumpName(D);
1975
0
}