Deleted Added
full compact
TextDiagnosticBuffer.cpp (198092) TextDiagnosticBuffer.cpp (199990)
1//===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 6 unchanged lines hidden (view full) ---

15#include "llvm/ADT/SmallString.h"
16using namespace clang;
17
18/// HandleDiagnostic - Store the errors, warnings, and notes that are
19/// reported.
20///
21void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
22 const DiagnosticInfo &Info) {
1//===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 6 unchanged lines hidden (view full) ---

15#include "llvm/ADT/SmallString.h"
16using namespace clang;
17
18/// HandleDiagnostic - Store the errors, warnings, and notes that are
19/// reported.
20///
21void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
22 const DiagnosticInfo &Info) {
23 llvm::SmallString<100> StrC;
24 Info.FormatDiagnostic(StrC);
25 std::string Str(StrC.begin(), StrC.end());
23 llvm::SmallString<100> Buf;
24 Info.FormatDiagnostic(Buf);
26 switch (Level) {
27 default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
28 case Diagnostic::Note:
25 switch (Level) {
26 default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
27 case Diagnostic::Note:
29 Notes.push_back(std::make_pair(Info.getLocation(), Str));
28 Notes.push_back(std::make_pair(Info.getLocation(), Buf.str()));
30 break;
31 case Diagnostic::Warning:
29 break;
30 case Diagnostic::Warning:
32 Warnings.push_back(std::make_pair(Info.getLocation(), Str));
31 Warnings.push_back(std::make_pair(Info.getLocation(), Buf.str()));
33 break;
34 case Diagnostic::Error:
35 case Diagnostic::Fatal:
32 break;
33 case Diagnostic::Error:
34 case Diagnostic::Fatal:
36 Errors.push_back(std::make_pair(Info.getLocation(), Str));
35 Errors.push_back(std::make_pair(Info.getLocation(), Buf.str()));
37 break;
38 }
39}
36 break;
37 }
38}
39
40void TextDiagnosticBuffer::FlushDiagnostics(Diagnostic &Diags) const {
41 // FIXME: Flush the diagnostics in order.
42 for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
43 Diags.Report(Diags.getCustomDiagID(Diagnostic::Error, it->second.c_str()));
44 for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
45 Diags.Report(Diags.getCustomDiagID(Diagnostic::Warning,it->second.c_str()));
46 for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
47 Diags.Report(Diags.getCustomDiagID(Diagnostic::Note, it->second.c_str()));
48}