Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 1 | //===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 959e5be | 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. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This is a concrete diagnostic client, which buffers the diagnostic messages. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Nico Weber | 0e13eaa | 2008-08-05 23:33:20 +0000 | [diff] [blame] | 14 | #include "clang/Driver/TextDiagnosticBuffer.h" |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 15 | using namespace clang; |
| 16 | |
Douglas Gregor | bb46150 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 17 | /// HandleDiagnostic - Store the errors, warnings, and notes that are |
| 18 | /// reported. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 19 | /// |
Chris Lattner | 6948ae6 | 2008-11-18 07:04:44 +0000 | [diff] [blame^] | 20 | void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level, |
| 21 | const DiagnosticInfo &Info) { |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 22 | switch (Level) { |
| 23 | default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); |
Douglas Gregor | 6293fd1 | 2008-09-11 02:46:36 +0000 | [diff] [blame] | 24 | case Diagnostic::Note: |
Chris Lattner | 6948ae6 | 2008-11-18 07:04:44 +0000 | [diff] [blame^] | 25 | Notes.push_back(std::make_pair(Info.getLocation().getLocation(), |
| 26 | FormatDiagnostic(Info))); |
Douglas Gregor | 6293fd1 | 2008-09-11 02:46:36 +0000 | [diff] [blame] | 27 | break; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 28 | case Diagnostic::Warning: |
Chris Lattner | 6948ae6 | 2008-11-18 07:04:44 +0000 | [diff] [blame^] | 29 | Warnings.push_back(std::make_pair(Info.getLocation().getLocation(), |
| 30 | FormatDiagnostic(Info))); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 31 | break; |
| 32 | case Diagnostic::Error: |
Chris Lattner | 6948ae6 | 2008-11-18 07:04:44 +0000 | [diff] [blame^] | 33 | Errors.push_back(std::make_pair(Info.getLocation().getLocation(), |
| 34 | FormatDiagnostic(Info))); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 35 | break; |
| 36 | } |
| 37 | } |