Skip to content

Commit 7672856

Browse files
Yakir Vizelyvizel
authored andcommitted
Naming conventions, unsigned -> size_t
1 parent f01cbe9 commit 7672856

File tree

3 files changed

+98
-122
lines changed

3 files changed

+98
-122
lines changed

src/cprover/chc_wto.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class chc_wtot
142142
typedef std::unordered_map<std::size_t , std::vector<wto_componentt>>
143143
nested_components_t;
144144

145-
chc_graph & m_g;
145+
chc_grapht & m_g;
146146

147147
std::unordered_map<std::size_t, inf_numt> m_dfn;
148148
std::vector<const symbol_exprt*> m_stack;
@@ -239,7 +239,7 @@ class chc_wtot
239239
}
240240

241241
public:
242-
chc_wtot(chc_graph & g) : m_g(g), m_cur_dfn_num(0) {}
242+
chc_wtot(chc_grapht & g) : m_g(g), m_cur_dfn_num(0) {}
243243

244244
void build_wto() {
245245
if (!m_g.has_entry())
@@ -276,7 +276,7 @@ class chc_wtot
276276
}
277277
};
278278

279-
class SimpleVisitor : public wto_element_visitort
279+
class simple_visitort : public wto_element_visitort
280280
{
281281
virtual void visit(const wto_singletont & s)
282282
{

src/cprover/cutpoint_graph.cpp

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
#include <iostream>
99
#include <fstream>
1010

11-
cutpoint_graph::~cutpoint_graph() {
11+
cutpoint_grapht::~cutpoint_grapht() {
1212
m_edges.clear();
1313
m_cps.clear();
1414
m_insts.clear();
1515
}
1616

17-
void cutpoint_graph::run(const goto_functiont & goto_function)
17+
void cutpoint_grapht::run(const goto_functiont & goto_function)
1818
{
19-
computeCutpoints (goto_function);
20-
computeFwdReach (goto_function);
21-
computeBwdReach (goto_function);
22-
computeEdges (goto_function);
19+
compute_cutpoints(goto_function);
20+
compute_fwd_reach(goto_function);
21+
compute_bwd_reach(goto_function);
22+
compute_edges(goto_function);
2323

24-
toDot(goto_function, "cp.dot");
24+
to_dot(goto_function, "cp.dot");
2525
}
2626

27-
void cutpoint_graph::toDot(const goto_functiont & f, std::string filename)
27+
void cutpoint_grapht::to_dot(const goto_functiont & f, std::string filename)
2828
{
2929
std::ofstream out;
3030
out.open(filename);
@@ -35,7 +35,7 @@ void cutpoint_graph::toDot(const goto_functiont & f, std::string filename)
3535

3636
for (auto cp : m_cps)
3737
{
38-
cp->toDot(out, ns);
38+
cp->to_dot(out, ns);
3939
}
4040

4141
for (auto edge : m_edges)
@@ -62,7 +62,7 @@ void cutpoint_graph::toDot(const goto_functiont & f, std::string filename)
6262
out.close();
6363
}
6464

65-
cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d)
65+
cutpoint_edge_ptr cutpoint_grapht::get_edge(const cutpointt &s, const cutpointt &d)
6666
{
6767
for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it)
6868
{
@@ -73,7 +73,8 @@ cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d)
7373
return nullptr;
7474
}
7575

76-
const cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoint &d) const
76+
const cutpoint_edge_ptr
77+
cutpoint_grapht::getEdge(const cutpointt &s, const cutpointt &d) const
7778
{
7879
for (auto it = s.succ_begin (), end = s.succ_end (); it != end; ++it)
7980
{
@@ -84,20 +85,20 @@ const cutpoint_edge_ptr cutpoint_graph::getEdge(const cutpoint &s, const cutpoin
8485
return nullptr;
8586
}
8687

87-
void cutpoint_graph::computeEdges (const goto_functiont &goto_function)
88+
void cutpoint_grapht::compute_edges(const goto_functiont &goto_function)
8889
{
8990
forall_goto_program_instructions(it, goto_function.body)
9091
{
91-
if (isCutpoint(*it))
92+
if (is_cutpoint(*it))
9293
{
9394
std::vector<bool> & reach = m_fwd[&(*it)];
94-
cutpoint & cp = getCutpoint(*it);
95+
cutpointt & cp = get_cutpoint(*it);
9596

96-
for (unsigned r = 0; r < reach.size(); r++)
97+
for (std::size_t r = 0; r < reach.size(); r++)
9798
{
9899
if (reach[r] == true)
99100
{
100-
cutpoint_edge_ptr edg = newEdge(cp, *m_cps[r]);
101+
cutpoint_edge_ptr edg = create_edge(cp, *m_cps[r]);
101102
edg->push_back(&(*it));
102103
}
103104
}
@@ -112,19 +113,19 @@ void cutpoint_graph::computeEdges (const goto_functiont &goto_function)
112113
if (breach[i] == false) continue;
113114
for (int j = 0; j < freach.size(); j++) {
114115
if (freach[j] == false) continue;
115-
cutpoint_edge_ptr edge = getEdge(*m_cps[i], *m_cps[j]);
116+
cutpoint_edge_ptr edge = get_edge(*m_cps[i], *m_cps[j]);
116117
edge->push_back(&(*it));
117118
}
118119
}
119120
}
120121
}
121122
}
122123

123-
void cutpoint_graph::computeCutpoints(const goto_functiont &goto_function)
124+
void cutpoint_grapht::compute_cutpoints(const goto_functiont &goto_function)
124125
{
125126
m_cps.clear();
126127

127-
std::map<const goto_programt::instructiont*, unsigned> cp_map;
128+
std::map<const goto_programt::instructiont*, std::size_t> cp_map;
128129

129130
forall_goto_program_instructions(it, goto_function.body)
130131
{
@@ -163,14 +164,14 @@ void cutpoint_graph::computeCutpoints(const goto_functiont &goto_function)
163164
auto i = cp_map.find(&*it);
164165
if (i == cp_map.end()) continue;
165166
auto inst = i->first;
166-
if (isCutpoint(*inst)) continue;
167+
if (is_cutpoint(*inst)) continue;
167168

168-
m_cps.push_back(std::make_shared<cutpoint>(*this, m_cps.size(), *inst));
169+
m_cps.push_back(std::make_shared<cutpointt>(*this, m_cps.size(), *inst));
169170
m_insts.insert(std::make_pair(inst, m_cps.back()));
170171
}
171172
}
172173

173-
void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function)
174+
void cutpoint_grapht::compute_fwd_reach(const goto_functiont &goto_function)
174175
{
175176

176177
for (auto it = goto_function.body.instructions.rbegin(); it != goto_function.body.instructions.rend();)
@@ -179,34 +180,32 @@ void cutpoint_graph::computeFwdReach (const goto_functiont &goto_function)
179180
auto succs = goto_function.body.get_successors(itf);
180181
//if (succs.empty()) continue;
181182
auto inst = &*itf;
182-
m_fwd.insert(std::make_pair(inst, reachability()));
183-
reachability &r = m_fwd [inst];
184-
std::cout << inst->to_string() << "\n";
185-
if (succs.size() > 1) std::cout << "YAY\n";
183+
m_fwd.insert(std::make_pair(inst, reachabilityt()));
184+
reachabilityt &r = m_fwd [inst];
186185
for (auto succ : succs)
187186
{
188-
if (isCutpoint(*succ))
189-
r.set(getCutpoint(*succ).id());
187+
if (is_cutpoint(*succ))
188+
r.set(get_cutpoint(*succ).id());
190189
else
191190
r |= m_fwd[&*succ];
192191

193192
}
194193
}
195194
}
196195

