From bc043f27f4f2374066f926dd1f6a98bea697df0f Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Sat, 21 Dec 2013 05:20:03 +0000 Subject: Fix getCustomDiagID() usage in CodeGen and TextDiagnosticBuffer DiagIDs are a cached resource generally only constructed from compile-time constant or stable format strings. Escaping arbitrary messages and constructing DiagIDs from them didn't make sense. llvm-svn: 197856 --- clang/lib/CodeGen/CodeGenAction.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenAction.cpp') diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 6fceabd109f..8efeba68e51 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -399,24 +399,15 @@ void CodeGenAction::ExecuteAction() { SM.getFileEntryForID(SM.getMainFileID()), Err.getLineNo(), Err.getColumnNo() + 1); - // Get a custom diagnostic for the error. We strip off a leading - // diagnostic code if there is one. + // Strip off a leading diagnostic code if there is one. StringRef Msg = Err.getMessage(); if (Msg.startswith("error: ")) Msg = Msg.substr(7); - // Escape '%', which is interpreted as a format character. - SmallString<128> EscapedMessage; - for (unsigned i = 0, e = Msg.size(); i != e; ++i) { - if (Msg[i] == '%') - EscapedMessage += '%'; - EscapedMessage += Msg[i]; - } - - unsigned DiagID = CI.getDiagnostics().getCustomDiagID( - DiagnosticsEngine::Error, EscapedMessage); + unsigned DiagID = + CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0"); - CI.getDiagnostics().Report(Loc, DiagID); + CI.getDiagnostics().Report(Loc, DiagID) << Msg; return; } const TargetOptions &TargetOpts = CI.getTargetOpts(); -- cgit v1.2.3