Expr: use class IntrusivePtr

As a side effect, this fixes lots of memory leaks in
`*Expr::InitVal()` because in most implementations, the `aggr`
parameter leaks.
This commit is contained in:
Max Kellermann 2020-02-26 19:12:57 +01:00
parent 7be3641f1d
commit c3ea246237
17 changed files with 885 additions and 1206 deletions

View file

@ -815,7 +815,7 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
return false;
}
Val* fmt_str_val = fmt_str_arg->Eval(0);
auto fmt_str_val = fmt_str_arg->Eval(0);
if ( fmt_str_val )
{
@ -829,7 +829,6 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
if ( ! *fmt_str )
{
Unref(fmt_str_val);
call->Error("format string ends with bare '%'");
return false;
}
@ -841,13 +840,11 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
if ( args.length() != num_fmt + 1 )
{
Unref(fmt_str_val);
call->Error("mismatch between format string to fmt() and number of arguments passed");
return false;
}
}
Unref(fmt_str_val);
return true;
}
@ -868,7 +865,7 @@ static int get_func_priority(const attr_list& attrs)
continue;
}
Val* v = a->AttrExpr()->Eval(0);
auto v = a->AttrExpr()->Eval(0);
if ( ! v )
{
a->Error("cannot evaluate attribute expression");
@ -877,13 +874,11 @@ static int get_func_priority(const attr_list& attrs)
if ( ! IsIntegral(v->Type()->Tag()) )
{
Unref(v);
a->Error("expression is not of integral type");
continue;
}
priority = v->InternalInt();
Unref(v);
}
return priority;