Skip to content

Commit 2314c77

Browse files
author
Remi Delmas
committed
Format fixes
1 parent 3fb0e70 commit 2314c77

File tree

3 files changed

+66
-74
lines changed

3 files changed

+66
-74
lines changed

src/analyses/goto_check.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,8 +1856,8 @@ optionalt<exprt> goto_checkt::rw_ok_check(exprt expr)
18561856
class flag_resett
18571857
{
18581858
public:
1859-
1860-
/// \brief Store the current value of \p flag and then set its value to \p new_value.
1859+
/// \brief Store the current value of \p flag and
1860+
/// then set its value to \p new_value.
18611861
/// \returns true if the flag was already seen before
18621862
bool set_flag(bool &flag, bool new_value)
18631863
{
@@ -1877,7 +1877,8 @@ class flag_resett
18771877
return seen_flags.find(&flag) != seen_flags.end();
18781878
}
18791879

1880-
/// \brief Restore the values of all flags that have been modified via `set_flag`.
1880+
/// \brief Restore the values of all flags that have been
1881+
/// modified via `set_flag`.
18811882
~flag_resett()
18821883
{
18831884
seen_flags.clear();

src/ansi-c/ansi_c_parser.cpp

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,18 @@ ansi_c_id_classt ansi_c_parsert::lookup(
1919
bool label)
2020
{
2121
// labels and tags have a separate name space
22-
const irep_idt scope_name=
23-
tag?"tag-"+id2string(base_name):
24-
label?"label-"+id2string(base_name):
25-
base_name;
22+
const irep_idt scope_name =
23+
tag ? "tag-" + id2string(base_name)
24+
: label ? "label-" + id2string(base_name) : base_name;
2625

27-
for(scopest::const_reverse_iterator it=scopes.rbegin();
28-
it!=scopes.rend();
26+
for(scopest::const_reverse_iterator it = scopes.rbegin(); it != scopes.rend();
2927
it++)
3028
{
31-
scopet::name_mapt::const_iterator n_it=
32-
it->name_map.find(scope_name);
29+
scopet::name_mapt::const_iterator n_it = it->name_map.find(scope_name);
3330

34-
if(n_it!=it->name_map.end())
31+
if(n_it != it->name_map.end())
3532
{
36-
identifier=n_it->second.prefixed_name;
33+
identifier = n_it->second.prefixed_name;
3734
return n_it->second.id_class;
3835
}
3936
}
@@ -42,33 +39,30 @@ ansi_c_id_classt ansi_c_parsert::lookup(
4239
// If it's a tag, we will add to current scope.
4340
if(tag)
4441
{
45-
ansi_c_identifiert &i=
46-
current_scope().name_map[scope_name];
47-
i.id_class=ansi_c_id_classt::ANSI_C_TAG;
48-
i.prefixed_name=current_scope().prefix+id2string(scope_name);
49-
i.base_name=base_name;
50-
identifier=i.prefixed_name;
42+
ansi_c_identifiert &i = current_scope().name_map[scope_name];
43+
i.id_class = ansi_c_id_classt::ANSI_C_TAG;
44+
i.prefixed_name = current_scope().prefix + id2string(scope_name);
45+
i.base_name = base_name;
46+
identifier = i.prefixed_name;
5147
return ansi_c_id_classt::ANSI_C_TAG;
5248
}
5349

54-
identifier=base_name;
50+
identifier = base_name;
5551
return ansi_c_id_classt::ANSI_C_UNKNOWN;
5652
}
5753

5854
void ansi_c_parsert::add_tag_with_body(irept &tag)
5955
{
60-
const std::string scope_name=
61-
"tag-"+tag.get_string(ID_C_base_name);
56+
const std::string scope_name = "tag-" + tag.get_string(ID_C_base_name);
6257

63-
irep_idt prefixed_name=current_scope().prefix+scope_name;
58+
irep_idt prefixed_name = current_scope().prefix + scope_name;
6459

65-
if(prefixed_name!=tag.get(ID_identifier))
60+
if(prefixed_name != tag.get(ID_identifier))
6661
{
6762
// re-defined in a deeper scope
68-
ansi_c_identifiert &identifier=
69-
current_scope().name_map[scope_name];
70-
identifier.id_class=ansi_c_id_classt::ANSI_C_TAG;
71-
identifier.prefixed_name=prefixed_name;
63+
ansi_c_identifiert &identifier = current_scope().name_map[scope_name];
64+
identifier.id_class = ansi_c_id_classt::ANSI_C_TAG;
65+
identifier.prefixed_name = prefixed_name;
7266
tag.set(ID_identifier, prefixed_name);
7367
}
7468
}
@@ -81,21 +75,18 @@ int yyansi_cerror(const std::string &error)
8175
return 0;
8276
}
8377

84-
void ansi_c_parsert::add_declarator(
85-
exprt &declaration,
86-
irept &declarator)
78+
void ansi_c_parsert::add_declarator(exprt &declaration, irept &declarator)
8779
{
8880
assert(declarator.is_not_nil());
89-
ansi_c_declarationt &ansi_c_declaration=
90-
to_ansi_c_declaration(declaration);
81+
ansi_c_declarationt &ansi_c_declaration = to_ansi_c_declaration(declaration);
9182

9283
ansi_c_declaratort new_declarator;
9384
new_declarator.build(declarator);
9485

95-
irep_idt base_name=new_declarator.get_base_name();
86+
irep_idt base_name = new_declarator.get_base_name();
9687

97-
bool is_member=ansi_c_declaration.get_is_member();
98-
bool is_parameter=ansi_c_declaration.get_is_parameter();
88+
bool is_member = ansi_c_declaration.get_is_member();
89+
bool is_parameter = ansi_c_declaration.get_is_parameter();
9990

10091
if(is_member)
10192
{
@@ -113,39 +104,35 @@ void ansi_c_parsert::add_declarator(
113104
if(!base_name.empty())
114105
{
115106
c_storage_spect c_storage_spec(ansi_c_declaration.type());
116-
bool is_typedef=c_storage_spec.is_typedef;
117-
bool is_extern=c_storage_spec.is_extern;
107+
bool is_typedef = c_storage_spec.is_typedef;
108+
bool is_extern = c_storage_spec.is_extern;
118109

119-
bool force_root_scope=false;
110+
bool force_root_scope = false;
120111

121112
// Functions always go into global scope, unless
122113
// declared as a parameter or are typedefs.
123-
if(new_declarator.type().id()==ID_code &&
124-
!is_parameter &&
125-
!is_typedef)
126-
force_root_scope=true;
114+
if(new_declarator.type().id() == ID_code && !is_parameter && !is_typedef)
115+
force_root_scope = true;
127116

128117
// variables marked as 'extern' always go into global scope
129118
if(is_extern)
130-
force_root_scope=true;
119+
force_root_scope = true;
131120

132-
ansi_c_id_classt id_class=is_typedef?
133-
ansi_c_id_classt::ANSI_C_TYPEDEF:
134-
ansi_c_id_classt::ANSI_C_SYMBOL;
121+
ansi_c_id_classt id_class = is_typedef ? ansi_c_id_classt::ANSI_C_TYPEDEF
122+
: ansi_c_id_classt::ANSI_C_SYMBOL;
135123

136-
scopet &scope=
137-
force_root_scope?root_scope():current_scope();
124+
scopet &scope = force_root_scope ? root_scope() : current_scope();
138125

139126
// set the final name
140-
irep_idt prefixed_name=force_root_scope?
141-
base_name:
142-
current_scope().prefix+id2string(base_name);
127+
irep_idt prefixed_name = force_root_scope
128+
? base_name
129+
: current_scope().prefix + id2string(base_name);
143130
new_declarator.set_name(prefixed_name);
144131

145132
// add to scope
146-
ansi_c_identifiert &identifier=scope.name_map[base_name];
147-
identifier.id_class=id_class;
148-
identifier.prefixed_name=prefixed_name;
133+
ansi_c_identifiert &identifier = scope.name_map[base_name];
134+
identifier.id_class = id_class;
135+
identifier.prefixed_name = prefixed_name;
149136

150137
if(force_root_scope)
151138
current_scope().name_map[base_name] = identifier;
@@ -156,13 +143,12 @@ void ansi_c_parsert::add_declarator(
156143

157144
ansi_c_id_classt ansi_c_parsert::get_class(const typet &type)
158145
{
159-
if(type.id()==ID_typedef)
146+
if(type.id() == ID_typedef)
160147
return ansi_c_id_classt::ANSI_C_TYPEDEF;
161-
else if(type.id()==ID_struct ||
162-
type.id()==ID_union ||
163-
type.id()==ID_c_enum)
148+
else if(
149+
type.id() == ID_struct || type.id() == ID_union || type.id() == ID_c_enum)
164150
return ansi_c_id_classt::ANSI_C_TAG;
165-
else if(type.id()==ID_merged_type)
151+
else if(type.id() == ID_merged_type)
166152
{
167153
for(const typet &subtype : to_type_with_subtypes(type).subtypes())
168154
{

src/ansi-c/ansi_c_parser.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
109
#ifndef CPROVER_ANSI_C_ANSI_C_PARSER_H
1110
#define CPROVER_ANSI_C_ANSI_C_PARSER_H
1211

13-
#include <set>
1412
#include <map>
13+
#include <set>
1514

16-
#include <util/parser.h>
1715
#include <util/config.h>
16+
#include <util/parser.h>
1817

1918
#include "ansi_c_parse_tree.h"
2019
#include "ansi_c_scope.h"
2120

2221
int yyansi_cparse();
2322

24-
class ansi_c_parsert:public parsert
23+
class ansi_c_parsert : public parsert
2524
{
2625
public:
2726
ansi_c_parse_treet parse_tree;
@@ -40,7 +39,7 @@ class ansi_c_parsert:public parsert
4039

4140
virtual bool parse() override
4241
{
43-
return yyansi_cparse()!=0;
42+
return yyansi_cparse() != 0;
4443
}
4544

4645
virtual void clear() override
@@ -49,9 +48,9 @@ class ansi_c_parsert:public parsert
4948
parse_tree.clear();
5049

5150
// scanner state
52-
tag_following=false;
53-
asm_block_following=false;
54-
parenthesis_counter=0;
51+
tag_following = false;
52+
asm_block_following = false;
53+
parenthesis_counter = 0;
5554
string_literal.clear();
5655
pragma_pack.clear();
5756
pragma_cprover_stack.clear();
@@ -108,7 +107,13 @@ class ansi_c_parsert:public parsert
108107
return scopes.back();
109108
}
110109

111-
enum class decl_typet { TAG, MEMBER, PARAMETER, OTHER };
110+
enum class decl_typet
111+
{
112+
TAG,
113+
MEMBER,
114+
PARAMETER,
115+
OTHER
116+
};
112117

113118
// convert a declarator and then add it to existing an declaration
114119
void add_declarator(exprt &declaration, irept &declarator);
@@ -118,20 +123,20 @@ class ansi_c_parsert:public parsert
118123

119124
void copy_item(const ansi_c_declarationt &declaration)
120125
{
121-
assert(declaration.id()==ID_declaration);
126+
assert(declaration.id() == ID_declaration);
122127
parse_tree.items.push_back(declaration);
123128
}
124129

125130
void new_scope(const std::string &prefix)
126131
{
127-
const scopet &current=current_scope();
132+
const scopet &current = current_scope();
128133
scopes.push_back(scopet());
129-
scopes.back().prefix=current.prefix+prefix;
134+
scopes.back().prefix = current.prefix + prefix;
130135
}
131136

132137
ansi_c_id_classt lookup(
133138
const irep_idt &base_name, // in
134-
irep_idt &identifier, // out
139+
irep_idt &identifier, // out
135140
bool tag,
136141
bool label);
137142

@@ -160,7 +165,7 @@ class ansi_c_parsert:public parsert
160165
/// is already present at top of the stack
161166
bool pragma_cprover_clash(irep_idt name, bool enabled);
162167

163-
/// \brief Tags \ref source_location with
168+
/// \brief Tags \ref source_location with
164169
/// the current CPROVER pragma stack
165170
void set_pragma_cprover();
166171
};

0 commit comments

Comments
 (0)