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 flags=[]> { - def f#NAME : Flag<["-"], "f"#name>, Flags, - Group, HelpText; + def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>, + Group, HelpText; def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, - Group, HelpText; + Group, HelpText; } // A boolean option which is opt-out in CC1. The negative option exists in CC1 and @@ -286,9 +286,9 @@ multiclass OptOutFFlag flags=[]> { def f#NAME : Flag<["-"], "f"#name>, Flags, - Group, HelpText; - def fno_#NAME : Flag<["-"], "fno-"#name>, Flags, - Group, HelpText; + Group, HelpText; + def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>, + Group, HelpText; } // Creates a positive and negative flags where both of them are prefixed with @@ -297,9 +297,9 @@ multiclass SimpleMFlag { def m#NAME : Flag<["-"], "m"#name>, Group, - HelpText; + HelpText; def mno_#NAME : Flag<["-"], "mno-"#name>, Group, - HelpText; + HelpText; } //===----------------------------------------------------------------------===// @@ -349,8 +349,8 @@ class ApplySuffix { FlagDef Result = FlagDef; + 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 { // 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. @@ -404,11 +404,19 @@ defvar flag2 = FlagDefExpanded.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; def flag2.RecordName : MarshalledFlagRec; @@ -1077,7 +1085,8 @@ def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Group; defm double_square_bracket_attributes : BoolFOption<"double-square-bracket-attributes", - LangOpts<"DoubleSquareBracketAttributes">, Default, + LangOpts<"DoubleSquareBracketAttributes">, + Default, PosFlag, NegFlag, BothFlags<[NoXarchOption, CC1Option], " '[[]]' attributes in all C and C++ language modes">>; @@ -1896,8 +1905,9 @@ "LangOptions::LaxVectorConversionKind::Integer", "LangOptions::LaxVectorConversionKind::All"]>, MarshallingInfoEnum, - !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, Alias, AliasArgs<["integer"]>; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group;