Skip to content

Commit

Permalink
[slang-tidy] Fix segmentation fault during mapping checker name on th…
Browse files Browse the repository at this point in the history
…e group
  • Loading branch information
Yan Churkin committed Jan 30, 2024
1 parent de03987 commit fd26280
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/tidy/src/TidyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ bool TidyConfig::toggleCheck(slang::TidyKind kind, const std::string& checkName,
registeredChecks.end()) {
return false;
}
checkKinds.at(kind).at(checkName) = status;
return true;

auto& checkNames = checkKinds.at(kind);
// Check that checker name is presence at target group
if (checkNames.count(checkName)) {
checkNames.at(checkName) = status;
return true;
}

return false;
}

bool TidyConfig::isCheckEnabled(slang::TidyKind kind, const std::string& checkName) const {
Expand Down
10 changes: 10 additions & 0 deletions tools/tidy/tests/TidyConfigParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,13 @@ TEST_CASE("TidyParser: Support for moduleInstantiationPrefix") {
auto config = parser.getConfig();
CHECK(config.getCheckConfigs().moduleInstantiationPrefix == "asdf");
}

TEST_CASE("TidyParser: existing checker in the wrong group") {
auto config_str = std::string(R"(Checks:
-style-enforce-port-suffix)");
TidyConfigParser parser(config_str);

auto config = parser.getConfig();

CHECK_FALSE(config.isCheckEnabled(slang::TidyKind::Style, "EnforcePortSuffix"));
}

0 comments on commit fd26280

Please sign in to comment.