From f87a4011949a180f4985064c9e68fc5a6e05b8ac Mon Sep 17 00:00:00 2001 From: chrchr Date: Mon, 18 Sep 2023 15:19:22 +0200 Subject: [PATCH 01/11] Check Type::Native in isWindows() --- lib/platform.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/platform.h b/lib/platform.h index 6d9833240d2..2eb165a4187 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -139,7 +139,11 @@ namespace cppcheck { bool isWindows() const { return type == Type::Win32A || type == Type::Win32W || - type == Type::Win64; + type == Type::Win64 +#ifdef _WIN32 + || type == Type::Native +#endif + ; } const char *toString() const { From 5d41d5d71e13f57c55bce5b473f4b8aff6af2416 Mon Sep 17 00:00:00 2001 From: chrchr Date: Mon, 18 Sep 2023 15:50:57 +0200 Subject: [PATCH 02/11] Format --- lib/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/platform.h b/lib/platform.h index 2eb165a4187..d3da41cdaec 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -143,7 +143,7 @@ namespace cppcheck { #ifdef _WIN32 || type == Type::Native #endif - ; + ; } const char *toString() const { From 4e005c44ae56fc81f37db717b7331f1fa01007a4 Mon Sep 17 00:00:00 2001 From: chrchr Date: Mon, 18 Sep 2023 16:37:04 +0200 Subject: [PATCH 03/11] Add test --- test/testplatform.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testplatform.cpp b/test/testplatform.cpp index 7dbb24789b6..3a37a32c09b 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -34,6 +34,7 @@ class TestPlatform : public TestFixture { TEST_CASE(valid_config_win32w); TEST_CASE(valid_config_unix32); TEST_CASE(valid_config_win64); + TEST_CASE(valid_config_native); TEST_CASE(valid_config_file_1); TEST_CASE(valid_config_file_2); TEST_CASE(valid_config_file_3); @@ -181,6 +182,16 @@ class TestPlatform : public TestFixture { ASSERT_EQUALS(64, platform.long_long_bit); } + void valid_config_native() const { + cppcheck::Platform platform; + PLATFORM(platform, cppcheck::Platform::Type::Native); +#ifdef _WIN32 + ASSERT(platform.isWindows()); +#else + ASSERT(!platform.isWindows()); +#endif + } + void valid_config_file_1() const { // Valid platform configuration with all possible values specified. // Similar to the avr8 platform file. From 2d456059e41e6e211a3c8790fb2e17ccc4ae4c19 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Tue, 19 Sep 2023 00:01:03 +0200 Subject: [PATCH 04/11] Add another test --- test/testsimplifytokens.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 1e633a0f0b2..de6a3e30894 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -42,6 +42,7 @@ class TestSimplifyTokens : public TestFixture { void run() override { TEST_CASE(combine_strings); TEST_CASE(combine_wstrings); + TEST_CASE(combine_wstrings_Windows); TEST_CASE(combine_ustrings); TEST_CASE(combine_Ustrings); TEST_CASE(combine_u8strings); @@ -270,6 +271,14 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } + void combine_wstrings_Windows() { + const char code[] = "const auto* f() {\n" + " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" + "}"; + + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, cppcheck::Platform::Type::Native)); + } + void combine_ustrings() { const char code[] = "abcd = u\"ab\" u\"cd\";"; From a37a5808202167a88c6a97c7b4e5a819423132b8 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Tue, 19 Sep 2023 00:11:10 +0200 Subject: [PATCH 05/11] Restrict --- test/testsimplifytokens.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index de6a3e30894..ace04a8bdc1 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -272,11 +272,13 @@ class TestSimplifyTokens : public TestFixture { } void combine_wstrings_Windows() { +#if defined(_WIN32) && defined(UNICODE) const char code[] = "const auto* f() {\n" " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" "}"; ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, cppcheck::Platform::Type::Native)); +#endif } void combine_ustrings() { From 2f97117992f1e2fa3b07dd22c1b171dcca4b6139 Mon Sep 17 00:00:00 2001 From: chrchr Date: Tue, 19 Sep 2023 10:09:04 +0200 Subject: [PATCH 06/11] Format --- test/testsimplifytokens.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index ace04a8bdc1..90a1bff8710 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -273,9 +273,9 @@ class TestSimplifyTokens : public TestFixture { void combine_wstrings_Windows() { #if defined(_WIN32) && defined(UNICODE) - const char code[] = "const auto* f() {\n" - " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" - "}"; + const char code[] = "const auto* f() {\n" + " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" + "}"; ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, cppcheck::Platform::Type::Native)); #endif From cf9921d938208e100e964c635fcfaf3cb2106861 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:39:10 +0100 Subject: [PATCH 07/11] Update testplatform.cpp --- test/testplatform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testplatform.cpp b/test/testplatform.cpp index 29c2054f79a..0b844b2589f 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -207,7 +207,7 @@ class TestPlatform : public TestFixture { } void valid_config_native() const { - cppcheck::Platform platform; + Platform platform; PLATFORM(platform, cppcheck::Platform::Type::Native); #ifdef _WIN32 ASSERT(platform.isWindows()); From f8390f1a9430e69ade66ac8c0a78bedea7387b69 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:54:44 +0100 Subject: [PATCH 08/11] Update testplatform.cpp --- test/testplatform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testplatform.cpp b/test/testplatform.cpp index 0b844b2589f..ce3457e9dfc 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -208,7 +208,7 @@ class TestPlatform : public TestFixture { void valid_config_native() const { Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Native); + PLATFORM(platform, Platform::Type::Native); #ifdef _WIN32 ASSERT(platform.isWindows()); #else From 858169aa55577b7129cc849751f88b8af23ff666 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:53:46 +0100 Subject: [PATCH 09/11] Update testsimplifytokens.cpp --- test/testsimplifytokens.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index a953e82e25f..ba02bb90d58 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -256,8 +256,7 @@ class TestSimplifyTokens : public TestFixture { const char code[] = "const auto* f() {\n" " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" "}"; - - ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, cppcheck::Platform::Type::Native)); + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, Platform::Type::Native)); #endif } From 7114a349b7ac858f7354c56555969801cbec768c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:12:10 +0100 Subject: [PATCH 10/11] Update testsimplifytokens.cpp --- test/testsimplifytokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index ba02bb90d58..0d5328a3b22 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -256,7 +256,7 @@ class TestSimplifyTokens : public TestFixture { const char code[] = "const auto* f() {\n" " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" "}"; - ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, Platform::Type::Native)); + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, dinit(TokOptions, $.type = Platform::Type::Native)); #endif } From 60f7361303e24101b13d59d38e2e9e89e40be539 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 12 Jan 2026 12:40:50 +0100 Subject: [PATCH 11/11] Update testsimplifytokens.cpp --- test/testsimplifytokens.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 0d5328a3b22..5d5de26837c 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -256,7 +256,7 @@ class TestSimplifyTokens : public TestFixture { const char code[] = "const auto* f() {\n" " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" "}"; - ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, dinit(TokOptions, $.type = Platform::Type::Native)); + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, dinit(TokOptions, $.type = Platform::Type::Native))); #endif }