ID: Add AddAttr() helper

This is just a follow-up as code cleanup, but not required
to be backported to 5.1.
This commit is contained in:
Arne Welzel 2022-12-02 17:57:07 +01:00
parent ef920ef3f5
commit da5fdb2072
5 changed files with 13 additions and 17 deletions

View file

@ -311,8 +311,7 @@ void ID::MakeDeprecated(ExprPtr deprecation)
if ( IsDeprecated() )
return;
std::vector<AttrPtr> attrv{make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation))};
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
AddAttr(make_intrusive<Attr>(ATTR_DEPRECATED, std::move(deprecation)));
}
std::string ID::GetDeprecationWarning() const
@ -329,6 +328,13 @@ std::string ID::GetDeprecationWarning() const
return util::fmt("deprecated (%s): %s", Name(), result.c_str());
}
void ID::AddAttr(AttrPtr a, bool is_redef)
{
std::vector<AttrPtr> attrv{std::move(a)};
auto attrs = make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal());
AddAttrs(std::move(attrs), is_redef);
}
void ID::AddAttrs(AttributesPtr a, bool is_redef)
{
if ( attrs )
@ -354,10 +360,7 @@ void ID::SetOption()
// option implied redefinable
if ( ! IsRedefinable() )
{
std::vector<AttrPtr> attrv{make_intrusive<Attr>(ATTR_REDEF)};
AddAttrs(make_intrusive<Attributes>(std::move(attrv), GetType(), false, IsGlobal()));
}
AddAttr(make_intrusive<Attr>(ATTR_REDEF));
}
void ID::EvalFunc(ExprPtr ef, ExprPtr ev)