Coverage Report

Created: 2021-06-15 06:44

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/JSONNodeDumper.h
Line
Count
Source (jump to first uncovered line)
1
//===--- JSONNodeDumper.h - Printing of AST nodes to JSON -----------------===//
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 AST dumping of components of individual AST nodes to
11
// a JSON.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_AST_JSONNODEDUMPER_H
16
#define LLVM_CLANG_AST_JSONNODEDUMPER_H
17
18
#include "clang/AST/ASTContext.h"
19
#include "clang/AST/ASTDumperUtils.h"
20
#include "clang/AST/ASTNodeTraverser.h"
21
#include "clang/AST/AttrVisitor.h"
22
#include "clang/AST/CommentCommandTraits.h"
23
#include "clang/AST/CommentVisitor.h"
24
#include "clang/AST/ExprCXX.h"
25
#include "clang/AST/Mangle.h"
26
#include "clang/AST/Type.h"
27
#include "llvm/Support/JSON.h"
28
29
namespace clang {
30
31
class APValue;
32
33
class NodeStreamer {
34
  bool FirstChild = true;
35
  bool TopLevel = true;
36
  llvm::SmallVector<std::function<void(bool IsLastChild)>, 32> Pending;
37
38
protected:
39
  llvm::json::OStream JOS;
40
41
public:
42
  /// Add a child of the current node.  Calls DoAddChild without arguments
43
1.95k
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
1.95k
    return AddChild("", DoAddChild);
45
1.95k
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
1.45k
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
1.45k
    return AddChild("", DoAddChild);
45
1.45k
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::BlockDecl::Capture const&)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
3
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
3
    return AddChild("", DoAddChild);
45
3
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::OMPClause const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
2
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
2
    return AddChild("", DoAddChild);
45
2
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::TemplateArgument const&, clang::SourceRange, clang::Decl const*, char const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
8
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
8
    return AddChild("", DoAddChild);
45
8
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Type const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
378
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
378
    return AddChild("", DoAddChild);
45
378
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::QualType)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
1
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
1
    return AddChild("", DoAddChild);
45
1
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::GenericSelectionExpr::AssociationTy<true> const&)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
12
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
12
    return AddChild("", DoAddChild);
45
12
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::CXXCtorInitializer const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
3
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
3
    return AddChild("", DoAddChild);
45
3
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(clang::ClassTemplateSpecializationDecl)
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(clang::ClassTemplateSpecializationDecl)
Line
Count
Source
43
1
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
1
    return AddChild("", DoAddChild);
45
1
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda'()>(clang::FunctionDecl)
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda0'()>(clang::FunctionDecl)
Line
Count
Source
43
1
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
1
    return AddChild("", DoAddChild);
45
1
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(clang::VarTemplateSpecializationDecl)
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(clang::VarTemplateSpecializationDecl)
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Attr const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
30
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
30
    return AddChild("", DoAddChild);
45
30
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::comments::Comment const*, clang::comments::FullComment const*)::'lambda'()>(clang::JSONDumper)
Line
Count
Source
43
64
  template <typename Fn> void AddChild(Fn DoAddChild) {
44
64
    return AddChild("", DoAddChild);
45
64
  }
46
47
  /// Add a child of the current node with an optional label.
48
  /// Calls DoAddChild without arguments.
