Ted Kremenek | 14f1457 | 2008-03-27 03:49:32 +0000 | [diff] [blame] | 1 | //===--- 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 | |
| 16 | using namespace clang; |
| 17 | |
| 18 | PathDiagnostic::~PathDiagnostic() { |
| 19 | for (iterator I = begin(), E = end(); I != E; ++I) delete &*I; |
| 20 | } |
| 21 | |
| 22 | void 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 | } |