[cfe-commits] r140488 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Chandler Carruth
chandlerc at gmail.com
Sun Sep 25 17:37:30 PDT 2011
Author: chandlerc
Date: Sun Sep 25 19:37:30 2011
New Revision: 140488
URL: http://llvm.org/viewvc/llvm-project?rev=140488&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=140488&r1=140487&r2=140488&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun Sep 25 19:37:30 2011
@@ -1086,6 +1086,11 @@
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 @@
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?
More information about the cfe-commits
mailing list