aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/PathSensitive
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Analysis/PathSensitive')
-rw-r--r--include/clang/Analysis/PathSensitive/ExplodedGraph.h26
-rw-r--r--include/clang/Analysis/PathSensitive/GREngine.h31
2 files changed, 35 insertions, 22 deletions
diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
index 9818095350..9545e7c0d8 100644
--- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h
+++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
@@ -29,7 +29,11 @@ namespace clang {
class GREngineImpl;
class ExplodedNodeImpl;
class GRNodeBuilderImpl;
+class CFG;
+class ASTContext;
+class FunctionDecl;
+
class ExplodedNodeImpl : public llvm::FoldingSetNode {
protected:
friend class ExplodedGraphImpl;
@@ -210,6 +214,15 @@ protected:
/// Allocator - BumpPtrAllocator to create nodes.
llvm::BumpPtrAllocator Allocator;
+
+ /// cfg - The CFG associated with this analysis graph.
+ CFG& cfg;
+
+ /// FD - The function declaration of the function being analyzed.
+ FunctionDecl& FD;
+
+ /// Ctx - The ASTContext used to "interpret" FD.
+ ASTContext& Ctx;
/// getNodeImpl - Retrieve the node associated with a (Location,State)
/// pair, where 'State' is represented as an opaque void*. This method
@@ -228,12 +241,20 @@ protected:
EndNodes.push_back(V);
return V;
}
+
+ // ctor.
+ ExplodedGraphImpl(CFG& c, FunctionDecl& f, ASTContext& ctx)
+ : cfg(c), FD(f), Ctx(ctx) {}
public:
virtual ~ExplodedGraphImpl();
unsigned num_roots() const { return Roots.size(); }
unsigned num_eops() const { return EndNodes.size(); }
+
+ CFG& getCFG() { return cfg; }
+ ASTContext& getContext() { return Ctx; }
+ FunctionDecl& getFunctionDecl() { return FD; }
};
template <typename CHECKER>
@@ -243,7 +264,7 @@ public:
typedef typename CHECKER::StateTy StateTy;
typedef ExplodedNode<StateTy> NodeTy;
-protected:
+protected:
llvm::OwningPtr<CheckerTy> CheckerState;
protected:
@@ -253,7 +274,8 @@ protected:
}
public:
- ExplodedGraph() : CheckerState(new CheckerTy()) {}
+ ExplodedGraph(CFG& c, FunctionDecl& fd, ASTContext& ctx)
+ : ExplodedGraphImpl(c, fd, ctx), CheckerState(new CheckerTy(*this)) {}
/// getCheckerState - Returns the internal checker state associated
/// with the exploded graph. Ownership remains with the ExplodedGraph
diff --git a/include/clang/Analysis/PathSensitive/GREngine.h b/include/clang/Analysis/PathSensitive/GREngine.h
index 5dcf6d7d0e..52a323dfb6 100644
--- a/include/clang/Analysis/PathSensitive/GREngine.h
+++ b/include/clang/Analysis/PathSensitive/GREngine.h
@@ -21,8 +21,6 @@
namespace clang {
-class CFG;
-class ASTContext;
class GRNodeBuilderImpl;
class GRWorkList;
@@ -31,9 +29,6 @@ protected:
friend class GRNodeBuilderImpl;
typedef llvm::DenseMap<Stmt*,Stmt*> ParentMapTy;
-
- /// cfg - The control-flow graph of the function being analyzed.
- CFG& cfg;
/// G - The simulation graph. Each node is a (location,state) pair.
llvm::OwningPtr<ExplodedGraphImpl> G;
@@ -77,8 +72,7 @@ private:
GREngineImpl& operator=(const GREngineImpl&);
protected:
- GREngineImpl(CFG& c, ExplodedGraphImpl* g, GRWorkList* wl)
- : cfg(c), G(g), WList(wl) {}
+ GREngineImpl(ExplodedGraphImpl* g, GRWorkList* wl) : G(g), WList(wl) {}
public:
/// ExecuteWorkList - Run the worklist algorithm for a maximum number of
@@ -86,6 +80,8 @@ public:
bool ExecuteWorkList(unsigned Steps = 1000000);
virtual ~GREngineImpl() {}
+
+ CFG& getCFG() { return G->getCFG(); }
};
class GRNodeBuilderImpl {
@@ -108,7 +104,7 @@ public:
~GRNodeBuilderImpl();
const ExplodedGraphImpl& getGraph() const { return *Eng.G; }
-
+
inline ExplodedNodeImpl* getLastNode() {
return LastNode ? (LastNode->isInfeasible() ? NULL : LastNode) : NULL;
}
@@ -170,8 +166,7 @@ public:
protected:
// A local reference to the checker that avoids an indirect access
// via the Graph.
- CheckerTy* Checker;
-
+ CheckerTy* Checker;
virtual void* getInitialState() {
return GRTrait<StateTy>::toPtr(getCheckerState().getInitialState());
@@ -196,20 +191,16 @@ protected:
public:
/// Construct a GREngine object to analyze the provided CFG using
/// a DFS exploration of the exploded graph.
- GREngine(CFG& cfg, ASTContext& Ctx)
- : GREngineImpl(cfg, new GraphTy(), GRWorkList::MakeDFS()),
- Checker(static_cast<GraphTy*>(G.get())->getCheckerState()) {
- Checker->Initialize(cfg, Ctx);
- }
+ GREngine(CFG& cfg, FunctionDecl& fd, ASTContext& ctx)
+ : GREngineImpl(new GraphTy(cfg, fd, ctx), GRWorkList::MakeDFS()),
+ Checker(static_cast<GraphTy*>(G.get())->getCheckerState()) {}
/// Construct a GREngine object to analyze the provided CFG and to
/// use the provided worklist object to execute the worklist algorithm.
/// The GREngine object assumes ownership of 'wlist'.
- GREngine(CFG& cfg, GRWorkList* wlist)
- : GREngineImpl(cfg, new GraphTy(), wlist),
- Checker(static_cast<GraphTy*>(G.get())->getCheckerState()) {
- Checker->Initialize(cfg);
- }
+ GREngine(CFG& cfg, FunctionDecl& fd, ASTContext& ctx, GRWorkList* wlist)
+ : GREngineImpl(new GraphTy(cfg, fd, ctx), wlist),
+ Checker(static_cast<GraphTy*>(G.get())->getCheckerState()) {}
virtual ~GREngine() {}