Coverage Report

Created: 2021-01-26 06:56

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/utils/TableGen/TableGen.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
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 contains the main function for Clang's TableGen.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "TableGenBackends.h" // Declares all backends.
14
#include "ASTTableGen.h"
15
#include "llvm/Support/CommandLine.h"
16
#include "llvm/Support/PrettyStackTrace.h"
17
#include "llvm/Support/Signals.h"
18
#include "llvm/TableGen/Error.h"
19
#include "llvm/TableGen/Main.h"
20
#include "llvm/TableGen/Record.h"
21
22
using namespace llvm;
23
using namespace clang;
24
25
enum ActionType {
26
  PrintRecords,
27
  DumpJSON,
28
  GenClangAttrClasses,
29
  GenClangAttrParserStringSwitches,
30
  GenClangAttrSubjectMatchRulesParserStringSwitches,
31
  GenClangAttrImpl,
32
  GenClangAttrList,
33
  GenClangAttrSubjectMatchRuleList,
34
  GenClangAttrPCHRead,
35
  GenClangAttrPCHWrite,
36
  GenClangAttrHasAttributeImpl,
37
  GenClangAttrSpellingListIndex,
38
  GenClangAttrASTVisitor,
39
  GenClangAttrTemplateInstantiate,
40
  GenClangAttrParsedAttrList,
41
  GenClangAttrParsedAttrImpl,
42
  GenClangAttrParsedAttrKinds,
43
  GenClangAttrTextNodeDump,
44
  GenClangAttrNodeTraverse,
45
  GenClangBasicReader,
46
  GenClangBasicWriter,
47
  GenClangDiagsDefs,
48
  GenClangDiagGroups,
49
  GenClangDiagsIndexName,
50
  GenClangCommentNodes,
51
  GenClangDeclNodes,
52
  GenClangStmtNodes,
53
  GenClangTypeNodes,
54
  GenClangTypeReader,
55
  GenClangTypeWriter,
56
  GenClangOpcodes,
57
  GenClangSACheckers,
58
  GenClangSyntaxNodeList,
59
  GenClangSyntaxNodeClasses,
60
  GenClangCommentHTMLTags,
61
  GenClangCommentHTMLTagsProperties,
62
  GenClangCommentHTMLNamedCharacterReferences,
63
  GenClangCommentCommandInfo,
64
  GenClangCommentCommandList,
65
  GenClangOpenCLBuiltins,
66
  GenArmNeon,
67
  GenArmFP16,
68
  GenArmBF16,
69
  GenArmNeonSema,
70
  GenArmNeonTest,
71
  GenArmMveHeader,
72
  GenArmMveBuiltinDef,
73
  GenArmMveBuiltinSema,
74
  GenArmMveBuiltinCG,
75
  GenArmMveBuiltinAliases,
76
  GenArmSveHeader,
77
  GenArmSveBuiltins,
78
  GenArmSveBuiltinCG,
79
  GenArmSveTypeFlags,
80
  GenArmSveRangeChecks,
81
  GenArmCdeHeader,
82
  GenArmCdeBuiltinDef,
83
  GenArmCdeBuiltinSema,
84
  GenArmCdeBuiltinCG,
85
  GenArmCdeBuiltinAliases,
86
  GenAttrDocs,
87
  GenDiagDocs,
88
  GenOptDocs,
89
  GenDataCollectors,
90
  GenTestPragmaAttributeSupportedAttributes
91
};
92
93
namespace {
94
cl::opt<ActionType> Action(
95
    cl::desc("Action to perform:"),
96
    cl::values(
97
        clEnumValN(PrintRecords, "print-records",
98
                   "Print all records to stdout (default)"),
99
        clEnumValN(DumpJSON, "dump-json",
100
                   "Dump all records as machine-readable JSON"),
101
        clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes",
102
                   "Generate clang attribute clases"),
103
        clEnumValN(GenClangAttrParserStringSwitches,
104
                   "gen-clang-attr-parser-string-switches",
105
                   "Generate all parser-related attribute string switches"),
106
        clEnumValN(GenClangAttrSubjectMatchRulesParserStringSwitches,
107
                   "gen-clang-attr-subject-match-rules-parser-string-switches",
108
                   "Generate all parser-related attribute subject match rule"
109
                   "string switches"),
110
        clEnumValN(GenClangAttrImpl, "gen-clang-attr-impl",
111
                   "Generate clang attribute implementations"),
112
        clEnumValN(GenClangAttrList, "gen-clang-attr-list",
113
                   "Generate a clang attribute list"),
114
        clEnumValN(GenClangAttrSubjectMatchRuleList,
115
                   "gen-clang-attr-subject-match-rule-list",
116
                   "Generate a clang attribute subject match rule list"),
117
        clEnumValN(GenClangAttrPCHRead, "gen-clang-attr-pch-read",
118
                   "Generate clang PCH attribute reader"),
119
        clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
120
                   "Generate clang PCH attribute writer"),
121
        clEnumValN(GenClangAttrHasAttributeImpl,
122
                   "gen-clang-attr-has-attribute-impl",
123
                   "Generate a clang attribute spelling list"),
124
        clEnumValN(GenClangAttrSpellingListIndex,
125
                   "gen-clang-attr-spelling-index",
126
                   "Generate a clang attribute spelling index"),
127
        clEnumValN(GenClangAttrASTVisitor, "gen-clang-attr-ast-visitor",
128
                   "Generate a recursive AST visitor for clang attributes"),
129
        clEnumValN(GenClangAttrTemplateInstantiate,
130
                   "gen-clang-attr-template-instantiate",
131
                   "Generate a clang template instantiate code"),
132
        clEnumValN(GenClangAttrParsedAttrList,
133
                   "gen-clang-attr-parsed-attr-list",
134
                   "Generate a clang parsed attribute list"),
135
        clEnumValN(GenClangAttrParsedAttrImpl,
136
                   "gen-clang-attr-parsed-attr-impl",
137
                   "Generate the clang parsed attribute helpers"),
138
        clEnumValN(GenClangAttrParsedAttrKinds,
139
                   "gen-clang-attr-parsed-attr-kinds",
140
                   "Generate a clang parsed attribute kinds"),
141
        clEnumValN(GenClangAttrTextNodeDump, "gen-clang-attr-text-node-dump",
142
                   "Generate clang attribute text node dumper"),
143
        clEnumValN(GenClangAttrNodeTraverse, "gen-clang-attr-node-traverse",
144
                   "Generate clang attribute traverser"),
145
        clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
146
                   "Generate Clang diagnostics definitions"),
