Merge pull request #439 from Dmitry-Me/moveDeclarationMergePatterns

Merge overlapping patterns, move declarations
This commit is contained in:
PKEuS 2014-09-17 18:28:33 +02:00
commit 5dd51f961d
2 changed files with 5 additions and 6 deletions

View File

@ -1232,9 +1232,7 @@ void CheckUnusedVar::checkStructMemberUsage()
if (Token::Match(tok->next(), "%type% %var% [;[]"))
varname = tok->strAt(2);
else if (Token::Match(tok->next(), "%type% %type% %var% [;[]"))
varname = tok->strAt(3);
else if (Token::Match(tok->next(), "%type% * %var% [;[]"))
else if (Token::Match(tok->next(), "%type% %type%|* %var% [;[]"))
varname = tok->strAt(3);
else if (Token::Match(tok->next(), "%type% %type% * %var% [;[]"))
varname = tok->strAt(4);

View File

@ -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 rightInt = MathLib::toLongNumber(right->str());
const bool rightIntIsPositive = rightInt >= 0;
const bool leftIntIsPositive = leftInt >= 0;
const bool leftOperationIsNotLeftShift = left->previous()->str() != "<<";
const bool operandIsLeftShift = right->previous()->str() == "<<";
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
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.
return left->str() + " << " + right->str();
}