summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-05-31 09:37:43 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-05-31 10:51:15 +0200
commitcee2e455605bbb921e1e32201cc27af973cb775c (patch)
tree104fb97e4c92d5bdee63c55231722de76d700d11 /bin
parent13da1c7913ca76ca5b33f0666ab7cc4a219815e1 (diff)
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/73240 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'bin')
-rwxr-xr-xbin/find-unneeded-includes16
1 files changed, 4 insertions, 12 deletions
diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 35784c0083e8..bea49fd7a267 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -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))
- continue
-
- 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)