[PATCH] D126197: [analyzer] SATest: Weaken assumption about HTML files

Marco Antognini via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 00:56:33 PDT 2022


mantognini created this revision.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
mantognini published this revision for review.
mantognini added reviewers: vsavchenko, steakhal.
mantognini added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch relates to my previous comment: https://reviews.llvm.org/D124621#3485799


Instead of assuming there is an HTML file for each diagnostics, consider
the HTML files only when they exist, individually of each other.

After generating the reference data, running

  python /scripts/SATest.py build --projects simbody

was resulting in this error:

    File "/scripts/CmpRuns.py", line 250, in read_single_file
      assert len(d['HTMLDiagnostics_files']) == 1
  KeyError: 'HTMLDiagnostics_files'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126197

Files:
  clang/utils/analyzer/CmpRuns.py


Index: clang/utils/analyzer/CmpRuns.py
===================================================================
--- clang/utils/analyzer/CmpRuns.py
+++ clang/utils/analyzer/CmpRuns.py
@@ -242,17 +242,20 @@
             return
 
         # Extract the HTML reports, if they exists.
-        if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
-            htmlFiles = []
-            for d in data['diagnostics']:
+        htmlFiles = []
+        for d in data['diagnostics']:
+            if 'HTMLDiagnostics_files' in d:
                 # FIXME: Why is this named files, when does it have multiple
                 # files?
                 assert len(d['HTMLDiagnostics_files']) == 1
                 htmlFiles.append(d.pop('HTMLDiagnostics_files')[0])
-        else:
-            htmlFiles = [None] * len(data['diagnostics'])
+            else:
+                htmlFiles.append(None)
 
         report = AnalysisReport(self, data.pop('files'))
+        # Python 3.10 offers zip(..., strict=True). The following assertion
+        # mimics it.
+        assert len(data['diagnostics']) == len(htmlFiles)
         diagnostics = [AnalysisDiagnostic(d, report, h)
                        for d, h in zip(data.pop('diagnostics'), htmlFiles)]
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126197.431338.patch
Type: text/x-patch
Size: 1240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220524/ed39fd7f/attachment.bin>


More information about the cfe-commits mailing list