blob: b138b1a24d2e412bc435010ce8f806a96c7d0347 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This is a concrete diagnostic client, which buffers the diagnostic messages.
11//
12//===----------------------------------------------------------------------===//
13
Nico Weberfd54ebc2008-08-05 23:33:20 +000014#include "clang/Driver/TextDiagnosticBuffer.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000015using namespace clang;
16
Douglas Gregor94b1dd22008-10-24 04:54:22 +000017/// HandleDiagnostic - Store the errors, warnings, and notes that are
18/// reported.
Reid Spencer5f016e22007-07-11 17:01:13 +000019///
Chris Lattner0a14eee2008-11-18 07:04:44 +000020void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
21 const DiagnosticInfo &Info) {
Reid Spencer5f016e22007-07-11 17:01:13 +000022 switch (Level) {
23 default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
Douglas Gregor233f74b2008-09-11 02:46:36 +000024 case Diagnostic::Note:
Chris Lattner0a14eee2008-11-18 07:04:44 +000025 Notes.push_back(std::make_pair(Info.getLocation().getLocation(),
26 FormatDiagnostic(Info)));
Douglas Gregor233f74b2008-09-11 02:46:36 +000027 break;
Reid Spencer5f016e22007-07-11 17:01:13 +000028 case Diagnostic::Warning:
Chris Lattner0a14eee2008-11-18 07:04:44 +000029 Warnings.push_back(std::make_pair(Info.getLocation().getLocation(),
30 FormatDiagnostic(Info)));
Reid Spencer5f016e22007-07-11 17:01:13 +000031 break;
32 case Diagnostic::Error:
Chris Lattner0a14eee2008-11-18 07:04:44 +000033 Errors.push_back(std::make_pair(Info.getLocation().getLocation(),
34 FormatDiagnostic(Info)));
Reid Spencer5f016e22007-07-11 17:01:13 +000035 break;
36 }
37}