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

New commits:
commit 40b447c064f551a596c6e009efc9968a60f1b5bc
Author:     Gabor Kelemen <[email protected]>
AuthorDate: Tue Oct 7 14:34:06 2025 +0200
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Tue Oct 14 11:02:50 2025 +0200

    bin/find-unneeded-includes: Add -d option to debug
    
    Inspecting IWYU output when find-unneeded-includes
    did not report any issue is less complicated this way
    
    which is useful during improvement of this script
    
    Change-Id: I44a603383e4eff5bbac01332e8622aa9ad5e8b7d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192048
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 601881c7c786..62786fb4fa87 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -493,7 +493,7 @@ def isInUnoIncludeFile(path):
             or path.startswith("include/uno/")
 
 
-def tidy(compileCommands, paths, dontstop, noexclude, checknamespaces, 
finderrors, removefwdd):
+def tidy(compileCommands, paths, dontstop, noexclude, checknamespaces, 
finderrors, removefwdd, debug):
     return_code = 0
 
     try:
@@ -552,6 +552,11 @@ def tidy(compileCommands, paths, dontstop, noexclude, 
checknamespaces, finderror
             # but those and our CI are not reliable enough yet for use
             else:
                 invocation = "include-what-you-use -Xiwyu --cxx17ns -Xiwyu 
--max_line_length=200 " + args
+
+            if debug:
+                print(invocation)
+                sys.exit(0)
+
             task_queue.put((invocation, moduleRules))
 
         task_queue.join()
@@ -584,6 +589,9 @@ def main(argv):
     parser.add_argument('--finderrors', action='store_true',
                    help='Report IWYU failures when it returns with -1 error 
code. '
                         'Use only for debugging this script!')
+    parser.add_argument('-d', action='store_true',
+                   help='Print the full IWYU invocation of a given file. '
+                        'Use only for debugging this script!')
     parser.add_argument('--fwdecl', action='store_true',
                     help='Suggest removal of obsolete forward declarations')
     parser.add_argument('--sanitycheck', action='store_true',
@@ -672,7 +680,7 @@ def main(argv):
                         print("WARNING: no exclusions are defined for:", file)
         sys.exit(0)
 
-    tidy(compileCommands, paths=list_of_files, 
dontstop=vars(args)["continue"], noexclude=args.noexclude, 
checknamespaces=args.ns, finderrors=args.finderrors, removefwdd=args.fwdecl)
+    tidy(compileCommands, paths=list_of_files, 
dontstop=vars(args)["continue"], noexclude=args.noexclude, 
checknamespaces=args.ns, finderrors=args.finderrors, removefwdd=args.fwdecl, 
debug=args.d)
 
 if __name__ == '__main__':
     main(sys.argv[1:])

Reply via email to