49
4.18k
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
4.18k
    if (TopLevel) {
53
153
      TopLevel = false;
54
153
      JOS.objectBegin();
55
56
153
      DoAddChild();
57
58
268
      while (!Pending.empty()) {
59
115
        Pending.back()(true);
60
115
        Pending.pop_back();
61
115
      }
62
63
153
      JOS.objectEnd();
64
153
      TopLevel = true;
65
153
      return;
66
153
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
4.03k
    std::string LabelStr(!Label.empty() ? 
Label1
:
"inner"4.03k
);
71
4.03k
    bool WasFirstChild = FirstChild;
72
4.03k
    auto DumpWithIndent = [=](bool IsLastChild) {
73
4.03k
      if (WasFirstChild) {
74
2.37k
        JOS.attributeBegin(LabelStr);
75
2.37k
        JOS.arrayBegin();
76
2.37k
      }
77
78
4.03k
      FirstChild = true;
79
4.03k
      unsigned Depth = Pending.size();
80
4.03k
      JOS.objectBegin();
81
82
4.03k
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
6.28k
      while (Depth < Pending.size()) {
87
2.25k
        Pending.back()(true);
88
2.25k
        this->Pending.pop_back();
89
2.25k
      }
90
91
4.03k
      JOS.objectEnd();
92
93
4.03k
      if (IsLastChild) {
94
2.37k
        JOS.arrayEnd();
95
2.37k
        JOS.attributeEnd();
96
2.37k
      }
97
4.03k
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::BlockDecl::Capture const&)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
3
    auto DumpWithIndent = [=](bool IsLastChild) {
73
3
      if (WasFirstChild) {
74
2
        JOS.attributeBegin(LabelStr);
75
2
        JOS.arrayBegin();
76
2
      }
77
78
3
      FirstChild = true;
79
3
      unsigned Depth = Pending.size();
80
3
      JOS.objectBegin();
81
82
3
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
3
      while (Depth < Pending.size()) {
87
0
        Pending.back()(true);
88
0
        this->Pending.pop_back();
89
0
      }
90
91
3
      JOS.objectEnd();
92
93
3
      if (IsLastChild) {
94
0
        JOS.arrayEnd();
95
0
        JOS.attributeEnd();
96
0
      }
97
3
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::OMPClause const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
2
    auto DumpWithIndent = [=](bool IsLastChild) {
73
2
      if (WasFirstChild) {
74
2
        JOS.attributeBegin(LabelStr);
75
2
        JOS.arrayBegin();
76
2
      }
77
78
2
      FirstChild = true;
79
2
      unsigned Depth = Pending.size();
80
2
      JOS.objectBegin();
81
82
2
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
4
      while (Depth < Pending.size()) {
87
2
        Pending.back()(true);
88
2
        this->Pending.pop_back();
89
2
      }
90
91
2
      JOS.objectEnd();
92
93
2
      if (IsLastChild) {
94
0
        JOS.arrayEnd();
95
0
        JOS.attributeEnd();
96
0
      }
97
2
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Type const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
378
    auto DumpWithIndent = [=](bool IsLastChild) {
73
378
      if (WasFirstChild) {
74
367
        JOS.attributeBegin(LabelStr);
75
367
        JOS.arrayBegin();
76
367
      }
77
78
378
      FirstChild = true;
79
378
      unsigned Depth = Pending.size();
80
378
      JOS.objectBegin();
81
82
378
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
486
      while (Depth < Pending.size()) {
87
108
        Pending.back()(true);
88
108
        this->Pending.pop_back();
89
108
      }
90
91
378
      JOS.objectEnd();
92
93
378
      if (IsLastChild) {
94
359
        JOS.arrayEnd();
95
359
        JOS.attributeEnd();
96
359
      }
97
378
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::QualType)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
1
        JOS.attributeBegin(LabelStr);
75
1
        JOS.arrayBegin();
76
1
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
2
      while (Depth < Pending.size()) {
87
1
        Pending.back()(true);
88
1
        this->Pending.pop_back();
89
1
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::TemplateArgument const&, clang::SourceRange, clang::Decl const*, char const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
8
    auto DumpWithIndent = [=](bool IsLastChild) {
73
8
      if (WasFirstChild) {
74
5
        JOS.attributeBegin(LabelStr);
75
5
        JOS.arrayBegin();
76
5
      }
77
78
8
      FirstChild = true;
79
8
      unsigned Depth = Pending.size();
80
8
      JOS.objectBegin();
81
82
8
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
15
      while (Depth < Pending.size()) {
87
7
        Pending.back()(true);
88
7
        this->Pending.pop_back();
89
7
      }
90
91
8
      JOS.objectEnd();
92
93
8
      if (IsLastChild) {
94
3
        JOS.arrayEnd();
95
3
        JOS.attributeEnd();
96
3
      }
97
8
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::GenericSelectionExpr::AssociationTy<true> const&)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
12
    auto DumpWithIndent = [=](bool IsLastChild) {
73
12
      if (WasFirstChild) {
74
0
        JOS.attributeBegin(LabelStr);
75
0
        JOS.arrayBegin();
76
0
      }
77
78
12
      FirstChild = true;
79
12
      unsigned Depth = Pending.size();
80
12
      JOS.objectBegin();
81
82
12
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
24
      while (Depth < Pending.size()) {
87
12
        Pending.back()(true);
88
12
        this->Pending.pop_back();
89
12
      }
90
91
12
      JOS.objectEnd();
92
93
12
      if (IsLastChild) {
94
7
        JOS.arrayEnd();
95
7
        JOS.attributeEnd();
96
7
      }
97
12
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Stmt const*, llvm::StringRef)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
2.22k
    auto DumpWithIndent = [=](bool IsLastChild) {
73
2.22k
      if (WasFirstChild) {
74
1.45k
        JOS.attributeBegin(LabelStr);
75
1.45k
        JOS.arrayBegin();
76
1.45k
      }
77
78
2.22k
      FirstChild = true;
79
2.22k
      unsigned Depth = Pending.size();
80
2.22k
      JOS.objectBegin();
81
82
2.22k
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
3.60k
      while (Depth < Pending.size()) {
87
1.37k
        Pending.back()(true);
88
1.37k
        this->Pending.pop_back();
89
1.37k
      }
90
91
2.22k
      JOS.objectEnd();
92
93
2.22k
      if (IsLastChild) {
94
1.56k
        JOS.arrayEnd();
95
1.56k
        JOS.attributeEnd();
96
1.56k
      }
97
2.22k
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::CXXCtorInitializer const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
3
    auto DumpWithIndent = [=](bool IsLastChild) {
73
3
      if (WasFirstChild) {
74
0
        JOS.attributeBegin(LabelStr);
75
0
        JOS.arrayBegin();
76
0
      }
77
78
3
      FirstChild = true;
79
3
      unsigned Depth = Pending.size();
80
3
      JOS.objectBegin();
81
82
3
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
6
      while (Depth < Pending.size()) {
87
3
        Pending.back()(true);
88
3
        this->Pending.pop_back();
89
3
      }
90
91
3
      JOS.objectEnd();
92
93
3
      if (IsLastChild) {
94
0
        JOS.arrayEnd();
95
0
        JOS.attributeEnd();
96
0
      }
97
3
    };
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::ClassTemplateSpecializationDecl)::'lambda'(bool)::operator()(bool) const
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::ClassTemplateSpecializationDecl)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
0
        JOS.attributeBegin(LabelStr);
75
0
        JOS.arrayBegin();
76
0
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1
      while (Depth < Pending.size()) {
87
0
        Pending.back()(true);
88
0
        this->Pending.pop_back();
89
0
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::FunctionDecl)::'lambda'(bool)::operator()(bool) const
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::FunctionDecl)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
0
        JOS.attributeBegin(LabelStr);
75
0
        JOS.arrayBegin();
76
0
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1
      while (Depth < Pending.size()) {
87
0
        Pending.back()(true);
88
0
        this->Pending.pop_back();
89
0
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::VarTemplateSpecializationDecl)::'lambda'(bool)::operator()(bool) const
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::VarTemplateSpecializationDecl)::'lambda'(bool)::operator()(bool) const
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Attr const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
30
    auto DumpWithIndent = [=](bool IsLastChild) {
73
30
      if (WasFirstChild) {
74
4
        JOS.attributeBegin(LabelStr);
75
4
        JOS.arrayBegin();
76
4
      }
77
78
30
      FirstChild = true;
79
30
      unsigned Depth = Pending.size();
80
30
      JOS.objectBegin();
81
82
30
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
30
      while (Depth < Pending.size()) {
87
0
        Pending.back()(true);
88
0
        this->Pending.pop_back();
89
0
      }
90
91
30
      JOS.objectEnd();
92
93
30
      if (IsLastChild) {
94
16
        JOS.arrayEnd();
95
16
        JOS.attributeEnd();
96
16
      }
97
30
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::comments::Comment const*, clang::comments::FullComment const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
64
    auto DumpWithIndent = [=](bool IsLastChild) {
73
64
      if (WasFirstChild) {
74
45
        JOS.attributeBegin(LabelStr);
75
45
        JOS.arrayBegin();
76
45
      }
77
78
64
      FirstChild = true;
79
64
      unsigned Depth = Pending.size();
80
64
      JOS.objectBegin();
81
82
64
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
101
      while (Depth < Pending.size()) {
87
37
        Pending.back()(true);
88
37
        this->Pending.pop_back();
89
37
      }
90
91
64
      JOS.objectEnd();
92
93
64
      if (IsLastChild) {
94
49
        JOS.arrayEnd();
95
49
        JOS.attributeEnd();
96
49
      }
97
64
    };
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)::'lambda'(bool)::operator()(bool) const
Line
Count
Source
72
1.30k
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1.30k
      if (WasFirstChild) {
74
485
        JOS.attributeBegin(LabelStr);
75
485
        JOS.arrayBegin();
76
485
      }
77
78
1.30k
      FirstChild = true;
79
1.30k
      unsigned Depth = Pending.size();
80
1.30k
      JOS.objectBegin();
81
82
1.30k
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
2.01k
      while (Depth < Pending.size()) {
87
714
        Pending.back()(true);
88
714
        this->Pending.pop_back();
89
714
      }
90
91
1.30k
      JOS.objectEnd();
92
93
1.30k
      if (IsLastChild) {
94
371
        JOS.arrayEnd();
95
371
        JOS.attributeEnd();
96
371
      }
97
1.30k
    };
98
99
4.03k
    if (FirstChild) {
100
2.37k
      Pending.push_back(std::move(DumpWithIndent));
101
2.37k
    } else {
102
1.66k
      Pending.back()(false);
103
1.66k
      Pending.back() = std::move(DumpWithIndent);
104
1.66k
    }
105
4.03k
    FirstChild = false;
106
4.03k
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
1.45k
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
1.45k
    if (TopLevel) {
53
153
      TopLevel = false;
54
153
      JOS.objectBegin();
55
56
153
      DoAddChild();
57
58
268
      while (!Pending.empty()) {
59
115
        Pending.back()(true);
60
115
        Pending.pop_back();
61
115
      }
62
63
153
      JOS.objectEnd();
64
153
      TopLevel = true;
65
153
      return;
66
153
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
1.30k
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
1.30k
    bool WasFirstChild = FirstChild;
72
1.30k
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1.30k
      if (WasFirstChild) {
74
1.30k
        JOS.attributeBegin(LabelStr);
75
1.30k
        JOS.arrayBegin();
76
1.30k
      }
77
78
1.30k
      FirstChild = true;
79
1.30k
      unsigned Depth = Pending.size();
80
1.30k
      JOS.objectBegin();
81
82
1.30k
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1.30k
      while (Depth < Pending.size()) {
87
1.30k
        Pending.back()(true);
88
1.30k
        this->Pending.pop_back();
89
1.30k
      }
90
91
1.30k
      JOS.objectEnd();
92
93
1.30k
      if (IsLastChild) {
94
1.30k
        JOS.arrayEnd();
95
1.30k
        JOS.attributeEnd();
96
1.30k
      }
97
1.30k
    };