147
        clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
148
                   "Generate Clang diagnostic groups"),
149
        clEnumValN(GenClangDiagsIndexName, "gen-clang-diags-index-name",
150
                   "Generate Clang diagnostic name index"),
151
        clEnumValN(GenClangBasicReader, "gen-clang-basic-reader",
152
                   "Generate Clang BasicReader classes"),
153
        clEnumValN(GenClangBasicWriter, "gen-clang-basic-writer",
154
                   "Generate Clang BasicWriter classes"),
155
        clEnumValN(GenClangCommentNodes, "gen-clang-comment-nodes",
156
                   "Generate Clang AST comment nodes"),
157
        clEnumValN(GenClangDeclNodes, "gen-clang-decl-nodes",
158
                   "Generate Clang AST declaration nodes"),
159
        clEnumValN(GenClangStmtNodes, "gen-clang-stmt-nodes",
160
                   "Generate Clang AST statement nodes"),
161
        clEnumValN(GenClangTypeNodes, "gen-clang-type-nodes",
162
                   "Generate Clang AST type nodes"),
163
        clEnumValN(GenClangTypeReader, "gen-clang-type-reader",
164
                   "Generate Clang AbstractTypeReader class"),
165
        clEnumValN(GenClangTypeWriter, "gen-clang-type-writer",
166
                   "Generate Clang AbstractTypeWriter class"),
167
        clEnumValN(GenClangOpcodes, "gen-clang-opcodes",
168
                   "Generate Clang constexpr interpreter opcodes"),
169
        clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers",
170
                   "Generate Clang Static Analyzer checkers"),
171
        clEnumValN(GenClangSyntaxNodeList, "gen-clang-syntax-node-list",
172
                   "Generate list of Clang Syntax Tree node types"),
173
        clEnumValN(GenClangSyntaxNodeClasses, "gen-clang-syntax-node-classes",
174
                   "Generate definitions of Clang Syntax Tree node clasess"),
175
        clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
176
                   "Generate efficient matchers for HTML tag "
177
                   "names that are used in documentation comments"),
178
        clEnumValN(GenClangCommentHTMLTagsProperties,
179
                   "gen-clang-comment-html-tags-properties",
180
                   "Generate efficient matchers for HTML tag "
181
                   "properties"),
182
        clEnumValN(GenClangCommentHTMLNamedCharacterReferences,
183
                   "gen-clang-comment-html-named-character-references",
184
                   "Generate function to translate named character "
185
                   "references to UTF-8 sequences"),
