aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-23 01:21:26 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-23 01:21:26 +0000
commite30024c96f88578fb7666d6d76977e4834127919 (patch)
treede094c9d793e45da648e406bfe02644ed8e698d9 /utils
parent281698935f62ac1d35ddd3533a562c1589aadc8b (diff)
[analyzer] CmpRuns.py: Accept single files as input.
This allows us to compare two direct invocations of the analyzer on a single source file without having to wrap the output plists in their own directories. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rwxr-xr-xutils/analyzer/CmpRuns.py97
1 files changed, 51 insertions, 46 deletions
diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py
index bca02124ee..30157bed3d 100755
--- a/utils/analyzer/CmpRuns.py
+++ b/utils/analyzer/CmpRuns.py
@@ -138,6 +138,46 @@ class AnalysisRun:
def getClangVersion(self):
return self.clang_version
+ def readSingleFile(self, p, deleteEmpty):
+ data = plistlib.readPlist(p)
+
+ # We want to retrieve the clang version even if there are no
+ # reports. Assume that all reports were created using the same
+ # clang version (this is always true and is more efficient).
+ if 'clang_version' in data:
+ if self.clang_version == None:
+ self.clang_version = data.pop('clang_version')
+ else:
+ data.pop('clang_version')
+
+ # Ignore/delete empty reports.
+ if not data['files']:
+ if deleteEmpty == True:
+ os.remove(p)
+ return
+
+ # Extract the HTML reports, if they exists.
+ if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
+ htmlFiles = []
+ for d in data['diagnostics']:
+ # 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'])
+
+ report = AnalysisReport(self, data.pop('files'))
+ diagnostics = [AnalysisDiagnostic(d, report, h)
+ for d,h in zip(data.pop('diagnostics'),
+ htmlFiles)]
+
+ assert not data
+
+ report.diagnostics.extend(diagnostics)
+ self.reports.append(report)
+ self.diagnostics.extend(diagnostics)
+
# Backward compatibility API.
def loadResults(path, opts, root = "", deleteEmpty=True):
@@ -150,52 +190,17 @@ def loadResults(path, opts, root = "", deleteEmpty=True):
def loadResultsFromSingleRun(info, deleteEmpty=True):
path = info.path
run = AnalysisRun(info)
-
- for (dirpath, dirnames, filenames) in os.walk(path):
- for f in filenames:
- if (not f.endswith('plist')):
- continue
-
- p = os.path.join(dirpath, f)
- data = plistlib.readPlist(p)
-
- # We want to retrieve the clang version even if there are no
- # reports. Assume that all reports were created using the same
- # clang version (this is always true and is more efficient).
- if ('clang_version' in data) :
- if (run.clang_version == None) :
- run.clang_version = data.pop('clang_version')
- else:
- data.pop('clang_version')
-
- # Ignore/delete empty reports.
- if not data['files']:
- if deleteEmpty == True:
- os.remove(p)
- continue
-
- # Extract the HTML reports, if they exists.
- if 'HTMLDiagnostics_files' in data['diagnostics'][0]:
- htmlFiles = []
- for d in data['diagnostics']:
- # 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'])
-
- report = AnalysisReport(run, data.pop('files'))
- diagnostics = [AnalysisDiagnostic(d, report, h)
- for d,h in zip(data.pop('diagnostics'),
- htmlFiles)]
-
- assert not data
-
- report.diagnostics.extend(diagnostics)
- run.reports.append(report)
- run.diagnostics.extend(diagnostics)
-
+
+ if os.path.isfile(path):
+ run.readSingleFile(path, deleteEmpty)
+ else:
+ for (dirpath, dirnames, filenames) in os.walk(path):
+ for f in filenames:
+ if (not f.endswith('plist')):
+ continue
+ p = os.path.join(dirpath, f)
+ run.readSingleFile(p, deleteEmpty)
+
return run
def cmpAnalysisDiagnostic(d) :