Skip to content

Construction of with expression in lowering/byte_operators.cpp does not match getters in with_exprt [rfc] #7272

Open
@thomasspriggs

Description

@thomasspriggs

This section constructs a with expression containing multiple where/new value pairs -

if(result.id() != ID_with)
result = with_exprt{result, std::move(where), std::move(update_value)};
else
result.add_to_operands(std::move(where), std::move(update_value));

However the API here only provides access to a single where/new value pair -

cbmc/src/util/std_expr.h

Lines 2444 to 2462 in 8bd2617

exprt &where()
{
return op1();
}
const exprt &where() const
{
return op1();
}
exprt &new_value()
{
return op2();
}
const exprt &new_value() const
{
return op2();
}

What should be the preferred way to deal with this mismatch?
A. Update the lowering to nest with expressions rather than constructing a single expression with multiple pairs.
B. Update with_exprt to expose the possibility of multiple pairs.
C. Work around the mismatch for the moment using exprt::operands to access the additional pairs.
I am not a huge fan of option C as it leaves the possibility of multiple pairs relatively surprising when referring to with_exprt. Option A seems relatively preferable as it keeps the API simpler, however I have also presented option B in case there are performance reasons for preferring more operands over more deeply nested expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for commentVersion 6Pull requests and issues requiring a major version bump

    Type

    No type

    Projects

    Status

    Candidates

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions