@@ -81,6 +81,8 @@ ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
8181
8282using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>;
8383using UsageWarnings = EnumSet<UsageWarning, UsageWarning_enumSize>;
84+ using Warning = std::variant<LanguageFeature, UsageWarning>;
85+ using WarningAndEnabled = std::pair<Warning, bool >;
8486
8587class LanguageFeatureControl {
8688public:
@@ -94,6 +96,13 @@ class LanguageFeatureControl {
9496 void EnableWarning (UsageWarning w, bool yes = true ) {
9597 warnUsage_.set (w, yes);
9698 }
99+ void EnableWarning (Warning warning, bool yes = true ) {
100+ if (std::holds_alternative<LanguageFeature>(warning)) {
101+ EnableWarning (std::get<LanguageFeature>(warning), yes);
102+ } else {
103+ EnableWarning (std::get<UsageWarning>(warning), yes);
104+ }
105+ }
97106 void WarnOnAllNonstandard (bool yes = true );
98107 bool IsWarnOnAllNonstandard () const { return warnAllLanguage_; }
99108 void WarnOnAllUsage (bool yes = true );
@@ -116,9 +125,11 @@ class LanguageFeatureControl {
116125 bool ShouldWarn (LanguageFeature f) const { return warnLanguage_.test (f); }
117126 bool ShouldWarn (UsageWarning w) const { return warnUsage_.test (w); }
118127 // Cli options
128+ // Find a warning by its Cli spelling, i.e. '[no-]warning-name'.
129+ std::optional<WarningAndEnabled> FindWarning (std::string input);
119130 // Take a string from the Cli and apply it to the LanguageFeatureControl.
120131 // Return true if the option was recognized (and hence applied).
121- bool ApplyCliOption (std::string input);
132+ bool EnableWarning (std::string input);
122133 // The add and replace functions are not currently used but are provided
123134 // to allow a flexible many-to-one mapping from Cli spellings to enum values.
124135 // Taking a string by value because the functions own this string after the
0 commit comments