diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-11-19 06:51:40 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-11-19 06:51:40 +0000 | 
| commit | 23be0674074db5a815ba2a0d2aacc36c1372a660 (patch) | |
| tree | c991db6f082a1f2800c0ef6adfce7d9454f18a27 /clang/lib/Driver/TextDiagnosticBuffer.cpp | |
| parent | 48fe79e9e161fba7516406d4bcebf3023a0fb60d (diff) | |
| download | bcm5719-llvm-23be0674074db5a815ba2a0d2aacc36c1372a660.tar.gz bcm5719-llvm-23be0674074db5a815ba2a0d2aacc36c1372a660.zip | |
rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics.  If you
want a % in a diagnostic, use %%.
llvm-svn: 59596
Diffstat (limited to 'clang/lib/Driver/TextDiagnosticBuffer.cpp')
| -rw-r--r-- | clang/lib/Driver/TextDiagnosticBuffer.cpp | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/clang/lib/Driver/TextDiagnosticBuffer.cpp b/clang/lib/Driver/TextDiagnosticBuffer.cpp index b138b1a24d2..5032cdb0b5d 100644 --- a/clang/lib/Driver/TextDiagnosticBuffer.cpp +++ b/clang/lib/Driver/TextDiagnosticBuffer.cpp @@ -12,6 +12,7 @@  //===----------------------------------------------------------------------===//  #include "clang/Driver/TextDiagnosticBuffer.h" +#include "llvm/ADT/SmallString.h"  using namespace clang;  /// HandleDiagnostic - Store the errors, warnings, and notes that are @@ -19,19 +20,19 @@ using namespace clang;  ///   void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,                                              const DiagnosticInfo &Info) { +  llvm::SmallString<100> StrC; +  Info.FormatDiagnostic(StrC); +  std::string Str(StrC.begin(), StrC.end());    switch (Level) {    default: assert(0 && "Diagnostic not handled during diagnostic buffering!");    case Diagnostic::Note: -    Notes.push_back(std::make_pair(Info.getLocation().getLocation(), -                                   FormatDiagnostic(Info))); +    Notes.push_back(std::make_pair(Info.getLocation().getLocation(), Str));      break;    case Diagnostic::Warning: -    Warnings.push_back(std::make_pair(Info.getLocation().getLocation(), -                                      FormatDiagnostic(Info))); +    Warnings.push_back(std::make_pair(Info.getLocation().getLocation(), Str));      break;    case Diagnostic::Error: -    Errors.push_back(std::make_pair(Info.getLocation().getLocation(), -                                    FormatDiagnostic(Info))); +    Errors.push_back(std::make_pair(Info.getLocation().getLocation(), Str));      break;    }  } | 

