Last step of template cleanup: merge *BuilderImpl to *Builder.
Some Builders need further cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78301 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Analysis/PathSensitive/Checker.h b/include/clang/Analysis/PathSensitive/Checker.h
index f3011cc..278f85c 100644
--- a/include/clang/Analysis/PathSensitive/Checker.h
+++ b/include/clang/Analysis/PathSensitive/Checker.h
@@ -31,7 +31,7 @@
class CheckerContext {
ExplodedNodeSet &Dst;
- GRStmtNodeBuilder<GRState> &B;
+ GRStmtNodeBuilder &B;
GRExprEngine &Eng;
ExplodedNode *Pred;
SaveAndRestore<bool> OldSink;
@@ -41,7 +41,7 @@
public:
CheckerContext(ExplodedNodeSet &dst,
- GRStmtNodeBuilder<GRState> &builder,
+ GRStmtNodeBuilder &builder,
GRExprEngine &eng,
ExplodedNode *pred,
const void *tag, bool preVisit)
@@ -63,7 +63,7 @@
return Eng.getConstraintManager();
}
ExplodedNodeSet &getNodeSet() { return Dst; }
- GRStmtNodeBuilder<GRState> &getNodeBuilder() { return B; }
+ GRStmtNodeBuilder &getNodeBuilder() { return B; }
ExplodedNode *&getPredecessor() { return Pred; }
const GRState *getState() { return B.GetState(Pred); }
@@ -86,10 +86,10 @@
friend class GRExprEngine;
void GR_Visit(ExplodedNodeSet &Dst,
- GRStmtNodeBuilder<GRState> &Builder,
+ GRStmtNodeBuilder &Builder,
GRExprEngine &Eng,
const Stmt *stmt,
- ExplodedNode *Pred, bool isPrevisit) {
+ ExplodedNode *Pred, bool isPrevisit) {
CheckerContext C(Dst, Builder, Eng, Pred, getTag(), isPrevisit);
assert(isPrevisit && "Only previsit supported for now.");
_PreVisit(C, stmt);
diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
index d5e3586..21311d1 100644
--- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h
+++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
@@ -50,11 +50,11 @@
protected:
friend class ExplodedGraph;
friend class GRCoreEngine;
- friend class GRStmtNodeBuilderImpl;
- friend class GRBranchNodeBuilderImpl;
- friend class GRIndirectGotoNodeBuilderImpl;
- friend class GRSwitchNodeBuilderImpl;
- friend class GREndPathNodeBuilderImpl;
+ friend class GRStmtNodeBuilder;
+ friend class GRBranchNodeBuilder;
+ friend class GRIndirectGotoNodeBuilder;
+ friend class GRSwitchNodeBuilder;
+ friend class GREndPathNodeBuilder;
class NodeGroup {
enum { Size1 = 0x0, SizeOther = 0x1, AuxFlag = 0x2, Mask = 0x3 };
diff --git a/include/clang/Analysis/PathSensitive/GRAuditor.h b/include/clang/Analysis/PathSensitive/GRAuditor.h
index eda1985..6233ca8 100644
--- a/include/clang/Analysis/PathSensitive/GRAuditor.h
+++ b/include/clang/Analysis/PathSensitive/GRAuditor.h
@@ -18,19 +18,15 @@
#ifndef LLVM_CLANG_ANALYSIS_GRAUDITOR
#define LLVM_CLANG_ANALYSIS_GRAUDITOR
-#include "clang/AST/Expr.h"
-#include "clang/Analysis/PathSensitive/ExplodedGraph.h"
-
namespace clang {
+
+class ExplodedNode;
+class GRStateManager;
-template <typename STATE>
class GRAuditor {
public:
- typedef ExplodedNode NodeTy;
- typedef typename STATE::ManagerTy ManagerTy;
-
virtual ~GRAuditor() {}
- virtual bool Audit(NodeTy* N, ManagerTy& M) = 0;
+ virtual bool Audit(ExplodedNode* N, GRStateManager& M) = 0;
};
diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
index 48613d1..4c04c81 100644
--- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
@@ -27,20 +27,14 @@
class GRState;
class GRStateManager;
-
-class GRStmtNodeBuilderImpl;
-template<typename STATE> class GRStmtNodeBuilder;
-class GRBranchNodeBuilderImpl;
-template<typename STATE> class GRBranchNodeBuilder;
-class GRIndirectGotoNodeBuilderImpl;
-template<typename STATE> class GRIndirectGotoNodeBuilder;
-class GRSwitchNodeBuilderImpl;
-template<typename STATE> class GRSwitchNodeBuilder;
-class GREndPathNodeBuilderImpl;
-template<typename STATE> class GREndPathNodeBuilder;
-
+class GRStmtNodeBuilder;
+class GRBranchNodeBuilder;
+class GRIndirectGotoNodeBuilder;
+class GRSwitchNodeBuilder;
+class GREndPathNodeBuilder;
class GRWorkList;
class GRCoreEngine;
+
//===----------------------------------------------------------------------===//
/// GRCoreEngine - Implements the core logic of the graph-reachability
/// analysis. It traverses the CFG and generates the ExplodedGraph.
@@ -51,18 +45,11 @@
/// at the statement and block-level. The analyses themselves must implement
/// any transfer function logic and the sub-expression level (if any).
class GRCoreEngine {
-public:
- typedef GRState StateTy;
- typedef GRStateManager StateManagerTy;
- typedef ExplodedGraph GraphTy;
- typedef GraphTy::NodeTy NodeTy;
-
-private:
- friend class GRStmtNodeBuilderImpl;
- friend class GRBranchNodeBuilderImpl;
- friend class GRIndirectGotoNodeBuilderImpl;
- friend class GRSwitchNodeBuilderImpl;
- friend class GREndPathNodeBuilderImpl;
+ friend class GRStmtNodeBuilder;
+ friend class GRBranchNodeBuilder;
+ friend class GRIndirectGotoNodeBuilder;
+ friend class GRSwitchNodeBuilder;
+ friend class GREndPathNodeBuilder;
GRSubEngine& SubEngine;
@@ -96,9 +83,9 @@
return SubEngine.getInitialState();
}
- void ProcessEndPath(GREndPathNodeBuilderImpl& BuilderImpl);
+ void ProcessEndPath(GREndPathNodeBuilder& Builder);
- void ProcessStmt(Stmt* S, GRStmtNodeBuilderImpl& BuilderImpl);
+ void ProcessStmt(Stmt* S, GRStmtNodeBuilder& Builder);
bool ProcessBlockEntrance(CFGBlock* Blk, const GRState* State,
@@ -106,13 +93,13 @@
void ProcessBranch(Stmt* Condition, Stmt* Terminator,
- GRBranchNodeBuilderImpl& BuilderImpl);
+ GRBranchNodeBuilder& Builder);
- void ProcessIndirectGoto(GRIndirectGotoNodeBuilderImpl& BuilderImpl);
+ void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& Builder);
- void ProcessSwitch(GRSwitchNodeBuilderImpl& BuilderImpl);
+ void ProcessSwitch(GRSwitchNodeBuilder& Builder);
private:
GRCoreEngine(const GRCoreEngine&); // Do not implement.
@@ -122,7 +109,7 @@
/// Construct a GRCoreEngine object to analyze the provided CFG using
/// a DFS exploration of the exploded graph.
GRCoreEngine(CFG& cfg, Decl& cd, ASTContext& ctx, GRSubEngine& subengine)
- : SubEngine(subengine), G(new GraphTy(cfg, cd, ctx)),
+ : SubEngine(subengine), G(new ExplodedGraph(cfg, cd, ctx)),
WList(GRWorkList::MakeBFS()),
BCounterFactory(G->getAllocator()) {}
@@ -131,7 +118,7 @@
/// The GRCoreEngine object assumes ownership of 'wlist'.
GRCoreEngine(CFG& cfg, Decl& cd, ASTContext& ctx, GRWorkList* wlist,
GRSubEngine& subengine)
- : SubEngine(subengine), G(new GraphTy(cfg, cd, ctx)), WList(wlist),
+ : SubEngine(subengine), G(new ExplodedGraph(cfg, cd, ctx)), WList(wlist),
BCounterFactory(G->getAllocator()) {}
~GRCoreEngine() {
@@ -139,11 +126,11 @@
}
/// getGraph - Returns the exploded graph.
- GraphTy& getGraph() { return *G.get(); }
+ ExplodedGraph& getGraph() { return *G.get(); }
/// takeGraph - Returns the exploded graph. Ownership of the graph is
/// transfered to the caller.
- GraphTy* takeGraph() { return G.take(); }
+ ExplodedGraph* takeGraph() { return G.take(); }
/// ExecuteWorkList - Run the worklist algorithm for a maximum number of
/// steps. Returns true if there is still simulation state on the worklist.
@@ -152,59 +139,105 @@
CFG& getCFG() { return G->getCFG(); }
};
-class GRStmtNodeBuilderImpl {
+class GRStmtNodeBuilder {
GRCoreEngine& Eng;
CFGBlock& B;
const unsigned Idx;
ExplodedNode* Pred;
ExplodedNode* LastNode;
+ GRStateManager& Mgr;
+ GRAuditor* Auditor;
+
+public:
+ bool PurgingDeadSymbols;
+ bool BuildSinks;
+ bool HasGeneratedNode;
+ ProgramPoint::Kind PointKind;
+ const void *Tag;
+ const GRState* CleanedState;
+
+
typedef llvm::SmallPtrSet<ExplodedNode*,5> DeferredTy;
DeferredTy Deferred;
void GenerateAutoTransition(ExplodedNode* N);
public:
- GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx,
- ExplodedNode* N, GRCoreEngine* e);
+ GRStmtNodeBuilder(CFGBlock* b, unsigned idx, ExplodedNode* N,
+ GRCoreEngine* e, GRStateManager &mgr);
- ~GRStmtNodeBuilderImpl();
+ ~GRStmtNodeBuilder();
ExplodedNode* getBasePredecessor() const { return Pred; }
ExplodedNode* getLastNode() const {
return LastNode ? (LastNode->isSink() ? NULL : LastNode) : NULL;
}
-
+
+ void SetCleanedState(const GRState* St) {
+ CleanedState = St;
+ }
+
GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
unsigned getCurrentBlockCount() const {
return getBlockCounter().getNumVisited(B.getBlockID());
}
-
+
+ ExplodedNode* generateNode(PostStmt PP,const GRState* St,ExplodedNode* Pred) {
+ HasGeneratedNode = true;
+ return generateNodeInternal(PP, St, Pred);
+ }
+
+ ExplodedNode* generateNode(const Stmt* S, const GRState* St, ExplodedNode* Pred,
+ ProgramPoint::Kind K) {
+ HasGeneratedNode = true;
+
+ if (PurgingDeadSymbols)
+ K = ProgramPoint::PostPurgeDeadSymbolsKind;
+
+ return generateNodeInternal(S, St, Pred, K, Tag);
+ }
+
+ ExplodedNode* generateNode(const Stmt* S, const GRState* St, ExplodedNode* Pred) {
+ return generateNode(S, St, Pred, PointKind);
+ }
+
+ ExplodedNode* generateNode(const Stmt* S, const GRState* St, ProgramPoint::Kind K) {
+ HasGeneratedNode = true;
+ if (PurgingDeadSymbols)
+ K = ProgramPoint::PostPurgeDeadSymbolsKind;
+ return generateNodeInternal(S, St, K, Tag);
+ }
+
+ ExplodedNode* generateNode(const Stmt* S, const GRState* St) {
+ return generateNode(S, St, PointKind);
+ }
+
ExplodedNode*
- generateNodeImpl(const ProgramPoint &PP, const GRState* State,
- ExplodedNode* Pred);
+ generateNodeInternal(const ProgramPoint &PP, const GRState* State,
+ ExplodedNode* Pred);
ExplodedNode*
- generateNodeImpl(const Stmt* S, const GRState* State, ExplodedNode* Pred,
+ generateNodeInternal(const Stmt* S, const GRState* State, ExplodedNode* Pred,
ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
const void *tag = 0);
ExplodedNode*
- generateNodeImpl(const Stmt* S, const GRState* State,
+ generateNodeInternal(const Stmt* S, const GRState* State,
ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
const void *tag = 0) {
ExplodedNode* N = getLastNode();
assert (N && "Predecessor of new node is infeasible.");
- return generateNodeImpl(S, State, N, K, tag);
+ return generateNodeInternal(S, State, N, K, tag);
}
ExplodedNode*
- generateNodeImpl(const Stmt* S, const GRState* State, const void *tag = 0) {
+ generateNodeInternal(const Stmt* S,const GRState* State,const void *tag = 0) {
ExplodedNode* N = getLastNode();
assert (N && "Predecessor of new node is infeasible.");
- return generateNodeImpl(S, State, N, ProgramPoint::PostStmtKind, tag);
+ return generateNodeInternal(S, State, N, ProgramPoint::PostStmtKind, tag);
}
/// getStmt - Return the current block-level expression associated with
@@ -214,94 +247,25 @@
/// getBlock - Return the CFGBlock associated with the block-level expression
/// of this builder.
CFGBlock* getBlock() const { return &B; }
-};
-
-
-template<typename STATE>
-class GRStmtNodeBuilder {
-public:
- typedef STATE StateTy;
- typedef typename StateTy::ManagerTy StateManagerTy;
- typedef ExplodedNode NodeTy;
-
-private:
- GRStmtNodeBuilderImpl& NB;
- StateManagerTy& Mgr;
- const StateTy* CleanedState;
- GRAuditor<StateTy>* Auditor;
-
-public:
- GRStmtNodeBuilder(GRStmtNodeBuilderImpl& nb, StateManagerTy& mgr) :
- NB(nb), Mgr(mgr), Auditor(0), PurgingDeadSymbols(false),
- BuildSinks(false), HasGeneratedNode(false),
- PointKind(ProgramPoint::PostStmtKind), Tag(0) {
-
- CleanedState = getLastNode()->getState();
- }
- void setAuditor(GRAuditor<StateTy>* A) {
- Auditor = A;
- }
-
- NodeTy* getLastNode() const {
- return static_cast<NodeTy*>(NB.getLastNode());
- }
-
- NodeTy* generateNode(PostStmt PP, const StateTy* St, NodeTy* Pred) {
- HasGeneratedNode = true;
- return static_cast<NodeTy*>(NB.generateNodeImpl(PP, St, Pred));
- }
-
- NodeTy* generateNode(const Stmt* S, const StateTy* St, NodeTy* Pred,
- ProgramPoint::Kind K) {
- HasGeneratedNode = true;
- if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind;
- return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, Pred, K, Tag));
- }
-
- NodeTy* generateNode(const Stmt* S, const StateTy* St, NodeTy* Pred) {
- return generateNode(S, St, Pred, PointKind);
- }
-
- NodeTy* generateNode(const Stmt* S, const StateTy* St, ProgramPoint::Kind K) {
- HasGeneratedNode = true;
- if (PurgingDeadSymbols) K = ProgramPoint::PostPurgeDeadSymbolsKind;
- return static_cast<NodeTy*>(NB.generateNodeImpl(S, St, K, Tag));
- }
-
- NodeTy* generateNode(const Stmt* S, const StateTy* St) {
- return generateNode(S, St, PointKind);
- }
+ void setAuditor(GRAuditor* A) { Auditor = A; }
-
- GRBlockCounter getBlockCounter() const {
- return NB.getBlockCounter();
- }
-
- unsigned getCurrentBlockCount() const {
- return NB.getCurrentBlockCount();
- }
-
- const StateTy* GetState(NodeTy* Pred) const {
- if ((ExplodedNode*) Pred == NB.getBasePredecessor())
+ const GRState* GetState(ExplodedNode* Pred) const {
+ if ((ExplodedNode*) Pred == getBasePredecessor())
return CleanedState;
else
return Pred->getState();
}
-
- void SetCleanedState(const StateTy* St) {
- CleanedState = St;
- }
-
- NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S,
- NodeTy* Pred, const StateTy* St) {
+
+ ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred,
+ const GRState* St) {
return MakeNode(Dst, S, Pred, St, PointKind);
}
- NodeTy* MakeNode(ExplodedNodeSet& Dst, Stmt* S,
- NodeTy* Pred, const StateTy* St, ProgramPoint::Kind K) {
+ ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S,
+ ExplodedNode* Pred, const GRState* St, ProgramPoint::Kind K) {
- const StateTy* PredState = GetState(Pred);
+ const GRState* PredState = GetState(Pred);
// If the state hasn't changed, don't generate a new node.
if (!BuildSinks && St == PredState && Auditor == 0) {
@@ -309,7 +273,7 @@
return NULL;
}
- NodeTy* N = generateNode(S, St, Pred, K);
+ ExplodedNode* N = generateNode(S, St, Pred, K);
if (N) {
if (BuildSinks)
@@ -325,23 +289,18 @@
return N;
}
- NodeTy* MakeSinkNode(ExplodedNodeSet& Dst, Stmt* S,
- NodeTy* Pred, const StateTy* St) {
+ ExplodedNode* MakeSinkNode(ExplodedNodeSet& Dst, Stmt* S,
+ ExplodedNode* Pred, const GRState* St) {
bool Tmp = BuildSinks;
BuildSinks = true;
- NodeTy* N = MakeNode(Dst, S, Pred, St);
+ ExplodedNode* N = MakeNode(Dst, S, Pred, St);
BuildSinks = Tmp;
return N;
}
-
- bool PurgingDeadSymbols;
- bool BuildSinks;
- bool HasGeneratedNode;
- ProgramPoint::Kind PointKind;
- const void *Tag;
+
};
-class GRBranchNodeBuilderImpl {
+class GRBranchNodeBuilder {
GRCoreEngine& Eng;
CFGBlock* Src;
CFGBlock* DstT;
@@ -357,19 +316,21 @@
bool InFeasibleFalse;
public:
- GRBranchNodeBuilderImpl(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF,
+ GRBranchNodeBuilder(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF,
ExplodedNode* pred, GRCoreEngine* e)
: Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred),
GeneratedTrue(false), GeneratedFalse(false),
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
- ~GRBranchNodeBuilderImpl();
+ ~GRBranchNodeBuilder();
ExplodedNode* getPredecessor() const { return Pred; }
+
const ExplodedGraph& getGraph() const { return *Eng.G; }
+
GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
- ExplodedNode* generateNodeImpl(const GRState* State, bool branch);
+ ExplodedNode* generateNode(const GRState* State, bool branch);
CFGBlock* getTargetBlock(bool branch) const {
return branch ? DstT : DstF;
@@ -385,74 +346,33 @@
bool isFeasible(bool branch) {
return branch ? !InFeasibleTrue : !InFeasibleFalse;
}
-};
-
-template<typename STATE>
-class GRBranchNodeBuilder {
- typedef STATE StateTy;
- typedef ExplodedGraph GraphTy;
- typedef typename GraphTy::NodeTy NodeTy;
- GRBranchNodeBuilderImpl& NB;
-
-public:
- GRBranchNodeBuilder(GRBranchNodeBuilderImpl& nb) : NB(nb) {}
-
- const GraphTy& getGraph() const {
- return static_cast<const GraphTy&>(NB.getGraph());
- }
-
- NodeTy* getPredecessor() const {
- return static_cast<NodeTy*>(NB.getPredecessor());
- }
-
- const StateTy* getState() const {
+ const GRState* getState() const {
return getPredecessor()->getState();
}
-
- NodeTy* generateNode(const StateTy* St, bool branch) {
- return static_cast<NodeTy*>(NB.generateNodeImpl(St, branch));
- }
-
- GRBlockCounter getBlockCounter() const {
- return NB.getBlockCounter();
- }
-
- CFGBlock* getTargetBlock(bool branch) const {
- return NB.getTargetBlock(branch);
- }
-
- void markInfeasible(bool branch) {
- NB.markInfeasible(branch);
- }
-
- bool isFeasible(bool branch) {
- return NB.isFeasible(branch);
- }
};
-
-class GRIndirectGotoNodeBuilderImpl {
+
+class GRIndirectGotoNodeBuilder {
GRCoreEngine& Eng;
CFGBlock* Src;
CFGBlock& DispatchBlock;
Expr* E;
ExplodedNode* Pred;
-public:
- GRIndirectGotoNodeBuilderImpl(ExplodedNode* pred, CFGBlock* src,
- Expr* e, CFGBlock* dispatch,
- GRCoreEngine* eng)
- : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {}
-
- class Iterator {
+public:
+ GRIndirectGotoNodeBuilder(ExplodedNode* pred, CFGBlock* src, Expr* e,
+ CFGBlock* dispatch, GRCoreEngine* eng)
+ : Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {}
+
+ class iterator {
CFGBlock::succ_iterator I;
- friend class GRIndirectGotoNodeBuilderImpl;
- Iterator(CFGBlock::succ_iterator i) : I(i) {}
+ friend class GRIndirectGotoNodeBuilder;
+ iterator(CFGBlock::succ_iterator i) : I(i) {}
public:
- Iterator& operator++() { ++I; return *this; }
- bool operator!=(const Iterator& X) const { return I != X.I; }
+ iterator& operator++() { ++I; return *this; }
+ bool operator!=(const iterator& X) const { return I != X.I; }
LabelStmt* getLabel() const {
return llvm::cast<LabelStmt>((*I)->getLabel());
@@ -463,62 +383,37 @@
}
};
- Iterator begin() { return Iterator(DispatchBlock.succ_begin()); }
- Iterator end() { return Iterator(DispatchBlock.succ_end()); }
+ iterator begin() { return iterator(DispatchBlock.succ_begin()); }
+ iterator end() { return iterator(DispatchBlock.succ_end()); }
- ExplodedNode* generateNodeImpl(const Iterator& I, const GRState* State,
- bool isSink);
+ ExplodedNode* generateNode(const iterator& I, const GRState* State,
+ bool isSink = false);
Expr* getTarget() const { return E; }
- const void* getState() const { return Pred->State; }
+
+ const GRState* getState() const { return Pred->State; }
};
-template<typename STATE>
-class GRIndirectGotoNodeBuilder {
- typedef STATE StateTy;
- typedef ExplodedGraph GraphTy;
- typedef typename GraphTy::NodeTy NodeTy;
-
- GRIndirectGotoNodeBuilderImpl& NB;
-
-public:
- GRIndirectGotoNodeBuilder(GRIndirectGotoNodeBuilderImpl& nb) : NB(nb) {}
-
- typedef GRIndirectGotoNodeBuilderImpl::Iterator iterator;
-
- iterator begin() { return NB.begin(); }
- iterator end() { return NB.end(); }
-
- Expr* getTarget() const { return NB.getTarget(); }
-
- NodeTy* generateNode(const iterator& I, const StateTy* St, bool isSink=false){
- return static_cast<NodeTy*>(NB.generateNodeImpl(I, St, isSink));
- }
-
- const StateTy* getState() const {
- return static_cast<const StateTy*>(NB.getState());
- }
-};
-
-class GRSwitchNodeBuilderImpl {
+class GRSwitchNodeBuilder {
GRCoreEngine& Eng;
CFGBlock* Src;
Expr* Condition;
ExplodedNode* Pred;
+
public:
- GRSwitchNodeBuilderImpl(ExplodedNode* pred, CFGBlock* src,
- Expr* condition, GRCoreEngine* eng)
+ GRSwitchNodeBuilder(ExplodedNode* pred, CFGBlock* src,
+ Expr* condition, GRCoreEngine* eng)
: Eng(*eng), Src(src), Condition(condition), Pred(pred) {}
- class Iterator {
+ class iterator {
CFGBlock::succ_reverse_iterator I;
- friend class GRSwitchNodeBuilderImpl;
- Iterator(CFGBlock::succ_reverse_iterator i) : I(i) {}
+ friend class GRSwitchNodeBuilder;
+ iterator(CFGBlock::succ_reverse_iterator i) : I(i) {}
+
public:
-
- Iterator& operator++() { ++I; return *this; }
- bool operator!=(const Iterator& X) const { return I != X.I; }
+ iterator& operator++() { ++I; return *this; }
+ bool operator!=(const iterator& X) const { return I != X.I; }
CaseStmt* getCase() const {
return llvm::cast<CaseStmt>((*I)->getLabel());
@@ -529,113 +424,49 @@
}
};
- Iterator begin() { return Iterator(Src->succ_rbegin()+1); }
- Iterator end() { return Iterator(Src->succ_rend()); }
+ iterator begin() { return iterator(Src->succ_rbegin()+1); }
+ iterator end() { return iterator(Src->succ_rend()); }
- ExplodedNode* generateCaseStmtNodeImpl(const Iterator& I,
- const GRState* State);
+ ExplodedNode* generateCaseStmtNode(const iterator& I, const GRState* State);
- ExplodedNode* generateDefaultCaseNodeImpl(const GRState* State,
- bool isSink);
+ ExplodedNode* generateDefaultCaseNode(const GRState* State,
+ bool isSink = false);
Expr* getCondition() const { return Condition; }
- const void* getState() const { return Pred->State; }
+
+ const GRState* getState() const { return Pred->State; }
};
-template<typename STATE>
-class GRSwitchNodeBuilder {
- typedef STATE StateTy;
- typedef ExplodedGraph GraphTy;
- typedef typename GraphTy::NodeTy NodeTy;
-
- GRSwitchNodeBuilderImpl& NB;
-
-public:
- GRSwitchNodeBuilder(GRSwitchNodeBuilderImpl& nb) : NB(nb) {}
-
- typedef GRSwitchNodeBuilderImpl::Iterator iterator;
-
- iterator begin() { return NB.begin(); }
- iterator end() { return NB.end(); }
-
- Expr* getCondition() const { return NB.getCondition(); }
-
- NodeTy* generateCaseStmtNode(const iterator& I, const StateTy* St) {
- return static_cast<NodeTy*>(NB.generateCaseStmtNodeImpl(I, St));
- }
-
- NodeTy* generateDefaultCaseNode(const StateTy* St, bool isSink = false) {
- return static_cast<NodeTy*>(NB.generateDefaultCaseNodeImpl(St, isSink));
- }
-
- const StateTy* getState() const {
- return static_cast<const StateTy*>(NB.getState());
- }
-};
-
-
-class GREndPathNodeBuilderImpl {
+class GREndPathNodeBuilder {
GRCoreEngine& Eng;
CFGBlock& B;
ExplodedNode* Pred;
bool HasGeneratedNode;
public:
- GREndPathNodeBuilderImpl(CFGBlock* b, ExplodedNode* N,
- GRCoreEngine* e)
+ GREndPathNodeBuilder(CFGBlock* b, ExplodedNode* N, GRCoreEngine* e)
: Eng(*e), B(*b), Pred(N), HasGeneratedNode(false) {}
- ~GREndPathNodeBuilderImpl();
+ ~GREndPathNodeBuilder();
ExplodedNode* getPredecessor() const { return Pred; }
- GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
+ GRBlockCounter getBlockCounter() const {
+ return Eng.WList->getBlockCounter();
+ }
unsigned getCurrentBlockCount() const {
return getBlockCounter().getNumVisited(B.getBlockID());
}
- ExplodedNode* generateNodeImpl(const GRState* State,
- const void *tag = 0,
- ExplodedNode *P = 0);
+ ExplodedNode* generateNode(const GRState* State, const void *tag = 0,
+ ExplodedNode *P = 0);
CFGBlock* getBlock() const { return &B; }
-};
-
-template<typename STATE>
-class GREndPathNodeBuilder {
- typedef STATE StateTy;
- typedef ExplodedNode NodeTy;
-
- GREndPathNodeBuilderImpl& NB;
-
-public:
- GREndPathNodeBuilder(GREndPathNodeBuilderImpl& nb) : NB(nb) {}
-
- NodeTy* getPredecessor() const {
- return static_cast<NodeTy*>(NB.getPredecessor());
- }
-
- GRBlockCounter getBlockCounter() const {
- return NB.getBlockCounter();
- }
-
- unsigned getCurrentBlockCount() const {
- return NB.getCurrentBlockCount();
- }
-
- const StateTy* getState() const {
+ const GRState* getState() const {
return getPredecessor()->getState();
}
-
- NodeTy* MakeNode(const StateTy* St, const void *tag = 0) {
- return static_cast<NodeTy*>(NB.generateNodeImpl(St, tag));
- }
-
- NodeTy *generateNode(const StateTy *St, NodeTy *Pred, const void *tag = 0) {
- return static_cast<NodeTy*>(NB.generateNodeImpl(St, tag, Pred));
- }
};
} // end clang namespace
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index 12c6352..7b29039 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -33,24 +33,11 @@
class Checker;
class GRExprEngine : public GRSubEngine {
-public:
- typedef GRState StateTy;
- typedef ExplodedGraph GraphTy;
- typedef GraphTy::NodeTy NodeTy;
-
- // Builders.
- typedef GRStmtNodeBuilder<StateTy> StmtNodeBuilder;
- typedef GRBranchNodeBuilder<StateTy> BranchNodeBuilder;
- typedef GRIndirectGotoNodeBuilder<StateTy> IndirectGotoNodeBuilder;
- typedef GRSwitchNodeBuilder<StateTy> SwitchNodeBuilder;
- typedef GREndPathNodeBuilder<StateTy> EndPathNodeBuilder;
- typedef ExplodedNodeSet NodeSet;
-
protected:
GRCoreEngine CoreEngine;
/// G - the simulation graph.
- GraphTy& G;
+ ExplodedGraph& G;
/// Liveness - live-variables information the ValueDecl* and block-level
/// Expr* in the CFG. Used to prune out dead state.
@@ -58,7 +45,7 @@
/// Builder - The current GRStmtNodeBuilder which is used when building the
/// nodes for a given statement.
- StmtNodeBuilder* Builder;
+ GRStmtNodeBuilder* Builder;
/// StateMgr - Object that manages the data for all created states.
GRStateManager StateMgr;
@@ -73,7 +60,7 @@
SValuator &SVator;
/// EntryNode - The immediate predecessor node.
- NodeTy* EntryNode;
+ ExplodedNode* EntryNode;
/// CleanedState - The state for EntryNode "cleaned" of all dead
/// variables and symbols (as determined by a liveness analysis).
@@ -110,8 +97,8 @@
const bool EagerlyAssume;
public:
- typedef llvm::SmallPtrSet<NodeTy*,2> ErrorNodes;
- typedef llvm::DenseMap<NodeTy*, Expr*> UndefArgsTy;
+ typedef llvm::SmallPtrSet<ExplodedNode*,2> ErrorNodes;
+ typedef llvm::DenseMap<ExplodedNode*, Expr*> UndefArgsTy;
/// NilReceiverStructRetExplicit - Nodes in the ExplodedGraph that resulted
/// from [x ...] with 'x' definitely being nil and the result was a 'struct'
@@ -248,7 +235,7 @@
/// simulation.
void ViewGraph(bool trim = false);
- void ViewGraph(NodeTy** Beg, NodeTy** End);
+ void ViewGraph(ExplodedNode** Beg, ExplodedNode** End);
/// getLiveness - Returned computed live-variables information for the
/// analyzed function.
@@ -259,8 +246,8 @@
/// in the ExplodedGraph.
const GRState* getInitialState();
- GraphTy& getGraph() { return G; }
- const GraphTy& getGraph() const { return G; }
+ ExplodedGraph& getGraph() { return G; }
+ const ExplodedGraph& getGraph() const { return G; }
void RegisterInternalChecks();
@@ -268,58 +255,58 @@
Checkers.push_back(check);
}
- bool isRetStackAddr(const NodeTy* N) const {
- return N->isSink() && RetsStackAddr.count(const_cast<NodeTy*>(N)) != 0;
+ bool isRetStackAddr(const ExplodedNode* N) const {
+ return N->isSink() && RetsStackAddr.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isUndefControlFlow(const NodeTy* N) const {
- return N->isSink() && UndefBranches.count(const_cast<NodeTy*>(N)) != 0;
+ bool isUndefControlFlow(const ExplodedNode* N) const {
+ return N->isSink() && UndefBranches.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isUndefStore(const NodeTy* N) const {
- return N->isSink() && UndefStores.count(const_cast<NodeTy*>(N)) != 0;
+ bool isUndefStore(const ExplodedNode* N) const {
+ return N->isSink() && UndefStores.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isImplicitNullDeref(const NodeTy* N) const {
- return N->isSink() && ImplicitNullDeref.count(const_cast<NodeTy*>(N)) != 0;
+ bool isImplicitNullDeref(const ExplodedNode* N) const {
+ return N->isSink() && ImplicitNullDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isExplicitNullDeref(const NodeTy* N) const {
- return N->isSink() && ExplicitNullDeref.count(const_cast<NodeTy*>(N)) != 0;
+ bool isExplicitNullDeref(const ExplodedNode* N) const {
+ return N->isSink() && ExplicitNullDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isUndefDeref(const NodeTy* N) const {
- return N->isSink() && UndefDeref.count(const_cast<NodeTy*>(N)) != 0;
+ bool isUndefDeref(const ExplodedNode* N) const {
+ return N->isSink() && UndefDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isImplicitBadDivide(const NodeTy* N) const {
- return N->isSink() && ImplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0;
+ bool isImplicitBadDivide(const ExplodedNode* N) const {
+ return N->isSink() && ImplicitBadDivides.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isExplicitBadDivide(const NodeTy* N) const {
- return N->isSink() && ExplicitBadDivides.count(const_cast<NodeTy*>(N)) != 0;
+ bool isExplicitBadDivide(const ExplodedNode* N) const {
+ return N->isSink() && ExplicitBadDivides.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isNoReturnCall(const NodeTy* N) const {
- return N->isSink() && NoReturnCalls.count(const_cast<NodeTy*>(N)) != 0;
+ bool isNoReturnCall(const ExplodedNode* N) const {
+ return N->isSink() && NoReturnCalls.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isUndefResult(const NodeTy* N) const {
- return N->isSink() && UndefResults.count(const_cast<NodeTy*>(N)) != 0;
+ bool isUndefResult(const ExplodedNode* N) const {
+ return N->isSink() && UndefResults.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isBadCall(const NodeTy* N) const {
- return N->isSink() && BadCalls.count(const_cast<NodeTy*>(N)) != 0;
+ bool isBadCall(const ExplodedNode* N) const {
+ return N->isSink() && BadCalls.count(const_cast<ExplodedNode*>(N)) != 0;
}
- bool isUndefArg(const NodeTy* N) const {
+ bool isUndefArg(const ExplodedNode* N) const {
return N->isSink() &&
- (UndefArgs.find(const_cast<NodeTy*>(N)) != UndefArgs.end() ||
- MsgExprUndefArgs.find(const_cast<NodeTy*>(N)) != MsgExprUndefArgs.end());
+ (UndefArgs.find(const_cast<ExplodedNode*>(N)) != UndefArgs.end() ||
+ MsgExprUndefArgs.find(const_cast<ExplodedNode*>(N)) != MsgExprUndefArgs.end());
}
- bool isUndefReceiver(const NodeTy* N) const {
- return N->isSink() && UndefReceivers.count(const_cast<NodeTy*>(N)) != 0;
+ bool isUndefReceiver(const ExplodedNode* N) const {
+ return N->isSink() && UndefReceivers.count(const_cast<ExplodedNode*>(N)) != 0;
}
typedef ErrorNodes::iterator ret_stackaddr_iterator;
@@ -437,7 +424,7 @@
/// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
/// nodes by processing the 'effects' of a block-level statement.
- void ProcessStmt(Stmt* S, StmtNodeBuilder& builder);
+ void ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder);
/// ProcessBlockEntrance - Called by GRCoreEngine when start processing
/// a CFGBlock. This method returns true if the analysis should continue
@@ -447,19 +434,19 @@
/// ProcessBranch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a branch condition.
- void ProcessBranch(Stmt* Condition, Stmt* Term, BranchNodeBuilder& builder);
+ void ProcessBranch(Stmt* Condition, Stmt* Term, GRBranchNodeBuilder& builder);
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a computed goto jump.
- void ProcessIndirectGoto(IndirectGotoNodeBuilder& builder);
+ void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder);
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
- void ProcessSwitch(SwitchNodeBuilder& builder);
+ void ProcessSwitch(GRSwitchNodeBuilder& builder);
/// ProcessEndPath - Called by GRCoreEngine. Used to generate end-of-path
/// nodes when the control reaches the end of a function.
- void ProcessEndPath(EndPathNodeBuilder& builder) {
+ void ProcessEndPath(GREndPathNodeBuilder& builder) {
getTF().EvalEndPath(*this, builder);
StateMgr.EndPath(builder.getState());
}
@@ -489,124 +476,124 @@
const SymbolManager& getSymbolManager() const { return SymMgr; }
protected:
- const GRState* GetState(NodeTy* N) {
+ const GRState* GetState(ExplodedNode* N) {
return N == EntryNode ? CleanedState : N->getState();
}
public:
- NodeTy* MakeNode(NodeSet& Dst, Stmt* S, NodeTy* Pred, const GRState* St,
+ ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred, const GRState* St,
ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
const void *tag = 0);
protected:
/// CheckerVisit - Dispatcher for performing checker-specific logic
/// at specific statements.
- void CheckerVisit(Stmt *S, NodeSet &Dst, NodeSet &Src, bool isPrevisit);
+ void CheckerVisit(Stmt *S, ExplodedNodeSet &Dst, ExplodedNodeSet &Src, bool isPrevisit);
/// Visit - Transfer function logic for all statements. Dispatches to
/// other functions that handle specific kinds of statements.
- void Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst);
+ void Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitLValue - Evaluate the lvalue of the expression. For example, if Ex is
/// a DeclRefExpr, it evaluates to the MemRegionVal which represents its
/// storage location. Note that not all kinds of expressions has lvalue.
- void VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst);
+ void VisitLValue(Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitArraySubscriptExpr - Transfer function for array accesses.
- void VisitArraySubscriptExpr(ArraySubscriptExpr* Ex, NodeTy* Pred,
- NodeSet& Dst, bool asLValue);
+ void VisitArraySubscriptExpr(ArraySubscriptExpr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue);
/// VisitAsmStmt - Transfer function logic for inline asm.
- void VisitAsmStmt(AsmStmt* A, NodeTy* Pred, NodeSet& Dst);
+ void VisitAsmStmt(AsmStmt* A, ExplodedNode* Pred, ExplodedNodeSet& Dst);
void VisitAsmStmtHelperOutputs(AsmStmt* A,
AsmStmt::outputs_iterator I,
AsmStmt::outputs_iterator E,
- NodeTy* Pred, NodeSet& Dst);
+ ExplodedNode* Pred, ExplodedNodeSet& Dst);
void VisitAsmStmtHelperInputs(AsmStmt* A,
AsmStmt::inputs_iterator I,
AsmStmt::inputs_iterator E,
- NodeTy* Pred, NodeSet& Dst);
+ ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitBinaryOperator - Transfer function logic for binary operators.
- void VisitBinaryOperator(BinaryOperator* B, NodeTy* Pred, NodeSet& Dst);
+ void VisitBinaryOperator(BinaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitCall - Transfer function for function calls.
- void VisitCall(CallExpr* CE, NodeTy* Pred,
+ void VisitCall(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI, CallExpr::arg_iterator AE,
- NodeSet& Dst);
- void VisitCallRec(CallExpr* CE, NodeTy* Pred,
+ ExplodedNodeSet& Dst);
+ void VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI, CallExpr::arg_iterator AE,
- NodeSet& Dst, const FunctionProtoType *,
+ ExplodedNodeSet& Dst, const FunctionProtoType *,
unsigned ParamIdx = 0);
/// VisitCast - Transfer function logic for all casts (implicit and explicit).
- void VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst);
+ void VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitCompoundLiteralExpr - Transfer function logic for compound literals.
- void VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, NodeTy* Pred,
- NodeSet& Dst, bool asLValue);
+ void VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue);
/// VisitDeclRefExpr - Transfer function logic for DeclRefExprs.
- void VisitDeclRefExpr(DeclRefExpr* DR, NodeTy* Pred, NodeSet& Dst,
+ void VisitDeclRefExpr(DeclRefExpr* DR, ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue);
/// VisitDeclStmt - Transfer function logic for DeclStmts.
- void VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst);
+ void VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitGuardedExpr - Transfer function logic for ?, __builtin_choose
- void VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, NodeTy* Pred, NodeSet& Dst);
+ void VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, ExplodedNode* Pred, ExplodedNodeSet& Dst);
- void VisitInitListExpr(InitListExpr* E, NodeTy* Pred, NodeSet& Dst);
+ void VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitLogicalExpr - Transfer function logic for '&&', '||'
- void VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred, NodeSet& Dst);
+ void VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitMemberExpr - Transfer function for member expressions.
- void VisitMemberExpr(MemberExpr* M, NodeTy* Pred, NodeSet& Dst,bool asLValue);
+ void VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred, ExplodedNodeSet& Dst,bool asLValue);
/// VisitObjCIvarRefExpr - Transfer function logic for ObjCIvarRefExprs.
- void VisitObjCIvarRefExpr(ObjCIvarRefExpr* DR, NodeTy* Pred, NodeSet& Dst,
+ void VisitObjCIvarRefExpr(ObjCIvarRefExpr* DR, ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue);
/// VisitObjCForCollectionStmt - Transfer function logic for
/// ObjCForCollectionStmt.
- void VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, NodeTy* Pred,
- NodeSet& Dst);
+ void VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst);
- void VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S, NodeTy* Pred,
- NodeSet& Dst, SVal ElementV);
+ void VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, SVal ElementV);
/// VisitObjCMessageExpr - Transfer function for ObjC message expressions.
- void VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred, NodeSet& Dst);
+ void VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred, ExplodedNodeSet& Dst);
void VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator I,
ObjCMessageExpr::arg_iterator E,
- NodeTy* Pred, NodeSet& Dst);
+ ExplodedNode* Pred, ExplodedNodeSet& Dst);
- void VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, NodeTy* Pred,
- NodeSet& Dst);
+ void VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst);
/// VisitReturnStmt - Transfer function logic for return statements.
- void VisitReturnStmt(ReturnStmt* R, NodeTy* Pred, NodeSet& Dst);
+ void VisitReturnStmt(ReturnStmt* R, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitSizeOfAlignOfExpr - Transfer function for sizeof.
- void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex, NodeTy* Pred,
- NodeSet& Dst);
+ void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst);
/// VisitUnaryOperator - Transfer function logic for unary operators.
- void VisitUnaryOperator(UnaryOperator* B, NodeTy* Pred, NodeSet& Dst,
+ void VisitUnaryOperator(UnaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue);
- const GRState* CheckDivideZero(Expr* Ex, const GRState* St, NodeTy* Pred,
+ const GRState* CheckDivideZero(Expr* Ex, const GRState* St, ExplodedNode* Pred,
SVal Denom);
/// EvalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic
/// expressions of the form 'x != 0' and generate new nodes (stored in Dst)
/// with those assumptions.
- void EvalEagerlyAssume(NodeSet& Dst, NodeSet& Src, Expr *Ex);
+ void EvalEagerlyAssume(ExplodedNodeSet& Dst, ExplodedNodeSet& Src, Expr *Ex);
SVal EvalMinus(SVal X) {
return X.isValid() ? SVator.EvalMinus(cast<NonLoc>(X)) : X;
@@ -631,36 +618,36 @@
protected:
- void EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred);
+ void EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L, ExplodedNode* Pred);
- void EvalObjCMessageExpr(NodeSet& Dst, ObjCMessageExpr* ME, NodeTy* Pred) {
+ void EvalObjCMessageExpr(ExplodedNodeSet& Dst, ObjCMessageExpr* ME, ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
getTF().EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred);
}
- void EvalReturn(NodeSet& Dst, ReturnStmt* s, NodeTy* Pred);
+ void EvalReturn(ExplodedNodeSet& Dst, ReturnStmt* s, ExplodedNode* Pred);
const GRState* MarkBranch(const GRState* St, Stmt* Terminator,
bool branchTaken);
/// EvalBind - Handle the semantics of binding a value to a specific location.
/// This method is used by EvalStore, VisitDeclStmt, and others.
- void EvalBind(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+ void EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* St, SVal location, SVal Val);
public:
- void EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+ void EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* St, SVal location, const void *tag = 0);
- NodeTy* EvalLocation(Stmt* Ex, NodeTy* Pred,
+ ExplodedNode* EvalLocation(Stmt* Ex, ExplodedNode* Pred,
const GRState* St, SVal location,
const void *tag = 0);
- void EvalStore(NodeSet& Dst, Expr* E, NodeTy* Pred, const GRState* St,
+ void EvalStore(ExplodedNodeSet& Dst, Expr* E, ExplodedNode* Pred, const GRState* St,
SVal TargetLV, SVal Val, const void *tag = 0);
- void EvalStore(NodeSet& Dst, Expr* E, Expr* StoreE, NodeTy* Pred,
+ void EvalStore(ExplodedNodeSet& Dst, Expr* E, Expr* StoreE, ExplodedNode* Pred,
const GRState* St, SVal TargetLV, SVal Val,
const void *tag = 0);
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
index 607c901..0c31818 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
@@ -20,10 +20,10 @@
namespace clang {
class GRStmtNodeBuilderRef {
- GRExprEngine::NodeSet &Dst;
- GRExprEngine::StmtNodeBuilder &B;
+ ExplodedNodeSet &Dst;
+ GRStmtNodeBuilder &B;
GRExprEngine& Eng;
- GRExprEngine::NodeTy* Pred;
+ ExplodedNode* Pred;
const GRState* state;
const Stmt* stmt;
const unsigned OldSize;
@@ -38,10 +38,10 @@
GRStmtNodeBuilderRef(); // do not implement
void operator=(const GRStmtNodeBuilderRef&); // do not implement
- GRStmtNodeBuilderRef(GRExprEngine::NodeSet &dst,
- GRExprEngine::StmtNodeBuilder &builder,
+ GRStmtNodeBuilderRef(ExplodedNodeSet &dst,
+ GRStmtNodeBuilder &builder,
GRExprEngine& eng,
- GRExprEngine::NodeTy* pred,
+ ExplodedNode* pred,
const GRState *st,
const Stmt* s, bool auto_create_node)
: Dst(dst), B(builder), Eng(eng), Pred(pred),
@@ -67,7 +67,7 @@
return Eng.getStateManager();
}
- GRExprEngine::NodeTy* MakeNode(const GRState* state) {
+ ExplodedNode* MakeNode(const GRState* state) {
return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
}
};
diff --git a/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
index 9de8624..c0593a3 100644
--- a/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
+++ b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
@@ -29,7 +29,7 @@
class ExplodedGraph;
-class GRSimpleAPICheck : public GRAuditor<GRState> {
+class GRSimpleAPICheck : public GRAuditor {
public:
GRSimpleAPICheck() {}
virtual ~GRSimpleAPICheck() {}
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index 3bb37cc..87caf8e 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -40,13 +40,13 @@
virtual void EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {}
virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred) {}
@@ -57,12 +57,12 @@
// End-of-path and dead symbol notification.
virtual void EvalEndPath(GRExprEngine& Engine,
- GREndPathNodeBuilder<GRState>& Builder) {}
+ GREndPathNodeBuilder& Builder) {}
virtual void EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper) {}
@@ -70,7 +70,7 @@
// Return statements.
virtual void EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred) {}
diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp
index d7631bc..6e9dd90 100644
--- a/lib/Analysis/BasicObjCFoundationChecks.cpp
+++ b/lib/Analysis/BasicObjCFoundationChecks.cpp
@@ -63,12 +63,12 @@
ASTContext &Ctx;
bool isNSString(const ObjCInterfaceType *T, const char* suffix);
- bool AuditNSString(NodeTy* N, const ObjCMessageExpr* ME);
+ bool AuditNSString(ExplodedNode* N, const ObjCMessageExpr* ME);
- void Warn(NodeTy* N, const Expr* E, const std::string& s);
- void WarnNilArg(NodeTy* N, const Expr* E);
+ void Warn(ExplodedNode* N, const Expr* E, const std::string& s);
+ void WarnNilArg(ExplodedNode* N, const Expr* E);
- bool CheckNilArg(NodeTy* N, unsigned Arg);
+ bool CheckNilArg(ExplodedNode* N, unsigned Arg);
public:
BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br)
@@ -77,7 +77,7 @@
bool Audit(ExplodedNode* N, GRStateManager&);
private:
- void WarnNilArg(NodeTy* N, const ObjCMessageExpr* ME, unsigned Arg) {
+ void WarnNilArg(ExplodedNode* N, const ObjCMessageExpr* ME, unsigned Arg) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Argument to '" << GetReceiverNameType(ME) << "' method '"
@@ -139,7 +139,7 @@
// Error reporting.
//===----------------------------------------------------------------------===//
-bool BasicObjCFoundationChecks::CheckNilArg(NodeTy* N, unsigned Arg) {
+bool BasicObjCFoundationChecks::CheckNilArg(ExplodedNode* N, unsigned Arg) {
const ObjCMessageExpr* ME =
cast<ObjCMessageExpr>(cast<PostStmt>(N->getLocation()).getStmt());
@@ -162,7 +162,7 @@
return !strcmp("String", suffix) || !strcmp("MutableString", suffix);
}
-bool BasicObjCFoundationChecks::AuditNSString(NodeTy* N,
+bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N,
const ObjCMessageExpr* ME) {
Selector S = ME->getSelector();
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 0b8b488..02f427a 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -167,19 +167,19 @@
namespace {
class VISIBILITY_HIDDEN GenericNodeBuilder {
- GRStmtNodeBuilder<GRState> *SNB;
+ GRStmtNodeBuilder *SNB;
Stmt *S;
const void *tag;
- GREndPathNodeBuilder<GRState> *ENB;
+ GREndPathNodeBuilder *ENB;
public:
- GenericNodeBuilder(GRStmtNodeBuilder<GRState> &snb, Stmt *s,
+ GenericNodeBuilder(GRStmtNodeBuilder &snb, Stmt *s,
const void *t)
: SNB(&snb), S(s), tag(t), ENB(0) {}
- GenericNodeBuilder(GREndPathNodeBuilder<GRState> &enb)
+
+ GenericNodeBuilder(GREndPathNodeBuilder &enb)
: SNB(0), S(0), tag(0), ENB(&enb) {}
- ExplodedNode *MakeNode(const GRState *state,
- ExplodedNode *Pred) {
+ ExplodedNode *MakeNode(const GRState *state, ExplodedNode *Pred) {
if (SNB)
return SNB->generateNode(PostStmt(S, tag), state, Pred);
@@ -1835,8 +1835,8 @@
};
private:
- typedef llvm::DenseMap<const GRExprEngine::NodeTy*, const RetainSummary*>
- SummaryLogTy;
+ typedef llvm::DenseMap<const ExplodedNode*, const RetainSummary*>
+ SummaryLogTy;
RetainSummaryManager Summaries;
SummaryLogTy SummaryLog;
@@ -1854,7 +1854,7 @@
RefVal::Kind& hasErr);
void ProcessNonLeakError(ExplodedNodeSet& Dst,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode* Pred,
const GRState* St,
@@ -1897,7 +1897,7 @@
void EvalSummary(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* Ex,
Expr* Receiver,
const RetainSummary& Summ,
@@ -1906,20 +1906,20 @@
virtual void EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred);
virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
bool EvalObjCMessageExprAux(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
@@ -1929,11 +1929,11 @@
// End-of-path.
virtual void EvalEndPath(GRExprEngine& Engine,
- GREndPathNodeBuilder<GRState>& Builder);
+ GREndPathNodeBuilder& Builder);
virtual void EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper);
@@ -1946,7 +1946,7 @@
virtual void EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred);
@@ -2743,7 +2743,7 @@
void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* Ex,
Expr* Receiver,
const RetainSummary& Summ,
@@ -2953,7 +2953,7 @@
}
// Generate a sink node if we are at the end of a path.
- GRExprEngine::NodeTy *NewNode =
+ ExplodedNode *NewNode =
Summ.isEndPath() ? Builder.MakeSinkNode(Dst, Ex, Pred, state)
: Builder.MakeNode(Dst, Ex, Pred, state);
@@ -2964,7 +2964,7 @@
void CFRefCount::EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
const FunctionDecl* FD = L.getAsFunctionDecl();
@@ -2978,7 +2978,7 @@
void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred) {
RetainSummary* Summ = 0;
@@ -3098,7 +3098,7 @@
void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred) {
@@ -3515,7 +3515,7 @@
}
void CFRefCount::EvalEndPath(GRExprEngine& Eng,
- GREndPathNodeBuilder<GRState>& Builder) {
+ GREndPathNodeBuilder& Builder) {
const GRState *state = Builder.getState();
GenericNodeBuilder Bd(Builder);
@@ -3543,7 +3543,7 @@
void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S,
const GRState* state,
@@ -3597,13 +3597,13 @@
}
void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode* Pred,
const GRState* St,
RefVal::Kind hasErr, SymbolRef Sym) {
Builder.BuildSinks = true;
- GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
+ ExplodedNode *N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
if (!N)
return;
diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp
index 0d67e01..b9599ce 100644
--- a/lib/Analysis/CheckNSError.cpp
+++ b/lib/Analysis/CheckNSError.cpp
@@ -66,7 +66,7 @@
void NSErrorCheck::FlushReports(BugReporter& BR) {
// Get the analysis engine and the exploded analysis graph.
- GRExprEngine::GraphTy& G = Eng.getGraph();
+ ExplodedGraph& G = Eng.getGraph();
// Get the declaration of the method/function that was analyzed.
Decl& CodeDecl = G.getCodeDecl();
@@ -89,8 +89,8 @@
if (ResultTy == Ctx.VoidTy) EmitRetTyWarning(BR, CodeDecl);
- for (GRExprEngine::GraphTy::roots_iterator RI=G.roots_begin(),
- RE=G.roots_end(); RI!=RE; ++RI) {
+ for (ExplodedGraph::roots_iterator RI=G.roots_begin(), RE=G.roots_end();
+ RI!=RE; ++RI) {
// Scan the parameters for an implicit null dereference.
for (llvm::SmallVectorImpl<VarDecl*>::iterator I=ErrorParams.begin(),
E=ErrorParams.end(); I!=E; ++I)
diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp
index 4f0179a..66c12fd 100644
--- a/lib/Analysis/GRCoreEngine.cpp
+++ b/lib/Analysis/GRCoreEngine.cpp
@@ -119,13 +119,11 @@
//===----------------------------------------------------------------------===//
// Core analysis engine.
//===----------------------------------------------------------------------===//
-void GRCoreEngine::ProcessEndPath(GREndPathNodeBuilderImpl& BuilderImpl) {
- GREndPathNodeBuilder<StateTy> Builder(BuilderImpl);
+void GRCoreEngine::ProcessEndPath(GREndPathNodeBuilder& Builder) {
SubEngine.ProcessEndPath(Builder);
}
-void GRCoreEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilderImpl& BuilderImpl) {
- GRStmtNodeBuilder<StateTy> Builder(BuilderImpl,SubEngine.getStateManager());
+void GRCoreEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& Builder) {
SubEngine.ProcessStmt(S, Builder);
}
@@ -135,20 +133,18 @@
}
void GRCoreEngine::ProcessBranch(Stmt* Condition, Stmt* Terminator,
- GRBranchNodeBuilderImpl& BuilderImpl) {
- GRBranchNodeBuilder<StateTy> Builder(BuilderImpl);
+ GRBranchNodeBuilder& Builder) {
SubEngine.ProcessBranch(Condition, Terminator, Builder);
}
-void GRCoreEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilderImpl& BuilderImpl) {
- GRIndirectGotoNodeBuilder<GRState> Builder(BuilderImpl);
+void GRCoreEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& Builder) {
SubEngine.ProcessIndirectGoto(Builder);
}
-void GRCoreEngine::ProcessSwitch(GRSwitchNodeBuilderImpl& BuilderImpl) {
- GRSwitchNodeBuilder<GRState> Builder(BuilderImpl);
+void GRCoreEngine::ProcessSwitch(GRSwitchNodeBuilder& Builder) {
SubEngine.ProcessSwitch(Builder);
}
+
/// ExecuteWorkList - Run the worklist algorithm for a maximum number of steps.
bool GRCoreEngine::ExecuteWorkList(unsigned Steps) {
@@ -224,7 +220,7 @@
&& "EXIT block cannot contain Stmts.");
// Process the final state transition.
- GREndPathNodeBuilderImpl Builder(Blk, Pred, this);
+ GREndPathNodeBuilder Builder(Blk, Pred, this);
ProcessEndPath(Builder);
// This path is done. Don't enqueue any more nodes.
@@ -238,7 +234,7 @@
}
void GRCoreEngine::HandleBlockEntrance(const BlockEntrance& L,
- ExplodedNode* Pred) {
+ ExplodedNode* Pred) {
// Increment the block counter.
GRBlockCounter Counter = WList->getBlockCounter();
@@ -247,7 +243,8 @@
// Process the entrance of the block.
if (Stmt* S = L.getFirstStmt()) {
- GRStmtNodeBuilderImpl Builder(L.getBlock(), 0, Pred, this);
+ GRStmtNodeBuilder Builder(L.getBlock(), 0, Pred, this,
+ SubEngine.getStateManager());
ProcessStmt(S, Builder);
}
else
@@ -298,7 +295,7 @@
// Only 1 successor: the indirect goto dispatch block.
assert (B->succ_size() == 1);
- GRIndirectGotoNodeBuilderImpl
+ GRIndirectGotoNodeBuilder
builder(Pred, B, cast<IndirectGotoStmt>(Term)->getTarget(),
*(B->succ_begin()), this);
@@ -322,9 +319,8 @@
}
case Stmt::SwitchStmtClass: {
- GRSwitchNodeBuilderImpl builder(Pred, B,
- cast<SwitchStmt>(Term)->getCond(),
- this);
+ GRSwitchNodeBuilder builder(Pred, B, cast<SwitchStmt>(Term)->getCond(),
+ this);
ProcessSwitch(builder);
return;
@@ -346,8 +342,8 @@
ExplodedNode* Pred) {
assert (B->succ_size() == 2);
- GRBranchNodeBuilderImpl Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
- Pred, this);
+ GRBranchNodeBuilder Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
+ Pred, this);
ProcessBranch(Cond, Term, Builder);
}
@@ -360,7 +356,8 @@
if (StmtIdx == B->size())
HandleBlockExit(B, Pred);
else {
- GRStmtNodeBuilderImpl Builder(B, StmtIdx, Pred, this);
+ GRStmtNodeBuilder Builder(B, StmtIdx, Pred, this,
+ SubEngine.getStateManager());
ProcessStmt((*B)[StmtIdx], Builder);
}
}
@@ -384,19 +381,23 @@
if (IsNew) WList->Enqueue(Node);
}
-GRStmtNodeBuilderImpl::GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx,
- ExplodedNode* N, GRCoreEngine* e)
- : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N) {
+GRStmtNodeBuilder::GRStmtNodeBuilder(CFGBlock* b, unsigned idx,
+ ExplodedNode* N, GRCoreEngine* e,
+ GRStateManager &mgr)
+ : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N), Mgr(mgr), Auditor(0),
+ PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false),
+ PointKind(ProgramPoint::PostStmtKind), Tag(0) {
Deferred.insert(N);
+ CleanedState = getLastNode()->getState();
}
-GRStmtNodeBuilderImpl::~GRStmtNodeBuilderImpl() {
+GRStmtNodeBuilder::~GRStmtNodeBuilder() {
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
if (!(*I)->isSink())
GenerateAutoTransition(*I);
}
-void GRStmtNodeBuilderImpl::GenerateAutoTransition(ExplodedNode* N) {
+void GRStmtNodeBuilder::GenerateAutoTransition(ExplodedNode* N) {
assert (!N->isSink());
PostStmt Loc(getStmt());
@@ -452,17 +453,17 @@
}
ExplodedNode*
-GRStmtNodeBuilderImpl::generateNodeImpl(const Stmt* S, const GRState* State,
+GRStmtNodeBuilder::generateNodeInternal(const Stmt* S, const GRState* State,
ExplodedNode* Pred,
ProgramPoint::Kind K,
const void *tag) {
return K == ProgramPoint::PreStmtKind
- ? generateNodeImpl(PreStmt(S, tag), State, Pred)
- : generateNodeImpl(GetPostLoc(S, K, tag), State, Pred);
+ ? generateNodeInternal(PreStmt(S, tag), State, Pred)
+ : generateNodeInternal(GetPostLoc(S, K, tag), State, Pred);
}
ExplodedNode*
-GRStmtNodeBuilderImpl::generateNodeImpl(const ProgramPoint &Loc,
+GRStmtNodeBuilder::generateNodeInternal(const ProgramPoint &Loc,
const GRState* State,
ExplodedNode* Pred) {
bool IsNew;
@@ -480,8 +481,8 @@
return NULL;
}
-ExplodedNode* GRBranchNodeBuilderImpl::generateNodeImpl(const GRState* State,
- bool branch) {
+ExplodedNode* GRBranchNodeBuilder::generateNode(const GRState* State,
+ bool branch) {
// If the branch has been marked infeasible we should not generate a node.
if (!isFeasible(branch))
@@ -507,9 +508,9 @@
return NULL;
}
-GRBranchNodeBuilderImpl::~GRBranchNodeBuilderImpl() {
- if (!GeneratedTrue) generateNodeImpl(Pred->State, true);
- if (!GeneratedFalse) generateNodeImpl(Pred->State, false);
+GRBranchNodeBuilder::~GRBranchNodeBuilder() {
+ if (!GeneratedTrue) generateNode(Pred->State, true);
+ if (!GeneratedFalse) generateNode(Pred->State, false);
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
if (!(*I)->isSink()) Eng.WList->Enqueue(*I);
@@ -517,13 +518,11 @@
ExplodedNode*
-GRIndirectGotoNodeBuilderImpl::generateNodeImpl(const Iterator& I,
- const GRState* St,
- bool isSink) {
+GRIndirectGotoNodeBuilder::generateNode(const iterator& I, const GRState* St,
+ bool isSink) {
bool IsNew;
- ExplodedNode* Succ =
- Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
Succ->addPredecessor(Pred);
@@ -542,13 +541,11 @@
ExplodedNode*
-GRSwitchNodeBuilderImpl::generateCaseStmtNodeImpl(const Iterator& I,
- const GRState* St) {
+GRSwitchNodeBuilder::generateCaseStmtNode(const iterator& I, const GRState* St){
bool IsNew;
- ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()),
- St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
Succ->addPredecessor(Pred);
if (IsNew) {
@@ -561,8 +558,7 @@
ExplodedNode*
-GRSwitchNodeBuilderImpl::generateDefaultCaseNodeImpl(const GRState* St,
- bool isSink) {
+GRSwitchNodeBuilder::generateDefaultCaseNode(const GRState* St, bool isSink) {
// Get the block for the default case.
assert (Src->succ_rbegin() != Src->succ_rend());
@@ -570,8 +566,7 @@
bool IsNew;
- ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock),
- St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock), St, &IsNew);
Succ->addPredecessor(Pred);
if (IsNew) {
@@ -586,20 +581,18 @@
return NULL;
}
-GREndPathNodeBuilderImpl::~GREndPathNodeBuilderImpl() {
+GREndPathNodeBuilder::~GREndPathNodeBuilder() {
// Auto-generate an EOP node if one has not been generated.
- if (!HasGeneratedNode) generateNodeImpl(Pred->State);
+ if (!HasGeneratedNode) generateNode(Pred->State);
}
ExplodedNode*
-GREndPathNodeBuilderImpl::generateNodeImpl(const GRState* State,
- const void *tag,
- ExplodedNode* P) {
+GREndPathNodeBuilder::generateNode(const GRState* State, const void *tag,
+ ExplodedNode* P) {
HasGeneratedNode = true;
bool IsNew;
- ExplodedNode* Node =
- Eng.G->getNode(BlockEntrance(&B, tag), State, &IsNew);
+ ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B, tag), State, &IsNew);
Node->addPredecessor(P ? P : Pred);
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index bf24248..47f77ce 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -82,7 +82,7 @@
AllStmts = F.Concat(A, AllStmts);
}
- virtual bool Audit(NodeTy* N, GRStateManager& VMgr) {
+ virtual bool Audit(ExplodedNode* N, GRStateManager& VMgr) {
// First handle the auditors that accept all statements.
bool isSink = false;
for (Checks::iterator I = AllStmts.begin(), E = AllStmts.end(); I!=E; ++I)
@@ -107,25 +107,26 @@
// Checker worklist routines.
//===----------------------------------------------------------------------===//
-void GRExprEngine::CheckerVisit(Stmt *S, NodeSet &Dst, NodeSet &Src,
- bool isPrevisit) {
+void GRExprEngine::CheckerVisit(Stmt *S, ExplodedNodeSet &Dst,
+ ExplodedNodeSet &Src, bool isPrevisit) {
if (Checkers.empty()) {
Dst = Src;
return;
}
- NodeSet Tmp;
- NodeSet *PrevSet = &Src;
+ ExplodedNodeSet Tmp;
+ ExplodedNodeSet *PrevSet = &Src;
for (std::vector<Checker*>::iterator I = Checkers.begin(), E = Checkers.end();
I != E; ++I) {
- NodeSet *CurrSet = (I+1 == E) ? &Dst : (PrevSet == &Tmp) ? &Src : &Tmp;
+ ExplodedNodeSet *CurrSet = (I+1 == E) ? &Dst
+ : (PrevSet == &Tmp) ? &Src : &Tmp;
CurrSet->clear();
Checker *checker = *I;
- for (NodeSet::iterator NI = PrevSet->begin(), NE = PrevSet->end();
+ for (ExplodedNodeSet::iterator NI = PrevSet->begin(), NE = PrevSet->end();
NI != NE; ++NI)
checker->GR_Visit(*CurrSet, *Builder, *this, S, *NI, isPrevisit);
@@ -231,7 +232,7 @@
// Top-level transfer function logic (Dispatcher).
//===----------------------------------------------------------------------===//
-void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
+void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
@@ -255,7 +256,7 @@
: EntryNode->getState();
// Process any special transfer function for dead symbols.
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (!SymReaper.hasDeadSymbols())
Tmp.Add(EntryNode);
@@ -275,9 +276,9 @@
bool HasAutoGenerated = false;
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
- NodeSet Dst;
+ ExplodedNodeSet Dst;
// Set the cleaned state.
Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I));
@@ -306,7 +307,7 @@
Builder = NULL;
}
-void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
"Error evaluating statement");
@@ -351,7 +352,7 @@
}
if (EagerlyAssume && (B->isRelationalOp() || B->isEqualityOp())) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Tmp);
EvalEagerlyAssume(Dst, Tmp, cast<Expr>(S));
}
@@ -477,7 +478,7 @@
case Stmt::UnaryOperatorClass: {
UnaryOperator *U = cast<UnaryOperator>(S);
if (EagerlyAssume && (U->getOpcode() == UnaryOperator::LNot)) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitUnaryOperator(U, Pred, Tmp, false);
EvalEagerlyAssume(Dst, Tmp, U);
}
@@ -488,7 +489,8 @@
}
}
-void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
Ex = Ex->IgnoreParens();
@@ -574,12 +576,9 @@
// Generic node creation.
//===----------------------------------------------------------------------===//
-GRExprEngine::NodeTy* GRExprEngine::MakeNode(NodeSet& Dst, Stmt* S,
- NodeTy* Pred,
- const GRState* St,
- ProgramPoint::Kind K,
- const void *tag) {
-
+ExplodedNode* GRExprEngine::MakeNode(ExplodedNodeSet& Dst, Stmt* S,
+ ExplodedNode* Pred, const GRState* St,
+ ProgramPoint::Kind K, const void *tag) {
assert (Builder && "GRStmtNodeBuilder not present.");
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->Tag = tag;
@@ -685,7 +684,7 @@
}
void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
- BranchNodeBuilder& builder) {
+ GRBranchNodeBuilder& builder) {
// Remove old bindings for subexpressions.
const GRState* PrevState =
@@ -731,7 +730,7 @@
}
case SVal::UndefinedKind: {
- NodeTy* N = builder.generateNode(PrevState, true);
+ ExplodedNode* N = builder.generateNode(PrevState, true);
if (N) {
N->markAsSink();
@@ -762,7 +761,7 @@
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a computed goto jump.
-void GRExprEngine::ProcessIndirectGoto(IndirectGotoNodeBuilder& builder) {
+void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) {
const GRState *state = builder.getState();
SVal V = state->getSVal(builder.getTarget());
@@ -774,7 +773,7 @@
// (3) We have no clue about the label. Dispatch to all targets.
//
- typedef IndirectGotoNodeBuilder::iterator iterator;
+ typedef GRIndirectGotoNodeBuilder::iterator iterator;
if (isa<loc::GotoLabel>(V)) {
LabelStmt* L = cast<loc::GotoLabel>(V).getLabel();
@@ -792,7 +791,7 @@
if (isa<loc::ConcreteInt>(V) || isa<UndefinedVal>(V)) {
// Dispatch to the first target and mark it as a sink.
- NodeTy* N = builder.generateNode(builder.begin(), state, true);
+ ExplodedNode* N = builder.generateNode(builder.begin(), state, true);
UndefBranches.insert(N);
return;
}
@@ -806,7 +805,7 @@
void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
assert (Ex == CurrentStmt && getCFG().isBlkExpr(Ex));
@@ -825,14 +824,14 @@
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
-void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
- typedef SwitchNodeBuilder::iterator iterator;
+void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
+ typedef GRSwitchNodeBuilder::iterator iterator;
const GRState* state = builder.getState();
Expr* CondE = builder.getCondition();
SVal CondV = state->getSVal(CondE);
if (CondV.isUndef()) {
- NodeTy* N = builder.generateDefaultCaseNode(state, true);
+ ExplodedNode* N = builder.generateDefaultCaseNode(state, true);
UndefBranches.insert(N);
return;
}
@@ -912,8 +911,8 @@
// Transfer functions: logical operations ('&&', '||').
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
- NodeSet& Dst) {
+void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
assert(B->getOpcode() == BinaryOperator::LAnd ||
B->getOpcode() == BinaryOperator::LOr);
@@ -967,8 +966,8 @@
// Transfer functions: Loads and stores.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
- bool asLValue) {
+void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
const GRState* state = GetState(Pred);
@@ -1005,12 +1004,13 @@
}
/// VisitArraySubscriptExpr - Transfer function for array accesses
-void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue){
Expr* Base = A->getBase()->IgnoreParens();
Expr* Idx = A->getIdx()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (Base->getType()->isVectorType()) {
// For vector types get its lvalue.
@@ -1022,11 +1022,11 @@
else
Visit(Base, Pred, Tmp); // Get Base's rvalue, which should be an LocVal.
- for (NodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
- NodeSet Tmp2;
+ for (ExplodedNodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
+ ExplodedNodeSet Tmp2;
Visit(Idx, *I1, Tmp2); // Evaluate the index.
- for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2!=E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2=Tmp2.begin(),E2=Tmp2.end();I2!=E2; ++I2) {
const GRState* state = GetState(*I2);
SVal V = state->getLValue(A->getType(), state->getSVal(Base),
state->getSVal(Idx));
@@ -1041,11 +1041,11 @@
}
/// VisitMemberExpr - Transfer function for member expressions.
-void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
Expr* Base = M->getBase()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (M->isArrow())
Visit(Base, Pred, Tmp); // p->f = ... or ... = p->f
@@ -1056,7 +1056,7 @@
if (!Field) // FIXME: skipping member expressions for non-fields
return;
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
const GRState* state = GetState(*I);
// FIXME: Should we insert some assumption logic in here to determine
// if "Base" is a valid piece of memory? Before we put this assumption
@@ -1073,7 +1073,7 @@
/// EvalBind - Handle the semantics of binding a value to a specific location.
/// This method is used by EvalStore and (soon) VisitDeclStmt, and others.
-void GRExprEngine::EvalBind(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val) {
const GRState* newState = 0;
@@ -1105,7 +1105,7 @@
/// @param state The current simulation state
/// @param location The location to store the value
/// @param Val The value to be stored
-void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val,
const void *tag) {
@@ -1128,7 +1128,7 @@
EvalBind(Dst, Ex, Pred, state, location, Val);
}
-void GRExprEngine::EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location,
const void *tag) {
@@ -1169,28 +1169,27 @@
}
}
-void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred,
- const GRState* state, SVal location, SVal Val,
- const void *tag) {
+void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, Expr* StoreE,
+ ExplodedNode* Pred, const GRState* state,
+ SVal location, SVal Val, const void *tag) {
- NodeSet TmpDst;
+ ExplodedNodeSet TmpDst;
EvalStore(TmpDst, StoreE, Pred, state, location, Val, tag);
- for (NodeSet::iterator I=TmpDst.begin(), E=TmpDst.end(); I!=E; ++I)
+ for (ExplodedNodeSet::iterator I=TmpDst.begin(), E=TmpDst.end(); I!=E; ++I)
MakeNode(Dst, Ex, *I, (*I)->getState(), ProgramPoint::PostStmtKind, tag);
}
-GRExprEngine::NodeTy* GRExprEngine::EvalLocation(Stmt* Ex, NodeTy* Pred,
- const GRState* state,
- SVal location,
- const void *tag) {
+ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
+ const GRState* state, SVal location,
+ const void *tag) {
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->Tag = tag;
// Check for loads/stores from/to undefined values.
if (location.isUndef()) {
- NodeTy* N =
+ ExplodedNode* N =
Builder->generateNode(Ex, state, Pred,
ProgramPoint::PostUndefLocationCheckFailedKind);
@@ -1227,7 +1226,7 @@
// We don't use "MakeNode" here because the node will be a sink
// and we have no intention of processing it later.
- NodeTy* NullNode =
+ ExplodedNode* NullNode =
Builder->generateNode(Ex, StNull, Pred,
ProgramPoint::PostNullCheckFailedKind);
@@ -1261,7 +1260,7 @@
if (StOutBound) {
// Report warning. Make sink node manually.
- NodeTy* OOBNode =
+ ExplodedNode* OOBNode =
Builder->generateNode(Ex, StOutBound, Pred,
ProgramPoint::PostOutOfBoundsCheckFailedKind);
@@ -1300,7 +1299,7 @@
//
static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
@@ -1404,7 +1403,7 @@
static bool EvalOSAtomic(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
const FunctionDecl* FD = L.getAsFunctionDecl();
@@ -1426,7 +1425,8 @@
// Transfer function: Function calls.
//===----------------------------------------------------------------------===//
-void GRExprEngine::EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred) {
+void GRExprEngine::EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L,
+ ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
// FIXME: Allow us to chain together transfer functions.
@@ -1436,10 +1436,10 @@
getTF().EvalCall(Dst, *this, *Builder, CE, L, Pred);
}
-void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
+void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- NodeSet& Dst)
+ ExplodedNodeSet& Dst)
{
// Determine the type of function we're calling (if available).
const FunctionProtoType *Proto = NULL;
@@ -1450,10 +1450,11 @@
VisitCallRec(CE, Pred, AI, AE, Dst, Proto, /*ParamIdx=*/0);
}
-void GRExprEngine::VisitCallRec(CallExpr* CE, NodeTy* Pred,
+void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- NodeSet& Dst, const FunctionProtoType *Proto,
+ ExplodedNodeSet& Dst,
+ const FunctionProtoType *Proto,
unsigned ParamIdx) {
// Process the arguments.
@@ -1464,14 +1465,15 @@
if (Proto && ParamIdx < Proto->getNumArgs())
VisitAsLvalue = Proto->getArgType(ParamIdx)->isReferenceType();
- NodeSet DstTmp;
+ ExplodedNodeSet DstTmp;
if (VisitAsLvalue)
VisitLValue(*AI, Pred, DstTmp);
else
Visit(*AI, Pred, DstTmp);
++AI;
- for (NodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE; ++DI)
+ for (ExplodedNodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE;
+ ++DI)
VisitCallRec(CE, *DI, AI, AE, Dst, Proto, ParamIdx + 1);
return;
@@ -1479,11 +1481,11 @@
// If we reach here we have processed all of the arguments. Evaluate
// the callee expression.
- NodeSet DstTmp;
+ ExplodedNodeSet DstTmp;
Expr* Callee = CE->getCallee()->IgnoreParens();
{ // Enter new scope to make the lifetime of 'DstTmp2' bounded.
- NodeSet DstTmp2;
+ ExplodedNodeSet DstTmp2;
Visit(Callee, Pred, DstTmp2);
// Perform the previsit of the CallExpr, storing the results in DstTmp.
@@ -1491,7 +1493,7 @@
}
// Finally, evaluate the function call.
- for (NodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end(); DI!=DE; ++DI) {
+ for (ExplodedNodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end(); DI!=DE; ++DI) {
const GRState* state = GetState(*DI);
SVal L = state->getSVal(Callee);
@@ -1502,7 +1504,7 @@
// Check for undefined control-flow or calls to NULL.
if (L.isUndef() || isa<loc::ConcreteInt>(L)) {
- NodeTy* N = Builder->generateNode(CE, state, *DI);
+ ExplodedNode* N = Builder->generateNode(CE, state, *DI);
if (N) {
N->markAsSink();
@@ -1640,7 +1642,7 @@
I != E; ++I) {
if (GetState(*DI)->getSVal(*I).isUndef()) {
- NodeTy* N = Builder->generateNode(CE, GetState(*DI), *DI);
+ ExplodedNode* N = Builder->generateNode(CE, GetState(*DI), *DI);
if (N) {
N->markAsSink();
@@ -1677,9 +1679,9 @@
static std::pair<const void*,const void*> EagerlyAssumeTag
= std::pair<const void*,const void*>(&EagerlyAssumeTag,0);
-void GRExprEngine::EvalEagerlyAssume(NodeSet &Dst, NodeSet &Src, Expr *Ex) {
- for (NodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
- NodeTy *Pred = *I;
+void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, Expr *Ex) {
+ for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
+ ExplodedNode *Pred = *I;
// Test if the previous node was as the same expression. This can happen
// when the expression fails to evaluate to anything meaningful and
@@ -1719,14 +1721,14 @@
//===----------------------------------------------------------------------===//
void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue) {
Expr* Base = cast<Expr>(Ex->getBase());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Base, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal BaseVal = state->getSVal(Base);
SVal location = state->getLValue(Ex->getDecl(), BaseVal);
@@ -1743,7 +1745,7 @@
//===----------------------------------------------------------------------===//
void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// ObjCForCollectionStmts are processed in two places. This method
// handles the case where an ObjCForCollectionStmt* occurs as one of the
@@ -1781,17 +1783,17 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(cast<Expr>(elem), Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
VisitObjCForCollectionStmtAux(S, *I, Dst, state->getSVal(elem));
}
}
void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
SVal ElementV) {
@@ -1840,8 +1842,8 @@
// Transfer function: Objective-C message expressions.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred,
- NodeSet& Dst){
+void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst){
VisitObjCMessageExprArgHelper(ME, ME->arg_begin(), ME->arg_end(),
Pred, Dst);
@@ -1850,16 +1852,16 @@
void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator AI,
ObjCMessageExpr::arg_iterator AE,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (AI == AE) {
// Process the receiver.
if (Expr* Receiver = ME->getReceiver()) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Receiver, Pred, Tmp);
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprDispatchHelper(ME, *NI, Dst);
return;
@@ -1869,18 +1871,18 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*AI, Pred, Tmp);
++AI;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprArgHelper(ME, AI, AE, *NI, Dst);
}
void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
- NodeTy* Pred,
- NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
// FIXME: More logic for the processing the method call.
@@ -1894,7 +1896,7 @@
// Check for undefined control-flow.
if (L.isUndef()) {
- NodeTy* N = Builder->generateNode(ME, state, Pred);
+ ExplodedNode* N = Builder->generateNode(ME, state, Pred);
if (N) {
N->markAsSink();
@@ -1922,7 +1924,7 @@
// this point.
// FIXME: We should bifurcate and fill the returned struct with
// garbage.
- if (NodeTy* N = Builder->generateNode(ME, StNull, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
if (StNotNull)
NilReceiverStructRetImplicit.insert(N);
@@ -1941,7 +1943,7 @@
const uint64_t returnTypeSize = Ctx.getTypeSize(ME->getType());
if(voidPtrSize < returnTypeSize) {
- if (NodeTy* N = Builder->generateNode(ME, StNull, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
if(StNotNull)
NilReceiverLargerThanVoidPtrRetImplicit.insert(N);
@@ -2038,7 +2040,7 @@
// Generate an error node for passing an uninitialized/undefined value
// as an argument to a message expression. This node is a sink.
- NodeTy* N = Builder->generateNode(ME, state, Pred);
+ ExplodedNode* N = Builder->generateNode(ME, state, Pred);
if (N) {
N->markAsSink();
@@ -2075,8 +2077,8 @@
// Transfer functions: Miscellaneous statements.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
- NodeSet S1;
+void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst){
+ ExplodedNodeSet S1;
QualType T = CastE->getType();
QualType ExTy = Ex->getType();
@@ -2090,14 +2092,14 @@
// Check for casting to "void".
if (T->isVoidType()) {
- for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
+ for (ExplodedNodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
Dst.Add(*I1);
return;
}
- for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
- NodeTy* N = *I1;
+ for (ExplodedNodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
+ ExplodedNode* N = *I1;
const GRState* state = GetState(N);
SVal V = state->getSVal(Ex);
const SValuator::CastResult &Res = SVator.EvalCast(V, state, T, ExTy);
@@ -2107,13 +2109,13 @@
}
void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue) {
InitListExpr* ILE = cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(ILE, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
const GRState* state = GetState(*I);
SVal ILV = state->getSVal(ILE);
state = state->bindCompoundLiteral(CL, ILV);
@@ -2125,7 +2127,7 @@
}
}
-void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// The CFG has one DeclStmt per Decl.
Decl* D = *DS->decl_begin();
@@ -2138,14 +2140,14 @@
// FIXME: static variables may have an initializer, but the second
// time a function is called those values may not be current.
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (InitEx)
Visit(InitEx, Pred, Tmp);
else
Tmp.Add(Pred);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
unsigned Count = Builder->getCurrentBlockCount();
@@ -2158,7 +2160,7 @@
SVal Size = state->getSVal(SE);
if (Size.isUndef()) {
- if (NodeTy* N = Builder->generateNode(DS, state, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(DS, state, Pred)) {
N->markAsSink();
ExplicitBadSizedVLA.insert(N);
}
@@ -2169,7 +2171,7 @@
state = state->assume(Size, true);
if (zeroState) {
- if (NodeTy* N = Builder->generateNode(DS, zeroState, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(DS, zeroState, Pred)) {
N->markAsSink();
if (state)
ImplicitBadSizedVLA.insert(N);
@@ -2216,18 +2218,18 @@
class VISIBILITY_HIDDEN InitListWLItem {
public:
llvm::ImmutableList<SVal> Vals;
- GRExprEngine::NodeTy* N;
+ ExplodedNode* N;
InitListExpr::reverse_iterator Itr;
- InitListWLItem(GRExprEngine::NodeTy* n, llvm::ImmutableList<SVal> vals,
- InitListExpr::reverse_iterator itr)
+ InitListWLItem(ExplodedNode* n, llvm::ImmutableList<SVal> vals,
+ InitListExpr::reverse_iterator itr)
: Vals(vals), N(n), Itr(itr) {}
};
}
-void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred,
- NodeSet& Dst) {
+void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
const GRState* state = GetState(Pred);
QualType T = getContext().getCanonicalType(E->getType());
@@ -2257,12 +2259,12 @@
InitListWLItem X = WorkList.back();
WorkList.pop_back();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*X.Itr, X.N, Tmp);
InitListExpr::reverse_iterator NewItr = X.Itr + 1;
- for (NodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
+ for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
// Get the last initializer value.
state = GetState(*NI);
SVal InitV = state->getSVal(cast<Expr>(*X.Itr));
@@ -2291,10 +2293,10 @@
if (Loc::IsLocType(T) || T->isIntegerType()) {
assert (E->getNumInits() == 1);
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Expr* Init = E->getInit(0);
Visit(Init, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) {
state = GetState(*I);
MakeNode(Dst, E, *I, state->bindExpr(E, state->getSVal(Init)));
}
@@ -2308,8 +2310,8 @@
/// VisitSizeOfAlignOfExpr - Transfer function for sizeof(type).
void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
- NodeTy* Pred,
- NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
QualType T = Ex->getTypeOfArgument();
uint64_t amt;
@@ -2341,8 +2343,8 @@
}
-void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
switch (U->getOpcode()) {
@@ -2352,10 +2354,10 @@
case UnaryOperator::Deref: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal location = state->getSVal(Ex);
@@ -2373,10 +2375,10 @@
case UnaryOperator::Real: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
@@ -2397,10 +2399,10 @@
case UnaryOperator::Imag: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
// Just report "Unknown."
@@ -2432,10 +2434,10 @@
// subexpression.
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
MakeNode(Dst, U, *I, state->bindExpr(U, state->getSVal(Ex)));
}
@@ -2447,10 +2449,10 @@
assert(!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal V = state->getSVal(Ex);
state = state->bindExpr(U, V);
@@ -2466,10 +2468,10 @@
assert (!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
// Get the value of the subexpression.
@@ -2540,20 +2542,20 @@
// Handle ++ and -- (both pre- and post-increment).
assert (U->isIncrementDecrementOp());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Expr* Ex = U->getSubExpr()->IgnoreParens();
VisitLValue(Ex, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal V1 = state->getSVal(Ex);
// Perform a load.
- NodeSet Tmp2;
+ ExplodedNodeSet Tmp2;
EvalLoad(Tmp2, Ex, *I, state, V1);
- for (NodeSet::iterator I2 = Tmp2.begin(), E2 = Tmp2.end(); I2!=E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2 = Tmp2.begin(), E2 = Tmp2.end(); I2!=E2; ++I2) {
state = GetState(*I2);
SVal V2 = state->getSVal(Ex);
@@ -2614,32 +2616,32 @@
}
}
-void GRExprEngine::VisitAsmStmt(AsmStmt* A, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitAsmStmt(AsmStmt* A, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
VisitAsmStmtHelperOutputs(A, A->begin_outputs(), A->end_outputs(), Pred, Dst);
}
void GRExprEngine::VisitAsmStmtHelperOutputs(AsmStmt* A,
AsmStmt::outputs_iterator I,
AsmStmt::outputs_iterator E,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (I == E) {
VisitAsmStmtHelperInputs(A, A->begin_inputs(), A->end_inputs(), Pred, Dst);
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(*I, Pred, Tmp);
++I;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitAsmStmtHelperOutputs(A, I, E, *NI, Dst);
}
void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A,
AsmStmt::inputs_iterator I,
AsmStmt::inputs_iterator E,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (I == E) {
// We have processed both the inputs and the outputs. All of the outputs
@@ -2665,16 +2667,16 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*I, Pred, Tmp);
++I;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitAsmStmtHelperInputs(A, I, E, *NI, Dst);
}
-void GRExprEngine::EvalReturn(NodeSet& Dst, ReturnStmt* S, NodeTy* Pred) {
+void GRExprEngine::EvalReturn(ExplodedNodeSet& Dst, ReturnStmt* S, ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
unsigned size = Dst.size();
@@ -2690,7 +2692,7 @@
MakeNode(Dst, S, Pred, GetState(Pred));
}
-void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitReturnStmt(ReturnStmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
Expr* R = S->getRetValue();
@@ -2699,10 +2701,10 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(R, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
SVal X = (*I)->getState()->getSVal(R);
// Check if we return the address of a stack variable.
@@ -2712,7 +2714,7 @@
if (R && R->hasStackStorage()) {
// Create a special node representing the error.
- if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
+ if (ExplodedNode* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink();
RetsStackAddr.insert(N);
}
@@ -2721,7 +2723,7 @@
}
// Check if we return an undefined value.
else if (X.isUndef()) {
- if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
+ if (ExplodedNode* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink();
RetsUndef.insert(N);
}
@@ -2737,12 +2739,12 @@
//===----------------------------------------------------------------------===//
const GRState* GRExprEngine::CheckDivideZero(Expr* Ex, const GRState* state,
- NodeTy* Pred, SVal Denom) {
+ ExplodedNode* Pred, SVal Denom) {
// Divide by undefined? (potentially zero)
if (Denom.isUndef()) {
- NodeTy* DivUndef = Builder->generateNode(Ex, state, Pred);
+ ExplodedNode* DivUndef = Builder->generateNode(Ex, state, Pred);
if (DivUndef) {
DivUndef->markAsSink();
@@ -2761,7 +2763,7 @@
// Create the node for the divide-by-zero (if it occurred).
if (zeroState)
- if (NodeTy* DivZeroNode = Builder->generateNode(Ex, zeroState, Pred)) {
+ if (ExplodedNode* DivZeroNode = Builder->generateNode(Ex, zeroState, Pred)) {
DivZeroNode->markAsSink();
if (state)
@@ -2775,10 +2777,10 @@
}
void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
- GRExprEngine::NodeTy* Pred,
- GRExprEngine::NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
- NodeSet Tmp1;
+ ExplodedNodeSet Tmp1;
Expr* LHS = B->getLHS()->IgnoreParens();
Expr* RHS = B->getRHS()->IgnoreParens();
@@ -2793,18 +2795,18 @@
else
Visit(LHS, Pred, Tmp1);
- for (NodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1 != E1; ++I1) {
+ for (ExplodedNodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1 != E1; ++I1) {
SVal LeftV = (*I1)->getState()->getSVal(LHS);
// Process the RHS.
- NodeSet Tmp2;
+ ExplodedNodeSet Tmp2;
Visit(RHS, *I1, Tmp2);
// With both the LHS and RHS evaluated, process the operation itself.
- for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2 != E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2 != E2; ++I2) {
const GRState* state = GetState(*I2);
const GRState* OldSt = state;
@@ -2873,7 +2875,7 @@
// The operands were *not* undefined, but the result is undefined.
// This is a special node that should be flagged as an error.
- if (NodeTy* UndefNode = Builder->generateNode(B, state, *I2)) {
+ if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I2)) {
UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
@@ -2907,11 +2909,11 @@
// Perform a load (the LHS). This performs the checks for
// null dereferences, and so on.
- NodeSet Tmp3;
+ ExplodedNodeSet Tmp3;
SVal location = state->getSVal(LHS);
EvalLoad(Tmp3, LHS, *I2, state, location);
- for (NodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3; ++I3) {
+ for (ExplodedNodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3; ++I3) {
state = GetState(*I3);
SVal V = state->getSVal(LHS);
@@ -2978,7 +2980,7 @@
if (Result.isUndef()) {
// The operands were not undefined, but the result is undefined.
- if (NodeTy* UndefNode = Builder->generateNode(B, state, *I3)) {
+ if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I3)) {
UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
@@ -3061,10 +3063,10 @@
namespace llvm {
template<>
-struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
+struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
public DefaultDOTGraphTraits {
- static std::string getNodeAttributes(const GRExprEngine::NodeTy* N, void*) {
+ static std::string getNodeAttributes(const ExplodedNode* N, void*) {
if (GraphPrintCheckerState->isImplicitNullDeref(N) ||
GraphPrintCheckerState->isExplicitNullDeref(N) ||
@@ -3084,8 +3086,7 @@
return "";
}
- static std::string getNodeLabel(const GRExprEngine::NodeTy* N, void*,
- bool ShortNames) {
+ static std::string getNodeLabel(const ExplodedNode* N, void*,bool ShortNames){
std::string sbuf;
llvm::raw_string_ostream Out(sbuf);
@@ -3234,12 +3235,11 @@
#ifndef NDEBUG
template <typename ITERATOR>
-GRExprEngine::NodeTy* GetGraphNode(ITERATOR I) { return *I; }
+ExplodedNode* GetGraphNode(ITERATOR I) { return *I; }
-template <>
-GRExprEngine::NodeTy*
-GetGraphNode<llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator>
- (llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator I) {
+template <> ExplodedNode*
+GetGraphNode<llvm::DenseMap<ExplodedNode*, Expr*>::iterator>
+ (llvm::DenseMap<ExplodedNode*, Expr*>::iterator I) {
return I->first;
}
#endif
@@ -3247,7 +3247,7 @@
void GRExprEngine::ViewGraph(bool trim) {
#ifndef NDEBUG
if (trim) {
- std::vector<NodeTy*> Src;
+ std::vector<ExplodedNode*> Src;
// Flush any outstanding reports to make sure we cover all the nodes.
// This does not cause them to get displayed.
@@ -3259,7 +3259,7 @@
for (BugType::const_iterator I2=(*I)->begin(), E2=(*I)->end(); I2!=E2; ++I2) {
const BugReportEquivClass& EQ = *I2;
const BugReport &R = **EQ.begin();
- NodeTy *N = const_cast<NodeTy*>(R.getEndNode());
+ ExplodedNode *N = const_cast<ExplodedNode*>(R.getEndNode());
if (N) Src.push_back(N);
}
}
@@ -3278,12 +3278,12 @@
#endif
}
-void GRExprEngine::ViewGraph(NodeTy** Beg, NodeTy** End) {
+void GRExprEngine::ViewGraph(ExplodedNode** Beg, ExplodedNode** End) {
#ifndef NDEBUG
GraphPrintCheckerState = this;
GraphPrintSourceManager = &getContext().getSourceManager();
- std::auto_ptr<GRExprEngine::GraphTy> TrimmedG(G.Trim(Beg, End).first);
+ std::auto_ptr<ExplodedGraph> TrimmedG(G.Trim(Beg, End).first);
if (!TrimmedG.get())
llvm::cerr << "warning: Trimmed ExplodedGraph is empty.\n";
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp
index f07a385..3c316eb 100644
--- a/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -491,7 +491,7 @@
// Determine whether this was a 'zero-sized' VLA or a VLA with an
// undefined size.
- GRExprEngine::NodeTy* N = *I;
+ ExplodedNode* N = *I;
PostStmt PS = cast<PostStmt>(N->getLocation());
const DeclStmt *DS = cast<DeclStmt>(PS.getStmt());
VarDecl* VD = cast<VarDecl>(*DS->decl_begin());