[cfe-dev] proposal: every warning should have a -W flag

Ted Kremenek kremenek at apple.com
Wed Aug 10 09:10:08 PDT 2011


On Aug 9, 2011, at 10:44 PM, David Blaikie wrote:

>> All of our diagnostics have unique tablegen entries, so getting unique names
>> for -W flags might not be that hard.  When one looks at the .td files, many
>> of the diagnostic names directly correspond to the -W flag.
> 
> Oh, of course. So would it be worth just making every diagnostic its
> own flag by definition, using the tablegen name for the -W flag?

I don't think so, or at least I wouldn't make it automatic.  Some diagnostics are just variants of basically the same thing, or logically part of a single warning.  For example, consider the different format string diagnostics:

def warn_printf_insufficient_data_args : Warning<
  "more '%%' conversions than data arguments">, InGroup<Format>;
def warn_format_invalid_conversion : Warning<
  "invalid conversion specifier '%0'">, InGroup<Format>;

and so on.

Is there real value in placing each of these under a separate flag?  In the general case, I don't think so, but where it makes sense it seems reasonable to break them down into separate -W flags (which we do in some cases for format string warnings).

> 
>> I was specifically proposing that…
>> (a) every warning is part of a group
>> and
>> (b) every group that contains a warning that can only be activated by that group maps to a -W flag
> 
> Does LLVM have the concept of groups that don't have an associated -W
> flag? what are they for?

That's a good point.  I don't think one can define a warning group without an associated flag.  Groups, however, can contain other groups, so when we report warnings we include the flag with the most precise coverage.



More information about the cfe-dev mailing list