diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-15 07:56:51 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-15 07:56:51 +0000 |
commit | d74cc397c8dc8fc02699b276f0ea02fb99a32804 (patch) | |
tree | adb9de162dd12b2f787a9221c753996777fc7d65 /clang/lib/Analysis/BugReporter.cpp | |
parent | 959990b840c0ec06ed5314ad1b3e089cd31b498b (diff) | |
download | bcm5719-llvm-d74cc397c8dc8fc02699b276f0ea02fb99a32804.tar.gz bcm5719-llvm-d74cc397c8dc8fc02699b276f0ea02fb99a32804.zip |
Teach BugReporter to "escape" the occurance of '%' characters in diagnostic messages when emitted results to the standard Diagnostics output. Fixes PR 6033.
llvm-svn: 93507
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index 13b7f4510d4..2a9531df60f 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -1818,8 +1818,23 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) { R->getRanges(Beg, End); Diagnostic& Diag = getDiagnostic(); FullSourceLoc L(R->getLocation(), getSourceManager()); - unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, - R->getShortDescription()); + + // Search the description for '%', as that will be interpretted as a + // format character by FormatDiagnostics. + llvm::StringRef desc = R->getShortDescription(); + unsigned ErrorDiag; + { + llvm::SmallString<512> TmpStr; + llvm::raw_svector_ostream Out(TmpStr); + for (llvm::StringRef::iterator I=desc.begin(), E=desc.end(); I!=E; ++I) + if (*I == '%') + Out << "%%"; + else + Out << *I; + + Out.flush(); + ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, TmpStr); + } switch (End-Beg) { default: assert(0 && "Don't handle this many ranges yet!"); |