summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-01-25 17:48:31 +0000
committerFlorian Hahn <flo@fhahn.com>2019-01-25 17:48:31 +0000
commitfd7ee479401b069bc14dd7b604fd6e1da31dc95e (patch)
tree1aaa776ffb95facb83131a358bb0b5fe1997fcb0 /llvm/tools
parent599c0bc93b14db810c91c2edcc467603fc627581 (diff)
downloadbcm5719-llvm-fd7ee479401b069bc14dd7b604fd6e1da31dc95e.tar.gz
bcm5719-llvm-fd7ee479401b069bc14dd7b604fd6e1da31dc95e.zip
[opt-viewer] Add javascript to expand/hide full message for multiline remarks.
This patch adds support for displaying remarks with multiple lines. For such remarks, it creates a hidden div containing the message's lines except the first one in a <pre> tag. It also prepends a link (with '+' as text) to the regular remark line. This link can be used to show/hide the div containing the full remark. In combination with D57159, this allows for better displaying of multiline remarks in the html pages generated by opt-viewer. The Javascript is very simple and should be supported by any recent major browser. Reviewers: hfinkel, anemet, thegameg, serge-sans-paille Reviewed By: anemet Differential Revision: https://reviews.llvm.org/D57167 llvm-svn: 352223
Diffstat (limited to 'llvm/tools')
-rwxr-xr-xllvm/tools/opt-viewer/opt-viewer.py33
-rw-r--r--llvm/tools/opt-viewer/style.css10
2 files changed, 42 insertions, 1 deletions
diff --git a/llvm/tools/opt-viewer/opt-viewer.py b/llvm/tools/opt-viewer/opt-viewer.py
index f6582506311..8aec321b959 100755
--- a/llvm/tools/opt-viewer/opt-viewer.py
+++ b/llvm/tools/opt-viewer/opt-viewer.py
@@ -120,12 +120,26 @@ class SourceFileRenderer:
indent = line[:max(r.Column, 1) - 1]
indent = re.sub('\S', ' ', indent)
+ # Create expanded message and link if we have a multiline message.
+ lines = r.message.split('\n')
+ if len(lines) > 1:
+ expand_link = '<a style="text-decoration: none;" href="" onclick="toggleExpandedMessage(this); return false;">+</a>'
+ message = lines[0]
+ expand_message = u'''
+<div class="full-info" style="display:none;">
+ <div class="col-left"><pre style="display:inline">{}</pre></div>
+ <div class="expanded col-left"><pre>{}</pre></div>
+</div>'''.format(indent, '\n'.join(lines[1:]))
+ else:
+ expand_link = ''
+ expand_message = ''
+ message = r.message
print(u'''
<tr>
<td></td>
<td>{r.RelativeHotness}</td>
<td class=\"column-entry-{r.color}\">{r.PassWithDiffPrefix}</td>
-<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\"> {r.message}&nbsp;</span></td>
+<td><pre style="display:inline">{indent}</pre><span class=\"column-entry-yellow\">{expand_link} {message}&nbsp;</span>{expand_message}</td>
<td class=\"column-entry-yellow\">{inlining_context}</td>
</tr>'''.format(**locals()), file=self.stream)
@@ -139,6 +153,23 @@ class SourceFileRenderer:
<meta charset="utf-8" />
<head>
<link rel='stylesheet' type='text/css' href='style.css'>
+<script type="text/javascript">
+/* Simple helper to show/hide the expanded message of a remark. */
+function toggleExpandedMessage(e) {{
+ var FullTextElems = e.parentElement.parentElement.getElementsByClassName("full-info");
+ if (!FullTextElems || FullTextElems.length < 1) {{
+ return false;
+ }}
+ var FullText = FullTextElems[0];
+ if (FullText.style.display == 'none') {{
+ e.innerHTML = '-';
+ FullText.style.display = 'block';
+ }} else {{
+ e.innerHTML = '+';
+ FullText.style.display = 'none';
+ }}
+}}
+</script>
</head>
<body>
<div class="centered">
diff --git a/llvm/tools/opt-viewer/style.css b/llvm/tools/opt-viewer/style.css
index 0d3347c1578..550c7e1cdff 100644
--- a/llvm/tools/opt-viewer/style.css
+++ b/llvm/tools/opt-viewer/style.css
@@ -139,6 +139,16 @@ td:first-child {
td:last-child {
border-right: none;
}
+.expanded {
+ background-color: #f2f2f2;
+ padding-top: 5px;
+ padding-left: 5px;
+}
+.col-left {
+ float: left;
+ margin-bottom: -99999px;
+ padding-bottom: 99999px;
+}
/* Generated with pygmentize -S colorful -f html >> style.css */
OpenPOWER on IntegriCloud