[cfe-commits] r161150 - /cfe/trunk/utils/analyzer/CmpRuns.py

Anna Zaks ganna at apple.com
Wed Aug 1 17:41:40 PDT 2012


Author: zaks
Date: Wed Aug  1 19:41:40 2012
New Revision: 161150

URL: http://llvm.org/viewvc/llvm-project?rev=161150&view=rev
Log:
[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.

Modified:
    cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=161150&r1=161149&r2=161150&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Wed Aug  1 19:41:40 2012
@@ -16,8 +16,12 @@
 
     # 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 @@
     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 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 @@
         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 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 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]",





More information about the cfe-commits mailing list