blob: 26ac879dd04a64772ca51fb7bb34c711dbad3884 [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 Lattner07506182007-11-30 22:53:43 +000020void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags,
21 Diagnostic::Level Level,
Ted Kremenek9c728dc2007-12-12 22:39:36 +000022 FullSourceLoc Pos,
Reid Spencer5f016e22007-07-11 17:01:13 +000023 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!");
Douglas Gregor233f74b2008-09-11 02:46:36 +000030 case Diagnostic::Note:
31 Notes.push_back(std::make_pair(Pos.getLocation(),
32 FormatDiagnostic(Diags, Level, ID,
33 Strs, NumStrs)));
34 break;
Reid Spencer5f016e22007-07-11 17:01:13 +000035 case Diagnostic::Warning:
Ted Kremenek9c728dc2007-12-12 22:39:36 +000036 Warnings.push_back(std::make_pair(Pos.getLocation(),
37 FormatDiagnostic(Diags, Level, ID,
38 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000039 break;
40 case Diagnostic::Error:
Ted Kremenek9c728dc2007-12-12 22:39:36 +000041 Errors.push_back(std::make_pair(Pos.getLocation(),
42 FormatDiagnostic(Diags, Level, ID,
43 Strs, NumStrs)));
Reid Spencer5f016e22007-07-11 17:01:13 +000044 break;
45 }
46}