diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-01-13 04:56:13 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-01-13 04:56:13 +0000 |
| commit | eb370bc386bd8957f8d4d030b7dbfbb6cb7ad1ff (patch) | |
| tree | cb9393cc110e4ca8ba3fd9102539b48531a5646d /clang/Analysis/ExplodedGraph.cpp | |
| parent | 49bbee0b1d1c0736ecb3b29190510a8be1b91d78 (diff) | |
| download | bcm5719-llvm-eb370bc386bd8957f8d4d030b7dbfbb6cb7ad1ff.tar.gz bcm5719-llvm-eb370bc386bd8957f8d4d030b7dbfbb6cb7ad1ff.zip | |
Created ExplodedGraph.cpp and moved most method implementations of
ExplodedNodeImpl::NodeGroup from being defined inline to being defined
"out-of-line" in ExplodedGraph.cpp. This removes a dependence on including
<vector> in ExplodedGraph.h, and will hopefully result in smaller generated code
with negligible performance impact.
llvm-svn: 45928
Diffstat (limited to 'clang/Analysis/ExplodedGraph.cpp')
| -rw-r--r-- | clang/Analysis/ExplodedGraph.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/clang/Analysis/ExplodedGraph.cpp b/clang/Analysis/ExplodedGraph.cpp new file mode 100644 index 00000000000..4c9f0265328 --- /dev/null +++ b/clang/Analysis/ExplodedGraph.cpp @@ -0,0 +1,70 @@ +//=-- ExplodedGraph.cpp - Local, Path-Sens. "Exploded Graph" -*- 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 template classes ExplodedNode and ExplodedGraph, +// which represent a path-sensitive, intra-procedural "exploded graph." +// +//===----------------------------------------------------------------------===// + +#include "clang/Analysis/PathSensitive/ExplodedGraph.h" +#include <vector> + +using namespace clang; + + +static inline std::vector<ExplodedNodeImpl*>& getVector(void* P) { + return *reinterpret_cast<std::vector<ExplodedNodeImpl*>*>(P); +} + +void ExplodedNodeImpl::NodeGroup::addNode(ExplodedNodeImpl* N) { + if (getKind() == Size1) { + if (ExplodedNodeImpl* NOld = getNode()) { + std::vector<ExplodedNodeImpl*>* V = new std::vector<ExplodedNodeImpl*>(); + V->push_back(NOld); + V->push_back(N); + P = reinterpret_cast<uintptr_t>(V) & SizeOther; + } + else + P = reinterpret_cast<uintptr_t>(N); + } + else + getVector(getPtr()).push_back(N); +} + +bool ExplodedNodeImpl::NodeGroup::empty() const { + if (getKind() == Size1) + return getNode() ? false : true; + else + return getVector(getPtr()).empty(); +} + +unsigned ExplodedNodeImpl::NodeGroup::size() const { + if (getKind() == Size1) + return getNode() ? 1 : 0; + else + return getVector(getPtr()).size(); +} + +ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::begin() const { + if (getKind() == Size1) + return (ExplodedNodeImpl**) &P; + else + return const_cast<ExplodedNodeImpl**>(&*(getVector(getPtr()).begin())); +} + +ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::end() const { + if (getKind() == Size1) + return ((ExplodedNodeImpl**) &P)+1; + else + return const_cast<ExplodedNodeImpl**>(&*(getVector(getPtr()).rbegin())+1); +} + +ExplodedNodeImpl::NodeGroup::~NodeGroup() { + if (getKind() == SizeOther) delete &getVector(getPtr()); +} |

