Skip to content

Commit 5acadac

Browse files
committed
remove_vector: maintain source location
Newly created expressions did not have a source location, which may, however, be useful in debugging.
1 parent b7859de commit 5acadac

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/goto-programs/remove_vector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static void remove_vector(exprt &expr)
103103
// x+y -> vector(x[0]+y[0],x[1]+y[1],...)
104104
array_exprt array_expr({}, array_type);
105105
array_expr.operands().resize(numeric_cast_v<std::size_t>(dimension));
106+
array_expr.add_source_location() = expr.source_location();
106107

107108
for(std::size_t i=0; i<array_expr.operands().size(); i++)
108109
{
@@ -130,6 +131,7 @@ static void remove_vector(exprt &expr)
130131
// -x -> vector(-x[0],-x[1],...)
131132
array_exprt array_expr({}, array_type);
132133
array_expr.operands().resize(numeric_cast_v<std::size_t>(dimension));
134+
array_expr.add_source_location() = expr.source_location();
133135

134136
for(std::size_t i=0; i<array_expr.operands().size(); i++)
135137
{
@@ -158,7 +160,9 @@ static void remove_vector(exprt &expr)
158160
numeric_cast_v<std::size_t>(to_constant_expr(array_type.size()));
159161
exprt casted_op =
160162
typecast_exprt::conditional_cast(op, array_type.subtype());
163+
source_locationt source_location = expr.source_location();
161164
expr = array_exprt(exprt::operandst(dimension, casted_op), array_type);
165+
expr.add_source_location() = std::move(source_location);
162166
}
163167
}
164168
}

0 commit comments

Comments
 (0)