[cfe-commits] r126332 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h lib/StaticAnalyzer/Checkers/ExprEngine.cpp lib/StaticAnalyzer/Checkers/MallocChecker.cpp lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp lib/StaticAnalyzer/Checkers/StreamChecker.cpp lib/StaticAnalyzer/Core/CoreEngine.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Feb 23 13:04:49 PST 2011
Author: akirtzidis
Date: Wed Feb 23 15:04:49 2011
New Revision: 126332
URL: http://llvm.org/viewvc/llvm-project?rev=126332&view=rev
Log:
[analyzer] Refactor EndOfFunctionNodeBuilder.
-Introduce EndOfFunctionNodeBuilder::withCheckerTag to allow it be "specialized" with a
checker tag and not require the checkers to pass a tag.
-For EndOfFunctionNodeBuilder::generateNode, reverse the order of tag/P parameters since
there are actual calls that assume the second parameter is ExplodedNode.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.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=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h Wed Feb 23 15:04:49 2011
@@ -447,16 +447,22 @@
CoreEngine &Eng;
const CFGBlock& B;
ExplodedNode* Pred;
+ void *Tag;
public:
bool hasGeneratedNode;
public:
- EndOfFunctionNodeBuilder(const CFGBlock* b, ExplodedNode* N, CoreEngine* e)
- : Eng(*e), B(*b), Pred(N), hasGeneratedNode(false) {}
+ EndOfFunctionNodeBuilder(const CFGBlock* b, ExplodedNode* N, CoreEngine* e,
+ void *checkerTag = 0)
+ : Eng(*e), B(*b), Pred(N), Tag(checkerTag), hasGeneratedNode(false) {}
~EndOfFunctionNodeBuilder();
+ EndOfFunctionNodeBuilder withCheckerTag(void *tag) {
+ return EndOfFunctionNodeBuilder(&B, Pred, &Eng, tag);
+ }
+
WorkList &getWorkList() { return *Eng.WList; }
ExplodedNode* getPredecessor() const { return Pred; }
@@ -471,8 +477,8 @@
B.getBlockID());
}
- ExplodedNode* generateNode(const GRState* State, const void *tag = 0,
- ExplodedNode *P = 0);
+ ExplodedNode* generateNode(const GRState* State, ExplodedNode *P = 0,
+ const void *tag = 0);
void GenerateCallExitNode(const GRState *state);
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Wed Feb 23 15:04:49 2011
@@ -1440,7 +1440,8 @@
for (CheckersOrdered::iterator I=Checkers.begin(),E=Checkers.end(); I!=E;++I){
void *tag = I->first;
Checker *checker = I->second;
- checker->evalEndPath(builder, tag, *this);
+ EndOfFunctionNodeBuilder B = builder.withCheckerTag(tag);
+ checker->evalEndPath(B, tag, *this);
}
}
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Wed Feb 23 15:04:49 2011
@@ -599,7 +599,7 @@
for (RegionStateTy::iterator I = M.begin(), E = M.end(); I != E; ++I) {
RefState RS = I->second;
if (RS.isAllocated()) {
- ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
+ ExplodedNode *N = B.generateNode(state);
if (N) {
if (!BT_Leak)
BT_Leak = new BuiltinBug("Memory leak",
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp?rev=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp Wed Feb 23 15:04:49 2011
@@ -180,7 +180,7 @@
return;
// Generate an error node.
- ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
+ ExplodedNode *N = B.generateNode(state);
if (!N)
return;
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp?rev=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp Wed Feb 23 15:04:49 2011
@@ -435,7 +435,7 @@
for (SymMap::iterator I = M.begin(), E = M.end(); I != E; ++I) {
StreamState SS = I->second;
if (SS.isOpened()) {
- ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
+ ExplodedNode *N = B.generateNode(state);
if (N) {
if (!BT_ResourceLeak)
BT_ResourceLeak = new BuiltinBug("Resource Leak",
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=126332&r1=126331&r2=126332&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Wed Feb 23 15:04:49 2011
@@ -718,13 +718,14 @@
}
ExplodedNode*
-EndOfFunctionNodeBuilder::generateNode(const GRState* State, const void *tag,
- ExplodedNode* P) {
+EndOfFunctionNodeBuilder::generateNode(const GRState* State,
+ ExplodedNode* P, const void *tag) {
hasGeneratedNode = true;
bool IsNew;
ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B,
- Pred->getLocationContext(), tag), State, &IsNew);
+ Pred->getLocationContext(), tag ? tag : Tag),
+ State, &IsNew);
Node->addPredecessor(P ? P : Pred, *Eng.G);
More information about the cfe-commits
mailing list