diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a4a2f4ac6..ede9698fd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9350,18 +9350,15 @@ void Tokenizer::simplifyMathExpressions() tok->str("0"); } - //Pythagorean trigonometric identity: pow(sin(x),2n)+pow(cos(x),2n) = 1 - //Hyperbolic identity: pow(sinh(x),2n)-pow(cosh(x),2n) = -1 - //2n = any even number + //Pythagorean trigonometric identity: pow(sin(x),2)+pow(cos(x),2) = 1 + //Hyperbolic identity: pow(sinh(x),2)-pow(cosh(x),2) = -1 if (Token::simpleMatch(tok, "pow (")) { if (Token::simpleMatch(tok->tokAt(2), "sin (")) { Token *tok2 = tok->linkAt(3); - if (!Token::Match(tok2, ") , %num% ) + pow ( cos (") || - (MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1) + if (!Token::simpleMatch(tok2, ") , 2 ) + pow ( cos (")) continue; Token *tok3 = tok2->tokAt(8); - if (!Token::Match(tok3->link(), ") , %num% )") || - tok3->link()->strAt(2) != tok2->strAt(2)) + if (!Token::simpleMatch(tok3->link(), ") , 2 )")) continue; if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { Token::eraseTokens(tok, tok3->link()->tokAt(4)); @@ -9369,12 +9366,10 @@ void Tokenizer::simplifyMathExpressions() } } else if (Token::simpleMatch(tok->tokAt(2), "sinh (")) { Token *tok2 = tok->linkAt(3); - if (!Token::Match(tok2, ") , %num% ) - pow ( cosh (") || - (MathLib::toLongNumber(tok2->strAt(2)) & 1) == 1) + if (!Token::simpleMatch(tok2, ") , 2 ) - pow ( cosh (") ) continue; Token *tok3 = tok2->tokAt(8); - if (!Token::Match(tok3->link(), ") , %num% )") || - tok3->link()->strAt(2) != tok2->strAt(2)) + if (!Token::simpleMatch(tok3->link(), ") , 2 )")) continue; if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { Token::eraseTokens(tok, tok3->link()->tokAt(4)); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 62887076c..9fd3a67af 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7727,8 +7727,6 @@ private: " std::cout<