parent
2adaafd20e
commit
e35d5d3ceb
|
@ -666,7 +666,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
mSettings.premiumArgs += " ";
|
||||
const std::string p(argv[i] + 10);
|
||||
mSettings.premiumArgs += "--" + p;
|
||||
if (p == "misra-c-2012")
|
||||
if (p == "misra-c-2012" || p == "misra-c-2023")
|
||||
mSettings.addons.emplace("misra");
|
||||
}
|
||||
|
||||
|
@ -1270,6 +1270,7 @@ void CmdLineParser::printHelp()
|
|||
<< " * cert-c-2016 Cert C 2016 checking\n"
|
||||
<< " * cert-c++-2016 Cert C++ 2016 checking (partial)\n"
|
||||
<< " * misra-c-2012 Misra C 2012\n"
|
||||
<< " * misra-c-2023 Misra C 2023\n"
|
||||
<< " * misra-c++-2008 Misra C++ 2008 (partial)\n"
|
||||
<< " Other:\n"
|
||||
<< " * bughunting Soundy analysis\n"
|
||||
|
|
|
@ -806,11 +806,42 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mMisraC2012">
|
||||
<property name="text">
|
||||
<string>Misra C 2012</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mMisraC">
|
||||
<property name="text">
|
||||
<string>Misra C</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="mMisraVersion">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2012</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2023</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="mLayoutMisraRuleTexts">
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <QtCore>
|
||||
|
||||
static const char ADDON_MISRA[] = "misra";
|
||||
static const char CODING_STANDARD_MISRA_C_2023[] = "misra-c-2023";
|
||||
static const char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008";
|
||||
static const char CODING_STANDARD_CERT_C[] = "cert-c-2016";
|
||||
static const char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016";
|
||||
|
@ -370,15 +371,22 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
|||
const QString dataDir = getDataDir();
|
||||
updateAddonCheckBox(mUI->mAddonThreadSafety, projectFile, dataDir, "threadsafety");
|
||||
updateAddonCheckBox(mUI->mAddonY2038, projectFile, dataDir, "y2038");
|
||||
updateAddonCheckBox(mUI->mMisraC2012, projectFile, dataDir, ADDON_MISRA);
|
||||
|
||||
// Misra checkbox..
|
||||
mUI->mMisraC->setText(mPremium ? "Misra C" : "Misra C 2012");
|
||||
updateAddonCheckBox(mUI->mMisraC, projectFile, dataDir, ADDON_MISRA);
|
||||
mUI->mMisraVersion->setEnabled(mUI->mMisraC->isChecked());
|
||||
connect(mUI->mMisraC, &QCheckBox::toggled, mUI->mMisraVersion, &QComboBox::setEnabled);
|
||||
|
||||
const QString &misraFile = settings.value(SETTINGS_MISRA_FILE, QString()).toString();
|
||||
mUI->mEditMisraFile->setText(misraFile);
|
||||
mUI->mMisraVersion->setVisible(mPremium);
|
||||
mUI->mMisraVersion->setCurrentIndex(projectFile->getCodingStandards().contains(CODING_STANDARD_MISRA_C_2023));
|
||||
if (mPremium) {
|
||||
mUI->mLabelMisraFile->setVisible(false);
|
||||
mUI->mEditMisraFile->setVisible(false);
|
||||
mUI->mBtnBrowseMisraFile->setVisible(false);
|
||||
} else if (!mUI->mMisraC2012->isEnabled()) {
|
||||
} else if (!mUI->mMisraC->isEnabled()) {
|
||||
mUI->mEditMisraFile->setEnabled(false);
|
||||
mUI->mBtnBrowseMisraFile->setEnabled(false);
|
||||
}
|
||||
|
@ -464,7 +472,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
|||
addons << "threadsafety";
|
||||
if (mUI->mAddonY2038->isChecked())
|
||||
addons << "y2038";
|
||||
if (mUI->mMisraC2012->isChecked())
|
||||
if (mUI->mMisraC->isChecked())
|
||||
addons << ADDON_MISRA;
|
||||
projectFile->setAddons(addons);
|
||||
QStringList codingStandards;
|
||||
|
@ -472,6 +480,8 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
|||
codingStandards << CODING_STANDARD_CERT_C;
|
||||
if (mUI->mCertCpp2016->isChecked())
|
||||
codingStandards << CODING_STANDARD_CERT_CPP;
|
||||
if (mPremium && mUI->mMisraVersion->currentIndex() == 1)
|
||||
codingStandards << CODING_STANDARD_MISRA_C_2023;
|
||||
if (mUI->mMisraCpp2008->isChecked())
|
||||
codingStandards << CODING_STANDARD_MISRA_CPP_2008;
|
||||
if (mUI->mAutosar->isChecked())
|
||||
|
@ -914,8 +924,8 @@ void ProjectFileDialog::browseMisraFile()
|
|||
mUI->mEditMisraFile->setText(fileName);
|
||||
settings.setValue(SETTINGS_MISRA_FILE, fileName);
|
||||
|
||||
mUI->mMisraC2012->setText("MISRA C 2012");
|
||||
mUI->mMisraC2012->setEnabled(true);
|
||||
updateAddonCheckBox(mUI->mMisraC2012, nullptr, getDataDir(), ADDON_MISRA);
|
||||
mUI->mMisraC->setText("MISRA C 2012");
|
||||
mUI->mMisraC->setEnabled(true);
|
||||
updateAddonCheckBox(mUI->mMisraC, nullptr, getDataDir(), ADDON_MISRA);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1439,6 +1439,8 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
|||
std::istringstream istr(results);
|
||||
std::string line;
|
||||
|
||||
const bool misraC2023 = mSettings.premiumArgs.find("--misra-c-2023") != std::string::npos;
|
||||
|
||||
while (std::getline(istr, line)) {
|
||||
if (line.compare(0,1,"{") != 0)
|
||||
continue;
|
||||
|
@ -1470,6 +1472,8 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
|||
}
|
||||
|
||||
errmsg.id = obj["addon"].get<std::string>() + "-" + obj["errorId"].get<std::string>();
|
||||
if (misraC2023 && errmsg.id.compare(0, 12, "misra-c2012-") == 0)
|
||||
errmsg.id = "misra-c2023-" + errmsg.id.substr(12);
|
||||
const std::string text = obj["message"].get<std::string>();
|
||||
errmsg.setmsg(text);
|
||||
const std::string severity = obj["severity"].get<std::string>();
|
||||
|
|
Loading…
Reference in New Issue