From e63719f446f15897a7aa29e0242f121b8df50555 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 11 Jun 2015 18:58:58 +0300 Subject: Allow give from childs to parents variables what cant be checked. This need for case like this: if (!a) { ... return; } *a = 10; --- src/analysis/analysis.cpp | 12 +++++++++++- src/analysis/statement.cpp | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/analysis/analysis.cpp b/src/analysis/analysis.cpp index eb69f4d..011fbf1 100644 --- a/src/analysis/analysis.cpp +++ b/src/analysis/analysis.cpp @@ -55,6 +55,14 @@ void walkTree(Node *node, const WalkItem &wi, WalkItem &wo) return; WalkItem wi2 = wi; + FOR_EACH (std::set::const_iterator, it, wi2.removeNullVars) + { + // found var for deletion + if (wi2.checkNullVars.find(*it) != wi2.checkNullVars.end()) + { + wi2.checkNullVars.erase(*it); + } + } analyseNode(node, wi2, wo); if (wo.stopWalking) @@ -66,10 +74,11 @@ void walkTree(Node *node, const WalkItem &wi, WalkItem &wo) WalkItem wo2 = wo; FOR_EACH (std::vector::iterator, it, node->childs) { - wi2 = wi; walkTree(*it, wi2, wo2); + wi2.removeNullVars = wo2.removeNullVars; wo2.stopWalking = false; } + wo.removeNullVars = wi2.removeNullVars; } int findBackLocation(Node *node) @@ -103,6 +112,7 @@ void analyseNode(Node *node, const WalkItem &wi, WalkItem &wo) } wo = wi; + // searching function declaration switch (node->nodeType) { diff --git a/src/analysis/statement.cpp b/src/analysis/statement.cpp index 0a1be70..a585adb 100644 --- a/src/analysis/statement.cpp +++ b/src/analysis/statement.cpp @@ -73,7 +73,7 @@ void analyseIfStmt(IfStmtNode *node, const WalkItem &wi, WalkItem &wo) walkTree(node->elseNode, wi2, wo); wo.stopWalking = true; - Log::log("add removeNullVars: %s\n", node1->label.c_str()); + //Log::log("add removeNullVars: %s\n", node1->label.c_str()); // add variable for ignore for all parent nodes except special like IF_STMT wo.removeNullVars.insert(node1->label); wo.checkNullVars.erase(node1->label); -- cgit v1.2.3-60-g2f50