98
99
1.30k
    if (FirstChild) {
100
485
      Pending.push_back(std::move(DumpWithIndent));
101
817
    } else {
102
817
      Pending.back()(false);
103
817
      Pending.back() = std::move(DumpWithIndent);
104
817
    }
105
1.30k
    FirstChild = false;
106
1.30k
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::BlockDecl::Capture const&)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
3
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
3
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
3
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
3
    bool WasFirstChild = FirstChild;
72
3
    auto DumpWithIndent = [=](bool IsLastChild) {
73
3
      if (WasFirstChild) {
74
3
        JOS.attributeBegin(LabelStr);
75
3
        JOS.arrayBegin();
76
3
      }
77
78
3
      FirstChild = true;
79
3
      unsigned Depth = Pending.size();
80
3
      JOS.objectBegin();
81
82
3
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
3
      while (Depth < Pending.size()) {
87
3
        Pending.back()(true);
88
3
        this->Pending.pop_back();
89
3
      }
90
91
3
      JOS.objectEnd();
92
93
3
      if (IsLastChild) {
94
3
        JOS.arrayEnd();
95
3
        JOS.attributeEnd();
96
3
      }
97
3
    };
98
99
3
    if (FirstChild) {
100
2
      Pending.push_back(std::move(DumpWithIndent));
101
2
    } else {
102
1
      Pending.back()(false);
103
1
      Pending.back() = std::move(DumpWithIndent);
104
1
    }
105
3
    FirstChild = false;
106
3
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Stmt const*, llvm::StringRef)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
2.22k
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
2.22k
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
2.22k
    std::string LabelStr(!Label.empty() ? 
Label1
:
"inner"2.22k
);
71
2.22k
    bool WasFirstChild = FirstChild;
72
2.22k
    auto DumpWithIndent = [=](bool IsLastChild) {
73
2.22k
      if (WasFirstChild) {
74
2.22k
        JOS.attributeBegin(LabelStr);
75
2.22k
        JOS.arrayBegin();
76
2.22k
      }
77
78
2.22k
      FirstChild = true;
79
2.22k
      unsigned Depth = Pending.size();
80
2.22k
      JOS.objectBegin();
81
82
2.22k
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
2.22k
      while (Depth < Pending.size()) {
87
2.22k
        Pending.back()(true);
88
2.22k
        this->Pending.pop_back();
89
2.22k
      }
90
91
2.22k
      JOS.objectEnd();
92
93
2.22k
      if (IsLastChild) {
94
2.22k
        JOS.arrayEnd();
95
2.22k
        JOS.attributeEnd();
96
2.22k
      }
97
2.22k
    };
98
99
2.22k
    if (FirstChild) {
100
1.45k
      Pending.push_back(std::move(DumpWithIndent));
101
1.45k
    } else {
102
770
      Pending.back()(false);
103
770
      Pending.back() = std::move(DumpWithIndent);
104
770
    }
105
2.22k
    FirstChild = false;
106
2.22k
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::OMPClause const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
2
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
2
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
2
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
2
    bool WasFirstChild = FirstChild;
72
2
    auto DumpWithIndent = [=](bool IsLastChild) {
73
2
      if (WasFirstChild) {
74
2
        JOS.attributeBegin(LabelStr);
75
2
        JOS.arrayBegin();
76
2
      }
77
78
2
      FirstChild = true;
79
2
      unsigned Depth = Pending.size();
80
2
      JOS.objectBegin();
81
82
2
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
2
      while (Depth < Pending.size()) {
87
2
        Pending.back()(true);
88
2
        this->Pending.pop_back();
89
2
      }
90
91
2
      JOS.objectEnd();
92
93
2
      if (IsLastChild) {
94
2
        JOS.arrayEnd();
95
2
        JOS.attributeEnd();
96
2
      }
97
2
    };
98
99
2
    if (FirstChild) {
100
2
      Pending.push_back(std::move(DumpWithIndent));
101
2
    } else {
102
0
      Pending.back()(false);
103
0
      Pending.back() = std::move(DumpWithIndent);
104
0
    }
105
2
    FirstChild = false;
106
2
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::TemplateArgument const&, clang::SourceRange, clang::Decl const*, char const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
8
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
8
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
8
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
8
    bool WasFirstChild = FirstChild;
72
8
    auto DumpWithIndent = [=](bool IsLastChild) {
73
8
      if (WasFirstChild) {
74
8
        JOS.attributeBegin(LabelStr);
75
8
        JOS.arrayBegin();
76
8
      }
77
78
8
      FirstChild = true;
79
8
      unsigned Depth = Pending.size();
80
8
      JOS.objectBegin();
81
82
8
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
8
      while (Depth < Pending.size()) {
87
8
        Pending.back()(true);
88
8
        this->Pending.pop_back();
89
8
      }
90
91
8
      JOS.objectEnd();
92
93
8
      if (IsLastChild) {
94
8
        JOS.arrayEnd();
95
8
        JOS.attributeEnd();
96
8
      }
97
8
    };
98
99
8
    if (FirstChild) {
100
5
      Pending.push_back(std::move(DumpWithIndent));
101
5
    } else {
102
3
      Pending.back()(false);
103
3
      Pending.back() = std::move(DumpWithIndent);
104
3
    }
105
8
    FirstChild = false;
106
8
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Type const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
378
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
378
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
378
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
378
    bool WasFirstChild = FirstChild;
72
378
    auto DumpWithIndent = [=](bool IsLastChild) {
73
378
      if (WasFirstChild) {
74
378
        JOS.attributeBegin(LabelStr);
75
378
        JOS.arrayBegin();
76
378
      }
77
78
378
      FirstChild = true;
79
378
      unsigned Depth = Pending.size();
80
378
      JOS.objectBegin();
81
82
378
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
378
      while (Depth < Pending.size()) {
87
378
        Pending.back()(true);
88
378
        this->Pending.pop_back();
89
378
      }
90
91
378
      JOS.objectEnd();
92
93
378
      if (IsLastChild) {
94
378
        JOS.arrayEnd();
95
378
        JOS.attributeEnd();
96
378
      }
97
378
    };
98
99
378
    if (FirstChild) {
100
367
      Pending.push_back(std::move(DumpWithIndent));
101
367
    } else {
102
11
      Pending.back()(false);
103
11
      Pending.back() = std::move(DumpWithIndent);
104
11
    }
105
378
    FirstChild = false;
106
378
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::QualType)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
1
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
1
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
1
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
1
    bool WasFirstChild = FirstChild;
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
1
        JOS.attributeBegin(LabelStr);
75
1
        JOS.arrayBegin();
