summaryrefslogtreecommitdiff
path: root/src/analysis/statement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/statement.cpp')
-rw-r--r--src/analysis/statement.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/analysis/statement.cpp b/src/analysis/statement.cpp
index 0f9f2eb..f405c2c 100644
--- a/src/analysis/statement.cpp
+++ b/src/analysis/statement.cpp
@@ -150,7 +150,7 @@ void analyseCondition(Node *node,
removeKnownNullVars2(wo3, wo);
}
if ((wo2.isReturned || wo2.isContinued) && (wo3.isReturned || wo3.isContinued))
- {
+ { // all branches returned or breaked
// add variable for ignore for all parent nodes except special like IF_STMT
FOR_EACH (it, wo.knownVars)
{
@@ -159,6 +159,18 @@ void analyseCondition(Node *node,
wo.knownNonNullVars.erase(it);
}
}
+ else if (thenNode && elseNode)
+ { // non branches returned or breaked
+ FOR_EACH (it, wo2.knownNonNullVars)
+ {
+ if (isIn(it, wo3.knownNonNullVars) &&
+ isNotIn(it, wo.knownNonNullVars))
+ { // check if var in both branches known as non null
+ removeNeedCheckNullVarOnly(wo, it);
+ addNonNullVar(wo, it);
+ }
+ }
+ }
wo.isReturned = false;
wo.isContinued = false;