SimulGraph::getVertex() now also returns a bool indicating if the returned

vertex was freshly created.

llvm-svn: 45550
This commit is contained in:
Ted Kremenek 2008-01-03 22:08:52 +00:00
parent 6abe02ada6
commit 9d375282cf
1 changed files with 6 additions and 4 deletions

View File

@ -58,8 +58,10 @@ public:
/// getVertex - Retrieve the vertex associated with a (Location,State) pair, /// getVertex - Retrieve the vertex associated with a (Location,State) pair,
/// where the 'Location' is a ProgramEdge in the CFG. If no vertex for /// where the 'Location' is a ProgramEdge in the CFG. If no vertex for
/// this pair exists, it is created. /// this pair exists, it is created. The bool returned in the pair
VertexTy* getVertex(const ProgramEdge& L, typename VertexTy::StateTy State) { /// is true if the vertex was freshly created.
std::pair<VertexTy*,bool> getVertex(const ProgramEdge& L,
typename VertexTy::StateTy State) {
// Retrieve the vertex set associated with Loc. // Retrieve the vertex set associated with Loc.
VertexSet& VSet = VerticesOfEdge[L]; VertexSet& VSet = VerticesOfEdge[L];
@ -75,7 +77,7 @@ public:
VertexTy::StateTy::Profile(profile, State); VertexTy::StateTy::Profile(profile, State);
if ((V = VSet.FindNodeOrInsertPos(profile,InsertPos))) if ((V = VSet.FindNodeOrInsertPos(profile,InsertPos)))
return V; return std::make_pair(V,false);
// No cache hit. Allocate a new vertex. // No cache hit. Allocate a new vertex.
V = (VertexTy*) Allocator.Allocate<VertexTy>(); V = (VertexTy*) Allocator.Allocate<VertexTy>();
@ -84,7 +86,7 @@ public:
// Insert the vertex into the vertex set and return it. // Insert the vertex into the vertex set and return it.
VSet.InsertNode(V,InsertPos); VSet.InsertNode(V,InsertPos);
return V; return std::make_pair(V,true);
} }
/// addRoot - Add a vertex to the set of roots. /// addRoot - Add a vertex to the set of roots.