blob: 1df93750f0dc20d5fab905f30dd342e371271ee9 [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
17/// HandleDiagnostic - Store the errors & warnings that are reported.
18///
Chris Lattner07506182007-11-30 22:53:43 +000019void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags,
20 Diagnostic::Level Level,
Ted Kremenek9c728dc2007-12-12 22:39:36 +000021 FullSourceLoc Pos,
Reid Spencer5f016e22007-07-11 17:01:13 +000022 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 Gregor233f74b2008-09-11 02:46:36 +000029 case Diagnostic::Note:
30 Notes.push_back(std::make_pair(Pos.getLocation(),
31 FormatDiagnostic(Diags, Level, ID,
32 Strs, NumStrs)));
33 break;
Reid Spencer5f016e22007-07-11 17:01:13 +000034 case Diagnostic::Warning:
Ted Kremenek9c728dc2007-12-12 22:39:36 +000035 Warnings.push_back(std::make_pair(Pos.getLocation(),
36 FormatDiagnostic(Diags, Level, ID,
37 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000038 break;
39 case Diagnostic::Error:
Ted Kremenek9c728dc2007-12-12 22:39:36 +000040 Errors.push_back(std::make_pair(Pos.getLocation(),
41 FormatDiagnostic(Diags, Level, ID,
42 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000043 break;
44 }
45}