aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-27 03:49:32 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-27 03:49:32 +0000
commitd3abcdfa30e476571e214d5d74fb12ac43d153ba (patch)
tree84ead0582f0ec0638ee65f88a87827aa70a3056d /lib
parentc74840329eeee429d9527cf2f3694a74accd1603 (diff)
Added classes "PathDiagnosticPiece", "PathDiagnostic", and "PathDiagnosticClient", which encapsulate diagnostic reporting for paths.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48861 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/PathDiagnostic.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
new file mode 100644
index 0000000000..a0be80aa5b
--- /dev/null
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -0,0 +1,52 @@
+//===--- PathDiagnostic.cpp - Path-Specific Diagnostic Handling -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the PathDiagnostic-related interfaces.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/PathDiagnostic.h"
+
+using namespace clang;
+
+PathDiagnostic::~PathDiagnostic() {
+ for (iterator I = begin(), E = end(); I != E; ++I) delete &*I;
+}
+
+void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,
+ Diagnostic::Level DiagLevel,
+ FullSourceLoc Pos,
+ diag::kind ID,
+ const std::string *Strs,
+ unsigned NumStrs,
+ const SourceRange *Ranges,
+ unsigned NumRanges) {
+
+ // Create a PathDiagnostic with a single piece.
+
+ PathDiagnostic D(DiagLevel, ID);
+
+ PathDiagnosticPiece* P = new PathDiagnosticPiece(Pos);
+
+ while (NumStrs) {
+ P->addString(*Strs);
+ --NumStrs;
+ ++Strs;
+ }
+
+ while (NumRanges) {
+ P->addRange(*Ranges);
+ --NumRanges;
+ ++Ranges;
+ }
+
+ D.push_front(P);
+
+ HandlePathDiagnostic(Diags, D);
+}