Identifying unnecessary #includes

Aleix Pol aleixpol at kde.org
Mon Mar 29 00:36:52 UTC 2010


On Mon, Mar 29, 2010 at 1:05 AM, David Nolden <zwabel at googlemail.com> wrote:

> Given the available information it would be relatively easy to do
> this, as said, all the info is there. It just needs someone to
> implement the "is this #include really needed" logic by looking at all
> the uses (given the "TopDUContext* topContext" for the file,
> recursively go through all context->childContexts(), and look at the
> contained context->uses()), and at the
> topContext->parsingEnvironmentFile()->usedMacros().
>
> I was planning for a long time to implement such a thing, but didn't
> come to it yet, and given my currently available time I won't do it in
> the close future.
>
> Also, you should be aware that this never will be 100% reliable, so
> I'm not sure whether I'd do it automatically over a whole codebase.
> I'd rather go for a menu-entry "Mark Unneeded Includes" within the
> "Code" menu, so that the user can decide by himself whether he really
> wants to remove them.
>
> --
> KDevelop-devel mailing list
> KDevelop-devel at kdevelop.org
> https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
>

Hi,
I was thinking about doing that for some time so I created a little plugin
now in playground to do so.
It's not what want yet but we can see it as a start. The main problem in
terms of the identification of these include directories is that we should
recognize the alias headers (like QString to qstring.h) and I didn't have an
idea to get to do so, maybe david will have an idea? :D
But it's a start.

Good night!
Aleix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20100329/c8df5c12/attachment.html>


More information about the KDevelop-devel mailing list