Merge pull request #439 from Dmitry-Me/moveDeclarationMergePatterns
Merge overlapping patterns, move declarations
This commit is contained in:
commit
5dd51f961d
|
@ -1232,9 +1232,7 @@ void CheckUnusedVar::checkStructMemberUsage()
|
||||||
|
|
||||||
if (Token::Match(tok->next(), "%type% %var% [;[]"))
|
if (Token::Match(tok->next(), "%type% %var% [;[]"))
|
||||||
varname = tok->strAt(2);
|
varname = tok->strAt(2);
|
||||||
else if (Token::Match(tok->next(), "%type% %type% %var% [;[]"))
|
else if (Token::Match(tok->next(), "%type% %type%|* %var% [;[]"))
|
||||||
varname = tok->strAt(3);
|
|
||||||
else if (Token::Match(tok->next(), "%type% * %var% [;[]"))
|
|
||||||
varname = tok->strAt(3);
|
varname = tok->strAt(3);
|
||||||
else if (Token::Match(tok->next(), "%type% %type% * %var% [;[]"))
|
else if (Token::Match(tok->next(), "%type% %type% * %var% [;[]"))
|
||||||
varname = tok->strAt(4);
|
varname = tok->strAt(4);
|
||||||
|
|
|
@ -862,13 +862,14 @@ static std::string ShiftInt(const char cop, const Token* left, const Token* righ
|
||||||
const MathLib::bigint leftInt = MathLib::toLongNumber(left->str());
|
const MathLib::bigint leftInt = MathLib::toLongNumber(left->str());
|
||||||
const MathLib::bigint rightInt = MathLib::toLongNumber(right->str());
|
const MathLib::bigint rightInt = MathLib::toLongNumber(right->str());
|
||||||
const bool rightIntIsPositive = rightInt >= 0;
|
const bool rightIntIsPositive = rightInt >= 0;
|
||||||
const bool leftIntIsPositive = leftInt >= 0;
|
|
||||||
const bool leftOperationIsNotLeftShift = left->previous()->str() != "<<";
|
|
||||||
const bool operandIsLeftShift = right->previous()->str() == "<<";
|
|
||||||
|
|
||||||
if (cop == '<') {
|
if (cop == '<') {
|
||||||
|
const bool leftOperationIsNotLeftShift = left->previous()->str() != "<<";
|
||||||
|
const bool operandIsLeftShift = right->previous()->str() == "<<";
|
||||||
|
|
||||||
// Ensure that its not a shift operator as used for streams
|
// Ensure that its not a shift operator as used for streams
|
||||||
if (leftOperationIsNotLeftShift && operandIsLeftShift && rightIntIsPositive) {
|
if (leftOperationIsNotLeftShift && operandIsLeftShift && rightIntIsPositive) {
|
||||||
|
const bool leftIntIsPositive = leftInt >= 0;
|
||||||
if (!leftIntIsPositive) { // In case the left integer is negative, e.g. -1000 << 16. Do not simplify.
|
if (!leftIntIsPositive) { // In case the left integer is negative, e.g. -1000 << 16. Do not simplify.
|
||||||
return left->str() + " << " + right->str();
|
return left->str() + " << " + right->str();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue