-
Notifications
You must be signed in to change notification settings - Fork 283
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++) | ||
|
||
{ | ||
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!