[Libreoffice-commits] core.git: bin/find-unneeded-includes

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri May 31 08:51:50 UTC 2019


 bin/find-unneeded-includes |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

New commits:
commit cee2e455605bbb921e1e32201cc27af973cb775c
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri May 31 09:37:43 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri May 31 10:51:15 2019 +0200

    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 at collabora.com>
    Tested-by: Jenkins

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)
 
 


More information about the Libreoffice-commits mailing list