]> granicus.if.org Git - llvm/commit
opt-viewer: Fix syntax highlighting
authorBrian Cain <bcain@codeaurora.org>
Sat, 18 Feb 2017 15:13:58 +0000 (15:13 +0000)
committerBrian Cain <bcain@codeaurora.org>
Sat, 18 Feb 2017 15:13:58 +0000 (15:13 +0000)
commit34b4908c3ea331a7c8be4335c582d16b4c4dc68f
treef8f276805bb98a2b18248d18ccdb167c76acf3cd
parent47cf6aadec0bc58d970052092ee85a69b3625792
opt-viewer: Fix syntax highlighting

Syntax highlighting has been done line-at-a-time. Done this way, the lexer
resets the context at each line, distorting the formatting.

This change will render the whole file at once and feed the highlighted text
line-at-a-time to be wrapped by the SourceFileRenderer.

Leading/trailing newlines were being ignored by Pygments but since each line
was rendered in its own row, it didn't matter. This bug was masked by the
line-at-a-time algorithm. So now we need to add "stripnl=False" to the
CppLexer to change its behavior to match the expectation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295546 91177308-0d34-0410-b5e6-96231b3b80d8
utils/opt-viewer/opt-viewer.py