[cfe-commits] r142454 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h lib/StaticAnalyzer/Core/CoreEngine.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp
Anna Zaks
ganna at apple.com
Tue Oct 18 16:06:48 PDT 2011
Author: zaks
Date: Tue Oct 18 18:06:48 2011
New Revision: 142454
URL: http://llvm.org/viewvc/llvm-project?rev=142454&view=rev
Log:
[analyzer] Move predecessor into the NodeBuilder context.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.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=142454&r1=142453&r2=142454&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:48 2011
@@ -48,7 +48,7 @@
Location(loc),
ST(st),
size(Dst.size()),
- Ctx(builder.C.Eng, builder.getBlock()),
+ Ctx(builder.C.Eng, builder.getBlock(), pred),
NB(builder),
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=142454&r1=142453&r2=142454&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:48 2011
@@ -171,8 +171,9 @@
struct NodeBuilderContext {
CoreEngine &Eng;
const CFGBlock *Block;
- NodeBuilderContext(CoreEngine &E, const CFGBlock *B)
- : Eng(E), Block(B) { assert(B); }
+ ExplodedNode *ContextPred;
+ NodeBuilderContext(CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
+ : Eng(E), Block(B), ContextPred(N) { assert(B); assert(!N->isSink()); }
};
/// This is the simplest builder which generates nodes in the ExplodedGraph.
@@ -219,17 +220,15 @@
bool MarkAsSink = false);
public:
- NodeBuilder(ExplodedNode *N, NodeBuilderContext &Ctx, bool F = true)
- : BuilderPred(N), C(Ctx), Finalized(F), HasGeneratedNodes(false) {
- assert(!N->isSink());
- Deferred.insert(N);
+ NodeBuilder(NodeBuilderContext &Ctx, bool F = true)
+ : C(Ctx), Finalized(F), HasGeneratedNodes(false) {
+ Deferred.insert(C.ContextPred);
}
/// Create a new builder using the parent builder's context.
- NodeBuilder(ExplodedNode *N, const NodeBuilder &ParentBldr, bool F = true)
- : BuilderPred(N), C(ParentBldr.C), Finalized(F), HasGeneratedNodes(false) {
- assert(!N->isSink());
- Deferred.insert(N);
+ NodeBuilder(const NodeBuilder &ParentBldr, bool F = true)
+ : C(ParentBldr.C), Finalized(F), HasGeneratedNodes(false) {
+ Deferred.insert(C.ContextPred);
}
virtual ~NodeBuilder() {}
@@ -269,8 +268,8 @@
/// visited on the exploded graph path.
unsigned getCurrentBlockCount() const {
return getBlockCounter().getNumVisited(
- BuilderPred->getLocationContext()->getCurrentStackFrame(),
- C.Block->getBlockID());
+ C.ContextPred->getLocationContext()->getCurrentStackFrame(),
+ C.Block->getBlockID());
}
};
@@ -363,7 +362,7 @@
}
void importNodesFromBuilder(const NodeBuilder &NB) {
- ExplodedNode *NBPred = const_cast<ExplodedNode*>(NB.BuilderPred);
+ ExplodedNode *NBPred = const_cast<ExplodedNode*>(NB.C.ContextPred);
if (NB.hasGeneratedNodes()) {
Deferred.erase(NBPred);
Deferred.insert(NB.Deferred.begin(), NB.Deferred.end());
@@ -379,19 +378,19 @@
bool InFeasibleFalse;
public:
- BranchNodeBuilder(ExplodedNode *Pred, NodeBuilderContext &C,
+ BranchNodeBuilder(NodeBuilderContext &C,
const CFGBlock *dstT, const CFGBlock *dstF)
- : NodeBuilder(Pred, C), DstT(dstT), DstF(dstF),
+ : NodeBuilder(C), DstT(dstT), DstF(dstF),
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
/// Create a new builder using the parent builder's context.
- BranchNodeBuilder(ExplodedNode *Pred, BranchNodeBuilder &ParentBldr)
- : NodeBuilder(Pred, ParentBldr), DstT(ParentBldr.DstT),
+ BranchNodeBuilder(BranchNodeBuilder &ParentBldr)
+ : NodeBuilder(ParentBldr), DstT(ParentBldr.DstT),
DstF(ParentBldr.DstF),
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
ExplodedNode *generateNode(const ProgramState *State, bool branch,
- ExplodedNode *Pred = 0);
+ ExplodedNode *Pred);
const CFGBlock *getTargetBlock(bool branch) const {
return branch ? DstT : DstF;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=142454&r1=142453&r2=142454&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Tue Oct 18 18:06:48 2011
@@ -314,7 +314,7 @@
// Process the entrance of the block.
if (CFGElement E = L.getFirstElement()) {
- NodeBuilderContext Ctx(*this, L.getBlock());
+ NodeBuilderContext Ctx(*this, L.getBlock(), Pred);
StmtNodeBuilder Builder(Pred, 0, Ctx);
SubEng.processCFGElement(E, Builder, Pred);
}
@@ -418,7 +418,7 @@
void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term,
const CFGBlock * B, ExplodedNode *Pred) {
assert(B->succ_size() == 2);
- NodeBuilderContext Ctx(*this, B);
+ NodeBuilderContext Ctx(*this, B, Pred);
SubEng.processBranch(Cond, Term, Ctx, Pred,
*(B->succ_begin()), *(B->succ_begin()+1));
}
@@ -431,7 +431,7 @@
if (StmtIdx == B->size())
HandleBlockExit(B, Pred);
else {
- NodeBuilderContext Ctx(*this, B);
+ NodeBuilderContext Ctx(*this, B, Pred);
StmtNodeBuilder Builder(Pred, StmtIdx, Ctx);
SubEng.processCFGElement((*B)[StmtIdx], Builder, Pred);
}
@@ -508,7 +508,7 @@
StmtNodeBuilder::StmtNodeBuilder(ExplodedNode *N, unsigned idx,
NodeBuilderContext &Ctx)
- : NodeBuilder(N, Ctx), Idx(idx),
+ : NodeBuilder(Ctx), Idx(idx),
PurgingDeadSymbols(false), BuildSinks(false), hasGeneratedNode(false),
PointKind(ProgramPoint::PostStmtKind), Tag(0) {
Deferred.insert(N);
@@ -573,8 +573,6 @@
if (!isFeasible(branch))
return NULL;
- if (!NodePred)
- 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=142454&r1=142453&r2=142454&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Oct 18 18:06:48 2011
@@ -949,7 +949,7 @@
// Check for NULL conditions; e.g. "for(;;)"
if (!Condition) {
- BranchNodeBuilder NullCondBldr(Pred, BldCtx, DstT, DstF);
+ BranchNodeBuilder NullCondBldr(BldCtx, DstT, DstF);
NullCondBldr.markInfeasible(false);
NullCondBldr.generateNode(Pred->getState(), true, Pred);
Engine.enqueue(NullCondBldr);
@@ -960,7 +960,7 @@
Condition->getLocStart(),
"Error evaluating branch");
- NodeBuilder CheckerBldr(Pred, BldCtx);
+ NodeBuilder CheckerBldr(BldCtx);
getCheckerManager().runCheckersForBranchCondition(Condition, CheckerBldr,
Pred, *this);
@@ -971,7 +971,7 @@
if (PredI->isSink())
continue;
- BranchNodeBuilder builder(PredI, BldCtx, DstT, DstF);
+ BranchNodeBuilder builder(BldCtx, DstT, DstF);
const ProgramState *PrevState = Pred->getState();
SVal X = PrevState->getSVal(Condition);
More information about the cfe-commits
mailing list