From cafddcb1091b7ca4a44843b4760f73123cd2df12 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sun, 14 Sep 2014 13:35:55 +0200 Subject: [PATCH] Fixed wrong function log10 being recommended instead of log1p --- lib/checkother.cpp | 2 +- test/testother.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 92e2fba3a..3a7ab9b37 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1897,7 +1897,7 @@ void CheckOther::checkMathFunctions() } else if (Token::simpleMatch(tok, "log (") && tok->next()->astOperand2()) { const Token* plus = tok->next()->astOperand2(); if (plus->str() == "+" && ((plus->astOperand1() && Tokenizer::isOneNumber(plus->astOperand1()->str())) || (plus->astOperand2() && Tokenizer::isOneNumber(plus->astOperand2()->str())))) - mathfunctionCallWarning(tok, "log(1 + x)", "log10(x)"); + mathfunctionCallWarning(tok, "log(1 + x)", "log1p(x)"); } } } diff --git a/test/testother.cpp b/test/testother.cpp index fa6b7f319..e66ad08b1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1717,7 +1717,7 @@ private: " print(1 - erf(x));\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (style) Expression 'exp(x) - 1' can be replaced by 'expm1(x)' to avoid loss of precision.\n" - "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log10(x)' to avoid loss of precision.\n" + "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log1p(x)' to avoid loss of precision.\n" "[test.cpp:4]: (style) Expression '1 - erf(x)' can be replaced by 'erfc(x)' to avoid loss of precision.\n", errout.str()); check("void foo() {\n" @@ -1726,7 +1726,7 @@ private: " print(1.0 - erf(x));\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (style) Expression 'exp(x) - 1' can be replaced by 'expm1(x)' to avoid loss of precision.\n" - "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log10(x)' to avoid loss of precision.\n" + "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log1p(x)' to avoid loss of precision.\n" "[test.cpp:4]: (style) Expression '1 - erf(x)' can be replaced by 'erfc(x)' to avoid loss of precision.\n", errout.str()); check("void foo() {\n" @@ -1735,7 +1735,7 @@ private: " print(1 - erf(34*x + f(x) - c));\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (style) Expression 'exp(x) - 1' can be replaced by 'expm1(x)' to avoid loss of precision.\n" - "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log10(x)' to avoid loss of precision.\n" + "[test.cpp:3]: (style) Expression 'log(1 + x)' can be replaced by 'log1p(x)' to avoid loss of precision.\n" "[test.cpp:4]: (style) Expression '1 - erf(x)' can be replaced by 'erfc(x)' to avoid loss of precision.\n", errout.str()); check("void foo() {\n"