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