197-
void cutpoint_graph::computeBwdReach (const goto_functiont &goto_function)
196+
void cutpoint_grapht::compute_bwd_reach(const goto_functiont &goto_function)
198197
{
199198
forall_goto_program_instructions(it, goto_function.body)
200199
{
201200
auto inst = &*it;
202-
m_bwd.insert(std::make_pair(inst, reachability()));
203-
reachability &r = m_bwd[inst];
201+
m_bwd.insert(std::make_pair(inst, reachabilityt()));
202+
reachabilityt &r = m_bwd[inst];
204203
for(auto pred : it->incoming_edges)
205204
{
206205
if(pred->is_backwards_goto())
207206
continue;
208-
if(isCutpoint(*pred))
209-
r.set(getCutpoint(*pred).id());
207+
if(is_cutpoint(*pred))
208+
r.set(get_cutpoint(*pred).id());
210209
else
211210
r |= m_bwd[&*pred];
212211

@@ -216,36 +215,16 @@ void cutpoint_graph::computeBwdReach (const goto_functiont &goto_function)
216215
for (auto & cp : m_cps)
217216
{
218217
auto & inst = cp->inst();
219-
reachability &r = m_bwd [&inst];
218+
reachabilityt &r = m_bwd [&inst];
220219

221220
for (auto pred : inst.incoming_edges)
222221
{
223222
if (! pred->is_backwards_goto()) continue;
224-
if (isCutpoint(*pred))
225-
r.set(getCutpoint(*pred).id());
223+
if (is_cutpoint(*pred))
224+
r.set(get_cutpoint(*pred).id());
226225
else
227226
r |= m_bwd[&*pred];
228227
}
229228
}
230229
}
231230

232-
bool cutpoint_graph::isFwdReach(const cutpoint &cp, const goto_programt::instructiont &inst) const
233-
{
234-
if (&(cp.inst ()) == &inst) return true;
235-
236-
// The instruction is already a cut-point, but not the one testes.
237-
// It is impossible to reach another cut-point without getting to it
238-
if (isCutpoint(inst)) return false;
239-
240-
// In case the instruction is not a cut-point, retrieve the backward
241-
// reachability info (cut-point backward reachability) and check if the
242-
// cut-point is backward reachable. If it is, then the instruction
243-
// is forward reachable from the given cp.
244-
auto it = m_bwd.find (&inst);
245-
INVARIANT(it != m_bwd.end (), "No back-reachability information");
246-
247-
unsigned sz = it->second.size ();
248-
unsigned id = cp.id ();
249-
if (sz == 0 || id >= sz) return false;
250-
return (it->second)[id];
251-
}

0 commit comments

Comments
 (0)