[cfe-commits] r142452 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h lib/StaticAnalyzer/Core/CheckerContext.cpp lib/StaticAnalyzer/Core/CoreEngine.cpp
Anna Zaks
ganna at apple.com
Tue Oct 18 16:06:38 PDT 2011
Author: zaks
Date: Tue Oct 18 18:06:38 2011
New Revision: 142452
URL: http://llvm.org/viewvc/llvm-project?rev=142452&view=rev
Log:
[analyzer] Remove StmtNodeBuilder from CheckerContext
It now only depends on a generic NodeBuilder instead. As part of this change, make the generic node builder results finalized by default.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.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=142452&r1=142451&r2=142452&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:38 2011
@@ -24,7 +24,6 @@
class CheckerContext {
ExplodedNodeSet &Dst;
- StmtNodeBuilder &B;
ExprEngine &Eng;
ExplodedNode *Pred;
const ProgramPoint Location;
@@ -32,26 +31,25 @@
const unsigned size;
// TODO: Use global context.
NodeBuilderContext Ctx;
- NodeBuilder NB;
+ NodeBuilder &NB;
public:
bool *respondsToCallback;
public:
CheckerContext(ExplodedNodeSet &dst,
- StmtNodeBuilder &builder,
+ NodeBuilder &builder,
ExprEngine &eng,
ExplodedNode *pred,
const ProgramPoint &loc,
bool *respondsToCB = 0,
const ProgramState *st = 0)
: Dst(dst),
- B(builder),
Eng(eng),
Pred(pred),
Location(loc),
ST(st),
size(Dst.size()),
Ctx(builder.C.Eng, builder.getBlock()),
- NB(pred, Ctx),
+ 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=142452&r1=142451&r2=142452&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:38 2011
@@ -187,6 +187,8 @@
const NodeBuilderContext &C;
protected:
+ /// Specifies if the builder results have been finalized. For example, if it
+ /// is set to false, autotransitions are yet to be generated.
bool Finalized;
/// \brief The frontier set - a set of nodes which need to be propagated after
@@ -196,7 +198,8 @@
BlockCounter getBlockCounter() const { return C.Eng.WList->getBlockCounter();}
- bool checkResults() {
+ /// Checkes if the results are ready.
+ virtual bool checkResults() {
if (!Finalized)
return false;
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
@@ -205,11 +208,8 @@
return true;
}
- virtual void finalizeResults() {
- if (!Finalized) {
- Finalized = true;
- }
- }
+ /// Allow subclasses to finalize results before result_begin() is executed.
+ virtual void finalizeResults() {}
ExplodedNode *generateNodeImpl(const ProgramPoint &PP,
const ProgramState *State,
@@ -217,15 +217,15 @@
bool MarkAsSink = false);
public:
- NodeBuilder(ExplodedNode *N, NodeBuilderContext &Ctx)
- : BuilderPred(N), C(Ctx), Finalized(false) {
+ NodeBuilder(ExplodedNode *N, NodeBuilderContext &Ctx, bool F = true)
+ : BuilderPred(N), C(Ctx), Finalized(F) {
assert(!N->isSink());
Deferred.insert(N);
}
/// Create a new builder using the parent builder's context.
- NodeBuilder(ExplodedNode *N, const NodeBuilder &ParentBldr)
- : BuilderPred(N), C(ParentBldr.C), Finalized(false) {
+ NodeBuilder(ExplodedNode *N, const NodeBuilder &ParentBldr, bool F = true)
+ : BuilderPred(N), C(ParentBldr.C), Finalized(F) {
assert(!N->isSink());
Deferred.insert(N);
}
@@ -383,6 +383,8 @@
bool InFeasibleTrue;
bool InFeasibleFalse;
+ /// Generate default branching transitions of none were generated or
+ /// suppressed.
void finalizeResults() {
if (Finalized)
return;
@@ -394,15 +396,15 @@
public:
BranchNodeBuilder(ExplodedNode *Pred, NodeBuilderContext &C,
const CFGBlock *dstT, const CFGBlock *dstF)
- : NodeBuilder(Pred, C), DstT(dstT), DstF(dstF),
+ : NodeBuilder(Pred, C, false), DstT(dstT), DstF(dstF),
GeneratedTrue(false), GeneratedFalse(false),
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), DstF(ParentBldr.DstF),
- GeneratedTrue(false), GeneratedFalse(false),
+ : NodeBuilder(Pred, ParentBldr, false), DstT(ParentBldr.DstT),
+ DstF(ParentBldr.DstF), GeneratedTrue(false), GeneratedFalse(false),
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp?rev=142452&r1=142451&r2=142452&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerContext.cpp Tue Oct 18 18:06:38 2011
@@ -22,8 +22,4 @@
E = NB.results_end(); I != E; ++I) {
Dst.Add(*I);
}
-
- // Copy the results into the StmtNodeBuilder.
- //TODO: This will be removed after we completely migrate NodeBuilder.
- B.importNodesFromBuilder(NB);
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=142452&r1=142451&r2=142452&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Tue Oct 18 18:06:38 2011
@@ -489,9 +489,6 @@
const ProgramState *State,
ExplodedNode *FromN,
bool MarkAsSink) {
- assert(Finalized == false &&
- "We cannot create new nodes after the results have been finalized.");
-
bool IsNew;
ExplodedNode *N = C.Eng.G->getNode(Loc, State, &IsNew);
N->addPredecessor(FromN, *C.Eng.G);
@@ -570,6 +567,8 @@
ExplodedNode *BranchNodeBuilder::generateNode(const ProgramState *State,
bool branch,
ExplodedNode *NodePred) {
+ assert(Finalized == false &&
+ "We cannot create new nodes after the results have been finalized.");
// If the branch has been marked infeasible we should not generate a node.
if (!isFeasible(branch))
More information about the cfe-commits
mailing list