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 | a2cd7434fdd6e55d780b290aaef4365fd011252c (patch) | |
| tree | 3179d0906341aaa145e9edac0f6b79799fb773ed /lib/CodeGen/CodeGenAction.cpp | |
| parent | f83451512ecb54410e1ca80a1b3a762051bcc2d1 (diff) | |
| download | clang-a2cd7434fdd6e55d780b290aaef4365fd011252c.tar.gz clang-a2cd7434fdd6e55d780b290aaef4365fd011252c.tar.bz2 clang-a2cd7434fdd6e55d780b290aaef4365fd011252c.tar.xz | |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenAction.cpp')
| -rw-r--r-- | lib/CodeGen/CodeGenAction.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 6fceabd109..8efeba68e5 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/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(); |
