Skip to content

Commit a64b205

Browse files
author
George Karpenkov
committedFeb 5, 2019
[analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path
Differential Revision: https://reviews.llvm.org/D57783 llvm-svn: 353228
1 parent 6794aa7 commit a64b205

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎clang/utils/analyzer/CmpRuns.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ def getFileName(self):
7373
return fileName[len(root) + 1:]
7474
return fileName
7575

76+
def getRootFileName(self):
77+
path = self._data['path']
78+
if not path:
79+
return self.getFileName()
80+
p = path[0]
81+
if 'location' in p:
82+
fIdx = p['location']['file']
83+
else: # control edge
84+
fIdx = path[0]['edges'][0]['start'][0]['file']
85+
out = self._report.files[fIdx]
86+
root = self._report.run.root
87+
if out.startswith(root):
88+
return out[len(root):]
89+
return out
90+
7691
def getLine(self):
7792
return self._loc['line']
7893

@@ -106,7 +121,13 @@ def getReadableName(self):
106121
funcnamePostfix = "#" + self._data['issue_context']
107122
else:
108123
funcnamePostfix = ""
109-
return '%s%s:%d:%d, %s: %s' % (self.getFileName(),
124+
rootFilename = self.getRootFileName()
125+
fileName = self.getFileName()
126+
if rootFilename != fileName:
127+
filePrefix = "[%s] %s" % (rootFilename, fileName)
128+
else:
129+
filePrefix = rootFilename
130+
return '%s%s:%d:%d, %s: %s' % (filePrefix,
110131
funcnamePostfix,
111132
self.getLine(),
112133
self.getColumn(), self.getCategory(),

0 commit comments

Comments
 (0)
Please sign in to comment.