Refactoring: add Token::isAssignmentOp and use it in CheckClass::checkConstFunc
This commit is contained in:
parent
7d93bfb42e
commit
77aebd357e
|
@ -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")
|
||||
{
|
||||
|
|
17
lib/token.h
17
lib/token.h
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue