let --premium=misra-c-2012 also set --addon=misra. changed addons container to a set

This commit is contained in:
Daniel Marjamäki 2022-10-31 15:04:16 +01:00
parent 5c10cfd59e
commit e8606a5e5a
5 changed files with 14 additions and 8 deletions

View File

@ -230,7 +230,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
} }
else if (std::strncmp(argv[i], "--addon=", 8) == 0) else if (std::strncmp(argv[i], "--addon=", 8) == 0)
mSettings->addons.emplace_back(argv[i]+8); mSettings->addons.emplace(argv[i]+8);
else if (std::strncmp(argv[i],"--addon-python=", 15) == 0) else if (std::strncmp(argv[i],"--addon-python=", 15) == 0)
mSettings->addonPython.assign(argv[i]+15); mSettings->addonPython.assign(argv[i]+15);
@ -621,7 +621,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
else if (std::strncmp(argv[i], "--premium=", 10) == 0 && isCppcheckPremium()) { else if (std::strncmp(argv[i], "--premium=", 10) == 0 && isCppcheckPremium()) {
if (!mSettings->premiumArgs.empty()) if (!mSettings->premiumArgs.empty())
mSettings->premiumArgs += " "; mSettings->premiumArgs += " ";
mSettings->premiumArgs += "--" + std::string(argv[i] + 10); const std::string p(argv[i] + 10);
mSettings->premiumArgs += "--" + p;
if (p == "misra-c-2012")
mSettings->addons.emplace("misra");
} }
// --project // --project

View File

@ -981,7 +981,7 @@ Settings MainWindow::getCppcheckSettings()
json += ", \"args\":[\"" + arg + "\"]"; json += ", \"args\":[\"" + arg + "\"]";
} }
json += " }"; json += " }";
result.addons.push_back(json.toStdString()); result.addons.emplace(json.toStdString());
} }
if (isCppcheckPremium()) { if (isCppcheckPremium()) {

View File

@ -1187,8 +1187,10 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
guiProject.analyzeAllVsConfigs = node->GetText(); guiProject.analyzeAllVsConfigs = node->GetText();
else if (strcmp(node->Name(), CppcheckXml::Parser) == 0) else if (strcmp(node->Name(), CppcheckXml::Parser) == 0)
temp.clang = true; temp.clang = true;
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0) else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0) {
temp.addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr); const auto& addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
temp.addons.insert(addons.cbegin(), addons.cend());
}
else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0) else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0)
node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning
else if (strcmp(node->Name(), CppcheckXml::ToolsElementName) == 0) { else if (strcmp(node->Name(), CppcheckXml::ToolsElementName) == 0) {

View File

@ -98,9 +98,9 @@ void Settings::loadCppcheckCfg()
for (const picojson::value &v : obj["addons"].get<picojson::array>()) { for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
const std::string &s = v.get<std::string>(); const std::string &s = v.get<std::string>();
if (!Path::isAbsolute(s)) if (!Path::isAbsolute(s))
addons.push_back(Path::getPathFromFilename(fileName) + s); addons.emplace(Path::getPathFromFilename(fileName) + s);
else else
addons.push_back(s); addons.emplace(s);
} }
} }
if (obj.count("suppressions") && obj["suppressions"].is<picojson::array>()) { if (obj.count("suppressions") && obj["suppressions"].is<picojson::array>()) {

View File

@ -37,6 +37,7 @@
#include <set> #include <set>
#include <string> #include <string>
#include <vector> #include <vector>
#include <unordered_set>
namespace ValueFlow { namespace ValueFlow {
class Value; class Value;
@ -99,7 +100,7 @@ public:
void loadCppcheckCfg(); void loadCppcheckCfg();
/** @brief addons, either filename of python/json file or json data */ /** @brief addons, either filename of python/json file or json data */
std::list<std::string> addons; std::unordered_set<std::string> addons;
/** @brief Path to the python interpreter to be used to run addons. */ /** @brief Path to the python interpreter to be used to run addons. */
std::string addonPython; std::string addonPython;