blob: a0be80aa5b1507ac5b87710c3bdbfc093d385612 [file] [log] [blame]
Ted Kremenek14f14572008-03-27 03:49:32 +00001//===--- PathDiagnostic.cpp - Path-Specific Diagnostic Handling -*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the PathDiagnostic-related interfaces.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Analysis/PathDiagnostic.h"
15
16using namespace clang;
17
18PathDiagnostic::~PathDiagnostic() {
19 for (iterator I = begin(), E = end(); I != E; ++I) delete &*I;
20}
21
22void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,
23 Diagnostic::Level DiagLevel,
24 FullSourceLoc Pos,
25 diag::kind ID,
26 const std::string *Strs,
27 unsigned NumStrs,
28 const SourceRange *Ranges,
29 unsigned NumRanges) {
30
31 // Create a PathDiagnostic with a single piece.
32
33 PathDiagnostic D(DiagLevel, ID);
34
35 PathDiagnosticPiece* P = new PathDiagnosticPiece(Pos);
36
37 while (NumStrs) {
38 P->addString(*Strs);
39 --NumStrs;
40 ++Strs;
41 }
42
43 while (NumRanges) {
44 P->addRange(*Ranges);
45 --NumRanges;
46 ++Ranges;
47 }
48
49 D.push_front(P);
50
51 HandlePathDiagnostic(Diags, D);
52}