Skip to content

Commit 5c211c7

Browse files
committed
Refactored the wrapping of the entry point functionality into its own file, and added support for goto-analyzer
1 parent 816b844 commit 5c211c7

File tree

7 files changed

+55
-18
lines changed

7 files changed

+55
-18
lines changed

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ 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>
2526
#include <linking/static_lifetime_init.h>
2627

2728
#include "ansi_c_entry_point.h"
@@ -478,16 +479,3 @@ bool ansi_c_entry_point(
478479

479480
return false;
480481
}
481-
482-
// Build and return a while(true) statement nesting the function call
483-
// passed as a parameter.
484-
code_whilet wrap_entry_point_in_while(code_function_callt &call_main)
485-
{
486-
exprt true_expr;
487-
code_whilet while_expr;
488-
true_expr.make_true();
489-
while_expr.cond() = true_expr;
490-
while_expr.body() = call_main;
491-
492-
return while_expr;
493-
}

src/ansi-c/ansi_c_entry_point.h

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

1313
#include <util/symbol_table.h>
1414
#include <util/message.h>
15-
#include <util/std_code.h>
1615

1716
bool ansi_c_entry_point(
1817
symbol_tablet &symbol_table,
1918
const std::string &standard_main,
2019
message_handlert &message_handler,
2120
bool wrap_entry_point);
2221

23-
code_whilet wrap_entry_point_in_while(
24-
code_function_callt &call_main);
25-
2622
#endif // CPROVER_ANSI_C_ANSI_C_ENTRY_POINT_H

src/cbmc/cbmc_parse_options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/parse_options.h>
1717

1818
#include <langapi/language_ui.h>
19+
#include <langapi/wrap_entry_point.h>
1920

2021
#include <analyses/goto_check.h>
2122

@@ -63,7 +64,7 @@ class optionst;
6364
"(java-cp-include-files):" \
6465
"(localize-faults)(localize-faults-method):" \
6566
"(lazy-methods)" \
66-
"(wrap-entry-point-in-while)" \
67+
WRAP_ENTRY_POINT_IN_WHILE_TRUE \
6768
"(test-invariant-failure)" \
6869
"(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
6970

src/goto-analyzer/goto_analyzer_parse_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ graphs in DOT format.
108108
#include <util/parse_options.h>
109109

110110
#include <langapi/language_ui.h>
111+
#include <langapi/wrap_entry_point.h>
111112

112113
#include <goto-programs/goto_model.h>
113114
#include <goto-programs/show_goto_functions.h>
@@ -149,6 +150,7 @@ class optionst;
149150
"(unwind-bounds)" \
150151
"(unwind-bounds-threshold):" \
151152
"(unwindset)" \
153+
WRAP_ENTRY_POINT_IN_WHILE_TRUE \
152154
"(functions-ignore)" \
153155
"(functions-full)"
154156

src/langapi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SRC = language_ui.cpp \
22
language_util.cpp \
33
languages.cpp \
44
mode.cpp \
5+
wrap_entry_point.cpp \
56
# Empty last line
67
INCLUDES= -I ..
78

src/langapi/wrap_entry_point.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************\
2+
3+
Module: Wrap the designated entry point into a while(true) loop.
4+
5+
Author: Diffblue Limited (c) 2017
6+
7+
Date: August 2017
8+
9+
\*******************************************************************/
10+
11+
/// \file
12+
/// Wrap the designated entry point into a while(true) loop.
13+
14+
#include "wrap_entry_point.h"
15+
16+
// Build and return a while(true) statement nesting the function call
17+
// passed as a parameter.
18+
code_whilet wrap_entry_point_in_while(code_function_callt &call_main)
19+
{
20+
exprt true_expr;
21+
code_whilet while_expr;
22+
true_expr.make_true();
23+
while_expr.cond() = true_expr;
24+
while_expr.body() = call_main;
25+
26+
return while_expr;
27+
}

src/langapi/wrap_entry_point.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*******************************************************************\
2+
3+
Module: Wrap the designated entry point into a while(true) loop.
4+
5+
Author: Diffblue Limited (c) 2017
6+
7+
Date: August 2017
8+
9+
\*******************************************************************/
10+
11+
#ifndef WRAP_ENTRY_POINT_H
12+
#define WRAP_ENTRY_POINT_H
13+
14+
#include <util/std_code.h>
15+
16+
/// Command line option (to be shared by the different tools)
17+
#define WRAP_ENTRY_POINT_IN_WHILE_TRUE "(wrap-entry-point-in-while)"
18+
19+
code_whilet wrap_entry_point_in_while(
20+
code_function_callt &call_main);
21+
22+
#endif // WRAP_ENTRY_POINT_H

0 commit comments

Comments
 (0)