diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-21 05:20:03 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-21 05:20:03 +0000 |
commit | bc043f27f4f2374066f926dd1f6a98bea697df0f (patch) | |
tree | d85bbc137d3e2029ae4723fbd310d39532f3069d /clang/lib/CodeGen/CodeGenAction.cpp | |
parent | 9477f9e52f20311ab4a15077b72dc48c81611555 (diff) | |
download | bcm5719-llvm-bc043f27f4f2374066f926dd1f6a98bea697df0f.tar.gz bcm5719-llvm-bc043f27f4f2374066f926dd1f6a98bea697df0f.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
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(); |