CBMC
|
#include <does_remove_const.h>
Public Member Functions | |
does_remove_constt (const goto_programt &) | |
A naive analysis to look for casts that remove const-ness from pointers. More... | |
std::pair< bool, source_locationt > | 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 |
Friends | |
class | does_remove_const_testt |
Definition at line 21 of file does_remove_const.h.
|
explicit |
A naive analysis to look for casts that remove const-ness from pointers.
goto_program | the goto program to check |
Definition at line 20 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 61 of file does_remove_const.cpp.
|
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 114 of file does_remove_const.cpp.
|
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 158 of file does_remove_const.cpp.
std::pair< bool, source_locationt > does_remove_constt::operator() | ( | ) | const |
A naive analysis to look for casts that remove const-ness from pointers.
Definition at line 26 of file does_remove_const.cpp.
|
friend |
Definition at line 38 of file does_remove_const.h.
|
private |
Definition at line 36 of file does_remove_const.h.