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.checkHeaders = mProjectFile->getCheckHeaders();
result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates();
result.safeChecks.classes = mProjectFile->getSafeChecks().classes;
result.safeChecks.externalFunctions = mProjectFile->getSafeChecks().externalFunctions;
result.safeChecks.internalFunctions = mProjectFile->getSafeChecks().internalFunctions;
result.safeChecks.externalVariables = mProjectFile->getSafeChecks().externalVariables;
result.safeChecks.classes = mProjectFile->safeChecks.classes;
result.safeChecks.externalFunctions = mProjectFile->safeChecks.externalFunctions;
result.safeChecks.internalFunctions = mProjectFile->safeChecks.internalFunctions;
result.safeChecks.externalVariables = mProjectFile->safeChecks.externalVariables;
foreach (QString s, mProjectFile->getCheckUnknownFunctionReturn())
result.checkUnknownFunctionReturn.insert(s.toStdString());
}

View File

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

View File

@ -26,6 +26,8 @@
#include "suppressions.h"
#include <settings.h>
/// @addtogroup GUI
/// @{
@ -308,52 +310,15 @@ public:
}
/** Do not only check how interface is used. Also check that interface is safe. */
class SafeChecks {
class SafeChecks : public Settings::SafeChecks {
public:
SafeChecks() : classes(false), externalFunctions(false), internalFunctions(false), externalVariables(false) {}
void clear() {
classes = externalFunctions = internalFunctions = externalVariables = false;
}
SafeChecks() : Settings::SafeChecks() {}
void loadFromXml(QXmlStreamReader &xmlReader);
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 getSafeChecks() const {
return mSafeChecks;
}
void setSafeChecks(SafeChecks safeChecks) {
mSafeChecks = safeChecks;
}
SafeChecks safeChecks;
/** Check unknown function return values */
QStringList getCheckUnknownFunctionReturn() const {
@ -550,8 +515,6 @@ private:
/** Max CTU depth */
int mMaxCtuDepth;
SafeChecks mSafeChecks;
QStringList mCheckUnknownFunctionReturn;
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>888</width>
<height>600</height>
<width>800</width>
<height>617</height>
</rect>
</property>
<property name="windowTitle">
@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="mTabPathsAndDefines">
<attribute name="title">
@ -131,6 +131,12 @@
</item>
<item>
<widget class="QListWidget" name="mListVsConfigs">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
@ -168,7 +174,14 @@
</layout>
</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>
<layout class="QVBoxLayout" name="mLayoutCheckPathsButtons">
@ -354,11 +367,52 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabChecking">
<widget class="QWidget" name="mTabTypesAndFunctions">
<attribute name="title">
<string>Checking</string>
<string>Types and Functions</string>
</attribute>
<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>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
@ -407,28 +461,38 @@
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Platform</string>
<string>Check that code is safe</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<layout class="QVBoxLayout" name="verticalLayout_19">
<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>
</layout>
</widget>
</item>
<item>
<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">
<string>Analysis</string>
<string>Limit analysis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QCheckBox" name="mBugHunting">
<property name="text">
<string>Bug hunting</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mCheckHeaders">
<property name="text">
@ -476,28 +540,6 @@
</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>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
@ -506,7 +548,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>96</height>
<height>73</height>
</size>
</property>
</spacer>
@ -650,9 +692,9 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mTabAddonsAndTools">
<widget class="QWidget" name="mTabAddons">
<attribute name="title">
<string>Addons and tools</string>
<string>Addons</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>

View File

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