76
1
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1
      while (Depth < Pending.size()) {
87
1
        Pending.back()(true);
88
1
        this->Pending.pop_back();
89
1
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
98
99
1
    if (FirstChild) {
100
1
      Pending.push_back(std::move(DumpWithIndent));
101
1
    } else {
102
0
      Pending.back()(false);
103
0
      Pending.back() = std::move(DumpWithIndent);
104
0
    }
105
1
    FirstChild = false;
106
1
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::GenericSelectionExpr::AssociationTy<true> const&)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
12
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
12
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
12
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
12
    bool WasFirstChild = FirstChild;
72
12
    auto DumpWithIndent = [=](bool IsLastChild) {
73
12
      if (WasFirstChild) {
74
12
        JOS.attributeBegin(LabelStr);
75
12
        JOS.arrayBegin();
76
12
      }
77
78
12
      FirstChild = true;
79
12
      unsigned Depth = Pending.size();
80
12
      JOS.objectBegin();
81
82
12
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
12
      while (Depth < Pending.size()) {
87
12
        Pending.back()(true);
88
12
        this->Pending.pop_back();
89
12
      }
90
91
12
      JOS.objectEnd();
92
93
12
      if (IsLastChild) {
94
12
        JOS.arrayEnd();
95
12
        JOS.attributeEnd();
96
12
      }
97
12
    };
98
99
12
    if (FirstChild) {
100
0
      Pending.push_back(std::move(DumpWithIndent));
101
12
    } else {
102
12
      Pending.back()(false);
103
12
      Pending.back() = std::move(DumpWithIndent);
104
12
    }
105
12
    FirstChild = false;
106
12
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::CXXCtorInitializer const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
3
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
3
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
3
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
3
    bool WasFirstChild = FirstChild;
72
3
    auto DumpWithIndent = [=](bool IsLastChild) {
73
3
      if (WasFirstChild) {
74
3
        JOS.attributeBegin(LabelStr);
75
3
        JOS.arrayBegin();
76
3
      }
77
78
3
      FirstChild = true;
79
3
      unsigned Depth = Pending.size();
80
3
      JOS.objectBegin();
81
82
3
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
3
      while (Depth < Pending.size()) {
87
3
        Pending.back()(true);
88
3
        this->Pending.pop_back();
89
3
      }
90
91
3
      JOS.objectEnd();
92
93
3
      if (IsLastChild) {
94
3
        JOS.arrayEnd();
95
3
        JOS.attributeEnd();
96
3
      }
97
3
    };
98
99
3
    if (FirstChild) {
100
0
      Pending.push_back(std::move(DumpWithIndent));
101
3
    } else {
102
3
      Pending.back()(false);
103
3
      Pending.back() = std::move(DumpWithIndent);
104
3
    }
105
3
    FirstChild = false;
106
3
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::ClassTemplateSpecializationDecl)
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::ClassTemplateSpecializationDecl)
Line
Count
Source
49
1
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
1
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
1
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
1
    bool WasFirstChild = FirstChild;
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
1
        JOS.attributeBegin(LabelStr);
75
1
        JOS.arrayBegin();
76
1
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1
      while (Depth < Pending.size()) {
87
1
        Pending.back()(true);
88
1
        this->Pending.pop_back();
89
1
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
98
99
1
    if (FirstChild) {
100
0
      Pending.push_back(std::move(DumpWithIndent));
101
1
    } else {
102
1
      Pending.back()(false);
103
1
      Pending.back() = std::move(DumpWithIndent);
104
1
    }
105
1
    FirstChild = false;
106
1
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::FunctionDecl)
void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::FunctionDecl)
Line
Count
Source
49
1
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
1
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
1
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
1
    bool WasFirstChild = FirstChild;
72
1
    auto DumpWithIndent = [=](bool IsLastChild) {
73
1
      if (WasFirstChild) {
74
1
        JOS.attributeBegin(LabelStr);
75
1
        JOS.arrayBegin();
76
1
      }
77
78
1
      FirstChild = true;
79
1
      unsigned Depth = Pending.size();
80
1
      JOS.objectBegin();
81
82
1
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
1
      while (Depth < Pending.size()) {
87
1
        Pending.back()(true);
88
1
        this->Pending.pop_back();
89
1
      }
90
91
1
      JOS.objectEnd();
92
93
1
      if (IsLastChild) {
94
1
        JOS.arrayEnd();
95
1
        JOS.attributeEnd();
96
1
      }
97
1
    };
98
99
1
    if (FirstChild) {
100
0
      Pending.push_back(std::move(DumpWithIndent));
101
1
    } else {
102
1
      Pending.back()(false);
103
1
      Pending.back() = std::move(DumpWithIndent);
104
1
    }
105
1
    FirstChild = false;
106
1
  }
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda'()>(llvm::StringRef, clang::VarTemplateSpecializationDecl)
Unexecuted instantiation: void clang::NodeStreamer::AddChild<void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda0'()>(llvm::StringRef, clang::VarTemplateSpecializationDecl)
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::Attr const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
30
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
30
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
30
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
30
    bool WasFirstChild = FirstChild;
72
30
    auto DumpWithIndent = [=](bool IsLastChild) {
73
30
      if (WasFirstChild) {
74
30
        JOS.attributeBegin(LabelStr);
75
30
        JOS.arrayBegin();
76
30
      }
77
78
30
      FirstChild = true;
79
30
      unsigned Depth = Pending.size();
80
30
      JOS.objectBegin();
81
82
30
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
30
      while (Depth < Pending.size()) {
87
30
        Pending.back()(true);
88
30
        this->Pending.pop_back();
89
30
      }
90
91
30
      JOS.objectEnd();
92
93
30
      if (IsLastChild) {
94
30
        JOS.arrayEnd();
95
30
        JOS.attributeEnd();
96
30
      }
97
30
    };
98
99
30
    if (FirstChild) {
100
4
      Pending.push_back(std::move(DumpWithIndent));
101
26
    } else {
102
26
      Pending.back()(false);
103
26
      Pending.back() = std::move(DumpWithIndent);
104
26
    }
105
30
    FirstChild = false;
106
30
  }
void clang::NodeStreamer::AddChild<clang::ASTNodeTraverser<clang::JSONDumper, clang::JSONNodeDumper>::Visit(clang::comments::Comment const*, clang::comments::FullComment const*)::'lambda'()>(llvm::StringRef, clang::JSONDumper)
Line
Count
Source
49
64
  template <typename Fn> void AddChild(StringRef Label, Fn DoAddChild) {
50
    // If we're at the top level, there's nothing interesting to do; just
51
    // run the dumper.
52
64
    if (TopLevel) {
53
0
      TopLevel = false;
54
0
      JOS.objectBegin();
55
56
0
      DoAddChild();
57
58
0
      while (!Pending.empty()) {
59
0
        Pending.back()(true);
60
0
        Pending.pop_back();
61
0
      }
62
63
0
      JOS.objectEnd();
64
0
      TopLevel = true;
65
0
      return;
66
0
    }
67
68
    // We need to capture an owning-string in the lambda because the lambda
69
    // is invoked in a deferred manner.
70
64
    std::string LabelStr(!Label.empty() ? 
Label0
: "inner");
71
64
    bool WasFirstChild = FirstChild;
72
64
    auto DumpWithIndent = [=](bool IsLastChild) {
73
64
      if (WasFirstChild) {
74
64
        JOS.attributeBegin(LabelStr);
75
64
        JOS.arrayBegin();
76
64
      }
77
78
64
      FirstChild = true;
79
64
      unsigned Depth = Pending.size();
80
64
      JOS.objectBegin();
81
82
64
      DoAddChild();
83
84
      // If any children are left, they're the last at their nesting level.
85
      // Dump those ones out now.
86
64
      while (Depth < Pending.size()) {
87
64
        Pending.back()(true);
88
64
        this->Pending.pop_back();
89
64
      }
90
91
64
      JOS.objectEnd();
92
93
64
      if (IsLastChild) {
94
64
        JOS.arrayEnd();
95
64
        JOS.attributeEnd();
96
64
      }
97
64
    };
98
99
64
    if (FirstChild) {
100
45
      Pending.push_back(std::move(DumpWithIndent));
101
45
    } else {
102
19
      Pending.back()(false);
103
19
      Pending.back() = std::move(DumpWithIndent);
104
19
    }
105
64
    FirstChild = false;
106
64
  }
