Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 1, 2024
2 parents b306d90 + 7b22594 commit 11ab940
Show file tree
Hide file tree
Showing 35 changed files with 137 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install psutil
- name: Build cppcheck
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

- name: Set up Python 3.12
if: matrix.config == 'release'
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
check-latest: true
Expand All @@ -100,7 +100,7 @@ jobs:

- name: Cache PCRE
id: cache-pcre
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
externals\pcre.h
Expand Down Expand Up @@ -132,6 +132,7 @@ jobs:
python -m pip install pytest || exit /b !errorlevel!
python -m pip install pytest-custom_exit_code || exit /b !errorlevel!
python -m pip install pytest-timeout || exit /b !errorlevel!
python -m pip install psutil || exit /b !errorlevel!
- name: Run CMake
if: false # TODO: enable
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
check-latest: true
Expand Down Expand Up @@ -64,6 +64,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install psutil
# TODO: disable all warnings
- name: CMake
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/buildman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
args: --output=output/manual-premium.pdf man/manual-premium.md

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: output
path: output
Expand All @@ -54,7 +54,7 @@ jobs:
run: |
make man
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cppcheck.1
path: cppcheck.1
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
dry-run: false
language: c++
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
lcov --extract lcov_tmp.info "$(pwd)/*" --output-file lcov.info
genhtml lcov.info -o coverage_report --frame --legend --demangle-cpp
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Coverage results
path: coverage_report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v3

- name: Cache uncrustify
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-uncrustify
with:
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ jobs:
# -isystem/usr/lib/clang/17/include
iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments > iwyu.log
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Compilation Database
path: ./cmake.output/compile_commands.json

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs (include-what-you-use)
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
# TODO: run multi-threaded
find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-18 --print=changes --extra-arg=-w -p cmake.output > clang-include-cleaner.log 2>&1
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Logs (clang-include-cleaner)
path: ./*.log
8 changes: 4 additions & 4 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Cache PCRE
id: cache-pcre
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
externals\pcre.h
Expand Down Expand Up @@ -133,12 +133,12 @@ jobs:
echo ProductVersion="%PRODUCTVER%" || exit /b !errorlevel!
msbuild -m cppcheck.wixproj -p:Platform=x64,ProductVersion=%PRODUCTVER%.${{ github.run_number }} || exit /b !errorlevel!
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: installer
path: win_installer/Build/

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: deploy
path: win_installer\files
Expand All @@ -162,7 +162,7 @@ jobs:
del win_installer\files\Qt5Svg.dll || exit /b !errorlevel!
del win_installer\files\vc_redist.x64.exe || exit /b !errorlevel!
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: portable
path: win_installer\files
6 changes: 3 additions & 3 deletions .github/workflows/scriptcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
key: ${{ github.workflow }}-${{ runner.os }}

- name: Cache Cppcheck
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: cppcheck
key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }}
Expand Down Expand Up @@ -58,13 +58,13 @@ jobs:
- uses: actions/checkout@v3

- name: Restore Cppcheck
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: cppcheck
key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/selfcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
env:
DISABLE_VALUEFLOW: 1

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Callgrind Output
path: ./callgrind.*
3 changes: 2 additions & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
check-latest: true
Expand Down Expand Up @@ -64,6 +64,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install psutil
- name: CMake
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
check-latest: true
Expand Down Expand Up @@ -63,6 +63,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install psutil
# TODO: disable warnings
- name: CMake
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
#env:
# DEBUGINFOD_URLS: https://debuginfod.ubuntu.com

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs
Expand Down
5 changes: 4 additions & 1 deletion gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,8 @@ QPair<bool,Settings> MainWindow::getCppcheckSettings()
QStringList dirs = mProjectFile->getIncludeDirs();
addIncludeDirs(dirs, result);

result.inlineSuppressions = mProjectFile->getInlineSuppression();

const QStringList defines = mProjectFile->getDefines();
for (const QString& define : defines) {
if (!result.userDefines.empty())
Expand Down Expand Up @@ -1111,6 +1113,8 @@ QPair<bool,Settings> MainWindow::getCppcheckSettings()
result.setMisraRuleTexts(CheckThread::executeCommand);
}
}
else
result.inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool();

// Include directories (and files) are searched in listed order.
// Global include directories must be added AFTER the per project include
Expand All @@ -1135,7 +1139,6 @@ QPair<bool,Settings> MainWindow::getCppcheckSettings()
result.force = mSettings->value(SETTINGS_CHECK_FORCE, 1).toBool();
result.xml = false;
result.jobs = mSettings->value(SETTINGS_CHECK_THREADS, 1).toInt();
result.inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool();
result.certainty.setEnabled(Certainty::inconclusive, mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool());
if (!mProjectFile || result.platform.type == Platform::Type::Unspecified)
result.platform.set((Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
Expand Down
8 changes: 8 additions & 0 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void ProjectFile::clear()
mAnalyzeAllVsConfigs = false;
mCheckHeaders = true;
mCheckUnusedTemplates = true;
mInlineSuppression = true;
mMaxCtuDepth = settings.maxCtuDepth;
mMaxTemplateRecursion = settings.maxTemplateRecursion;
mCheckUnknownFunctionReturn.clear();
Expand Down Expand Up @@ -143,6 +144,9 @@ bool ProjectFile::read(const QString &filename)
if (xmlReader.name() == QString(CppcheckXml::CheckUnusedTemplatesElementName))
mCheckUnusedTemplates = readBool(xmlReader);

if (xmlReader.name() == QString(CppcheckXml::InlineSuppression))
mInlineSuppression = readBool(xmlReader);

if (xmlReader.name() == QString(CppcheckXml::CheckLevelExhaustiveElementName))
mCheckLevel = CheckLevel::exhaustive;

Expand Down Expand Up @@ -873,6 +877,10 @@ bool ProjectFile::write(const QString &filename)
xmlWriter.writeCharacters(bool_to_string(mCheckUnusedTemplates));
xmlWriter.writeEndElement();

xmlWriter.writeStartElement(CppcheckXml::InlineSuppression);
xmlWriter.writeCharacters(bool_to_string(mInlineSuppression));
xmlWriter.writeEndElement();

xmlWriter.writeStartElement(CppcheckXml::MaxCtuDepthElementName);
xmlWriter.writeCharacters(QString::number(mMaxCtuDepth));
xmlWriter.writeEndElement();
Expand Down
13 changes: 13 additions & 0 deletions gui/projectfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class ProjectFile : public QObject {
mCheckUnusedTemplates = b;
}

bool getInlineSuppression() const {
return mInlineSuppression;
}

void setInlineSuppression(bool b) {
mInlineSuppression = b;
}

/**
* @brief Get list of include directories.
* @return list of directories.
Expand Down Expand Up @@ -557,6 +565,11 @@ class ProjectFile : public QObject {
/** Check code in unused templates */
bool mCheckUnusedTemplates;

