This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, RFC] plugin to warn about surplus includes
- From: Tom Tromey <tromey at redhat dot com>
- To: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 May 2010 17:13:38 -0600
- Subject: Re: [PATCH, RFC] plugin to warn about surplus includes
- References: <20100518210546.GY14941@mx.loc>
- Reply-to: Tom Tromey <tromey at redhat dot com>
>>>>> "Bernhard" == Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> writes:
Bernhard> - should handle structs.
There are some other difficult cases.
First, don't let this discourage you :-). I think this would be a
useful feature.
I think in general you cannot actually ever tell if a header is unused
or not. Maybe it will only be used with some set of -D options, or when
some configure option is passed in. So I think users of a plugin like
this will always have to live with some "false" reporting.
A header can #define things that are used by other headers. You would
need to modify libcpp to detect this situation.
Suppose a system header which is used includes a header which is not
used. In this case, I think a warning about the inner header should be
suppressed -- users generally can't do anything about this. (There are
other worse cases like this. You might have a system header that seems
directly unused, but it is the documented way to access some set of
declarations. E.g., <stdio.h> might actually just be a bunch of
#includes.)
Tom