From cee2e455605bbb921e1e32201cc27af973cb775c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 31 May 2019 09:37:43 +0200 Subject: 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 Tested-by: Jenkins --- bin/find-unneeded-includes | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'bin/find-unneeded-includes') 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) -- cgit