Kaydet (Commit) cee2e455 authored tarafından Miklos Vajna's avatar Miklos Vajna

find-unneded-includes: don't suggest removal of fwd decls

Removal of those have to be decided manually:

1) If it would be removed to be replaced with an include, that's bad.

2) If the fwd decls is truly unused, that's good.

Focus on the mechanical part: removal of includes which are unused, and
where removal doesn't introduce a transitive dependency.

Verified that e.g. writerfilter/source/dmapper/DomainMapper.cxx reports
no removals now, but including e.g. filter/msfilter/rtfutil.hxx in
either writerfilter/source/dmapper/DomainMapper.cxx or
writerfilter/source/dmapper/DomainMapper.hxx triggers a removal hint.

Change-Id: I4c359318113ccba421a125984e23c9778567ea4e
Reviewed-on: https://gerrit.libreoffice.org/73240Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 13da1c79
......@@ -186,24 +186,16 @@ def processIWYUOutput(iwyuOutput, moduleRules):
if inRemove:
match = re.match("- #include (.*) // lines (.*)-.*", line)
if match:
# Only suggest removals for now. Removing fwd decls is more complex: they may be
# indeed unused or they may removed to be replaced with an include. And we want to
# avoid the later.
include = unwrapInclude(match.group(1))
lineno = match.group(2)
if not ignoreRemoval(include, toAdd, currentFileName, moduleRules):
toRemove.append("%s:%s: %s" % (currentFileName, lineno, include))
match = re.match("- (.*;(?: })*)* // lines (.*)-.*", line)
if match:
fwdDecl = match.group(1)
if fwdDecl.endswith(";"):
# Remove trailing semicolon.
fwdDecl = fwdDecl[:-1]
lineno = match.group(2)
if not ignoreRemoval(fwdDecl, toAdd, currentFileName, moduleRules):
toRemove.append("%s:%s: %s" % (currentFileName, lineno, fwdDecl))
for remove in sorted(toRemove):
print("ERROR: %s: remove not needed include / forward declaration" % remove)
print("ERROR: %s: remove not needed include" % remove)
return len(toRemove)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment