aboutsummaryrefslogtreecommitdiff
path: root/utils/analyzer
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-08-02 00:41:40 +0000
committerAnna Zaks <ganna@apple.com>2012-08-02 00:41:40 +0000
commit2a84b8bd106db5c878ab7bbaa848f49bfd6d42f9 (patch)
tree6d5c179758f258160816f1b4f77b038778ba5b1c /utils/analyzer
parentea66f9f9e17d619d617885e26adc1530cec7c0fd (diff)
[analyzer] CmpRuns should include file name in the issue identifier.
This prevents us from treating the issues from different files with the same function names and same offsets as the same. The issue identifier now includes the file name. Also added a way to strip off the root directories form the source file names. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/analyzer')
-rwxr-xr-xutils/analyzer/CmpRuns.py43
1 files changed, 26 insertions, 17 deletions
diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py
index ff48aa73b3..f2961cf0ac 100755
--- a/utils/analyzer/CmpRuns.py
+++ b/utils/analyzer/CmpRuns.py
@@ -16,8 +16,12 @@ Usage:
# Load the results of both runs, to obtain lists of the corresponding
# AnalysisDiagnostic objects.
- resultsA = loadResults(dirA, opts, deleteEmpty)
- resultsB = loadResults(dirB, opts, deleteEmpty)
+ #
+ # root - the name of the root directory, which will be disregarded when
+ # determining the source file name
+ #
+ resultsA = loadResults(dirA, opts, root, deleteEmpty)
+ resultsB = loadResults(dirB, opts, root, deleteEmpty)
# Generate a relation from diagnostics in run A to diagnostics in run B
# to obtain a list of triples (a, b, confidence).
@@ -54,10 +58,10 @@ class AnalysisDiagnostic:
def getIssueIdentifier(self) :
id = ''
if 'issue_context' in self._data :
- id += self._data['issue_context']
+ id += self._data['issue_context'] + ":"
if 'issue_hash' in self._data :
- id += str(self._data['issue_hash'])
- return id
+ id += str(self._data['issue_hash']) + ":"
+ return id + ":" + self.getFileName()
def getReport(self):
if self._htmlReport is None:
@@ -96,8 +100,9 @@ class multidict:
#
class CmpOptions:
- def __init__(self, verboseLog=None, root=""):
- self.root = root
+ def __init__(self, verboseLog=None, rootA="", rootB=""):
+ self.rootA = rootA
+ self.rootB = rootB
self.verboseLog = verboseLog
class AnalysisReport:
@@ -106,20 +111,21 @@ class AnalysisReport:
self.files = files
class AnalysisRun:
- def __init__(self, path, opts):
+ def __init__(self, path, root, opts):
self.path = path
+ self.root = root
self.reports = []
self.diagnostics = []
self.opts = opts
def getSourceName(self, path):
- if path.startswith(self.opts.root):
- return path[len(self.opts.root):]
+ if path.startswith(self.root):
+ return path[len(self.root):]
return path
-def loadResults(path, opts, deleteEmpty=True):
- run = AnalysisRun(path, opts)
-
+def loadResults(path, opts, root = "", deleteEmpty=True):
+ run = AnalysisRun(path, root, opts)
+
for f in os.listdir(path):
if (not f.startswith('report') or
not f.endswith('plist')):
@@ -209,8 +215,8 @@ def compareResults(A, B):
def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True):
# Load the run results.
- resultsA = loadResults(dirA, opts, deleteEmpty)
- resultsB = loadResults(dirB, opts, deleteEmpty)
+ resultsA = loadResults(dirA, opts, opts.rootA, deleteEmpty)
+ resultsB = loadResults(dirB, opts, opts.rootB, deleteEmpty)
# Open the verbose log, if given.
if opts.verboseLog:
@@ -259,8 +265,11 @@ def dumpScanBuildResultsDiff(dirA, dirB, opts, deleteEmpty=True):
def main():
from optparse import OptionParser
parser = OptionParser("usage: %prog [options] [dir A] [dir B]")
- parser.add_option("", "--root", dest="root",
- help="Prefix to ignore on source files",
+ parser.add_option("", "--rootA", dest="rootA",
+ help="Prefix to ignore on source files for directory A",
+ action="store", type=str, default="")
+ parser.add_option("", "--rootB", dest="rootB",
+ help="Prefix to ignore on source files for directory B",
action="store", type=str, default="")
parser.add_option("", "--verbose-log", dest="verboseLog",
help="Write additional information to LOG [default=None]",