aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ExplodedGraph.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
committerMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
commit1eb4433ac451dc16f4133a88af2d002ac26c58ef (patch)
tree07065b80cb7787bb7b9ffcb985196007a57e86f7 /lib/Analysis/ExplodedGraph.cpp
parent79d39f92590cf2e91bf81486b02cd1156d13ca54 (diff)
Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ExplodedGraph.cpp')
-rw-r--r--lib/Analysis/ExplodedGraph.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/lib/Analysis/ExplodedGraph.cpp b/lib/Analysis/ExplodedGraph.cpp
index 88bb120f5d..463b171249 100644
--- a/lib/Analysis/ExplodedGraph.cpp
+++ b/lib/Analysis/ExplodedGraph.cpp
@@ -64,10 +64,10 @@ void ExplodedNode::addPredecessor(ExplodedNode* V) {
}
void ExplodedNode::NodeGroup::addNode(ExplodedNode* N) {
-
+
assert ((reinterpret_cast<uintptr_t>(N) & Mask) == 0x0);
assert (!getFlag());
-
+
if (getKind() == Size1) {
if (ExplodedNode* NOld = getNode()) {
std::vector<ExplodedNode*>* V = new std::vector<ExplodedNode*>();
@@ -93,7 +93,7 @@ void ExplodedNode::NodeGroup::addNode(ExplodedNode* N) {
unsigned ExplodedNode::NodeGroup::size() const {
if (getFlag())
return 0;
-
+
if (getKind() == Size1)
return getNode() ? 1 : 0;
else
@@ -103,7 +103,7 @@ unsigned ExplodedNode::NodeGroup::size() const {
ExplodedNode** ExplodedNode::NodeGroup::begin() const {
if (getFlag())
return NULL;
-
+
if (getKind() == Size1)
return (ExplodedNode**) (getPtr() ? &P : NULL);
else
@@ -113,7 +113,7 @@ ExplodedNode** ExplodedNode::NodeGroup::begin() const {
ExplodedNode** ExplodedNode::NodeGroup::end() const {
if (getFlag())
return NULL;
-
+
if (getKind() == Size1)
return (ExplodedNode**) (getPtr() ? &P+1 : NULL);
else {
@@ -127,47 +127,47 @@ ExplodedNode::NodeGroup::~NodeGroup() {
if (getKind() == SizeOther) delete &getVector(getPtr());
}
-ExplodedNode *ExplodedGraph::getNode(const ProgramPoint& L,
+ExplodedNode *ExplodedGraph::getNode(const ProgramPoint& L,
const GRState* State, bool* IsNew) {
// Profile 'State' to determine if we already have an existing node.
- llvm::FoldingSetNodeID profile;
+ llvm::FoldingSetNodeID profile;
void* InsertPos = 0;
-
+
NodeTy::Profile(profile, L, State);
NodeTy* V = Nodes.FindNodeOrInsertPos(profile, InsertPos);
-
+
if (!V) {
// Allocate a new node.
V = (NodeTy*) Allocator.Allocate<NodeTy>();
new (V) NodeTy(L, State);
-
+
// Insert the node into the node set and return it.
Nodes.InsertNode(V, InsertPos);
-
+
++NumNodes;
-
+
if (IsNew) *IsNew = true;
}
else
if (IsNew) *IsNew = false;
-
+
return V;
}
std::pair<ExplodedGraph*, InterExplodedGraphMap*>
ExplodedGraph::Trim(const NodeTy* const* NBeg, const NodeTy* const* NEnd,
llvm::DenseMap<const void*, const void*> *InverseMap) const {
-
+
if (NBeg == NEnd)
return std::make_pair((ExplodedGraph*) 0,
(InterExplodedGraphMap*) 0);
-
+
assert (NBeg < NEnd);
llvm::OwningPtr<InterExplodedGraphMap> M(new InterExplodedGraphMap());
-
+
ExplodedGraph* G = TrimInternal(NBeg, NEnd, M.get(), InverseMap);
-
+
return std::make_pair(static_cast<ExplodedGraph*>(G), M.take());
}
@@ -179,10 +179,10 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
typedef llvm::DenseSet<const ExplodedNode*> Pass1Ty;
Pass1Ty Pass1;
-
+
typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*> Pass2Ty;
Pass2Ty& Pass2 = M->M;
-
+
llvm::SmallVector<const ExplodedNode*, 10> WL1, WL2;
// ===- Pass 1 (reverse DFS) -===
@@ -190,59 +190,59 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
assert(*I);
WL1.push_back(*I);
}
-
+
// Process the first worklist until it is empty. Because it is a std::list
// it acts like a FIFO queue.
while (!WL1.empty()) {
const ExplodedNode *N = WL1.back();
WL1.pop_back();
-
+
// Have we already visited this node? If so, continue to the next one.
if (Pass1.count(N))
continue;
// Otherwise, mark this node as visited.
Pass1.insert(N);
-
+
// If this is a root enqueue it to the second worklist.
if (N->Preds.empty()) {
WL2.push_back(N);
continue;
}
-
+
// Visit our predecessors and enqueue them.
for (ExplodedNode** I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I)
WL1.push_back(*I);
}
-
+
// We didn't hit a root? Return with a null pointer for the new graph.
if (WL2.empty())
return 0;
// Create an empty graph.
ExplodedGraph* G = MakeEmptyGraph();
-
- // ===- Pass 2 (forward DFS to construct the new graph) -===
+
+ // ===- Pass 2 (forward DFS to construct the new graph) -===
while (!WL2.empty()) {
const ExplodedNode* N = WL2.back();
WL2.pop_back();
-
+
// Skip this node if we have already processed it.
if (Pass2.find(N) != Pass2.end())
continue;
-
+
// Create the corresponding node in the new graph and record the mapping
// from the old node to the new node.
ExplodedNode* NewN = G->getNode(N->getLocation(), N->State, NULL);
Pass2[N] = NewN;
-
+
// Also record the reverse mapping from the new node to the old node.
if (InverseMap) (*InverseMap)[NewN] = N;
-
+
// If this node is a root, designate it as such in the graph.
if (N->Preds.empty())
G->addRoot(NewN);
-
+
// In the case that some of the intended predecessors of NewN have already
// been created, we should hook them up as predecessors.
@@ -252,7 +252,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
Pass2Ty::iterator PI = Pass2.find(*I);
if (PI == Pass2.end())
continue;
-
+
NewN->addPredecessor(PI->second);
}
@@ -261,7 +261,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
// the new nodes from the original graph that should have nodes created
// in the new graph.
for (ExplodedNode **I=N->Succs.begin(), **E=N->Succs.end(); I!=E; ++I) {
- Pass2Ty::iterator PI = Pass2.find(*I);
+ Pass2Ty::iterator PI = Pass2.find(*I);
if (PI != Pass2.end()) {
PI->second->addPredecessor(NewN);
continue;
@@ -271,12 +271,12 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
if (Pass1.count(*I))
WL2.push_back(*I);
}
-
+
// Finally, explictly mark all nodes without any successors as sinks.
if (N->isSink())
NewN->markAsSink();
}
-
+
return G;
}