mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
support for associating &is_used attributes with functions
This commit is contained in:
parent
91f1ecd1ff
commit
763b448aef
1 changed files with 18 additions and 2 deletions
20
src/Func.cc
20
src/Func.cc
|
@ -864,7 +864,7 @@ static int get_func_priority(const std::vector<AttrPtr>& attrs)
|
|||
|
||||
for ( const auto& a : attrs )
|
||||
{
|
||||
if ( a->Tag() == ATTR_DEPRECATED )
|
||||
if ( a->Tag() == ATTR_DEPRECATED || a->Tag() == ATTR_IS_USED )
|
||||
continue;
|
||||
|
||||
if ( a->Tag() != ATTR_PRIORITY )
|
||||
|
@ -903,7 +903,23 @@ function_ingredients::function_ingredients(ScopePtr scope, StmtPtr body)
|
|||
|
||||
const auto& attrs = this->scope->Attrs();
|
||||
|
||||
priority = (attrs ? get_func_priority(*attrs) : 0);
|
||||
if ( attrs )
|
||||
{
|
||||
priority = get_func_priority(*attrs);
|
||||
|
||||
for ( const auto& a : *attrs )
|
||||
if ( a->Tag() == ATTR_IS_USED )
|
||||
{
|
||||
// Associate this with the identifier, too.
|
||||
std::vector<AttrPtr> used_attr;
|
||||
used_attr.emplace_back(make_intrusive<Attr>(ATTR_IS_USED));
|
||||
id->AddAttrs(make_intrusive<Attributes>(used_attr, nullptr, false, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
priority = 0;
|
||||
|
||||
this->body = std::move(body);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue