File tree 5 files changed +38
-0
lines changed
regression/goto-cc-multi-file/maintain-location
5 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ int foo ()
2
+ {
3
+ return 0 ;
4
+ }
5
+
6
+ int main ()
7
+ {
8
+ int result ;
9
+ result = foo ();
10
+ return result ;
11
+ }
Original file line number Diff line number Diff line change
1
+ int foo ();
2
+
3
+ int bar ()
4
+ {
5
+ return foo ();
6
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ other.c
4
+ file main.c line 9 function main
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ --
8
+ --
9
+ We previously lost the location attached to the call of `foo` in function main.
Original file line number Diff line number Diff line change @@ -100,13 +100,16 @@ bool casting_replace_symbolt::replace_symbol_expr(symbol_exprt &s) const
100
100
101
101
const exprt &e = it->second ;
102
102
103
+ source_locationt previous_source_location{s.source_location ()};
103
104
if (e.type ().id () != ID_array && e.type ().id () != ID_code)
104
105
{
105
106
typet type = s.type ();
106
107
static_cast <exprt &>(s) = typecast_exprt::conditional_cast (e, type);
107
108
}
108
109
else
109
110
static_cast <exprt &>(s) = e;
111
+ if (previous_source_location.is_not_nil ())
112
+ s.add_source_location () = std::move (previous_source_location);
110
113
111
114
return false ;
112
115
}
Original file line number Diff line number Diff line change @@ -51,7 +51,10 @@ bool replace_symbolt::replace_symbol_expr(symbol_exprt &s) const
51
51
s.type () == it->second .type (),
52
52
" types to be replaced should match. s.type:\n " + s.type ().pretty () +
53
53
" \n it->second.type:\n " + it->second .type ().pretty ());
54
+ source_locationt previous_source_location{s.source_location ()};
54
55
static_cast <exprt &>(s) = it->second ;
56
+ if (previous_source_location.is_not_nil ())
57
+ s.add_source_location () = std::move (previous_source_location);
55
58
56
59
return false ;
57
60
}
@@ -334,7 +337,10 @@ bool unchecked_replace_symbolt::replace_symbol_expr(symbol_exprt &s) const
334
337
if (it == expr_map.end ())
335
338
return true ;
336
339
340
+ source_locationt previous_source_location{s.source_location ()};
337
341
static_cast <exprt &>(s) = it->second ;
342
+ if (previous_source_location.is_not_nil ())
343
+ s.add_source_location () = std::move (previous_source_location);
338
344
339
345
return false ;
340
346
}
@@ -415,7 +421,10 @@ bool address_of_aware_replace_symbolt::replace_symbol_expr(
415
421
416
422
// Note s_copy is no longer a symbol_exprt due to the replace operation,
417
423
// and after this line `s` won't be either
424
+ source_locationt previous_source_location{s.source_location ()};
418
425
s = s_copy;
426
+ if (previous_source_location.is_not_nil ())
427
+ s.add_source_location () = std::move (previous_source_location);
419
428
420
429
return false ;
421
430
}
You can’t perform that action at this time.
0 commit comments