1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +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 ImpliedValue = ?;
code ImpliedCheck = "false";
code ShouldParse = "true";
bit ShouldAlwaysEmit = false;
code NormalizerRetTy = ?;
code NormalizedValuesScope = "";
@ -202,6 +203,7 @@ class MarshallingInfoBooleanFlag<code keypath, code defaultvalue, code value, co
// Mixins for additional marshalling attributes.
class ShouldParseIf<code condition> { code ShouldParse = condition; }
class AlwaysEmit { bit ShouldAlwaysEmit = true; }
class Normalizer<code normalizer> { code Normalizer = normalizer; }
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }

View File

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

View File

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