From 61e47208eb5535166617e73c5f17130b26d9eea0 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 9 Aug 2017 11:58:27 +0200 Subject: [PATCH] Removed hard coded avr8 platform and moved it into a platform file (avr8.xml). --- cli/cmdlineparser.cpp | 2 -- lib/platform.cpp | 21 ----------------- lib/platform.h | 3 --- platforms/avr8.xml | 18 +++++++++++++++ test/testtype.cpp | 53 ------------------------------------------- 5 files changed, 18 insertions(+), 79 deletions(-) create mode 100644 platforms/avr8.xml diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index b9f19bc20..c74f22b73 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -703,8 +703,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) _settings->platform(Settings::Unix32); else if (platform == "unix64") _settings->platform(Settings::Unix64); - else if (platform == "avr8") - _settings->platform(Settings::AVR8); else if (platform == "native") _settings->platform(Settings::Native); else if (platform == "unspecified") diff --git a/lib/platform.cpp b/lib/platform.cpp index 3221f1f2a..14af7bd6b 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -146,28 +146,7 @@ bool cppcheck::Platform::platform(cppcheck::Platform::PlatformType type) long_bit = char_bit * sizeof_long; long_long_bit = char_bit * sizeof_long_long; return true; - case AVR8: - platformType = type; - sizeof_bool = 1; - sizeof_short = 2; - sizeof_int = 2; - sizeof_long = 4; - sizeof_long_long = 8; - sizeof_float = 4; - sizeof_double = 4; - sizeof_long_double = 4; - sizeof_wchar_t = 2; - sizeof_size_t = 2; - sizeof_pointer = 2; - defaultSign = '\0'; - char_bit = 8; - short_bit = char_bit * sizeof_short; - int_bit = char_bit * sizeof_int; - long_bit = char_bit * sizeof_long; - long_long_bit = char_bit * sizeof_long_long; - return true; } - // unsupported platform return false; } diff --git a/lib/platform.h b/lib/platform.h index ec5768f20..2824d1b7e 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -87,7 +87,6 @@ namespace cppcheck { Win64, Unix32, Unix64, - AVR8, PlatformFile }; @@ -126,8 +125,6 @@ namespace cppcheck { return "unix32"; case Unix64: return "unix64"; - case AVR8: - return "avr8"; case PlatformFile: return "platformFile"; default: diff --git a/platforms/avr8.xml b/platforms/avr8.xml new file mode 100644 index 000000000..73eac30f6 --- /dev/null +++ b/platforms/avr8.xml @@ -0,0 +1,18 @@ + + + 8 + unsigned + + 1 + 2 + 2 + 4 + 8 + 4 + 4 + 4 + 2 + 2 + 2 + + diff --git a/test/testtype.cpp b/test/testtype.cpp index e33c6f069..da0535c8a 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -34,7 +34,6 @@ private: void run() { TEST_CASE(checkTooBigShift_Unix32); - TEST_CASE(checkTooBigShift_AVR8); TEST_CASE(checkIntegerOverflow); TEST_CASE(signConversion); TEST_CASE(longCastAssign); @@ -62,58 +61,6 @@ private: checkType.runChecks(&tokenizer, settings, this); } - void checkTooBigShift_AVR8() { - Settings settings; - settings.platform(Settings::AVR8); - - // int, short and size_t on AVR is 2 bytes long - { - check("int foo(int x) { return x << 17;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 17 bits is undefined behaviour\n", errout.str()); - check("int foo(int x) { return x << 16;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 16 bits is undefined behaviour\n", errout.str()); - check("int foo(int x) { return x << 15;}",&settings); - ASSERT_EQUALS("", errout.str()); - check("short foo(int x) { return x << 17;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 17 bits is undefined behaviour\n", errout.str()); - check("short foo(int x) { return x << 16;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 16 bits is undefined behaviour\n", errout.str()); - check("short foo(int x) { return x << 15;}",&settings); - ASSERT_EQUALS("", errout.str()); - check("size_t foo(int x) { return x << 17;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 17 bits is undefined behaviour\n", errout.str()); - check("size_t foo(int x) { return x << 16;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 16 bits is undefined behaviour\n", errout.str()); - check("size_t foo(int x) { return x << 15;}",&settings); - ASSERT_EQUALS("", errout.str()); - } - // long has four 4 bytes long - { - // downcast to int - check("long foo(long x) { return (int)x << 33;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 33 bits is undefined behaviour\n", errout.str()); - check("long foo(long x) { return x << 33;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 33 bits is undefined behaviour\n", errout.str()); - check("long foo(long x) { return x << 32;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n", errout.str()); - check("long foo(long x) { return x << 31;}",&settings); - } - // long long is 8 bytes long - { - // downcast to int - check("long long foo(long long x) { return (int)x << 65;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 16-bit value by 65 bits is undefined behaviour\n", errout.str()); - // downcast to long - check("long long foo(long long x) { return (long)x << 65;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 32-bit value by 65 bits is undefined behaviour\n", errout.str()); - check("long long foo(long long x) { return x << 65;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 64-bit value by 65 bits is undefined behaviour\n", errout.str()); - check("long long foo(long long x) { return x << 64;}",&settings); - ASSERT_EQUALS("[test.cpp:1]: (error) Shifting 64-bit value by 64 bits is undefined behaviour\n", errout.str()); - check("long long foo(long long x) { return x << 63;}",&settings); - } - } - void checkTooBigShift_Unix32() { Settings settings; settings.platform(Settings::Unix32);