Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This is a concrete diagnostic client, which buffers the diagnostic messages. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Nico Weber | fd54ebc | 2008-08-05 23:33:20 +0000 | [diff] [blame] | 14 | #include "clang/Driver/TextDiagnosticBuffer.h" |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/SmallString.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | using namespace clang; |
| 17 | |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 18 | /// HandleDiagnostic - Store the errors, warnings, and notes that are |
| 19 | /// reported. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 20 | /// |
Chris Lattner | 0a14eee | 2008-11-18 07:04:44 +0000 | [diff] [blame] | 21 | void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level, |
| 22 | const DiagnosticInfo &Info) { |
Chris Lattner | f4c8396 | 2008-11-19 06:51:40 +0000 | [diff] [blame] | 23 | llvm::SmallString<100> StrC; |
| 24 | Info.FormatDiagnostic(StrC); |
| 25 | std::string Str(StrC.begin(), StrC.end()); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 26 | switch (Level) { |
| 27 | default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); |
Douglas Gregor | 233f74b | 2008-09-11 02:46:36 +0000 | [diff] [blame] | 28 | case Diagnostic::Note: |
Chris Lattner | 59ddeab | 2009-01-16 23:06:35 +0000 | [diff] [blame] | 29 | Notes.push_back(std::make_pair(Info.getLocation(), Str)); |
Douglas Gregor | 233f74b | 2008-09-11 02:46:36 +0000 | [diff] [blame] | 30 | break; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 31 | case Diagnostic::Warning: |
Chris Lattner | 59ddeab | 2009-01-16 23:06:35 +0000 | [diff] [blame] | 32 | Warnings.push_back(std::make_pair(Info.getLocation(), Str)); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 33 | break; |
| 34 | case Diagnostic::Error: |
Ben Laurie | 64ea69f | 2009-02-17 17:32:22 +0000 | [diff] [blame^] | 35 | case Diagnostic::Fatal: |
Chris Lattner | 59ddeab | 2009-01-16 23:06:35 +0000 | [diff] [blame] | 36 | Errors.push_back(std::make_pair(Info.getLocation(), Str)); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 37 | break; |
| 38 | } |
| 39 | } |