186
        clEnumValN(GenClangCommentCommandInfo, "gen-clang-comment-command-info",
187
                   "Generate command properties for commands that "
188
                   "are used in documentation comments"),
189
        clEnumValN(GenClangCommentCommandList, "gen-clang-comment-command-list",
190
                   "Generate list of commands that are used in "
191
                   "documentation comments"),
192
        clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
193
                   "Generate OpenCL builtin declaration handlers"),
194
        clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
195
        clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
196
        clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
197
        clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
198
                   "Generate ARM NEON sema support for clang"),
199
        clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
200
                   "Generate ARM NEON tests for clang"),
201
        clEnumValN(GenArmSveHeader, "gen-arm-sve-header",
202
                   "Generate arm_sve.h for clang"),
203
        clEnumValN(GenArmSveBuiltins, "gen-arm-sve-builtins",
204
                   "Generate arm_sve_builtins.inc for clang"),
205
        clEnumValN(GenArmSveBuiltinCG, "gen-arm-sve-builtin-codegen",
206
                   "Generate arm_sve_builtin_cg_map.inc for clang"),
207
        clEnumValN(GenArmSveTypeFlags, "gen-arm-sve-typeflags",
208
                   "Generate arm_sve_typeflags.inc for clang"),
209
        clEnumValN(GenArmSveRangeChecks, "gen-arm-sve-sema-rangechecks",
210
                   "Generate arm_sve_sema_rangechecks.inc for clang"),
211
        clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
212
                   "Generate arm_mve.h for clang"),
213
        clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
214
                   "Generate ARM MVE builtin definitions for clang"),
215
        clEnumValN(GenArmMveBuiltinSema, "gen-arm-mve-builtin-sema",
216
                   "Generate ARM MVE builtin sema checks for clang"),
217
        clEnumValN(GenArmMveBuiltinCG, "gen-arm-mve-builtin-codegen",
218
                   "Generate ARM MVE builtin code-generator for clang"),
219
        clEnumValN(GenArmMveBuiltinAliases, "gen-arm-mve-builtin-aliases",
220
                   "Generate list of valid ARM MVE builtin aliases for clang"),
221
        clEnumValN(GenArmCdeHeader, "gen-arm-cde-header",
222
                   "Generate arm_cde.h for clang"),
223
        clEnumValN(GenArmCdeBuiltinDef, "gen-arm-cde-builtin-def",
224
                   "Generate ARM CDE builtin definitions for clang"),
225
        clEnumValN(GenArmCdeBuiltinSema, "gen-arm-cde-builtin-sema",
226
                   "Generate ARM CDE builtin sema checks for clang"),
227
        clEnumValN(GenArmCdeBuiltinCG, "gen-arm-cde-builtin-codegen",
228
                   "Generate ARM CDE builtin code-generator for clang"),
229
        clEnumValN(GenArmCdeBuiltinAliases, "gen-arm-cde-builtin-aliases",
230
                   "Generate list of valid ARM CDE builtin aliases for clang"),
231
        clEnumValN(GenAttrDocs, "gen-attr-docs",
232
                   "Generate attribute documentation"),
233
        clEnumValN(GenDiagDocs, "gen-diag-docs",
234
                   "Generate diagnostic documentation"),
235
        clEnumValN(GenOptDocs, "gen-opt-docs", "Generate option documentation"),
236
        clEnumValN(GenDataCollectors, "gen-clang-data-collectors",
237
                   "Generate data collectors for AST nodes"),
238
        clEnumValN(GenTestPragmaAttributeSupportedAttributes,
239
                   "gen-clang-test-pragma-attribute-supported-attributes",
240
                   "Generate a list of attributes supported by #pragma clang "
241
                   "attribute for testing purposes")));
242
243
cl::opt<std::string>
244
ClangComponent("clang-component",
245
               cl::desc("Only use warnings from specified component"),
246
               cl::value_desc("component"), cl::Hidden);
