Last step of template cleanup: merge *BuilderImpl to *Builder.
Some Builders need further cleanup.
llvm-svn: 78301
diff --git a/clang/lib/Analysis/BasicObjCFoundationChecks.cpp b/clang/lib/Analysis/BasicObjCFoundationChecks.cpp
index d7631bc..6e9dd90 100644
--- a/clang/lib/Analysis/BasicObjCFoundationChecks.cpp
+++ b/clang/lib/Analysis/BasicObjCFoundationChecks.cpp
@@ -63,12 +63,12 @@
ASTContext &Ctx;
bool isNSString(const ObjCInterfaceType *T, const char* suffix);
- bool AuditNSString(NodeTy* N, const ObjCMessageExpr* ME);
+ bool AuditNSString(ExplodedNode* N, const ObjCMessageExpr* ME);
- void Warn(NodeTy* N, const Expr* E, const std::string& s);
- void WarnNilArg(NodeTy* N, const Expr* E);
+ void Warn(ExplodedNode* N, const Expr* E, const std::string& s);
+ void WarnNilArg(ExplodedNode* N, const Expr* E);
- bool CheckNilArg(NodeTy* N, unsigned Arg);
+ bool CheckNilArg(ExplodedNode* N, unsigned Arg);
public:
BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br)
@@ -77,7 +77,7 @@
bool Audit(ExplodedNode* N, GRStateManager&);
private:
- void WarnNilArg(NodeTy* N, const ObjCMessageExpr* ME, unsigned Arg) {
+ void WarnNilArg(ExplodedNode* N, const ObjCMessageExpr* ME, unsigned Arg) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Argument to '" << GetReceiverNameType(ME) << "' method '"
@@ -139,7 +139,7 @@
// Error reporting.
//===----------------------------------------------------------------------===//
-bool BasicObjCFoundationChecks::CheckNilArg(NodeTy* N, unsigned Arg) {
+bool BasicObjCFoundationChecks::CheckNilArg(ExplodedNode* N, unsigned Arg) {
const ObjCMessageExpr* ME =
cast<ObjCMessageExpr>(cast<PostStmt>(N->getLocation()).getStmt());
@@ -162,7 +162,7 @@
return !strcmp("String", suffix) || !strcmp("MutableString", suffix);
}
-bool BasicObjCFoundationChecks::AuditNSString(NodeTy* N,
+bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N,
const ObjCMessageExpr* ME) {
Selector S = ME->getSelector();
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 0b8b488..02f427a 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/lib/Analysis/CFRefCount.cpp
@@ -167,19 +167,19 @@
namespace {
class VISIBILITY_HIDDEN GenericNodeBuilder {
- GRStmtNodeBuilder<GRState> *SNB;
+ GRStmtNodeBuilder *SNB;
Stmt *S;
const void *tag;
- GREndPathNodeBuilder<GRState> *ENB;
+ GREndPathNodeBuilder *ENB;
public:
- GenericNodeBuilder(GRStmtNodeBuilder<GRState> &snb, Stmt *s,
+ GenericNodeBuilder(GRStmtNodeBuilder &snb, Stmt *s,
const void *t)
: SNB(&snb), S(s), tag(t), ENB(0) {}
- GenericNodeBuilder(GREndPathNodeBuilder<GRState> &enb)
+
+ GenericNodeBuilder(GREndPathNodeBuilder &enb)
: SNB(0), S(0), tag(0), ENB(&enb) {}
- ExplodedNode *MakeNode(const GRState *state,
- ExplodedNode *Pred) {
+ ExplodedNode *MakeNode(const GRState *state, ExplodedNode *Pred) {
if (SNB)
return SNB->generateNode(PostStmt(S, tag), state, Pred);
@@ -1835,8 +1835,8 @@
};
private:
- typedef llvm::DenseMap<const GRExprEngine::NodeTy*, const RetainSummary*>
- SummaryLogTy;
+ typedef llvm::DenseMap<const ExplodedNode*, const RetainSummary*>
+ SummaryLogTy;
RetainSummaryManager Summaries;
SummaryLogTy SummaryLog;
@@ -1854,7 +1854,7 @@
RefVal::Kind& hasErr);
void ProcessNonLeakError(ExplodedNodeSet& Dst,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode* Pred,
const GRState* St,
@@ -1897,7 +1897,7 @@
void EvalSummary(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* Ex,
Expr* Receiver,
const RetainSummary& Summ,
@@ -1906,20 +1906,20 @@
virtual void EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred);
virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
bool EvalObjCMessageExprAux(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
@@ -1929,11 +1929,11 @@
// End-of-path.
virtual void EvalEndPath(GRExprEngine& Engine,
- GREndPathNodeBuilder<GRState>& Builder);
+ GREndPathNodeBuilder& Builder);
virtual void EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper);
@@ -1946,7 +1946,7 @@
virtual void EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred);
@@ -2743,7 +2743,7 @@
void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* Ex,
Expr* Receiver,
const RetainSummary& Summ,
@@ -2953,7 +2953,7 @@
}
// Generate a sink node if we are at the end of a path.
- GRExprEngine::NodeTy *NewNode =
+ ExplodedNode *NewNode =
Summ.isEndPath() ? Builder.MakeSinkNode(Dst, Ex, Pred, state)
: Builder.MakeNode(Dst, Ex, Pred, state);
@@ -2964,7 +2964,7 @@
void CFRefCount::EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
const FunctionDecl* FD = L.getAsFunctionDecl();
@@ -2978,7 +2978,7 @@
void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred) {
RetainSummary* Summ = 0;
@@ -3098,7 +3098,7 @@
void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred) {
@@ -3515,7 +3515,7 @@
}
void CFRefCount::EvalEndPath(GRExprEngine& Eng,
- GREndPathNodeBuilder<GRState>& Builder) {
+ GREndPathNodeBuilder& Builder) {
const GRState *state = Builder.getState();
GenericNodeBuilder Bd(Builder);
@@ -3543,7 +3543,7 @@
void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S,
const GRState* state,
@@ -3597,13 +3597,13 @@
}
void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
Expr* NodeExpr, Expr* ErrorExpr,
ExplodedNode* Pred,
const GRState* St,
RefVal::Kind hasErr, SymbolRef Sym) {
Builder.BuildSinks = true;
- GRExprEngine::NodeTy* N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
+ ExplodedNode *N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
if (!N)
return;
diff --git a/clang/lib/Analysis/CheckNSError.cpp b/clang/lib/Analysis/CheckNSError.cpp
index 0d67e01..b9599ce 100644
--- a/clang/lib/Analysis/CheckNSError.cpp
+++ b/clang/lib/Analysis/CheckNSError.cpp
@@ -66,7 +66,7 @@
void NSErrorCheck::FlushReports(BugReporter& BR) {
// Get the analysis engine and the exploded analysis graph.
- GRExprEngine::GraphTy& G = Eng.getGraph();
+ ExplodedGraph& G = Eng.getGraph();
// Get the declaration of the method/function that was analyzed.
Decl& CodeDecl = G.getCodeDecl();
@@ -89,8 +89,8 @@
if (ResultTy == Ctx.VoidTy) EmitRetTyWarning(BR, CodeDecl);
- for (GRExprEngine::GraphTy::roots_iterator RI=G.roots_begin(),
- RE=G.roots_end(); RI!=RE; ++RI) {
+ for (ExplodedGraph::roots_iterator RI=G.roots_begin(), RE=G.roots_end();
+ RI!=RE; ++RI) {
// Scan the parameters for an implicit null dereference.
for (llvm::SmallVectorImpl<VarDecl*>::iterator I=ErrorParams.begin(),
E=ErrorParams.end(); I!=E; ++I)
diff --git a/clang/lib/Analysis/GRCoreEngine.cpp b/clang/lib/Analysis/GRCoreEngine.cpp
index 4f0179a..66c12fd 100644
--- a/clang/lib/Analysis/GRCoreEngine.cpp
+++ b/clang/lib/Analysis/GRCoreEngine.cpp
@@ -119,13 +119,11 @@
//===----------------------------------------------------------------------===//
// Core analysis engine.
//===----------------------------------------------------------------------===//
-void GRCoreEngine::ProcessEndPath(GREndPathNodeBuilderImpl& BuilderImpl) {
- GREndPathNodeBuilder<StateTy> Builder(BuilderImpl);
+void GRCoreEngine::ProcessEndPath(GREndPathNodeBuilder& Builder) {
SubEngine.ProcessEndPath(Builder);
}
-void GRCoreEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilderImpl& BuilderImpl) {
- GRStmtNodeBuilder<StateTy> Builder(BuilderImpl,SubEngine.getStateManager());
+void GRCoreEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& Builder) {
SubEngine.ProcessStmt(S, Builder);
}
@@ -135,20 +133,18 @@
}
void GRCoreEngine::ProcessBranch(Stmt* Condition, Stmt* Terminator,
- GRBranchNodeBuilderImpl& BuilderImpl) {
- GRBranchNodeBuilder<StateTy> Builder(BuilderImpl);
+ GRBranchNodeBuilder& Builder) {
SubEngine.ProcessBranch(Condition, Terminator, Builder);
}
-void GRCoreEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilderImpl& BuilderImpl) {
- GRIndirectGotoNodeBuilder<GRState> Builder(BuilderImpl);
+void GRCoreEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& Builder) {
SubEngine.ProcessIndirectGoto(Builder);
}
-void GRCoreEngine::ProcessSwitch(GRSwitchNodeBuilderImpl& BuilderImpl) {
- GRSwitchNodeBuilder<GRState> Builder(BuilderImpl);
+void GRCoreEngine::ProcessSwitch(GRSwitchNodeBuilder& Builder) {
SubEngine.ProcessSwitch(Builder);
}
+
/// ExecuteWorkList - Run the worklist algorithm for a maximum number of steps.
bool GRCoreEngine::ExecuteWorkList(unsigned Steps) {
@@ -224,7 +220,7 @@
&& "EXIT block cannot contain Stmts.");
// Process the final state transition.
- GREndPathNodeBuilderImpl Builder(Blk, Pred, this);
+ GREndPathNodeBuilder Builder(Blk, Pred, this);
ProcessEndPath(Builder);
// This path is done. Don't enqueue any more nodes.
@@ -238,7 +234,7 @@
}
void GRCoreEngine::HandleBlockEntrance(const BlockEntrance& L,
- ExplodedNode* Pred) {
+ ExplodedNode* Pred) {
// Increment the block counter.
GRBlockCounter Counter = WList->getBlockCounter();
@@ -247,7 +243,8 @@
// Process the entrance of the block.
if (Stmt* S = L.getFirstStmt()) {
- GRStmtNodeBuilderImpl Builder(L.getBlock(), 0, Pred, this);
+ GRStmtNodeBuilder Builder(L.getBlock(), 0, Pred, this,
+ SubEngine.getStateManager());
ProcessStmt(S, Builder);
}
else
@@ -298,7 +295,7 @@
// Only 1 successor: the indirect goto dispatch block.
assert (B->succ_size() == 1);
- GRIndirectGotoNodeBuilderImpl
+ GRIndirectGotoNodeBuilder
builder(Pred, B, cast<IndirectGotoStmt>(Term)->getTarget(),
*(B->succ_begin()), this);
@@ -322,9 +319,8 @@
}
case Stmt::SwitchStmtClass: {
- GRSwitchNodeBuilderImpl builder(Pred, B,
- cast<SwitchStmt>(Term)->getCond(),
- this);
+ GRSwitchNodeBuilder builder(Pred, B, cast<SwitchStmt>(Term)->getCond(),
+ this);
ProcessSwitch(builder);
return;
@@ -346,8 +342,8 @@
ExplodedNode* Pred) {
assert (B->succ_size() == 2);
- GRBranchNodeBuilderImpl Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
- Pred, this);
+ GRBranchNodeBuilder Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
+ Pred, this);
ProcessBranch(Cond, Term, Builder);
}
@@ -360,7 +356,8 @@
if (StmtIdx == B->size())
HandleBlockExit(B, Pred);
else {
- GRStmtNodeBuilderImpl Builder(B, StmtIdx, Pred, this);
+ GRStmtNodeBuilder Builder(B, StmtIdx, Pred, this,
+ SubEngine.getStateManager());
ProcessStmt((*B)[StmtIdx], Builder);
}
}
@@ -384,19 +381,23 @@
if (IsNew) WList->Enqueue(Node);
}
-GRStmtNodeBuilderImpl::GRStmtNodeBuilderImpl(CFGBlock* b, unsigned idx,
- ExplodedNode* N, GRCoreEngine* e)
- : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N) {
+GRStmtNodeBuilder::GRStmtNodeBuilder(CFGBlock* b, unsigned idx,
+ ExplodedNode* N, GRCoreEngine* e,
+ GRStateManager &mgr)
+ : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N), Mgr(mgr), Auditor(0),
+ PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false),
+ PointKind(ProgramPoint::PostStmtKind), Tag(0) {
Deferred.insert(N);
+ CleanedState = getLastNode()->getState();
}
-GRStmtNodeBuilderImpl::~GRStmtNodeBuilderImpl() {
+GRStmtNodeBuilder::~GRStmtNodeBuilder() {
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
if (!(*I)->isSink())
GenerateAutoTransition(*I);
}
-void GRStmtNodeBuilderImpl::GenerateAutoTransition(ExplodedNode* N) {
+void GRStmtNodeBuilder::GenerateAutoTransition(ExplodedNode* N) {
assert (!N->isSink());
PostStmt Loc(getStmt());
@@ -452,17 +453,17 @@
}
ExplodedNode*
-GRStmtNodeBuilderImpl::generateNodeImpl(const Stmt* S, const GRState* State,
+GRStmtNodeBuilder::generateNodeInternal(const Stmt* S, const GRState* State,
ExplodedNode* Pred,
ProgramPoint::Kind K,
const void *tag) {
return K == ProgramPoint::PreStmtKind
- ? generateNodeImpl(PreStmt(S, tag), State, Pred)
- : generateNodeImpl(GetPostLoc(S, K, tag), State, Pred);
+ ? generateNodeInternal(PreStmt(S, tag), State, Pred)
+ : generateNodeInternal(GetPostLoc(S, K, tag), State, Pred);
}
ExplodedNode*
-GRStmtNodeBuilderImpl::generateNodeImpl(const ProgramPoint &Loc,
+GRStmtNodeBuilder::generateNodeInternal(const ProgramPoint &Loc,
const GRState* State,
ExplodedNode* Pred) {
bool IsNew;
@@ -480,8 +481,8 @@
return NULL;
}
-ExplodedNode* GRBranchNodeBuilderImpl::generateNodeImpl(const GRState* State,
- bool branch) {
+ExplodedNode* GRBranchNodeBuilder::generateNode(const GRState* State,
+ bool branch) {
// If the branch has been marked infeasible we should not generate a node.
if (!isFeasible(branch))
@@ -507,9 +508,9 @@
return NULL;
}
-GRBranchNodeBuilderImpl::~GRBranchNodeBuilderImpl() {
- if (!GeneratedTrue) generateNodeImpl(Pred->State, true);
- if (!GeneratedFalse) generateNodeImpl(Pred->State, false);
+GRBranchNodeBuilder::~GRBranchNodeBuilder() {
+ if (!GeneratedTrue) generateNode(Pred->State, true);
+ if (!GeneratedFalse) generateNode(Pred->State, false);
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
if (!(*I)->isSink()) Eng.WList->Enqueue(*I);
@@ -517,13 +518,11 @@
ExplodedNode*
-GRIndirectGotoNodeBuilderImpl::generateNodeImpl(const Iterator& I,
- const GRState* St,
- bool isSink) {
+GRIndirectGotoNodeBuilder::generateNode(const iterator& I, const GRState* St,
+ bool isSink) {
bool IsNew;
- ExplodedNode* Succ =
- Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
Succ->addPredecessor(Pred);
@@ -542,13 +541,11 @@
ExplodedNode*
-GRSwitchNodeBuilderImpl::generateCaseStmtNodeImpl(const Iterator& I,
- const GRState* St) {
+GRSwitchNodeBuilder::generateCaseStmtNode(const iterator& I, const GRState* St){
bool IsNew;
- ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()),
- St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock()), St, &IsNew);
Succ->addPredecessor(Pred);
if (IsNew) {
@@ -561,8 +558,7 @@
ExplodedNode*
-GRSwitchNodeBuilderImpl::generateDefaultCaseNodeImpl(const GRState* St,
- bool isSink) {
+GRSwitchNodeBuilder::generateDefaultCaseNode(const GRState* St, bool isSink) {
// Get the block for the default case.
assert (Src->succ_rbegin() != Src->succ_rend());
@@ -570,8 +566,7 @@
bool IsNew;
- ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock),
- St, &IsNew);
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock), St, &IsNew);
Succ->addPredecessor(Pred);
if (IsNew) {
@@ -586,20 +581,18 @@
return NULL;
}
-GREndPathNodeBuilderImpl::~GREndPathNodeBuilderImpl() {
+GREndPathNodeBuilder::~GREndPathNodeBuilder() {
// Auto-generate an EOP node if one has not been generated.
- if (!HasGeneratedNode) generateNodeImpl(Pred->State);
+ if (!HasGeneratedNode) generateNode(Pred->State);
}
ExplodedNode*
-GREndPathNodeBuilderImpl::generateNodeImpl(const GRState* State,
- const void *tag,
- ExplodedNode* P) {
+GREndPathNodeBuilder::generateNode(const GRState* State, const void *tag,
+ ExplodedNode* P) {
HasGeneratedNode = true;
bool IsNew;
- ExplodedNode* Node =
- Eng.G->getNode(BlockEntrance(&B, tag), State, &IsNew);
+ ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B, tag), State, &IsNew);
Node->addPredecessor(P ? P : Pred);
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index bf24248..47f77ce 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -82,7 +82,7 @@
AllStmts = F.Concat(A, AllStmts);
}
- virtual bool Audit(NodeTy* N, GRStateManager& VMgr) {
+ virtual bool Audit(ExplodedNode* N, GRStateManager& VMgr) {
// First handle the auditors that accept all statements.
bool isSink = false;
for (Checks::iterator I = AllStmts.begin(), E = AllStmts.end(); I!=E; ++I)
@@ -107,25 +107,26 @@
// Checker worklist routines.
//===----------------------------------------------------------------------===//
-void GRExprEngine::CheckerVisit(Stmt *S, NodeSet &Dst, NodeSet &Src,
- bool isPrevisit) {
+void GRExprEngine::CheckerVisit(Stmt *S, ExplodedNodeSet &Dst,
+ ExplodedNodeSet &Src, bool isPrevisit) {
if (Checkers.empty()) {
Dst = Src;
return;
}
- NodeSet Tmp;
- NodeSet *PrevSet = &Src;
+ ExplodedNodeSet Tmp;
+ ExplodedNodeSet *PrevSet = &Src;
for (std::vector<Checker*>::iterator I = Checkers.begin(), E = Checkers.end();
I != E; ++I) {
- NodeSet *CurrSet = (I+1 == E) ? &Dst : (PrevSet == &Tmp) ? &Src : &Tmp;
+ ExplodedNodeSet *CurrSet = (I+1 == E) ? &Dst
+ : (PrevSet == &Tmp) ? &Src : &Tmp;
CurrSet->clear();
Checker *checker = *I;
- for (NodeSet::iterator NI = PrevSet->begin(), NE = PrevSet->end();
+ for (ExplodedNodeSet::iterator NI = PrevSet->begin(), NE = PrevSet->end();
NI != NE; ++NI)
checker->GR_Visit(*CurrSet, *Builder, *this, S, *NI, isPrevisit);
@@ -231,7 +232,7 @@
// Top-level transfer function logic (Dispatcher).
//===----------------------------------------------------------------------===//
-void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
+void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
@@ -255,7 +256,7 @@
: EntryNode->getState();
// Process any special transfer function for dead symbols.
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (!SymReaper.hasDeadSymbols())
Tmp.Add(EntryNode);
@@ -275,9 +276,9 @@
bool HasAutoGenerated = false;
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
- NodeSet Dst;
+ ExplodedNodeSet Dst;
// Set the cleaned state.
Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I));
@@ -306,7 +307,7 @@
Builder = NULL;
}
-void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
"Error evaluating statement");
@@ -351,7 +352,7 @@
}
if (EagerlyAssume && (B->isRelationalOp() || B->isEqualityOp())) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Tmp);
EvalEagerlyAssume(Dst, Tmp, cast<Expr>(S));
}
@@ -477,7 +478,7 @@
case Stmt::UnaryOperatorClass: {
UnaryOperator *U = cast<UnaryOperator>(S);
if (EagerlyAssume && (U->getOpcode() == UnaryOperator::LNot)) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitUnaryOperator(U, Pred, Tmp, false);
EvalEagerlyAssume(Dst, Tmp, U);
}
@@ -488,7 +489,8 @@
}
}
-void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
Ex = Ex->IgnoreParens();
@@ -574,12 +576,9 @@
// Generic node creation.
//===----------------------------------------------------------------------===//
-GRExprEngine::NodeTy* GRExprEngine::MakeNode(NodeSet& Dst, Stmt* S,
- NodeTy* Pred,
- const GRState* St,
- ProgramPoint::Kind K,
- const void *tag) {
-
+ExplodedNode* GRExprEngine::MakeNode(ExplodedNodeSet& Dst, Stmt* S,
+ ExplodedNode* Pred, const GRState* St,
+ ProgramPoint::Kind K, const void *tag) {
assert (Builder && "GRStmtNodeBuilder not present.");
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->Tag = tag;
@@ -685,7 +684,7 @@
}
void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
- BranchNodeBuilder& builder) {
+ GRBranchNodeBuilder& builder) {
// Remove old bindings for subexpressions.
const GRState* PrevState =
@@ -731,7 +730,7 @@
}
case SVal::UndefinedKind: {
- NodeTy* N = builder.generateNode(PrevState, true);
+ ExplodedNode* N = builder.generateNode(PrevState, true);
if (N) {
N->markAsSink();
@@ -762,7 +761,7 @@
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a computed goto jump.
-void GRExprEngine::ProcessIndirectGoto(IndirectGotoNodeBuilder& builder) {
+void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) {
const GRState *state = builder.getState();
SVal V = state->getSVal(builder.getTarget());
@@ -774,7 +773,7 @@
// (3) We have no clue about the label. Dispatch to all targets.
//
- typedef IndirectGotoNodeBuilder::iterator iterator;
+ typedef GRIndirectGotoNodeBuilder::iterator iterator;
if (isa<loc::GotoLabel>(V)) {
LabelStmt* L = cast<loc::GotoLabel>(V).getLabel();
@@ -792,7 +791,7 @@
if (isa<loc::ConcreteInt>(V) || isa<UndefinedVal>(V)) {
// Dispatch to the first target and mark it as a sink.
- NodeTy* N = builder.generateNode(builder.begin(), state, true);
+ ExplodedNode* N = builder.generateNode(builder.begin(), state, true);
UndefBranches.insert(N);
return;
}
@@ -806,7 +805,7 @@
void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
assert (Ex == CurrentStmt && getCFG().isBlkExpr(Ex));
@@ -825,14 +824,14 @@
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
-void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
- typedef SwitchNodeBuilder::iterator iterator;
+void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
+ typedef GRSwitchNodeBuilder::iterator iterator;
const GRState* state = builder.getState();
Expr* CondE = builder.getCondition();
SVal CondV = state->getSVal(CondE);
if (CondV.isUndef()) {
- NodeTy* N = builder.generateDefaultCaseNode(state, true);
+ ExplodedNode* N = builder.generateDefaultCaseNode(state, true);
UndefBranches.insert(N);
return;
}
@@ -912,8 +911,8 @@
// Transfer functions: logical operations ('&&', '||').
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, NodeTy* Pred,
- NodeSet& Dst) {
+void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
assert(B->getOpcode() == BinaryOperator::LAnd ||
B->getOpcode() == BinaryOperator::LOr);
@@ -967,8 +966,8 @@
// Transfer functions: Loads and stores.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
- bool asLValue) {
+void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
const GRState* state = GetState(Pred);
@@ -1005,12 +1004,13 @@
}
/// VisitArraySubscriptExpr - Transfer function for array accesses
-void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue){
Expr* Base = A->getBase()->IgnoreParens();
Expr* Idx = A->getIdx()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (Base->getType()->isVectorType()) {
// For vector types get its lvalue.
@@ -1022,11 +1022,11 @@
else
Visit(Base, Pred, Tmp); // Get Base's rvalue, which should be an LocVal.
- for (NodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
- NodeSet Tmp2;
+ for (ExplodedNodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
+ ExplodedNodeSet Tmp2;
Visit(Idx, *I1, Tmp2); // Evaluate the index.
- for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2!=E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2=Tmp2.begin(),E2=Tmp2.end();I2!=E2; ++I2) {
const GRState* state = GetState(*I2);
SVal V = state->getLValue(A->getType(), state->getSVal(Base),
state->getSVal(Idx));
@@ -1041,11 +1041,11 @@
}
/// VisitMemberExpr - Transfer function for member expressions.
-void GRExprEngine::VisitMemberExpr(MemberExpr* M, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
Expr* Base = M->getBase()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (M->isArrow())
Visit(Base, Pred, Tmp); // p->f = ... or ... = p->f
@@ -1056,7 +1056,7 @@
if (!Field) // FIXME: skipping member expressions for non-fields
return;
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
const GRState* state = GetState(*I);
// FIXME: Should we insert some assumption logic in here to determine
// if "Base" is a valid piece of memory? Before we put this assumption
@@ -1073,7 +1073,7 @@
/// EvalBind - Handle the semantics of binding a value to a specific location.
/// This method is used by EvalStore and (soon) VisitDeclStmt, and others.
-void GRExprEngine::EvalBind(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val) {
const GRState* newState = 0;
@@ -1105,7 +1105,7 @@
/// @param state The current simulation state
/// @param location The location to store the value
/// @param Val The value to be stored
-void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val,
const void *tag) {
@@ -1128,7 +1128,7 @@
EvalBind(Dst, Ex, Pred, state, location, Val);
}
-void GRExprEngine::EvalLoad(NodeSet& Dst, Expr* Ex, NodeTy* Pred,
+void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location,
const void *tag) {
@@ -1169,28 +1169,27 @@
}
}
-void GRExprEngine::EvalStore(NodeSet& Dst, Expr* Ex, Expr* StoreE, NodeTy* Pred,
- const GRState* state, SVal location, SVal Val,
- const void *tag) {
+void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, Expr* StoreE,
+ ExplodedNode* Pred, const GRState* state,
+ SVal location, SVal Val, const void *tag) {
- NodeSet TmpDst;
+ ExplodedNodeSet TmpDst;
EvalStore(TmpDst, StoreE, Pred, state, location, Val, tag);
- for (NodeSet::iterator I=TmpDst.begin(), E=TmpDst.end(); I!=E; ++I)
+ for (ExplodedNodeSet::iterator I=TmpDst.begin(), E=TmpDst.end(); I!=E; ++I)
MakeNode(Dst, Ex, *I, (*I)->getState(), ProgramPoint::PostStmtKind, tag);
}
-GRExprEngine::NodeTy* GRExprEngine::EvalLocation(Stmt* Ex, NodeTy* Pred,
- const GRState* state,
- SVal location,
- const void *tag) {
+ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
+ const GRState* state, SVal location,
+ const void *tag) {
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->Tag = tag;
// Check for loads/stores from/to undefined values.
if (location.isUndef()) {
- NodeTy* N =
+ ExplodedNode* N =
Builder->generateNode(Ex, state, Pred,
ProgramPoint::PostUndefLocationCheckFailedKind);
@@ -1227,7 +1226,7 @@
// We don't use "MakeNode" here because the node will be a sink
// and we have no intention of processing it later.
- NodeTy* NullNode =
+ ExplodedNode* NullNode =
Builder->generateNode(Ex, StNull, Pred,
ProgramPoint::PostNullCheckFailedKind);
@@ -1261,7 +1260,7 @@
if (StOutBound) {
// Report warning. Make sink node manually.
- NodeTy* OOBNode =
+ ExplodedNode* OOBNode =
Builder->generateNode(Ex, StOutBound, Pred,
ProgramPoint::PostOutOfBoundsCheckFailedKind);
@@ -1300,7 +1299,7 @@
//
static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
@@ -1404,7 +1403,7 @@
static bool EvalOSAtomic(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
- GRStmtNodeBuilder<GRState>& Builder,
+ GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
const FunctionDecl* FD = L.getAsFunctionDecl();
@@ -1426,7 +1425,8 @@
// Transfer function: Function calls.
//===----------------------------------------------------------------------===//
-void GRExprEngine::EvalCall(NodeSet& Dst, CallExpr* CE, SVal L, NodeTy* Pred) {
+void GRExprEngine::EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L,
+ ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
// FIXME: Allow us to chain together transfer functions.
@@ -1436,10 +1436,10 @@
getTF().EvalCall(Dst, *this, *Builder, CE, L, Pred);
}
-void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
+void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- NodeSet& Dst)
+ ExplodedNodeSet& Dst)
{
// Determine the type of function we're calling (if available).
const FunctionProtoType *Proto = NULL;
@@ -1450,10 +1450,11 @@
VisitCallRec(CE, Pred, AI, AE, Dst, Proto, /*ParamIdx=*/0);
}
-void GRExprEngine::VisitCallRec(CallExpr* CE, NodeTy* Pred,
+void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- NodeSet& Dst, const FunctionProtoType *Proto,
+ ExplodedNodeSet& Dst,
+ const FunctionProtoType *Proto,
unsigned ParamIdx) {
// Process the arguments.
@@ -1464,14 +1465,15 @@
if (Proto && ParamIdx < Proto->getNumArgs())
VisitAsLvalue = Proto->getArgType(ParamIdx)->isReferenceType();
- NodeSet DstTmp;
+ ExplodedNodeSet DstTmp;
if (VisitAsLvalue)
VisitLValue(*AI, Pred, DstTmp);
else
Visit(*AI, Pred, DstTmp);
++AI;
- for (NodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE; ++DI)
+ for (ExplodedNodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE;
+ ++DI)
VisitCallRec(CE, *DI, AI, AE, Dst, Proto, ParamIdx + 1);
return;
@@ -1479,11 +1481,11 @@
// If we reach here we have processed all of the arguments. Evaluate
// the callee expression.
- NodeSet DstTmp;
+ ExplodedNodeSet DstTmp;
Expr* Callee = CE->getCallee()->IgnoreParens();
{ // Enter new scope to make the lifetime of 'DstTmp2' bounded.
- NodeSet DstTmp2;
+ ExplodedNodeSet DstTmp2;
Visit(Callee, Pred, DstTmp2);
// Perform the previsit of the CallExpr, storing the results in DstTmp.
@@ -1491,7 +1493,7 @@
}
// Finally, evaluate the function call.
- for (NodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end(); DI!=DE; ++DI) {
+ for (ExplodedNodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end(); DI!=DE; ++DI) {
const GRState* state = GetState(*DI);
SVal L = state->getSVal(Callee);
@@ -1502,7 +1504,7 @@
// Check for undefined control-flow or calls to NULL.
if (L.isUndef() || isa<loc::ConcreteInt>(L)) {
- NodeTy* N = Builder->generateNode(CE, state, *DI);
+ ExplodedNode* N = Builder->generateNode(CE, state, *DI);
if (N) {
N->markAsSink();
@@ -1640,7 +1642,7 @@
I != E; ++I) {
if (GetState(*DI)->getSVal(*I).isUndef()) {
- NodeTy* N = Builder->generateNode(CE, GetState(*DI), *DI);
+ ExplodedNode* N = Builder->generateNode(CE, GetState(*DI), *DI);
if (N) {
N->markAsSink();
@@ -1677,9 +1679,9 @@
static std::pair<const void*,const void*> EagerlyAssumeTag
= std::pair<const void*,const void*>(&EagerlyAssumeTag,0);
-void GRExprEngine::EvalEagerlyAssume(NodeSet &Dst, NodeSet &Src, Expr *Ex) {
- for (NodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
- NodeTy *Pred = *I;
+void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, Expr *Ex) {
+ for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
+ ExplodedNode *Pred = *I;
// Test if the previous node was as the same expression. This can happen
// when the expression fails to evaluate to anything meaningful and
@@ -1719,14 +1721,14 @@
//===----------------------------------------------------------------------===//
void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue) {
Expr* Base = cast<Expr>(Ex->getBase());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Base, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal BaseVal = state->getSVal(Base);
SVal location = state->getLValue(Ex->getDecl(), BaseVal);
@@ -1743,7 +1745,7 @@
//===----------------------------------------------------------------------===//
void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// ObjCForCollectionStmts are processed in two places. This method
// handles the case where an ObjCForCollectionStmt* occurs as one of the
@@ -1781,17 +1783,17 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(cast<Expr>(elem), Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
VisitObjCForCollectionStmtAux(S, *I, Dst, state->getSVal(elem));
}
}
void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
SVal ElementV) {
@@ -1840,8 +1842,8 @@
// Transfer function: Objective-C message expressions.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred,
- NodeSet& Dst){
+void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst){
VisitObjCMessageExprArgHelper(ME, ME->arg_begin(), ME->arg_end(),
Pred, Dst);
@@ -1850,16 +1852,16 @@
void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator AI,
ObjCMessageExpr::arg_iterator AE,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (AI == AE) {
// Process the receiver.
if (Expr* Receiver = ME->getReceiver()) {
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Receiver, Pred, Tmp);
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprDispatchHelper(ME, *NI, Dst);
return;
@@ -1869,18 +1871,18 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*AI, Pred, Tmp);
++AI;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprArgHelper(ME, AI, AE, *NI, Dst);
}
void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
- NodeTy* Pred,
- NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
// FIXME: More logic for the processing the method call.
@@ -1894,7 +1896,7 @@
// Check for undefined control-flow.
if (L.isUndef()) {
- NodeTy* N = Builder->generateNode(ME, state, Pred);
+ ExplodedNode* N = Builder->generateNode(ME, state, Pred);
if (N) {
N->markAsSink();
@@ -1922,7 +1924,7 @@
// this point.
// FIXME: We should bifurcate and fill the returned struct with
// garbage.
- if (NodeTy* N = Builder->generateNode(ME, StNull, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
if (StNotNull)
NilReceiverStructRetImplicit.insert(N);
@@ -1941,7 +1943,7 @@
const uint64_t returnTypeSize = Ctx.getTypeSize(ME->getType());
if(voidPtrSize < returnTypeSize) {
- if (NodeTy* N = Builder->generateNode(ME, StNull, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
if(StNotNull)
NilReceiverLargerThanVoidPtrRetImplicit.insert(N);
@@ -2038,7 +2040,7 @@
// Generate an error node for passing an uninitialized/undefined value
// as an argument to a message expression. This node is a sink.
- NodeTy* N = Builder->generateNode(ME, state, Pred);
+ ExplodedNode* N = Builder->generateNode(ME, state, Pred);
if (N) {
N->markAsSink();
@@ -2075,8 +2077,8 @@
// Transfer functions: Miscellaneous statements.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
- NodeSet S1;
+void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst){
+ ExplodedNodeSet S1;
QualType T = CastE->getType();
QualType ExTy = Ex->getType();
@@ -2090,14 +2092,14 @@
// Check for casting to "void".
if (T->isVoidType()) {
- for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
+ for (ExplodedNodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
Dst.Add(*I1);
return;
}
- for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
- NodeTy* N = *I1;
+ for (ExplodedNodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
+ ExplodedNode* N = *I1;
const GRState* state = GetState(N);
SVal V = state->getSVal(Ex);
const SValuator::CastResult &Res = SVator.EvalCast(V, state, T, ExTy);
@@ -2107,13 +2109,13 @@
}
void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL,
- NodeTy* Pred, NodeSet& Dst,
+ ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue) {
InitListExpr* ILE = cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(ILE, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
const GRState* state = GetState(*I);
SVal ILV = state->getSVal(ILE);
state = state->bindCompoundLiteral(CL, ILV);
@@ -2125,7 +2127,7 @@
}
}
-void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// The CFG has one DeclStmt per Decl.
Decl* D = *DS->decl_begin();
@@ -2138,14 +2140,14 @@
// FIXME: static variables may have an initializer, but the second
// time a function is called those values may not be current.
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
if (InitEx)
Visit(InitEx, Pred, Tmp);
else
Tmp.Add(Pred);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
unsigned Count = Builder->getCurrentBlockCount();
@@ -2158,7 +2160,7 @@
SVal Size = state->getSVal(SE);
if (Size.isUndef()) {
- if (NodeTy* N = Builder->generateNode(DS, state, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(DS, state, Pred)) {
N->markAsSink();
ExplicitBadSizedVLA.insert(N);
}
@@ -2169,7 +2171,7 @@
state = state->assume(Size, true);
if (zeroState) {
- if (NodeTy* N = Builder->generateNode(DS, zeroState, Pred)) {
+ if (ExplodedNode* N = Builder->generateNode(DS, zeroState, Pred)) {
N->markAsSink();
if (state)
ImplicitBadSizedVLA.insert(N);
@@ -2216,18 +2218,18 @@
class VISIBILITY_HIDDEN InitListWLItem {
public:
llvm::ImmutableList<SVal> Vals;
- GRExprEngine::NodeTy* N;
+ ExplodedNode* N;
InitListExpr::reverse_iterator Itr;
- InitListWLItem(GRExprEngine::NodeTy* n, llvm::ImmutableList<SVal> vals,
- InitListExpr::reverse_iterator itr)
+ InitListWLItem(ExplodedNode* n, llvm::ImmutableList<SVal> vals,
+ InitListExpr::reverse_iterator itr)
: Vals(vals), N(n), Itr(itr) {}
};
}
-void GRExprEngine::VisitInitListExpr(InitListExpr* E, NodeTy* Pred,
- NodeSet& Dst) {
+void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
const GRState* state = GetState(Pred);
QualType T = getContext().getCanonicalType(E->getType());
@@ -2257,12 +2259,12 @@
InitListWLItem X = WorkList.back();
WorkList.pop_back();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*X.Itr, X.N, Tmp);
InitListExpr::reverse_iterator NewItr = X.Itr + 1;
- for (NodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
+ for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
// Get the last initializer value.
state = GetState(*NI);
SVal InitV = state->getSVal(cast<Expr>(*X.Itr));
@@ -2291,10 +2293,10 @@
if (Loc::IsLocType(T) || T->isIntegerType()) {
assert (E->getNumInits() == 1);
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Expr* Init = E->getInit(0);
Visit(Init, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I != EI; ++I) {
state = GetState(*I);
MakeNode(Dst, E, *I, state->bindExpr(E, state->getSVal(Init)));
}
@@ -2308,8 +2310,8 @@
/// VisitSizeOfAlignOfExpr - Transfer function for sizeof(type).
void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
- NodeTy* Pred,
- NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
QualType T = Ex->getTypeOfArgument();
uint64_t amt;
@@ -2341,8 +2343,8 @@
}
-void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
- NodeSet& Dst, bool asLValue) {
+void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
+ ExplodedNodeSet& Dst, bool asLValue) {
switch (U->getOpcode()) {
@@ -2352,10 +2354,10 @@
case UnaryOperator::Deref: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal location = state->getSVal(Ex);
@@ -2373,10 +2375,10 @@
case UnaryOperator::Real: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
@@ -2397,10 +2399,10 @@
case UnaryOperator::Imag: {
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
// Just report "Unknown."
@@ -2432,10 +2434,10 @@
// subexpression.
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
MakeNode(Dst, U, *I, state->bindExpr(U, state->getSVal(Ex)));
}
@@ -2447,10 +2449,10 @@
assert(!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal V = state->getSVal(Ex);
state = state->bindExpr(U, V);
@@ -2466,10 +2468,10 @@
assert (!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
- for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
// Get the value of the subexpression.
@@ -2540,20 +2542,20 @@
// Handle ++ and -- (both pre- and post-increment).
assert (U->isIncrementDecrementOp());
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Expr* Ex = U->getSubExpr()->IgnoreParens();
VisitLValue(Ex, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal V1 = state->getSVal(Ex);
// Perform a load.
- NodeSet Tmp2;
+ ExplodedNodeSet Tmp2;
EvalLoad(Tmp2, Ex, *I, state, V1);
- for (NodeSet::iterator I2 = Tmp2.begin(), E2 = Tmp2.end(); I2!=E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2 = Tmp2.begin(), E2 = Tmp2.end(); I2!=E2; ++I2) {
state = GetState(*I2);
SVal V2 = state->getSVal(Ex);
@@ -2614,32 +2616,32 @@
}
}
-void GRExprEngine::VisitAsmStmt(AsmStmt* A, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitAsmStmt(AsmStmt* A, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
VisitAsmStmtHelperOutputs(A, A->begin_outputs(), A->end_outputs(), Pred, Dst);
}
void GRExprEngine::VisitAsmStmtHelperOutputs(AsmStmt* A,
AsmStmt::outputs_iterator I,
AsmStmt::outputs_iterator E,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (I == E) {
VisitAsmStmtHelperInputs(A, A->begin_inputs(), A->end_inputs(), Pred, Dst);
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
VisitLValue(*I, Pred, Tmp);
++I;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitAsmStmtHelperOutputs(A, I, E, *NI, Dst);
}
void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A,
AsmStmt::inputs_iterator I,
AsmStmt::inputs_iterator E,
- NodeTy* Pred, NodeSet& Dst) {
+ ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (I == E) {
// We have processed both the inputs and the outputs. All of the outputs
@@ -2665,16 +2667,16 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(*I, Pred, Tmp);
++I;
- for (NodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
+ for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitAsmStmtHelperInputs(A, I, E, *NI, Dst);
}
-void GRExprEngine::EvalReturn(NodeSet& Dst, ReturnStmt* S, NodeTy* Pred) {
+void GRExprEngine::EvalReturn(ExplodedNodeSet& Dst, ReturnStmt* S, ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
unsigned size = Dst.size();
@@ -2690,7 +2692,7 @@
MakeNode(Dst, S, Pred, GetState(Pred));
}
-void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
+void GRExprEngine::VisitReturnStmt(ReturnStmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
Expr* R = S->getRetValue();
@@ -2699,10 +2701,10 @@
return;
}
- NodeSet Tmp;
+ ExplodedNodeSet Tmp;
Visit(R, Pred, Tmp);
- for (NodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
+ for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
SVal X = (*I)->getState()->getSVal(R);
// Check if we return the address of a stack variable.
@@ -2712,7 +2714,7 @@
if (R && R->hasStackStorage()) {
// Create a special node representing the error.
- if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
+ if (ExplodedNode* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink();
RetsStackAddr.insert(N);
}
@@ -2721,7 +2723,7 @@
}
// Check if we return an undefined value.
else if (X.isUndef()) {
- if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
+ if (ExplodedNode* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink();
RetsUndef.insert(N);
}
@@ -2737,12 +2739,12 @@
//===----------------------------------------------------------------------===//
const GRState* GRExprEngine::CheckDivideZero(Expr* Ex, const GRState* state,
- NodeTy* Pred, SVal Denom) {
+ ExplodedNode* Pred, SVal Denom) {
// Divide by undefined? (potentially zero)
if (Denom.isUndef()) {
- NodeTy* DivUndef = Builder->generateNode(Ex, state, Pred);
+ ExplodedNode* DivUndef = Builder->generateNode(Ex, state, Pred);
if (DivUndef) {
DivUndef->markAsSink();
@@ -2761,7 +2763,7 @@
// Create the node for the divide-by-zero (if it occurred).
if (zeroState)
- if (NodeTy* DivZeroNode = Builder->generateNode(Ex, zeroState, Pred)) {
+ if (ExplodedNode* DivZeroNode = Builder->generateNode(Ex, zeroState, Pred)) {
DivZeroNode->markAsSink();
if (state)
@@ -2775,10 +2777,10 @@
}
void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
- GRExprEngine::NodeTy* Pred,
- GRExprEngine::NodeSet& Dst) {
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst) {
- NodeSet Tmp1;
+ ExplodedNodeSet Tmp1;
Expr* LHS = B->getLHS()->IgnoreParens();
Expr* RHS = B->getRHS()->IgnoreParens();
@@ -2793,18 +2795,18 @@
else
Visit(LHS, Pred, Tmp1);
- for (NodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1 != E1; ++I1) {
+ for (ExplodedNodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1 != E1; ++I1) {
SVal LeftV = (*I1)->getState()->getSVal(LHS);
// Process the RHS.
- NodeSet Tmp2;
+ ExplodedNodeSet Tmp2;
Visit(RHS, *I1, Tmp2);
// With both the LHS and RHS evaluated, process the operation itself.
- for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2 != E2; ++I2) {
+ for (ExplodedNodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2 != E2; ++I2) {
const GRState* state = GetState(*I2);
const GRState* OldSt = state;
@@ -2873,7 +2875,7 @@
// The operands were *not* undefined, but the result is undefined.
// This is a special node that should be flagged as an error.
- if (NodeTy* UndefNode = Builder->generateNode(B, state, *I2)) {
+ if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I2)) {
UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
@@ -2907,11 +2909,11 @@
// Perform a load (the LHS). This performs the checks for
// null dereferences, and so on.
- NodeSet Tmp3;
+ ExplodedNodeSet Tmp3;
SVal location = state->getSVal(LHS);
EvalLoad(Tmp3, LHS, *I2, state, location);
- for (NodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3; ++I3) {
+ for (ExplodedNodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3; ++I3) {
state = GetState(*I3);
SVal V = state->getSVal(LHS);
@@ -2978,7 +2980,7 @@
if (Result.isUndef()) {
// The operands were not undefined, but the result is undefined.
- if (NodeTy* UndefNode = Builder->generateNode(B, state, *I3)) {
+ if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I3)) {
UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
@@ -3061,10 +3063,10 @@
namespace llvm {
template<>
-struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
+struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
public DefaultDOTGraphTraits {
- static std::string getNodeAttributes(const GRExprEngine::NodeTy* N, void*) {
+ static std::string getNodeAttributes(const ExplodedNode* N, void*) {
if (GraphPrintCheckerState->isImplicitNullDeref(N) ||
GraphPrintCheckerState->isExplicitNullDeref(N) ||
@@ -3084,8 +3086,7 @@
return "";
}
- static std::string getNodeLabel(const GRExprEngine::NodeTy* N, void*,
- bool ShortNames) {
+ static std::string getNodeLabel(const ExplodedNode* N, void*,bool ShortNames){
std::string sbuf;
llvm::raw_string_ostream Out(sbuf);
@@ -3234,12 +3235,11 @@
#ifndef NDEBUG
template <typename ITERATOR>
-GRExprEngine::NodeTy* GetGraphNode(ITERATOR I) { return *I; }
+ExplodedNode* GetGraphNode(ITERATOR I) { return *I; }
-template <>
-GRExprEngine::NodeTy*
-GetGraphNode<llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator>
- (llvm::DenseMap<GRExprEngine::NodeTy*, Expr*>::iterator I) {
+template <> ExplodedNode*
+GetGraphNode<llvm::DenseMap<ExplodedNode*, Expr*>::iterator>
+ (llvm::DenseMap<ExplodedNode*, Expr*>::iterator I) {
return I->first;
}
#endif
@@ -3247,7 +3247,7 @@
void GRExprEngine::ViewGraph(bool trim) {
#ifndef NDEBUG
if (trim) {
- std::vector<NodeTy*> Src;
+ std::vector<ExplodedNode*> Src;
// Flush any outstanding reports to make sure we cover all the nodes.
// This does not cause them to get displayed.
@@ -3259,7 +3259,7 @@
for (BugType::const_iterator I2=(*I)->begin(), E2=(*I)->end(); I2!=E2; ++I2) {
const BugReportEquivClass& EQ = *I2;
const BugReport &R = **EQ.begin();
- NodeTy *N = const_cast<NodeTy*>(R.getEndNode());
+ ExplodedNode *N = const_cast<ExplodedNode*>(R.getEndNode());
if (N) Src.push_back(N);
}
}
@@ -3278,12 +3278,12 @@
#endif
}
-void GRExprEngine::ViewGraph(NodeTy** Beg, NodeTy** End) {
+void GRExprEngine::ViewGraph(ExplodedNode** Beg, ExplodedNode** End) {
#ifndef NDEBUG
GraphPrintCheckerState = this;
GraphPrintSourceManager = &getContext().getSourceManager();
- std::auto_ptr<GRExprEngine::GraphTy> TrimmedG(G.Trim(Beg, End).first);
+ std::auto_ptr<ExplodedGraph> TrimmedG(G.Trim(Beg, End).first);
if (!TrimmedG.get())
llvm::cerr << "warning: Trimmed ExplodedGraph is empty.\n";
diff --git a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp
index f07a385..3c316eb 100644
--- a/clang/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/clang/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -491,7 +491,7 @@
// Determine whether this was a 'zero-sized' VLA or a VLA with an
// undefined size.
- GRExprEngine::NodeTy* N = *I;
+ ExplodedNode* N = *I;
PostStmt PS = cast<PostStmt>(N->getLocation());
const DeclStmt *DS = cast<DeclStmt>(PS.getStmt());
VarDecl* VD = cast<VarDecl>(*DS->decl_begin());