Skip to content

Commit

Permalink
Merge branch 'main' into chr_varscope
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Mar 13, 2024
2 parents 4a280ed + 4eac07f commit 8a990c5
Show file tree
Hide file tree
Showing 118 changed files with 10,773 additions and 10,701 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/CI-cygwin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Some convenient links:
# - https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
#

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CI-cygwin

on:
Expand Down Expand Up @@ -34,6 +32,7 @@ jobs:
fail-fast: false

runs-on: ${{ matrix.os }}
if: false # the hard-coded cygwin repository has changed so the setup step fails - TODO: re-enable

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/CI-mingw.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Some convenient links:
# - https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
#

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CI-mingw

on:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Some convenient links:
# - https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
#

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CI-windows

on:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/buildman.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: Build manual

on:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CIFuzz

on: [pull_request]

permissions:
contents: read

jobs:
Fuzzing:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'danmar' }}
steps:
- name: Build Fuzzers
id: build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: "CodeQL"

on:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: Coverity

on:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cppcheck-premium.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: cppcheck-premium

on:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
image: ["opensuse/tumbleweed:latest"] # "fedora:latest" / "debian:unstable" / "archlinux:latest"

runs-on: ubuntu-22.04
if: ${{ github.repository_owner == 'danmar' }}

container:
image: ${{ matrix.image }}
Expand Down Expand Up @@ -118,6 +119,7 @@ jobs:
clang-include-cleaner:

runs-on: ubuntu-22.04
if: ${{ github.repository_owner == 'danmar' }}

env:
QT_VERSION: 5.15.2
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Some convenient links:
# - https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
#

# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: release-windows

on:
Expand All @@ -24,6 +22,7 @@ jobs:
build:

runs-on: windows-2022
if: ${{ github.repository_owner == 'danmar' }}

env:
# see https://www.pcre.org/original/changelog.txt
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: CMake
run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DUSE_THREADS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-18
CXX: clang++-18
Expand Down Expand Up @@ -98,6 +98,8 @@ jobs:
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
env:
TEST_CPPCHECK_INJECT_EXECUTOR: thread

- name: Run test/cli (-j2)
run: |
Expand Down Expand Up @@ -129,6 +131,7 @@ jobs:
if: false
run: |
selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5_summary -D__GNUC__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings --check-level=exhaustive"
selfcheck_options="$selfcheck_options --executor=thread"
cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2"
ec=0
./cmake.output/bin/cppcheck $selfcheck_options externals/simplecpp || ec=1
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,10 @@ test/testtoken.o: test/testtoken.cpp lib/addoninfo.h lib/check.h lib/color.h lib
test/testtokenize.o: test/testtokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenize.cpp

test/testtokenlist.o: test/testtokenlist.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h
test/testtokenlist.o: test/testtokenlist.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenlist.cpp

test/testtokenrange.o: test/testtokenrange.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/vfvalue.h test/fixture.h
test/testtokenrange.o: test/testtokenrange.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenrange.cpp

