diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2011-09-26 00:37:30 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2011-09-26 00:37:30 +0000 |
| commit | b59f9cb9ce7ed82ec54c8dad8cccfb143529ebc1 (patch) | |
| tree | 8d98a8d317700e7e0764ccbb792e24adcd6b1e4f /clang/lib/Frontend/TextDiagnosticPrinter.cpp | |
| parent | 09c65ce3a3daff09775bf4c120bad2d2427a4e19 (diff) | |
| download | bcm5719-llvm-b59f9cb9ce7ed82ec54c8dad8cccfb143529ebc1.tar.gz bcm5719-llvm-b59f9cb9ce7ed82ec54c8dad8cccfb143529ebc1.zip | |
Start a more correct pattern for factoring out the name printing. Slowly
I'm planning to switch a bunch of these over to use a raw_ostream
instead of += on a string object.
llvm-svn: 140488
Diffstat (limited to 'clang/lib/Frontend/TextDiagnosticPrinter.cpp')
| -rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index f645bd4925c..7edc8fc1ab3 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -1086,6 +1086,11 @@ static void PrintDiagnosticLevel(raw_ostream &OS, OS.resetColor(); } +static void PrintDiagnosticName(raw_ostream &OS, const DiagnosticInfo &Info) { + if (!DiagnosticIDs::isBuiltinNote(Info.getID())) + OS << " [" << DiagnosticIDs::getName(Info.getID()) << "]"; +} + void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level, const DiagnosticInfo &Info) { // Default implementation (Warnings/errors count). @@ -1121,13 +1126,11 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level, llvm::SmallString<100> OutStr; Info.FormatDiagnostic(OutStr); - if (DiagOpts->ShowNames && - !DiagnosticIDs::isBuiltinNote(Info.getID())) { - OutStr += " ["; - OutStr += DiagnosticIDs::getName(Info.getID()); - OutStr += "]"; - } - + llvm::raw_svector_ostream DiagMessageStream(OutStr); + if (DiagOpts->ShowNames) + PrintDiagnosticName(DiagMessageStream, Info); + DiagMessageStream.flush(); + std::string OptionName; if (DiagOpts->ShowOptionNames) { // Was this a warning mapped to an error using -Werror or pragma? |

