Skip to content

Commit 482c36b

Browse files
committed
let --premium=misra-c-2012 also set --addon=misra. changed addons container to a set
1 parent e81e6ee commit 482c36b

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
@@ -226,7 +226,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
226226
}
227227

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

231231
else if (std::strncmp(argv[i],"--addon-python=", 15) == 0)
232232
mSettings->addonPython.assign(argv[i]+15);
@@ -612,7 +612,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
612612
else if (std::strncmp(argv[i], "--premium=", 10) == 0 && isCppcheckPremium()) {
613613
if (!mSettings->premiumArgs.size())
614614
mSettings->premiumArgs += " ";
615-
mSettings->premiumArgs += "--" + std::string(argv[i] + 10);
615+
const std::string p(argv[i] + 10);
616+
mSettings->premiumArgs += "--" + p;
617+
if (p == "misra-c-2012")
618+
mSettings->addons.emplace("misra");
616619
}
617620

618621
// --project

gui/mainwindow.cpp

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

985985
if (isCppcheckPremium()) {

lib/importproject.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,10 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
11901190
guiProject.analyzeAllVsConfigs = node->GetText();
11911191
else if (strcmp(node->Name(), CppcheckXml::Parser) == 0)
11921192
temp.clang = true;
1193-
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0)
1194-
temp.addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
1193+
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0) {
1194+
const auto& addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
1195+
temp.addons.insert(addons.cbegin(), addons.cend());
1196+
}
11951197
else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0)
11961198
node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning
11971199
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
@@ -97,9 +97,9 @@ void Settings::loadCppcheckCfg()
9797
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
9898
const std::string &s = v.get<std::string>();
9999
if (!Path::isAbsolute(s))
100-
addons.push_back(Path::getPathFromFilename(fileName) + s);
100+
addons.emplace(Path::getPathFromFilename(fileName) + s);
101101
else
102-
addons.push_back(s);
102+
addons.emplace(s);
103103
}
104104
}
105105
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)