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 | // |
| 5 | // This file was developed by Bill Wendling and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 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, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 22 | SourceLocation Pos, |
| 23 | diag::kind ID, |
Ted Kremenek | 7a9d49f | 2007-12-11 21:27:55 +0000 | [diff] [blame] | 24 | SourceManager& SrcMgr, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 25 | const std::string *Strs, |
| 26 | unsigned NumStrs, |
| 27 | const SourceRange *, |
| 28 | unsigned) { |
| 29 | switch (Level) { |
| 30 | default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); |
| 31 | case Diagnostic::Warning: |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 32 | Warnings.push_back(std::make_pair(Pos, 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: |
Chris Lattner | 0750618 | 2007-11-30 22:53:43 +0000 | [diff] [blame] | 36 | Errors.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID, |
| 37 | Strs, NumStrs))); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 38 | break; |
| 39 | } |
| 40 | } |