]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/utils/TableGen/LLDBTableGen.cpp
Merge missed sources for lldb-specific TableGen tool.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / utils / TableGen / LLDBTableGen.cpp
1 //===- TableGen.cpp - Top-Level TableGen implementation for Clang ---------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the main function for Clang's TableGen.
10 //
11 //===----------------------------------------------------------------------===//
12
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"
20
21 using namespace llvm;
22 using namespace lldb_private;
23
24 enum ActionType {
25   PrintRecords,
26   DumpJSON,
27   GenOptionDefs,
28 };
29
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")));
38
39 static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
40   switch (Action) {
41   case PrintRecords:
42     OS << Records; // No argument, dump all contents
43     break;
44   case DumpJSON:
45     EmitJSON(Records, OS);
46     break;
47   case GenOptionDefs:
48     EmitOptionDefs(Records, OS);
49     break;
50   }
51   return false;
52 }
53
54 int main(int argc, char **argv) {
55   sys::PrintStackTraceOnErrorSignal(argv[0]);
56   PrettyStackTraceProgram X(argc, argv);
57   cl::ParseCommandLineOptions(argc, argv);
58
59   llvm_shutdown_obj Y;
60
61   return TableGenMain(argv[0], &LLDBTableGenMain);
62 }
63
64 #ifdef __has_feature
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)