/**
* @brief Enable inline suppression.
*/
bool mInlineSuppression;

/**
* @brief List of include directories used to search include files.
*/
Expand Down
7 changes: 7 additions & 0 deletions gui/projectfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mInlineSuppressions">
<property name="text">
<string>Enable inline suppressions</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_9">
<property name="orientation">
Expand Down
2 changes: 2 additions & 0 deletions gui/projectfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
mUI->mCheckLevelNormal->setChecked(true);
mUI->mCheckHeaders->setChecked(projectFile->getCheckHeaders());
mUI->mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
mUI->mInlineSuppressions->setChecked(projectFile->getInlineSuppression());
mUI->mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
mUI->mMaxTemplateRecursion->setValue(projectFile->getMaxTemplateRecursion());
if (projectFile->clangParser)
Expand Down Expand Up @@ -435,6 +436,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
projectFile->setVSConfigurations(getProjectConfigurations());
projectFile->setCheckHeaders(mUI->mCheckHeaders->isChecked());
projectFile->setCheckUnusedTemplates(mUI->mCheckUnusedTemplates->isChecked());
projectFile->setInlineSuppression(mUI->mInlineSuppressions->isChecked());
projectFile->setMaxCtuDepth(mUI->mMaxCtuDepth->value());
projectFile->setMaxTemplateRecursion(mUI->mMaxTemplateRecursion->value());
projectFile->setIncludes(getIncludePaths());
Expand Down
15 changes: 15 additions & 0 deletions gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ void TestProjectFile::getAddonFilePath() const
QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), filepath), filepath);
}

void TestProjectFile::getInlineSuppressionDefaultValue() const
{
ProjectFile projectFile;
projectFile.setFilename("/some/path/123.cppcheck");
QCOMPARE(projectFile.getInlineSuppression(), true);
}

void TestProjectFile::getInlineSuppression() const
{
ProjectFile projectFile;
projectFile.setFilename("/some/path/123.cppcheck");
projectFile.setInlineSuppression(false);
QCOMPARE(projectFile.getInlineSuppression(), false);
}

void TestProjectFile::getCheckingSuppressionsRelative() const
{
const SuppressionList::Suppression suppression("*", "externals/*");
Expand Down
3 changes: 3 additions & 0 deletions gui/test/projectfile/testprojectfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ private slots:

void getAddonFilePath() const;

void getInlineSuppressionDefaultValue() const;
void getInlineSuppression() const;

void getCheckingSuppressionsRelative() const;
void getCheckingSuppressionsAbsolute() const;
void getCheckingSuppressionsStar() const;
Expand Down
3 changes: 3 additions & 0 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
checkLevelExhaustive = true;
else if (strcmp(node->Name(), CppcheckXml::CheckUnusedTemplatesElementName) == 0)
temp.checkUnusedTemplates = (strcmp(readSafe(node->GetText(), ""), "true") == 0);
else if (strcmp(node->Name(), CppcheckXml::InlineSuppression) == 0)
temp.inlineSuppressions = (strcmp(readSafe(node->GetText(), ""), "true") == 0);
else if (strcmp(node->Name(), CppcheckXml::MaxCtuDepthElementName) == 0)
temp.maxCtuDepth = strToInt<int>(readSafe(node->GetText(), "2")); // TODO: bail out when missing?
else if (strcmp(node->Name(), CppcheckXml::MaxTemplateRecursionElementName) == 0)
Expand Down Expand Up @@ -1284,6 +1286,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
settings->checkUnusedTemplates = temp.checkUnusedTemplates;
settings->maxCtuDepth = temp.maxCtuDepth;
settings->maxTemplateRecursion = temp.maxTemplateRecursion;
settings->inlineSuppressions |= temp.inlineSuppressions;
settings->safeChecks = temp.safeChecks;

if (checkLevelExhaustive)
Expand Down
1 change: 1 addition & 0 deletions lib/importproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ namespace CppcheckXml {
static constexpr char MaxCtuDepthElementName[] = "max-ctu-depth";
static constexpr char MaxTemplateRecursionElementName[] = "max-template-recursion";
static constexpr char CheckUnknownFunctionReturn[] = "check-unknown-function-return-values";
static constexpr char InlineSuppression[] = "inline-suppression";
static constexpr char ClangTidy[] = "clang-tidy";
static constexpr char Name[] = "name";
static constexpr char VSConfigurationElementName[] = "vs-configurations";
Expand Down
Loading

0 comments on commit 11ab940

Please sign in to comment.