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
|
//===- 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 "ClangASTNodesEmitter.h"
#include "ClangAttrEmitter.h"
#include "ClangDiagnosticsEmitter.h"
#include "ClangSACheckersEmitter.h"
#include "NeonEmitter.h"
#include "OptParserEmitter.h"
#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"
#include "llvm/TableGen/TableGenAction.h"
using namespace llvm;
enum ActionType {
GenClangAttrClasses,
GenClangAttrImpl,
GenClangAttrList,
GenClangAttrPCHRead,
GenClangAttrPCHWrite,
GenClangAttrSpellingList,
GenClangAttrLateParsedList,
GenClangAttrTemplateInstantiate,
GenClangAttrParsedAttrList,
GenClangAttrParsedAttrKinds,
GenClangDiagsDefs,
GenClangDiagGroups,
GenClangDiagsIndexName,
GenClangDeclNodes,
GenClangStmtNodes,
GenClangSACheckers,
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(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(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(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(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(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);
class ClangTableGenAction : public TableGenAction {
public:
bool operator()(raw_ostream &OS, RecordKeeper &Records) {
switch (Action) {
case GenClangAttrClasses:
ClangAttrClassEmitter(Records).run(OS);
break;
case GenClangAttrImpl:
ClangAttrImplEmitter(Records).run(OS);
break;
case GenClangAttrList:
ClangAttrListEmitter(Records).run(OS);
break;
case GenClangAttrPCHRead:
ClangAttrPCHReadEmitter(Records).run(OS);
break;
case GenClangAttrPCHWrite:
ClangAttrPCHWriteEmitter(Records).run(OS);
break;
case GenClangAttrSpellingList:
ClangAttrSpellingListEmitter(Records).run(OS);
break;
case GenClangAttrLateParsedList:
ClangAttrLateParsedListEmitter(Records).run(OS);
break;
case GenClangAttrTemplateInstantiate:
ClangAttrTemplateInstantiateEmitter(Records).run(OS);
break;
case GenClangAttrParsedAttrList:
ClangAttrParsedAttrListEmitter(Records).run(OS);
break;
case GenClangAttrParsedAttrKinds:
ClangAttrParsedAttrKindsEmitter(Records).run(OS);
break;
case GenClangDiagsDefs:
ClangDiagsDefsEmitter(Records, ClangComponent).run(OS);
break;
case GenClangDiagGroups:
ClangDiagGroupsEmitter(Records).run(OS);
break;
case GenClangDiagsIndexName:
ClangDiagsIndexNameEmitter(Records).run(OS);
break;
case GenClangDeclNodes:
ClangASTNodesEmitter(Records, "Decl", "Decl").run(OS);
ClangDeclContextEmitter(Records).run(OS);
break;
case GenClangStmtNodes:
ClangASTNodesEmitter(Records, "Stmt", "").run(OS);
break;
case GenClangSACheckers:
ClangSACheckersEmitter(Records).run(OS);
break;
case GenOptParserDefs:
OptParserEmitter(Records, true).run(OS);
break;
case GenOptParserImpl:
OptParserEmitter(Records, false).run(OS);
break;
case GenArmNeon:
NeonEmitter(Records).run(OS);
break;
case GenArmNeonSema:
NeonEmitter(Records).runHeader(OS);
break;
case GenArmNeonTest:
NeonEmitter(Records).runTests(OS);
break;
}
return false;
}
};
}
int main(int argc, char **argv) {
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
ClangTableGenAction Action;
return TableGenMain(argv[0], Action);
}
|