Skip to content

Commit fc864e2

Browse files
committed
astutils.cpp: added more bailouts in isMutableExpression() [skip ci]
1 parent 50adc67 commit fc864e2

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include <unordered_map>
4949
#include <utility>
5050

51+
#include <iostream>
52+
5153
const Token* findExpression(const nonneg int exprid,
5254
const Token* start,
5355
const Token* end,
@@ -2479,12 +2481,20 @@ bool isMutableExpression(const Token* tok)
24792481
return false;
24802482
if (tok->isLiteral() || tok->isKeyword() || tok->isStandardType() || tok->isEnumerator())
24812483
return false;
2484+
if (Token::Match(tok, "std :: %name%"))
2485+
return false;
2486+
if (Token::Match(tok->previous(), "std :: %name%"))
2487+
return false;
2488+
if (Token::Match(tok->tokAt(-2), "std :: %name%"))
2489+
return false;
24822490
if (Token::Match(tok, ",|;|:|]|)|}"))
24832491
return false;
24842492
if (Token::simpleMatch(tok, "[ ]"))
24852493
return false;
2486-
if (tok->previous() && tok->previous()->isKeyword() && Token::Match(tok->previous(), "%name% ("))
2494+
if (tok->previous() && tok->previous()->exprId() == 0 && Token::Match(tok->previous(), "%name% (")) {
2495+
//std::cout << tok->strAt(-1) << std::endl;
24872496
return false;
2497+
}
24882498
if (tok->link() && Token::Match(tok, "<|>"))
24892499
return false;
24902500
if (tok->astOperand1() && Token::simpleMatch(tok, "["))
@@ -2920,7 +2930,10 @@ static bool isExpressionChangedAt(const F& getExprTok,
29202930
if (!expr && !(tok->valueType() && tok->valueType()->pointer == 0 && tok->valueType()->reference == Reference::None))
29212931
aliased = true;
29222932
if (!aliased)
2933+
{
2934+
std::cout << tok->str() << " " << tok->exprId() << " " << exprid << " " << indirect << std::endl;
29232935
aliased = isAliasOf(tok, expr, &i);
2936+
}
29242937
if (!aliased)
29252938
return false;
29262939
if (isVariableChanged(tok, indirect + i, settings, depth))

0 commit comments

Comments
 (0)