summaryrefslogtreecommitdiffstats
path: root/lib/Frontend/TextDiagnosticBuffer.cpp
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2013-12-21 05:20:03 +0000
committerAlp Toker <alp@nuanti.com>2013-12-21 05:20:03 +0000
commita2cd7434fdd6e55d780b290aaef4365fd011252c (patch)
tree3179d0906341aaa145e9edac0f6b79799fb773ed /lib/Frontend/TextDiagnosticBuffer.cpp
parentf83451512ecb54410e1ca80a1b3a762051bcc2d1 (diff)
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/Frontend/TextDiagnosticBuffer.cpp')
-rw-r--r--lib/Frontend/TextDiagnosticBuffer.cpp35
1 files changed, 9 insertions, 26 deletions
diff --git a/lib/Frontend/TextDiagnosticBuffer.cpp b/lib/Frontend/TextDiagnosticBuffer.cpp
index 5821436a30..31fb665cbc 100644
--- a/lib/Frontend/TextDiagnosticBuffer.cpp
+++ b/lib/Frontend/TextDiagnosticBuffer.cpp
@@ -42,36 +42,19 @@ void TextDiagnosticBuffer::HandleDiagnostic(DiagnosticsEngine::Level Level,
}
}
-/// \brief Escape diagnostic texts to avoid problems when they are fed into the
-/// diagnostic formatter a second time.
-static StringRef escapeDiag(StringRef Str, SmallVectorImpl<char> &Buf) {
- size_t Pos = Str.find('%');
- if (Pos == StringRef::npos)
- return Str;
-
- // We found a '%'. Replace this and all following '%' with '%%'.
- Buf.clear();
- Buf.append(Str.data(), Str.data() + Pos);
- for (size_t I = Pos, E = Str.size(); I != E; ++I) {
- if (Str[I] == '%')
- Buf.push_back('%');
- Buf.push_back(Str[I]);
- }
-
- return StringRef(Buf.data(), Buf.size());
-}
-
void TextDiagnosticBuffer::FlushDiagnostics(DiagnosticsEngine &Diags) const {
- SmallVector<char, 64> Buf;
// FIXME: Flush the diagnostics in order.
for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
- Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error,
- escapeDiag(it->second, Buf)));
+ Diags.Report(it->first,
+ Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
+ << it->second;
for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
- Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning,
- escapeDiag(it->second, Buf)));
+ Diags.Report(it->first,
+ Diags.getCustomDiagID(DiagnosticsEngine::Warning, "%0"))
+ << it->second;
for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
- Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note,
- escapeDiag(it->second, Buf)));
+ Diags.Report(it->first,
+ Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
+ << it->second;
}