[llvm] r286545 - [opt-viewer] Add column number support

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 17:51:35 PST 2016


Author: anemet
Date: Thu Nov 10 19:51:34 2016
New Revision: 286545

URL: http://llvm.org/viewvc/llvm-project?rev=286545&view=rev
Log:
[opt-viewer] Add column number support

With this the yellow (bubble) part of the remark shows up under the
corresponding expression.

Modified:
    llvm/trunk/utils/opt-viewer/opt-viewer.py

Modified: llvm/trunk/utils/opt-viewer/opt-viewer.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/opt-viewer/opt-viewer.py?rev=286545&r1=286544&r2=286545&view=diff
==============================================================================
--- llvm/trunk/utils/opt-viewer/opt-viewer.py (original)
+++ llvm/trunk/utils/opt-viewer/opt-viewer.py Thu Nov 10 19:51:34 2016
@@ -10,6 +10,7 @@ The tools requires PyYAML and Pygments P
 import yaml
 import argparse
 import os.path
+import re
 import subprocess
 import shutil
 from pygments import highlight
@@ -150,19 +151,23 @@ class SourceFileRenderer:
 <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} </span></td>
 <td class=\"column-entry-yellow\">{inlining_context}</td>
 </tr>'''.format(**locals()), file=self.stream)
 
@@ -188,7 +193,7 @@ class SourceFileRenderer:
         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>




More information about the llvm-commits mailing list