Traverse conditions for container size

This commit is contained in:
Paul 2019-10-30 10:19:14 -05:00
parent 210232d35c
commit 914783769f
1 changed files with 6 additions and 0 deletions

View File

@ -5868,7 +5868,11 @@ static void valueFlowContainerForward(Token *tok, nonneg int containerId, ValueF
break;
}
if (Token::simpleMatch(tok, ") {") && Token::Match(tok->link()->previous(), "while|for|if (")) {
const Token * condTok = tok->link()->astOperand2();
const Token *start = tok->next();
ProgramMemory pm = getProgramMemory(tok->link()->previous(), containerId, value);
if (conditionIsTrue(condTok, pm))
valueFlowContainerForward(start->next(), containerId, value, settings, cpp);
if (isContainerSizeChanged(containerId, start, start->link()))
break;
tok = start->link();
@ -5876,6 +5880,8 @@ static void valueFlowContainerForward(Token *tok, nonneg int containerId, ValueF
start = tok->tokAt(2);
if (isContainerSizeChanged(containerId, start, start->link()))
break;
if (conditionIsFalse(condTok, pm))
valueFlowContainerForward(start->next(), containerId, value, settings, cpp);
tok = start->link();
}
}