Identifying unnecessary #includes

Aleix Pol aleixpol at
Mon Mar 29 00:37:58 UTC 2010

On Mon, Mar 29, 2010 at 1:36 AM, Aleix Pol <aleixpol at> wrote:

> On Mon, Mar 29, 2010 at 1:05 AM, David Nolden <zwabel at>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
> 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

Oh btw, it's the includemanager plugin, couldn't find a better name.
And only works with the currently opened file, we can extend to the whole
project later.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the KDevelop-devel mailing list