Skip to content

Commit

Permalink
[opt-viewer] Add column number support
Browse files Browse the repository at this point in the history
With this the yellow (bubble) part of the remark shows up under the
corresponding expression.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286545 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
anemet committed Nov 11, 2016
1 parent ee5205b commit 58da394
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions utils/opt-viewer/opt-viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import yaml
import argparse
import os.path
import re
import subprocess
import shutil
from pygments import highlight
Expand Down Expand Up @@ -150,19 +151,23 @@ def render_source_line(self, linenum, line):
<td>{html_line}</td>
</tr>'''.format(**locals()), file=self.stream)

def render_inline_remarks(self, r):
def render_inline_remarks(self, r, line):
inlining_context = r.DemangledFunctionName
dl = Remark.caller_loc.get(r.Function)
if dl:
link = Remark.make_link(dl['File'], dl['Line'] - 2)
inlining_context = "<a href={link}>{r.DemangledFunctionName}</a>".format(**locals())

# Column is the number of characters *including* tabs, keep those and
# replace everything else with spaces.
indent = line[:r.Column - 1]
indent = re.sub('\S', ' ', indent)
print('''
<tr>
<td></td>
<td>{r.RelativeHotness}%</td>
<td class=\"column-entry-{r.color}\">{r.Pass}</td>
<td class=\"column-entry-yellow\">{r.message}</td>
<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message}&nbsp;</span></td>
<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)

Expand All @@ -188,7 +193,7 @@ def render(self, line_remarks):
for (linenum, line) in enumerate(self.source_stream.readlines(), start=1):
self.render_source_line(linenum, line)
for remark in line_remarks.get(linenum, []):
self.render_inline_remarks(remark)
self.render_inline_remarks(remark, line)
print('''
</table>
</body>
Expand Down

0 comments on commit 58da394

Please sign in to comment.