Skip to content

Commit 075a562

Browse files
author
thk123
committed
Cleanup changes
Using range based for loops inside the expr2c changes Removed single depth typedefs and replaced with line breaks
1 parent cc02062 commit 075a562

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/ansi-c/expr2c.cpp

+20-21
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ Function: expr2ct::convert_struct_type
706706
declarator - the declarator on the type
707707
inc_struct_body - when generating the code, should we include
708708
a complete definition of the struct
709-
inc_padding_parameters - should the padding parameters be included
709+
inc_padding_components - should the padding parameters be included
710710
Note this only makes sense if inc_struct_body
711711
712712
Outputs: Returns a type declaration for a struct, optionally containing the
@@ -721,12 +721,12 @@ std::string expr2ct::convert_struct_type(
721721
const std::string &qualifiers,
722722
const std::string &declarator,
723723
bool inc_struct_body,
724-
bool inc_padding_parameters)
724+
bool inc_padding_components)
725725
{
726726
// Either we are including the body (in which case it makes sense to include
727727
// or exclude the parameters) or there is no body so therefore we definitely
728728
// shouldn't be including the parameters
729-
assert(inc_struct_body || !inc_padding_parameters);
729+
assert(inc_struct_body || !inc_padding_components);
730730

731731
const struct_typet &struct_type=to_struct_type(src);
732732

@@ -740,20 +740,21 @@ std::string expr2ct::convert_struct_type(
740740
{
741741
dest+=" {";
742742

743-
for(struct_typet::componentst::const_iterator
744-
it=struct_type.components().begin();
745-
it!=struct_type.components().end();
746-
it++)
743+
for(const struct_union_typet::componentt &component :
744+
struct_type.components())
747745
{
748746
// Skip padding parameters unless we including them
749-
if(it->get_is_padding() && !inc_padding_parameters)
747+
if(component.get_is_padding() && !inc_padding_components)
750748
{
751749
continue;
752750
}
753751

754-
dest+= ' ';
755-
dest+=convert_rec(it->type(), c_qualifierst(), id2string(it->get_name()));
756-
dest+= ';';
752+
dest+=' ';
753+
dest+=convert_rec(
754+
component.type(),
755+
c_qualifierst(),
756+
id2string(component.get_name()));
757+
dest+=';';
757758
}
758759

759760
dest+=" }";
@@ -2267,7 +2268,7 @@ std::string expr2ct::convert_constant(
22672268
}
22682269
else if(type.id()==ID_bool)
22692270
{
2270-
dest = convert_constant_bool(src.is_true());
2271+
dest=convert_constant_bool(src.is_true());
22712272
}
22722273
else if(type.id()==ID_unsignedbv ||
22732274
type.id()==ID_signedbv ||
@@ -2283,7 +2284,7 @@ std::string expr2ct::convert_constant(
22832284

22842285
if(type.id()==ID_c_bool)
22852286
{
2286-
dest = convert_constant_bool(int_value != 0);
2287+
dest=convert_constant_bool(int_value!=0);
22872288
}
22882289
else if(type==char_type() && type!=signed_int_type() && type!=unsigned_int_type())
22892290
{
@@ -2482,7 +2483,7 @@ Function: expr2ct::convert_struct
24822483
Inputs:
24832484
src - The struct declaration expression
24842485
precedence
2485-
include_padding_members - Should the generated C code
2486+
include_padding_components - Should the generated C code
24862487
include the padding members added
24872488
to structs for GOTOs benifit
24882489
@@ -2495,7 +2496,7 @@ Function: expr2ct::convert_struct
24952496
std::string expr2ct::convert_struct(
24962497
const exprt &src,
24972498
unsigned &precedence,
2498-
bool include_padding_members)
2499+
bool include_padding_components)
24992500
{
25002501
const typet full_type=ns.follow(src.type());
25012502

@@ -2519,15 +2520,13 @@ std::string expr2ct::convert_struct(
25192520
bool newline=false;
25202521
size_t last_size=0;
25212522

2522-
for(struct_typet::componentst::const_iterator
2523-
c_it=components.begin();
2524-
c_it!=components.end();
2525-
c_it++)
2523+
for(const struct_union_typet::componentt &component :
2524+
struct_type.components())
25262525
{
25272526
if(o_it->type().id()==ID_code)
25282527
continue;
25292528

2530-
if(c_it->get_is_padding() && !include_padding_members)
2529+
if(component.get_is_padding() && !include_padding_components)
25312530
{
25322531
++o_it;
25332532
continue;
@@ -2556,7 +2555,7 @@ std::string expr2ct::convert_struct(
25562555
newline=false;
25572556

25582557
dest+='.';
2559-
dest+=c_it->get_string(ID_name);
2558+
dest+=component.get_string(ID_name);
25602559
dest+='=';
25612560
dest+=tmp;
25622561

src/ansi-c/expr2c_class.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class expr2ct
4848
const std::string &qualifer_str,
4949
const std::string &declarator_str,
5050
bool inc_struct_body,
51-
bool inc_padding_parameters);
51+
bool inc_padding_components);
5252

5353
virtual std::string convert_array_type(
5454
const typet &src,
@@ -237,7 +237,7 @@ class expr2ct
237237
std::string convert_struct(
238238
const exprt &src,
239239
unsigned &precedence,
240-
bool include_padding_members);
240+
bool include_padding_components);
241241
};
242242

243243
#endif // CPROVER_ANSI_C_EXPR2C_CLASS_H

0 commit comments

Comments
 (0)