Prior to this commit, a tvm::NameSupply needed to be constructed with an explicit const String& prefix argument. Omitting this argument would fall back to the default constructor provided by the TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS macro, producing a NameSupply holding a nullptr. This then leads to a segfault when the null NameSupply is used.
The vast majority of usages of NameSupply::NameSupply (29 out of 31) initialize it with an empty prefix string. The remaining two use cases initialize it with a non-empty prefix string. There are no cases in which a null NameSupply is initialized.
This commit updates NameSupply to use the TVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS macro instead of TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS. This allows the default constructor to provide the common usage of a NameSupply with an empty prefix, rather than the error-prone usage of a null NameSupply
A similar change is also made for GlobalVarSupply, as the majority of its uses also default to an empty prefix (11 out of 13).
Prior to this commit, a
tvm::NameSupply
needed to be constructed with an explicitconst String& prefix
argument. Omitting this argument would fall back to the default constructor provided by theTVM_DEFINE_MUTABLE_OBJECT_REF_METHODS
macro, producing aNameSupply
holding a nullptr. This then leads to a segfault when the nullNameSupply
is used.The vast majority of usages of
NameSupply::NameSupply
(29 out of 31) initialize it with an emptyprefix
string. The remaining two use cases initialize it with a non-emptyprefix
string. There are no cases in which a nullNameSupply
is initialized.This commit updates
NameSupply
to use theTVM_DEFINE_MUTABLE_NOTNULLABLE_OBJECT_REF_METHODS
macro instead ofTVM_DEFINE_MUTABLE_OBJECT_REF_METHODS
. This allows the default constructor to provide the common usage of aNameSupply
with an empty prefix, rather than the error-prone usage of a nullNameSupply
A similar change is also made for
GlobalVarSupply
, as the majority of its uses also default to an empty prefix (11 out of 13).