[cfe-commits] r142830 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/ExprEngineC.cpp
Anna Zaks
ganna at apple.com
Mon Oct 24 11:26:12 PDT 2011
Author: zaks
Date: Mon Oct 24 13:26:12 2011
New Revision: 142830
URL: http://llvm.org/viewvc/llvm-project?rev=142830&view=rev
Log:
[analyzer] Convert VisitDeclStmt to use local node builder.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
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=142830&r1=142829&r2=142830&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Mon Oct 24 13:26:12 2011
@@ -283,6 +283,24 @@
C.ContextPred->getLocationContext()->getCurrentStackFrame(),
C.Block->getBlockID());
}
+
+ void takeNodes(const ExplodedNodeSet &S) {
+ for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I )
+ Frontier.erase(*I);
+ }
+
+ void takeNodes(ExplodedNode *N) {
+ Frontier.erase(N);
+ }
+
+ void addNodes(const ExplodedNodeSet &S) {
+ Frontier.insert(S);
+ }
+
+ void addNodes(ExplodedNode *N) {
+ Frontier.Add(N);
+ }
+
};
class CommonNodeBuilder {
@@ -403,23 +421,6 @@
BuildSinks = Tmp;
return N;
}
-
- void takeNodes(const ExplodedNodeSet &S) {
- for (ExplodedNodeSet::iterator I = S.begin(), E = S.end(); I != E; ++I )
- Frontier.erase(*I);
- }
-
- void takeNodes(ExplodedNode *N) {
- Frontier.erase(N);
- }
-
- void addNodes(const ExplodedNodeSet &S) {
- Frontier.insert(S);
- }
-
- void addNodes(ExplodedNode *N) {
- Frontier.Add(N);
- }
};
class BranchNodeBuilder: public NodeBuilder {
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=142830&r1=142829&r2=142830&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Oct 24 13:26:12 2011
@@ -1297,7 +1297,7 @@
getCheckerManager().runCheckersForBind(CheckedSet, Pred, location, Val,
StoreE, *this);
- // TODO: Remove TmpDst after NB refactoring is done.
+ // TODO:AZ Remove TmpDst after NB refactoring is done.
ExplodedNodeSet TmpDst;
Builder->takeNodes(CheckedSet);
PureStmtNodeBuilder Bldr(CheckedSet, TmpDst, *currentBuilderContext);
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=142830&r1=142829&r2=142830&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Mon Oct 24 13:26:12 2011
@@ -302,6 +302,9 @@
void ExprEngine::VisitCompoundLiteralExpr(const CompoundLiteralExpr *CL,
ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
+ PureStmtNodeBuilder B(Pred, Dst, *currentBuilderContext);
+ Builder->takeNodes(Pred);
+
const InitListExpr *ILE
= cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
@@ -311,9 +314,10 @@
state = state->bindCompoundLiteral(CL, LC, ILV);
if (CL->isLValue())
- MakeNode(Dst, CL, Pred, state->BindExpr(CL, state->getLValue(CL, LC)));
+ B.generateNode(CL, Pred, state->BindExpr(CL, state->getLValue(CL, LC)));
else
- MakeNode(Dst, CL, Pred, state->BindExpr(CL, ILV));
+ B.generateNode(CL, Pred, state->BindExpr(CL, ILV));
+ Builder->addNodes(Dst);
}
void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
@@ -333,8 +337,9 @@
ExplodedNodeSet dstPreVisit;
getCheckerManager().runCheckersForPreStmt(dstPreVisit, Pred, DS, *this);
+ PureStmtNodeBuilder B(dstPreVisit, Dst, *currentBuilderContext);
+ Builder->takeNodes(dstPreVisit);
const VarDecl *VD = dyn_cast<VarDecl>(D);
-
for (ExplodedNodeSet::iterator I = dstPreVisit.begin(), E = dstPreVisit.end();
I!=E; ++I) {
ExplodedNode *N = *I;
@@ -362,13 +367,15 @@
InitVal = svalBuilder.getConjuredSymbolVal(NULL, InitEx,
Builder->getCurrentBlockCount());
}
-
+ B.takeNodes(N);
evalBind(Dst, DS, N, state->getLValue(VD, LC), InitVal, true);
+ B.addNodes(Dst);
}
else {
- MakeNode(Dst, DS, N, state->bindDeclWithNoInit(state->getRegion(VD, LC)));
+ B.generateNode(DS, N,state->bindDeclWithNoInit(state->getRegion(VD, LC)));
}
}
+ Builder->addNodes(Dst);
}
void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
More information about the cfe-commits
mailing list