This revision was automatically updated to reflect the committed changes. Closed by commit rGd40a0b8af771: [TableGen] [Clang] Clean up Options.td and add asserts. (authored by Paul-C-Anagnostopoulos).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101766/new/ https://reviews.llvm.org/D101766 Files: clang/include/clang/Driver/Options.td
Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -274,10 +274,10 @@ // 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 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 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 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 @@ : 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 @@ defvar flag2 = FlagDefExpanded<ApplySuffix<flag2_base, suffix>.Result, prefix, NAME, spelling_base>; - // TODO: Assert that the flags have different polarity. - // TODO: Assert that the flags have different value. - // TODO: Assert that only one of the flags can be implied. + // The flags must have different polarity, different values, and only + // one can be implied. + assert !xor(flag1.Polarity, flag2.Polarity), + "the flags must have different polarity: flag1: " # + flag1.Polarity # ", flag2: " # flag2.Polarity; + assert !ne(flag1.Value, flag2.Value), + "the flags must have different 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 @@ "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>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits