blob: d0e2f900c554a537402d3d1ada5ff225c2253716 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- 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"
16using namespace clang;
17
18/// HandleDiagnostic - Store the errors & warnings that are reported.
19///
Chris Lattner07506182007-11-30 22:53:43 +000020void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags,
21 Diagnostic::Level Level,
Reid Spencer5f016e22007-07-11 17:01:13 +000022 SourceLocation Pos,
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:
Chris Lattner07506182007-11-30 22:53:43 +000031 Warnings.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID,
32 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000033 break;
34 case Diagnostic::Error:
Chris Lattner07506182007-11-30 22:53:43 +000035 Errors.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID,
36 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000037 break;
38 }
39}