Identifying unnecessary #includes

David Nolden zwabel at googlemail.com
Mon Mar 29 00:05:54 UTC 2010


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.




More information about the KDevelop-devel mailing list