File tree Expand file tree Collapse file tree 7 files changed +59
-9
lines changed
cbmc-library/string-abstraction Expand file tree Collapse file tree 7 files changed +59
-9
lines changed Original file line number Diff line number Diff line change 1+ #include < cassert>
2+
3+ int main ()
4+ {
5+ int *some_data = new int (10 );
6+ assert (some_data);
7+ assert (*some_data == 10 );
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.cpp
3+ --pointer-check
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
9+ --
10+ Ensure that the new operator is implemented.
Original file line number Diff line number Diff line change 1+ CORE
2+ test.c
3+ --string-abstraction --show-goto-functions
4+ strlen#return_value = \(.*\)s#strarg->length - POINTER_OFFSET\(s\);
5+ ^EXIT=0$
6+ ^SIGNAL=0$
7+ --
8+ --
9+ Ensure that the --string-abstraction flag enables the string abstraction
10+ version of string functions
Original file line number Diff line number Diff line change 1+ CORE
2+ test.c
3+ --show-goto-functions
4+ IF !\(\(signed int\)s\[\(.*\)len\] != 0\) THEN GOTO 2
5+ ^EXIT=0$
6+ ^SIGNAL=0$
7+ --
8+ --
9+ Ensure that if the string abstraction flag is not provided, the regular model for
10+ string functions is used (in this case searching for the terminator).
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+ #include <stdlib.h>
3+
4+ int main ()
5+ {
6+ char * x = malloc (sizeof (char ) * 10 );
7+ x [8 ] = '\0' ;
8+ assert (strlen (x ) == 8 );
9+ }
Original file line number Diff line number Diff line change @@ -45,7 +45,9 @@ std::string get_cprover_library_text(
4545 const struct cprover_library_entryt cprover_library[],
4646 const std::string &prologue)
4747{
48- std::ostringstream library_text (prologue);
48+ // the default mode is ios_base::out which means subsequent write to the
49+ // stream will overwrite the original content
50+ std::ostringstream library_text (prologue, std::ios_base::ate);
4951
5052 std::size_t count=0 ;
5153
Original file line number Diff line number Diff line change 11file (GLOB cpp_library_sources "library/*.c" )
22
3- add_custom_command (OUTPUT converter_input.txt
4- COMMAND cat ${cpp_library_sources} > converter_input.txt
5- DEPENDS ${cpp_library_sources}
6- )
7-
83add_custom_command (OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /cprover_library.inc"
9- COMMAND ../ansi-c/converter < "converter_input.txt" > "${CMAKE_CURRENT_BINARY_DIR} /cprover_library.inc"
10- DEPENDS "converter_input.txt" ../ansi-c/converter
11- )
4+ COMMAND cat ${cpp_library_sources} | $<TARGET_FILE:converter> > "${CMAKE_CURRENT_BINARY_DIR} /cprover_library.inc"
5+ DEPENDS converter ${cpp_library_sources} )
126
137################################################################################
148
@@ -33,6 +27,12 @@ endif()
3327file (GLOB_RECURSE sources "*.cpp" "*.h" )
3428add_library (cpp ${sources} )
3529
30+ set_source_files_properties (
31+ ${sources}
32+ PROPERTIES
33+ OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR} /cprover_library.inc"
34+ )
35+
3636generic_includes(cpp)
3737
3838target_link_libraries (cpp util ansi-c)
You can’t perform that action at this time.
0 commit comments