mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
factoring out logic to check for overflows during coercions
This commit is contained in:
parent
9757d37332
commit
a67897135e
8 changed files with 89 additions and 37 deletions
|
@ -2134,8 +2134,6 @@ ExprPtr ArithCoerceExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
|
|||
if ( ! op->IsReduced(c) )
|
||||
op = op->ReduceToSingleton(c, red_stmt);
|
||||
|
||||
auto t = type->InternalType();
|
||||
|
||||
if ( op->Tag() == EXPR_CONST )
|
||||
{
|
||||
const auto& t = GetType();
|
||||
|
@ -2153,9 +2151,18 @@ ExprPtr ArithCoerceExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
|
|||
if ( c->Optimizing() )
|
||||
return ThisPtr();
|
||||
|
||||
auto bt = op->GetType()->InternalType();
|
||||
const auto& ot = op->GetType();
|
||||
auto bt = ot->InternalType();
|
||||
auto tt = type->InternalType();
|
||||
|
||||
if ( t == bt )
|
||||
if ( ot->Tag() == TYPE_VECTOR )
|
||||
{
|
||||
bt = ot->Yield()->InternalType();
|
||||
tt = type->Yield()->InternalType();
|
||||
}
|
||||
|
||||
if ( bt == tt )
|
||||
// Can drop the conversion.
|
||||
return op;
|
||||
|
||||
return AssignToTemporary(c, red_stmt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue