cprover
|
#include <does_remove_const.h>
Public Member Functions | |
does_remove_constt (const goto_programt &goto_program, const namespacet &ns) | |
A naive analysis to look for casts that remove const-ness from pointers. More... | |
bool | operator() () const |
A naive analysis to look for casts that remove const-ness from pointers. More... | |
Private Member Functions | |
bool | does_expr_lose_const (const exprt &expr) const |
Search the expression tree to look for any children that have the same base type, but a less strict const qualification. More... | |
bool | is_type_at_least_as_const_as (const typet &type_more_const, const typet &type_compare) const |
A simple check to check the type_more_const is at least as const as type compare. More... | |
bool | does_type_preserve_const_correctness (const typet *target_type, const typet *source_type) const |
A recursive check that handles when assigning a source value to a target, is the assignment a loss of const-correctness. More... | |
Private Attributes | |
const goto_programt & | goto_program |
const namespacet & | ns |
Friends | |
class | does_remove_const_testt |
Definition at line 21 of file does_remove_const.h.
does_remove_constt::does_remove_constt | ( | const goto_programt & | goto_program, |
const namespacet & | ns | ||
) |
A naive analysis to look for casts that remove const-ness from pointers.
goto_program | the goto program to check |
ns | the namespace of the goto program (used for checking type equality) |
Definition at line 25 of file does_remove_const.cpp.
|
private |
Search the expression tree to look for any children that have the same base type, but a less strict const qualification.
If one is found, we return true.
expr | The expression to check |
Definition at line 70 of file does_remove_const.cpp.
References base_type_eq(), does_type_preserve_const_correctness(), ns, exprt::operands(), and exprt::type().
Referenced by operator()().
|
private |
A recursive check that handles when assigning a source value to a target, is the assignment a loss of const-correctness.
For primitive types, it always returns true since these are copied
For pointers we requires that if in the source it's value couldn't be modified, then it still can't be modified in the target
const int | int -> true int | const int -> true const int | const int -> true int | int -> true
int * | int * const -> true int * | const int * -> false const int * | int * -> true const int * | const int * -> true int * const | int * -> true
See unit/analyses/does_type_preserve_const_correcness for comprehensive list
target_type | the resulting type |
source_type | the starting type |
Definition at line 123 of file does_remove_const.cpp.
References irept::id(), is_type_at_least_as_const_as(), and typet::subtype().
Referenced by does_expr_lose_const(), and operator()().
|
private |
A simple check to check the type_more_const is at least as const as type compare.
This only checks the exact type, use is_pointer_at_least_as_constant_as
for dealing with nested types
const int | int -> true int | const int -> false const int | const int -> true int | int -> true int * | int * const -> false int * | const int * -> true const int * | int * -> true int * const | int * -> true
See unit/analyses/is_type_as_least_as_const_as for comprehensive list
type_more_const | the type we are expecting to be at least as const qualified |
type_compare | the type we are comparing against which may be less const qualified |
Definition at line 163 of file does_remove_const.cpp.
References c_qualifierst::is_constant.
Referenced by does_type_preserve_const_correctness().
bool does_remove_constt::operator() | ( | ) | const |
A naive analysis to look for casts that remove const-ness from pointers.
Definition at line 34 of file does_remove_const.cpp.
References does_expr_lose_const(), does_type_preserve_const_correctness(), goto_program, goto_program_templatet< codeT, guardT >::instructions, code_assignt::lhs(), code_assignt::rhs(), to_code_assign(), and exprt::type().
|
friend |
Definition at line 39 of file does_remove_const.h.
|
private |
Definition at line 36 of file does_remove_const.h.
Referenced by operator()().
|
private |
Definition at line 37 of file does_remove_const.h.
Referenced by does_expr_lose_const().