mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Expr: check_and_promote_expr() returns IntrusivePtr
Instead of returning a pseudo-boolean integer, it now returns a referenced object or nullptr on error. The old API was very error prone because of its obscure reference counting semantics.
This commit is contained in:
parent
78e736621c
commit
097a362c80
4 changed files with 56 additions and 46 deletions
19
src/Attr.cc
19
src/Attr.cc
|
@ -315,10 +315,10 @@ void Attributes::CheckAttr(Attr* a)
|
|||
// Ok.
|
||||
break;
|
||||
|
||||
Expr* e = a->AttrExpr();
|
||||
if ( check_and_promote_expr(e, type) )
|
||||
auto e = check_and_promote_expr(a->AttrExpr(), type);
|
||||
if ( e )
|
||||
{
|
||||
a->SetAttrExpr(e);
|
||||
a->SetAttrExpr(e.release());
|
||||
// Ok.
|
||||
break;
|
||||
}
|
||||
|
@ -354,10 +354,10 @@ void Attributes::CheckAttr(Attr* a)
|
|||
// Ok.
|
||||
break;
|
||||
|
||||
Expr* e = a->AttrExpr();
|
||||
if ( check_and_promote_expr(e, ytype) )
|
||||
auto e = check_and_promote_expr(a->AttrExpr(), ytype);
|
||||
if ( e )
|
||||
{
|
||||
a->SetAttrExpr(e);
|
||||
a->SetAttrExpr(e.release());
|
||||
// Ok.
|
||||
break;
|
||||
}
|
||||
|
@ -379,11 +379,10 @@ void Attributes::CheckAttr(Attr* a)
|
|||
|
||||
if ( (atype->Tag() == TYPE_TABLE && atype->AsTableType()->IsUnspecifiedTable()) )
|
||||
{
|
||||
Expr* e = a->AttrExpr();
|
||||
|
||||
if ( check_and_promote_expr(e, type) )
|
||||
auto e = check_and_promote_expr(a->AttrExpr(), type);
|
||||
if ( e )
|
||||
{
|
||||
a->SetAttrExpr(e);
|
||||
a->SetAttrExpr(e.release());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue