Skip to content

Commit b48b405

Browse files
committed
Implemented all the changes asked for by Martin
1 parent cec8faa commit b48b405

File tree

12 files changed

+33
-73
lines changed

12 files changed

+33
-73
lines changed

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,25 @@ Author: Daniel Kroening, [email protected]
2222
#include <ansi-c/string_constant.h>
2323

2424
#include <goto-programs/goto_functions.h>
25-
#include <langapi/wrap_entry_point.h>
2625
#include <linking/static_lifetime_init.h>
2726

2827
#include "ansi_c_entry_point.h"
2928
#include "ansi_c_language.h"
3029
#include "c_nondet_symbol_factory.h"
3130

31+
// Build and return a while(true) statement nesting the function call
32+
// passed as a parameter.
33+
code_whilet wrap_entry_point_in_while(code_function_callt &call_main)
34+
{
35+
exprt true_expr;
36+
code_whilet while_expr;
37+
true_expr.make_true();
38+
while_expr.cond()=true_expr;
39+
while_expr.body()=call_main;
40+
41+
return while_expr;
42+
}
43+
3244
exprt::operandst build_function_environment(
3345
const code_typet::parameterst &parameters,
3446
code_blockt &init_code,
@@ -123,8 +135,7 @@ void record_function_outputs(
123135
bool ansi_c_entry_point(
124136
symbol_tablet &symbol_table,
125137
const std::string &standard_main,
126-
message_handlert &message_handler,
127-
bool wrap_entry_point)
138+
message_handlert &message_handler)
128139
{
129140
// check if entry point is already there
130141
if(symbol_table.symbols.find(goto_functionst::entry_point())!=

src/ansi-c/ansi_c_entry_point.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Author: Daniel Kroening, [email protected]
1616
bool ansi_c_entry_point(
1717
symbol_tablet &symbol_table,
1818
const std::string &standard_main,
19-
message_handlert &message_handler,
20-
bool wrap_entry_point);
19+
message_handlert &message_handler);
2120

2221
#endif // CPROVER_ANSI_C_ANSI_C_ENTRY_POINT_H

src/ansi-c/ansi_c_language.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ bool ansi_c_languaget::typecheck(
127127

128128
bool ansi_c_languaget::final(symbol_tablet &symbol_table)
129129
{
130-
if(ansi_c_entry_point(symbol_table, "main", get_message_handler(),
131-
config.ansi_c.wrap_entry_point_in_while))
130+
if(ansi_c_entry_point(symbol_table, "main", get_message_handler()))
132131
{
133132
return true;
134133
}

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <util/ui_message.h>
1616
#include <util/parse_options.h>
17+
#include <util/config.h>
1718

1819
#include <langapi/language_ui.h>
19-
#include <langapi/wrap_entry_point.h>
2020

2121
#include <analyses/goto_check.h>
2222

src/cpp/cpp_language.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ bool cpp_languaget::typecheck(
135135

136136
bool cpp_languaget::final(symbol_tablet &symbol_table)
137137
{
138-
if(ansi_c_entry_point(symbol_table, "main", get_message_handler(),
139-
config.ansi_c.wrap_entry_point_in_while))
138+
if(ansi_c_entry_point(symbol_table, "main", get_message_handler()))
140139
{
141140
return true;
142141
}

src/goto-analyzer/goto_analyzer_parse_options.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,9 @@ graphs in DOT format.
106106

107107
#include <util/ui_message.h>
108108
#include <util/parse_options.h>
109+
#include <util/config.h>
109110

110111
#include <langapi/language_ui.h>
111-
#include <langapi/wrap_entry_point.h>
112-
113112
#include <goto-programs/goto_model.h>
114113
#include <goto-programs/show_goto_functions.h>
115114

src/goto-cc/compile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ bool compilet::link()
368368
symbol_table.remove(goto_functionst::entry_point());
369369
compiled_functions.function_map.erase(goto_functionst::entry_point());
370370

371-
if(ansi_c_entry_point(symbol_table, "main", get_message_handler(), false))
371+
if(ansi_c_entry_point(symbol_table, "main", get_message_handler()))
372372
return true;
373373

374374
// entry_point may (should) add some more functions.

src/langapi/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ SRC = language_ui.cpp \
22
language_util.cpp \
33
languages.cpp \
44
mode.cpp \
5-
wrap_entry_point.cpp \
65
# Empty last line
76
INCLUDES= -I ..
87

src/langapi/wrap_entry_point.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/langapi/wrap_entry_point.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/util/config.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Author: Daniel Kroening, [email protected]
1818
#include "std_expr.h"
1919
#include "cprover_prefix.h"
2020

21-
#include "langapi/wrap_entry_point.h"
22-
2321
configt config;
2422

2523
void configt::ansi_ct::set_16()

src/util/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <list>
1414

15+
#include <util/std_code.h>
16+
1517
#include "ieee_float.h"
1618
#include "irep.h"
1719

@@ -161,4 +163,15 @@ class configt
161163

162164
extern configt config;
163165

166+
/// Command line option (to be shared by the different tools)
167+
/// (This contains the actual string, needed in config.cpp)
168+
#define WRAP_ENTRY_POINT_IN_WHILE_TRUE_STRING "wrap-entry-point-in-while"
169+
170+
/// Command line option (to be shared by the different tools)
171+
#define WRAP_ENTRY_POINT_IN_WHILE_TRUE "(" WRAP_ENTRY_POINT_IN_WHILE_TRUE_STRING ")"
172+
173+
/// Command line help text
174+
#define HELP_WRAP_ENTRY_POINT_IN_WHILE_TRUE \
175+
" --wrap-entry-point-in-while wrap the designated entry point function in a while(true) statement\n" // NOLINT(*)
176+
164177
#endif // CPROVER_UTIL_CONFIG_H

0 commit comments

Comments
 (0)