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);
|
||||
}
|
||||
// Critical return
|
||||
else if (Token::Match(tok, "return & %var% ;") && isAutoVar(tok->tokAt(2))) {
|
||||
else if (Token::Match(tok, "return & %var% ;")) {
|
||||
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% [") &&
|
||||
Token::simpleMatch(tok->linkAt(3), "] ;") &&
|
||||
isAutoVarArray(tok->tokAt(2))) {
|
||||
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
|
||||
else if ((Token::Match(tok, "%name% ( %var% ) ;") && _settings->library.dealloc(tok)) ||
|
||||
|
|
Loading…
Reference in New Issue