107
108
153
  NodeStreamer(raw_ostream &OS) : JOS(OS, 2) {}
109
};
110
111
// Dumps AST nodes in JSON format. There is no implied stability for the
112
// content or format of the dump between major releases of Clang, other than it
113
// being valid JSON output. Further, there is no requirement that the
114
// information dumped is a complete representation of the AST, only that the
115
// information presented is correct.
116
class JSONNodeDumper
117
    : public ConstAttrVisitor<JSONNodeDumper>,
118
      public comments::ConstCommentVisitor<JSONNodeDumper, void,
119
                                           const comments::FullComment *>,
120
      public ConstTemplateArgumentVisitor<JSONNodeDumper>,
121
      public ConstStmtVisitor<JSONNodeDumper>,
122
      public TypeVisitor<JSONNodeDumper>,
123
      public ConstDeclVisitor<JSONNodeDumper>,
124
      public NodeStreamer {
125
  friend class JSONDumper;
126
127
  const SourceManager &SM;
128
  ASTContext& Ctx;
129
  ASTNameGenerator ASTNameGen;
130
  PrintingPolicy PrintPolicy;
131
  const comments::CommandTraits *Traits;
132
  StringRef LastLocFilename, LastLocPresumedFilename;
133
  unsigned LastLocLine, LastLocPresumedLine;
134
135
  using InnerAttrVisitor = ConstAttrVisitor<JSONNodeDumper>;
136
  using InnerCommentVisitor =
137
      comments::ConstCommentVisitor<JSONNodeDumper, void,
138
                                    const comments::FullComment *>;
139
  using InnerTemplateArgVisitor = ConstTemplateArgumentVisitor<JSONNodeDumper>;
140
  using InnerStmtVisitor = ConstStmtVisitor<JSONNodeDumper>;
141
  using InnerTypeVisitor = TypeVisitor<JSONNodeDumper>;
142
  using InnerDeclVisitor = ConstDeclVisitor<JSONNodeDumper>;
143
144
11.9k
  void attributeOnlyIfTrue(StringRef Key, bool Value) {
145
11.9k
    if (Value)
146
911
      JOS.attribute(Key, Value);
147
11.9k
  }
148
149
  void writeIncludeStack(PresumedLoc Loc, bool JustFirst = false);
150
151
  // Writes the attributes of a SourceLocation object without.
152
  void writeBareSourceLocation(SourceLocation Loc, bool IsSpelling);
153
154
  // Writes the attributes of a SourceLocation to JSON based on its presumed
155
  // spelling location. If the given location represents a macro invocation,
156
  // this outputs two sub-objects: one for the spelling and one for the
157
  // expansion location.
158
  void writeSourceLocation(SourceLocation Loc);
159
  void writeSourceRange(SourceRange R);
160
  std::string createPointerRepresentation(const void *Ptr);
161
  llvm::json::Object createQualType(QualType QT, bool Desugar = true);
162
  llvm::json::Object createBareDeclRef(const Decl *D);
163
  void writeBareDeclRef(const Decl *D);
164
  llvm::json::Object createCXXRecordDefinitionData(const CXXRecordDecl *RD);
165
  llvm::json::Object createCXXBaseSpecifier(const CXXBaseSpecifier &BS);
166
  std::string createAccessSpecifier(AccessSpecifier AS);
167
  llvm::json::Array createCastPath(const CastExpr *C);
168
169
137
  void writePreviousDeclImpl(...) {}
170
171
128
  template <typename T> void writePreviousDeclImpl(const Mergeable<T> *D) {
172
128
    const T *First = D->getFirstDecl();
173
128
    if (First != D)
174
0
      JOS.attribute("firstRedecl", createPointerRepresentation(First));
175
128
  }
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::LifetimeExtendedTemporaryDecl>(clang::Mergeable<clang::LifetimeExtendedTemporaryDecl> const*)
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UsingDecl>(clang::Mergeable<clang::UsingDecl> const*)
Line
Count
Source
171
4
  template <typename T> void writePreviousDeclImpl(const Mergeable<T> *D) {
172
4
    const T *First = D->getFirstDecl();
173
4
    if (First != D)
174
0
      JOS.attribute("firstRedecl", createPointerRepresentation(First));
175
4
  }
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UsingEnumDecl>(clang::Mergeable<clang::UsingEnumDecl> const*)
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::ConceptDecl>(clang::Mergeable<clang::ConceptDecl> const*)
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UnresolvedUsingTypenameDecl>(clang::Mergeable<clang::UnresolvedUsingTypenameDecl> const*)
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UsingPackDecl>(clang::Mergeable<clang::UsingPackDecl> const*)
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::FieldDecl>(clang::Mergeable<clang::FieldDecl> const*)
Line
Count
Source
171
97
  template <typename T> void writePreviousDeclImpl(const Mergeable<T> *D) {
172
97
    const T *First = D->getFirstDecl();
173
97
    if (First != D)
174
0
      JOS.attribute("firstRedecl", createPointerRepresentation(First));
175
97
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::EnumConstantDecl>(clang::Mergeable<clang::EnumConstantDecl> const*)
Line
Count
Source
171
17
  template <typename T> void writePreviousDeclImpl(const Mergeable<T> *D) {
172
17
    const T *First = D->getFirstDecl();
173
17
    if (First != D)
174
0
      JOS.attribute("firstRedecl", createPointerRepresentation(First));
175
17
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::IndirectFieldDecl>(clang::Mergeable<clang::IndirectFieldDecl> const*)
Line
Count
Source
171
10
  template <typename T> void writePreviousDeclImpl(const Mergeable<T> *D) {
172
10
    const T *First = D->getFirstDecl();
173
10
    if (First != D)
174
0
      JOS.attribute("firstRedecl", createPointerRepresentation(First));
175
10
  }
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::MSGuidDecl>(clang::Mergeable<clang::MSGuidDecl> const*)
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::TemplateParamObjectDecl>(clang::Mergeable<clang::TemplateParamObjectDecl> const*)
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UnresolvedUsingValueDecl>(clang::Mergeable<clang::UnresolvedUsingValueDecl> const*)
176
177
1.18k
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
1.18k
    const T *Prev = D->getPreviousDecl();
179
1.18k
    if (Prev)
180
30
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
1.18k
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::NamespaceDecl>(clang::Redeclarable<clang::NamespaceDecl> const*)
Line
Count
Source
177
12
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
12
    const T *Prev = D->getPreviousDecl();
179
12
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
12
  }
Unexecuted instantiation: void clang::JSONNodeDumper::writePreviousDeclImpl<clang::NamespaceAliasDecl>(clang::Redeclarable<clang::NamespaceAliasDecl> const*)
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::ObjCInterfaceDecl>(clang::Redeclarable<clang::ObjCInterfaceDecl> const*)
Line
Count
Source
177
4
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
4
    const T *Prev = D->getPreviousDecl();
179
4
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
4
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::ObjCProtocolDecl>(clang::Redeclarable<clang::ObjCProtocolDecl> const*)
Line
Count
Source
177
1
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
1
    const T *Prev = D->getPreviousDecl();
179
1
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
1
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::RedeclarableTemplateDecl>(clang::Redeclarable<clang::RedeclarableTemplateDecl> const*)
Line
Count
Source
177
32
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
32
    const T *Prev = D->getPreviousDecl();
179
32
    if (Prev)
180
1
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
32
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::TagDecl>(clang::Redeclarable<clang::TagDecl> const*)
Line
Count
Source
177
189
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
189
    const T *Prev = D->getPreviousDecl();
179
189
    if (Prev)
180
2
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
189
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::TypedefNameDecl>(clang::Redeclarable<clang::TypedefNameDecl> const*)
Line
Count
Source
177
245
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
245
    const T *Prev = D->getPreviousDecl();
179
245
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
245
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::UsingShadowDecl>(clang::Redeclarable<clang::UsingShadowDecl> const*)
Line
Count
Source
177
3
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
3
    const T *Prev = D->getPreviousDecl();
179
3
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
3
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::FunctionDecl>(clang::Redeclarable<clang::FunctionDecl> const*)
Line
Count
Source
177
332
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
332
    const T *Prev = D->getPreviousDecl();
179
332
    if (Prev)
180
27
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
332
  }
void clang::JSONNodeDumper::writePreviousDeclImpl<clang::VarDecl>(clang::Redeclarable<clang::VarDecl> const*)
Line
Count
Source
177
371
  template <typename T> void writePreviousDeclImpl(const Redeclarable<T> *D) {
178
371
    const T *Prev = D->getPreviousDecl();
179
371
    if (Prev)
180
0
      JOS.attribute("previousDecl", createPointerRepresentation(Prev));
181
371
  }
182
  void addPreviousDeclaration(const Decl *D);
183
184
  StringRef getCommentCommandName(unsigned CommandID) const;
185
186
public:
187
  JSONNodeDumper(raw_ostream &OS, const SourceManager &SrcMgr, ASTContext &Ctx,
188
                 const PrintingPolicy &PrintPolicy,
189
                 const comments::CommandTraits *Traits)
190
      : NodeStreamer(OS), SM(SrcMgr), Ctx(Ctx), ASTNameGen(Ctx),
191
        PrintPolicy(PrintPolicy), Traits(Traits), LastLocLine(0),
192
153
        LastLocPresumedLine(0) {}
193
194
  void Visit(const Attr *A);
195
  void Visit(const Stmt *Node);
196
  void Visit(const Type *T);
197
  void Visit(QualType T);
198
  void Visit(const Decl *D);
199
200
  void Visit(const comments::Comment *C, const comments::FullComment *FC);
201
  void Visit(const TemplateArgument &TA, SourceRange R = {},
202
             const Decl *From = nullptr, StringRef Label = {});
203
  void Visit(const CXXCtorInitializer *Init);
204
  void Visit(const OMPClause *C);
205
  void Visit(const BlockDecl::Capture &C);
206
  void Visit(const GenericSelectionExpr::ConstAssociation &A);
207
  void Visit(const APValue &Value, QualType Ty);
208
209
  void VisitTypedefType(const TypedefType *TT);
210
  void VisitFunctionType(const FunctionType *T);
211
  void VisitFunctionProtoType(const FunctionProtoType *T);
212
  void VisitRValueReferenceType(const ReferenceType *RT);
213
  void VisitArrayType(const ArrayType *AT);
214
  void VisitConstantArrayType(const ConstantArrayType *CAT);
215
  void VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *VT);
