Skip to content

Commit e8606a5

Browse files
committed
let --premium=misra-c-2012 also set --addon=misra. changed addons container to a set
1 parent 5c10cfd commit e8606a5

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
230230
}
231231

232232
else if (std::strncmp(argv[i], "--addon=", 8) == 0)
233-
mSettings->addons.emplace_back(argv[i]+8);
233+
mSettings->addons.emplace(argv[i]+8);
234234

235235
else if (std::strncmp(argv[i],"--addon-python=", 15) == 0)
236236
mSettings->addonPython.assign(argv[i]+15);
@@ -621,7 +621,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
621621
else if (std::strncmp(argv[i], "--premium=", 10) == 0 && isCppcheckPremium()) {
622622
if (!mSettings->premiumArgs.empty())
623623
mSettings->premiumArgs += " ";
624-
mSettings->premiumArgs += "--" + std::string(argv[i] + 10);
624+
const std::string p(argv[i] + 10);
625+
mSettings->premiumArgs += "--" + p;
626+
if (p == "misra-c-2012")
627+
mSettings->addons.emplace("misra");
625628
}
626629

627630
// --project

gui/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ Settings MainWindow::getCppcheckSettings()
981981
json += ", \"args\":[\"" + arg + "\"]";
982982
}
983983
json += " }";
984-
result.addons.push_back(json.toStdString());
984+
result.addons.emplace(json.toStdString());
985985
}
986986

987987
if (isCppcheckPremium()) {

lib/importproject.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,10 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
11871187
guiProject.analyzeAllVsConfigs = node->GetText();
11881188
else if (strcmp(node->Name(), CppcheckXml::Parser) == 0)
11891189
temp.clang = true;
1190-
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0)
1191-
temp.addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
1190+
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0) {
1191+
const auto& addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
1192+
temp.addons.insert(addons.cbegin(), addons.cend());
1193+
}
11921194
else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0)
11931195
node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning
11941196
else if (strcmp(node->Name(), CppcheckXml::ToolsElementName) == 0) {

lib/settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ void Settings::loadCppcheckCfg()
9898
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
9999
const std::string &s = v.get<std::string>();
100100
if (!Path::isAbsolute(s))
101-
addons.push_back(Path::getPathFromFilename(fileName) + s);
101+
addons.emplace(Path::getPathFromFilename(fileName) + s);
102102
else
103-
addons.push_back(s);
103+
addons.emplace(s);
104104
}
105105
}
106106
if (obj.count("suppressions") && obj["suppressions"].is<picojson::array>()) {

lib/settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <set>
3838
#include <string>
3939
#include <vector>
40+
#include <unordered_set>
4041

4142
namespace ValueFlow {
4243
class Value;
@@ -99,7 +100,7 @@ class CPPCHECKLIB Settings : public cppcheck::Platform {
99100
void loadCppcheckCfg();
100101

101102
/** @brief addons, either filename of python/json file or json data */
102-
std::list<std::string> addons;
103+
std::unordered_set<std::string> addons;
103104

104105
/** @brief Path to the python interpreter to be used to run addons. */
105106
std::string addonPython;

0 commit comments

Comments
 (0)