diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b006e23fe..814ec585d 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -979,6 +979,10 @@ Settings MainWindow::getCppcheckSettings() result.maxCtuDepth = mProjectFile->getMaxCtuDepth(); result.maxTemplateRecursion = mProjectFile->getMaxTemplateRecursion(); + if (mProjectFile->isCheckLevelExhaustive()) + result.setCheckLevelExhaustive(); + else + result.setCheckLevelNormal(); result.checkHeaders = mProjectFile->getCheckHeaders(); result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates(); result.safeChecks.classes = mProjectFile->safeChecks.classes; diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index 3c7d669f6..e60e54a61 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -58,6 +58,7 @@ void ProjectFile::clear() { const Settings settings; clangParser = false; + mCheckLevel = CheckLevel::normal; mRootPath.clear(); mBuildDir.clear(); mImportProject.clear(); @@ -141,6 +142,9 @@ bool ProjectFile::read(const QString &filename) if (xmlReader.name() == QString(CppcheckXml::CheckUnusedTemplatesElementName)) mCheckUnusedTemplates = readBool(xmlReader); + if (xmlReader.name() == QString(CppcheckXml::CheckLevelExhaustiveElementName)) + mCheckLevel = CheckLevel::exhaustive; + // Find include directory from inside project element if (xmlReader.name() == QString(CppcheckXml::IncludeDirElementName)) readIncludeDirs(xmlReader); @@ -780,6 +784,16 @@ void ProjectFile::setVSConfigurations(const QStringList &vsConfigs) mVsConfigurations = vsConfigs; } +void ProjectFile::setCheckLevel(ProjectFile::CheckLevel checkLevel) +{ + mCheckLevel = checkLevel; +} + +bool ProjectFile::isCheckLevelExhaustive() const +{ + return mCheckLevel == CheckLevel::exhaustive; +} + void ProjectFile::setWarningTags(std::size_t hash, const QString& tags) { if (tags.isEmpty()) @@ -978,6 +992,11 @@ bool ProjectFile::write(const QString &filename) } } + if (mCheckLevel == CheckLevel::exhaustive) { + xmlWriter.writeStartElement(CppcheckXml::CheckLevelExhaustiveElementName); + xmlWriter.writeEndElement(); + } + // Cppcheck Premium if (mBughunting) { xmlWriter.writeStartElement(CppcheckXml::BughuntingElementName); diff --git a/gui/projectfile.h b/gui/projectfile.h index 7926faf2b..50d87ea56 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -53,6 +53,11 @@ public: if (this == mActiveProject) mActiveProject = nullptr; } + enum class CheckLevel { + normal, + exhaustive + }; + static ProjectFile* getActiveProject() { return mActiveProject; } @@ -329,6 +334,10 @@ public: */ void setVSConfigurations(const QStringList &vsConfigs); + /** CheckLevel: normal/exhaustive */ + void setCheckLevel(CheckLevel checkLevel); + bool isCheckLevelExhaustive() const; + /** * @brief Set tags. * @param tags tag list @@ -587,7 +596,10 @@ private: */ QStringList mAddons; - bool mBughunting; + bool mBughunting = false; + + /** @brief Should Cppcheck run normal or exhaustive analysis? */ + CheckLevel mCheckLevel = CheckLevel::normal; /** * @brief List of coding standards, checked by Cppcheck Premium. @@ -597,6 +609,7 @@ private: /** @brief Project name, used when generating compliance report */ QString mProjectName; + /** @brief Cppcheck Premium: This value is passed to the Cert C checker if that is enabled */ int mCertIntPrecision; /** @brief Execute clang analyzer? */ diff --git a/gui/projectfile.ui b/gui/projectfile.ui index a2e47484e..79ed0908f 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -7,7 +7,7 @@ 0 0 940 - 617 + 701 @@ -402,7 +402,7 @@ Analysis - + @@ -452,6 +452,29 @@ + + + + Check level + + + + + + Normal -- meant for normal analysis in CI. Analysis should finish in reasonable time. + + + + + + + Exhaustive -- meant for nightly builds etc. Analysis time can be longer (10x slower than compilation is OK). + + + + + + diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 29dd2b419..523641d27 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -307,6 +307,10 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) else item->setCheckState(Qt::Unchecked); } + if (projectFile->isCheckLevelExhaustive()) + mUI->mCheckLevelExhaustive->setChecked(true); + else + mUI->mCheckLevelNormal->setChecked(true); mUI->mCheckHeaders->setChecked(projectFile->getCheckHeaders()); mUI->mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates()); mUI->mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth()); @@ -428,6 +432,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const projectFile->setCheckPaths(getCheckPaths()); projectFile->setExcludedPaths(getExcludedPaths()); projectFile->setLibraries(getLibraries()); + projectFile->setCheckLevel(mUI->mCheckLevelExhaustive->isChecked() ? ProjectFile::CheckLevel::exhaustive : ProjectFile::CheckLevel::normal); projectFile->clangParser = mUI->mBtnClangParser->isChecked(); projectFile->safeChecks.classes = mUI->mBtnSafeClasses->isChecked(); if (mUI->mComboBoxPlatform->currentText().endsWith(".xml")) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 767b29141..c59bf288a 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1147,6 +1147,8 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti guiProject.analyzeAllVsConfigs.clear(); + bool checkLevelExhaustive = false; + // TODO: this should support all available command-line options for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { if (strcmp(node->Name(), CppcheckXml::RootPathName) == 0) { @@ -1216,6 +1218,8 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti } } else if (strcmp(node->Name(), CppcheckXml::CheckHeadersElementName) == 0) temp.checkHeaders = (strcmp(readSafe(node->GetText(), ""), "true") == 0); + else if (strcmp(node->Name(), CppcheckXml::CheckLevelExhaustiveElementName) == 0) + checkLevelExhaustive = true; else if (strcmp(node->Name(), CppcheckXml::CheckUnusedTemplatesElementName) == 0) temp.checkUnusedTemplates = (strcmp(readSafe(node->GetText(), ""), "true") == 0); else if (strcmp(node->Name(), CppcheckXml::MaxCtuDepthElementName) == 0) @@ -1281,6 +1285,11 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti settings->maxTemplateRecursion = temp.maxTemplateRecursion; settings->safeChecks = temp.safeChecks; + if (checkLevelExhaustive) + settings->setCheckLevelExhaustive(); + else + settings->setCheckLevelNormal(); + return true; } diff --git a/lib/importproject.h b/lib/importproject.h index 5955337a5..704722edc 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -172,6 +172,7 @@ namespace CppcheckXml { const char TagAttributeName[] = "tag"; const char WarningElementName[] = "warning"; const char HashAttributeName[] = "hash"; + const char CheckLevelExhaustiveElementName[] = "check-level-exhaustive"; const char CheckHeadersElementName[] = "check-headers"; const char CheckUnusedTemplatesElementName[] = "check-unused-templates"; const char MaxCtuDepthElementName[] = "max-ctu-depth";