summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-10 18:08:10 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-10 18:08:10 +0300
commit6259def98c7241f25233613298e87a1abab9e853 (patch)
tree851f55a405a9dbe9eb76288ba62d24c5002e323e /src
parent2c66820bd689662170447158ef5a8cf66f760e0d (diff)
downloadparanucker-6259def98c7241f25233613298e87a1abab9e853.tar.gz
paranucker-6259def98c7241f25233613298e87a1abab9e853.tar.bz2
paranucker-6259def98c7241f25233613298e87a1abab9e853.tar.xz
paranucker-6259def98c7241f25233613298e87a1abab9e853.zip
Add analysis for CONTINUE_STMT node.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/analysis.cpp7
-rw-r--r--src/analysis/statement.cpp16
-rw-r--r--src/analysis/statement.h5
-rw-r--r--src/analysis/walkitem.h3
-rw-r--r--src/logger.cpp2
5 files changed, 29 insertions, 4 deletions
diff --git a/src/analysis/analysis.cpp b/src/analysis/analysis.cpp
index 70905e6..e35de85 100644
--- a/src/analysis/analysis.cpp
+++ b/src/analysis/analysis.cpp
@@ -55,6 +55,7 @@
#include "nodes/ref/component_ref.h"
+#include "nodes/stmt/continue_stmt.h"
#include "nodes/stmt/if_stmt.h"
#include "nodes/stmt/while_stmt.h"
@@ -98,6 +99,7 @@ void walkTree(Node *node, const WalkItem &wi, WalkItem &wo)
removeNeedCheckNullVarsSet(wi2, wi2.removeNullVars);
const bool isReturned = wo.isReturned;
+ const bool isContinued = wo.isContinued;
WalkItem wo2 = wo;
if (command != Command::DumpNullPointers)
@@ -117,6 +119,7 @@ void walkTree(Node *node, const WalkItem &wi, WalkItem &wo)
wi2.knownNullVars = wo2.knownNullVars;
wi2.knownNonNullVars = wo2.knownNonNullVars;
wi2.isReturned = wi2.isReturned || wo2.isReturned;
+ wi2.isContinued = wi2.isContinued || wo2.isContinued;
wi2.linkedVars = wo2.linkedVars;
wi2.linkedReverseVars = wo2.linkedReverseVars;
wo2.stopWalking = false;
@@ -126,6 +129,7 @@ void walkTree(Node *node, const WalkItem &wi, WalkItem &wo)
wo.removeNullVars = wi2.removeNullVars;
wo.addNullVars = wi2.addNullVars;
wo.isReturned = wo.isReturned || isReturned || wo2.isReturned;
+ wo.isContinued = wo.isContinued || isContinued || wo2.isContinued;
wo.linkedVars = wi2.linkedVars;
wo.linkedReverseVars = wi2.linkedReverseVars;
wo.knownVars = wo2.knownVars;
@@ -280,6 +284,9 @@ void analyseNode(Node *node, const WalkItem &wi, WalkItem &wo)
case WHILE_STMT:
analyseWhileStmt(static_cast<WhileStmtNode*>(node), wi2, wo);
break;
+ case CONTINUE_STMT:
+ analyseContinueStmt(static_cast<ContinueStmtNode*>(node), wi2, wo);
+ break;
case COMPONENT_REF:
analyseComponentRef(static_cast<ComponentRefNode*>(node), wi2, wo);
break;
diff --git a/src/analysis/statement.cpp b/src/analysis/statement.cpp
index d3a066f..5f1f95b 100644
--- a/src/analysis/statement.cpp
+++ b/src/analysis/statement.cpp
@@ -34,6 +34,7 @@
#include "nodes/ref/indirect_ref.h"
+#include "nodes/stmt/continue_stmt.h"
#include "nodes/stmt/if_stmt.h"
#include "nodes/stmt/while_stmt.h"
@@ -108,7 +109,7 @@ void analyseCondition(Node *node,
// need check for cleanExpr?
intersectElseNonNullChecked(wo, wo2, wo3);
- if (wo2.isReturned)
+ if (wo2.isReturned || wo2.isContinued)
{
// add variable for ignore for all parent nodes except special like IF_STMT
FOR_EACH (it, wco.checkedElseNonNullVars)
@@ -126,7 +127,7 @@ void analyseCondition(Node *node,
{
addNeedCheckNullVars2(wo2, wo);
}
- if (wo3.isReturned)
+ if (wo3.isReturned || wo3.isContinued)
{
// add variable for ignore for all parent nodes except special like IF_STMT
FOR_EACH (it, wco.checkedThenNonNullVars)
@@ -144,7 +145,7 @@ void analyseCondition(Node *node,
{
addNeedCheckNullVars2(wo3, wo);
}
- if (wo2.isReturned && wo3.isReturned)
+ if ((wo2.isReturned || wo2.isContinued) && (wo3.isReturned || wo3.isContinued))
{
// add variable for ignore for all parent nodes except special like IF_STMT
FOR_EACH (it, wo.knownVars)
@@ -156,6 +157,7 @@ void analyseCondition(Node *node,
}
wo.isReturned = false;
+ wo.isContinued = false;
wo.cleanExpr = true;
wo.stopWalking = true;
wo.uselessExpr = false;
@@ -213,7 +215,7 @@ void analyseWhileStmt(WhileStmtNode *node, const WalkItem &wi, WalkItem &wo)
if (wo2.cleanExpr)
mergeElseNullChecked(wo, wo2);
- if (wo2.isReturned)
+ if (wo2.isReturned || wo2.isContinued)
{
// add variable for ignore for all parent nodes except special like IF_STMT
FOR_EACH (it, wco.checkedElseNonNullVars)
@@ -243,9 +245,15 @@ void analyseWhileStmt(WhileStmtNode *node, const WalkItem &wi, WalkItem &wo)
}
wo.isReturned = false;
+ wo.isContinued = false;
wo.cleanExpr = true;
wo.stopWalking = true;
wo.uselessExpr = false;
}
+void analyseContinueStmt(ContinueStmtNode *node, const WalkItem &wi, WalkItem &wo)
+{
+ wo.isContinued = true;
+}
+
}
diff --git a/src/analysis/statement.h b/src/analysis/statement.h
index ab15a7a..5637da7 100644
--- a/src/analysis/statement.h
+++ b/src/analysis/statement.h
@@ -22,6 +22,7 @@
#include "includes.h"
+struct ContinueStmtNode;
struct IfStmtNode;
struct Node;
struct WalkItem;
@@ -43,6 +44,10 @@ namespace Analysis
void analyseWhileStmt(WhileStmtNode *node,
const WalkItem &wi,
WalkItem &wo);
+
+ void analyseContinueStmt(ContinueStmtNode *node,
+ const WalkItem &wi,
+ WalkItem &wo);
}
#endif // ANALYSIS_STATEMENT_H
diff --git a/src/analysis/walkitem.h b/src/analysis/walkitem.h
index 829a73e..aa5d579 100644
--- a/src/analysis/walkitem.h
+++ b/src/analysis/walkitem.h
@@ -46,6 +46,7 @@ struct WalkItem
linkedReverseVars(),
stopWalking(false),
isReturned(false),
+ isContinued(false),
cleanExpr(false),
uselessExpr(true)
{
@@ -67,6 +68,7 @@ struct WalkItem
linkedReverseVars(item.linkedReverseVars),
stopWalking(item.stopWalking),
isReturned(item.isReturned),
+ isContinued(item.isContinued),
cleanExpr(item.cleanExpr),
uselessExpr(item.uselessExpr)
{
@@ -87,6 +89,7 @@ struct WalkItem
StringMap linkedReverseVars; // linked vars. map <child, parent>
bool stopWalking; // stop walking on tree after this node
bool isReturned; // set if return present in child nodes
+ bool isContinued; // set if continue present in child nodes
bool cleanExpr; // set if expression is only variable check without compound conditions
bool uselessExpr; // set if some part of expression is unknown and not checking parameters
};
diff --git a/src/logger.cpp b/src/logger.cpp
index addbff7..51a32b1 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -219,6 +219,8 @@ void dumpWI(Node *const node,
Log::log(" useless");
if (wi.isReturned)
Log::log(" returned");
+ if (wi.isContinued)
+ Log::log(" continued");
dumpWIProps(" checkedThenNullVars:", wi.checkedThenNullVars)
dumpWIProps(" checkedThenNonNullVars:", wi.checkedThenNonNullVars)
dumpWIProps(" checkedElseNullVars:", wi.checkedElseNullVars)