Refactor isVLAIndex

This commit is contained in:
Daniel Marjamäki 2018-11-23 20:23:20 +01:00
parent 8f164d9602
commit 2214ef5359
1 changed files with 13 additions and 21 deletions

View File

@ -1081,15 +1081,10 @@ void CheckBufferOverrun::checkScope_inner(const Token *tok, const ArrayInfo &arr
// Negative size in array declarations
//---------------------------------------------------------------------------
static bool isVLAIndex(const Token *index)
static bool isVLAIndex(const Token *tok)
{
std::stack<const Token *> tokens;
tokens.push(index);
while (!tokens.empty()) {
const Token *tok = tokens.top();
tokens.pop();
if (!tok)
continue;
return false;
if (tok->varId() != 0U)
return true;
if (tok->str() == "?") {
@ -1099,12 +1094,9 @@ static bool isVLAIndex(const Token *index)
isVLAIndex(tok->astOperand2()->astOperand1()) &&
isVLAIndex(tok->astOperand2()->astOperand2()))
return true;
continue;
}
tokens.push(tok->astOperand1());
tokens.push(tok->astOperand2());
}
return false;
}
return isVLAIndex(tok->astOperand1()) || isVLAIndex(tok->astOperand2());
}
void CheckBufferOverrun::negativeArraySize()