Skip to content

[Options] Fix makeOptions after upstream Option TableGen change #1429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions Sources/makeOptions/makeOptions.cpp
Original file line number Diff line number Diff line change
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