Coverage Report

Created: 2020-09-19 12:23

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