GUI: Tweak ProjectFileDialog: Bug hunting, safe class checking

This commit is contained in:
Daniel Marjamäki 2020-02-09 21:02:28 +01:00
parent f438cc6105
commit bb701fd8be
5 changed files with 100 additions and 91 deletions

View File

@ -891,10 +891,10 @@ Settings MainWindow::getCppcheckSettings()
result.maxCtuDepth = mProjectFile->getMaxCtuDepth(); result.maxCtuDepth = mProjectFile->getMaxCtuDepth();
result.checkHeaders = mProjectFile->getCheckHeaders(); result.checkHeaders = mProjectFile->getCheckHeaders();
result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates(); result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates();
result.safeChecks.classes = mProjectFile->getSafeChecks().classes; result.safeChecks.classes = mProjectFile->safeChecks.classes;
result.safeChecks.externalFunctions = mProjectFile->getSafeChecks().externalFunctions; result.safeChecks.externalFunctions = mProjectFile->safeChecks.externalFunctions;
result.safeChecks.internalFunctions = mProjectFile->getSafeChecks().internalFunctions; result.safeChecks.internalFunctions = mProjectFile->safeChecks.internalFunctions;
result.safeChecks.externalVariables = mProjectFile->getSafeChecks().externalVariables; result.safeChecks.externalVariables = mProjectFile->safeChecks.externalVariables;
foreach (QString s, mProjectFile->getCheckUnknownFunctionReturn()) foreach (QString s, mProjectFile->getCheckUnknownFunctionReturn())
result.checkUnknownFunctionReturn.insert(s.toStdString()); result.checkUnknownFunctionReturn.insert(s.toStdString());
} }

View File

