Skip to content

Commit

Permalink
[Options] Fix makeOptions after upstream Option TableGen change
Browse files Browse the repository at this point in the history
Generate correct `Options.swift` from new option tablegen output format
after https://reviews.llvm.org/D157029.
  • Loading branch information
cachemeifyoucan committed Aug 28, 2023
1 parent 45555b1 commit 752f526
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Sources/makeOptions/makeOptions.cpp
Expand Up @@ -29,13 +29,15 @@ enum class OptionKind {
JoinedOrSeparate,
};

#define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(ID_PREFIX, PREFIX, NAME, ID, KIND, \
GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
ID_PREFIX##ID

//. The IDs of each option
enum class OptionID {
Opt_INVALID = 0,
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
PARAM, HELPTEXT, METAVAR, VALUES) \
Opt_##ID,

#define OPTION(...) LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(Opt_, __VA_ARGS__),
#if __has_include("swift/Option/Options.inc")
#include "swift/Option/Options.inc"
#else
Expand Down Expand Up @@ -185,10 +187,13 @@ void forEachSpelling(const char * const *prefixes, const std::string &spelling,
return;
}

bool isAlternateSpelling = false;
fn(spelling, /*isAlternateSpelling=*/false);

std::string defaultPrefix = std::string(*prefixes++);
while (*prefixes) {
fn(*prefixes++ + spelling, isAlternateSpelling);
isAlternateSpelling = true;
std::string altSpelling =
std::string(*prefixes++) + spelling.substr(defaultPrefix.size());
fn(altSpelling, /*isAlternateSpelling=*/true);
}
}

Expand Down

0 comments on commit 752f526

Please sign in to comment.