[analyzer] Eliminate InterExplodedGraphMap class and NodeBackMap typedef.
...in favor of this typedef:
typedef llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>
InterExplodedGraphMap;
Use this everywhere the previous class and typedef were used.
Took the opportunity to ArrayRef-ize ExplodedGraph::trim while I'm at it.
No functionality change.
llvm-svn: 177215
This commit is contained in:
@@ -331,45 +331,31 @@ ExplodedNode *ExplodedGraph::getNode(const ProgramPoint &L,
|
||||
return V;
|
||||
}
|
||||
|
||||
std::pair<ExplodedGraph*, InterExplodedGraphMap*>
|
||||
ExplodedGraph::Trim(const NodeTy* const* NBeg, const NodeTy* const* NEnd,
|
||||
llvm::DenseMap<const void*, const void*> *InverseMap) const {
|
||||
ExplodedGraph *
|
||||
ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
|
||||
InterExplodedGraphMap *ForwardMap,
|
||||
InterExplodedGraphMap *InverseMap) const{
|
||||
|
||||
if (NBeg == NEnd)
|
||||
return std::make_pair((ExplodedGraph*) 0,
|
||||
(InterExplodedGraphMap*) 0);
|
||||
|
||||
assert (NBeg < NEnd);
|
||||
|
||||
OwningPtr<InterExplodedGraphMap> M(new InterExplodedGraphMap());
|
||||
|
||||
ExplodedGraph* G = TrimInternal(NBeg, NEnd, M.get(), InverseMap);
|
||||
|
||||
return std::make_pair(static_cast<ExplodedGraph*>(G), M.take());
|
||||
}
|
||||
|
||||
ExplodedGraph*
|
||||
ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
|
||||
const ExplodedNode* const* EndSources,
|
||||
InterExplodedGraphMap* M,
|
||||
llvm::DenseMap<const void*, const void*> *InverseMap) const {
|
||||
if (Nodes.empty())
|
||||
return 0;
|
||||
|
||||
typedef llvm::DenseSet<const ExplodedNode*> Pass1Ty;
|
||||
Pass1Ty Pass1;
|
||||
|
||||
typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*> Pass2Ty;
|
||||
Pass2Ty& Pass2 = M->M;
|
||||
typedef InterExplodedGraphMap Pass2Ty;
|
||||
InterExplodedGraphMap Pass2Scratch;
|
||||
Pass2Ty &Pass2 = ForwardMap ? *ForwardMap : Pass2Scratch;
|
||||
|
||||
SmallVector<const ExplodedNode*, 10> WL1, WL2;
|
||||
|
||||
// ===- Pass 1 (reverse DFS) -===
|
||||
for (const ExplodedNode* const* I = BeginSources; I != EndSources; ++I) {
|
||||
for (ArrayRef<const NodeTy *>::iterator I = Sinks.begin(), E = Sinks.end();
|
||||
I != E; ++I) {
|
||||
if (*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.
|
||||
// Process the first worklist until it is empty.
|
||||
while (!WL1.empty()) {
|
||||
const ExplodedNode *N = WL1.back();
|
||||
WL1.pop_back();
|
||||
@@ -432,7 +418,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
|
||||
if (PI == Pass2.end())
|
||||
continue;
|
||||
|
||||
NewN->addPredecessor(PI->second, *G);
|
||||
NewN->addPredecessor(const_cast<ExplodedNode *>(PI->second), *G);
|
||||
}
|
||||
|
||||
// In the case that some of the intended successors of NewN have already
|
||||
@@ -443,7 +429,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
|
||||
I != E; ++I) {
|
||||
Pass2Ty::iterator PI = Pass2.find(*I);
|
||||
if (PI != Pass2.end()) {
|
||||
PI->second->addPredecessor(NewN, *G);
|
||||
const_cast<ExplodedNode *>(PI->second)->addPredecessor(NewN, *G);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -456,13 +442,3 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
|
||||
return G;
|
||||
}
|
||||
|
||||
void InterExplodedGraphMap::anchor() { }
|
||||
|
||||
ExplodedNode*
|
||||
InterExplodedGraphMap::getMappedNode(const ExplodedNode *N) const {
|
||||
llvm::DenseMap<const ExplodedNode*, ExplodedNode*>::const_iterator I =
|
||||
M.find(N);
|
||||
|
||||
return I == M.end() ? 0 : I->second;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user