[cfe-commits] r142447 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h lib/StaticAnalyzer/Core/CoreEngine.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp
Anna Zaks
ganna at apple.com
Tue Oct 18 16:06:16 PDT 2011
Author: zaks
Date: Tue Oct 18 18:06:16 2011
New Revision: 142447
URL: http://llvm.org/viewvc/llvm-project?rev=142447&view=rev
Log:
[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.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Tue Oct 18 18:06:16 2011
@@ -50,8 +50,8 @@
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()));
}
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Tue Oct 18 18:06:16 2011
@@ -170,10 +170,9 @@
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 @@
protected:
friend class StmtNodeBuilder;
+ ExplodedNode *BuilderPred;
NodeBuilderContext &C;
bool Finalized;
@@ -212,8 +212,11 @@
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 @@
}
// \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 @@
/// 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 @@
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) {
}
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Tue Oct 18 18:06:16 2011
@@ -155,6 +155,7 @@
/// 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);
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h Tue Oct 18 18:06:16 2011
@@ -67,6 +67,7 @@
/// 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;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Tue Oct 18 18:06:16 2011
@@ -417,8 +417,8 @@
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 @@
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 @@
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);
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=142447&r1=142446&r2=142447&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Oct 18 18:06:16 2011
@@ -941,14 +941,15 @@
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;
More information about the cfe-commits
mailing list