[clang] ff4abe7 - [scan-build-py] Fix exception on shutdown with sarif-html output format

Anders Waldenborg via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 14:23:43 PDT 2022


Author: Anders Waldenborg
Date: 2022-06-10T23:21:09+02:00
New Revision: ff4abe755279a3a47cc416ef80dbc900d9a98a19

URL: https://github.com/llvm/llvm-project/commit/ff4abe755279a3a47cc416ef80dbc900d9a98a19
DIFF: https://github.com/llvm/llvm-project/commit/ff4abe755279a3a47cc416ef80dbc900d9a98a19.diff

LOG: [scan-build-py] Fix exception on shutdown with sarif-html output format

When running scan-build-py's analyze-build script with output format set
to sarif & html it wants to print a message on how to look at the
defects mentioning the directory name twice.

But the path argument was only given once to the logging function,
causing "TypeError: not enough arguments for format string" exception.

Differential Revision: https://reviews.llvm.org/D126974

Added: 
    

Modified: 
    clang/tools/scan-build-py/lib/libscanbuild/analyze.py

Removed: 
    


################################################################################
diff  --git a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
index 08802de81cc5..2633139fd523 100644
--- a/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
+++ b/clang/tools/scan-build-py/lib/libscanbuild/analyze.py
@@ -357,6 +357,7 @@ def report_directory(hint, keep, output_format):
     try:
         yield name
     finally:
+        args = (name,)
         if os.listdir(name):
             if output_format not in ['sarif', 'sarif-html']: # FIXME:
                 # 'scan-view' currently does not support sarif format.
@@ -364,6 +365,7 @@ def report_directory(hint, keep, output_format):
             elif output_format == 'sarif-html':
                 msg = "Run 'scan-view %s' to examine bug reports or see " \
                     "merged sarif results at %s/results-merged.sarif."
+                args = (name, name)
             else:
                 msg = "View merged sarif results at %s/results-merged.sarif."
             keep = True
@@ -372,7 +374,7 @@ def report_directory(hint, keep, output_format):
                 msg = "Report directory '%s' contains no report, but kept."
             else:
                 msg = "Removing directory '%s' because it contains no report."
-        logging.warning(msg, name)
+        logging.warning(msg, *args)
 
         if not keep:
             os.rmdir(name)


        


More information about the cfe-commits mailing list