diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-12 22:12:10 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-12 22:12:10 +0000 |
commit | c242446f7a7c6a0c1f1bf9ad403d6dac6f215f1c (patch) | |
tree | d8a63ec8deb287ac8847e10bf20fde319b929483 /lib/ubsan/ubsan_diag.cc | |
parent | f4a1ea7e0130273039f6c76d97e852f28e572d7a (diff) |
Highlight caret in bold green, to match Clang diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/ubsan_diag.cc')
-rw-r--r-- | lib/ubsan/ubsan_diag.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ubsan/ubsan_diag.cc b/lib/ubsan/ubsan_diag.cc index 57c98e669..95fad74f8 100644 --- a/lib/ubsan/ubsan_diag.cc +++ b/lib/ubsan/ubsan_diag.cc @@ -156,7 +156,7 @@ static Range *upperBound(MemoryLocation Loc, Range *Ranges, } /// 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(MemoryLocation Loc, 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(MemoryLocation Loc, 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); } |