From c9d00a4c6308fd8f212391c438cb84eded5a395c Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Tue, 5 Feb 2019 22:26:57 +0000 Subject: [PATCH] [analyzer] [testing] Inside CmpRuns.py output also print the filename of the first item in the path Differential Revision: https://reviews.llvm.org/D57783 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353228 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/analyzer/CmpRuns.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/utils/analyzer/CmpRuns.py b/utils/analyzer/CmpRuns.py index be50349962..3fab6ef520 100755 --- a/utils/analyzer/CmpRuns.py +++ b/utils/analyzer/CmpRuns.py @@ -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(), -- 2.50.1