Coverage Report

Created: 2020-02-15 09:57

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Tooling/Syntax/Nodes.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- Nodes.cpp ----------------------------------------------*- C++ -*-=====//
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
#include "clang/Tooling/Syntax/Nodes.h"
9
#include "clang/Basic/TokenKinds.h"
10
11
using namespace clang;
12
13
150
llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeKind K) {
14
150
  switch (K) {
15
0
  case NodeKind::Leaf:
16
0
    return OS << "Leaf";
17
25
  case NodeKind::TranslationUnit:
18
25
    return OS << "TranslationUnit";
19
21
  case NodeKind::UnknownExpression:
20
21
    return OS << "UnknownExpression";
21
1
  case NodeKind::UnknownStatement:
22
1
    return OS << "UnknownStatement";
23
4
  case NodeKind::DeclarationStatement:
24
4
    return OS << "DeclarationStatement";
25
3
  case NodeKind::EmptyStatement:
26
3
    return OS << "EmptyStatement";
27
1
  case NodeKind::SwitchStatement:
28
1
    return OS << "SwitchStatement";
29
1
  case NodeKind::CaseStatement:
30
1
    return OS << "CaseStatement";
31
1
  case NodeKind::DefaultStatement:
32
1
    return OS << "DefaultStatement";
33
5
  case NodeKind::IfStatement:
34
5
    return OS << "IfStatement";
35
1
  case NodeKind::ForStatement:
36
1
    return OS << "ForStatement";
37
1
  case NodeKind::WhileStatement:
38
1
    return OS << "WhileStatement";
39
1
  case NodeKind::ContinueStatement:
40
1
    return OS << "ContinueStatement";
41
1
  case NodeKind::BreakStatement:
42
1
    return OS << "BreakStatement";
43
2
  case NodeKind::ReturnStatement:
44
2
    return OS << "ReturnStatement";
45
1
  case NodeKind::RangeBasedForStatement:
46
1
    return OS << "RangeBasedForStatement";
47
5
  case NodeKind::ExpressionStatement:
48
5
    return OS << "ExpressionStatement";
49
25
  case NodeKind::CompoundStatement:
50
25
    return OS << "CompoundStatement";
51
2
  case NodeKind::UnknownDeclaration:
52
2
    return OS << "UnknownDeclaration";
53
1
  case NodeKind::EmptyDeclaration:
54
1
    return OS << "EmptyDeclaration";
55
2
  case NodeKind::StaticAssertDeclaration:
56
2
    return OS << "StaticAssertDeclaration";
57
2
  case NodeKind::LinkageSpecificationDeclaration:
58
2
    return OS << "LinkageSpecificationDeclaration";
59
32
  case NodeKind::SimpleDeclaration:
60
32
    return OS << "SimpleDeclaration";
61
6
  case NodeKind::NamespaceDefinition:
62
6
    return OS << "NamespaceDefinition";
63
1
  case NodeKind::NamespaceAliasDefinition:
64
1
    return OS << "NamespaceAliasDefinition";
65
1
  case NodeKind::UsingNamespaceDirective:
66
1
    return OS << "UsingNamespaceDirective";
67
3
  case NodeKind::UsingDeclaration:
68
3
    return OS << "UsingDeclaration";
69
1
  case NodeKind::TypeAliasDeclaration:
70
1
    return OS << "TypeAliasDeclaration";
71
0
  }
72
0
  llvm_unreachable("unknown node kind");
73
0
}
74
75
0
llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeRole R) {
76
0
  switch (R) {
77
0
  case syntax::NodeRole::Detached:
78
0
    return OS << "Detached";
79
0
  case syntax::NodeRole::Unknown:
80
0
    return OS << "Unknown";
81
0
  case syntax::NodeRole::OpenParen:
82
0
    return OS << "OpenParen";
83
0
  case syntax::NodeRole::CloseParen:
84
0
    return OS << "CloseParen";
85
0
  case syntax::NodeRole::IntroducerKeyword:
86
0
    return OS << "IntroducerKeyword";
87
0
  case syntax::NodeRole::BodyStatement:
88
0
    return OS << "BodyStatement";
89
0
  case syntax::NodeRole::CaseStatement_value:
90
0
    return OS << "CaseStatement_value";
91
0
  case syntax::NodeRole::IfStatement_thenStatement:
92
0
    return OS << "IfStatement_thenStatement";
93
0
  case syntax::NodeRole::IfStatement_elseKeyword:
94
0
    return OS << "IfStatement_elseKeyword";
95
0
  case syntax::NodeRole::IfStatement_elseStatement:
96
0
    return OS << "IfStatement_elseStatement";
97
0
  case syntax::NodeRole::ReturnStatement_value:
98
0
    return OS << "ReturnStatement_value";
99
0
  case syntax::NodeRole::ExpressionStatement_expression:
100
0
    return OS << "ExpressionStatement_expression";
101
0
  case syntax::NodeRole::CompoundStatement_statement:
102
0
    return OS << "CompoundStatement_statement";
103
0
  case syntax::NodeRole::StaticAssertDeclaration_condition:
104
0
    return OS << "StaticAssertDeclaration_condition";
105
0
  case syntax::NodeRole::StaticAssertDeclaration_message:
106
0
    return OS << "StaticAssertDeclaration_message";
107
0
  }
108
0
  llvm_unreachable("invalid role");
109
0
}
110
111
0
syntax::Leaf *syntax::SwitchStatement::switchKeyword() {
112
0
  return llvm::cast_or_null<syntax::Leaf>(
113
0
      findChild(syntax::NodeRole::IntroducerKeyword));
114
0
}
115
116
0
syntax::Statement *syntax::SwitchStatement::body() {
117
0
  return llvm::cast_or_null<syntax::Statement>(
118
0
      findChild(syntax::NodeRole::BodyStatement));
119
0
}
120
121
0
syntax::Leaf *syntax::CaseStatement::caseKeyword() {
122
0
  return llvm::cast_or_null<syntax::Leaf>(
123
0
      findChild(syntax::NodeRole::IntroducerKeyword));
124
0
}
125
126
0
syntax::Expression *syntax::CaseStatement::value() {
127
0
  return llvm::cast_or_null<syntax::Expression>(
128
0
      findChild(syntax::NodeRole::CaseStatement_value));
129
0
}
130
131
0
syntax::Statement *syntax::CaseStatement::body() {
132
0
  return llvm::cast_or_null<syntax::Statement>(
133
0
      findChild(syntax::NodeRole::BodyStatement));
134
0
}
135
136
0
syntax::Leaf *syntax::DefaultStatement::defaultKeyword() {
137
0
  return llvm::cast_or_null<syntax::Leaf>(
138
0
      findChild(syntax::NodeRole::IntroducerKeyword));
139
0
}
140
141
0
syntax::Statement *syntax::DefaultStatement::body() {
142
0
  return llvm::cast_or_null<syntax::Statement>(
143
0
      findChild(syntax::NodeRole::BodyStatement));
144
0
}
145
146
0
syntax::Leaf *syntax::IfStatement::ifKeyword() {
147
0
  return llvm::cast_or_null<syntax::Leaf>(
148
0
      findChild(syntax::NodeRole::IntroducerKeyword));
149
0
}
150
151
0
syntax::Statement *syntax::IfStatement::thenStatement() {
152
0
  return llvm::cast_or_null<syntax::Statement>(
153
0
      findChild(syntax::NodeRole::IfStatement_thenStatement));
154
0
}
155
156
0
syntax::Leaf *syntax::IfStatement::elseKeyword() {
157
0
  return llvm::cast_or_null<syntax::Leaf>(
158
0
      findChild(syntax::NodeRole::IfStatement_elseKeyword));
159
0
}
160
161
0
syntax::Statement *syntax::IfStatement::elseStatement() {
162
0
  return llvm::cast_or_null<syntax::Statement>(
163
0
      findChild(syntax::NodeRole::IfStatement_elseStatement));
164
0
}
165
166
0
syntax::Leaf *syntax::ForStatement::forKeyword() {
167
0
  return llvm::cast_or_null<syntax::Leaf>(
168
0
      findChild(syntax::NodeRole::IntroducerKeyword));
169
0
}
170
171
0
syntax::Statement *syntax::ForStatement::body() {
172
0
  return llvm::cast_or_null<syntax::Statement>(
173
0
      findChild(syntax::NodeRole::BodyStatement));
174
0
}
175
176
0
syntax::Leaf *syntax::WhileStatement::whileKeyword() {
177
0
  return llvm::cast_or_null<syntax::Leaf>(
178
0
      findChild(syntax::NodeRole::IntroducerKeyword));
179
0
}
180
181
0
syntax::Statement *syntax::WhileStatement::body() {
182
0
  return llvm::cast_or_null<syntax::Statement>(
183
0
      findChild(syntax::NodeRole::BodyStatement));
184
0
}
185
186
0
syntax::Leaf *syntax::ContinueStatement::continueKeyword() {
187
0
  return llvm::cast_or_null<syntax::Leaf>(
188
0
      findChild(syntax::NodeRole::IntroducerKeyword));
189
0
}
190
191
0
syntax::Leaf *syntax::BreakStatement::breakKeyword() {
192
0
  return llvm::cast_or_null<syntax::Leaf>(
193
0
      findChild(syntax::NodeRole::IntroducerKeyword));
194
0
}
195
196
0
syntax::Leaf *syntax::ReturnStatement::returnKeyword() {
197
0
  return llvm::cast_or_null<syntax::Leaf>(
198
0
      findChild(syntax::NodeRole::IntroducerKeyword));
199
0
}
200
201
0
syntax::Expression *syntax::ReturnStatement::value() {
202
0
  return llvm::cast_or_null<syntax::Expression>(
203
0
      findChild(syntax::NodeRole::ReturnStatement_value));
204
0
}
205
206
0
syntax::Leaf *syntax::RangeBasedForStatement::forKeyword() {
207
0
  return llvm::cast_or_null<syntax::Leaf>(
208
0
      findChild(syntax::NodeRole::IntroducerKeyword));
209
0
}
210
211
0
syntax::Statement *syntax::RangeBasedForStatement::body() {
212
0
  return llvm::cast_or_null<syntax::Statement>(
213
0
      findChild(syntax::NodeRole::BodyStatement));
214
0
}
215
216
0
syntax::Expression *syntax::ExpressionStatement::expression() {
217
0
  return llvm::cast_or_null<syntax::Expression>(
218
0
      findChild(syntax::NodeRole::ExpressionStatement_expression));
219
0
}
220
221
0
syntax::Leaf *syntax::CompoundStatement::lbrace() {
222
0
  return llvm::cast_or_null<syntax::Leaf>(
223
0
      findChild(syntax::NodeRole::OpenParen));
224
0
}
225
226
0
std::vector<syntax::Statement *> syntax::CompoundStatement::statements() {
227
0
  std::vector<syntax::Statement *> Children;
228
0
  for (auto *C = firstChild(); C; C = C->nextSibling()) {
229
0
    if (C->role() == syntax::NodeRole::CompoundStatement_statement)
230
0
      Children.push_back(llvm::cast<syntax::Statement>(C));
231
0
  }
232
0
  return Children;
233
0
}
234
235
0
syntax::Leaf *syntax::CompoundStatement::rbrace() {
236
0
  return llvm::cast_or_null<syntax::Leaf>(
237
0
      findChild(syntax::NodeRole::CloseParen));
238
0
}
239
240
0
syntax::Expression *syntax::StaticAssertDeclaration::condition() {
241
0
  return llvm::cast_or_null<syntax::Expression>(
242
0
      findChild(syntax::NodeRole::StaticAssertDeclaration_condition));
243
0
}
244
245
0
syntax::Expression *syntax::StaticAssertDeclaration::message() {
246
0
  return llvm::cast_or_null<syntax::Expression>(
247
0
      findChild(syntax::NodeRole::StaticAssertDeclaration_message));
248
0
}