зеркало из https://github.com/microsoft/clang-1.git
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126332 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
ecc4d33619
Коммит
f178ac8b68
|
@ -447,16 +447,22 @@ class EndOfFunctionNodeBuilder {
|
|||
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 @@ public:
|
|||
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);
|
||||
|
||||
|
|
|
@ -1440,7 +1440,8 @@ void ExprEngine::processEndOfFunction(EndOfFunctionNodeBuilder& builder) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ void MallocChecker::evalEndPath(EndOfFunctionNodeBuilder &B, void *tag,
|
|||
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",
|
||||
|
|
|
@ -180,7 +180,7 @@ void StackAddrLeakChecker::evalEndPath(EndOfFunctionNodeBuilder &B, void *tag,
|
|||
return;
|
||||
|
||||
// Generate an error node.
|
||||
ExplodedNode *N = B.generateNode(state, tag, B.getPredecessor());
|
||||
ExplodedNode *N = B.generateNode(state);
|
||||
if (!N)
|
||||
return;
|
||||
|
||||
|
|
|
@ -435,7 +435,7 @@ void StreamChecker::evalEndPath(EndOfFunctionNodeBuilder &B, void *tag,
|
|||
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",
|
||||
|
|
|
@ -718,13 +718,14 @@ EndOfFunctionNodeBuilder::~EndOfFunctionNodeBuilder() {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче