bin/find-unneeded-includes      |   11 +++++++++++
 include/IwyuFilter_include.yaml |    3 ---
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit fc989238e57dcaf541f870a1202b3c6681386293
Author:     Gabor Kelemen <[email protected]>
AuthorDate: Mon Oct 20 20:58:07 2025 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Thu Nov 6 19:28:39 2025 +0100

    bin/find-unneeded-includes: another method against obsolete exclusions
    
    Spotted with include/o3tl/vector_utils.hxx
    it can happen that IWYU starts to consider a header having
    all correct includes, in this case it does not give a list of
    proposals.
    
    This makes the previous method of spotting obsolete exclusions
    ineffective in these cases.
    
    Start watching for the "foo.hxx has correct #includes/fwd-decls"
    announcement and consider every exclusion as obsolete
    
    Change-Id: I46dd8dd4e2765a972ceaa7aa950d92c9e0a2d1b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192747
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 2dafa002b4cc..405a6c9286a2 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -235,6 +235,17 @@ def processIWYUOutput(iwyuOutput, moduleRules, fileName, 
noexclude, checknamespa
             inFull = True
             continue
 
+        # Check if IWYU considers the header as having correct
+        # list of includes - this would make all exclusions obsolete
+        match = re.match(".*has correct #includes/fwd-decls.*", line)
+        if match:
+            if "excludelist" in moduleRules.keys():
+                excludelistRules = moduleRules["excludelist"]
+                realFileName = os.path.relpath(fileName, os.getcwd())
+                if realFileName in excludelistRules.keys():
+                    print("WARNING:", "File has correct #includes/fwd-decls; 
all excluded headers can be removed from exclusion list of:", realFileName)
+            continue
+
         if inAdd:
             match = re.match('#include ([^ ]+)', line)
             if match:
diff --git a/include/IwyuFilter_include.yaml b/include/IwyuFilter_include.yaml
index d10299f84262..8f5373c8e2a8 100644
--- a/include/IwyuFilter_include.yaml
+++ b/include/IwyuFilter_include.yaml
@@ -212,9 +212,6 @@ excludelist:
     include/o3tl/unreachable.hxx:
     # Needed for C++23 mode
     - utility
-    include/o3tl/vector_utils.hxx:
-    # Needed for std::copy_if
-    - algorithm
     include/sot/exchange.hxx:
     # Used in a macro #define
     - com/sun/star/datatransfer/dnd/DNDConstants.hpp

Reply via email to