bin/find-unneeded-includes |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit b6b8643fbd0fbf777f2bb8bc7720ad97785ea155
Author:     Gabor Kelemen <[email protected]>
AuthorDate: Thu Oct 2 23:18:26 2025 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Fri Oct 10 22:12:04 2025 +0200

    bin/find-unneeded-includes: handle namespaces in sanitycheck better
    
    as seen in chart2/ or store/, some namespace fw declarations are
    written in two lines so matching them without the namespace prefix
    is necessary, i.e. to avoid:
    
    WARNING: namespace chart { class ChartTypeTabPage; } is not present anymore 
in chart2/source/controller/inc/dlg_ChartType.hxx
    or
    WARNING: store/source/stordir.hxx : namespace store { struct 
OStoreDirectoryPageData; } line is not present anymore, remove it from: 
store/IwyuFilter_store.yaml
    
    we need to look for "class ChartTypeTabPage" and
    "struct OStoreDirectoryPageData" too when searching
    for obsolete exclusions.
    
    Change-Id: Ic72b5d99fed0906fd7822754a043b2e60a9301c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191826
    Reviewed-by: Gabor Kelemen <[email protected]>
    Tested-by: Jenkins

diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 76daaabb67c2..601881c7c786 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -657,9 +657,17 @@ def main(argv):
                 else:
                     try:
                         for exclusion in excludelistRules[pathname]:
-                            p = subprocess.run(["git", "grep", "-q", "-e", 
"#include <"+exclusion, "-e", exclusion, file])
-                            if p.returncode == 1 :
-                                print("WARNING:", exclusion, "is not present 
anymore in", file)
+                            # class names behind namespace prefixes may be in 
separate lines
+                            c=re.match(r"(?:namespace.*{ )(class.*|struct .*); 
}.*", exclusion)
+                            if c:
+                                classname=c.group(1)
+                                p = subprocess.run(["git", "grep", "-q", "-e", 
"#include <"+exclusion, "-e", exclusion, "-e", classname, file])
+                                if p.returncode == 1 :
+                                    print("WARNING:", exclusion, "is not 
present anymore in", file)
+                            else:
+                                p = subprocess.run(["git", "grep", "-q", "-e", 
"#include <"+exclusion, "-e", exclusion, file])
+                                if p.returncode == 1 :
+                                    print("WARNING:", exclusion, "is not 
present anymore in", file)
                     except TypeError:
                         print("WARNING: no exclusions are defined for:", file)
         sys.exit(0)

Reply via email to