test/testtype.o: test/testtype.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checktype.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
Expand Down
2 changes: 1 addition & 1 deletion cfg/posix.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5237,7 +5237,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<arg nr="2" direction="inout">
<not-null/>
</arg>
<arg nr="3" direction="in">
<arg nr="3" direction="inout">
<not-null/>
<not-uninit/>
</arg>
Expand Down
73 changes: 70 additions & 3 deletions cfg/wxwidgets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7365,6 +7365,26 @@
<returnValue type="wxString"/>
<warn severity="style">Use 'wxStyledTextEvent::GetString()' instead.</warn>
</function>
<!-- wxString wxToolbookEvent::GetString() const-->
<!-- wxString wxStyledTextEvent::GetString() const-->
<function name="wxStyledTextEvent::GetString,wxToolbookEvent::GetString">
<noreturn>false</noreturn>
<use-retval/>
<const/>
<leak-ignore/>
<returnValue type="wxString"/>
</function>
<!-- int wxToolbookEvent::GetOldSelection( void ) const -->
<!-- int wxToolbookEvent::GetSelection( void ) const -->
<!-- int wxBookCtrlEvent::GetOldSelection( void ) const -->
<!-- int wxBookCtrlEvent::GetSelection( void ) const -->
<function name="wxBookCtrlEvent::GetOldSelection,wxBookCtrlEvent::GetSelection,wxToolbookEvent::GetOldSelection,wxToolbookEvent::GetSelection">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="int"/>
<use-retval/>
<const/>
</function>
<!-- void wxStyledTextEvent::SetText(const wxString & t) -->
<!-- void wxStyledTextEvent::SetDragText(const wxString & val) -->
<function name="wxStyledTextEvent::SetText,wxStyledTextEvent::SetDragText">
Expand Down Expand Up @@ -7409,9 +7429,18 @@
<noreturn>false</noreturn>
<leak-ignore/>
<use-retval/>
<const/>
<returnValue type="wxCoord"/>
<warn severity="style">This function is deprecated and kept mostly for backwards compatibility. Please override 'GetMargins()' method instead in any new code.</warn>
</function>
<!-- wxPoint wxComboCtrl::GetMargins( ) const-->
<function name="wxComboCtrl::GetMargins">
<noreturn>false</noreturn>
<leak-ignore/>
<use-retval/>
<const/>
<returnValue type="wxPoint"/>
</function>
<!-- http://docs.wxwidgets.org/trunk/classwx_combo_ctrl.html#ae38353a81954d02af302ba103e984cb7 -->
<!-- void wxComboCtrl::HidePopup (bool generateEvent=false)-->
<function name="wxComboCtrl::HidePopup">
Expand Down Expand Up @@ -14265,6 +14294,26 @@ wxItemKind kind = wxITEM_NORMAL) -->
<not-uninit/>
</arg>
</function>
<!-- wxCoord wxMouseEvent::GetX( void ) const -->
<!-- wxCoord wxMouseEvent::GetY( void ) const -->
<!-- wxCoord wxMouseState::GetX( void ) const -->
<!-- wxCoord wxMouseState::GetY( void ) const -->
<function name="wxMouseEvent::GetX,wxMouseEvent::GetY,wxMouseState::GetY,wxMouseState::GetX">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="wxCoord"/>
<use-retval/>
<const/>
</function>
<!-- virtual wxString wxComboCtrl::GetValue( void ) const -->
<!-- virtual wxString wxOwnerDrawnComboBox::GetValue( void ) const -->
<function name="wxComboCtrl::GetValue,wxOwnerDrawnComboBox::GetValue">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="wxString"/>
<use-retval/>
<const/>
</function>
<!-- bool wxGridCellAttr::CanOverflow( void ) const -->
<function name="wxGridCellAttr::CanOverflow">
<noreturn>false</noreturn>
Expand All @@ -14289,6 +14338,24 @@ wxItemKind kind = wxITEM_NORMAL) -->
<use-retval/>
<const/>
</function>
<!-- int wxWithImages::GetImageCount( void ) const -->
<!-- int wxBookCtrlBase::GetImageCount( void ) const -->
<function name="wxWithImages::GetImageCount,wxBookCtrlBase::GetImageCount">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="int"/>
<use-retval/>
<const/>
</function>
<!-- wxImageList * wxWithImages::GetImageList( void ) const -->
<!-- wxImageList * wxBookCtrlBase::GetImageList( void ) const -->
<function name="wxWithImages::GetImageList,wxBookCtrlBase::GetImageList">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="wxImageList *"/>
<use-retval/>
<const/>
</function>
<!-- void wxFocusEvent::Skip(bool skip = true) -->
<!-- void wxSpinEvent::Skip(bool skip = true) -->
<!-- void wxEvent::Skip(bool skip = true) -->
Expand All @@ -14308,8 +14375,7 @@ wxItemKind kind = wxITEM_NORMAL) -->
<function name="wxPopupTransientWindow::OnDismiss">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="bool"/>
<use-retval/>
<returnValue type="void"/>
</function>
<!-- void wxPropertyGridManager::SetColumnCount(int colCount, int page = -1) -->
<function name="wxPropertyGridManager::SetColumnCount">
Expand Down Expand Up @@ -16812,9 +16878,10 @@ wxItemKind kind = wxITEM_NORMAL) -->
<use-retval/>
<const/>
</function>
<!-- int wxToolbookEvent::GetId( void ) const -->
<!-- int wxEvent::GetId( void ) const -->
<!-- int wxCommandEvent::GetId( void ) const -->
<function name="wxEvent::GetId,wxCommandEvent::GetId">
<function name="wxEvent::GetId,wxCommandEvent::GetId,wxToolbookEvent::GetId">
<noreturn>false</noreturn>
<leak-ignore/>
<returnValue type="int"/>
Expand Down
37 changes: 36 additions & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a

