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

Douglas Gregor dgregor at apple.com
Tue Aug 9 15:10:19 PDT 2011


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

>> (1) We aim to gradually put all existing warnings under a -W flag.  Multiple (related) warnings can be placed under the same -W flag (as they are often done now), but the main idea is to allow users to control these warnings.
> 
> Is it worth considering whether they should all be under separate
> flags (eg: VC numbers each diagnostic uniquely - the numbers are a bit
> annoying, but it does make finding documentation/discussions on the
> issues relatively easy & I can imagine we might end up with some
> difficulty uniquely naming certain diagnostics)? I suppose I could see
> the benefit of two technically distinct diagnostics being grouped
> under the same name because they're different phrasings of the same
> problem. At which point it's just a policy/semantic thing where we try
> not to group things that aren't really tightly related - fuzzier to
> keep track of, but possibly the right thing to do.

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'd much prefer that we have a logical grouping for our warnings, so we can document warning sets together.

>> (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.

	- Doug



More information about the cfe-dev mailing list