From: David Blaikie Date: Thu, 28 Jun 2012 21:46:07 +0000 (+0000) Subject: Fix template type diffing coloring (r159216) when forcing color output to a file... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50badd523b9b90c0731423d002b13a00bf754036;p=clang Fix template type diffing coloring (r159216) when forcing color output to a file (not a terminal) Reviewed (over the shoulder) by Richard Trieu. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159381 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 8b7332dbeb..bd766d354c 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -720,8 +720,11 @@ TextDiagnostic::printDiagnosticMessage(raw_ostream &OS, if (Columns) printWordWrapped(OS, Message, Columns, CurrentColumn); - else - OS << Message; + else { + bool Normal = true; + applyTemplateHighlighting(OS, Message, Normal); + assert(Normal && "Formatting should have returned to normal"); + } if (ShowColors) OS.resetColor(); diff --git a/test/Misc/diag-template-diffing-color.cpp b/test/Misc/diag-template-diffing-color.cpp new file mode 100644 index 0000000000..edbf4c216d --- /dev/null +++ b/test/Misc/diag-template-diffing-color.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -fcolor-diagnostics %s 2>&1 | FileCheck %s +// XFAIL: cygwin,mingw32,win32 +template struct foo {}; +void func(foo); +int main() { + func(foo()); +} +// CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<{{.}}[0;1;36mdouble{{.}}[0m>' to 'foo<{{.}}[0;1;36mint{{.}}[0m>' for 1st argument{{.}}[0m