Skip to content

Commit b18d860

Browse files
Merge branch 'main' into chr_14305
2 parents 602e2a7 + 2d0326d commit b18d860

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1834
-1020
lines changed

.github/workflows/CI-unixish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,15 @@ jobs:
571571
warnings="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar"
572572
g++ $warnings -c -Ilib -Iexternals/tinyxml2 democlient/democlient.cpp
573573
574+
- name: Test disabled executors
575+
if: matrix.os == 'ubuntu-22.04'
576+
run: |
577+
g++ -Ilib -c cli/threadexecutor.cpp -DDISALLOW_THREAD_EXECUTOR
578+
test -z "$(nm threadexecutor.o)"
579+
g++ -Ilib -c cli/processexecutor.cpp -DDISALLOW_PROCESS_EXECUTOR
580+
test -z "$(nm processexecutor.o)"
581+
# TODO: test NO_* defines
582+
574583
- name: Show all ignored files
575584
if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched
576585
run: |

.github/workflows/selfcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
122122
- name: Self check (unusedFunction / no test / no gui)
123123
run: |
124-
supprs="--suppress=unusedFunction:lib/errorlogger.h:193 --suppress=unusedFunction:lib/importproject.cpp:1508 --suppress=unusedFunction:lib/importproject.cpp:1532"
124+
supprs="--suppress=unusedFunction:lib/errorlogger.h:193 --suppress=unusedFunction:lib/importproject.cpp:1516 --suppress=unusedFunction:lib/importproject.cpp:1540"
125125
./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib -D__CPPCHECK__ -D__GNUC__ --enable=unusedFunction,information --exception-handling -rp=. --project=cmake.output.notest_nogui/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr $supprs
126126
env:
127127
DISABLE_VALUEFLOW: 1

cli/cli.vcxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<BufferSecurityCheck>true</BufferSecurityCheck>
9090
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
9191
<Optimization>Disabled</Optimization>
92-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
92+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9393
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
9494
<WarningLevel>Level4</WarningLevel>
9595
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
@@ -118,7 +118,7 @@
118118
<BufferSecurityCheck>true</BufferSecurityCheck>
119119
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
120120
<Optimization>Disabled</Optimization>
121-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
122122
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
123123
<WarningLevel>Level4</WarningLevel>
124124
<DisableSpecificWarnings>4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805</DisableSpecificWarnings>
@@ -146,7 +146,7 @@
146146
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
147147
<BufferSecurityCheck>false</BufferSecurityCheck>
148148
<Optimization>MaxSpeed</Optimization>
149-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
149+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
150150
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
151151
<WarningLevel>Level4</WarningLevel>
152152
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
@@ -184,7 +184,7 @@
184184
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
185185
<BufferSecurityCheck>false</BufferSecurityCheck>
186186
<Optimization>MaxSpeed</Optimization>
187-
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
187+
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
188188
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
189189
<WarningLevel>Level4</WarningLevel>
190190
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>

cli/cmdlineparser.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
407407
}
408408
}
409409

410-
bool def = false;
411-
bool maxconfigs = false;
412410
bool debug = false;
413411
bool inputAsFilter = false; // set by: --file-filter=+
414412

@@ -421,7 +419,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
421419

422420
std::vector<std::string> lookupPaths{
423421
Path::getCurrentPath(), // TODO: do we want to look in CWD?
424-
Path::getPathFromFilename(argv[0])
422+
Path::getPathFromFilename(mSettings.exename),
425423
};
426424

427425
bool executorAuto = true;
@@ -457,8 +455,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
457455
if (!mSettings.userDefines.empty())
458456
mSettings.userDefines += ";";
459457
mSettings.userDefines += define;
460-
461-
def = true;
462458
}
463459

464460
// -E
@@ -801,8 +797,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
801797
}
802798

803799
// Force checking of files that have "too many" configurations
804-
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0)
800+
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0) {
805801
mSettings.force = true;
802+
mSettings.maxConfigsOption = Settings::maxConfigsNotAssigned;
803+
}
806804

807805
else if (std::strcmp(argv[i], "--fsigned-char") == 0)
808806
defaultSign = 's';
@@ -974,9 +972,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
974972
return Result::Fail;
975973
}
976974

977-
mSettings.maxConfigs = tmp;
975+
mSettings.maxConfigsOption = tmp;
978976
mSettings.force = false;
979-
maxconfigs = true;
980977
}
981978

982979
// max ctu depth
@@ -1160,7 +1157,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11601157
return Result::Fail;
11611158
}
11621159

