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" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 15 | using namespace clang; |
| 16 | |
| 17 | /// HandleDiagnostic - Store the errors & warnings that are reported. |
| 18 | /// |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 19 | void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags, |
| 20 | Diagnostic::Level Level, |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 21 | FullSourceLoc Pos, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 22 | diag::kind ID, |
| 23 | const std::string *Strs, |
| 24 | unsigned NumStrs, |
| 25 | const SourceRange *, |
| 26 | unsigned) { |
| 27 | switch (Level) { |
| 28 | default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); |
Douglas Gregor | 233f74b | 2008-09-11 02:46:36 +0000 | [diff] [blame] | 29 | case Diagnostic::Note: |
| 30 | Notes.push_back(std::make_pair(Pos.getLocation(), |
| 31 | FormatDiagnostic(Diags, Level, ID, |
| 32 | Strs, NumStrs))); |
| 33 | break; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 34 | case Diagnostic::Warning: |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 35 | Warnings.push_back(std::make_pair(Pos.getLocation(), |
| 36 | FormatDiagnostic(Diags, Level, ID, |
| 37 | Strs, NumStrs))); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 38 | break; |
| 39 | case Diagnostic::Error: |
Ted Kremenek | 9c728dc | 2007-12-12 22:39:36 +0000 | [diff] [blame] | 40 | Errors.push_back(std::make_pair(Pos.getLocation(), |
| 41 | FormatDiagnostic(Diags, Level, ID, |
| 42 | Strs, NumStrs))); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 43 | break; |
| 44 | } |
| 45 | } |