247
248
6
bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
249
6
  switch (Action) {
250
0
  case PrintRecords:
251
0
    OS << Records;           // No argument, dump all contents
252
0
    break;
253
0
  case DumpJSON:
254
0
    EmitJSON(Records, OS);
255
0
    break;
256
0
  case GenClangAttrClasses:
257
0
    EmitClangAttrClass(Records, OS);
258
0
    break;
259
0
  case GenClangAttrParserStringSwitches:
260
0
    EmitClangAttrParserStringSwitches(Records, OS);
261
0
    break;
262
0
  case GenClangAttrSubjectMatchRulesParserStringSwitches:
263
0
    EmitClangAttrSubjectMatchRulesParserStringSwitches(Records, OS);
264
0
    break;
265
0
  case GenClangAttrImpl:
266
0
    EmitClangAttrImpl(Records, OS);
267
0
    break;
268
0
  case GenClangAttrList:
269
0
    EmitClangAttrList(Records, OS);
270
0
    break;
271
0
  case GenClangAttrSubjectMatchRuleList:
272
0
    EmitClangAttrSubjectMatchRuleList(Records, OS);
273
0
    break;
274
0
  case GenClangAttrPCHRead:
275
0
    EmitClangAttrPCHRead(Records, OS);
276
0
    break;
277
0
  case GenClangAttrPCHWrite:
278
0
    EmitClangAttrPCHWrite(Records, OS);
279
0
    break;
280
0
  case GenClangAttrHasAttributeImpl:
281
0
    EmitClangAttrHasAttrImpl(Records, OS);
282
0
    break;
283
0
  case GenClangAttrSpellingListIndex:
284
0
    EmitClangAttrSpellingListIndex(Records, OS);
285
0
    break;
286
0
  case GenClangAttrASTVisitor:
287
0
    EmitClangAttrASTVisitor(Records, OS);
288
0
    break;
289
0
  case GenClangAttrTemplateInstantiate:
290
0
    EmitClangAttrTemplateInstantiate(Records, OS);
291
0
    break;
292
0
  case GenClangAttrParsedAttrList:
293
0
    EmitClangAttrParsedAttrList(Records, OS);
294
0
    break;
295
0
  case GenClangAttrParsedAttrImpl:
296
0
    EmitClangAttrParsedAttrImpl(Records, OS);
297
0
    break;
298
0
  case GenClangAttrParsedAttrKinds:
299
0
    EmitClangAttrParsedAttrKinds(Records, OS);
300
0
    break;
301
0
  case GenClangAttrTextNodeDump:
302
0
    EmitClangAttrTextNodeDump(Records, OS);
303
0
    break;
304
0
  case GenClangAttrNodeTraverse:
305
0
    EmitClangAttrNodeTraverse(Records, OS);
306
0
    break;
307
2
  case GenClangDiagsDefs:
308
2
    EmitClangDiagsDefs(Records, OS, ClangComponent);
309
2
    break;
310
2
  case GenClangDiagGroups:
311
2
    EmitClangDiagGroups(Records, OS);
312
2
    break;
313
0
  case GenClangDiagsIndexName:
314
0
    EmitClangDiagsIndexName(Records, OS);
315
0
    break;
316
0
  case GenClangCommentNodes:
317
0
    EmitClangASTNodes(Records, OS, CommentNodeClassName, "");
318
0
    break;
319
0
  case GenClangDeclNodes:
320
0
    EmitClangASTNodes(Records, OS, DeclNodeClassName, "Decl");
321
0
    EmitClangDeclContext(Records, OS);
322
0
    break;
323
0
  case GenClangStmtNodes:
324
0
    EmitClangASTNodes(Records, OS, StmtNodeClassName, "");
325
0
    break;
326
0
  case GenClangTypeNodes:
327
0
    EmitClangTypeNodes(Records, OS);
328
0
    break;
329
0
  case GenClangTypeReader:
330
0
    EmitClangTypeReader(Records, OS);
331
0
    break;
332
0
  case GenClangTypeWriter:
333
0
    EmitClangTypeWriter(Records, OS);
334
0
    break;
335
0
  case GenClangBasicReader:
336
0
    EmitClangBasicReader(Records, OS);
337
0
    break;
338
0
  case GenClangBasicWriter:
339
0
    EmitClangBasicWriter(Records, OS);
340
0
    break;
341
0
  case GenClangOpcodes:
342
0
    EmitClangOpcodes(Records, OS);
343
0
    break;
344
0
  case GenClangSACheckers:
345
0
    EmitClangSACheckers(Records, OS);
346
0
    break;
347
0
  case GenClangCommentHTMLTags:
348
0
    EmitClangCommentHTMLTags(Records, OS);
349
0
    break;
350
0
  case GenClangCommentHTMLTagsProperties:
351
0
    EmitClangCommentHTMLTagsProperties(Records, OS);
352
0
    break;
353
0
  case GenClangCommentHTMLNamedCharacterReferences:
354
0
    EmitClangCommentHTMLNamedCharacterReferences(Records, OS);
355
0
    break;
356
0
  case GenClangCommentCommandInfo:
357
0
    EmitClangCommentCommandInfo(Records, OS);
358
0
    break;
359
0
  case GenClangCommentCommandList:
360
0
    EmitClangCommentCommandList(Records, OS);
361
0
    break;
362
0
  case GenClangOpenCLBuiltins:
363
0
    EmitClangOpenCLBuiltins(Records, OS);
364
0
    break;
365
0
  case GenClangSyntaxNodeList:
366
0
    EmitClangSyntaxNodeList(Records, OS);
367
0
    break;
368
0
  case GenClangSyntaxNodeClasses:
369
0
    EmitClangSyntaxNodeClasses(Records, OS);
370
0
    break;
371
0
  case GenArmNeon:
372
0
    EmitNeon(Records, OS);
373
0
    break;
374
0
  case GenArmFP16:
375
0
    EmitFP16(Records, OS);
376
0
    break;
377
0
  case GenArmBF16:
378
0
    EmitBF16(Records, OS);
379
0
    break;
380
0
  case GenArmNeonSema:
381
0
    EmitNeonSema(Records, OS);
382
0
    break;
383
0
  case GenArmNeonTest:
384
0
    EmitNeonTest(Records, OS);
385
0
    break;
386
0
  case GenArmMveHeader:
387
0
    EmitMveHeader(Records, OS);
388
0
    break;
389
0
  case GenArmMveBuiltinDef:
390
0
    EmitMveBuiltinDef(Records, OS);
391
0
    break;
392
0
  case GenArmMveBuiltinSema:
393
0
    EmitMveBuiltinSema(Records, OS);
394
0
    break;
395
0
  case GenArmMveBuiltinCG:
396
0
    EmitMveBuiltinCG(Records, OS);
397
0
    break;
398
0
  case GenArmMveBuiltinAliases:
399
0
    EmitMveBuiltinAliases(Records, OS);
400
0
    break;
401
0
  case GenArmSveHeader:
402
0
    EmitSveHeader(Records, OS);
403
0
    break;
404
0
  case GenArmSveBuiltins:
405
0
    EmitSveBuiltins(Records, OS);
406
0
    break;
407
0
  case GenArmSveBuiltinCG:
408
0
    EmitSveBuiltinCG(Records, OS);
409
0
    break;
410
0
  case GenArmSveTypeFlags:
411
0
    EmitSveTypeFlags(Records, OS);
412
0
    break;
413
0
  case GenArmSveRangeChecks:
414
0
    EmitSveRangeChecks(Records, OS);
415
0
    break;
416
0
  case GenArmCdeHeader:
417
0
    EmitCdeHeader(Records, OS);
418
0
    break;
419
0
  case GenArmCdeBuiltinDef:
420
0
    EmitCdeBuiltinDef(Records, OS);
421
0
    break;
422
0
  case GenArmCdeBuiltinSema:
423
0
    EmitCdeBuiltinSema(Records, OS);
424
0
    break;
425
0
  case GenArmCdeBuiltinCG:
426
0
    EmitCdeBuiltinCG(Records, OS);
427
0
    break;
428
0
  case GenArmCdeBuiltinAliases:
429
0
    EmitCdeBuiltinAliases(Records, OS);
430
0
    break;
431
0
  case GenAttrDocs:
432
0
    EmitClangAttrDocs(Records, OS);
433
0
    break;
434
1
  case GenDiagDocs:
435
1
    EmitClangDiagDocs(Records, OS);
436
1
    break;
437
0
  case GenOptDocs:
438
0
    EmitClangOptDocs(Records, OS);
439
0
    break;
440
0
  case GenDataCollectors:
441
0
    EmitClangDataCollectors(Records, OS);
442
0
    break;
443
1
  case GenTestPragmaAttributeSupportedAttributes:
444
1
    EmitTestPragmaAttributeSupportedAttributes(Records, OS);
445
1
    break;
446
6
  }
447
448
6
  return false;
449
6
}
450
}
451
452
20.9k
int main(int argc, char **argv) {
453
20.9k
  sys::PrintStackTraceOnErrorSignal(argv[0]);
454
20.9k
  PrettyStackTraceProgram X(argc, argv);
455
20.9k
  cl::ParseCommandLineOptions(argc, argv);
456
457
20.9k
  llvm_shutdown_obj Y;
458
459
20.9k
  return TableGenMain(argv[0], &ClangTableGenMain);
460
20.9k
}
461
462
#ifdef __has_feature
463
#if __has_feature(address_sanitizer)
464
#include <sanitizer/lsan_interface.h>
465
// Disable LeakSanitizer for this binary as it has too many leaks that are not
466
// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
467
int __lsan_is_turned_off() { return 1; }
468
#endif  // __has_feature(address_sanitizer)
469
#endif  // defined(__has_feature)