Skip to content

Commit 4bb682c

Browse files
committed
genmc/setup: Check GenMC config validity
GenMC v0.14.1 does not throw an error internally if the config is invalid, but rather returns an appropriate error value. This commit has setup code in Miri check the returned value, and exit if there are any errors.
1 parent 545f39e commit 4bb682c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

genmc-sys/cpp/src/MiriInterface/Setup.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,16 @@ static auto to_genmc_verbosity_level(const LogLevel log_level) -> VerbosityLevel
147147
// that is allowed to leak and memory that is not.
148148
conf->warnUnfreedMemory = false;
149149

150-
// FIXME(genmc,error handling): This function currently exits on error, but will return an
151-
// error value in the future. The return value should be checked once this change is made.
152-
checkConfig(*conf);
150+
// Validate the config and exit if there are any errors
151+
std::vector<std::string> warnings;
152+
auto config_valid = conf->validate(warnings);
153+
for (const auto& w : warnings)
154+
WARN("{}", w);
155+
if (auto* errors = std::get_if<ConfigErrorList>(&config_valid); errors) {
156+
for (const auto& e : *errors)
157+
LOG(VerbosityLevel::Error, "{}", e);
158+
exit(EUSER);
159+
}
153160

154161
// Create the actual driver and Miri-GenMC communication shim.
155162
auto driver = std::make_unique<MiriGenmcShim>(std::move(conf), mode);

0 commit comments

Comments
 (0)