-
Notifications
You must be signed in to change notification settings - Fork 275
Refactoring usage of forall_symbols
macro into c++11 loops and replacement of asserts.
#1839
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
Changes from all commits
a8319a3
f1670b2
ecbbc73
f8c2b09
357bbe4
4d33a91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,21 +19,21 @@ void print_struct_alignment_problems( | |
const symbol_tablet &symbol_table, | ||
std::ostream &out) | ||
{ | ||
forall_symbols(it, symbol_table.symbols) | ||
if(it->second.is_type && it->second.type.id()==ID_struct) | ||
for(const auto &symbol_pair : symbol_table.symbols) | ||
{ | ||
if(symbol_pair.second.is_type && symbol_pair.second.type.id() == ID_struct) | ||
{ | ||
const struct_typet &str=to_struct_type(it->second.type); | ||
const struct_typet::componentst &components=str.components(); | ||
const struct_typet &str = to_struct_type(symbol_pair.second.type); | ||
const struct_typet::componentst &components = str.components(); | ||
|
||
bool first_time_seen_in_struct=true; | ||
bool first_time_seen_in_struct = true; | ||
|
||
for(struct_typet::componentst::const_iterator | ||
it_mem=components.begin(); | ||
it_mem!=components.end(); | ||
for(struct_typet::componentst::const_iterator it_mem = components.begin(); | ||
it_mem != components.end(); | ||
it_mem++) | ||
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. Why all these whitespace changes? Makes it harder to see what are actual code changes. If cleaning up the formatting is a good idea, can you do this in a separate commit? 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. Because I ran my updates through clang-format before making each commit. I now realise these should have been kept in separate commits. 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. @hannes-steffenhagen-diffblue If you add "?w=1" to the end of the URL when viewing a diff on github then it ignores whitespace when making the diff. 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. Add to that a later use of 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. I agree that running clang-format should be done in a separate commit in this instance, as it will make the PR much easier to review. Ignoring whitespace when viewing a diff is still useful in other situations, e.g. when a conditional is introduced which changes the indentation of a large section of code. 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. Though with that flag you can no longer add comments seemingly |
||
{ | ||
mp_integer cumulated_length=0; | ||
bool first_time_seen_from=true; | ||
mp_integer cumulated_length = 0; | ||
bool first_time_seen_from = true; | ||
|
||
// if the instruction cannot be aligned to the address, | ||
// try the next one | ||
|
@@ -42,40 +42,39 @@ void print_struct_alignment_problems( | |
// || alignment(it_mem->type())%config.ansi_c.alignment!=0) | ||
continue; | ||
|
||
for(struct_typet::componentst::const_iterator | ||
it_next=it_mem; | ||
it_next!=components.end(); | ||
for(struct_typet::componentst::const_iterator it_next = it_mem; | ||
it_next != components.end(); | ||
it_next++) | ||
{ | ||
const typet &it_type=it_next->type(); | ||
const typet &it_type = it_next->type(); | ||
const namespacet ns(symbol_table); | ||
mp_integer size=pointer_offset_size(it_type, ns); | ||
mp_integer size = pointer_offset_size(it_type, ns); | ||
|
||
if(size<0) | ||
throw "type of unknown size:\n"+it_type.pretty(); | ||
if(size < 0) | ||
throw "type of unknown size:\n" + it_type.pretty(); | ||
|
||
cumulated_length+=size; | ||
cumulated_length += size; | ||
// [it_mem;it_next] cannot be covered by an instruction | ||
if(cumulated_length>config.ansi_c.memory_operand_size) | ||
if(cumulated_length > config.ansi_c.memory_operand_size) | ||
{ | ||
// if interferences have been found, no need to check with | ||
// starting from an already covered member | ||
if(!first_time_seen_from) | ||
it_mem=it_next-1; | ||
it_mem = it_next - 1; | ||
break; | ||
} | ||
|
||
if(it_mem!=it_next && !it_next->get_is_padding()) | ||
if(it_mem != it_next && !it_next->get_is_padding()) | ||
{ | ||
if(first_time_seen_in_struct) | ||
{ | ||
first_time_seen_in_struct=false; | ||
first_time_seen_from=false; | ||
first_time_seen_in_struct = false; | ||
first_time_seen_from = false; | ||
|
||
out << "\nWARNING: " | ||
<< "declaration of structure " | ||
<< str.find_type(ID_tag).pretty() | ||
<< " at " << it->second.location << '\n'; | ||
<< str.find_type(ID_tag).pretty() << " at " | ||
<< symbol_pair.second.location << '\n'; | ||
} | ||
|
||
out << "members " << it_mem->get_pretty_name() << " and " | ||
|
@@ -84,12 +83,12 @@ void print_struct_alignment_problems( | |
} | ||
} | ||
} | ||
else if(it->second.type.id()==ID_array) | ||
else if(symbol_pair.second.type.id() == ID_array) | ||
{ | ||
// is this structure likely to introduce data races? | ||
#if 0 | ||
const namespacet ns(symbol_table); | ||
const array_typet array=to_array_type(it->second.type); | ||
const array_typet array=to_array_type(symbol_pair.second.type); | ||
const mp_integer size= | ||
pointer_offset_size(array.subtype(), ns); | ||
|
||
|
@@ -100,9 +99,10 @@ void print_struct_alignment_problems( | |
{ | ||
out << "\nWARNING: " | ||
<< "declaration of an array at " | ||
<< it->second.location << | ||
<< symbol_pair.second.location << | ||
<< "\nmight be concurrently accessed\n"; | ||
} | ||
#endif | ||
} | ||
} | ||
} |
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.
Good riddance to this confusing indentation!