diff options
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r-- | clang/lib/Driver/TextDiagnosticBuffer.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Driver/TextDiagnosticPrinter.cpp | 11 |
2 files changed, 14 insertions, 10 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; } } diff --git a/clang/lib/Driver/TextDiagnosticPrinter.cpp b/clang/lib/Driver/TextDiagnosticPrinter.cpp index 3b8ec10ec81..cfbe8a7f927 100644 --- a/clang/lib/Driver/TextDiagnosticPrinter.cpp +++ b/clang/lib/Driver/TextDiagnosticPrinter.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Lex/Lexer.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/ADT/SmallString.h" using namespace clang; void TextDiagnosticPrinter:: @@ -138,13 +139,15 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, case Diagnostic::Warning: OS << "warning: "; break; case Diagnostic::Error: OS << "error: "; break; case Diagnostic::Fatal: OS << "fatal error: "; break; - break; } - OS << FormatDiagnostic(Info) << "\n"; + llvm::SmallString<100> OutStr; + Info.FormatDiagnostic(OutStr); + OS.write(OutStr.begin(), OutStr.size()); + OS << '\n'; - if (CaretDiagnostics && Pos.isValid() && ((LastLoc != Pos) || - Info.getNumRanges())) { + if (CaretDiagnostics && Pos.isValid() && + ((LastLoc != Pos) || Info.getNumRanges())) { // Cache the LastLoc, it allows us to omit duplicate source/caret spewage. LastLoc = Pos; |