@ -66,7 +66,7 @@ void ProjectFile::clear()
mCheckUnusedTemplates = false; mCheckUnusedTemplates = false;
mMaxCtuDepth = 10; mMaxCtuDepth = 10;
mCheckUnknownFunctionReturn.clear(); mCheckUnknownFunctionReturn.clear();
mSafeChecks.clear(); safeChecks.clear();
mVsConfigurations.clear(); mVsConfigurations.clear();
} }
@ -163,7 +163,7 @@ bool ProjectFile::read(const QString &filename)
// check all function parameter values // check all function parameter values
if (xmlReader.name() == Settings::SafeChecks::XmlRootName) if (xmlReader.name() == Settings::SafeChecks::XmlRootName)
mSafeChecks.loadFromXml(xmlReader); safeChecks.loadFromXml(xmlReader);
// Addons // Addons
if (xmlReader.name() == CppcheckXml::AddonsElementName) if (xmlReader.name() == CppcheckXml::AddonsElementName)
@ -819,7 +819,7 @@ bool ProjectFile::write(const QString &filename)
CppcheckXml::CheckUnknownFunctionReturn, CppcheckXml::CheckUnknownFunctionReturn,
CppcheckXml::Name); CppcheckXml::Name);
mSafeChecks.saveToXml(xmlWriter); safeChecks.saveToXml(xmlWriter);
writeStringList(xmlWriter, writeStringList(xmlWriter,
mAddons, mAddons,

View File

@ -26,6 +26,8 @@
#include "suppressions.h" #include "suppressions.h"
#include <settings.h>
/// @addtogroup GUI /// @addtogroup GUI
/// @{ /// @{
@ -308,52 +310,15 @@ public:
} }
/** Do not only check how interface is used. Also check that interface is safe. */ /** Do not only check how interface is used. Also check that interface is safe. */
class SafeChecks { class SafeChecks : public Settings::SafeChecks {
public: public:
SafeChecks() : classes(false), externalFunctions(false), internalFunctions(false), externalVariables(false) {} SafeChecks() : Settings::SafeChecks() {}
void clear() {
classes = externalFunctions = internalFunctions = externalVariables = false;
}
void loadFromXml(QXmlStreamReader &xmlReader); void loadFromXml(QXmlStreamReader &xmlReader);
void saveToXml(QXmlStreamWriter &xmlWriter) const; void saveToXml(QXmlStreamWriter &xmlWriter) const;
/**
* Public interface of classes
* - public function parameters can have any value
* - public functions can be called in any order
* - public variables can have any value
*/
bool classes;
/**
* External functions
* - external functions can be called in any order
* - function parameters can have any values
*/
bool externalFunctions;
/**
* Experimental: assume that internal functions can be used in any way
* This is only available in the GUI.
*/
bool internalFunctions;
/**
* Global variables that can be modified outside the TU.
* - Such variable can have "any" value
*/
bool externalVariables;
}; };
/** Safe checks */ SafeChecks safeChecks;
SafeChecks getSafeChecks() const {
return mSafeChecks;
}
void setSafeChecks(SafeChecks safeChecks) {
mSafeChecks = safeChecks;
}
/** Check unknown function return values */ /** Check unknown function return values */
QStringList getCheckUnknownFunctionReturn() const { QStringList getCheckUnknownFunctionReturn() const {
@ -550,8 +515,6 @@ private:
/** Max CTU depth */ /** Max CTU depth */
int mMaxCtuDepth; int mMaxCtuDepth;
SafeChecks mSafeChecks;
QStringList mCheckUnknownFunctionReturn; QStringList mCheckUnknownFunctionReturn;
}; };

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>888</width> <width>800</width>
<height>600</height> <height>617</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="mTabPathsAndDefines"> <widget class="QWidget" name="mTabPathsAndDefines">
<attribute name="title"> <attribute name="title">
@ -131,6 +131,12 @@
</item> </item>
<item> <item>
<widget class="QListWidget" name="mListVsConfigs"> <widget class="QListWidget" name="mListVsConfigs">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum> <enum>QAbstractItemView::MultiSelection</enum>
</property> </property>
@ -168,7 +174,14 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QListWidget" name="mListCheckPaths"/> <widget class="QListWidget" name="mListCheckPaths">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>140</height>
</size>
</property>
</widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="mLayoutCheckPathsButtons"> <layout class="QVBoxLayout" name="mLayoutCheckPathsButtons">
@ -354,11 +367,52 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="mTabChecking"> <widget class="QWidget" name="mTabTypesAndFunctions">
<attribute name="title"> <attribute name="title">
<string>Checking</string> <string>Types and Functions</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_15"> <layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Platform</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QComboBox" name="mComboBoxPlatform"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Libraries</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="mLibraries"/>
</item>
<item>
<widget class="QLabel" name="mLabelLibrariesNote">
<property name="text">
<string>Note: Put your own custom .cfg files in the same folder as the project file. You should see them above.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabAnalysis">
<attribute name="title">
<string>Analysis</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_18">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
@ -407,28 +461,38 @@
<item> <item>
<widget class="QGroupBox" name="groupBox_6"> <widget class="QGroupBox" name="groupBox_6">
<property name="title"> <property name="title">
<string>Platform</string> <string>Check that code is safe</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="verticalLayout_19">
<item> <item>
<widget class="QComboBox" name="mComboBoxPlatform"/> <widget class="QCheckBox" name="mBugHunting">
<property name="text">
<string>Bug hunting -- Detect all bugs. Generates mostly noise.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mBtnSafeClasses">
<property name="text">
<string>Check that each class has a safe public interface</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_9"> <widget class="QGroupBox" name="groupBox_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string>Analysis</string> <string>Limit analysis</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QCheckBox" name="mBugHunting">
<property name="text">
<string>Bug hunting</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="mCheckHeaders"> <widget class="QCheckBox" name="mCheckHeaders">
<property name="text"> <property name="text">
@ -476,28 +540,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Libraries</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QListWidget" name="mLibraries"/>
</item>
<item>
<widget class="QLabel" name="mLabelLibrariesNote">
<property name="text">
<string>Note: Put your own custom .cfg files in the same folder as the project file. You should see them above.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_7"> <spacer name="verticalSpacer_7">
<property name="orientation"> <property name="orientation">
@ -506,7 +548,7 @@
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>96</height> <height>73</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -650,9 +692,9 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="mTabAddonsAndTools"> <widget class="QWidget" name="mTabAddons">
<attribute name="title"> <attribute name="title">
<string>Addons and tools</string> <string>Addons</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<item> <item>

View File

@ -170,6 +170,10 @@ public:
static const char XmlInternalFunctions[]; static const char XmlInternalFunctions[];
static const char XmlExternalVariables[]; static const char XmlExternalVariables[];
void clear() {
classes = externalFunctions = internalFunctions = externalVariables = false;
}
/** /**
* Public interface of classes * Public interface of classes
* - public function parameters can have any value * - public function parameters can have any value