[clang] d40a0b8 - [TableGen] [Clang] Clean up Options.td and add asserts.
Paul C. Anagnostopoulos via cfe-commits
cfe-commits at lists.llvm.org
Thu May 6 06:34:00 PDT 2021
Author: Paul C. Anagnostopoulos
Date: 2021-05-06T09:32:25-04:00
New Revision: d40a0b8af771f9b37dd2985fc692443c0ac5473e
URL: https://github.com/llvm/llvm-project/commit/d40a0b8af771f9b37dd2985fc692443c0ac5473e
DIFF: https://github.com/llvm/llvm-project/commit/d40a0b8af771f9b37dd2985fc692443c0ac5473e.diff
LOG: [TableGen] [Clang] Clean up Options.td and add asserts.
Differential Revision: https://reviews.llvm.org/D101766
Added:
Modified:
clang/include/clang/Driver/Options.td
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index b17eb50835ff8..78cc0a4e53a5f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -274,10 +274,10 @@ class MigratorOpts<string base>
// Use this only when the option cannot be declared via BoolFOption.
multiclass OptInFFlag<string name, string pos_prefix, string neg_prefix="",
string help="", list<OptionFlag> flags=[]> {
- def f#NAME : Flag<["-"], "f"#name>, Flags<!listconcat([CC1Option], flags)>,
- Group<f_Group>, HelpText<!strconcat(pos_prefix, help)>;
+ def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>,
+ Group<f_Group>, HelpText<pos_prefix # help>;
def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<flags>,
- Group<f_Group>, HelpText<!strconcat(neg_prefix, help)>;
+ Group<f_Group>, HelpText<neg_prefix # help>;
}
// A boolean option which is opt-out in CC1. The negative option exists in CC1 and
@@ -286,9 +286,9 @@ multiclass OptInFFlag<string name, string pos_prefix, string neg_prefix="",
multiclass OptOutFFlag<string name, string pos_prefix, string neg_prefix,
string help="", list<OptionFlag> flags=[]> {
def f#NAME : Flag<["-"], "f"#name>, Flags<flags>,
- Group<f_Group>, HelpText<!strconcat(pos_prefix, help)>;
- def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<!listconcat([CC1Option], flags)>,
- Group<f_Group>, HelpText<!strconcat(neg_prefix, help)>;
+ Group<f_Group>, HelpText<pos_prefix # help>;
+ def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>,
+ Group<f_Group>, HelpText<neg_prefix # help>;
}
// Creates a positive and negative flags where both of them are prefixed with
@@ -297,9 +297,9 @@ multiclass OptOutFFlag<string name, string pos_prefix, string neg_prefix,
multiclass SimpleMFlag<string name, string pos_prefix, string neg_prefix,
string help, OptionGroup opt_group = m_Group> {
def m#NAME : Flag<["-"], "m"#name>, Group<opt_group>,
- HelpText<!strconcat(pos_prefix, help)>;
+ HelpText<pos_prefix # help>;
def mno_#NAME : Flag<["-"], "mno-"#name>, Group<opt_group>,
- HelpText<!strconcat(neg_prefix, help)>;
+ HelpText<neg_prefix # help>;
}
//===----------------------------------------------------------------------===//
@@ -349,8 +349,8 @@ class BothFlags<list<OptionFlag> option_flags, string help = ""> {
class ApplySuffix<FlagDef flag, BothFlags suffix> {
FlagDef Result
= FlagDef<flag.Polarity, flag.Value,
- !listconcat(flag.OptionFlags, suffix.OptionFlags),
- !strconcat(flag.Help, suffix.Help), flag.ImpliedBy>;
+ flag.OptionFlags # suffix.OptionFlags,
+ flag.Help # suffix.Help, flag.ImpliedBy>;
}
// Definition of the command line flag with positive spelling, e.g. "-ffoo".
@@ -368,16 +368,16 @@ class FlagDefExpanded<FlagDef flag, string prefix, string name, string spelling>
: FlagDef<flag.Polarity, flag.Value, flag.OptionFlags, flag.Help,
flag.ImpliedBy> {
// Name of the TableGen record.
- string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name;
+ string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
// Spelling of the flag.
- string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling;
+ string Spelling = prefix # !if(flag.Polarity, "", "no-") # spelling;
// Can the flag be implied by another flag?
bit CanBeImplied = !not(!empty(flag.ImpliedBy));
// C++ code that will be assigned to the keypath when the flag is present.
- code ValueAsCode = !cond(flag.Value : "true", true: "false");
+ code ValueAsCode = !if(flag.Value, "true", "false");
}
// TableGen record for a single marshalled flag.
@@ -406,11 +406,19 @@ multiclass BoolOption<string prefix = "", string spelling_base,
defvar flag2 = FlagDefExpanded<ApplySuffix<flag2_base, suffix>.Result, prefix,
NAME, spelling_base>;
- // TODO: Assert that the flags have
diff erent polarity.
- // TODO: Assert that the flags have
diff erent value.
- // TODO: Assert that only one of the flags can be implied.
+ // The flags must have
diff erent polarity,
diff erent values, and only
+ // one can be implied.
+ assert !xor(flag1.Polarity, flag2.Polarity),
+ "the flags must have
diff erent polarity: flag1: " #
+ flag1.Polarity # ", flag2: " # flag2.Polarity;
+ assert !ne(flag1.Value, flag2.Value),
+ "the flags must have
diff erent values: flag1: " #
+ flag1.Value # ", flag2: " # flag2.Value;
+ assert !not(!and(flag1.CanBeImplied, flag2.CanBeImplied)),
+ "only one of the flags can be implied: flag1: " #
+ flag1.CanBeImplied # ", flag2: " # flag2.CanBeImplied;
- defvar implied = !cond(flag1.CanBeImplied: flag1, true: flag2);
+ defvar implied = !if(flag1.CanBeImplied, flag1, flag2);
def flag1.RecordName : MarshalledFlagRec<flag1, flag2, implied, kpm, default>;
def flag2.RecordName : MarshalledFlagRec<flag2, flag1, implied, kpm, default>;
@@ -1921,8 +1929,9 @@ def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, Grou
"LangOptions::LaxVectorConversionKind::Integer",
"LangOptions::LaxVectorConversionKind::All"]>,
MarshallingInfoEnum<LangOpts<"LaxVectorConversions">,
- !strconcat(open_cl.KeyPath, " ? LangOptions::LaxVectorConversionKind::None"
- " : LangOptions::LaxVectorConversionKind::All")>;
+ open_cl.KeyPath #
+ " ? LangOptions::LaxVectorConversionKind::None" #
+ " : LangOptions::LaxVectorConversionKind::All">;
def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group<f_Group>,
Alias<flax_vector_conversions_EQ>, AliasArgs<["integer"]>;
def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group<f_Group>;
More information about the cfe-commits
mailing list