Refactoring: add Token::isAssignmentOp and use it in CheckClass::checkConstFunc

This commit is contained in:
Robert Reif 2011-04-09 14:36:05 -04:00
parent 7d93bfb42e
commit 77aebd357e
2 changed files with 18 additions and 3 deletions

View File

@ -1491,9 +1491,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
}
// assignment.. = += |= ..
else if (tok1->str() == "=" ||
(tok1->str().find("=") == 1 &&
tok1->str().find_first_of("<!>") == std::string::npos))
else if (tok1->isAssignmentOp())
{
if (tok1->next()->str() == "this")
{

View File

@ -178,6 +178,23 @@ public:
return isOp() ||
(this && _str.size() == 1 && _str.find_first_of(",[]()?:") != std::string::npos);
}
bool isAssignmentOp() const
{
if (!this)
return false;
return (_str == "=" ||
_str == "+=" ||
_str == "-=" ||
_str == "*=" ||
_str == "/=" ||
_str == "%=" ||
_str == "&=" ||
_str == "^=" ||
_str == "|=" ||
_str == "<<=" ||
_str == ">>=");
}
bool isBoolean() const
{
return _isBoolean;