summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-01-11 16:36:20 +0000
committerTed Kremenek <kremenek@apple.com>2008-01-11 16:36:20 +0000
commit5906b9e79a85fa5ecdf26932c7f082ca6b4e867b (patch)
tree650e2559d53892c3900764e79a480e14a8ebf7b2
parentbf1816ea7b2b1184325367bfded8e859a69d52d1 (diff)
downloadbcm5719-llvm-5906b9e79a85fa5ecdf26932c7f082ca6b4e867b.tar.gz
bcm5719-llvm-5906b9e79a85fa5ecdf26932c7f082ca6b4e867b.zip
Added ProgramPoint.cpp, which implements several methods of the subclasses
of ProgramPoint. llvm-svn: 45866
-rw-r--r--clang/Analysis/ProgramPoint.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/clang/Analysis/ProgramPoint.cpp b/clang/Analysis/ProgramPoint.cpp
new file mode 100644
index 00000000000..c089e486988
--- /dev/null
+++ b/clang/Analysis/ProgramPoint.cpp
@@ -0,0 +1,65 @@
+//= ProgramPoint.cpp - Program Points for Path-Sensitive Analysis --*- C++ -*-//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements methods for subclasses of ProgramPoint.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/CFG.h"
+#include "clang/Analysis/ProgramPoint.h"
+
+using namespace clang;
+
+BlockEdge::BlockEdge(CFG& cfg, const CFGBlock* B1, const CFGBlock* B2) {
+ if (B1->succ_size() == 1) {
+ assert (*(B1->succ_begin()) == B2);
+ Data = reinterpret_cast<uintptr_t>(B1) | BlockEdgeSrcKind;
+ }
+ else if (B2->pred_size() == 1) {
+ assert (*(B2->pred_begin()) == B1);
+ Data = reinterpret_cast<uintptr_t>(B2) | BlockEdgeDstKind;
+ }
+ else
+ Data = reinterpret_cast<uintptr_t>(cfg.getBlockEdgeImpl(B1,B2))
+ | BlockEdgeAuxKind;
+}
+
+CFGBlock* BlockEdge::getSrc() const {
+ switch (getKind()) {
+ default:
+ assert (false && "Invalid BlockEdgeKind.");
+ return NULL;
+
+ case BlockEdgeSrcKind:
+ return reinterpret_cast<CFGBlock*>(getRawPtr());
+
+ case BlockEdgeDstKind:
+ return *(reinterpret_cast<CFGBlock*>(getRawPtr())->pred_begin());
+
+ case BlockEdgeAuxKind:
+ return reinterpret_cast<BPair*>(getRawPtr())->first;
+ }
+}
+
+CFGBlock* BlockEdge::getDst() const {
+ switch (getKind()) {
+ default:
+ assert (false && "Invalid BlockEdgeKind.");
+ return NULL;
+
+ case BlockEdgeSrcKind:
+ return *(reinterpret_cast<CFGBlock*>(getRawPtr())->succ_begin());
+
+ case BlockEdgeDstKind:
+ return reinterpret_cast<CFGBlock*>(getRawPtr());
+
+ case BlockEdgeAuxKind:
+ return reinterpret_cast<BPair*>(getRawPtr())->second;
+ }
+}
OpenPOWER on IntegriCloud