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/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
index aed83ea..29ea8c0 100644
--- a/lib/Analysis/PathDiagnostic.cpp
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/PathDiagnostic.h"
+#include "llvm/ADT/SmallString.h"
#include <sstream>
-
using namespace clang;
PathDiagnostic::~PathDiagnostic() {
@@ -36,10 +36,13 @@
case Diagnostic::Fatal: LevelStr = "fatal error: "; break;
}
- std::string Msg = FormatDiagnostic(Info);
+ llvm::SmallString<100> StrC;
+ StrC += LevelStr;
+ Info.FormatDiagnostic(StrC);
PathDiagnosticPiece *P =
- new PathDiagnosticPiece(Info.getLocation(), LevelStr+Msg);
+ new PathDiagnosticPiece(Info.getLocation(),
+ std::string(StrC.begin(), StrC.end()));
for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
P->addRange(Info.getRange(i));