diff options
| author | Hans Wennborg <hans@hanshq.net> | 2013-09-24 00:08:55 +0000 | 
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2013-09-24 00:08:55 +0000 | 
| commit | f4aee180860db43da336d5d5babc5e5ae9dd0510 (patch) | |
| tree | b62a92f9ce07e3a7ca4c6cd003eb55758e09727b /clang/lib/Frontend | |
| parent | 8a2d496e180023cdad774c1512cce1ef69bf4f9c (diff) | |
| download | bcm5719-llvm-f4aee180860db43da336d5d5babc5e5ae9dd0510.tar.gz bcm5719-llvm-f4aee180860db43da336d5d5babc5e5ae9dd0510.zip  | |
clang-cl: print diagnostics as "error(clang): foo" in /fallback mode
This solves two problems:
1) MSBuild will not flag the build as unsuccessful just because we print
   an error in the output, since "error(clang):" doesn't seem to match
   the regex it's using.
2) It becomes more clear that the diagnostic is coming from clang as
   supposed to cl.exe.
Differential Revision: http://llvm-reviews.chandlerc.com/D1735
llvm-svn: 191250
Diffstat (limited to 'clang/lib/Frontend')
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 3 | 
3 files changed, 23 insertions, 8 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1c3dd7da7c5..b13507a5ef1 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -589,7 +589,10 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,      Opts.setFormat(DiagnosticOptions::Clang);    else if (Format == "msvc")      Opts.setFormat(DiagnosticOptions::Msvc); -  else if (Format == "vi") +  else if (Format == "msvc-fallback") { +    Opts.setFormat(DiagnosticOptions::Msvc); +    Opts.CLFallbackMode = true; +  } else if (Format == "vi")      Opts.setFormat(DiagnosticOptions::Vi);    else {      Success = false; diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 691ca3493a0..a2dc9537bc0 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -693,7 +693,8 @@ TextDiagnostic::emitDiagnosticMessage(SourceLocation Loc,    if (DiagOpts->ShowColors)      OS.resetColor(); -  printDiagnosticLevel(OS, Level, DiagOpts->ShowColors); +  printDiagnosticLevel(OS, Level, DiagOpts->ShowColors, +                       DiagOpts->CLFallbackMode);    printDiagnosticMessage(OS, Level, Message,                           OS.tell() - StartOfLocationInfo,                           DiagOpts->MessageLength, DiagOpts->ShowColors); @@ -702,7 +703,8 @@ TextDiagnostic::emitDiagnosticMessage(SourceLocation Loc,  /*static*/ void  TextDiagnostic::printDiagnosticLevel(raw_ostream &OS,                                       DiagnosticsEngine::Level Level, -                                     bool ShowColors) { +                                     bool ShowColors, +                                     bool CLFallbackMode) {    if (ShowColors) {      // Print diagnostic category in bold and color      switch (Level) { @@ -718,12 +720,21 @@ TextDiagnostic::printDiagnosticLevel(raw_ostream &OS,    switch (Level) {    case DiagnosticsEngine::Ignored:      llvm_unreachable("Invalid diagnostic type"); -  case DiagnosticsEngine::Note:    OS << "note: "; break; -  case DiagnosticsEngine::Warning: OS << "warning: "; break; -  case DiagnosticsEngine::Error:   OS << "error: "; break; -  case DiagnosticsEngine::Fatal:   OS << "fatal error: "; break; +  case DiagnosticsEngine::Note:    OS << "note"; break; +  case DiagnosticsEngine::Warning: OS << "warning"; break; +  case DiagnosticsEngine::Error:   OS << "error"; break; +  case DiagnosticsEngine::Fatal:   OS << "fatal error"; break;    } +  // In clang-cl /fallback mode, print diagnostics as "error(clang):". This +  // makes it more clear whether a message is coming from clang or cl.exe, +  // and it prevents MSBuild from concluding that the build failed just because +  // there is an "error:" in the output. +  if (CLFallbackMode) +    OS << "(clang)"; + +  OS << ": "; +    if (ShowColors)      OS.resetColor();  } diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index c22798af60a..994a8f74ed4 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -132,7 +132,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,    // diagnostics in a context that lacks language options, a source manager, or    // other infrastructure necessary when emitting more rich diagnostics.    if (!Info.getLocation().isValid()) { -    TextDiagnostic::printDiagnosticLevel(OS, Level, DiagOpts->ShowColors); +    TextDiagnostic::printDiagnosticLevel(OS, Level, DiagOpts->ShowColors, +                                         DiagOpts->CLFallbackMode);      TextDiagnostic::printDiagnosticMessage(OS, Level, DiagMessageStream.str(),                                             OS.tell() - StartOfLocationInfo,                                             DiagOpts->MessageLength,  | 

