Skip to content

Commit b073387

Browse files
committed
Moved the command line argument handling, and removed the code specific to it in ansi-c and cpp folders. Also added a basic test for cbmc that passes for now.
1 parent 3dd2079 commit b073387

File tree

10 files changed

+24
-37
lines changed

10 files changed

+24
-37
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
int main(int argc, char **argv)
1+
int g = 0;
2+
3+
int main(void)
24
{
3-
return 0;
5+
assert(g == 0);
6+
g = (g == 0) ? 1 : 0;
47
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
CORE
22
main.c
3-
--show-goto-functions --wrap-entry-point-in-while
4-
^EXIT=0$
3+
--wrap-entry-point-in-while --unwind 100
4+
^EXIT=10$
55
^SIGNAL=0$
6-
^ 1: main\(argc', argv'\);$
7-
^ GOTO 1$
6+
^\[main.assertion.1\] assertion g == 0: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^VERIFICATION SUCCESSFUL$
810
--

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ bool ansi_c_entry_point(
447447
message_handler);
448448
}
449449

450-
if(wrap_entry_point)
450+
if(config.ansi_c.wrap_entry_point_in_while)
451451
{
452452
code_whilet wrapped_main=wrap_entry_point_in_while(call_main);
453453
init_code.move_to_operands(wrapped_main);

src/ansi-c/ansi_c_language.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ Author: Daniel Kroening, [email protected]
2727
#include "ansi_c_internal_additions.h"
2828
#include "type2name.h"
2929

30-
void ansi_c_languaget::get_language_options(const cmdlinet &cmd)
31-
{
32-
wrap_entry_point=cmd.isset("wrap-entry-point-in-while");
33-
}
34-
3530
std::set<std::string> ansi_c_languaget::extensions() const
3631
{
3732
return { "c", "i" };
@@ -133,7 +128,7 @@ bool ansi_c_languaget::typecheck(
133128
bool ansi_c_languaget::final(symbol_tablet &symbol_table)
134129
{
135130
if(ansi_c_entry_point(symbol_table, "main", get_message_handler(),
136-
wrap_entry_point_in_while()))
131+
config.ansi_c.wrap_entry_point_in_while))
137132
{
138133
return true;
139134
}

src/ansi-c/ansi_c_language.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Author: Daniel Kroening, [email protected]
2222
class ansi_c_languaget:public languaget
2323
{
2424
public:
25-
virtual void get_language_options(
26-
const cmdlinet &) override;
27-
2825
bool preprocess(
2926
std::istream &instream,
3027
const std::string &path,
@@ -79,12 +76,6 @@ class ansi_c_languaget:public languaget
7976
protected:
8077
ansi_c_parse_treet parse_tree;
8178
std::string parse_path;
82-
83-
bool wrap_entry_point_in_while() const
84-
{ return wrap_entry_point; }
85-
86-
private:
87-
bool wrap_entry_point;
8879
};
8980

9081
languaget *new_ansi_c_language();

src/cpp/cpp_language.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ Author: Daniel Kroening, [email protected]
2929
#include "cpp_typecheck.h"
3030
#include "cpp_type2name.h"
3131

32-
void cpp_languaget::get_language_options(const cmdlinet &cmd)
33-
{
34-
wrap_entry_point=cmd.isset("wrap-entry-point-in-while");
35-
}
36-
3732
std::set<std::string> cpp_languaget::extensions() const
3833
{
3934
std::set<std::string> s;
@@ -141,7 +136,7 @@ bool cpp_languaget::typecheck(
141136
bool cpp_languaget::final(symbol_tablet &symbol_table)
142137
{
143138
if(ansi_c_entry_point(symbol_table, "main", get_message_handler(),
144-
wrap_entry_point_in_while()))
139+
config.ansi_c.wrap_entry_point_in_while))
145140
{
146141
return true;
147142
}

src/cpp/cpp_language.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ Author: Daniel Kroening, [email protected]
2424
class cpp_languaget:public languaget
2525
{
2626
public:
27-
virtual void get_language_options(
28-
const cmdlinet &cmd) override;
29-
3027
bool preprocess(
3128
std::istream &instream,
3229
const std::string &path,
@@ -88,9 +85,6 @@ class cpp_languaget:public languaget
8885

8986
void modules_provided(std::set<std::string> &modules) override;
9087

91-
bool wrap_entry_point_in_while() const
92-
{ return wrap_entry_point; }
93-
9488
protected:
9589
cpp_parse_treet cpp_parse_tree;
9690
std::string parse_path;
@@ -101,9 +95,6 @@ class cpp_languaget:public languaget
10195
{
10296
return "main";
10397
}
104-
105-
private:
106-
bool wrap_entry_point;
10798
};
10899

109100
languaget *new_cpp_language();

src/langapi/wrap_entry_point.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Date: August 2017
1313

1414
#include <util/std_code.h>
1515

16+
/// Command line option (to be shared by the different tools)
17+
/// (This contains the actual string, needed in config.cpp)
18+
#define WRAP_ENTRY_POINT_IN_WHILE_TRUE_STRING "wrap-entry-point-in-while"
19+
1620
/// Command line option (to be shared by the different tools)
1721
#define WRAP_ENTRY_POINT_IN_WHILE_TRUE "(wrap-entry-point-in-while)"
1822

src/util/config.cpp

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

21+
#include "langapi/wrap_entry_point.h"
22+
2123
configt config;
2224

2325
void configt::ansi_ct::set_16()
@@ -757,6 +759,9 @@ bool configt::set(const cmdlinet &cmdline)
757759
if(cmdline.isset('I'))
758760
ansi_c.include_paths=cmdline.get_values('I');
759761

762+
ansi_c.wrap_entry_point_in_while=
763+
cmdline.isset(WRAP_ENTRY_POINT_IN_WHILE_TRUE_STRING);
764+
760765
if(cmdline.isset("classpath"))
761766
{
762767
// Specifying -classpath or -cp overrides any setting of the

src/util/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class configt
4444
bool use_fixed_for_float;
4545
bool for_has_scope;
4646
bool single_precision_constant;
47+
bool wrap_entry_point_in_while;
4748
enum class c_standardt { C89, C99, C11 } c_standard;
4849
static c_standardt default_c_standard();
4950

0 commit comments

Comments
 (0)