From: Ted Kremenek Date: Sun, 13 Jan 2008 05:33:04 +0000 (+0000) Subject: Moved destructor logic of templated class ExplodedGraph to non-templated X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d880c1829395f55129fee31e2df542a475ec3cd7;p=clang Moved destructor logic of templated class ExplodedGraph to non-templated parent class ExplodedGraphImpl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45930 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/ExplodedGraph.cpp b/Analysis/ExplodedGraph.cpp index 4c9f026532..61548e9b27 100644 --- a/Analysis/ExplodedGraph.cpp +++ b/Analysis/ExplodedGraph.cpp @@ -68,3 +68,20 @@ ExplodedNodeImpl** ExplodedNodeImpl::NodeGroup::end() const { ExplodedNodeImpl::NodeGroup::~NodeGroup() { if (getKind() == SizeOther) delete &getVector(getPtr()); } + + +ExplodedGraphImpl::~ExplodedGraphImpl() { + // Delete the FoldingSet's in Nodes. Note that the contents + // of the FoldingSets are nodes allocated from the BumpPtrAllocator, + // so all of those will get nuked when that object is destroyed. + for (EdgeNodeSetMap::iterator I=Nodes.begin(), E=Nodes.end(); I!=E; ++I) { + llvm::FoldingSet* ENodes = + reinterpret_cast*>(I->second); + + for (llvm::FoldingSet::iterator + I=ENodes->begin(), E=ENodes->end(); I!=E; ++I) + delete &*I; + + delete ENodes; + } +} diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h index 347c9e6f4f..1a9ec32f60 100644 --- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -86,6 +86,16 @@ protected: } public: + // This method is only defined so that we can cast a + // void* to FoldingSet so that we can iterate + // over the vertices of EdgeNodeSetMap in ExplodeGraphImpl. + // The actual profiling of vertices will be done in the derived + // class, ExplodedNode<>. Nodes will NEVER be INSERTED into the + // FoldingSet using this Profile method (since it doesn't do anything). + inline void Profile(llvm::FoldingSetNodeID& ID) const { + assert (false && "Needs to be implemented in derived class."); + } + /// getLocation - Returns the edge associated with the given node. const ProgramPoint& getLocation() const { return Location; } @@ -227,22 +237,6 @@ protected: } public: - virtual ~ExplodedGraph() { - // Delete the FoldingSet's in Nodes. Note that the contents - // of the FoldingSets are nodes allocated from the BumpPtrAllocator, - // so all of those will get nuked when that object is destroyed. - for (EdgeNodeSetMap::iterator I=Nodes.begin(), E=Nodes.end(); I!=E; ++I) { - llvm::FoldingSet* ENodes = - reinterpret_cast*>(I->second); - - for (typename llvm::FoldingSet::iterator - I=ENodes->begin(), E=ENodes->end(); I!=E; ++I) - delete *I; - - delete ENodes; - } - } - /// getCheckerState - Returns the internal checker state associated /// with the exploded graph. Ownership remains with the ExplodedGraph /// objecct.