systemc: Add an error check to sc_gen_unique_name.

Accellera checks for a null pointer, and a test tries using that input.

Change-Id: I0f098f53de37ebbe481ea46e61fc0a9a404c29db
Reviewed-on: https://gem5-review.googlesource.com/c/13302
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-10-05 15:38:23 -07:00
parent 834846f802
commit c701d88756

View File

@@ -822,12 +822,20 @@ at_negedge(const sc_signal_in_if<sc_dt::sc_logic> &s)
const char *
sc_gen_unique_name(const char *seed)
{
if (!seed || seed[0] == '\0') {
SC_REPORT_ERROR(
"(E532) cannot generate unique name from null string", "");
seed = "unnamed";
}
auto mod = sc_gem5::pickParentModule();
if (mod)
return mod->uniqueName(seed);
sc_gem5::Process *p = sc_gem5::scheduler.current();
if (p)
return p->uniqueName(seed);
return ::sc_gem5::nameGen.gen(seed);
}