GUI: Activate 'human knowledge' options
This commit is contained in:
parent
d4d9bb4830
commit
4a70208e0e
|
@ -882,6 +882,9 @@ Settings MainWindow::getCppcheckSettings()
|
|||
result.maxCtuDepth = mProjectFile->getMaxCtuDepth();
|
||||
result.checkHeaders = mProjectFile->getCheckHeaders();
|
||||
result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates();
|
||||
result.allFunctionsAreSafe = mProjectFile->getCheckAllFunctionParameterValues();
|
||||
foreach (QString s, mProjectFile->getCheckUnknownFunctionReturn())
|
||||
result.checkUnknownFunctionReturn.insert(s.toStdString());
|
||||
}
|
||||
|
||||
// Include directories (and files) are searched in listed order.
|
||||
|
|
|
@ -66,6 +66,9 @@ static const char TagElementName[] = "tag";
|
|||
static const char CheckHeadersElementName[] = "check-headers";
|
||||
static const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
||||
static const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
||||
static const char CheckUnknownFunctionReturn[] = "check-unknown-function-return-values";
|
||||
static const char CheckAllFunctionParameterValues[] = "check-all-function-parameter-values";
|
||||
static const char Name[] = "name";
|
||||
|
||||
ProjectFile::ProjectFile(QObject *parent) :
|
||||
QObject(parent)
|
||||
|
@ -101,6 +104,8 @@ void ProjectFile::clear()
|
|||
mCheckHeaders = true;
|
||||
mCheckUnusedTemplates = false;
|
||||
mMaxCtuDepth = 10;
|
||||
mCheckAllFunctionParameterValues = false;
|
||||
mCheckUnknownFunctionReturn.clear();
|
||||
}
|
||||
|
||||
bool ProjectFile::read(const QString &filename)
|
||||
|
@ -180,6 +185,14 @@ bool ProjectFile::read(const QString &filename)
|
|||
if (insideProject && xmlReader.name() == SuppressionsElementName)
|
||||
readSuppressions(xmlReader);
|
||||
|
||||
// Unknown function return values
|
||||
if (insideProject && xmlReader.name() == CheckUnknownFunctionReturn)
|
||||
readStringList(mCheckUnknownFunctionReturn, xmlReader, Name);
|
||||
|
||||
// check all function parameter values
|
||||
if (insideProject && xmlReader.name() == CheckAllFunctionParameterValues)
|
||||
mCheckAllFunctionParameterValues = true;
|
||||
|
||||
// Addons
|
||||
if (insideProject && xmlReader.name() == AddonsElementName)
|
||||
readStringList(mAddons, xmlReader, AddonElementName);
|
||||
|
@ -778,6 +791,16 @@ bool ProjectFile::write(const QString &filename)
|
|||
xmlWriter.writeEndElement();
|
||||
}
|
||||
|
||||
writeStringList(xmlWriter,
|
||||
mCheckUnknownFunctionReturn,
|
||||
CheckUnknownFunctionReturn,
|
||||
Name);
|
||||
|
||||
if (mCheckAllFunctionParameterValues) {
|
||||
xmlWriter.writeStartElement(CheckAllFunctionParameterValues);
|
||||
xmlWriter.writeEndElement();
|
||||
}
|
||||
|
||||
writeStringList(xmlWriter,
|
||||
mAddons,
|
||||
AddonsElementName,
|
||||
|
|
|
@ -300,6 +300,22 @@ public:
|
|||
mFilename = filename;
|
||||
}
|
||||
|
||||
/** Experimental: checking all function parameter values */
|
||||
bool getCheckAllFunctionParameterValues() const {
|
||||
return mCheckAllFunctionParameterValues;
|
||||
}
|
||||
void setCheckAllFunctionParameterValues(bool b) {
|
||||
mCheckAllFunctionParameterValues = b;
|
||||
}
|
||||
|
||||
/** Check unknown function return values */
|
||||
QStringList getCheckUnknownFunctionReturn() const {
|
||||
return mCheckUnknownFunctionReturn;
|
||||
}
|
||||
void setCheckUnknownFunctionReturn(QStringList s) {
|
||||
mCheckUnknownFunctionReturn = s;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -472,6 +488,11 @@ private:
|
|||
|
||||
/** Max CTU depth */
|
||||
int mMaxCtuDepth;
|
||||
|
||||
bool mCheckAllFunctionParameterValues;
|
||||
|
||||
QStringList mCheckUnknownFunctionReturn;
|
||||
|
||||
};
|
||||
/// @}
|
||||
#endif // PROJECT_FILE_H
|
||||
|
|
|
@ -178,15 +178,6 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, QWidget *parent)
|
|||
const QRegExp undefRegExp("\\s*([a-zA-Z_][a-zA-Z0-9_]*[; ]*)*");
|
||||
mUI.mEditUndefines->setValidator(new QRegExpValidator(undefRegExp, this));
|
||||
|
||||
// Human knowledge..
|
||||
mUI.mListUnknownFunctionReturn->clear();
|
||||
mUI.mListUnknownFunctionReturn->addItem("rand()");
|
||||
for (int row = 0; row < mUI.mListUnknownFunctionReturn->count(); ++row) {
|
||||
QListWidgetItem *item = mUI.mListUnknownFunctionReturn->item(row);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
item->setCheckState(item->text() == "rand()" ? Qt::Checked : Qt::Unchecked); // AND initialize check state
|
||||
}
|
||||
|
||||
connect(mUI.mButtons, &QDialogButtonBox::accepted, this, &ProjectFileDialog::ok);
|
||||
connect(mUI.mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir);
|
||||
connect(mUI.mBtnClearImportProject, &QPushButton::clicked, this, &ProjectFileDialog::clearImportProject);
|
||||
|
@ -283,6 +274,18 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
|||
mUI.mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
|
||||
setSuppressions(projectFile->getSuppressions());
|
||||
|
||||
// Human knowledge..
|
||||
mUI.mListUnknownFunctionReturn->clear();
|
||||
mUI.mListUnknownFunctionReturn->addItem("rand()");
|
||||
for (int row = 0; row < mUI.mListUnknownFunctionReturn->count(); ++row) {
|
||||
QListWidgetItem *item = mUI.mListUnknownFunctionReturn->item(row);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
const bool unknownValues = projectFile->getCheckUnknownFunctionReturn().contains(item->text());
|
||||
item->setCheckState(unknownValues ? Qt::Checked : Qt::Unchecked); // AND initialize check state
|
||||
}
|
||||
mUI.mAllFunctionsAreSafe->setChecked(projectFile->getCheckAllFunctionParameterValues());
|
||||
|
||||
// Addons..
|
||||
QSettings settings;
|
||||
const QString dataDir = settings.value("DATADIR", QString()).toString();
|
||||
updateAddonCheckBox(mUI.mAddonThreadSafety, projectFile, dataDir, "threadsafety");
|
||||
|
@ -335,6 +338,16 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
|||
projectFile->setPlatform(QString());
|
||||
}
|
||||
projectFile->setSuppressions(getSuppressions());
|
||||
// Human knowledge
|
||||
QStringList unknownReturnValues;
|
||||
for (int row = 0; row < mUI.mListUnknownFunctionReturn->count(); ++row) {
|
||||
QListWidgetItem *item = mUI.mListUnknownFunctionReturn->item(row);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
unknownReturnValues << item->text();
|
||||
}
|
||||
projectFile->setCheckUnknownFunctionReturn(unknownReturnValues);
|
||||
projectFile->setCheckAllFunctionParameterValues(mUI.mAllFunctionsAreSafe->isChecked());
|
||||
// Addons
|
||||
QStringList list;
|
||||
if (mUI.mAddonThreadSafety->isChecked())
|
||||
list << "threadsafety";
|
||||
|
|
|
@ -481,28 +481,14 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>TODO: Configure possible values of function parameters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Note: It must be possible to define parameter values in the code using annotations in the code (SAL , code contracts, etc)</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>All classes must have a "safe" public interface</string>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue