Skip to content

Commit 1165dde

Browse files
author
thk123
committed
Renamed find declaration method
To be more consistent, renamed to require rather than find since it throws if the declaration is not found
1 parent 5886145 commit 1165dde

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

unit/testing-utils/require_goto_statements.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
\*******************************************************************/
88

99
#include "require_goto_statements.h"
10+
#include "catch.hpp"
1011

1112
#include <algorithm>
1213
#include <util/expr_iterator.h>
@@ -118,7 +119,7 @@ require_goto_statements::pointer_assignment_locationt require_goto_statements::f
118119
/// \param variable_name: The name of the variable.
119120
/// \param entry_point_instructions: The statements to look through
120121
/// \return The declaration statement corresponding to that variable
121-
const code_declt & require_goto_statements::find_declaration_by_name(
122+
const code_declt & require_goto_statements::require_declaration_of_name(
122123
const irep_idt &variable_name,
123124
const std::vector<codet> &entry_point_instructions)
124125
{

unit/testing-utils/require_goto_statements.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,44 @@
1919
#ifndef CPROVER_TESTING_UTILS_CHECK_GOTO_FUNCTIONS_H
2020
#define CPROVER_TESTING_UTILS_CHECK_GOTO_FUNCTIONS_H
2121

22-
class no_decl_found_exception : public std::exception
23-
{
24-
public:
25-
explicit no_decl_found_exception(const std::string &varname) : _varname
26-
(varname) {}
27-
28-
virtual const char *what() const throw() {
29-
std::ostringstream stringStream;
30-
stringStream << "Failed to find declaration for: "
31-
<< _varname;
32-
return stringStream.str().c_str();
33-
}
34-
35-
private:
36-
std::string _varname;
37-
};
3822

3923
namespace require_goto_statements
4024
{
41-
std::vector<code_assignt> find_struct_component_assignments(
42-
const std::vector<codet> &statements,
43-
const irep_idt &structure_name,
44-
const irep_idt &component_name);
45-
4625
struct pointer_assignment_locationt
4726
{
4827
optionalt<code_assignt> null_assignment;
4928
std::vector<code_assignt> non_null_assignments;
5029
};
5130

31+
class no_decl_found_exception : public std::exception
32+
{
33+
public:
34+
explicit no_decl_found_exception(const std::string &varname) : _varname
35+
(varname) {}
36+
37+
virtual const char *what() const throw() {
38+
std::ostringstream stringStream;
39+
stringStream << "Failed to find declaration for: "
40+
<< _varname;
41+
return stringStream.str().c_str();
42+
}
43+
44+
private:
45+
std::string _varname;
46+
};
47+
48+
std::vector<code_assignt> find_struct_component_assignments(
49+
const std::vector<codet> &statements,
50+
const irep_idt &structure_name,
51+
const irep_idt &component_name);
52+
5253
std::vector<codet> get_all_statements(const exprt &function_value);
5354

5455
pointer_assignment_locationt find_pointer_assignments(
5556
const irep_idt &pointer_name,
5657
const std::vector<codet> &instructions);
5758

58-
const code_declt & find_declaration_by_name(
59+
const code_declt &require_declaration_of_name(
5960
const irep_idt &variable_name,
6061
const std::vector<codet> &entry_point_instructions);
6162
}

0 commit comments

Comments
 (0)