Merge pull request #652 from Dmitry-Me/mergeIdenticalMAtches
Merge identical matches
This commit is contained in:
commit
6b4a0a5ed7
|
@ -196,16 +196,19 @@ void CheckAutoVariables::autoVariables()
|
||||||
errorAutoVariableAssignment(tok->next(), false);
|
errorAutoVariableAssignment(tok->next(), false);
|
||||||
}
|
}
|
||||||
// Critical return
|
// Critical return
|
||||||
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2))) {
|
else if (Token::Match(tok, "return & %var% ;")) {
|
||||||
errorReturnAddressToAutoVariable(tok);
|
const Token* varTok = tok->tokAt(2);
|
||||||
|
if (isAutoVar(varTok))
|
||||||
|
errorReturnAddressToAutoVariable(tok);
|
||||||
|
else if (varTok->varId()) {
|
||||||
|
const Variable * var1 = varTok->variable();
|
||||||
|
if (var1 && var1->isArgument() && var1->typeEndToken()->str() != "&")
|
||||||
|
errorReturnAddressOfFunctionParameter(tok, varTok->str());
|
||||||
|
}
|
||||||
} else if (Token::Match(tok, "return & %var% [") &&
|
} else if (Token::Match(tok, "return & %var% [") &&
|
||||||
Token::simpleMatch(tok->linkAt(3), "] ;") &&
|
Token::simpleMatch(tok->linkAt(3), "] ;") &&
|
||||||
isAutoVarArray(tok->tokAt(2))) {
|
isAutoVarArray(tok->tokAt(2))) {
|
||||||
errorReturnAddressToAutoVariable(tok);
|
errorReturnAddressToAutoVariable(tok);
|
||||||
} else if (Token::Match(tok, "return & %var% ;") && tok->tokAt(2)->varId()) {
|
|
||||||
const Variable * var1 = tok->tokAt(2)->variable();
|
|
||||||
if (var1 && var1->isArgument() && var1->typeEndToken()->str() != "&")
|
|
||||||
errorReturnAddressOfFunctionParameter(tok, tok->strAt(2));
|
|
||||||
}
|
}
|
||||||
// Invalid pointer deallocation
|
// Invalid pointer deallocation
|
||||||
else if ((Token::Match(tok, "%name% ( %var% ) ;") && _settings->library.dealloc(tok)) ||
|
else if ((Token::Match(tok, "%name% ( %var% ) ;") && _settings->library.dealloc(tok)) ||
|
||||||
|
|
Loading…
Reference in New Issue