forked from OSchip/llvm-project
[analyzer] Pull Pred out of NodeBuilderContext.
Each builder will have a different one, so it doesn't make sense to keep it in the context. llvm-svn: 142447
This commit is contained in:
parent
2e2eb49f7f
commit
eebbbc7253
|
|
@ -50,8 +50,8 @@ public:
|
|||
Location(loc),
|
||||
ST(st),
|
||||
size(Dst.size()),
|
||||
Ctx(builder.Eng, pred, builder.getBlock()),
|
||||
NB(Ctx),
|
||||
Ctx(builder.Eng, builder.getBlock()),
|
||||
NB(Ctx, pred),
|
||||
respondsToCallback(respondsToCB) {
|
||||
assert(!(ST && ST != Pred->getState()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,10 +170,9 @@ public:
|
|||
|
||||
struct NodeBuilderContext {
|
||||
CoreEngine &Eng;
|
||||
ExplodedNode *Pred;
|
||||
const CFGBlock *Block;
|
||||
NodeBuilderContext(CoreEngine &E, ExplodedNode *N, const CFGBlock *B)
|
||||
: Eng(E), Pred(N), Block(B) { assert(B); assert(!N->isSink()); }
|
||||
NodeBuilderContext(CoreEngine &E, const CFGBlock *B)
|
||||
: Eng(E), Block(B) { assert(B); }
|
||||
};
|
||||
|
||||
/// This is the simplest builder which generates nodes in the ExplodedGraph.
|
||||
|
|
@ -181,6 +180,7 @@ class NodeBuilder {
|
|||
protected:
|
||||
friend class StmtNodeBuilder;
|
||||
|
||||
ExplodedNode *BuilderPred;
|
||||
NodeBuilderContext &C;
|
||||
bool Finalized;
|
||||
|
||||
|
|
@ -212,8 +212,11 @@ protected:
|
|||
bool MarkAsSink = false);
|
||||
|
||||
public:
|
||||
NodeBuilder(NodeBuilderContext &Ctx)
|
||||
: C(Ctx), Finalized(false) { Deferred.insert(C.Pred); }
|
||||
NodeBuilder(NodeBuilderContext &Ctx, ExplodedNode *N)
|
||||
: BuilderPred(N), C(Ctx), Finalized(false) {
|
||||
assert(!N->isSink());
|
||||
Deferred.insert(N);
|
||||
}
|
||||
|
||||
virtual ~NodeBuilder() {}
|
||||
|
||||
|
|
@ -229,10 +232,10 @@ public:
|
|||
}
|
||||
|
||||
// \brief Get the builder's predecessor - the parent to all the other nodes.
|
||||
const ExplodedNode *getPred() const { return C.Pred; }
|
||||
const ExplodedNode *getPred() const { return BuilderPred; }
|
||||
|
||||
bool hasGeneratedNodes() const {
|
||||
return (!Deferred.count(C.Pred));
|
||||
return (!Deferred.count(BuilderPred));
|
||||
}
|
||||
|
||||
typedef DeferredTy::iterator iterator;
|
||||
|
|
@ -251,11 +254,11 @@ public:
|
|||
/// visited on the exploded graph path.
|
||||
unsigned getCurrentBlockCount() const {
|
||||
return getBlockCounter().getNumVisited(
|
||||
C.Pred->getLocationContext()->getCurrentStackFrame(),
|
||||
BuilderPred->getLocationContext()->getCurrentStackFrame(),
|
||||
C.Block->getBlockID());
|
||||
}
|
||||
|
||||
ExplodedNode *getPredecessor() const { return C.Pred; }
|
||||
ExplodedNode *getPredecessor() const { return BuilderPred; }
|
||||
};
|
||||
|
||||
class CommonNodeBuilder {
|
||||
|
|
@ -400,15 +403,15 @@ class BranchNodeBuilder: public NodeBuilder {
|
|||
void finalizeResults() {
|
||||
if (Finalized)
|
||||
return;
|
||||
if (!GeneratedTrue) generateNode(C.Pred->State, true);
|
||||
if (!GeneratedFalse) generateNode(C.Pred->State, false);
|
||||
if (!GeneratedTrue) generateNode(BuilderPred->State, true);
|
||||
if (!GeneratedFalse) generateNode(BuilderPred->State, false);
|
||||
Finalized = true;
|
||||
}
|
||||
|
||||
public:
|
||||
BranchNodeBuilder(NodeBuilderContext &C, const CFGBlock *dstT,
|
||||
const CFGBlock *dstF)
|
||||
: NodeBuilder(C), DstT(dstT), DstF(dstF),
|
||||
BranchNodeBuilder(NodeBuilderContext &C, ExplodedNode *Pred,
|
||||
const CFGBlock *dstT, const CFGBlock *dstF)
|
||||
: NodeBuilder(C, Pred), DstT(dstT), DstF(dstF),
|
||||
GeneratedTrue(false), GeneratedFalse(false),
|
||||
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ public:
|
|||
/// nodes by processing the 'effects' of a branch condition.
|
||||
void processBranch(const Stmt *Condition, const Stmt *Term,
|
||||
NodeBuilderContext& BuilderCtx,
|
||||
ExplodedNode *Pred,
|
||||
const CFGBlock *DstT,
|
||||
const CFGBlock *DstF);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ public:
|
|||
/// nodes by processing the 'effects' of a branch condition.
|
||||
virtual void processBranch(const Stmt *Condition, const Stmt *Term,
|
||||
NodeBuilderContext& BuilderCtx,
|
||||
ExplodedNode *Pred,
|
||||
const CFGBlock *DstT,
|
||||
const CFGBlock *DstF) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -417,8 +417,8 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
|
|||
void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term,
|
||||
const CFGBlock * B, ExplodedNode *Pred) {
|
||||
assert(B->succ_size() == 2);
|
||||
NodeBuilderContext Ctx(*this, Pred, B);
|
||||
SubEng.processBranch(Cond, Term, Ctx,
|
||||
NodeBuilderContext Ctx(*this, B);
|
||||
SubEng.processBranch(Cond, Term, Ctx, Pred,
|
||||
*(B->succ_begin()), *(B->succ_begin()+1));
|
||||
}
|
||||
|
||||
|
|
@ -608,11 +608,12 @@ ExplodedNode *BranchNodeBuilder::generateNode(const Stmt *Condition,
|
|||
const ProgramState *State,
|
||||
const ProgramPointTag *Tag,
|
||||
bool MarkAsSink) {
|
||||
ProgramPoint PP = PostCondition(Condition, C.Pred->getLocationContext(), Tag);
|
||||
ExplodedNode *N = generateNodeImpl(PP, State, C.Pred, MarkAsSink);
|
||||
ProgramPoint PP = PostCondition(Condition,
|
||||
BuilderPred->getLocationContext(), Tag);
|
||||
ExplodedNode *N = generateNodeImpl(PP, State, BuilderPred, MarkAsSink);
|
||||
assert(N);
|
||||
// TODO: This needs to go - we should not change Pred!!!
|
||||
C.Pred = N;
|
||||
BuilderPred = N;
|
||||
return N;
|
||||
}
|
||||
|
||||
|
|
@ -625,7 +626,7 @@ ExplodedNode *BranchNodeBuilder::generateNode(const ProgramState *State,
|
|||
return NULL;
|
||||
|
||||
if (!NodePred)
|
||||
NodePred = C.Pred;
|
||||
NodePred = BuilderPred;
|
||||
ProgramPoint Loc = BlockEdge(C.Block, branch ? DstT:DstF,
|
||||
NodePred->getLocationContext());
|
||||
ExplodedNode *Succ = generateNodeImpl(Loc, State, NodePred);
|
||||
|
|
|
|||
|
|
@ -941,14 +941,15 @@ static SVal RecoverCastedSymbol(ProgramStateManager& StateMgr,
|
|||
|
||||
void ExprEngine::processBranch(const Stmt *Condition, const Stmt *Term,
|
||||
NodeBuilderContext& BldCtx,
|
||||
ExplodedNode *Pred,
|
||||
const CFGBlock *DstT,
|
||||
const CFGBlock *DstF) {
|
||||
|
||||
BranchNodeBuilder builder(BldCtx, DstT, DstF);
|
||||
BranchNodeBuilder builder(BldCtx, Pred, DstT, DstF);
|
||||
|
||||
// Check for NULL conditions; e.g. "for(;;)"
|
||||
if (!Condition) {
|
||||
BranchNodeBuilder NullCondBldr(BldCtx, DstT, DstF);
|
||||
BranchNodeBuilder NullCondBldr(BldCtx, Pred, DstT, DstF);
|
||||
NullCondBldr.markInfeasible(false);
|
||||
Engine.enqueue(NullCondBldr);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue