diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 1e5655112..0a78fc653 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -908,6 +908,7 @@ Settings MainWindow::getCppcheckSettings() } result.maxCtuDepth = mProjectFile->getMaxCtuDepth(); + result.maxTemplateRecursion = mProjectFile->getMaxTemplateRecursion(); 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 9fa7bc107..01bdd28fa 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -44,6 +44,7 @@ ProjectFile::ProjectFile(const QString &filename, QObject *parent) : void ProjectFile::clear() { + const Settings settings; clangParser = false; bugHunting = false; mRootPath.clear(); @@ -64,7 +65,8 @@ void ProjectFile::clear() mAnalyzeAllVsConfigs = false; mCheckHeaders = true; mCheckUnusedTemplates = false; - mMaxCtuDepth = 10; + mMaxCtuDepth = settings.maxCtuDepth; + mMaxTemplateRecursion = settings.maxTemplateRecursion; mCheckUnknownFunctionReturn.clear(); safeChecks.clear(); mVsConfigurations.clear(); @@ -187,6 +189,9 @@ bool ProjectFile::read(const QString &filename) if (xmlReader.name() == CppcheckXml::MaxCtuDepthElementName) mMaxCtuDepth = readInt(xmlReader, mMaxCtuDepth); + if (xmlReader.name() == CppcheckXml::MaxTemplateRecursionElementName) + mMaxTemplateRecursion = readInt(xmlReader, mMaxTemplateRecursion); + // VSConfiguration if (xmlReader.name() == CppcheckXml::VSConfigurationElementName) readVsConfigurations(xmlReader); @@ -786,6 +791,10 @@ bool ProjectFile::write(const QString &filename) xmlWriter.writeCharacters(QString::number(mMaxCtuDepth)); xmlWriter.writeEndElement(); + xmlWriter.writeStartElement(CppcheckXml::MaxTemplateRecursionElementName); + xmlWriter.writeCharacters(QString::number(mMaxTemplateRecursion)); + xmlWriter.writeEndElement(); + if (!mIncludeDirs.isEmpty()) { xmlWriter.writeStartElement(CppcheckXml::IncludeDirElementName); foreach (QString incdir, mIncludeDirs) { diff --git a/gui/projectfile.h b/gui/projectfile.h index 4aba8a4e3..18772dcd8 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -208,6 +208,14 @@ public: mMaxCtuDepth = maxCtuDepth; } + int getMaxTemplateRecursion() const { + return mMaxTemplateRecursion; + } + + void setMaxTemplateRecursion(int maxTemplateRecursion) { + mMaxTemplateRecursion = maxTemplateRecursion; + } + const std::map& getFunctionContracts() const { return mFunctionContracts; } @@ -538,6 +546,9 @@ private: /** Max CTU depth */ int mMaxCtuDepth; + /** Max template instantiation recursion */ + int mMaxTemplateRecursion; + QStringList mCheckUnknownFunctionReturn; }; diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index ef18f8c65..4eb1c403d 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -260,6 +260,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders()); mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates()); mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth()); + mUI.mMaxTemplateRecursion->setValue(projectFile->getMaxTemplateRecursion()); if (projectFile->clangParser) mUI.mBtnClangParser->setChecked(true); else @@ -361,6 +362,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const projectFile->setCheckHeaders(mUI.mCheckHeaders->isChecked()); projectFile->setCheckUnusedTemplates(mUI.mCheckUnusedTemplates->isChecked()); projectFile->setMaxCtuDepth(mUI.mMaxCtuDepth->value()); + projectFile->setMaxTemplateRecursion(mUI.mMaxTemplateRecursion->value()); projectFile->setIncludes(getIncludePaths()); projectFile->setDefines(getDefines()); projectFile->setUndefines(getUndefines()); diff --git a/gui/projectfiledialog.ui b/gui/projectfiledialog.ui index 8d5c7bc54..1cf6d5d15 100644 --- a/gui/projectfiledialog.ui +++ b/gui/projectfiledialog.ui @@ -520,7 +520,11 @@ - + + + 10 + + @@ -537,6 +541,40 @@ + + + + + + Max recursion in template instantiation + + + + + + + 1000 + + + 100 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/lib/importproject.h b/lib/importproject.h index a57379b39..3676c3b8c 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -164,6 +164,7 @@ namespace CppcheckXml { const char CheckHeadersElementName[] = "check-headers"; const char CheckUnusedTemplatesElementName[] = "check-unused-templates"; const char MaxCtuDepthElementName[] = "max-ctu-depth"; + const char MaxTemplateRecursionElementName[] = "max-template-recursion"; const char CheckUnknownFunctionReturn[] = "check-unknown-function-return-values"; const char ClangTidy[] = "clang-tidy"; const char Name[] = "name";