1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

Reapply "[clang][cli] Allow users to specify a conditional to prevent parsing options with MarshallingInfo"

This reverts commit d0fa7a05 and fixes failing OptionMarshallingTest by adding the SHOULD_PARSE macro argument
This commit is contained in:
Jan Svoboda 2021-01-07 10:14:48 +01:00
parent 617f268f92
commit 88551a2c36
3 changed files with 9 additions and 3 deletions

View File

@ -101,6 +101,7 @@ class Option<list<string> prefixes, string name, OptionKind kind> {
code DefaultValue = ?; code DefaultValue = ?;
code ImpliedValue = ?; code ImpliedValue = ?;
code ImpliedCheck = "false"; code ImpliedCheck = "false";
code ShouldParse = "true";
bit ShouldAlwaysEmit = false; bit ShouldAlwaysEmit = false;
code NormalizerRetTy = ?; code NormalizerRetTy = ?;
code NormalizedValuesScope = ""; code NormalizedValuesScope = "";
@ -202,6 +203,7 @@ class MarshallingInfoBooleanFlag<code keypath, code defaultvalue, code value, co
// Mixins for additional marshalling attributes. // Mixins for additional marshalling attributes.
class ShouldParseIf<code condition> { code ShouldParse = condition; }
class AlwaysEmit { bit ShouldAlwaysEmit = true; } class AlwaysEmit { bit ShouldAlwaysEmit = true; }
class Normalizer<code normalizer> { code Normalizer = normalizer; } class Normalizer<code normalizer> { code Normalizer = normalizer; }
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; } class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }

View File

@ -18,9 +18,9 @@ struct OptionWithMarshallingInfo {
static const OptionWithMarshallingInfo MarshallingTable[] = { static const OptionWithMarshallingInfo MarshallingTable[] = {
#define OPTION_WITH_MARSHALLING( \ #define OPTION_WITH_MARSHALLING( \
PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, \ HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, \ DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
TABLE_INDEX) \ MERGER, EXTRACTOR, TABLE_INDEX) \
{NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE}, {NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
#include "Opts.inc" #include "Opts.inc"
#undef OPTION_WITH_MARSHALLING #undef OPTION_WITH_MARSHALLING

View File

@ -71,6 +71,7 @@ public:
StringRef NormalizedValuesScope; StringRef NormalizedValuesScope;
StringRef ImpliedCheck; StringRef ImpliedCheck;
StringRef ImpliedValue; StringRef ImpliedValue;
StringRef ShouldParse;
StringRef Normalizer; StringRef Normalizer;
StringRef Denormalizer; StringRef Denormalizer;
StringRef ValueMerger; StringRef ValueMerger;
@ -102,6 +103,8 @@ struct SimpleEnumValueTable {
void emit(raw_ostream &OS) const { void emit(raw_ostream &OS) const {
write_cstring(OS, StringRef(getOptionSpelling(R))); write_cstring(OS, StringRef(getOptionSpelling(R)));
OS << ", "; OS << ", ";
OS << ShouldParse;
OS << ", ";
OS << ShouldAlwaysEmit; OS << ShouldAlwaysEmit;
OS << ", "; OS << ", ";
OS << KeyPath; OS << KeyPath;
@ -167,6 +170,7 @@ static MarshallingInfo createMarshallingInfo(const Record &R) {
Ret.ImpliedValue = Ret.ImpliedValue =
R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret.DefaultValue); R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret.DefaultValue);
Ret.ShouldParse = R.getValueAsString("ShouldParse");
Ret.Normalizer = R.getValueAsString("Normalizer"); Ret.Normalizer = R.getValueAsString("Normalizer");
Ret.Denormalizer = R.getValueAsString("Denormalizer"); Ret.Denormalizer = R.getValueAsString("Denormalizer");
Ret.ValueMerger = R.getValueAsString("ValueMerger"); Ret.ValueMerger = R.getValueAsString("ValueMerger");