From 9b14ab15eb8eaf069525600dcd04876fef9fde65 Mon Sep 17 00:00:00 2001 From: Martin Ettl Date: Tue, 16 Jun 2015 19:12:18 +0200 Subject: [PATCH] MathLib::intsuffix: Added support for LLU and LU suffixes. --- lib/mathlib.cpp | 6 ++++-- lib/tokenize.cpp | 6 +++--- test/testmathlib.cpp | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/mathlib.cpp b/lib/mathlib.cpp index 69541d44b..834fb7c64 100644 --- a/lib/mathlib.cpp +++ b/lib/mathlib.cpp @@ -547,11 +547,13 @@ static std::string intsuffix(const std::string & first, const std::string & seco suffix2 = c + suffix2; } - if (suffix1 == "ULL" || suffix2 == "ULL") + if (suffix1 == "ULL" || suffix2 == "ULL" + || suffix1 == "LLU" || suffix2 == "LLU") return "ULL"; if (suffix1 == "LL" || suffix2 == "LL") return "LL"; - if (suffix1 == "UL" || suffix2 == "UL") + if (suffix1 == "UL" || suffix2 == "UL" + || suffix1 == "LU" || suffix2 == "LU") return "UL"; if (suffix1 == "L" || suffix2 == "L") return "L"; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 99f6b7f40..ae3fe503d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2036,7 +2036,7 @@ void Tokenizer::simplifySQL() void Tokenizer::simplifyDebugNew() { - if (isC()) + if (isC()) return; if (!_settings->isWindowsPlatform()) return; @@ -9694,7 +9694,7 @@ void Tokenizer::simplifyNamespaceStd() // Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()' void Tokenizer::simplifyMicrosoftMFC() { - if (isC()) + if (isC()) return; // skip if not Windows if (!_settings->isWindowsPlatform()) @@ -9890,7 +9890,7 @@ void Tokenizer::simplifyBorland() // Remove Qt signals and slots void Tokenizer::simplifyQtSignalsSlots() { - if (isC()) + if (isC()) return; for (Token *tok = list.front(); tok; tok = tok->next()) { // check for emit which can be outside of class diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index 7fa7603be..b09f81132 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -189,6 +189,13 @@ private: ASSERT_EQUALS("2LL", MathLib::add("1LL", "1UL")); ASSERT_EQUALS("2ULL", MathLib::add("1ULL", "1UL")); + ASSERT_EQUALS("2UL", MathLib::add("1", "1LU")); + ASSERT_EQUALS("2UL", MathLib::add("1U", "1LU")); + ASSERT_EQUALS("2UL", MathLib::add("1L", "1LU")); + ASSERT_EQUALS("2UL", MathLib::add("1UL", "1LU")); + ASSERT_EQUALS("2LL", MathLib::add("1LL", "1LU")); + ASSERT_EQUALS("2ULL", MathLib::add("1ULL", "1LU")); + ASSERT_EQUALS("2LL", MathLib::add("1", "1LL")); ASSERT_EQUALS("2LL", MathLib::add("1U", "1LL")); ASSERT_EQUALS("2LL", MathLib::add("1L", "1LL")); @@ -202,6 +209,13 @@ private: ASSERT_EQUALS("2ULL", MathLib::add("1UL", "1ULL")); ASSERT_EQUALS("2ULL", MathLib::add("1LL", "1ULL")); ASSERT_EQUALS("2ULL", MathLib::add("1ULL", "1ULL")); + + ASSERT_EQUALS("2ULL", MathLib::add("1", "1LLU")); + ASSERT_EQUALS("2ULL", MathLib::add("1U", "1LLU")); + ASSERT_EQUALS("2ULL", MathLib::add("1L", "1LLU")); + ASSERT_EQUALS("2ULL", MathLib::add("1UL", "1LLU")); + ASSERT_EQUALS("2ULL", MathLib::add("1LL", "1LLU")); + ASSERT_EQUALS("2ULL", MathLib::add("1ULL", "1LLU")); } void convert() const {