216
  void VisitVectorType(const VectorType *VT);
217
  void VisitUnresolvedUsingType(const UnresolvedUsingType *UUT);
218
  void VisitUnaryTransformType(const UnaryTransformType *UTT);
219
  void VisitTagType(const TagType *TT);
220
  void VisitTemplateTypeParmType(const TemplateTypeParmType *TTPT);
221
  void VisitAutoType(const AutoType *AT);
222
  void VisitTemplateSpecializationType(const TemplateSpecializationType *TST);
223
  void VisitInjectedClassNameType(const InjectedClassNameType *ICNT);
224
  void VisitObjCInterfaceType(const ObjCInterfaceType *OIT);
225
  void VisitPackExpansionType(const PackExpansionType *PET);
226
  void VisitElaboratedType(const ElaboratedType *ET);
227
  void VisitMacroQualifiedType(const MacroQualifiedType *MQT);
228
  void VisitMemberPointerType(const MemberPointerType *MPT);
229
230
  void VisitNamedDecl(const NamedDecl *ND);
231
  void VisitTypedefDecl(const TypedefDecl *TD);
232
  void VisitTypeAliasDecl(const TypeAliasDecl *TAD);
233
  void VisitNamespaceDecl(const NamespaceDecl *ND);
234
  void VisitUsingDirectiveDecl(const UsingDirectiveDecl *UDD);
235
  void VisitNamespaceAliasDecl(const NamespaceAliasDecl *NAD);
236
  void VisitUsingDecl(const UsingDecl *UD);
237
  void VisitUsingEnumDecl(const UsingEnumDecl *UED);
238
  void VisitUsingShadowDecl(const UsingShadowDecl *USD);
239
  void VisitVarDecl(const VarDecl *VD);
240
  void VisitFieldDecl(const FieldDecl *FD);
241
  void VisitFunctionDecl(const FunctionDecl *FD);
242
  void VisitEnumDecl(const EnumDecl *ED);
243
  void VisitEnumConstantDecl(const EnumConstantDecl *ECD);
244
  void VisitRecordDecl(const RecordDecl *RD);
245
  void VisitCXXRecordDecl(const CXXRecordDecl *RD);
246
  void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
247
  void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
248
  void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
249
  void VisitLinkageSpecDecl(const LinkageSpecDecl *LSD);
250
  void VisitAccessSpecDecl(const AccessSpecDecl *ASD);
251
  void VisitFriendDecl(const FriendDecl *FD);
252
253
  void VisitObjCIvarDecl(const ObjCIvarDecl *D);
254
  void VisitObjCMethodDecl(const ObjCMethodDecl *D);
255
  void VisitObjCTypeParamDecl(const ObjCTypeParamDecl *D);
256
  void VisitObjCCategoryDecl(const ObjCCategoryDecl *D);
257
  void VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D);
258
  void VisitObjCProtocolDecl(const ObjCProtocolDecl *D);
259
  void VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
260
  void VisitObjCImplementationDecl(const ObjCImplementationDecl *D);
261
  void VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D);
262
  void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
263
  void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
264
  void VisitBlockDecl(const BlockDecl *D);
265
266
  void VisitDeclRefExpr(const DeclRefExpr *DRE);
267
  void VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E);
268
  void VisitPredefinedExpr(const PredefinedExpr *PE);
269
  void VisitUnaryOperator(const UnaryOperator *UO);
270
  void VisitBinaryOperator(const BinaryOperator *BO);
271
  void VisitCompoundAssignOperator(const CompoundAssignOperator *CAO);
272
  void VisitMemberExpr(const MemberExpr *ME);
