-
Notifications
You must be signed in to change notification settings - Fork 273
remove uses of base_type_eq #6989
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,13 @@ Author: Diffblue Ltd. | |
|
||
#include <goto-programs/goto_program.h> | ||
|
||
#include <util/base_type.h> | ||
#include <util/pointer_expr.h> | ||
#include <util/std_code.h> | ||
|
||
/// A naive analysis to look for casts that remove const-ness from pointers. | ||
/// \param goto_program: the goto program to check | ||
/// \param ns: the namespace of the goto program (used for checking type | ||
/// equality) | ||
does_remove_constt::does_remove_constt( | ||
const goto_programt &goto_program, | ||
const namespacet &ns): | ||
goto_program(goto_program), | ||
ns(ns) | ||
does_remove_constt::does_remove_constt(const goto_programt &goto_program) | ||
: goto_program(goto_program) | ||
{} | ||
|
||
/// A naive analysis to look for casts that remove const-ness from pointers. | ||
|
@@ -69,11 +63,11 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const | |
{ | ||
const typet &root_type=expr.type(); | ||
|
||
// Look in each child that has the same base type as the root | ||
// Look in each child that has the same type as the root | ||
for(const exprt &op : expr.operands()) | ||
{ | ||
const typet &op_type=op.type(); | ||
if(base_type_eq(op_type, root_type, ns)) | ||
if(op_type == root_type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this change the |
||
{ | ||
// Is this child more const-qualified than the root | ||
if(!does_type_preserve_const_correctness(&root_type, &op_type)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <iomanip> | ||
|
||
#include <util/base_type.h> | ||
#include <util/expr_iterator.h> | ||
#include <util/find_symbols.h> | ||
#include <util/format_expr.h> | ||
|
@@ -808,7 +807,7 @@ void goto_programt::instructiont::validate( | |
if(!ns.lookup(goto_id, table_symbol)) | ||
{ | ||
bool symbol_expr_type_matches_symbol_table = | ||
base_type_eq(goto_symbol_expr.type(), table_symbol->type, ns); | ||
goto_symbol_expr.type() == table_symbol->type; | ||
|
||
if( | ||
!symbol_expr_type_matches_symbol_table && | ||
|
@@ -831,7 +830,7 @@ void goto_programt::instructiont::validate( | |
table_symbol_type.return_type(); | ||
|
||
symbol_expr_type_matches_symbol_table = | ||
base_type_eq(goto_symbol_expr_type, table_symbol_type, ns); | ||
goto_symbol_expr_type == table_symbol_type; | ||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ Author: Daniel Kroening, [email protected] | |
#include <deque> | ||
#include <unordered_set> | ||
|
||
#include <util/base_type.h> | ||
#include <util/c_types.h> | ||
#include <util/find_symbols.h> | ||
#include <util/mathematical_types.h> | ||
|
@@ -150,10 +149,8 @@ void linkingt::detailed_conflict_report_rec( | |
t1.id()==ID_array) | ||
{ | ||
if( | ||
depth > 0 && !base_type_eq( | ||
to_type_with_subtype(t1).subtype(), | ||
to_type_with_subtype(t2).subtype(), | ||
ns)) | ||
depth > 0 && | ||
to_type_with_subtype(t1).subtype() != to_type_with_subtype(t2).subtype()) | ||
{ | ||
if(conflict_path.type().id() == ID_pointer) | ||
conflict_path = dereference_exprt(conflict_path); | ||
|
@@ -202,7 +199,7 @@ void linkingt::detailed_conflict_report_rec( | |
msg+=id2string(components2[i].get_name())+')'; | ||
break; | ||
} | ||
else if(!base_type_eq(subtype1, subtype2, ns)) | ||
else if(subtype1 != subtype2) | ||
{ | ||
typedef std::unordered_set<typet, irep_hash> type_sett; | ||
type_sett parent_types; | ||
|
@@ -332,7 +329,7 @@ void linkingt::detailed_conflict_report_rec( | |
msg+=std::to_string(parameters1.size())+'/'; | ||
msg+=std::to_string(parameters2.size())+')'; | ||
} | ||
else if(!base_type_eq(return_type1, return_type2, ns)) | ||
else if(return_type1 != return_type2) | ||
{ | ||
conflict_path= | ||
index_exprt(conflict_path, | ||
|
@@ -356,7 +353,7 @@ void linkingt::detailed_conflict_report_rec( | |
const typet &subtype1=parameters1[i].type(); | ||
const typet &subtype2=parameters2[i].type(); | ||
|
||
if(!base_type_eq(subtype1, subtype2, ns)) | ||
if(subtype1 != subtype2) | ||
{ | ||
conflict_path= | ||
index_exprt(conflict_path, | ||
|
@@ -475,7 +472,7 @@ void linkingt::duplicate_code_symbol( | |
symbolt &new_symbol) | ||
{ | ||
// Both are functions. | ||
if(!base_type_eq(old_symbol.type, new_symbol.type, ns)) | ||
if(old_symbol.type != new_symbol.type) | ||
{ | ||
const code_typet &old_t=to_code_type(old_symbol.type); | ||
const code_typet &new_t=to_code_type(new_symbol.type); | ||
|
@@ -486,11 +483,8 @@ void linkingt::duplicate_code_symbol( | |
// casts we need to fail hard | ||
if(old_symbol.type.get_bool(ID_C_incomplete) && old_symbol.value.is_nil()) | ||
{ | ||
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns)) | ||
link_warning( | ||
old_symbol, | ||
new_symbol, | ||
"implicit function declaration"); | ||
if(old_t.return_type() == new_t.return_type()) | ||
link_warning(old_symbol, new_symbol, "implicit function declaration"); | ||
else | ||
link_error( | ||
old_symbol, | ||
|
@@ -504,7 +498,7 @@ void linkingt::duplicate_code_symbol( | |
else if( | ||
new_symbol.type.get_bool(ID_C_incomplete) && new_symbol.value.is_nil()) | ||
{ | ||
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns)) | ||
if(old_t.return_type() == new_t.return_type()) | ||
link_warning( | ||
old_symbol, | ||
new_symbol, | ||
|
@@ -516,13 +510,12 @@ void linkingt::duplicate_code_symbol( | |
"implicit function declaration"); | ||
} | ||
// handle (incomplete) function prototypes | ||
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) && | ||
((old_t.parameters().empty() && | ||
old_t.has_ellipsis() && | ||
old_symbol.value.is_nil()) || | ||
(new_t.parameters().empty() && | ||
new_t.has_ellipsis() && | ||
new_symbol.value.is_nil()))) | ||
else if( | ||
old_t.return_type() == new_t.return_type() && | ||
((old_t.parameters().empty() && old_t.has_ellipsis() && | ||
old_symbol.value.is_nil()) || | ||
(new_t.parameters().empty() && new_t.has_ellipsis() && | ||
new_symbol.value.is_nil()))) | ||
{ | ||
if(old_t.parameters().empty() && | ||
old_t.has_ellipsis() && | ||
|
@@ -572,9 +565,9 @@ void linkingt::duplicate_code_symbol( | |
} | ||
// conflicting declarations without a definition, matching return | ||
// types | ||
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) && | ||
old_symbol.value.is_nil() && | ||
new_symbol.value.is_nil()) | ||
else if( | ||
old_t.return_type() == new_t.return_type() && old_symbol.value.is_nil() && | ||
new_symbol.value.is_nil()) | ||
{ | ||
link_warning( | ||
old_symbol, | ||
|
@@ -613,7 +606,7 @@ void linkingt::duplicate_code_symbol( | |
typedef std::deque<std::pair<typet, typet> > conflictst; | ||
conflictst conflicts; | ||
|
||
if(!base_type_eq(old_t.return_type(), new_t.return_type(), ns)) | ||
if(old_t.return_type() != new_t.return_type()) | ||
conflicts.push_back( | ||
std::make_pair(old_t.return_type(), new_t.return_type())); | ||
|
||
|
@@ -625,7 +618,7 @@ void linkingt::duplicate_code_symbol( | |
n_it!=new_t.parameters().end(); | ||
++o_it, ++n_it) | ||
{ | ||
if(!base_type_eq(o_it->type(), n_it->type(), ns)) | ||
if(o_it->type() != n_it->type()) | ||
conflicts.push_back( | ||
std::make_pair(o_it->type(), n_it->type())); | ||
} | ||
|
@@ -718,7 +711,7 @@ void linkingt::duplicate_code_symbol( | |
|
||
bool found=false; | ||
for(const auto &c : union_type.components()) | ||
if(base_type_eq(c.type(), src_type, ns)) | ||
if(c.type() == src_type) | ||
{ | ||
found=true; | ||
if(warn_msg.empty()) | ||
|
@@ -793,7 +786,7 @@ void linkingt::duplicate_code_symbol( | |
{ | ||
// ok, silently ignore | ||
} | ||
else if(base_type_eq(old_symbol.type, new_symbol.type, ns)) | ||
else if(old_symbol.type == new_symbol.type) | ||
{ | ||
// keep the one in old_symbol -- libraries come last! | ||
debug().source_location = new_symbol.location; | ||
|
@@ -816,7 +809,7 @@ bool linkingt::adjust_object_type_rec( | |
const typet &t2, | ||
adjust_type_infot &info) | ||
{ | ||
if(base_type_eq(t1, t2, ns)) | ||
if(t1 == t2) | ||
return false; | ||
|
||
if( | ||
|
@@ -1025,7 +1018,7 @@ void linkingt::duplicate_object_symbol( | |
// both are variables | ||
bool set_to_new = false; | ||
|
||
if(!base_type_eq(old_symbol.type, new_symbol.type, ns)) | ||
if(old_symbol.type != new_symbol.type) | ||
{ | ||
bool failed= | ||
adjust_object_type(old_symbol, new_symbol, set_to_new); | ||
|
@@ -1081,7 +1074,7 @@ void linkingt::duplicate_object_symbol( | |
simplify(tmp_old, ns); | ||
simplify(tmp_new, ns); | ||
|
||
if(base_type_eq(tmp_old, tmp_new, ns)) | ||
if(tmp_old == tmp_new) | ||
{ | ||
// ok, the same | ||
} | ||
|
@@ -1211,10 +1204,8 @@ void linkingt::duplicate_type_symbol( | |
|
||
if( | ||
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array && | ||
base_type_eq( | ||
to_array_type(old_symbol.type).element_type(), | ||
to_array_type(new_symbol.type).element_type(), | ||
ns)) | ||
to_array_type(old_symbol.type).element_type() == | ||
to_array_type(new_symbol.type).element_type()) | ||
{ | ||
if(to_array_type(old_symbol.type).size().is_nil() && | ||
to_array_type(new_symbol.type).size().is_not_nil()) | ||
|
@@ -1286,10 +1277,8 @@ bool linkingt::needs_renaming_type( | |
|
||
if( | ||
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array && | ||
base_type_eq( | ||
to_array_type(old_symbol.type).element_type(), | ||
to_array_type(new_symbol.type).element_type(), | ||
ns)) | ||
to_array_type(old_symbol.type).element_type() == | ||
to_array_type(new_symbol.type).element_type()) | ||
{ | ||
if(to_array_type(old_symbol.type).size().is_nil() && | ||
to_array_type(new_symbol.type).size().is_not_nil()) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thank you for adding this commit. The documentation above, however, also needs to be updated (removing lines 21 and 22) to keep doxygen happy.