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

David Blaikie dblaikie at gmail.com
Tue Aug 9 15:28:55 PDT 2011


> I don't find it useful to number individual diagnostics, because it makes it harder to split a single diagnostic into several diagnostics further down the road. If someone has suppressed D1234, and we split that diagnostic into several, more-specific diagnostics, does suppressing D1234 still suppress those? Should it?

I wasn't necessarily suggesting numbers themselves - we could stick
with names, but mostly my question was about "should we identify each
separate diagnostic" or is "every diagnostic must be part of at least
one group" the requirement we're aiming for? In the latter case we'll
just have to be more diligent about ensuring we get the right
granularity to make this work worthwhile (that is if we're trying to
address users coming to us & asking for suppression for a particular
warning it's not going to help to tell them "you can suppress that,
but you'll be suppressing a bunch of other things you like, too")

One way we could implement "every diagnostic has an identifier" while
still implementing your idea is simply to have the names of individual
diagnostics fit in with the names of sets: So initially we have a
"foo" warning then tomorrow we realize that foo is really only the
foo-bar case & we'd like to cover foo-baz too. So we rename foo to
foo-bar and promote foo-bar up to a set that includes foo-bar and
foo-baz.

> I'd much prefer that we have a logical grouping for our warnings, so we can document warning sets together.

I think groupings make sense, too - but perhaps I don't understand the
details sufficiently. I see -Wall as a grouping, but I don't know if
-Wno-all is supported. If it is supported, then that's all we'd have -
from the broadest to the narrowest case - warning groups. Potentially
even groups of groups to make them easier to manage/document.

Then my question boils down: should we ensure that every diagnostic is
in a group of its own (in addition to any other groups) to ensure that
someone can disable any specific warning they're interested in. But I
do see your point: that two diagnostics aren't necessarily two
different warnings/problems (they might be different phrases for the
same problem) so I don't think it's terribly important that we make
standalone names/groups/sets for each diagnostic message. We just have
to make sure warning sets don't end up too large/vague.

>
>>> (2) We require all new warnings to include a -W flag the moment they are added to Clang.  We can enforce this by using diagtool in our tests (e.g., verify that the set of warnings without flags hasn't changed).
>>
>> I assume eventually this would be enforced syntactically (I don't know
>> enough about how the tblgen works to generate the diagnostic messages
>> - but would the documentation be able to be included alongside the
>> diagnostic message itself? I suppose that only works if it's a 1-1
>> mapping, otherwise you'd need some kind of grouping structure in the
>> tblgen itself such that no diagnostic could be outside a -W group.
>> That would also be awkward because each diagnostic would be in a
>> single place in the hierarchy while still possibly belonging to
>> multiple -W groups?)
>
> The documentation should go on the warning group itself.

Thinking about my original statement I realized we could potentially
invert the structure, basically: Each diagnostic must declare itself
to be part of one or more warning groups. A warning group is then just
a name and documentation & any warnings can insert themselves into it.
That way we can easily ensure all warnings are part of a group.

- David




More information about the cfe-dev mailing list