273
  void VisitCXXNewExpr(const CXXNewExpr *NE);
274
  void VisitCXXDeleteExpr(const CXXDeleteExpr *DE);
275
  void VisitCXXThisExpr(const CXXThisExpr *TE);
276
  void VisitCastExpr(const CastExpr *CE);
277
  void VisitImplicitCastExpr(const ImplicitCastExpr *ICE);
278
  void VisitCallExpr(const CallExpr *CE);
279
  void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *TTE);
280
  void VisitSizeOfPackExpr(const SizeOfPackExpr *SOPE);
281
  void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *ULE);
282
  void VisitAddrLabelExpr(const AddrLabelExpr *ALE);
283
  void VisitCXXTypeidExpr(const CXXTypeidExpr *CTE);
284
  void VisitConstantExpr(const ConstantExpr *CE);
285
  void VisitInitListExpr(const InitListExpr *ILE);
286
  void VisitGenericSelectionExpr(const GenericSelectionExpr *GSE);
287
  void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *UCE);
288
  void VisitCXXConstructExpr(const CXXConstructExpr *CE);
289
  void VisitExprWithCleanups(const ExprWithCleanups *EWC);
290
  void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE);
291
  void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE);
292
  void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *ME);
293
294
  void VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE);
295
  void VisitObjCMessageExpr(const ObjCMessageExpr *OME);
296
  void VisitObjCBoxedExpr(const ObjCBoxedExpr *OBE);
297
  void VisitObjCSelectorExpr(const ObjCSelectorExpr *OSE);
298
  void VisitObjCProtocolExpr(const ObjCProtocolExpr *OPE);
299
  void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *OPRE);
300
  void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *OSRE);
301
  void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE);
302
  void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *OBLE);
303
304
  void VisitIntegerLiteral(const IntegerLiteral *IL);
305
  void VisitCharacterLiteral(const CharacterLiteral *CL);
306
  void VisitFixedPointLiteral(const FixedPointLiteral *FPL);
307
  void VisitFloatingLiteral(const FloatingLiteral *FL);
308
  void VisitStringLiteral(const StringLiteral *SL);
309
  void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *BLE);
310
311
  void VisitIfStmt(const IfStmt *IS);
312
  void VisitSwitchStmt(const SwitchStmt *SS);
313
  void VisitCaseStmt(const CaseStmt *CS);
314
  void VisitLabelStmt(const LabelStmt *LS);
315
  void VisitGotoStmt(const GotoStmt *GS);
316
  void VisitWhileStmt(const WhileStmt *WS);
317
  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
318
319
  void VisitNullTemplateArgument(const TemplateArgument &TA);
320
  void VisitTypeTemplateArgument(const TemplateArgument &TA);
321
  void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
322
  void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
323
  void VisitIntegralTemplateArgument(const TemplateArgument &TA);
324
  void VisitTemplateTemplateArgument(const TemplateArgument &TA);
325
  void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
326
  void VisitExpressionTemplateArgument(const TemplateArgument &TA);
327
  void VisitPackTemplateArgument(const TemplateArgument &TA);
328
329
  void visitTextComment(const comments::TextComment *C,
330
                        const comments::FullComment *);
331
  void visitInlineCommandComment(const comments::InlineCommandComment *C,
332
                                 const comments::FullComment *);
333
  void visitHTMLStartTagComment(const comments::HTMLStartTagComment *C,
334
                                const comments::FullComment *);
335
  void visitHTMLEndTagComment(const comments::HTMLEndTagComment *C,
336
                              const comments::FullComment *);
337
  void visitBlockCommandComment(const comments::BlockCommandComment *C,
338
                                const comments::FullComment *);
339
  void visitParamCommandComment(const comments::ParamCommandComment *C,
340
                                const comments::FullComment *FC);
341
  void visitTParamCommandComment(const comments::TParamCommandComment *C,
342
                                 const comments::FullComment *FC);
343
  void visitVerbatimBlockComment(const comments::VerbatimBlockComment *C,
344
                                 const comments::FullComment *);
345
  void
346
  visitVerbatimBlockLineComment(const comments::VerbatimBlockLineComment *C,
347
                                const comments::FullComment *);
348
  void visitVerbatimLineComment(const comments::VerbatimLineComment *C,
349
                                const comments::FullComment *);
350
};
351
352
class JSONDumper : public ASTNodeTraverser<JSONDumper, JSONNodeDumper> {
353
  JSONNodeDumper NodeDumper;
354
355
  template <typename SpecializationDecl>
356
  void writeTemplateDeclSpecialization(const SpecializationDecl *SD,
357
                                       bool DumpExplicitInst,
358
2
                                       bool DumpRefOnly) {
359
2
    bool DumpedAny = false;
360
3
    for (const auto *RedeclWithBadType : SD->redecls()) {
361
      // FIXME: The redecls() range sometimes has elements of a less-specific
362
      // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
363
      // us TagDecls, and should give CXXRecordDecls).
364
3
      const auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
365
3
      if (!Redecl) {
366
        // Found the injected-class-name for a class template. This will be
367
        // dumped as part of its surrounding class so we don't need to dump it
368
        // here.
369
0
        assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
370
0
               "expected an injected-class-name");
371
0
        continue;
372
0
      }
373
374
3
      switch (Redecl->getTemplateSpecializationKind()) {
375
0
      case TSK_ExplicitInstantiationDeclaration:
376
0
      case TSK_ExplicitInstantiationDefinition:
377
0
        if (!DumpExplicitInst)
378
0
          break;
379
0
        LLVM_FALLTHROUGH;
380
0
      case TSK_Undeclared:
381
0
      case TSK_ImplicitInstantiation:
382
0
        if (DumpRefOnly)
383
0
          NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(Redecl); });
Unexecuted instantiation: void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda'()::operator()() const
Unexecuted instantiation: void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda'()::operator()() const
Unexecuted instantiation: void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda'()::operator()() const
384
0
        else
385
0
          Visit(Redecl);
386
0
        DumpedAny = true;
387
0
        break;
388
3
      case TSK_ExplicitSpecialization:
389
3
        break;
390
3
      }
391
3
    }
392
393
    // Ensure we dump at least one decl for each specialization.
394
2
    if (!DumpedAny)
395
2
      NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)::'lambda0'()::operator()() const
Line
Count
Source
395
1
      NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)::'lambda0'()::operator()() const
Line
Count
Source
395
1
      NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
Unexecuted instantiation: void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)::'lambda0'()::operator()() const
396
2
  }
void clang::JSONDumper::writeTemplateDeclSpecialization<clang::ClassTemplateSpecializationDecl>(clang::ClassTemplateSpecializationDecl const*, bool, bool)
Line
Count
Source
358
1
                                       bool DumpRefOnly) {
359
1
    bool DumpedAny = false;
360
1
    for (const auto *RedeclWithBadType : SD->redecls()) {
361
      // FIXME: The redecls() range sometimes has elements of a less-specific
362
      // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
363
      // us TagDecls, and should give CXXRecordDecls).
364
1
      const auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
365
1
      if (!Redecl) {
366
        // Found the injected-class-name for a class template. This will be
367
        // dumped as part of its surrounding class so we don't need to dump it
368
        // here.
369
0
        assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
370
0
               "expected an injected-class-name");
371
0
        continue;
372
0
      }
373
374
1
      switch (Redecl->getTemplateSpecializationKind()) {
375
0
      case TSK_ExplicitInstantiationDeclaration:
376
0
      case TSK_ExplicitInstantiationDefinition:
377
0
        if (!DumpExplicitInst)
378
0
          break;
379
0
        LLVM_FALLTHROUGH;
380
0
      case TSK_Undeclared:
381
0
      case TSK_ImplicitInstantiation:
382
0
        if (DumpRefOnly)
383
0
          NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(Redecl); });