1163-
mSettings.checkAllConfigurations = false; // Can be overridden with --max-configs or --force
11641160
std::string projectFile = argv[i]+10;
11651161
projectType = project.import(projectFile, &mSettings, &mSuppressions);
11661162
if (projectType == ImportProject::Type::CPPCHECK_GUI) {
@@ -1187,6 +1183,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
11871183
}
11881184
}
11891185
}
1186+
if (projectType == ImportProject::Type::COMPILE_DB)
1187+
mSettings.maxConfigsProject = 1;
11901188
if (projectType == ImportProject::Type::VS_SLN || projectType == ImportProject::Type::VS_VCXPROJ) {
11911189
mSettings.libraries.emplace_back("windows");
11921190
}
@@ -1591,14 +1589,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15911589
substituteTemplateFormatStatic(mSettings.templateFormat, !mSettings.outputFile.empty());
15921590
substituteTemplateLocationStatic(mSettings.templateLocation, !mSettings.outputFile.empty());
15931591

1594-
if (mSettings.force || maxconfigs)
1595-
mSettings.checkAllConfigurations = true;
1596-
1597-
if (mSettings.force)
1598-
mSettings.maxConfigs = INT_MAX;
1599-
else if ((def || mSettings.preprocessOnly) && !maxconfigs)
1600-
mSettings.maxConfigs = 1U;
1601-
16021592
if (debug) {
16031593
mSettings.debugnormal = true;
16041594
mSettings.debugvalueflow = true;

cli/cppcheckexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include <windows.h>
7575
#endif
7676

77-
#if !defined(WIN32) && !defined(__MINGW32__)
77+
#if !defined(_WIN32) && !defined(__MINGW32__)
7878
#include <sys/wait.h> // WIFEXITED and friends
7979
#endif
8080

@@ -684,7 +684,7 @@ int CppCheckExecutor::executeCommand(std::string exe, std::vector<std::string> a
684684
//std::cout << "pclose() errno " << std::to_string(err) << std::endl;
685685
return res;
686686
}
687-
#if !defined(WIN32) && !defined(__MINGW32__)
687+
#if !defined(_WIN32) && !defined(__MINGW32__)
688688
if (WIFEXITED(res)) {
689689
return WEXITSTATUS(res);
690690
}

cli/processexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "processexecutor.h"
2424

25-
#if !defined(WIN32) && !defined(__MINGW32__)
25+
#ifdef HAS_THREADING_MODEL_FORK
2626

2727
#include "cppcheck.h"
2828
#include "errorlogger.h"
@@ -471,4 +471,4 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
471471
mErrorLogger.reportErr(errmsg);
472472
}
473473

474-
#endif // !WIN32
474+
#endif // HAS_THREADING_MODEL_FORK

cli/processexecutor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef PROCESSEXECUTOR_H
2020
#define PROCESSEXECUTOR_H
2121

22+
#include "config.h"
23+
24+
#ifdef HAS_THREADING_MODEL_FORK
25+
2226
#include "cppcheck.h"
2327
#include "executor.h"
2428

@@ -72,4 +76,6 @@ class ProcessExecutor : public Executor {
7276

7377
/// @}
7478

79+
#endif // HAS_THREADING_MODEL_FORK
80+
7581
#endif // PROCESSEXECUTOR_H

cli/singleexecutor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ unsigned int SingleExecutor::check()
6767
reportStatus(c, mFileSettings.size(), c, mFileSettings.size());
6868
}
6969

70+
// TODO: CppCheckExecutor::check_internal() is also invoking the whole program analysis - is it run twice?
7071
if (mCppcheck.analyseWholeProgram())
7172
result++;
7273

cli/threadexecutor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "threadexecutor.h"
2020

21+
#ifdef HAS_THREADING_MODEL_THREAD
22+
2123
#include "config.h"
2224
#include "cppcheck.h"
2325
#include "errorlogger.h"
@@ -219,3 +221,5 @@ unsigned int ThreadExecutor::check()
219221

220222
return result;
221223
}
224+
225+
#endif // HAS_THREADING_MODEL_THREAD

cli/threadexecutor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#ifndef THREADEXECUTOR_H
2020
#define THREADEXECUTOR_H
2121

22+
#include "config.h"
23+
24+
#ifdef HAS_THREADING_MODEL_THREAD
25+
2226
#include "cppcheck.h"
2327
#include "executor.h"
2428

@@ -52,4 +56,6 @@ class ThreadExecutor : public Executor {
5256

5357
/// @}
5458

59+
#endif // HAS_THREADING_MODEL_THREAD
60+
5561
#endif // THREADEXECUTOR_H

0 commit comments

Comments
 (0)