Loading...
Searching...
No Matches
does_remove_constt Class Reference
#include <does_remove_const.h>
+ Collaboration diagram for does_remove_constt:
A naive analysis to look for casts that remove const-ness from pointers.
A naive analysis to look for casts that remove const-ness from pointers.
Search the expression tree to look for any children that have the same base type, but a less strict const qualification.
A simple check to check the type_more_const is at least as const as type compare.
A recursive check that handles when assigning a source value to a target, is the assignment a loss of const-correctness.
Detailed Description
Constructor & Destructor Documentation
◆ does_remove_constt()
A naive analysis to look for casts that remove const-ness from pointers.
- Parameters
-
goto_program the goto program to check
Definition at line 20 of file does_remove_const.cpp.
Member Function Documentation
◆ does_expr_lose_const()
bool does_remove_constt::does_expr_lose_const
(
const exprt &
expr )
const
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.
- Parameters
-
expr The expression to check
- Returns
- Returns true if somewhere in the passed expression tree the const- ness is lost.
Definition at line 61 of file does_remove_const.cpp.
◆ does_type_preserve_const_correctness()
bool does_remove_constt::does_type_preserve_const_correctness
(
const typet *
target_type,
)
const
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
target_type | source_type || result
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
- Parameters
-
target_type the resulting type
source_type the starting type
- Returns
- Returns true if a value of type source_type could be assigned into a a value of target_type without losing const-correctness
Definition at line 114 of file does_remove_const.cpp.
◆ is_type_at_least_as_const_as()
bool does_remove_constt::is_type_at_least_as_const_as
(
const typet &
type_more_const,
)
const
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
type_more_const | type_compare || result
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
- Parameters
-
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
- Returns
- Returns true if type_more_const is at least as const as type_compare
Definition at line 158 of file does_remove_const.cpp.
◆ operator()()
A naive analysis to look for casts that remove const-ness from pointers.
- Returns
- Returns true if the program contains a const-removing cast
Definition at line 26 of file does_remove_const.cpp.
Friends And Related Symbol Documentation
◆ does_remove_const_testt
Member Data Documentation
◆ goto_program
The documentation for this class was generated from the following files: