aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen/LLDBTableGen.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-25 20:29:50 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-25 20:29:50 +0000
commitfdb00c4408990a0a63ef7f496d809ce59f263bc5 (patch)
tree9bc380d17aeef3f6c1ac73bb7690ec16d1f04ae0 /utils/TableGen/LLDBTableGen.cpp
parent5f29bb8a675e8f96452b632e7129113f7dec850e (diff)
downloadsrc-fdb00c4408990a0a63ef7f496d809ce59f263bc5.tar.gz
src-fdb00c4408990a0a63ef7f496d809ce59f263bc5.zip
Import missed sources for lldb-specific TableGen tool.vendor/lldb/lldb-trunk-r366426
Notes
Notes: svn path=/vendor/lldb/dist/; revision=351489 svn path=/vendor/lldb/lldb-trunk-r366426/; revision=351491; tag=vendor/lldb/lldb-trunk-r366426
Diffstat (limited to 'utils/TableGen/LLDBTableGen.cpp')
-rw-r--r--utils/TableGen/LLDBTableGen.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/utils/TableGen/LLDBTableGen.cpp b/utils/TableGen/LLDBTableGen.cpp
new file mode 100644
index 000000000000..9325fe038561
--- /dev/null
+++ b/utils/TableGen/LLDBTableGen.cpp
@@ -0,0 +1,71 @@
+//===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the main function for Clang's TableGen.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenBackends.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 lldb_private;
+
+enum ActionType {
+ PrintRecords,
+ DumpJSON,
+ GenOptionDefs,
+};
+
+static 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(GenOptionDefs, "gen-lldb-option-defs",
+ "Generate clang attribute clases")));
+
+static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
+ switch (Action) {
+ case PrintRecords:
+ OS << Records; // No argument, dump all contents
+ break;
+ case DumpJSON:
+ EmitJSON(Records, OS);
+ break;
+ case GenOptionDefs:
+ EmitOptionDefs(Records, OS);
+ break;
+ }
+ return false;
+}
+
+int main(int argc, char **argv) {
+ sys::PrintStackTraceOnErrorSignal(argv[0]);
+ PrettyStackTraceProgram X(argc, argv);
+ cl::ParseCommandLineOptions(argc, argv);
+
+ llvm_shutdown_obj Y;
+
+ return TableGenMain(argv[0], &LLDBTableGenMain);
+}
+
+#ifdef __has_feature
+#if __has_feature(address_sanitizer)
+#include <sanitizer/lsan_interface.h>
+// Disable LeakSanitizer for this binary as it has too many leaks that are not
+// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
+int __lsan_is_turned_off() { return 1; }
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)