From 219176c11c422827f2022d67e82f9f1edb853168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 17 Apr 2018 20:34:31 +0200 Subject: [PATCH] Update isLikelyStreamRead (#8494) --- lib/astutils.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index d77fd5094..84431b9f9 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -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()); }