r353228 - [analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 5 14:26:57 PST 2019


Author: george.karpenkov
Date: Tue Feb  5 14:26:57 2019
New Revision: 353228

URL: http://llvm.org/viewvc/llvm-project?rev=353228&view=rev
Log:
[analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path

Differential Revision: https://reviews.llvm.org/D57783

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=353228&r1=353227&r2=353228&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Tue Feb  5 14:26:57 2019
@@ -73,6 +73,21 @@ class AnalysisDiagnostic(object):
             return fileName[len(root) + 1:]
         return fileName
 
+    def getRootFileName(self):
+        path = self._data['path']
+        if not path:
+            return self.getFileName()
+        p = path[0]
+        if 'location' in p:
+            fIdx = p['location']['file']
+        else: # control edge
+            fIdx = path[0]['edges'][0]['start'][0]['file']
+        out = self._report.files[fIdx]
+        root = self._report.run.root
+        if out.startswith(root):
+            return out[len(root):]
+        return out
+
     def getLine(self):
         return self._loc['line']
 
@@ -106,7 +121,13 @@ class AnalysisDiagnostic(object):
             funcnamePostfix = "#" + self._data['issue_context']
         else:
             funcnamePostfix = ""
-        return '%s%s:%d:%d, %s: %s' % (self.getFileName(),
+        rootFilename = self.getRootFileName()
+        fileName = self.getFileName()
+        if rootFilename != fileName:
+            filePrefix = "[%s] %s" % (rootFilename, fileName)
+        else:
+            filePrefix = rootFilename
+        return '%s%s:%d:%d, %s: %s' % (filePrefix,
                                        funcnamePostfix,
                                        self.getLine(),
                                        self.getColumn(), self.getCategory(),




More information about the cfe-commits mailing list