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.maxCtuDepth = mProjectFile->getMaxCtuDepth();
|
||||||
result.checkHeaders = mProjectFile->getCheckHeaders();
|
result.checkHeaders = mProjectFile->getCheckHeaders();
|
||||||
result.checkUnusedTemplates = mProjectFile->getCheckUnusedTemplates();
|
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.
|
// 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 CheckHeadersElementName[] = "check-headers";
|
||||||
static const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
static const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
||||||
static const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
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) :
|
ProjectFile::ProjectFile(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
|
@ -101,6 +104,8 @@ void ProjectFile::clear()
|
||||||
mCheckHeaders = true;
|
mCheckHeaders = true;
|
||||||
mCheckUnusedTemplates = false;
|
mCheckUnusedTemplates = false;
|
||||||
mMaxCtuDepth = 10;
|
mMaxCtuDepth = 10;
|
||||||
|
mCheckAllFunctionParameterValues = false;
|
||||||
|
mCheckUnknownFunctionReturn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectFile::read(const QString &filename)
|
bool ProjectFile::read(const QString &filename)
|
||||||
|
@ -180,6 +185,14 @@ bool ProjectFile::read(const QString &filename)
|
||||||
if (insideProject && xmlReader.name() == SuppressionsElementName)
|
if (insideProject && xmlReader.name() == SuppressionsElementName)
|
||||||
readSuppressions(xmlReader);
|
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
|
// Addons
|
||||||
if (insideProject && xmlReader.name() == AddonsElementName)
|
if (insideProject && xmlReader.name() == AddonsElementName)
|
||||||
readStringList(mAddons, xmlReader, AddonElementName);
|
readStringList(mAddons, xmlReader, AddonElementName);
|
||||||
|
@ -778,6 +791,16 @@ bool ProjectFile::write(const QString &filename)
|
||||||
xmlWriter.writeEndElement();
|
xmlWriter.writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeStringList(xmlWriter,
|
||||||
|
mCheckUnknownFunctionReturn,
|
||||||
|
CheckUnknownFunctionReturn,
|
||||||
|
Name);
|
||||||
|
|
||||||
|
if (mCheckAllFunctionParameterValues) {
|
||||||
|
xmlWriter.writeStartElement(CheckAllFunctionParameterValues);
|
||||||
|
xmlWriter.writeEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
writeStringList(xmlWriter,
|
writeStringList(xmlWriter,
|
||||||
mAddons,
|
mAddons,
|
||||||
AddonsElementName,
|
AddonsElementName,
|
||||||
|
|
|
@ -300,6 +300,22 @@ public:
|
||||||
mFilename = filename;
|
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:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,6 +488,11 @@ private:
|
||||||
|
|
||||||
/** Max CTU depth */
|
/** Max CTU depth */
|
||||||
int mMaxCtuDepth;
|
int mMaxCtuDepth;
|
||||||
|
|
||||||
|
bool mCheckAllFunctionParameterValues;
|
||||||
|
|
||||||
|
QStringList mCheckUnknownFunctionReturn;
|
||||||
|
|
||||||
};
|
};
|
||||||
/// @}
|
/// @}
|
||||||
#endif // PROJECT_FILE_H
|
#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_]*[; ]*)*");
|
const QRegExp undefRegExp("\\s*([a-zA-Z_][a-zA-Z0-9_]*[; ]*)*");
|
||||||
mUI.mEditUndefines->setValidator(new QRegExpValidator(undefRegExp, this));
|
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.mButtons, &QDialogButtonBox::accepted, this, &ProjectFileDialog::ok);
|
||||||
connect(mUI.mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir);
|
connect(mUI.mBtnBrowseBuildDir, &QPushButton::clicked, this, &ProjectFileDialog::browseBuildDir);
|
||||||
connect(mUI.mBtnClearImportProject, &QPushButton::clicked, this, &ProjectFileDialog::clearImportProject);
|
connect(mUI.mBtnClearImportProject, &QPushButton::clicked, this, &ProjectFileDialog::clearImportProject);
|
||||||
|
@ -283,6 +274,18 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
||||||
mUI.mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
|
mUI.mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
|
||||||
setSuppressions(projectFile->getSuppressions());
|
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;
|
QSettings settings;
|
||||||
const QString dataDir = settings.value("DATADIR", QString()).toString();
|
const QString dataDir = settings.value("DATADIR", QString()).toString();
|
||||||
updateAddonCheckBox(mUI.mAddonThreadSafety, projectFile, dataDir, "threadsafety");
|
updateAddonCheckBox(mUI.mAddonThreadSafety, projectFile, dataDir, "threadsafety");
|
||||||
|
@ -335,6 +338,16 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
||||||
projectFile->setPlatform(QString());
|
projectFile->setPlatform(QString());
|
||||||
}
|
}
|
||||||
projectFile->setSuppressions(getSuppressions());
|
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;
|
QStringList list;
|
||||||
if (mUI.mAddonThreadSafety->isChecked())
|
if (mUI.mAddonThreadSafety->isChecked())
|
||||||
list << "threadsafety";
|
list << "threadsafety";
|
||||||
|
|
|
@ -481,28 +481,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="checkBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>All classes must have a "safe" public interface</string>
|
<string>All classes must have a "safe" public interface</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue