1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
//===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the main function for Clang's TableGen.
//
//===----------------------------------------------------------------------===//
#include "TableGenBackends.h" // Declares all backends.
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Main.h"
#include "llvm/TableGen/Record.h"
using namespace llvm;
using namespace clang;
enum ActionType {
GenClangAttrClasses,
GenClangAttrExprArgsList,
GenClangAttrImpl,
GenClangAttrList,
GenClangAttrPCHRead,
GenClangAttrPCHWrite,
GenClangAttrSpellingList,
GenClangAttrSpellingListIndex,
GenClangAttrLateParsedList,
GenClangAttrTemplateInstantiate,
GenClangAttrParsedAttrList,
GenClangAttrParsedAttrKinds,
GenClangAttrDump,
GenClangDiagsDefs,
GenClangDiagGroups,
GenClangDiagsIndexName,
GenClangCommentNodes,
GenClangDeclNodes,
GenClangStmtNodes,
GenClangSACheckers,
GenClangCommentHTMLTags,
GenClangCommentHTMLTagsProperties,
GenClangCommentHTMLNamedCharacterReferences,
GenClangCommentCommandInfo,
GenClangCommentCommandList,
GenOptParserDefs, GenOptParserImpl,
GenArmNeon,
GenArmNeonSema,
GenArmNeonTest
};
namespace {
cl::opt<ActionType>
Action(cl::desc("Action to perform:"),
cl::values(clEnumValN(GenOptParserDefs, "gen-opt-parser-defs",
"Generate option definitions"),
clEnumValN(GenOptParserImpl, "gen-opt-parser-impl",
"Generate option parser implementation"),
clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes",
"Generate clang attribute clases"),
clEnumValN(GenClangAttrExprArgsList,
"gen-clang-attr-expr-args-list",
"Generate a clang attribute expression "
"arguments list"),
clEnumValN(GenClangAttrImpl, "gen-clang-attr-impl",
"Generate clang attribute implementations"),
clEnumValN(GenClangAttrList, "gen-clang-attr-list",
"Generate a clang attribute list"),
clEnumValN(GenClangAttrPCHRead, "gen-clang-attr-pch-read",
"Generate clang PCH attribute reader"),
clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write",
"Generate clang PCH attribute writer"),
clEnumValN(GenClangAttrSpellingList,
"gen-clang-attr-spelling-list",
"Generate a clang attribute spelling list"),
clEnumValN(GenClangAttrSpellingListIndex,
"gen-clang-attr-spelling-index",
"Generate a clang attribute spelling index"),
clEnumValN(GenClangAttrLateParsedList,
"gen-clang-attr-late-parsed-list",
"Generate a clang attribute LateParsed list"),
clEnumValN(GenClangAttrTemplateInstantiate,
"gen-clang-attr-template-instantiate",
"Generate a clang template instantiate code"),
clEnumValN(GenClangAttrParsedAttrList,
"gen-clang-attr-parsed-attr-list",
"Generate a clang parsed attribute list"),
clEnumValN(GenClangAttrParsedAttrKinds,
"gen-clang-attr-parsed-attr-kinds",
"Generate a clang parsed attribute kinds"),
clEnumValN(GenClangAttrDump, "gen-clang-attr-dump",
"Generate clang attribute dumper"),
clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
"Generate Clang diagnostics definitions"),
clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
"Generate Clang diagnostic groups"),
clEnumValN(GenClangDiagsIndexName,
"gen-clang-diags-index-name",
"Generate Clang diagnostic name index"),
clEnumValN(GenClangCommentNodes, "gen-clang-comment-nodes",
"Generate Clang AST comment nodes"),
clEnumValN(GenClangDeclNodes, "gen-clang-decl-nodes",
"Generate Clang AST declaration nodes"),
clEnumValN(GenClangStmtNodes, "gen-clang-stmt-nodes",
"Generate Clang AST statement nodes"),
clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers",
"Generate Clang Static Analyzer checkers"),
clEnumValN(GenClangCommentHTMLTags,
"gen-clang-comment-html-tags",
"Generate efficient matchers for HTML tag "
"names that are used in documentation comments"),
clEnumValN(GenClangCommentHTMLTagsProperties,
"gen-clang-comment-html-tags-properties",
"Generate efficient matchers for HTML tag "
"properties"),
clEnumValN(GenClangCommentHTMLNamedCharacterReferences,
"gen-clang-comment-html-named-character-references",
"Generate function to translate named character "
"references to UTF-8 sequences"),
clEnumValN(GenClangCommentCommandInfo,
"gen-clang-comment-command-info",
"Generate command properties for commands that "
"are used in documentation comments"),
clEnumValN(GenClangCommentCommandList,
"gen-clang-comment-command-list",
"Generate list of commands that are used in "
"documentation comments"),
clEnumValN(GenArmNeon, "gen-arm-neon",
"Generate arm_neon.h for clang"),
clEnumValN(GenArmNeonSema, "gen-arm-neon-sema",
"Generate ARM NEON sema support for clang"),
clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
"Generate ARM NEON tests for clang"),
clEnumValEnd));
cl::opt<std::string>
ClangComponent("clang-component",
cl::desc("Only use warnings from specified component"),
cl::value_desc("component"), cl::Hidden);
bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
switch (Action) {
case GenClangAttrClasses:
EmitClangAttrClass(Records, OS);
break;
case GenClangAttrExprArgsList:
EmitClangAttrExprArgsList(Records, OS);
break;
case GenClangAttrImpl:
EmitClangAttrImpl(Records, OS);
break;
case GenClangAttrList:
EmitClangAttrList(Records, OS);
break;
case GenClangAttrPCHRead:
EmitClangAttrPCHRead(Records, OS);
break;
case GenClangAttrPCHWrite:
EmitClangAttrPCHWrite(Records, OS);
break;
case GenClangAttrSpellingList:
EmitClangAttrSpellingList(Records, OS);
break;
case GenClangAttrSpellingListIndex:
EmitClangAttrSpellingListIndex(Records, OS);
break;
case GenClangAttrLateParsedList:
EmitClangAttrLateParsedList(Records, OS);
break;
case GenClangAttrTemplateInstantiate:
EmitClangAttrTemplateInstantiate(Records, OS);
break;
case GenClangAttrParsedAttrList:
EmitClangAttrParsedAttrList(Records, OS);
break;
case GenClangAttrParsedAttrKinds:
EmitClangAttrParsedAttrKinds(Records, OS);
break;
case GenClangAttrDump:
EmitClangAttrDump(Records, OS);
break;
case GenClangDiagsDefs:
EmitClangDiagsDefs(Records, OS, ClangComponent);
break;
case GenClangDiagGroups:
EmitClangDiagGroups(Records, OS);
break;
case GenClangDiagsIndexName:
EmitClangDiagsIndexName(Records, OS);
break;
case GenClangCommentNodes:
EmitClangASTNodes(Records, OS, "Comment", "");
break;
case GenClangDeclNodes:
EmitClangASTNodes(Records, OS, "Decl", "Decl");
EmitClangDeclContext(Records, OS);
break;
case GenClangStmtNodes:
EmitClangASTNodes(Records, OS, "Stmt", "");
break;
case GenClangSACheckers:
EmitClangSACheckers(Records, OS);
break;
case GenClangCommentHTMLTags:
EmitClangCommentHTMLTags(Records, OS);
break;
case GenClangCommentHTMLTagsProperties:
EmitClangCommentHTMLTagsProperties(Records, OS);
break;
case GenClangCommentHTMLNamedCharacterReferences:
EmitClangCommentHTMLNamedCharacterReferences(Records, OS);
break;
case GenClangCommentCommandInfo:
EmitClangCommentCommandInfo(Records, OS);
break;
case GenClangCommentCommandList:
EmitClangCommentCommandList(Records, OS);
break;
case GenOptParserDefs:
EmitOptParser(Records, OS, true);
break;
case GenOptParserImpl:
EmitOptParser(Records, OS, false);
break;
case GenArmNeon:
EmitNeon(Records, OS);
break;
case GenArmNeonSema:
EmitNeonSema(Records, OS);
break;
case GenArmNeonTest:
EmitNeonTest(Records, OS);
break;
}
return false;
}
}
int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
return TableGenMain(argv[0], &ClangTableGenMain);
}
|