1 //===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file contains the main function for Clang's TableGen.
11 //===----------------------------------------------------------------------===//
13 #include "LLDBTableGenBackends.h" // Declares all backends.
14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/PrettyStackTrace.h"
16 #include "llvm/Support/Signals.h"
17 #include "llvm/TableGen/Error.h"
18 #include "llvm/TableGen/Main.h"
19 #include "llvm/TableGen/Record.h"
22 using namespace lldb_private;
30 static cl::opt<ActionType>
31 Action(cl::desc("Action to perform:"),
32 cl::values(clEnumValN(PrintRecords, "print-records",
33 "Print all records to stdout (default)"),
34 clEnumValN(DumpJSON, "dump-json",
35 "Dump all records as machine-readable JSON"),
36 clEnumValN(GenOptionDefs, "gen-lldb-option-defs",
37 "Generate clang attribute clases")));
39 static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
42 OS << Records; // No argument, dump all contents
45 EmitJSON(Records, OS);
48 EmitOptionDefs(Records, OS);
54 int main(int argc, char **argv) {
55 sys::PrintStackTraceOnErrorSignal(argv[0]);
56 PrettyStackTraceProgram X(argc, argv);
57 cl::ParseCommandLineOptions(argc, argv);
61 return TableGenMain(argv[0], &LLDBTableGenMain);
65 #if __has_feature(address_sanitizer)
66 #include <sanitizer/lsan_interface.h>
67 // Disable LeakSanitizer for this binary as it has too many leaks that are not
68 // very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
69 int __lsan_is_turned_off() { return 1; }
70 #endif // __has_feature(address_sanitizer)
71 #endif // defined(__has_feature)