384
0
        else
385
0
          Visit(Redecl);
386
0
        DumpedAny = true;
387
0
        break;
388
1
      case TSK_ExplicitSpecialization:
389
1
        break;
390
1
      }
391
1
    }
392
393
    // Ensure we dump at least one decl for each specialization.
394
1
    if (!DumpedAny)
395
1
      NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
396
1
  }
void clang::JSONDumper::writeTemplateDeclSpecialization<clang::FunctionDecl>(clang::FunctionDecl const*, bool, bool)
Line
Count
Source
358
1
                                       bool DumpRefOnly) {
359
1
    bool DumpedAny = false;
360
2
    for (const auto *RedeclWithBadType : SD->redecls()) {
361
      // FIXME: The redecls() range sometimes has elements of a less-specific
362
      // type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
363
      // us TagDecls, and should give CXXRecordDecls).
364
2
      const auto *Redecl = dyn_cast<SpecializationDecl>(RedeclWithBadType);
365
2
      if (!Redecl) {
366
        // Found the injected-class-name for a class template. This will be
367
        // dumped as part of its surrounding class so we don't need to dump it
368
        // here.
369
0
        assert(isa<CXXRecordDecl>(RedeclWithBadType) &&
370
0
               "expected an injected-class-name");
371
0
        continue;
372
0
      }
373
374
2
      switch (Redecl->getTemplateSpecializationKind()) {
375
0
      case TSK_ExplicitInstantiationDeclaration:
376
0
      case TSK_ExplicitInstantiationDefinition:
377
0
        if (!DumpExplicitInst)
378
0
          break;
379
0
        LLVM_FALLTHROUGH;
380
0
      case TSK_Undeclared:
381
0
      case TSK_ImplicitInstantiation:
382
0
        if (DumpRefOnly)
383
0
          NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(Redecl); });
384
0
        else
385
0
          Visit(Redecl);
386
0
        DumpedAny = true;
387
0
        break;
388
2
      case TSK_ExplicitSpecialization:
389
2
        break;
390
2
      }
391
2
    }
392
393
    // Ensure we dump at least one decl for each specialization.
394
1
    if (!DumpedAny)
395
1
      NodeDumper.AddChild([=] { NodeDumper.writeBareDeclRef(SD); });
396
1
  }
Unexecuted instantiation: void clang::JSONDumper::writeTemplateDeclSpecialization<clang::VarTemplateSpecializationDecl>(clang::VarTemplateSpecializationDecl const*, bool, bool)
397
398
  template <typename TemplateDecl>
399
32
  void writeTemplateDecl(const TemplateDecl *TD, bool DumpExplicitInst) {
400
    // FIXME: it would be nice to dump template parameters and specializations
401
    // to their own named arrays rather than shoving them into the "inner"
402
    // array. However, template declarations are currently being handled at the
403
    // wrong "level" of the traversal hierarchy and so it is difficult to
404
    // achieve without losing information elsewhere.
405
406
32
    dumpTemplateParameters(TD->getTemplateParameters());
407
408
32
    Visit(TD->getTemplatedDecl());
409
410
32
    for (const auto *Child : TD->specializations())
411
2
      writeTemplateDeclSpecialization(Child, DumpExplicitInst,
412
2
                                      !TD->isCanonicalDecl());
413
32
  }
void clang::JSONDumper::writeTemplateDecl<clang::ClassTemplateDecl>(clang::ClassTemplateDecl const*, bool)
Line
Count
Source
399
9
  void writeTemplateDecl(const TemplateDecl *TD, bool DumpExplicitInst) {
400
    // FIXME: it would be nice to dump template parameters and specializations
401
    // to their own named arrays rather than shoving them into the "inner"
402
    // array. However, template declarations are currently being handled at the
403
    // wrong "level" of the traversal hierarchy and so it is difficult to
404
    // achieve without losing information elsewhere.
405
406
9
    dumpTemplateParameters(TD->getTemplateParameters());
407
408
9
    Visit(TD->getTemplatedDecl());
409
410
9
    for (const auto *Child : TD->specializations())
411
1
      writeTemplateDeclSpecialization(Child, DumpExplicitInst,
412
1
                                      !TD->isCanonicalDecl());
413
9
  }
void clang::JSONDumper::writeTemplateDecl<clang::FunctionTemplateDecl>(clang::FunctionTemplateDecl const*, bool)
Line
Count
Source
399
22
  void writeTemplateDecl(const TemplateDecl *TD, bool DumpExplicitInst) {
400
    // FIXME: it would be nice to dump template parameters and specializations
401
    // to their own named arrays rather than shoving them into the "inner"
402
    // array. However, template declarations are currently being handled at the
403
    // wrong "level" of the traversal hierarchy and so it is difficult to
404
    // achieve without losing information elsewhere.
405
406
22
    dumpTemplateParameters(TD->getTemplateParameters());
407
408
22
    Visit(TD->getTemplatedDecl());
409
410
22
    for (const auto *Child : TD->specializations())
411
1
      writeTemplateDeclSpecialization(Child, DumpExplicitInst,
412
1
                                      !TD->isCanonicalDecl());
413
22
  }
void clang::JSONDumper::writeTemplateDecl<clang::VarTemplateDecl>(clang::VarTemplateDecl const*, bool)
Line
Count
Source
399
1
  void writeTemplateDecl(const TemplateDecl *TD, bool DumpExplicitInst) {
400
    // FIXME: it would be nice to dump template parameters and specializations
401
    // to their own named arrays rather than shoving them into the "inner"
402
    // array. However, template declarations are currently being handled at the
403
    // wrong "level" of the traversal hierarchy and so it is difficult to
404
    // achieve without losing information elsewhere.
405
406
1
    dumpTemplateParameters(TD->getTemplateParameters());
407
408
1
    Visit(TD->getTemplatedDecl());
409
410
1
    for (const auto *Child : TD->specializations())
411
0
      writeTemplateDeclSpecialization(Child, DumpExplicitInst,
412
0
                                      !TD->isCanonicalDecl());
413
1
  }
414
415
public:
416
  JSONDumper(raw_ostream &OS, const SourceManager &SrcMgr, ASTContext &Ctx,
417
             const PrintingPolicy &PrintPolicy,
418
             const comments::CommandTraits *Traits)
419
153
      : NodeDumper(OS, SrcMgr, Ctx, PrintPolicy, Traits) {}
420
421
8.37k
  JSONNodeDumper &doGetNodeDelegate() { return NodeDumper; }
422
423
22
  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *FTD) {
424
22
    writeTemplateDecl(FTD, true);
425
22
  }
426
9
  void VisitClassTemplateDecl(const ClassTemplateDecl *CTD) {
427
9
    writeTemplateDecl(CTD, false);
428
9
  }
429
1
  void VisitVarTemplateDecl(const VarTemplateDecl *VTD) {
430
1
    writeTemplateDecl(VTD, false);
431
1
  }
432
};
433
434
} // namespace clang
435
436
#endif // LLVM_CLANG_AST_JSONNODEDUMPER_H