diff --git a/src/ID.cc b/src/ID.cc index 5d1f2f3bc9..20172a5e54 100644 --- a/src/ID.cc +++ b/src/ID.cc @@ -217,7 +217,7 @@ void ID::SetVal(IntrusivePtr ev, init_class c) bool ID::IsRedefinable() const { - return FindAttr(ATTR_REDEF) != nullptr; + return GetAttr(ATTR_REDEF) != nullptr; } void ID::SetAttrs(IntrusivePtr a) @@ -266,14 +266,14 @@ void ID::UpdateValAttrs() } } -Attr* ID::FindAttr(attr_tag t) const +const IntrusivePtr& ID::GetAttr(attr_tag t) const { - return attrs ? attrs->Find(t).get() : nullptr; + return attrs ? attrs->Find(t) : Attr::nil; } bool ID::IsDeprecated() const { - return FindAttr(ATTR_DEPRECATED) != nullptr; + return GetAttr(ATTR_DEPRECATED) != nullptr; } void ID::MakeDeprecated(IntrusivePtr deprecation) @@ -288,7 +288,8 @@ void ID::MakeDeprecated(IntrusivePtr deprecation) std::string ID::GetDeprecationWarning() const { std::string result; - Attr* depr_attr = FindAttr(ATTR_DEPRECATED); + const auto& depr_attr = GetAttr(ATTR_DEPRECATED); + if ( depr_attr ) { auto expr = static_cast(depr_attr->GetExpr().get()); diff --git a/src/ID.h b/src/ID.h index ba63c46a03..4c7839bed9 100644 --- a/src/ID.h +++ b/src/ID.h @@ -109,7 +109,11 @@ public: [[deprecated("Remove in 4.1. Use GetAttrs().")]] Attributes* Attrs() const { return attrs.get(); } - Attr* FindAttr(attr_tag t) const; + [[deprecated("Remove in 4.1. Use GetAttr().")]] + Attr* FindAttr(attr_tag t) const + { return GetAttr(t).get(); } + + const IntrusivePtr& GetAttr(attr_tag t) const; bool IsDeprecated() const; diff --git a/src/Var.cc b/src/Var.cc index 19053bc489..5449fe939e 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -237,8 +237,8 @@ static void make_var(ID* id, IntrusivePtr t, init_class c, // intention clearly isn't to overwrite entire existing table val. c = INIT_EXTRA; - if ( init && ((c == INIT_EXTRA && id->FindAttr(ATTR_ADD_FUNC)) || - (c == INIT_REMOVE && id->FindAttr(ATTR_DEL_FUNC)) )) + if ( init && ((c == INIT_EXTRA && id->GetAttr(ATTR_ADD_FUNC)) || + (c == INIT_REMOVE && id->GetAttr(ATTR_DEL_FUNC)) )) // Just apply the function. id->SetVal(init, c); diff --git a/src/zeekygen/ScriptInfo.cc b/src/zeekygen/ScriptInfo.cc index 7249f141d3..827bac5979 100644 --- a/src/zeekygen/ScriptInfo.cc +++ b/src/zeekygen/ScriptInfo.cc @@ -219,7 +219,7 @@ void ScriptInfo::DoInitPostScript() if ( id->IsConst() ) { - if ( id->FindAttr(ATTR_REDEF) ) + if ( id->GetAttr(ATTR_REDEF) ) { DBG_LOG(DBG_ZEEKYGEN, "Filter id '%s' in '%s' as a redef_option", id->Name(), name.c_str());