Cache and reuse value

This commit is contained in:
Dmitry-Me 2017-09-04 23:33:52 +03:00
parent aece2254d7
commit 5885988b1f
1 changed files with 5 additions and 4 deletions

View File

@ -1245,11 +1245,12 @@ void CheckClass::operatorEq()
}
if (!returnSelfRef) {
// make sure we really have a copy assignment operator
if (Token::Match(func->tokenDef->tokAt(2), "const| %name% &")) {
if (func->tokenDef->strAt(2) == "const" &&
func->tokenDef->strAt(3) == scope->className)
const Token *paramTok = func->tokenDef->tokAt(2);
if (Token::Match(paramTok, "const| %name% &")) {
if (paramTok->str() == "const" &&
paramTok->strAt(1) == scope->className)
operatorEqReturnError(func->retDef, scope->className);
else if (func->tokenDef->strAt(2) == scope->className)
else if (paramTok->str() == scope->className)
operatorEqReturnError(func->retDef, scope->className);
}
}