rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics. If you
want a % in a diagnostic, use %%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59596 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/TextDiagnosticBuffer.cpp b/lib/Driver/TextDiagnosticBuffer.cpp
index b138b1a..5032cdb 100644
--- a/lib/Driver/TextDiagnosticBuffer.cpp
+++ b/lib/Driver/TextDiagnosticBuffer.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/TextDiagnosticBuffer.h"
+#include "llvm/ADT/SmallString.h"
using namespace clang;
/// HandleDiagnostic - Store the errors, warnings, and notes that are
@@ -19,19 +20,19 @@
///
void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
const DiagnosticInfo &Info) {
+ llvm::SmallString<100> StrC;
+ Info.FormatDiagnostic(StrC);
+ std::string Str(StrC.begin(), StrC.end());
switch (Level) {
default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
case Diagnostic::Note:
- Notes.push_back(std::make_pair(Info.getLocation().getLocation(),
- FormatDiagnostic(Info)));
+ Notes.push_back(std::make_pair(Info.getLocation().getLocation(), Str));
break;
case Diagnostic::Warning:
- Warnings.push_back(std::make_pair(Info.getLocation().getLocation(),
- FormatDiagnostic(Info)));
+ Warnings.push_back(std::make_pair(Info.getLocation().getLocation(), Str));
break;
case Diagnostic::Error:
- Errors.push_back(std::make_pair(Info.getLocation().getLocation(),
- FormatDiagnostic(Info)));
+ Errors.push_back(std::make_pair(Info.getLocation().getLocation(), Str));
break;
}
}