Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,10 @@ void CmdLineParser::printError(const std::string &message)
printMessage("error: " + message);
}

#if defined(_WIN64) || defined(_WIN32)
bool CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
#endif

// TODO: normalize/simplify/native all path parameters
// TODO: error out on all missing given files/paths
bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
{
#if defined(_WIN64) || defined(_WIN32)
bool default_platform = true;
#endif

bool def = false;
bool maxconfigs = false;

Expand Down Expand Up @@ -632,10 +624,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
return false;
}

#if defined(_WIN64) || defined(_WIN32)
default_platform = false;
#endif

// TODO: remove
// these are loaded via external files and thus have Settings::PlatformFile set instead.
// override the type so they behave like the regular platforms.
Expand Down Expand Up @@ -1057,14 +1045,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
return true;
}

#if defined(_WIN64)
if (SHOW_DEF_PLATFORM_MSG && default_platform && !mSettings.quiet)
printMessage("Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this.");
#elif defined(_WIN32)
if (SHOW_DEF_PLATFORM_MSG && default_platform && !mSettings.quiet)
printMessage("Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this.");
#endif

// Print error only if we have "real" command and expect files
if (!mExitAfterPrint && mPathNames.empty() && mSettings.project.fileSettings.empty()) {
printError("no C or C++ source files found.");
Expand Down
5 changes: 0 additions & 5 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ class CmdLineParser {
return mIgnoredPaths;
}

#if defined(_WIN64) || defined(_WIN32)
// temporary variable to "un-break" tests
static bool SHOW_DEF_PLATFORM_MSG;
#endif

protected:

/**
Expand Down
7 changes: 0 additions & 7 deletions lib/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@

cppcheck::Platform::Platform()
{
// This assumes the code you are checking is for the same architecture this is compiled on.
#if defined(_WIN64)
set(Type::Win64);
#elif defined(_WIN32)
set(Type::Win32A);
#else
set(Type::Native);
#endif
}


Expand Down
2 changes: 1 addition & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Changed interface:
-

Other:
-
- Windows builds now default to the `native` platform instead of `win32A` or `win64`. Please specify it explicitly if you depedent on it.
4 changes: 2 additions & 2 deletions test/cli/test-helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_addon_absolute_path():

def test_addon_relative_path():
prjpath = getRelativeProjectPath()
ret, stdout, stderr = cppcheck(['--platform=native', '--addon=misra', '--enable=style', '--template=cppcheck1', prjpath])
ret, stdout, stderr = cppcheck(['--addon=misra', '--enable=style', '--template=cppcheck1', prjpath])
filename = os.path.join(prjpath, 'main.c')
assert ret == 0, stdout
assert stdout == ('Checking %s ...\n'
Expand All @@ -89,7 +89,7 @@ def test_addon_relative_path():
def test_addon_with_gui_project():
project_file = 'helloworld/test.cppcheck'
create_gui_project_file(project_file, paths=['.'], addon='misra')
ret, stdout, stderr = cppcheck(['--platform=native', '--template=cppcheck1', '--enable=style', '--project=' + project_file])
ret, stdout, stderr = cppcheck(['--template=cppcheck1', '--enable=style', '--project=' + project_file])
filename = os.path.join('helloworld', 'main.c')
assert ret == 0, stdout
assert stdout == 'Checking %s ...\n' % filename
Expand Down
8 changes: 4 additions & 4 deletions test/cli/test-more-projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_project_custom_platform(tmpdir):
with open(os.path.join(tmpdir, '1.c'), 'wt') as f:
f.write("int x;")

ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q'])
ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q'])
assert ret == 0, stdout
assert stdout == ''
assert stderr == ''
Expand All @@ -89,7 +89,7 @@ def test_project_empty_platform(tmpdir):
with open(os.path.join(tmpdir, '1.c'), 'wt') as f:
f.write("int x;")

ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q'])
ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q'])
assert ret == 0, stdout
assert stdout == ''
assert stderr == ''
Expand All @@ -104,7 +104,7 @@ def test_project_unspecified_platform(tmpdir):
with open(os.path.join(tmpdir, '1.c'), 'wt') as f:
f.write("int x;")

ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1', '-q'])
ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1', '-q'])
assert ret == 0, stdout
assert stdout == "cppcheck: 'Unspecified' is a deprecated platform type and will be removed in Cppcheck 2.14. Please use 'unspecified' instead.\n"
assert stderr == ''
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_project_empty_fields(tmpdir):
</coding-standards>
</project>""")

ret, stdout, stderr = cppcheck(['--platform=native', '--project=' + project_file, '--template=cppcheck1'])
ret, stdout, stderr = cppcheck(['--project=' + project_file, '--template=cppcheck1'])
assert ret == 1, stdout # do not crash
assert stdout == 'cppcheck: error: no C or C++ source files found.\n'
assert stderr == ''
Expand Down
8 changes: 4 additions & 4 deletions test/cli/test-other.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_missing_include_inline_suppr(tmpdir):


def test_invalid_library(tmpdir):
args = ['--library=none', '--library=posix', '--library=none2', '--platform=native', 'file.c']
args = ['--library=none', '--library=posix', '--library=none2', 'file.c']

exitcode, stdout, stderr = cppcheck(args)
assert exitcode == 1
Expand All @@ -85,7 +85,7 @@ def test_message_j(tmpdir):
with open(test_file, 'wt') as f:
f.write("")

args = ['-j2', '--platform=native', test_file]
args = ['-j2', test_file]

_, stdout, _ = cppcheck(args)
assert stdout == "Checking {} ...\n".format(test_file) # we were adding stray \0 characters at the end
Expand All @@ -102,7 +102,7 @@ def test_progress(tmpdir):
}
""")

args = ['--report-progress=0', '--enable=all', '--inconclusive', '--platform=native', test_file]
args = ['--report-progress=0', '--enable=all', '--inconclusive', test_file]

exitcode, stdout, stderr = cppcheck(args)
assert exitcode == 0
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_progress_j(tmpdir):
}
""")

args = ['--report-progress=0', '--enable=all', '--inconclusive', '-j2', '--disable=unusedFunction', '--platform=native', test_file]
args = ['--report-progress=0', '--enable=all', '--inconclusive', '-j2', '--disable=unusedFunction', test_file]

exitcode, stdout, stderr = cppcheck(args)
assert exitcode == 0
Expand Down
5 changes: 2 additions & 3 deletions test/fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,8 @@ TestFixture::SettingsBuilder& TestFixture::SettingsBuilder::platform(cppcheck::P
{
const std::string platformStr = cppcheck::Platform::toString(type);

// TODO: the default platform differs between Windows and Linux
//if (REDUNDANT_CHECK && settings.platform.type == type)
// throw std::runtime_error("redundant setting: platform (" + platformStr + ")");
if (REDUNDANT_CHECK && settings.platform.type == type)
throw std::runtime_error("redundant setting: platform (" + platformStr + ")");

std::string errstr;
// TODO: exename is not yet set
Expand Down
49 changes: 1 addition & 48 deletions test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,7 @@
class TestCmdlineParser : public TestFixture {
public:
TestCmdlineParser() : TestFixture("TestCmdlineParser")
{
#if defined(_WIN64) || defined(_WIN32)
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
#endif
}

~TestCmdlineParser() override {
#if defined(_WIN64) || defined(_WIN32)
CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;
#endif
}
{}

private:
std::unique_ptr<Settings> settings;
Expand Down Expand Up @@ -169,10 +159,6 @@ class TestCmdlineParser : public TestFixture {
TEST_CASE(platformUnspecified);
TEST_CASE(platformPlatformFile);
TEST_CASE(platformUnknown);
#if defined(_WIN64) || defined(_WIN32)
TEST_CASE(platformDefault);
TEST_CASE(platformDefault2);
#endif
TEST_CASE(plistEmpty);
TEST_CASE(plistDoesNotExist);
TEST_CASE(suppressionsOld);
Expand Down Expand Up @@ -1237,39 +1223,6 @@ class TestCmdlineParser : public TestFixture {
ASSERT_EQUALS("cppcheck: error: unrecognized platform: 'win128'.\n", GET_REDIRECT_OUTPUT);
}

#if defined(_WIN64) || defined(_WIN32)
void platformDefault() {
REDIRECT;

CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;

const char * const argv[] = {"cppcheck", "file.cpp"};
ASSERT(parser->parseFromArgs(2, argv));
#if defined(_WIN64)
ASSERT_EQUALS(cppcheck::Platform::Type::Win64, settings->platform.type);
ASSERT_EQUALS("cppcheck: Windows 64-bit binaries currently default to the 'win64' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win64' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT);
#elif defined(_WIN32)
ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, settings->platform.type);
ASSERT_EQUALS("cppcheck: Windows 32-bit binaries currently default to the 'win32A' platform. Starting with Cppcheck 2.13 they will default to 'native' instead. Please specify '--platform=win32A' explicitly if you rely on this.\n", GET_REDIRECT_OUTPUT);
#endif

CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
}

void platformDefault2() {
REDIRECT;

CmdLineParser::SHOW_DEF_PLATFORM_MSG = true;

const char * const argv[] = {"cppcheck", "--platform=unix64", "file.cpp"};
ASSERT(parser->parseFromArgs(3, argv));
ASSERT_EQUALS(cppcheck::Platform::Type::Unix64, settings->platform.type);
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);

CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
}
#endif

void plistEmpty() {
REDIRECT;
const char * const argv[] = {"cppcheck", "--plist-output=", "file.cpp"};
Expand Down
4 changes: 2 additions & 2 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class TestCondition : public TestFixture {
TestCondition() : TestFixture("TestCondition") {}

private:
const Settings settings0 = settingsBuilder().library("qt.cfg").library("std.cfg").severity(Severity::style).severity(Severity::warning).platform(cppcheck::Platform::Type::Native).build();
Settings settings1 = settingsBuilder().severity(Severity::style).severity(Severity::warning).platform(cppcheck::Platform::Type::Native).build();
const Settings settings0 = settingsBuilder().library("qt.cfg").library("std.cfg").severity(Severity::style).severity(Severity::warning).build();
Settings settings1 = settingsBuilder().severity(Severity::style).severity(Severity::warning).build();

void run() override {
const char cfg[] = "<?xml version=\"1.0\"?>\n"
Expand Down
8 changes: 1 addition & 7 deletions test/testplatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,9 @@ class TestPlatform : public TestFixture {
ASSERT(!readPlatform(platform, xmldata));
}

void default_platform() {
void default_platform() const {
cppcheck::Platform platform;
#if defined(_WIN64)
ASSERT_EQUALS(cppcheck::Platform::Type::Win64, platform.type);
#elif defined(_WIN32)
ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, platform.type);
#else
ASSERT_EQUALS(cppcheck::Platform::Type::Native, platform.type);
#endif
}
};

Expand Down