File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ does_remove_constt::does_remove_constt(
31
31
32
32
// / A naive analysis to look for casts that remove const-ness from pointers.
33
33
// / \return Returns true if the program contains a const-removing cast
34
- bool does_remove_constt::operator ()() const
34
+ std::pair< bool , source_locationt> does_remove_constt::operator ()() const
35
35
{
36
36
for (const goto_programt::instructiont &instruction :
37
37
goto_program.instructions )
@@ -49,16 +49,16 @@ bool does_remove_constt::operator()() const
49
49
// const that the lhs
50
50
if (!does_type_preserve_const_correctness (&lhs_type, &rhs_type))
51
51
{
52
- return true ;
52
+ return { true , assign. find_source_location ()} ;
53
53
}
54
54
55
55
if (does_expr_lose_const (assign.rhs ()))
56
56
{
57
- return true ;
57
+ return { true , assign. rhs (). find_source_location ()} ;
58
58
}
59
59
}
60
60
61
- return false ;
61
+ return { false , source_locationt ()} ;
62
62
}
63
63
64
64
// / Search the expression tree to look for any children that have the same base
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class does_remove_constt
22
22
{
23
23
public:
24
24
does_remove_constt (const goto_programt &goto_program, const namespacet &ns);
25
- bool operator ()() const ;
25
+ std::pair< bool , source_locationt> operator ()() const ;
26
26
27
27
private:
28
28
bool does_expr_lose_const (const exprt &expr) const ;
Original file line number Diff line number Diff line change @@ -285,9 +285,11 @@ void remove_function_pointerst::remove_function_pointer(
285
285
const exprt &pointer=function.op0 ();
286
286
remove_const_function_pointerst::functionst functions;
287
287
does_remove_constt const_removal_check (goto_program, ns);
288
- if (const_removal_check ())
288
+ const auto does_remove_const = const_removal_check ();
289
+ if (does_remove_const.first )
289
290
{
290
- warning () << " Cast from const to non-const pointer found, only worst case"
291
+ warning ().source_location = does_remove_const.second ;
292
+ warning () << " cast from const to non-const pointer found, only worst case"
291
293
<< " function pointer removal will be done." << eom;
292
294
found_functions=false ;
293
295
}
You can’t perform that action at this time.
0 commit comments