Skip to content

Commit

Permalink
[analyzer] Remove the old StmtNodeBuilder.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142848 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AnnaZaks committed Oct 24, 2011
1 parent 056c4b4 commit cca79db
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 135 deletions.
90 changes: 1 addition & 89 deletions include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
Expand Up @@ -41,7 +41,6 @@ class NodeBuilder;
class CoreEngine {
friend struct NodeBuilderContext;
friend class NodeBuilder;
friend class StmtNodeBuilder;
friend class CommonNodeBuilder;
friend class GenericNodeBuilderImpl;
friend class IndirectGotoNodeBuilder;
Expand Down Expand Up @@ -192,8 +191,6 @@ struct NodeBuilderContext {
/// This is the simplest builder which generates nodes in the ExplodedGraph.
class NodeBuilder {
protected:
friend class StmtNodeBuilder;

const NodeBuilderContext &C;

/// Specifies if the builder results have been finalized. For example, if it
Expand Down Expand Up @@ -333,12 +330,7 @@ class PureStmtNodeBuilder: public NodeBuilder {

}

virtual ~PureStmtNodeBuilder() {
if (EnclosingBldr)
for (ExplodedNodeSet::iterator I = Frontier.begin(),
E = Frontier.end(); I != E; ++I )
EnclosingBldr->addNodes(*I);
}
virtual ~PureStmtNodeBuilder();

ExplodedNode *generateNode(const Stmt *S,
ExplodedNode *Pred,
Expand Down Expand Up @@ -366,86 +358,6 @@ class PureStmtNodeBuilder: public NodeBuilder {

};

class StmtNodeBuilder : public NodeBuilder {
const unsigned Idx;

public:
bool PurgingDeadSymbols;
bool BuildSinks;
// TODO: Remove the flag. We should be able to use the method in the parent.
bool hasGeneratedNode;
ProgramPoint::Kind PointKind;
const ProgramPointTag *Tag;

void GenerateAutoTransition(ExplodedNode *N);

StmtNodeBuilder(ExplodedNode *SrcNode, ExplodedNodeSet &DstSet,
unsigned idx, const NodeBuilderContext &Ctx)
: NodeBuilder(SrcNode, DstSet, Ctx), Idx(idx),
PurgingDeadSymbols(false), BuildSinks(false), hasGeneratedNode(false),
PointKind(ProgramPoint::PostStmtKind), Tag(0) {}

ExplodedNode *generateNode(const Stmt *S,
const ProgramState *St,
ExplodedNode *Pred,
ProgramPoint::Kind K,
const ProgramPointTag *tag = 0,
bool MarkAsSink = false) {
if (PurgingDeadSymbols)
K = ProgramPoint::PostPurgeDeadSymbolsKind;

const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K,
Pred->getLocationContext(), tag ? tag : Tag);
return generateNodeImpl(L, St, Pred, MarkAsSink);
}

ExplodedNode *generateNode(const Stmt *S,
const ProgramState *St,
ExplodedNode *Pred,
const ProgramPointTag *tag = 0) {
return generateNode(S, St, Pred, PointKind, tag);
}

ExplodedNode *generateNode(const ProgramPoint &PP,
const ProgramState *State,
ExplodedNode *Pred) {
return generateNodeImpl(PP, State, Pred, false);
}

/// getStmt - Return the current block-level expression associated with
/// this builder.
const Stmt *getStmt() const {
const CFGStmt *CS = (*C.Block)[Idx].getAs<CFGStmt>();
return CS ? CS->getStmt() : 0;
}

unsigned getIndex() const { return Idx; }

ExplodedNode *MakeNode(ExplodedNodeSet &Dst,
const Stmt *S,
ExplodedNode *Pred,
const ProgramState *St) {
return MakeNode(Dst, S, Pred, St, PointKind);
}

ExplodedNode *MakeNode(ExplodedNodeSet &Dst,
const Stmt *S,
ExplodedNode *Pred,
const ProgramState *St,
ProgramPoint::Kind K);

ExplodedNode *MakeSinkNode(ExplodedNodeSet &Dst,
const Stmt *S,
ExplodedNode *Pred,
const ProgramState *St) {
bool Tmp = BuildSinks;
BuildSinks = true;
ExplodedNode *N = MakeNode(Dst, S, Pred, St);
BuildSinks = Tmp;
return N;
}
};

class BranchNodeBuilder: public NodeBuilder {
const CFGBlock *DstT;
const CFGBlock *DstF;
Expand Down
Expand Up @@ -54,7 +54,6 @@ class ExplodedNode : public llvm::FoldingSetNode {
friend class ExplodedGraph;
friend class CoreEngine;
friend class NodeBuilder;
friend class StmtNodeBuilder;
friend class BranchNodeBuilder;
friend class IndirectGotoNodeBuilder;
friend class SwitchNodeBuilder;
Expand Down
Expand Up @@ -34,7 +34,6 @@ class ExplodedNode;
class ProgramState;
class ProgramStateManager;
class BlockCounter;
class StmtNodeBuilder;
class BranchNodeBuilder;
class IndirectGotoNodeBuilder;
class SwitchNodeBuilder;
Expand Down
49 changes: 5 additions & 44 deletions lib/StaticAnalyzer/Core/CoreEngine.cpp
Expand Up @@ -506,50 +506,11 @@ ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
return (IsNew ? N : 0);
}

void StmtNodeBuilder::GenerateAutoTransition(ExplodedNode *N) {
assert (!N->isSink());

// Check if this node entered a callee.
if (isa<CallEnter>(N->getLocation())) {
// Still use the index of the CallExpr. It's needed to create the callee
// StackFrameContext.
C.Eng.WList->enqueue(N, C.Block, Idx);
return;
}

// Do not create extra nodes. Move to the next CFG element.
if (isa<PostInitializer>(N->getLocation())) {
C.Eng.WList->enqueue(N, C.Block, Idx+1);
return;
}

PostStmt Loc(getStmt(), N->getLocationContext());

if (Loc == N->getLocation()) {
// Note: 'N' should be a fresh node because otherwise it shouldn't be
// a member of Deferred.
C.Eng.WList->enqueue(N, C.Block, Idx+1);
return;
}

bool IsNew;
ExplodedNode *Succ = C.Eng.G->getNode(Loc, N->State, &IsNew);
Succ->addPredecessor(N, *C.Eng.G);

if (IsNew)
C.Eng.WList->enqueue(Succ, C.Block, Idx+1);
}

ExplodedNode *StmtNodeBuilder::MakeNode(ExplodedNodeSet &DstSet,
const Stmt *S,
ExplodedNode *Pred,
const ProgramState *St,
ProgramPoint::Kind K) {
ExplodedNode *N = generateNode(S, St, Pred, K, 0, BuildSinks);
if (N && !BuildSinks){
DstSet.Add(N);
}
return N;
PureStmtNodeBuilder::~PureStmtNodeBuilder() {
if (EnclosingBldr)
for (ExplodedNodeSet::iterator I = Frontier.begin(),
E = Frontier.end(); I != E; ++I )
EnclosingBldr->addNodes(*I);
}

ExplodedNode *BranchNodeBuilder::generateNode(const ProgramState *State,
Expand Down

0 comments on commit cca79db

Please sign in to comment.