diff options
author | Simon Tatham <simon.tatham@arm.com> | 2018-08-22 09:20:39 +0000 |
---|---|---|
committer | Simon Tatham <simon.tatham@arm.com> | 2018-08-22 09:20:39 +0000 |
commit | b092da8c95885cf86edcc1bc7679c5f8fd353e8b (patch) | |
tree | 71320fc62130e3f7a5e0c70ab2d9747891e83b85 /clang/utils/TableGen/TableGen.cpp | |
parent | d764c1b656321d8742ab0436c26e8a160929d847 (diff) | |
download | bcm5719-llvm-b092da8c95885cf86edcc1bc7679c5f8fd353e8b.tar.gz bcm5719-llvm-b092da8c95885cf86edcc1bc7679c5f8fd353e8b.zip |
[clang-tblgen] Add -print-records and -dump-json modes.
Currently, if clang-tblgen is run without a mode option, it defaults
to the first mode in its 'enum Action', which happens to be
-gen-clang-attr-classes. I think it makes more sense for it to behave
the same way as llvm-tblgen, i.e. print a diagnostic dump if it's not
given any more specific instructions.
I've also added the same -dump-json that llvm-tblgen supports. This
means any tblgen command line (whether llvm- or clang-) can be
mechanically turned into one that processes the same input into JSON.
Reviewers: nhaehnle
Reviewed By: nhaehnle
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D50771
llvm-svn: 340390
Diffstat (limited to 'clang/utils/TableGen/TableGen.cpp')
-rw-r--r-- | clang/utils/TableGen/TableGen.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/utils/TableGen/TableGen.cpp b/clang/utils/TableGen/TableGen.cpp index a2ba131628f..c02fa3d170c 100644 --- a/clang/utils/TableGen/TableGen.cpp +++ b/clang/utils/TableGen/TableGen.cpp @@ -23,6 +23,8 @@ using namespace llvm; using namespace clang; enum ActionType { + PrintRecords, + DumpJSON, GenClangAttrClasses, GenClangAttrParserStringSwitches, GenClangAttrSubjectMatchRulesParserStringSwitches, @@ -66,6 +68,10 @@ namespace { cl::opt<ActionType> Action( cl::desc("Action to perform:"), cl::values( + clEnumValN(PrintRecords, "print-records", + "Print all records to stdout (default)"), + clEnumValN(DumpJSON, "dump-json", + "Dump all records as machine-readable JSON"), clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes", "Generate clang attribute clases"), clEnumValN(GenClangAttrParserStringSwitches, @@ -164,6 +170,12 @@ ClangComponent("clang-component", bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) { switch (Action) { + case PrintRecords: + OS << Records; // No argument, dump all contents + break; + case DumpJSON: + EmitJSON(Records, OS); + break; case GenClangAttrClasses: EmitClangAttrClass(Records, OS); break; |