diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-03-01 14:54:16 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-03-01 14:54:16 +0000 |
commit | 8b9b3bd07c5046ae3010516d84d3217934ad10d5 (patch) | |
tree | b352ac923482fa800709b5291976798ace5613b5 /clang/tools/scan-build-py/libscanbuild/report.py | |
parent | 1bab70109b9fa259f928fe30a8ad153db8f4ecbe (diff) | |
download | bcm5719-llvm-8b9b3bd07c5046ae3010516d84d3217934ad10d5.tar.gz bcm5719-llvm-8b9b3bd07c5046ae3010516d84d3217934ad10d5.zip |
Resubmit [analyzer] Support for naive cross translation unit analysis
Originally submitted as r326323 and r326324.
Reverted in r326432.
Reverting the commit was a mistake.
The breakage was due to invalid build files in our internal buildsystem,
CMakeLists did not have any cyclic dependencies.
llvm-svn: 326439
Diffstat (limited to 'clang/tools/scan-build-py/libscanbuild/report.py')
-rw-r--r-- | clang/tools/scan-build-py/libscanbuild/report.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/tools/scan-build-py/libscanbuild/report.py b/clang/tools/scan-build-py/libscanbuild/report.py index 54b9695d927..b3753c1d9d4 100644 --- a/clang/tools/scan-build-py/libscanbuild/report.py +++ b/clang/tools/scan-build-py/libscanbuild/report.py @@ -13,7 +13,6 @@ import os import os.path import sys import shutil -import itertools import plistlib import glob import json @@ -255,24 +254,29 @@ def read_crashes(output_dir): def read_bugs(output_dir, html): + # type: (str, bool) -> Generator[Dict[str, Any], None, None] """ Generate a unique sequence of bugs from given output directory. Duplicates can be in a project if the same module was compiled multiple times with different compiler options. These would be better to show in the final report (cover) only once. """ - parser = parse_bug_html if html else parse_bug_plist - pattern = '*.html' if html else '*.plist' + def empty(file_name): + return os.stat(file_name).st_size == 0 duplicate = duplicate_check( lambda bug: '{bug_line}.{bug_path_length}:{bug_file}'.format(**bug)) - bugs = itertools.chain.from_iterable( - # parser creates a bug generator not the bug itself - parser(filename) - for filename in glob.iglob(os.path.join(output_dir, pattern))) - - return (bug for bug in bugs if not duplicate(bug)) + # get the right parser for the job. + parser = parse_bug_html if html else parse_bug_plist + # get the input files, which are not empty. + pattern = os.path.join(output_dir, '*.html' if html else '*.plist') + bug_files = (file for file in glob.iglob(pattern) if not empty(file)) + + for bug_file in bug_files: + for bug in parser(bug_file): + if not duplicate(bug): + yield bug def parse_bug_plist(filename): |