[compiler-rt] r175013 - Highlight caret in bold green, to match Clang diagnostics.
Richard Smith
richard-llvm at metafoo.co.uk
Tue Feb 12 14:12:10 PST 2013
Author: rsmith
Date: Tue Feb 12 16:12:10 2013
New Revision: 175013
URL: http://llvm.org/viewvc/llvm-project?rev=175013&view=rev
Log:
Highlight caret in bold green, to match Clang diagnostics.
Modified:
compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
Modified: compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag.cc?rev=175013&r1=175012&r2=175013&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_diag.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_diag.cc Tue Feb 12 16:12:10 2013
@@ -156,7 +156,7 @@ static Range *upperBound(MemoryLocation
}
/// Render a snippet of the address space near a location.
-static void renderMemorySnippet(MemoryLocation Loc,
+static void renderMemorySnippet(bool UseAnsiColor, MemoryLocation Loc,
Range *Ranges, unsigned NumRanges,
const Diag::Arg *Args) {
const unsigned BytesToShow = 32;
@@ -183,6 +183,8 @@ static void renderMemorySnippet(MemoryLo
RawWrite("\n");
// Emit highlights.
+ if (UseAnsiColor)
+ RawWrite("\033[1;32m");
Range *InRange = upperBound(Min, Ranges, NumRanges);
for (uptr P = Min; P != Max; ++P) {
char Pad = ' ', Byte = ' ';
@@ -197,6 +199,8 @@ static void renderMemorySnippet(MemoryLo
char Buffer[] = { Pad, Pad, P == Loc ? '^' : Byte, Byte, 0 };
RawWrite((P % 8 == 0) ? Buffer : &Buffer[1]);
}
+ if (UseAnsiColor)
+ RawWrite("\033[0m");
RawWrite("\n");
// Go over the line again, and print names for the ranges.
@@ -267,5 +271,6 @@ Diag::~Diag() {
RawWrite("\n");
if (Loc.isMemoryLocation())
- renderMemorySnippet(Loc.getMemoryLocation(), Ranges, NumRanges, Args);
+ renderMemorySnippet(UseAnsiColor, Loc.getMemoryLocation(), Ranges,
+ NumRanges, Args);
}
More information about the llvm-commits
mailing list