ImportProject project;

bool executorAuto = true;
int8_t logMissingInclude{0};

for (int i = 1; i < argc; i++) {
Expand Down Expand Up @@ -614,6 +615,36 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
#endif
}

else if (std::strncmp(argv[i], "--executor=", 11) == 0) {
const std::string type = 11 + argv[i];
if (type == "auto") {
executorAuto = true;
mSettings.executor = Settings::defaultExecutor();
}
else if (type == "thread") {
#if defined(HAS_THREADING_MODEL_THREAD)
executorAuto = false;
mSettings.executor = Settings::ExecutorType::Thread;
#else
mLogger.printError("executor type 'thread' cannot be used as Cppcheck has not been built with a respective threading model.");
return Result::Fail;
#endif
}
else if (type == "process") {
#if defined(HAS_THREADING_MODEL_FORK)
executorAuto = false;
mSettings.executor = Settings::ExecutorType::Process;
#else
mLogger.printError("executor type 'process' cannot be used as Cppcheck has not been built with a respective threading model.");
return Result::Fail;
#endif
}
else {
mLogger.printError("unknown executor: '" + type + "'.");
return Result::Fail;
}
}

// Filter errors
else if (std::strncmp(argv[i], "--exitcode-suppressions=", 24) == 0) {
// exitcode-suppressions=filename.txt
Expand Down Expand Up @@ -751,7 +782,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
}

else if (std::strncmp(argv[i], "-l", 2) == 0) {
#ifdef THREADING_MODEL_FORK
#ifdef HAS_THREADING_MODEL_FORK
std::string numberString;

// "-l 3"
Expand Down Expand Up @@ -1276,6 +1307,10 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
if (!loadCppcheckCfg())
return Result::Fail;

// TODO: bail out?
if (!executorAuto && mSettings.useSingleJob())
mLogger.printMessage("'--executor' has no effect as only a single job will be used.");

// Default template format..
if (mSettings.templateFormat.empty()) {
mSettings.templateFormat = "{bold}{file}:{line}:{column}: {red}{inconclusive:{magenta}}{severity}:{inconclusive: inconclusive:}{default} {message} [{id}]{reset}\\n{code}";
Expand Down
23 changes: 15 additions & 8 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
#include "suppressions.h"
#include "utils.h"

#if defined(THREADING_MODEL_THREAD)
#if defined(HAS_THREADING_MODEL_THREAD)
#include "threadexecutor.h"
#elif defined(THREADING_MODEL_FORK)
#endif
#if defined(HAS_THREADING_MODEL_FORK)
#include "processexecutor.h"
#endif

Expand Down Expand Up @@ -271,18 +272,24 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
cppcheck.settings() = settings; // this is a copy
auto& suppressions = cppcheck.settings().supprs.nomsg;

unsigned int returnValue;
unsigned int returnValue = 0;
if (settings.useSingleJob()) {
// Single process
SingleExecutor executor(cppcheck, mFiles, mFileSettings, settings, suppressions, stdLogger);
returnValue = executor.check();
} else {
#if defined(THREADING_MODEL_THREAD)
ThreadExecutor executor(mFiles, mFileSettings, settings, suppressions, stdLogger, CppCheckExecutor::executeCommand);
#elif defined(THREADING_MODEL_FORK)
ProcessExecutor executor(mFiles, mFileSettings, settings, suppressions, stdLogger, CppCheckExecutor::executeCommand);
#if defined(HAS_THREADING_MODEL_THREAD)
if (settings.executor == Settings::ExecutorType::Thread) {
ThreadExecutor executor(mFiles, mFileSettings, settings, suppressions, stdLogger, CppCheckExecutor::executeCommand);
returnValue = executor.check();
}
#endif
#if defined(HAS_THREADING_MODEL_FORK)
if (settings.executor == Settings::ExecutorType::Process) {
ProcessExecutor executor(mFiles, mFileSettings, settings, suppressions, stdLogger, CppCheckExecutor::executeCommand);
returnValue = executor.check();
}
#endif
returnValue = executor.check();
}

cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings);
Expand Down
Loading

0 comments on commit 8a990c5

Please sign in to comment.