-
Notifications
You must be signed in to change notification settings - Fork 275
remove usage of typet::subtype() #6599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
12497e2
to
796d841
Compare
src/analyses/does_remove_const.cpp
Outdated
to_pointer_type(*target_type).base_type(), source_type->subtype()); | ||
// We have a pointer to something, but the thing it is pointing to can't be | ||
// modified normally, but can through this pointer | ||
if(!direct_subtypes_at_least_as_const) | ||
return false; | ||
// Check the subtypes if they are pointers | ||
target_type=&target_type->subtype(); | ||
target_type = &to_pointer_type(*target_type).base_type(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I suggest a temporary to avoid the repeated to_pointer_type(*target_type)
in this code branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/analyses/does_remove_const.cpp
Outdated
#include <util/base_type.h> | ||
#include <util/pointer_expr.h> | ||
#include <util/std_code.h> | ||
#include <util/type.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: I'm pretty sure util/type.h
does not need to be included explicitly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
{ | ||
PRECONDITION(type.id()==ID_pointer); | ||
|
||
if(type.subtype().id() == ID_struct_tag) | ||
return to_struct_tag_type(type.subtype()).get_identifier(); | ||
if(to_pointer_type(type).base_type().id() == ID_struct_tag) | ||
return to_struct_tag_type(to_pointer_type(type).base_type()) | ||
.get_identifier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please change the interface here to just take a const pointer_typet &
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/ansi-c/c_typecast.cpp
Outdated
if(src_type_id==ID_c_bit_field) | ||
return check_c_implicit_typecast(src_type.subtype(), dest_type); | ||
return check_c_implicit_typecast( | ||
to_c_bit_field_type(src_type).underlying_type(), dest_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } around the multi-line body.
src/ansi-c/c_typecast.cpp
Outdated
if(dest_type.id()==ID_c_bit_field) | ||
return check_c_implicit_typecast(src_type, dest_type.subtype()); | ||
return check_c_implicit_typecast( | ||
src_type, to_c_bit_field_type(dest_type).underlying_type()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } around the multi-line body.
if( | ||
to_reference_type(parameter1_type).base_type().get(ID_identifier) != | ||
symbol.name) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } given the multi-line condition.
if( | ||
to_reference_type(arg1_type).base_type().get(ID_identifier) != | ||
symbol.name) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } given the multi-line condition.
if( | ||
type.id() == ID_array && | ||
to_array_type(type).element_type().get_bool(ID_C_constant)) | ||
return true; | ||
|
||
return type.get_bool(ID_C_constant); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } given the multi-line condition. Or perhaps just rewrite this function to just have a return
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if( | ||
expr.type().id() == ID_array && | ||
boolbv_width(to_array_type(expr.type()).element_type()) != 0) | ||
return bvt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: would appreciate a pair of { ... } given the multi-line condition.
src/solvers/smt2/smt2_conv.cpp
Outdated
if(to_pointer_type(expr.type()).base_type().id() == ID_empty) | ||
{ | ||
// This is a gcc extension. | ||
// https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Pointer-Arith.html | ||
element_size = 1; | ||
} | ||
else | ||
{ | ||
auto element_size_opt = pointer_offset_size(expr.type().subtype(), ns); | ||
auto element_size_opt = | ||
pointer_offset_size(to_pointer_type(expr.type()).base_type(), ns); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A temporary may be useful here to avoid the repeated to_pointer_type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
b22be30
to
f87a099
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6599 +/- ##
===========================================
- Coverage 76.65% 76.64% -0.01%
===========================================
Files 1579 1579
Lines 181294 181480 +186
===========================================
+ Hits 138973 139098 +125
- Misses 42321 42382 +61
Continue to review full report at Codecov.
|
ad15521
to
19c3981
Compare
This commit replaces invocations of typet::subtype() by the appropriate methods offered by the more specific types, e.g., pointer_typet, array_typet, and so on.
19c3981
to
3b27b76
Compare
This commit replaces invocations of
typet::subtype()
by the appropriatemethods offered by the more specific types, e.g.,
pointer_typet
,array_typet
, and so on.