Update isLikelyStreamRead (#8494)

This commit is contained in:
Daniel Marjamäki 2018-04-17 20:34:31 +02:00
parent 7825eb8670
commit 219176c11c
1 changed files with 10 additions and 14 deletions

View File

@ -631,20 +631,16 @@ bool isLikelyStreamRead(bool cpp, const Token *op)
if (!cpp)
return false;
if (Token::Match(op, ">> %name% >>|;")) {
const Token *parent = op;
while (Token::simpleMatch(parent->astParent(), ">>"))
parent = parent->astParent();
if (parent->astParent())
return false;
if (!parent->astOperand1() || !parent->astOperand2())
return false;
return (!parent->astOperand1()->valueType() || !parent->astOperand1()->valueType()->isIntegral());
}
if (!Token::Match(op, "& %name% ;|&") && !Token::Match(op, ">> %name% ;|>>"))
return false;
if (Token::Match(op, "& %name% ;") && !op->astParent() && op->astOperand1() && op->astOperand2() && (!op->astOperand1()->valueType() || !op->astOperand1()->valueType()->isIntegral()))
return true;
return false;
const Token *parent = op;
while (parent->astParent() && parent->astParent()->str() == op->str())
parent = parent->astParent();
if (parent->astParent())
return false;
if (!parent->astOperand1() || !parent->astOperand2())
return false;
return (!parent->astOperand1()->valueType() || !parent->astOperand1()->valueType()->isIntegral());
}