Reverted 'simplify NOT' since there are problems related to signedness of numeric values.

This commit is contained in:
Daniel Marjamäki 2013-04-24 06:32:34 +02:00
parent e1dd14626c
commit c3d1274db3
4 changed files with 0 additions and 18 deletions

View File

@ -339,11 +339,6 @@ std::string MathLib::calculate(const std::string &first, const std::string &seco
} }
} }
std::string MathLib::bitwiseNot(const std::string &number)
{
return MathLib::longToString(~MathLib::toLongNumber(number));
}
std::string MathLib::sin(const std::string &tok) std::string MathLib::sin(const std::string &tok)
{ {
return doubleToString(std::sin(toDoubleNumber(tok))); return doubleToString(std::sin(toDoubleNumber(tok)));

View File

@ -50,7 +50,6 @@ public:
static std::string multiply(const std::string & first, const std::string & second); static std::string multiply(const std::string & first, const std::string & second);
static std::string divide(const std::string & first, const std::string & second); static std::string divide(const std::string & first, const std::string & second);
static std::string mod(const std::string & first, const std::string & second); static std::string mod(const std::string & first, const std::string & second);
static std::string bitwiseNot(const std::string &number);
static std::string calculate(const std::string & first, const std::string & second, char action); static std::string calculate(const std::string & first, const std::string & second, char action);
static std::string sin(const std::string & tok); static std::string sin(const std::string & tok);

View File

@ -1001,12 +1001,6 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
tok->str() == MathLib::multiply(tok->strAt(2), MathLib::divide(tok->str(), tok->strAt(2)))) { tok->str() == MathLib::multiply(tok->strAt(2), MathLib::divide(tok->str(), tok->strAt(2)))) {
tok->deleteNext(2); tok->deleteNext(2);
} }
// simplify bitwise not operations, e.g: ~0 --> -1
else if (Token::Match(tok, "~ %num%")) {
const std::string result = MathLib::bitwiseNot(tok->strAt(1));
tok->str(result);
tok->deleteNext();
}
else { else {
ret |= simplifyNumericCalculations(tok); ret |= simplifyNumericCalculations(tok);

View File

@ -41,7 +41,6 @@ private:
TEST_CASE(isNotEqual) TEST_CASE(isNotEqual)
TEST_CASE(isLess) TEST_CASE(isLess)
TEST_CASE(isLessEqual) TEST_CASE(isLessEqual)
TEST_CASE(bitwiseNot)
} }
void isGreater() const { void isGreater() const {
@ -344,11 +343,6 @@ private:
ASSERT_EQUALS(true , MathLib::isFloat("1.0E-1")); ASSERT_EQUALS(true , MathLib::isFloat("1.0E-1"));
ASSERT_EQUALS(true , MathLib::isFloat("-1.0E+1")); ASSERT_EQUALS(true , MathLib::isFloat("-1.0E+1"));
} }
void bitwiseNot() const {
ASSERT_EQUALS("-1" , MathLib::bitwiseNot("0"));
ASSERT_EQUALS("-8" , MathLib::bitwiseNot("7"));
}
}; };
REGISTER_TEST(TestMathLib) REGISTER_TEST(TestMathLib)