Skip to content

Commit 752f526

Browse files
[Options] Fix makeOptions after upstream Option TableGen change
Generate correct `Options.swift` from new option tablegen output format after https://reviews.llvm.org/D157029.
1 parent 45555b1 commit 752f526

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Sources/makeOptions/makeOptions.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ enum class OptionKind {
2929
JoinedOrSeparate,
3030
};
3131

32+
#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(ID_PREFIX, PREFIX, NAME, ID, KIND, \
33+
GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
34+
HELPTEXT, METAVAR, VALUES) \
35+
ID_PREFIX##ID
36+
3237
//. The IDs of each option
3338
enum class OptionID {
3439
Opt_INVALID = 0,
35-
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
36-
PARAM, HELPTEXT, METAVAR, VALUES) \
37-
Opt_##ID,
38-
40+
#define OPTION(...) LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(Opt_, __VA_ARGS__),
3941
#if __has_include("swift/Option/Options.inc")
4042
#include "swift/Option/Options.inc"
4143
#else
@@ -185,10 +187,13 @@ void forEachSpelling(const char * const *prefixes, const std::string &spelling,
185187
return;
186188
}
187189

188-
bool isAlternateSpelling = false;
190+
fn(spelling, /*isAlternateSpelling=*/false);
191+
192+
std::string defaultPrefix = std::string(*prefixes++);
189193
while (*prefixes) {
190-
fn(*prefixes++ + spelling, isAlternateSpelling);
191-
isAlternateSpelling = true;
194+
std::string altSpelling =
195+
std::string(*prefixes++) + spelling.substr(defaultPrefix.size());
196+
fn(altSpelling, /*isAlternateSpelling=*/true);
192197
}
193198
}
194199

0 commit comments

Comments
 (0)