Skip to content

Commit 2fdde27

Browse files
committed
Move new cl::opt to lib/TableGen/Main.cpp so it always gets registered
1 parent 5bdcaef commit 2fdde27

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

llvm/include/llvm/TableGen/Main.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_TABLEGEN_MAIN_H
1414
#define LLVM_TABLEGEN_MAIN_H
1515

16+
#include "llvm/Support/CommandLine.h"
1617
#include <functional>
1718

1819
namespace llvm {
@@ -27,6 +28,10 @@ using TableGenMainFn = bool(raw_ostream &OS, const RecordKeeper &Records);
2728
int TableGenMain(const char *argv0,
2829
std::function<TableGenMainFn> MainFn = nullptr);
2930

31+
/// Controls emitting large character arrays as strings or character arrays.
32+
/// Typically set to false when building with MSVC.
33+
extern cl::opt<bool> EmitLongStrLiterals;
34+
3035
} // end namespace llvm
3136

3237
#endif // LLVM_TABLEGEN_MAIN_H

llvm/lib/TableGen/Main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ WriteIfChanged("write-if-changed", cl::desc("Only write output if it changed"));
6464
static cl::opt<bool>
6565
TimePhases("time-phases", cl::desc("Time phases of parser and backend"));
6666

67+
namespace llvm {
68+
cl::opt<bool> EmitLongStrLiterals(
69+
"long-string-literals",
70+
cl::desc("when emitting large string tables, prefer string literals over "
71+
"comma-separated char literals. This can be a readability and "
72+
"compile-time performance win, but upsets some compilers"),
73+
cl::Hidden, cl::init(true));
74+
} // end namespace llvm
75+
6776
static cl::opt<bool> NoWarnOnUnusedTemplateArgs(
6877
"no-warn-on-unused-template-args",
6978
cl::desc("Disable unused template argument warnings."));

llvm/lib/TableGen/StringToOffsetTable.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,12 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/TableGen/StringToOffsetTable.h"
10-
#include "llvm/Support/CommandLine.h"
1110
#include "llvm/Support/FormatVariadic.h"
1211
#include "llvm/Support/raw_ostream.h"
12+
#include "llvm/TableGen/Main.h"
1313

1414
using namespace llvm;
1515

16-
namespace llvm {
17-
cl::opt<bool> EmitLongStrLiterals(
18-
"long-string-literals",
19-
cl::desc("when emitting large string tables, prefer string literals over "
20-
"comma-separated char literals. This can be a readability and "
21-
"compile-time performance win, but upsets some compilers"),
22-
cl::Hidden, cl::init(true));
23-
} // end namespace llvm
24-
2516
unsigned StringToOffsetTable::GetOrAddStringOffset(StringRef Str,
2617
bool appendZero) {
2718
auto [II, Inserted] = StringOffset.insert({Str, size()});

llvm/utils/TableGen/Basic/SequenceToOffsetTable.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
#define LLVM_UTILS_TABLEGEN_BASIC_SEQUENCETOOFFSETTABLE_H
1616

1717
#include "llvm/ADT/StringExtras.h"
18-
#include "llvm/Support/CommandLine.h"
1918
#include "llvm/Support/raw_ostream.h"
19+
#include "llvm/TableGen/Main.h"
2020
#include <algorithm>
2121
#include <cassert>
2222
#include <functional>
2323
#include <map>
2424

2525
namespace llvm {
26-
extern cl::opt<bool> EmitLongStrLiterals;
2726

2827
inline void printChar(raw_ostream &OS, char C) {
2928
unsigned char UC(C);

0 commit comments

Comments
 (0)