Display error instead of assertion when pass exists

This commit is contained in:
Miodrag Milanovic 2023-01-09 17:02:56 +01:00
parent f2c689403a
commit 40282576b0
1 changed files with 12 additions and 5 deletions

View File

@ -108,7 +108,9 @@ Pass::Pass(std::string name, std::string short_help) : pass_name(name), short_he
void Pass::run_register()
{
log_assert(pass_register.count(pass_name) == 0);
if (pass_register.count(pass_name))
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
pass_register[pass_name] = this;
}
@ -445,10 +447,13 @@ Frontend::Frontend(std::string name, std::string short_help) :
void Frontend::run_register()
{
log_assert(pass_register.count(pass_name) == 0);
if (pass_register.count(pass_name))
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
pass_register[pass_name] = this;
log_assert(frontend_register.count(frontend_name) == 0);
if (frontend_register.count(frontend_name))
log_error("Unable to register frontend '%s', frontend already exists!\n", frontend_name.c_str());
frontend_register[frontend_name] = this;
}
@ -626,10 +631,12 @@ Backend::Backend(std::string name, std::string short_help) :
void Backend::run_register()
{
log_assert(pass_register.count(pass_name) == 0);
if (pass_register.count(pass_name))
log_error("Unable to register pass '%s', pass already exists!\n", pass_name.c_str());
pass_register[pass_name] = this;
log_assert(backend_register.count(backend_name) == 0);
if (backend_register.count(backend_name))
log_error("Unable to register backend '%s', backend already exists!\n", backend_name.c_str());
backend_register[backend_name] = this;
}