diff --git a/doc/html-manual/boop-example/driver.c b/doc/html-manual/boop-example/driver.c index ff9ec214b76..815fc5b7c7b 100644 --- a/doc/html-manual/boop-example/driver.c +++ b/doc/html-manual/boop-example/driver.c @@ -18,7 +18,7 @@ int dummy_open (struct inode *inode, struct file *filp) if (locked) return -1; locked = TRUE; - + return 0; /* success */ } @@ -30,7 +30,7 @@ unsigned int dummy_read (struct file *filp, char *buf, int max) n = nondet_int (); __CPROVER_assume ((n >= 0) && (n <= max)); /* writing to the buffer is not modeled here */ - + return n; } return -1; @@ -46,4 +46,3 @@ int dummy_release (struct inode *inode, struct file *filp) } return -1; } - diff --git a/doc/html-manual/boop-example/spec.c b/doc/html-manual/boop-example/spec.c index b8e714356d3..d35513ecf90 100644 --- a/doc/html-manual/boop-example/spec.c +++ b/doc/html-manual/boop-example/spec.c @@ -31,7 +31,7 @@ int main () unsigned int count; unsigned char random; - int lock_held = 0; + int lock_held = 0; dummy_major = register_chrdev (0, "dummy"); inode.i_rdev = dummy_major << MINORBITS; @@ -49,14 +49,14 @@ int main () switch (random) { - case 1: + case 1: rval = dummy_open (&inode, &my_file); if (rval == 0) lock_held = TRUE; break; case 2: __CPROVER_assume (lock_held); - count = dummy_read (&my_file, buffer, BUF_SIZE); + count = dummy_read (&my_file, buffer, BUF_SIZE); break; case 3: dummy_release (&inode, &my_file); diff --git a/doc/html-manual/gcc-wrap.c b/doc/html-manual/gcc-wrap.c index 0ac8a3d9239..8894b904ef4 100644 --- a/doc/html-manual/gcc-wrap.c +++ b/doc/html-manual/gcc-wrap.c @@ -16,7 +16,7 @@ void run(const char *what, char *const argv[]) /* now create new process */ childpid = fork(); - + if(childpid>=0) /* fork succeeded */ { if(childpid==0) /* fork() returns 0 to the child process */ @@ -40,24 +40,24 @@ void run(const char *what, char *const argv[]) exit(1); } } - + int main(int argc, char * argv[]) { // First do original call. - + // on some systems, gcc gets confused if it is not argument 0 // (which normally contains the path to the executable being called). argv[0]=strdup(gcc); run(gcc, argv); - + // now do preprocessing call char **new_argv=malloc(sizeof(char *)*(argc+1)); - + _Bool compile=0; _Bool assemble=0; _Bool next_is_o=0; - + unsigned i; for(i=0; iHardware Verification - diff --git a/doc/html-manual/pid.c b/doc/html-manual/pid.c index 4d33545647a..fd2f7e27a85 100644 --- a/doc/html-manual/pid.c +++ b/doc/html-manual/pid.c @@ -30,7 +30,7 @@ float desired_pitch; float climb_sum_err=0; /** Computes desired_gaz and desired_pitch */ -void climb_pid_run() +void climb_pid_run() { float err=estimator_z_dot-desired_climb; @@ -39,7 +39,7 @@ void climb_pid_run() float pprz=fgaz*MAX_PPRZ; desired_gaz=((pprz>=0 && pprz<=MAX_PPRZ) ? pprz : (pprz>MAX_PPRZ ? MAX_PPRZ : 0)); - + /** pitch offset for climb */ float pitch_of_vz=(desired_climb>0) ? desired_climb*pitch_of_vz_pgain : 0; desired_pitch=nav_pitch+pitch_of_vz; @@ -55,18 +55,18 @@ int main() while(1) { - /** Non-deterministic input values */ + /** Non-deterministic input values */ desired_climb=nondet_float(); estimator_z_dot=nondet_float(); - /** Range of input values */ + /** Range of input values */ __CPROVER_assume(desired_climb>=-MAX_CLIMB && desired_climb<=MAX_CLIMB); __CPROVER_assume(estimator_z_dot>=-MAX_CLIMB && estimator_z_dot<=MAX_CLIMB); __CPROVER_input("desired_climb", desired_climb); __CPROVER_input("estimator_z_dot", estimator_z_dot); - climb_pid_run(); + climb_pid_run(); __CPROVER_output("desired_gaz", desired_gaz); __CPROVER_output("desired_pitch", desired_pitch); @@ -75,4 +75,3 @@ int main() return 0; } - diff --git a/doc/html-manual/ring_buffer1.c b/doc/html-manual/ring_buffer1.c index f90be79f1ab..323d97b474e 100644 --- a/doc/html-manual/ring_buffer1.c +++ b/doc/html-manual/ring_buffer1.c @@ -15,14 +15,14 @@ unsigned int ring_buffer[SIZE]; int main() { unsigned index=0; - + while(1) { unsigned output; output=ring_buffer[index]; printf("%u\n", output); assert(output<=MAX); - + ring_buffer[index]=sample(); index=(index+1)%SIZE; diff --git a/doc/html-manual/ring_buffer2.c b/doc/html-manual/ring_buffer2.c index 475260f8232..e852d2c9c56 100644 --- a/doc/html-manual/ring_buffer2.c +++ b/doc/html-manual/ring_buffer2.c @@ -15,14 +15,14 @@ unsigned int ring_buffer[SIZE]; int main() { unsigned index=0, previous_index=SIZE-1; - + while(1) { unsigned output; output=(ring_buffer[index]+ring_buffer[previous_index])/2; assert(ring_buffer[index]<=MAX); assert(output<=MAX); - + ring_buffer[index]=sample(); previous_index=index; diff --git a/regression/ansi-c/Array_Declarator1/main.c b/regression/ansi-c/Array_Declarator1/main.c index e7bc36d0cc5..93ca50ede43 100644 --- a/regression/ansi-c/Array_Declarator1/main.c +++ b/regression/ansi-c/Array_Declarator1/main.c @@ -22,7 +22,7 @@ keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size -expression. +expression. 6.7.5.3(21): The following are all compatible function prototype declarators. @@ -39,10 +39,10 @@ as are: corresponding to a in any call to f must be a non-null pointer to the first of at least three arrays of 5 doubles, which the others do not.) -The comments in the rule for array_abstract_declarator in +The comments in the rule for array_abstract_declarator in src/ansi-c/parser.y indicate awareness of the standard regarding this issue, however, it seems that the case where both TOK_STATIC and -attribute_type_qualifier_list (in either order) occur is not covered, +attribute_type_qualifier_list (in either order) occur is not covered, even though the standard allows this combination. Further investigation into this issue also revealed that the rules diff --git a/regression/ansi-c/Array_Declarator3/main.c b/regression/ansi-c/Array_Declarator3/main.c index c84e9a4ca4f..b0a3cba1564 100644 --- a/regression/ansi-c/Array_Declarator3/main.c +++ b/regression/ansi-c/Array_Declarator3/main.c @@ -7,4 +7,3 @@ int main(void) int bar0[restrict] = {0}; return 0; } - diff --git a/regression/ansi-c/Atomic1/main.c b/regression/ansi-c/Atomic1/main.c index d7af26682bc..24083d42d12 100644 --- a/regression/ansi-c/Atomic1/main.c +++ b/regression/ansi-c/Atomic1/main.c @@ -1,9 +1,9 @@ // _Atomic is a C11 keyword. It can be used as a type qualifier // and as a type specifier, which introduces ambiguity into the grammar. - + // 6.7.2.4 - 4: If the _Atomic keyword is immediately followed by a left // parenthesis, it is interpreted as a type specifier (with a type name), -// not as a type qualifier. +// not as a type qualifier. // Visual Studio doesn't have it, will likely never have it. diff --git a/regression/ansi-c/Header_files1/main.c b/regression/ansi-c/Header_files1/main.c index 9a89425b6c0..040b61f6ea2 100644 --- a/regression/ansi-c/Header_files1/main.c +++ b/regression/ansi-c/Header_files1/main.c @@ -28,4 +28,3 @@ int main() { return 0; } - diff --git a/regression/ansi-c/Header_files1/test.desc b/regression/ansi-c/Header_files1/test.desc index 2967c9aa631..5dabd73bf87 100644 --- a/regression/ansi-c/Header_files1/test.desc +++ b/regression/ansi-c/Header_files1/test.desc @@ -8,4 +8,3 @@ main.c ^CONVERSION ERROR$ is not declared$ -- - diff --git a/regression/ansi-c/Initializer_cast1/main.c b/regression/ansi-c/Initializer_cast1/main.c index fe209ec38d8..a15d42f6038 100644 --- a/regression/ansi-c/Initializer_cast1/main.c +++ b/regression/ansi-c/Initializer_cast1/main.c @@ -21,18 +21,18 @@ int main() struct S s; union U u; - // scalar + // scalar l=(long){0x1}; - + // struct s=(struct S){ 1, 2, 3, 4, 5, 6 }; - + // union u=(union U)s; - + // union u=(union U){ 1 }; - + // array const int *a=(array_type){ 1, 2, 3, 4 }; } diff --git a/regression/ansi-c/KnR1/main.c b/regression/ansi-c/KnR1/main.c index d192c54baa2..a72a852faf9 100644 --- a/regression/ansi-c/KnR1/main.c +++ b/regression/ansi-c/KnR1/main.c @@ -37,4 +37,3 @@ int main() { return d(-1)!=0; } - diff --git a/regression/ansi-c/KnR2/main.c b/regression/ansi-c/KnR2/main.c index ddde5205bb6..efe80ea626f 100644 --- a/regression/ansi-c/KnR2/main.c +++ b/regression/ansi-c/KnR2/main.c @@ -12,4 +12,3 @@ register int x; int main() { } - diff --git a/regression/ansi-c/KnR3/main.c b/regression/ansi-c/KnR3/main.c index 91a3f9c4c8e..a416f1fc921 100644 --- a/regression/ansi-c/KnR3/main.c +++ b/regression/ansi-c/KnR3/main.c @@ -29,4 +29,3 @@ int main() { return whois_func_head(0)==0; } - diff --git a/regression/ansi-c/Lvalue1/main.c b/regression/ansi-c/Lvalue1/main.c index fcc4e398374..b63d1451748 100644 --- a/regression/ansi-c/Lvalue1/main.c +++ b/regression/ansi-c/Lvalue1/main.c @@ -14,4 +14,3 @@ int main() const char *f=&(__FUNCTION__[2]); char *p=&(char){':'}; } - diff --git a/regression/ansi-c/MMX1/main.c b/regression/ansi-c/MMX1/main.c index dfa5b682562..1114d40f6fc 100644 --- a/regression/ansi-c/MMX1/main.c +++ b/regression/ansi-c/MMX1/main.c @@ -5,13 +5,13 @@ int main() { // This is a gcc extension - #ifdef __GNUC__ + #ifdef __GNUC__ #ifdef __MMX__ __m64 x; - + long long unsigned di; - - x=(__m64)di; + + x=(__m64)di; #endif #endif diff --git a/regression/ansi-c/Qualifiers1/main.c b/regression/ansi-c/Qualifiers1/main.c index 71ffdd9ca4a..e1760882f58 100644 --- a/regression/ansi-c/Qualifiers1/main.c +++ b/regression/ansi-c/Qualifiers1/main.c @@ -16,11 +16,11 @@ int main() volatile int * const p=(int * const)&a; *((int * const)&a) = 1; *p=2; - + f(&a); g(&a); - // now with typedef + // now with typedef ptr_constant pp1; const_ptr_constant pp2=pp1; } diff --git a/regression/ansi-c/Recursive_Structure2/main.c b/regression/ansi-c/Recursive_Structure2/main.c index 98c62554868..20fc636db65 100644 --- a/regression/ansi-c/Recursive_Structure2/main.c +++ b/regression/ansi-c/Recursive_Structure2/main.c @@ -12,4 +12,3 @@ int main() return 0; } - diff --git a/regression/ansi-c/Struct_Bitfields1/main.c b/regression/ansi-c/Struct_Bitfields1/main.c index 045e50f7f6e..a65e86fba1a 100644 --- a/regression/ansi-c/Struct_Bitfields1/main.c +++ b/regression/ansi-c/Struct_Bitfields1/main.c @@ -44,7 +44,7 @@ int main() s1.my_bit++; ++s1.my_bit; (unsigned)s1.my_bit; - + int *p; p=p+s1.my_bit; p=p-s1.my_bit; diff --git a/regression/ansi-c/Struct_Enum_Padding1/main.c b/regression/ansi-c/Struct_Enum_Padding1/main.c index 87f52665f12..ff842a308da 100644 --- a/regression/ansi-c/Struct_Enum_Padding1/main.c +++ b/regression/ansi-c/Struct_Enum_Padding1/main.c @@ -27,4 +27,3 @@ STATIC_ASSERT(sizeof(struct ofpact) == 4); int main() { } - diff --git a/regression/ansi-c/Struct_Padding2/main.c b/regression/ansi-c/Struct_Padding2/main.c index 2479688276d..415bf5e8f67 100644 --- a/regression/ansi-c/Struct_Padding2/main.c +++ b/regression/ansi-c/Struct_Padding2/main.c @@ -157,4 +157,3 @@ STATIC_ASSERT( int main() { } - diff --git a/regression/ansi-c/Struct_Padding3/main.c b/regression/ansi-c/Struct_Padding3/main.c index 3c88bc06137..e74d3e6722f 100644 --- a/regression/ansi-c/Struct_Padding3/main.c +++ b/regression/ansi-c/Struct_Padding3/main.c @@ -19,7 +19,7 @@ STATIC_ASSERT(__builtin_offsetof(struct my_struct1a, ch2)==5); struct my_struct1b { char ch1; // this would normally be padded, but it won't! - int i __attribute__((packed)); + int i __attribute__((packed)); char ch2; }; @@ -31,7 +31,7 @@ struct my_struct1c { // this would normally be padded, but it won't! struct { - int i; + int i; } sub __attribute__((packed)); char ch2; }; @@ -115,4 +115,3 @@ STATIC_ASSERT(__builtin_offsetof(struct my_struct3, i3)==28); int main() { } - diff --git a/regression/ansi-c/Transparent_union1/main.c b/regression/ansi-c/Transparent_union1/main.c index 23a60debf80..d977c176c9d 100644 --- a/regression/ansi-c/Transparent_union1/main.c +++ b/regression/ansi-c/Transparent_union1/main.c @@ -35,11 +35,11 @@ int main() { struct S1 s1; struct S2 s2; - + f1(&s1); f1(&s2); f1(0); - + f2(0); f2(1>2); // these are int } diff --git a/regression/ansi-c/Typecast_to_array_ptr1/main.c b/regression/ansi-c/Typecast_to_array_ptr1/main.c index 1bab0d91b01..3b5be4b89c1 100644 --- a/regression/ansi-c/Typecast_to_array_ptr1/main.c +++ b/regression/ansi-c/Typecast_to_array_ptr1/main.c @@ -6,4 +6,3 @@ int main() return 0; } - diff --git a/regression/ansi-c/Typecast_to_union1/main.c b/regression/ansi-c/Typecast_to_union1/main.c index 6da547e4d2b..8bed126e7cd 100644 --- a/regression/ansi-c/Typecast_to_union1/main.c +++ b/regression/ansi-c/Typecast_to_union1/main.c @@ -10,7 +10,7 @@ union U int main() { union U u; - + u=(union U)(1>2); // the relational operators return "int" u=(union U)(1 && 1); u=(union U)1.0; // the literal is double, not float diff --git a/regression/ansi-c/Union_Initialization1/main.c b/regression/ansi-c/Union_Initialization1/main.c index e6c8b97117d..9e8406c238c 100644 --- a/regression/ansi-c/Union_Initialization1/main.c +++ b/regression/ansi-c/Union_Initialization1/main.c @@ -7,7 +7,7 @@ typedef struct some_struct long two; } three; } num_t; - + int main() { num_t num1 = { 0 }; diff --git a/regression/ansi-c/Universal_characters1/main.c b/regression/ansi-c/Universal_characters1/main.c index c2cc9358a60..30c9a445361 100644 --- a/regression/ansi-c/Universal_characters1/main.c +++ b/regression/ansi-c/Universal_characters1/main.c @@ -2,7 +2,7 @@ int identifier_\u0201_; int \u0201_abc; #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; char my_string[]="\u0201"; STATIC_ASSERT(sizeof(my_string)==3); @@ -15,4 +15,3 @@ int main() identifier_ȁ_=10; ȁ_abc=10; } - diff --git a/regression/ansi-c/VS_extensions1/main.c b/regression/ansi-c/VS_extensions1/main.c index 1bea594ba1f..ca6a8434b06 100644 --- a/regression/ansi-c/VS_extensions1/main.c +++ b/regression/ansi-c/VS_extensions1/main.c @@ -22,7 +22,7 @@ struct __declspec(dllimport) some_struct_tag { int x; }; //__delegate int GetDayOfWeek(); -// __event +// __event void f4() { @@ -58,7 +58,7 @@ __int64 i64; __int8 i8; -// __interface +// __interface void f9() { @@ -83,7 +83,7 @@ void f9() // __property -// __raise +// __raise // __sealed diff --git a/regression/ansi-c/Zero_Initialization1/main.c b/regression/ansi-c/Zero_Initialization1/main.c index f51b398e018..3b7570d3ad3 100644 --- a/regression/ansi-c/Zero_Initialization1/main.c +++ b/regression/ansi-c/Zero_Initialization1/main.c @@ -12,7 +12,7 @@ extern inline void bar() // similar with an incomplete array extern char some_array[]; - + // similar with a union extern union moo y; diff --git a/regression/ansi-c/_Alignof1/main.c b/regression/ansi-c/_Alignof1/main.c index 32af89e45f2..76f2a516e5e 100644 --- a/regression/ansi-c/_Alignof1/main.c +++ b/regression/ansi-c/_Alignof1/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; // C11: _Alignof // 6.5.3.4 @@ -46,7 +46,7 @@ STATIC_ASSERT(_Alignof(struct foo)==128); // gcc takes the following, but clang doesn't STATIC_ASSERT(_Alignof(int __attribute__((aligned(128))))==128); -#endif +#endif int main() { diff --git a/regression/ansi-c/_Bool1/main.c b/regression/ansi-c/_Bool1/main.c index 7c1e8e3f494..16feeb70ce2 100644 --- a/regression/ansi-c/_Bool1/main.c +++ b/regression/ansi-c/_Bool1/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; // C11: // 6.3.1.2 Boolean type diff --git a/regression/ansi-c/_Generic1/main.c b/regression/ansi-c/_Generic1/main.c index 40804e58dfa..b0d58d4860f 100644 --- a/regression/ansi-c/_Generic1/main.c +++ b/regression/ansi-c/_Generic1/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; #define G(X) _Generic((X), \ long double: 1, \ diff --git a/regression/ansi-c/arithmetic_right_shift1/main.c b/regression/ansi-c/arithmetic_right_shift1/main.c index 9013df05cf4..e4423878e3b 100644 --- a/regression/ansi-c/arithmetic_right_shift1/main.c +++ b/regression/ansi-c/arithmetic_right_shift1/main.c @@ -1,7 +1,7 @@ #define static_assert(x) struct { char some[(x)?1:-1]; } // arithmetic shift right isn't division! -// http://en.wikipedia.org/wiki/Arithmetic_shift +// http://en.wikipedia.org/wiki/Arithmetic_shift static_assert((-70)/16==-4); static_assert((-70)>>4==-5); diff --git a/regression/ansi-c/array_initialization1/main.c b/regression/ansi-c/array_initialization1/main.c index 142aa76948e..623adfbe40e 100644 --- a/regression/ansi-c/array_initialization1/main.c +++ b/regression/ansi-c/array_initialization1/main.c @@ -21,4 +21,3 @@ int main() return 0; } - diff --git a/regression/ansi-c/asm1/main.c b/regression/ansi-c/asm1/main.c index e4e3b8f9ee9..243c1f36fb0 100644 --- a/regression/ansi-c/asm1/main.c +++ b/regression/ansi-c/asm1/main.c @@ -23,9 +23,9 @@ int main() #ifdef __GNUC__ __asm volatile("mov ax, dx"); - // another gcc-extension + // another gcc-extension register unsigned my_var asm("eax")=1; - + // Apple added "ASM Blocks", similar to MS', to gcc __asm { mov al, 2 @@ -47,6 +47,6 @@ int main() __asm mov dx, 0xD007 __asm out dx, al #endif - + return 0; } diff --git a/regression/ansi-c/asm3/other.c b/regression/ansi-c/asm3/other.c index 03f7e46f1d9..1fae0c0aebe 100644 --- a/regression/ansi-c/asm3/other.c +++ b/regression/ansi-c/asm3/other.c @@ -5,4 +5,3 @@ int* other(int *) __asm__("" "my_real_name"); int *other(int *p) { return p; } #endif - diff --git a/regression/ansi-c/character_literals1/main.c b/regression/ansi-c/character_literals1/main.c index db347426c05..fb1e228979d 100644 --- a/regression/ansi-c/character_literals1/main.c +++ b/regression/ansi-c/character_literals1/main.c @@ -11,7 +11,7 @@ STATIC_ASSERT('\144' == 100); STATIC_ASSERT('\xff' == (char)0xff); // wide ones - + STATIC_ASSERT(L'\xff'==255); STATIC_ASSERT(L'a'=='a'); diff --git a/regression/ansi-c/decl_initialization1/main.c b/regression/ansi-c/decl_initialization1/main.c index 492d47547da..9af910e996e 100644 --- a/regression/ansi-c/decl_initialization1/main.c +++ b/regression/ansi-c/decl_initialization1/main.c @@ -14,4 +14,3 @@ int main() foo(); return cr_register_hook(); } - diff --git a/regression/ansi-c/decl_initialization2/main.c b/regression/ansi-c/decl_initialization2/main.c index 96afef71d32..386538cd2c1 100644 --- a/regression/ansi-c/decl_initialization2/main.c +++ b/regression/ansi-c/decl_initialization2/main.c @@ -14,4 +14,3 @@ int main() foo(); return cr_register_hook(); } - diff --git a/regression/ansi-c/enum1/main.c b/regression/ansi-c/enum1/main.c index 1a8c2161496..3edb2d4a7b0 100644 --- a/regression/ansi-c/enum1/main.c +++ b/regression/ansi-c/enum1/main.c @@ -9,4 +9,3 @@ int main() return 0; } - diff --git a/regression/ansi-c/enum3/main.c b/regression/ansi-c/enum3/main.c index ff41f84f8b7..bd9942fbe67 100644 --- a/regression/ansi-c/enum3/main.c +++ b/regression/ansi-c/enum3/main.c @@ -62,4 +62,3 @@ int main() { } #endif - diff --git a/regression/ansi-c/enum8/main.c b/regression/ansi-c/enum8/main.c index c320c754d12..f1493804506 100644 --- a/regression/ansi-c/enum8/main.c +++ b/regression/ansi-c/enum8/main.c @@ -6,4 +6,3 @@ enum { int main (void) { return 0; } - diff --git a/regression/ansi-c/extern_inline1/main.c b/regression/ansi-c/extern_inline1/main.c index 886e207a79c..ffc07bd7344 100644 --- a/regression/ansi-c/extern_inline1/main.c +++ b/regression/ansi-c/extern_inline1/main.c @@ -27,4 +27,3 @@ int main() assert(foo(0)==0); #endif } - diff --git a/regression/ansi-c/float_constant1/main.c b/regression/ansi-c/float_constant1/main.c index b8ad9424408..3661c8a064f 100644 --- a/regression/ansi-c/float_constant1/main.c +++ b/regression/ansi-c/float_constant1/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; // hex-based constants STATIC_ASSERT(0x1.0p-95f == 2.524355e-29f); diff --git a/regression/ansi-c/for_scope1/main.c b/regression/ansi-c/for_scope1/main.c index 92cd501e8e7..7feb28d0eb4 100644 --- a/regression/ansi-c/for_scope1/main.c +++ b/regression/ansi-c/for_scope1/main.c @@ -7,9 +7,9 @@ int main() #else // the following is ok in C99 and upwards - - for(unsigned i=0; i<10; i++); + + for(unsigned i=0; i<10; i++); for(char i=0; i<10; i++); - + #endif } diff --git a/regression/ansi-c/gcc_attributes1/main.c b/regression/ansi-c/gcc_attributes1/main.c index a934deaa2ae..f36e5c58a74 100644 --- a/regression/ansi-c/gcc_attributes1/main.c +++ b/regression/ansi-c/gcc_attributes1/main.c @@ -2,7 +2,7 @@ typedef int i32; -i32 __attribute__((aligned)) counter; +i32 __attribute__((aligned)) counter; __attribute__((aligned)) __attribute__((aligned)) int x0; const __attribute__((aligned)) int x1; @@ -94,7 +94,7 @@ int gvar3 __attribute__((__aligned__)); struct Scomb { int x; } __attribute__ ((packed, aligned (64))); - + #endif int main() diff --git a/regression/ansi-c/gcc_attributes2/main.c b/regression/ansi-c/gcc_attributes2/main.c index b16ff84a4ed..d881abf7a1b 100644 --- a/regression/ansi-c/gcc_attributes2/main.c +++ b/regression/ansi-c/gcc_attributes2/main.c @@ -23,11 +23,10 @@ int main() static_assert(sizeof(int16_t)==2, "width of int16_t"); static_assert(sizeof(int32_t)==4, "width of int32_t"); static_assert(sizeof(int64_t)==8, "width of int64_t"); - + // also directly in the sizeof static_assert(sizeof(int __attribute__((__mode__(__DI__))))==8, "width of int64_t"); static_assert(sizeof(__attribute__((__mode__(__DI__))) int)==8, "width of int64_t"); - #endif + #endif } - diff --git a/regression/ansi-c/gcc_attributes3/main.c b/regression/ansi-c/gcc_attributes3/main.c index b5e66493694..d843a1b2dc2 100644 --- a/regression/ansi-c/gcc_attributes3/main.c +++ b/regression/ansi-c/gcc_attributes3/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; #ifdef __GNUC__ diff --git a/regression/ansi-c/gcc_attributes4/main.c b/regression/ansi-c/gcc_attributes4/main.c index f71473cfbcb..3fa2abd8218 100644 --- a/regression/ansi-c/gcc_attributes4/main.c +++ b/regression/ansi-c/gcc_attributes4/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array[(condition) ? 1 : -1]; + int some_array[(condition) ? 1 : -1]; #ifdef __GNUC__ diff --git a/regression/ansi-c/gcc_attributes5/main.c b/regression/ansi-c/gcc_attributes5/main.c index 45233c24196..ae40a62d049 100644 --- a/regression/ansi-c/gcc_attributes5/main.c +++ b/regression/ansi-c/gcc_attributes5/main.c @@ -29,7 +29,7 @@ int (* __attribute__((cdecl,regparm(0))) foo4)(int x); typedef int (__attribute__((cdecl,regparm(0))) foo5)(int x); typedef int (__attribute__((cdecl,regparm(0))) *foo6)(int x); typedef int* (__attribute__((cdecl,regparm(0))) *foo7)(int x); - + #endif int main() diff --git a/regression/ansi-c/gcc_attributes6/main.c b/regression/ansi-c/gcc_attributes6/main.c index aa73313fa0b..e874070e605 100644 --- a/regression/ansi-c/gcc_attributes6/main.c +++ b/regression/ansi-c/gcc_attributes6/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array[(condition) ? 1 : -1]; + int some_array[(condition) ? 1 : -1]; #ifdef __GNUC__ diff --git a/regression/ansi-c/gcc_builtin_constant_p1/main.c b/regression/ansi-c/gcc_builtin_constant_p1/main.c index 2fb3d255220..8ce2e0f5522 100644 --- a/regression/ansi-c/gcc_builtin_constant_p1/main.c +++ b/regression/ansi-c/gcc_builtin_constant_p1/main.c @@ -26,4 +26,3 @@ int main() assert(i==0); #endif } - diff --git a/regression/ansi-c/gcc_builtins3/main.c b/regression/ansi-c/gcc_builtins3/main.c index b1223972467..c527c50aa2c 100644 --- a/regression/ansi-c/gcc_builtins3/main.c +++ b/regression/ansi-c/gcc_builtins3/main.c @@ -14,4 +14,3 @@ void __attribute__((ms_abi)) bar(__builtin_ms_va_list authors, ...) int main() { } - diff --git a/regression/ansi-c/gcc_types_compatible_p1/main.c b/regression/ansi-c/gcc_types_compatible_p1/main.c index 92c0dae1bf7..403596c4276 100644 --- a/regression/ansi-c/gcc_types_compatible_p1/main.c +++ b/regression/ansi-c/gcc_types_compatible_p1/main.c @@ -1,6 +1,6 @@ #define STATIC_ASSERT(condition) \ int some_array[(condition) ? 1 : -1]; - + int i; double d; @@ -18,7 +18,7 @@ cranberry _cranberry; #define __intN_t(N, MODE) \ typedef int int##N##_t __attribute__ ((__mode__ (MODE))); \ typedef unsigned int uint##N##_t __attribute__ ((__mode__ (MODE))) - + __intN_t (8, __QI__); __intN_t (16, __HI__); __intN_t (32, __SI__); diff --git a/regression/ansi-c/gcc_types_compatible_p3/main.c b/regression/ansi-c/gcc_types_compatible_p3/main.c index 35dd8c552c4..5693270c7da 100644 --- a/regression/ansi-c/gcc_types_compatible_p3/main.c +++ b/regression/ansi-c/gcc_types_compatible_p3/main.c @@ -44,9 +44,9 @@ STATIC_ASSERT(__builtin_types_compatible_p(typeof(enum large_enum1), unsigned lo // Also works when signed enum large_enum2 { NEG=-1, LARGE_CONSTANT2=0x100000000 }; -STATIC_ASSERT(__builtin_types_compatible_p(typeof(LARGE_CONSTANT2), signed long) || +STATIC_ASSERT(__builtin_types_compatible_p(typeof(LARGE_CONSTANT2), signed long) || __builtin_types_compatible_p(typeof(LARGE_CONSTANT2), signed long long)); -STATIC_ASSERT(__builtin_types_compatible_p(typeof(enum large_enum2), signed long) || +STATIC_ASSERT(__builtin_types_compatible_p(typeof(enum large_enum2), signed long) || __builtin_types_compatible_p(typeof(enum large_enum2), signed long long)); // 'Packed' is interesting. diff --git a/regression/ansi-c/integer_constant1/main.c b/regression/ansi-c/integer_constant1/main.c index 7776545e708..f1cd209e840 100644 --- a/regression/ansi-c/integer_constant1/main.c +++ b/regression/ansi-c/integer_constant1/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; STATIC_ASSERT('\''==39); STATIC_ASSERT(L'\''==39); diff --git a/regression/ansi-c/pragma_pack1/main.c b/regression/ansi-c/pragma_pack1/main.c index 508535d75cb..2f90725c359 100644 --- a/regression/ansi-c/pragma_pack1/main.c +++ b/regression/ansi-c/pragma_pack1/main.c @@ -46,4 +46,3 @@ int main() printf("struct S: %lu\n", sizeof(struct S)); return 0; } - diff --git a/regression/ansi-c/pragma_pack2/main.c b/regression/ansi-c/pragma_pack2/main.c index 095a91d8c56..07b4d1a5b66 100644 --- a/regression/ansi-c/pragma_pack2/main.c +++ b/regression/ansi-c/pragma_pack2/main.c @@ -21,4 +21,3 @@ int main() { return 0; } - diff --git a/regression/ansi-c/pragma_pack3/main.c b/regression/ansi-c/pragma_pack3/main.c index c4857f6d3f2..7eb85820319 100644 --- a/regression/ansi-c/pragma_pack3/main.c +++ b/regression/ansi-c/pragma_pack3/main.c @@ -40,4 +40,3 @@ int main() { return 0; } - diff --git a/regression/ansi-c/sizeof1/main.c b/regression/ansi-c/sizeof1/main.c index e519b3736e2..a624bd9ff6e 100644 --- a/regression/ansi-c/sizeof1/main.c +++ b/regression/ansi-c/sizeof1/main.c @@ -2,7 +2,7 @@ #include // for size_t #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; // check size_t STATIC_ASSERT(sizeof(void *)==sizeof(size_t)); diff --git a/regression/ansi-c/sizeof3/main.c b/regression/ansi-c/sizeof3/main.c index bab07828fc9..cd21d97cf1b 100644 --- a/regression/ansi-c/sizeof3/main.c +++ b/regression/ansi-c/sizeof3/main.c @@ -1,5 +1,5 @@ #define STATIC_ASSERT(condition) \ - int some_array##__LINE__[(condition) ? 1 : -1]; + int some_array##__LINE__[(condition) ? 1 : -1]; struct empty_struct { }; union empty_union { }; diff --git a/regression/ansi-c/struct3/main.c b/regression/ansi-c/struct3/main.c index 4d9dba5f6fa..c06578de812 100644 --- a/regression/ansi-c/struct3/main.c +++ b/regression/ansi-c/struct3/main.c @@ -1,5 +1,5 @@ //#define STATIC_ASSERT(condition) \ -// int some_array##__LINE__[(condition) ? 1 : -1]; +// int some_array##__LINE__[(condition) ? 1 : -1]; #define STATIC_ASSERT(condition) \ _Static_assert((condition), "assertion"); @@ -19,7 +19,7 @@ int main() }; STATIC_ASSERT(sizeof(struct A)==sizeof(int)); - + { struct A { diff --git a/regression/ansi-c/struct5/main.c b/regression/ansi-c/struct5/main.c index 8b0db354337..6859074ce23 100644 --- a/regression/ansi-c/struct5/main.c +++ b/regression/ansi-c/struct5/main.c @@ -4,9 +4,9 @@ struct foo1 { int x; }; - + int y; -}; +}; union foo2 { @@ -14,18 +14,18 @@ union foo2 { int x; }; - + int y; -}; +}; int main() { struct foo1 s; union foo2 u; - + s.y=1; s.x=2; - + u.y=1; u.x=2; diff --git a/regression/array-refinement-with-incr/Array_UF3/main.c b/regression/array-refinement-with-incr/Array_UF3/main.c index 4a945f152e4..9c423192760 100644 --- a/regression/array-refinement-with-incr/Array_UF3/main.c +++ b/regression/array-refinement-with-incr/Array_UF3/main.c @@ -1,8 +1,8 @@ void main() { unsigned int N; - __CPROVER_assume(N>0); - + __CPROVER_assume(N>0); + unsigned int j,k; int matrix[N], max; diff --git a/regression/array-refinement/Array_UF3/main.c b/regression/array-refinement/Array_UF3/main.c index 0b8403c00a4..4db1610f46e 100644 --- a/regression/array-refinement/Array_UF3/main.c +++ b/regression/array-refinement/Array_UF3/main.c @@ -1,8 +1,8 @@ main() { unsigned int N; - __CPROVER_assume(N>0); - + __CPROVER_assume(N>0); + unsigned int j,k; int matrix[N], max; @@ -17,4 +17,3 @@ main() assert(matrix[0] #include -int x = 0, y; +int x = 0, y; void* thr1(void * arg) { diff --git a/regression/cbmc-concurrency/pthread_join1/main.c b/regression/cbmc-concurrency/pthread_join1/main.c index 0f1bd148819..d6c2c815f20 100644 --- a/regression/cbmc-concurrency/pthread_join1/main.c +++ b/regression/cbmc-concurrency/pthread_join1/main.c @@ -21,4 +21,3 @@ int main() assert(i==1); // should fail, as there are two threads assert(i==2); // should pass } - diff --git a/regression/cbmc-concurrency/pthread_join2/main.c b/regression/cbmc-concurrency/pthread_join2/main.c index c964d185ed7..91ee9566794 100644 --- a/regression/cbmc-concurrency/pthread_join2/main.c +++ b/regression/cbmc-concurrency/pthread_join2/main.c @@ -32,7 +32,7 @@ struct chord_args_t // Internal start routine for a thread in a chord static void* chord_start_routine(void *ptr) { - struct chord_args_t *args = (struct chord_args_t *) ptr; + struct chord_args_t *args = (struct chord_args_t *) ptr; // ignore errors pthread_join(args->thread, NULL); diff --git a/regression/cbmc-concurrency/recursion1/main.c b/regression/cbmc-concurrency/recursion1/main.c index f4af36c6c46..dab775d4f60 100644 --- a/regression/cbmc-concurrency/recursion1/main.c +++ b/regression/cbmc-concurrency/recursion1/main.c @@ -22,4 +22,3 @@ int main() return 0; } - diff --git a/regression/cbmc-concurrency/sc2/main.c b/regression/cbmc-concurrency/sc2/main.c index 3575d682d12..7fff830abb3 100644 --- a/regression/cbmc-concurrency/sc2/main.c +++ b/regression/cbmc-concurrency/sc2/main.c @@ -17,4 +17,3 @@ int main() assert(global!=3); // safe // #4 global=3; // #5 } - diff --git a/regression/cbmc-concurrency/sc3/main.c b/regression/cbmc-concurrency/sc3/main.c index 2235a20ac54..9714ecbbdc4 100644 --- a/regression/cbmc-concurrency/sc3/main.c +++ b/regression/cbmc-concurrency/sc3/main.c @@ -9,15 +9,15 @@ __CPROVER_thread_local int local2; void f() { int local3; - + local1=1; local2=1; local3=1; - + local1++; local2++; local3++; - + assert(local1==2); assert(local2==2); assert(local3==2); diff --git a/regression/cbmc-concurrency/sc4/main.c b/regression/cbmc-concurrency/sc4/main.c index d0c44cba275..2c5a07cb979 100644 --- a/regression/cbmc-concurrency/sc4/main.c +++ b/regression/cbmc-concurrency/sc4/main.c @@ -4,8 +4,8 @@ int main() { global=1; global=2; - + __CPROVER_ASYNC_1: assert(global==2); - + assert(global==2); } diff --git a/regression/cbmc-concurrency/sc6/main.c b/regression/cbmc-concurrency/sc6/main.c index 029434f6308..0115f470f74 100644 --- a/regression/cbmc-concurrency/sc6/main.c +++ b/regression/cbmc-concurrency/sc6/main.c @@ -20,4 +20,3 @@ int main(){ __CPROVER_assert(!(r1 == 1 && r2 == 1), "SC"); return 0; } - diff --git a/regression/cbmc-concurrency/sc8/main.c b/regression/cbmc-concurrency/sc8/main.c index cc23a0c90bb..b860527b95f 100644 --- a/regression/cbmc-concurrency/sc8/main.c +++ b/regression/cbmc-concurrency/sc8/main.c @@ -2,13 +2,13 @@ int i, j; int main() { - + i++; // j++; - + __CPROVER_ASYNC_1: j++; - + assert(0); - + j++; } diff --git a/regression/cbmc-concurrency/struct_and_array1/main.c b/regression/cbmc-concurrency/struct_and_array1/main.c index fdc909d823b..b7b0369a647 100644 --- a/regression/cbmc-concurrency/struct_and_array1/main.c +++ b/regression/cbmc-concurrency/struct_and_array1/main.c @@ -31,7 +31,7 @@ int main() pthread_t t; pthread_create(&t,NULL,foo1,NULL); pthread_create(&t,NULL,foo2,NULL); - + if(done1 && done2) { assert(st.x==st.y); diff --git a/regression/cbmc-concurrency/svcomp13_qrcu_safe/main.c b/regression/cbmc-concurrency/svcomp13_qrcu_safe/main.c index a06b18623d8..0f277272d38 100644 --- a/regression/cbmc-concurrency/svcomp13_qrcu_safe/main.c +++ b/regression/cbmc-concurrency/svcomp13_qrcu_safe/main.c @@ -10,7 +10,7 @@ extern int __VERIFIER_nondet_int(); int idx=0; // boolean to control which of the two elements will be used by readers // (idx <= 0) then ctr1 is used // (idx >= 1) then ctr2 is used -int ctr1=1, ctr2=0; +int ctr1=1, ctr2=0; int readerprogress1=0, readerprogress2=0; // the progress is indicated by an integer: // 0: reader not yet started // 1: reader withing QRCU read-side critical section @@ -42,7 +42,7 @@ void __VERIFIER_atomic_check_progress1(int readerstart1) { if (__VERIFIER_nondet_int()) { __VERIFIER_assume(readerstart1 == 1 && readerprogress1 == 1); assert(0); - } + } return; } @@ -50,7 +50,7 @@ void __VERIFIER_atomic_check_progress2(int readerstart2) { if (__VERIFIER_nondet_int()) { __VERIFIER_assume(readerstart2 == 1 && readerprogress2 == 1); assert(0); - } + } return; } diff --git a/regression/cbmc-concurrency/svcomp13_qrcu_unsafe/main.c b/regression/cbmc-concurrency/svcomp13_qrcu_unsafe/main.c index 9bb52ce6f9b..4b8230404c6 100644 --- a/regression/cbmc-concurrency/svcomp13_qrcu_unsafe/main.c +++ b/regression/cbmc-concurrency/svcomp13_qrcu_unsafe/main.c @@ -10,7 +10,7 @@ extern int __VERIFIER_nondet_int(); int idx=0; // boolean to control which of the two elements will be used by readers // (idx <= 0) then ctr1 is used // (idx >= 1) then ctr2 is used -int ctr1=1, ctr2=0; +int ctr1=1, ctr2=0; int readerprogress1=0, readerprogress2=0; // the progress is indicated by an integer: // 0: reader not yet started // 1: reader withing QRCU read-side critical section @@ -42,7 +42,7 @@ void __VERIFIER_atomic_check_progress1(int readerstart1) { if (__VERIFIER_nondet_int()) { __VERIFIER_assume(readerstart1 == 1 && readerprogress1 == 1); assert(0); - } + } return; } @@ -50,7 +50,7 @@ void __VERIFIER_atomic_check_progress2(int readerstart2) { if (__VERIFIER_nondet_int()) { __VERIFIER_assume(readerstart2 == 1 && readerprogress2 == 1); assert(0); - } + } return; } diff --git a/regression/cbmc-concurrency/svcomp13_read_write_lock_safe/main.c b/regression/cbmc-concurrency/svcomp13_read_write_lock_safe/main.c index 48b4eb886ee..116c0cf351b 100644 --- a/regression/cbmc-concurrency/svcomp13_read_write_lock_safe/main.c +++ b/regression/cbmc-concurrency/svcomp13_read_write_lock_safe/main.c @@ -44,4 +44,3 @@ __CPROVER_ASYNC_1: writer(); __CPROVER_ASYNC_1: reader(); return 0; } - diff --git a/regression/cbmc-concurrency/thread_chain_posix1/main.c b/regression/cbmc-concurrency/thread_chain_posix1/main.c index 6979059ccc6..9f1d31a7d0c 100644 --- a/regression/cbmc-concurrency/thread_chain_posix1/main.c +++ b/regression/cbmc-concurrency/thread_chain_posix1/main.c @@ -54,7 +54,7 @@ struct thread_chain_args_t // Internal start routine for a thread in a thread_chain static void* thread_chain_start_routine(void *ptr) { - struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; + struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; // ignore errors pthread_join(args->thread, NULL); diff --git a/regression/cbmc-concurrency/thread_chain_posix2/main.c b/regression/cbmc-concurrency/thread_chain_posix2/main.c index 6979059ccc6..9f1d31a7d0c 100644 --- a/regression/cbmc-concurrency/thread_chain_posix2/main.c +++ b/regression/cbmc-concurrency/thread_chain_posix2/main.c @@ -54,7 +54,7 @@ struct thread_chain_args_t // Internal start routine for a thread in a thread_chain static void* thread_chain_start_routine(void *ptr) { - struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; + struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; // ignore errors pthread_join(args->thread, NULL); diff --git a/regression/cbmc-concurrency/thread_chain_posix3/main.c b/regression/cbmc-concurrency/thread_chain_posix3/main.c index 6979059ccc6..9f1d31a7d0c 100644 --- a/regression/cbmc-concurrency/thread_chain_posix3/main.c +++ b/regression/cbmc-concurrency/thread_chain_posix3/main.c @@ -54,7 +54,7 @@ struct thread_chain_args_t // Internal start routine for a thread in a thread_chain static void* thread_chain_start_routine(void *ptr) { - struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; + struct thread_chain_args_t *args = (struct thread_chain_args_t *) ptr; // ignore errors pthread_join(args->thread, NULL); diff --git a/regression/cbmc-concurrency/thread_local1/main.c b/regression/cbmc-concurrency/thread_local1/main.c index 6972b0d2e56..1cbad005d8e 100644 --- a/regression/cbmc-concurrency/thread_local1/main.c +++ b/regression/cbmc-concurrency/thread_local1/main.c @@ -18,4 +18,3 @@ int main() pthread_create(&t, 0, thr1, 0); pthread_create(&t, 0, thr1, 0); } - diff --git a/regression/cbmc-concurrency/uf_with_threads1/main.c b/regression/cbmc-concurrency/uf_with_threads1/main.c index 73dbe9ee399..1f916a80b1d 100644 --- a/regression/cbmc-concurrency/uf_with_threads1/main.c +++ b/regression/cbmc-concurrency/uf_with_threads1/main.c @@ -25,7 +25,7 @@ int main() pthread_t t; pthread_create(&t,NULL,foo1,NULL); pthread_create(&t,NULL,foo2,NULL); - + if(done1 && done2) assert(res1 == res2); } diff --git a/regression/cbmc-cover/assertion1/main.c b/regression/cbmc-cover/assertion1/main.c index 80e30689b08..ca0f7d96dd4 100644 --- a/regression/cbmc-cover/assertion1/main.c +++ b/regression/cbmc-cover/assertion1/main.c @@ -1,12 +1,12 @@ int main() { int input1, input2; - + __CPROVER_input("input1", input1); __CPROVER_input("input2", input2); __CPROVER_assert(!input1, ""); - + if(input1) { __CPROVER_assert(!input1, ""); // will work, we ignore the assertion diff --git a/regression/cbmc-cover/branch1/main.c b/regression/cbmc-cover/branch1/main.c index 0c9e7eb23a7..92b64795521 100644 --- a/regression/cbmc-cover/branch1/main.c +++ b/regression/cbmc-cover/branch1/main.c @@ -1,10 +1,10 @@ int main() { int input1, input2; - + __CPROVER_input("input1", input1); __CPROVER_input("input2", input2); - + if(input1) { if(input1) // dependent diff --git a/regression/cbmc-cover/condition1/main.c b/regression/cbmc-cover/condition1/main.c index c53207527eb..62341b53cd3 100644 --- a/regression/cbmc-cover/condition1/main.c +++ b/regression/cbmc-cover/condition1/main.c @@ -4,7 +4,7 @@ int main() __CPROVER_input("input1", input1); __CPROVER_input("input2", input2); - + if(input1 && input2) { } diff --git a/regression/cbmc-cover/cover1/main.c b/regression/cbmc-cover/cover1/main.c index a9e743567e5..6928622d2dc 100644 --- a/regression/cbmc-cover/cover1/main.c +++ b/regression/cbmc-cover/cover1/main.c @@ -7,12 +7,12 @@ int main() __CPROVER_cover(input1); __CPROVER_cover(!input1); - + if(input1) { __CPROVER_cover(!input1); // won't work } - + // should not produce a goal __CPROVER_assert(input1, ""); } diff --git a/regression/cbmc-cover/decision1/main.c b/regression/cbmc-cover/decision1/main.c index ebd204036fb..cf2beee9b7e 100644 --- a/regression/cbmc-cover/decision1/main.c +++ b/regression/cbmc-cover/decision1/main.c @@ -1,7 +1,7 @@ int main() { int input1, input2, input3; - + __CPROVER_input("input1", input1); __CPROVER_input("input2", input2); __CPROVER_input("input3", input3); diff --git a/regression/cbmc-cover/location1/main.c b/regression/cbmc-cover/location1/main.c index 0409678bb2f..81fd1d23bdb 100644 --- a/regression/cbmc-cover/location1/main.c +++ b/regression/cbmc-cover/location1/main.c @@ -2,7 +2,7 @@ int main() { int input1; int x=0; - + __CPROVER_input("input1", input1); if(input1) diff --git a/regression/cbmc-cover/mcdc14/main.c b/regression/cbmc-cover/mcdc14/main.c index ebc094c78d5..8ee96b8a080 100644 --- a/regression/cbmc-cover/mcdc14/main.c +++ b/regression/cbmc-cover/mcdc14/main.c @@ -6,7 +6,7 @@ int main() if (altitude > 2500) { - /* instructions */ + /* instructions */ } return 1; diff --git a/regression/cbmc-cover/mcdc3/main.c b/regression/cbmc-cover/mcdc3/main.c index 5800ada9ee6..d5dad1ac232 100644 --- a/regression/cbmc-cover/mcdc3/main.c +++ b/regression/cbmc-cover/mcdc3/main.c @@ -1,11 +1,11 @@ int main() { unsigned x, y; - + __CPROVER_input("x", x); __CPROVER_input("y", y); - - if (!(x>3) && y<5) + + if (!(x>3) && y<5) ; return 1; diff --git a/regression/cbmc-cover/mcdc4/main.c b/regression/cbmc-cover/mcdc4/main.c index 08ea1146922..fb1e8b9cc17 100644 --- a/regression/cbmc-cover/mcdc4/main.c +++ b/regression/cbmc-cover/mcdc4/main.c @@ -8,7 +8,7 @@ int main() __CPROVER_input("C", C); __CPROVER_input("D", D); - if((A && B) || (C && D)) + if((A && B) || (C && D)) { } else diff --git a/regression/cbmc-cover/mcdc5/main.c b/regression/cbmc-cover/mcdc5/main.c index 65a7761db1b..fbce43d7b52 100644 --- a/regression/cbmc-cover/mcdc5/main.c +++ b/regression/cbmc-cover/mcdc5/main.c @@ -7,7 +7,7 @@ int main() __CPROVER_input("C", C); __CPROVER_input("D", D); - if((A || B) && (C || D)) + if((A || B) && (C || D)) { } else diff --git a/regression/cbmc-cover/mcdc6/main.c b/regression/cbmc-cover/mcdc6/main.c index c3aa903c471..cbfdb77d01e 100644 --- a/regression/cbmc-cover/mcdc6/main.c +++ b/regression/cbmc-cover/mcdc6/main.c @@ -1,10 +1,10 @@ int main() { unsigned x; - + __CPROVER_input("x", x); - - if(x<3) + + if(x<3) ; return 1; diff --git a/regression/cbmc-cover/mcdc7/main.c b/regression/cbmc-cover/mcdc7/main.c index e8a19b16588..e2395b86475 100644 --- a/regression/cbmc-cover/mcdc7/main.c +++ b/regression/cbmc-cover/mcdc7/main.c @@ -1,7 +1,7 @@ int main() { signed x, y; - + __CPROVER_input("x", x); __CPROVER_input("y", y); diff --git a/regression/cbmc-cover/mcdc8/main.c b/regression/cbmc-cover/mcdc8/main.c index 3eb9a0010e9..d286ec76092 100644 --- a/regression/cbmc-cover/mcdc8/main.c +++ b/regression/cbmc-cover/mcdc8/main.c @@ -1,7 +1,7 @@ int main() { _Bool a, b, c; - + __CPROVER_input("a", a); __CPROVER_input("b", b); __CPROVER_input("c", c); diff --git a/regression/cbmc-from-CVS/Array_Access3/main.c b/regression/cbmc-from-CVS/Array_Access3/main.c index 94aeaf3ffc3..c3c0b2374ee 100644 --- a/regression/cbmc-from-CVS/Array_Access3/main.c +++ b/regression/cbmc-from-CVS/Array_Access3/main.c @@ -10,9 +10,9 @@ int main() // not normal 2[a]=2; - + assert(a[2]==2); - + p=a; // also a bit strange diff --git a/regression/cbmc-from-CVS/Array_Pointer1/main.c b/regression/cbmc-from-CVS/Array_Pointer1/main.c index 407fbf15add..200ace72223 100644 --- a/regression/cbmc-from-CVS/Array_Pointer1/main.c +++ b/regression/cbmc-from-CVS/Array_Pointer1/main.c @@ -14,7 +14,7 @@ int main() j = a[1]; assert(j == 1); - + // Assignment with (dummy) cast. // The array should be zero-initialized. p=(int *)a; diff --git a/regression/cbmc-from-CVS/Array_Pointer6/main.c b/regression/cbmc-from-CVS/Array_Pointer6/main.c index daebe6163a2..f5120136573 100644 --- a/regression/cbmc-from-CVS/Array_Pointer6/main.c +++ b/regression/cbmc-from-CVS/Array_Pointer6/main.c @@ -11,6 +11,6 @@ int main() q=&array; q++; q--; - + assert(**q==*p); } diff --git a/regression/cbmc-from-CVS/Array_Pointer7/main.c b/regression/cbmc-from-CVS/Array_Pointer7/main.c index cf474a4534c..e6b01a5f5da 100644 --- a/regression/cbmc-from-CVS/Array_Pointer7/main.c +++ b/regression/cbmc-from-CVS/Array_Pointer7/main.c @@ -1,12 +1,12 @@ void f1() { int array1[4]; - + char *p=(char *)array1; - + for(unsigned i=0; i=0 && index<100); @@ -16,7 +16,7 @@ void testB() { char arrayB1[100], arrayB2[100]; - arrayB2[10]=11; + arrayB2[10]=11; __CPROVER_array_copy(arrayB1, arrayB2); __CPROVER_assert(arrayB1[10]==11, "arrayB1[10] is OK"); diff --git a/regression/cbmc-from-CVS/End_thread1/main.c b/regression/cbmc-from-CVS/End_thread1/main.c index 4147fdf937c..70e318eed89 100644 --- a/regression/cbmc-from-CVS/End_thread1/main.c +++ b/regression/cbmc-from-CVS/End_thread1/main.c @@ -23,4 +23,3 @@ int main() assert(i!=100); } - diff --git a/regression/cbmc-from-CVS/Failed_Symbols1/main.c b/regression/cbmc-from-CVS/Failed_Symbols1/main.c index 8edae80b335..85380e5f6aa 100644 --- a/regression/cbmc-from-CVS/Failed_Symbols1/main.c +++ b/regression/cbmc-from-CVS/Failed_Symbols1/main.c @@ -1,14 +1,14 @@ int main() { int *p, *q, *a, *b; - + q=a; p=b; - + *p=1; *q=2; - // this should work if no pointer checks are enabled + // this should work if no pointer checks are enabled assert(*p==1); assert(*q==2); } diff --git a/regression/cbmc-from-CVS/Linked_List1/main.c b/regression/cbmc-from-CVS/Linked_List1/main.c index 4439630d3a9..0d767e3b75f 100644 --- a/regression/cbmc-from-CVS/Linked_List1/main.c +++ b/regression/cbmc-from-CVS/Linked_List1/main.c @@ -9,7 +9,7 @@ int main() { unsigned i; struct nodet *list=(void *)0; struct nodet *new_node; - + for(i=0; i<10; i++) { new_node=malloc(sizeof(*new_node)); new_node->n=list; diff --git a/regression/cbmc-from-CVS/Malloc1/main.c b/regression/cbmc-from-CVS/Malloc1/main.c index 8e18343df2f..847289aa064 100644 --- a/regression/cbmc-from-CVS/Malloc1/main.c +++ b/regression/cbmc-from-CVS/Malloc1/main.c @@ -7,16 +7,16 @@ int main() { int *p; unsigned o; size_t n=nondet_uint(); - + __CPROVER_assume(n>=1); __CPROVER_assume(n<10000000); p=malloc(sizeof(int)*n); - + o=n-1; p[o]=1000; - + assert(p[o]==1000); free(p); diff --git a/regression/cbmc-from-CVS/Malloc10/main.c b/regression/cbmc-from-CVS/Malloc10/main.c index 36d20f30fa9..548a5c20caf 100644 --- a/regression/cbmc-from-CVS/Malloc10/main.c +++ b/regression/cbmc-from-CVS/Malloc10/main.c @@ -35,7 +35,7 @@ void drm_vm_open_locked(struct drm_device *dev) } } -int main(void) +int main(void) { struct drm_device dev; drm_vm_open_locked(&dev); diff --git a/regression/cbmc-from-CVS/Malloc11/main.c b/regression/cbmc-from-CVS/Malloc11/main.c index afbb7eb5c75..2ef0fc461e2 100644 --- a/regression/cbmc-from-CVS/Malloc11/main.c +++ b/regression/cbmc-from-CVS/Malloc11/main.c @@ -24,7 +24,7 @@ int main() if( a != NULL) a[0]=0; - + if(n>=1) assert(a[0]==0); return 1; diff --git a/regression/cbmc-from-CVS/Malloc2/main.c b/regression/cbmc-from-CVS/Malloc2/main.c index 14c5e5a32f2..fd263964119 100644 --- a/regression/cbmc-from-CVS/Malloc2/main.c +++ b/regression/cbmc-from-CVS/Malloc2/main.c @@ -26,10 +26,10 @@ int main(void) if (!pp) return -10; - + pp2=&(pp->irqc); - + //*(&(pp->irqc))=0; - + return 0; } diff --git a/regression/cbmc-from-CVS/Malloc3/main.c b/regression/cbmc-from-CVS/Malloc3/main.c index 8fbe4adeca6..c4a06bdd8db 100644 --- a/regression/cbmc-from-CVS/Malloc3/main.c +++ b/regression/cbmc-from-CVS/Malloc3/main.c @@ -8,7 +8,7 @@ int main() { p=malloc(sizeof(int)*10); free(p); - + // bad! p[1]=1; } diff --git a/regression/cbmc-from-CVS/Malloc5/main.c b/regression/cbmc-from-CVS/Malloc5/main.c index 21cfd0dd48f..51d367ea2c5 100644 --- a/regression/cbmc-from-CVS/Malloc5/main.c +++ b/regression/cbmc-from-CVS/Malloc5/main.c @@ -6,11 +6,11 @@ int analyze_this() char *p_char=malloc(sizeof(char)); int *p_int=malloc(sizeof(int)); void *p; - + p=nondet_bool()?p_char:p_int; p_int=p; - + // this should fail, as a char is too small *p_int=1; } diff --git a/regression/cbmc-from-CVS/Malloc6/main.c b/regression/cbmc-from-CVS/Malloc6/main.c index 901f53b9056..075afaa94dc 100644 --- a/regression/cbmc-from-CVS/Malloc6/main.c +++ b/regression/cbmc-from-CVS/Malloc6/main.c @@ -6,11 +6,11 @@ int analyze_this() char *p_char=malloc(sizeof(char)); int *p_int=malloc(sizeof(int)); void *p; - + p=nondet_bool()?p_char:p_int; p_int=p; - + // this should not fail if((void *)p_int!=(void *)p_char) *p_int=1; diff --git a/regression/cbmc-from-CVS/Malloc7/main.c b/regression/cbmc-from-CVS/Malloc7/main.c index 540a10e6781..a9666086375 100644 --- a/regression/cbmc-from-CVS/Malloc7/main.c +++ b/regression/cbmc-from-CVS/Malloc7/main.c @@ -13,12 +13,12 @@ int main() struct X *p; struct X x; int *q; - + p=malloc(sizeof(struct X)); q=&(p->i); - + *q=1; - // should pass + // should pass assert(p->i==1); } diff --git a/regression/cbmc-from-CVS/Malloc8/main.c b/regression/cbmc-from-CVS/Malloc8/main.c index ab33864c9bf..045aec63d0d 100644 --- a/regression/cbmc-from-CVS/Malloc8/main.c +++ b/regression/cbmc-from-CVS/Malloc8/main.c @@ -9,10 +9,10 @@ int main() { struct person** ptr_ptr_p1; ptr_ptr_p1 = malloc(sizeof(struct person*)); *ptr_ptr_p1 = malloc(sizeof(struct person)); - + // Piecewise assignments are ok with cbmc struct person* ptr_p; - ptr_p = *ptr_ptr_p1; + ptr_p = *ptr_ptr_p1; ptr_p->name = "Dummy"; printf("%s\n", ptr_p->name); diff --git a/regression/cbmc-from-CVS/Malloc9/main.c b/regression/cbmc-from-CVS/Malloc9/main.c index de6fbf068b1..c61812ca576 100644 --- a/regression/cbmc-from-CVS/Malloc9/main.c +++ b/regression/cbmc-from-CVS/Malloc9/main.c @@ -18,7 +18,7 @@ struct S2 int main(void) { _Bool b; - + if(b) { struct S1 *p=my_malloc(sizeof(struct S1)); @@ -29,6 +29,6 @@ int main(void) struct S2 *p=my_malloc(sizeof(struct S2)); p->y=1; } - + return 0; } diff --git a/regression/cbmc-from-CVS/Minisat_Simp1/main.c b/regression/cbmc-from-CVS/Minisat_Simp1/main.c index 8810b4799ae..83e859d45d3 100644 --- a/regression/cbmc-from-CVS/Minisat_Simp1/main.c +++ b/regression/cbmc-from-CVS/Minisat_Simp1/main.c @@ -4,10 +4,9 @@ int isnan(double); int main() { double my_d, dabs; - + __CPROVER_assume(!isnan(my_d)); - + dabs=(my_d<0)?-my_d:my_d; assert(fabs(my_d)==dabs); } - diff --git a/regression/cbmc-from-CVS/Pointer1/main.c b/regression/cbmc-from-CVS/Pointer1/main.c index d3f956a0f88..23795f17e22 100644 --- a/regression/cbmc-from-CVS/Pointer1/main.c +++ b/regression/cbmc-from-CVS/Pointer1/main.c @@ -1,10 +1,10 @@ int main() { - int a, b, c, *p; - + int a, b, c, *p; + if(c) p=&a; else p=&b; - + *p=3; - + assert(b==3 || a==3); } diff --git a/regression/cbmc-from-CVS/Pointer10/main.c b/regression/cbmc-from-CVS/Pointer10/main.c index df0ad71d088..0cb84393e53 100644 --- a/regression/cbmc-from-CVS/Pointer10/main.c +++ b/regression/cbmc-from-CVS/Pointer10/main.c @@ -14,11 +14,11 @@ main() p=&(s.array[4]); *p=5; - + assert(s.array[4]==5); - + p=&s.z; *p=6; - + assert(s.z==6); } diff --git a/regression/cbmc-from-CVS/Pointer11/main.c b/regression/cbmc-from-CVS/Pointer11/main.c index 4889d0cd1cc..6de67d9ce7b 100644 --- a/regression/cbmc-from-CVS/Pointer11/main.c +++ b/regression/cbmc-from-CVS/Pointer11/main.c @@ -9,12 +9,12 @@ main() { struct S s[10]; int *p, *q, x=nondet_int(), y=nondet_int(); - + __CPROVER_assume(x==0); __CPROVER_assume(y==0); - + p=&(s[x].a); q=&(s[y].a); - + assert(p==q); } diff --git a/regression/cbmc-from-CVS/Pointer12/main.c b/regression/cbmc-from-CVS/Pointer12/main.c index 02e67312a68..dc9fe5120f5 100644 --- a/regression/cbmc-from-CVS/Pointer12/main.c +++ b/regression/cbmc-from-CVS/Pointer12/main.c @@ -1,10 +1,10 @@ void f(const int *p) { int *q; - + // this is ok q=(int *)p; - + // this, too! *q=1; } @@ -12,6 +12,6 @@ void f(const int *p) main() { int x; - + f(&x); } diff --git a/regression/cbmc-from-CVS/Pointer15/main.c b/regression/cbmc-from-CVS/Pointer15/main.c index 59679d6191e..fe750738dd0 100644 --- a/regression/cbmc-from-CVS/Pointer15/main.c +++ b/regression/cbmc-from-CVS/Pointer15/main.c @@ -5,6 +5,6 @@ int main() int c; p=(c?p:0); - + p=(int * const)0; } diff --git a/regression/cbmc-from-CVS/Pointer17/main.c b/regression/cbmc-from-CVS/Pointer17/main.c index 32dec818a7e..709520ba95c 100644 --- a/regression/cbmc-from-CVS/Pointer17/main.c +++ b/regression/cbmc-from-CVS/Pointer17/main.c @@ -5,7 +5,7 @@ int main() int i; q=&i; p=&q; - - + + **p=1; } diff --git a/regression/cbmc-from-CVS/Pointer20/main.c b/regression/cbmc-from-CVS/Pointer20/main.c index 027747c2d1d..c92e561b243 100644 --- a/regression/cbmc-from-CVS/Pointer20/main.c +++ b/regression/cbmc-from-CVS/Pointer20/main.c @@ -6,7 +6,7 @@ int global; void f() { int local; int input; - + input=nondet_int(); p=input?&local:&global; diff --git a/regression/cbmc-from-CVS/Pointer24/main.c b/regression/cbmc-from-CVS/Pointer24/main.c index 417bec90822..b2597b963f9 100644 --- a/regression/cbmc-from-CVS/Pointer24/main.c +++ b/regression/cbmc-from-CVS/Pointer24/main.c @@ -3,12 +3,12 @@ char a[100]; int main() { char *p, *q; - + q=p; - + __CPROVER_assume(!__CPROVER_same_object(p, 0)); - + p++; - + assert(!__CPROVER_same_object(p, 0)); } diff --git a/regression/cbmc-from-CVS/Pointer25/main.c b/regression/cbmc-from-CVS/Pointer25/main.c index 887d45ad237..b5f2ea854d7 100644 --- a/regression/cbmc-from-CVS/Pointer25/main.c +++ b/regression/cbmc-from-CVS/Pointer25/main.c @@ -4,15 +4,15 @@ int main() void *p; // from integer 0 to NULL - + if(x==0) { p=x; assert(p==0); } - + // the other way around - + if(p==0) { x=p; diff --git a/regression/cbmc-from-CVS/Pointer26/main.c b/regression/cbmc-from-CVS/Pointer26/main.c index a87e9664fa8..ec513fbe68f 100644 --- a/regression/cbmc-from-CVS/Pointer26/main.c +++ b/regression/cbmc-from-CVS/Pointer26/main.c @@ -3,7 +3,7 @@ int main() unsigned int *p=(unsigned int *)0xdeadbeef; assert(p!=0); - int zero; + int zero; __CPROVER_assume(zero==0); unsigned int *q=(unsigned int *)zero; assert(q==0); diff --git a/regression/cbmc-from-CVS/Pointer27/main.c b/regression/cbmc-from-CVS/Pointer27/main.c index 0ba17105630..62db7615843 100644 --- a/regression/cbmc-from-CVS/Pointer27/main.c +++ b/regression/cbmc-from-CVS/Pointer27/main.c @@ -1,11 +1,11 @@ #include - + typedef struct { char a; int b; } S1t; - + int main () { S1t* mem[4]; diff --git a/regression/cbmc-from-CVS/Pointer29/main.c b/regression/cbmc-from-CVS/Pointer29/main.c index 10223c16fa3..e1b8b5e59a5 100644 --- a/regression/cbmc-from-CVS/Pointer29/main.c +++ b/regression/cbmc-from-CVS/Pointer29/main.c @@ -5,4 +5,3 @@ int main() { assert(s_pdt > 1); return 0; } - diff --git a/regression/cbmc-from-CVS/Pointer3/main.c b/regression/cbmc-from-CVS/Pointer3/main.c index 9bbb6c0b4cb..fd3181137b4 100644 --- a/regression/cbmc-from-CVS/Pointer3/main.c +++ b/regression/cbmc-from-CVS/Pointer3/main.c @@ -3,12 +3,12 @@ int main() typedef int *intptr; intptr a[10]; int x, y; - + unsigned i; __CPROVER_assume(i<10); a[i]=&x; a[5]=&y; - - assert(*(a[i])==x); + + assert(*(a[i])==x); } diff --git a/regression/cbmc-from-CVS/Pointer31/main.c b/regression/cbmc-from-CVS/Pointer31/main.c index 41a8ee7ca4b..36996af38fa 100644 --- a/regression/cbmc-from-CVS/Pointer31/main.c +++ b/regression/cbmc-from-CVS/Pointer31/main.c @@ -6,12 +6,12 @@ int global; int main() { p=&global; - + for(int i=0; i<10; i++) { *p=1; - // this is not allowed! + // this is not allowed! int local; p=&local; } diff --git a/regression/cbmc-from-CVS/Pointer6/main.c b/regression/cbmc-from-CVS/Pointer6/main.c index 7914e3c54b7..13d671fad68 100644 --- a/regression/cbmc-from-CVS/Pointer6/main.c +++ b/regression/cbmc-from-CVS/Pointer6/main.c @@ -10,8 +10,8 @@ int main() int z, k, *q; array[0].p=&k; - + q=array[0].p; - + z=*q; } diff --git a/regression/cbmc-from-CVS/Pointer7/main.c b/regression/cbmc-from-CVS/Pointer7/main.c index 7ddb5dfb8e3..49e2de7b750 100644 --- a/regression/cbmc-from-CVS/Pointer7/main.c +++ b/regression/cbmc-from-CVS/Pointer7/main.c @@ -2,8 +2,8 @@ int main() { unsigned char u=255; signed char *p; - + p=(signed char *)&u; - + assert(*p==-1); } diff --git a/regression/cbmc-from-CVS/Pointer_Object_Type1/main.c b/regression/cbmc-from-CVS/Pointer_Object_Type1/main.c index 55a3b0fae29..bebd3a91cfb 100644 --- a/regression/cbmc-from-CVS/Pointer_Object_Type1/main.c +++ b/regression/cbmc-from-CVS/Pointer_Object_Type1/main.c @@ -6,12 +6,12 @@ int main() int input; void *p; int *p2; - + if(input) p=&int_var; else p=&ch_var; - + p2=(int *)p; // this should fail if p points to ch_var diff --git a/regression/cbmc-from-CVS/Same_Basename1/bar.c b/regression/cbmc-from-CVS/Same_Basename1/bar.c index 6ca6609d3ea..3a4dbd9e1aa 100644 --- a/regression/cbmc-from-CVS/Same_Basename1/bar.c +++ b/regression/cbmc-from-CVS/Same_Basename1/bar.c @@ -6,4 +6,3 @@ int main() assert(func(x)); return 0; } - diff --git a/regression/cbmc-from-CVS/Same_Basename1/foo/bar.c b/regression/cbmc-from-CVS/Same_Basename1/foo/bar.c index 82b74a5e5b9..0bb1fd170be 100644 --- a/regression/cbmc-from-CVS/Same_Basename1/foo/bar.c +++ b/regression/cbmc-from-CVS/Same_Basename1/foo/bar.c @@ -2,4 +2,3 @@ int func(int x) { return 1; } - diff --git a/regression/cbmc-from-CVS/Sizeof1/main.c b/regression/cbmc-from-CVS/Sizeof1/main.c index 0c59eb9d96a..e69fcdb7810 100644 --- a/regression/cbmc-from-CVS/Sizeof1/main.c +++ b/regression/cbmc-from-CVS/Sizeof1/main.c @@ -28,6 +28,6 @@ OS_EVENT OSEventTbl[10] ; int main(void) { int x; - + x=sizeof(OSEventTbl); } diff --git a/regression/cbmc-from-CVS/String_Abstraction1/main.c b/regression/cbmc-from-CVS/String_Abstraction1/main.c index 5352ac5ce76..1800bef2e3b 100644 --- a/regression/cbmc-from-CVS/String_Abstraction1/main.c +++ b/regression/cbmc-from-CVS/String_Abstraction1/main.c @@ -3,15 +3,15 @@ int main() { char a[100], b[100], *p; - + strcpy(a, "asd"); assert(strlen(a)==3); - + a[2]=0; assert(strlen(a)==2); - + p=strcpy(b, a); assert(p==b); - assert(strlen(b)==2); + assert(strlen(b)==2); assert(strlen(p)==2); } diff --git a/regression/cbmc-from-CVS/String_Abstraction10/main.c b/regression/cbmc-from-CVS/String_Abstraction10/main.c index 260e750ce46..ed0c0c50d5b 100644 --- a/regression/cbmc-from-CVS/String_Abstraction10/main.c +++ b/regression/cbmc-from-CVS/String_Abstraction10/main.c @@ -12,10 +12,10 @@ int main() { strcpy(a[0], "asd"); assert(strlen(a[0])==3); - + strcpy(s.x, "asdasd"); assert(strlen(s.x)==6); - + s.p=s.x; assert(strlen(s.p)==6); } diff --git a/regression/cbmc-from-CVS/String_Abstraction12/char-array.c b/regression/cbmc-from-CVS/String_Abstraction12/char-array.c index 97615ebeaa7..4a751e2daf0 100644 --- a/regression/cbmc-from-CVS/String_Abstraction12/char-array.c +++ b/regression/cbmc-from-CVS/String_Abstraction12/char-array.c @@ -1,10 +1,9 @@ int main(int argc, char* argv[]) { char dest[10]; - + __CPROVER_assert(__CPROVER_buffer_size(dest) == 10, "CBMC failed to track char array size"); dest[9] = '\0'; __CPROVER_assert(__CPROVER_is_zero_string(dest), "CBMC failed to track char array (2)"); return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction13/constant.c b/regression/cbmc-from-CVS/String_Abstraction13/constant.c index 8c8af8be8c3..c8da924d263 100644 --- a/regression/cbmc-from-CVS/String_Abstraction13/constant.c +++ b/regression/cbmc-from-CVS/String_Abstraction13/constant.c @@ -13,4 +13,3 @@ int main() { assert(__CPROVER_is_zero_string(x)); return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction14/pass-in-implicit.c b/regression/cbmc-from-CVS/String_Abstraction14/pass-in-implicit.c index af6ef9a84b6..b62283af641 100644 --- a/regression/cbmc-from-CVS/String_Abstraction14/pass-in-implicit.c +++ b/regression/cbmc-from-CVS/String_Abstraction14/pass-in-implicit.c @@ -1,7 +1,7 @@ void * malloc(unsigned); void use_str(char * s) { - assert(__CPROVER_is_zero_string(s)); + assert(__CPROVER_is_zero_string(s)); } int main(int argc, char* argv[]) { diff --git a/regression/cbmc-from-CVS/String_Abstraction15/pass-in.c b/regression/cbmc-from-CVS/String_Abstraction15/pass-in.c index 73a56b79aab..4972c1f6768 100644 --- a/regression/cbmc-from-CVS/String_Abstraction15/pass-in.c +++ b/regression/cbmc-from-CVS/String_Abstraction15/pass-in.c @@ -1,7 +1,7 @@ void * malloc(unsigned); void use_str(char * s) { - assert(__CPROVER_is_zero_string(s)); + assert(__CPROVER_is_zero_string(s)); } int main(int argc, char* argv[]) { diff --git a/regression/cbmc-from-CVS/String_Abstraction16/ptr-arith.c b/regression/cbmc-from-CVS/String_Abstraction16/ptr-arith.c index ce3aa49697f..372723a35c9 100644 --- a/regression/cbmc-from-CVS/String_Abstraction16/ptr-arith.c +++ b/regression/cbmc-from-CVS/String_Abstraction16/ptr-arith.c @@ -10,7 +10,6 @@ int main(int argc, char* argv[]) { name=strcpy(name, "abcdefghi"); name=strcpy(name+5-1, "xxxxx"); assert(__CPROVER_is_zero_string(name)); - + return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction17/strcpy-no-decl.c b/regression/cbmc-from-CVS/String_Abstraction17/strcpy-no-decl.c index e122165e7b2..1b4863e7d6e 100644 --- a/regression/cbmc-from-CVS/String_Abstraction17/strcpy-no-decl.c +++ b/regression/cbmc-from-CVS/String_Abstraction17/strcpy-no-decl.c @@ -3,7 +3,7 @@ void * malloc(unsigned); char * make_str() { unsigned short len; char * str; - + __CPROVER_assume(len > 0); str = malloc(len); __CPROVER_assume(__CPROVER_buffer_size(str) == len); @@ -25,4 +25,3 @@ int main(int argc, char* argv[]) { return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction18/strcpy.c b/regression/cbmc-from-CVS/String_Abstraction18/strcpy.c index 6b39c131091..c74e9fea4e5 100644 --- a/regression/cbmc-from-CVS/String_Abstraction18/strcpy.c +++ b/regression/cbmc-from-CVS/String_Abstraction18/strcpy.c @@ -5,7 +5,7 @@ void * malloc(unsigned); char * make_str() { unsigned short len; char * str; - + __CPROVER_assume(len > 0); str = malloc(len); __CPROVER_assume(__CPROVER_buffer_size(str) == len); @@ -28,4 +28,3 @@ int main(int argc, char* argv[]) { return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction2/main.c b/regression/cbmc-from-CVS/String_Abstraction2/main.c index c6187aac31c..41c52122cf9 100644 --- a/regression/cbmc-from-CVS/String_Abstraction2/main.c +++ b/regression/cbmc-from-CVS/String_Abstraction2/main.c @@ -5,15 +5,15 @@ int main() { char a[100], b[100], *p; unsigned int i; - + i=strlen("asdasd"); - + strcpy(a, "asd"); strcpy(b, "asd"); - + p=i?a:b; - + i=strlen(p); - + assert(i==3); } diff --git a/regression/cbmc-from-CVS/String_Abstraction21/strcpy2.c b/regression/cbmc-from-CVS/String_Abstraction21/strcpy2.c index f9d4739325e..77fa5db3fa0 100644 --- a/regression/cbmc-from-CVS/String_Abstraction21/strcpy2.c +++ b/regression/cbmc-from-CVS/String_Abstraction21/strcpy2.c @@ -5,7 +5,7 @@ void * malloc(unsigned); char * make_str() { unsigned short len; char * str; - + __CPROVER_assume(len > 0); str = malloc(len); __CPROVER_assume(__CPROVER_buffer_size(str) == len); @@ -29,10 +29,9 @@ int main(int argc, char* argv[]) { strcpy(dest, name); assert(__CPROVER_is_zero_string(dest)); - + strcpy(dest2, name); assert(__CPROVER_is_zero_string(dest2)); return 0; } - diff --git a/regression/cbmc-from-CVS/String_Abstraction3/main.c b/regression/cbmc-from-CVS/String_Abstraction3/main.c index df69d92fc4f..626df8e3800 100644 --- a/regression/cbmc-from-CVS/String_Abstraction3/main.c +++ b/regression/cbmc-from-CVS/String_Abstraction3/main.c @@ -7,7 +7,7 @@ int main() strcpy(a, "asdasd\000"); assert(strlen(a+1)==5); - + p=a+1; assert(strlen(p)==5); diff --git a/regression/cbmc-from-CVS/String_Abstraction5/main.c b/regression/cbmc-from-CVS/String_Abstraction5/main.c index 1df1c4fb92f..ce43ab835ac 100644 --- a/regression/cbmc-from-CVS/String_Abstraction5/main.c +++ b/regression/cbmc-from-CVS/String_Abstraction5/main.c @@ -17,7 +17,7 @@ int main() // this sould work if(idata=1; - p->next=malloc( sizeof(struct mylist ) ); + p->next=malloc( sizeof(struct mylist ) ); p->next->data=2; - p->next->next=malloc( sizeof(struct mylist ) ); + p->next->next=malloc( sizeof(struct mylist ) ); p->next->next->data=3; - p->next->next->next=malloc( sizeof(struct mylist ) ); + p->next->next->next=malloc( sizeof(struct mylist ) ); p->next->next->next->data=4; - + assert(p->next->next->data==3); return 0; diff --git a/regression/cbmc-from-CVS/Struct_Pointer3/main.c b/regression/cbmc-from-CVS/Struct_Pointer3/main.c index c5f2185a4e7..14d8b17961c 100644 --- a/regression/cbmc-from-CVS/Struct_Pointer3/main.c +++ b/regression/cbmc-from-CVS/Struct_Pointer3/main.c @@ -5,7 +5,7 @@ struct listt }; typedef struct listt listt; - + int main () { listt el0, el1, *ppp1, *ppp2; diff --git a/regression/cbmc-from-CVS/Struct_Pointer_Array1/main2.c b/regression/cbmc-from-CVS/Struct_Pointer_Array1/main2.c index a1297770dfe..70165b406f3 100644 --- a/regression/cbmc-from-CVS/Struct_Pointer_Array1/main2.c +++ b/regression/cbmc-from-CVS/Struct_Pointer_Array1/main2.c @@ -8,7 +8,7 @@ StructTag *TagTbl[2]; int main() { unsigned int i; assume(i<2); - + if(TagTbl[i] != NULL) TagTbl[i]->field = 1; } diff --git a/regression/cbmc-from-CVS/Unbounded_Array1/main.c b/regression/cbmc-from-CVS/Unbounded_Array1/main.c index 624ef1c18df..675d8af2c26 100644 --- a/regression/cbmc-from-CVS/Unbounded_Array1/main.c +++ b/regression/cbmc-from-CVS/Unbounded_Array1/main.c @@ -1,12 +1,12 @@ int main() { unsigned int n, i, j, ai, aj; int a[n]; - + __CPROVER_assume(n>10 && n<10000000); - + __CPROVER_assume(i10 && n<100000); - + if(x) a[0]=1; a[1]=2; - assert(a[0]==1 || !x); + assert(a[0]==1 || !x); } diff --git a/regression/cbmc-from-CVS/Unbounded_Array5/main.c b/regression/cbmc-from-CVS/Unbounded_Array5/main.c index aebfa1e3a94..c6071a177cb 100644 --- a/regression/cbmc-from-CVS/Unbounded_Array5/main.c +++ b/regression/cbmc-from-CVS/Unbounded_Array5/main.c @@ -3,7 +3,7 @@ int mem[__CPROVER_constant_infinity_uint]; int main() { int i, j, mem_j; - + mem[0] = 0; mem[1] = 1; @@ -12,7 +12,7 @@ int main() assert(mem_j == 1); mem[i] = mem[mem_j]; - + unsigned xxxi=mem[i]; unsigned xxx1=mem[1]; diff --git a/regression/cbmc-from-CVS/extern3/main.c b/regression/cbmc-from-CVS/extern3/main.c index fbf9d26241d..2e253b18aa0 100644 --- a/regression/cbmc-from-CVS/extern3/main.c +++ b/regression/cbmc-from-CVS/extern3/main.c @@ -15,12 +15,12 @@ int f() { return x; } } - + int main() { int ret; ret=f(); - + assert(ret==5); } diff --git a/regression/cbmc-from-CVS/extern4/main.c b/regression/cbmc-from-CVS/extern4/main.c index fc468d3b243..6ef05a8e4fa 100644 --- a/regression/cbmc-from-CVS/extern4/main.c +++ b/regression/cbmc-from-CVS/extern4/main.c @@ -5,20 +5,20 @@ void f() int j; j=11; - + assert(i==1); - + i=10; } int main() { extern int i; - + i=1; - + f(); - + assert(i==10); } diff --git a/regression/cbmc-from-CVS/return2/tcas_v23_523.c b/regression/cbmc-from-CVS/return2/tcas_v23_523.c index 4504d9c4dd4..d3398ec3a54 100644 --- a/regression/cbmc-from-CVS/return2/tcas_v23_523.c +++ b/regression/cbmc-from-CVS/return2/tcas_v23_523.c @@ -85,7 +85,7 @@ bool Non_Crossing_Biased_Climb() result = !(Own_Below_Threat()) || ((Own_Below_Threat()) && (!(Down_Separation >= ALIM()))); } else - { + { result = Own_Above_Threat() && (Cur_Vertical_Sep >= MINSEP) && (Up_Separation >= ALIM()); } return result; @@ -128,9 +128,9 @@ int alt_sep_test() enabled = High_Confidence && (Own_Tracked_Alt_Rate <= OLEV) && (Cur_Vertical_Sep > MAXALTDIFF); tcas_equipped = Other_Capability == TCAS_TA; intent_not_known = Two_of_Three_Reports_Valid && Other_RAC == NO_INTENT; - + alt_sep = UNRESOLVED; - + if (enabled && ((tcas_equipped && intent_not_known) || !tcas_equipped)) { need_upward_RA = Non_Crossing_Biased_Climb() && Own_Below_Threat(); @@ -147,7 +147,7 @@ int alt_sep_test() else alt_sep = UNRESOLVED; } - + return alt_sep; } @@ -155,17 +155,17 @@ main(int argc, char*argv[]) { initialize(); - Cur_Vertical_Sep = 860; - High_Confidence = 1; - Two_of_Three_Reports_Valid = 1; - Own_Tracked_Alt = 618; - Own_Tracked_Alt_Rate = 329; - Other_Tracked_Alt = 574; - Alt_Layer_Value = 4; - Up_Separation = 893; - Down_Separation = 914; - Other_RAC = 0; - Other_Capability = 2; - Climb_Inhibit = 0; + Cur_Vertical_Sep = 860; + High_Confidence = 1; + Two_of_Three_Reports_Valid = 1; + Own_Tracked_Alt = 618; + Own_Tracked_Alt_Rate = 329; + Other_Tracked_Alt = 574; + Alt_Layer_Value = 4; + Up_Separation = 893; + Down_Separation = 914; + Other_RAC = 0; + Other_Capability = 2; + Climb_Inhibit = 0; assert(alt_sep_test()==0); } diff --git a/regression/cbmc-incr-oneloop/alarm1/main.c b/regression/cbmc-incr-oneloop/alarm1/main.c index 4896a14f3c2..4c485d71988 100644 --- a/regression/cbmc-incr-oneloop/alarm1/main.c +++ b/regression/cbmc-incr-oneloop/alarm1/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr-oneloop/alarm2/main.c b/regression/cbmc-incr-oneloop/alarm2/main.c index 952c8f698a3..c5b62d3037e 100644 --- a/regression/cbmc-incr-oneloop/alarm2/main.c +++ b/regression/cbmc-incr-oneloop/alarm2/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr-oneloop/alarm3/main.c b/regression/cbmc-incr-oneloop/alarm3/main.c index 420f0c33e8e..1df007abbc7 100644 --- a/regression/cbmc-incr-oneloop/alarm3/main.c +++ b/regression/cbmc-incr-oneloop/alarm3/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr-oneloop/assertion-after-loop1/main.c b/regression/cbmc-incr-oneloop/assertion-after-loop1/main.c index b23bea554a4..115c392b84e 100644 --- a/regression/cbmc-incr-oneloop/assertion-after-loop1/main.c +++ b/regression/cbmc-incr-oneloop/assertion-after-loop1/main.c @@ -3,7 +3,7 @@ int main() { int x = nondet_int(); __CPROVER_assume(0<=x && x<=1); - while(x<4) { + while(x<4) { x=x+1; } assert(x<4); diff --git a/regression/cbmc-incr-oneloop/cruise1/main.c b/regression/cbmc-incr-oneloop/cruise1/main.c index 8318e62fd5b..436b0f029b9 100644 --- a/regression/cbmc-incr-oneloop/cruise1/main.c +++ b/regression/cbmc-incr-oneloop/cruise1/main.c @@ -5,7 +5,7 @@ /* modelled after */ /* Robert Bosch GmbH: Bosch Automotive Handbook. Bentley (2007) */ /* if you reuse this code, please cite also */ -/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for +/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for Reactive System Testing. In Testing Software and Systems LNCS Volume 8254, 2013, pp 133-148 */ /*******************************************************************************/ @@ -27,7 +27,7 @@ typedef struct state { #define I_BRAKE 5 typedef struct input { - int signal; + int signal; } t_input; void init(t_state *s) { @@ -48,7 +48,7 @@ void compute(t_input* i, t_state *s) { } else if((s->mode==0) && (s->speed==0) && (s->button==1)) { if((i->signal==I_GAS)||(i->signal==I_ACC)) {s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } else if((s->mode==1) && (s->speed==1) && (s->button==1)) { if(i->signal==I_GAS) { s->speed=2; s->mode=2; } @@ -64,12 +64,12 @@ void compute(t_input* i, t_state *s) { else if(i->signal==I_BUTTON) { s->mode=0; s->button=0; } } else if((s->mode==0) && (s->speed==2) && (s->button==0)) { - if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; - else if(i->signal==I_BUTTON) s->button=1; + if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; + else if(i->signal==I_BUTTON) s->button=1; } else if((s->mode==0) && (s->speed==2) && (s->button==1)) { if((i->signal==I_BRAKE)||(i->signal==I_DEC)) { s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } } diff --git a/regression/cbmc-incr-oneloop/cruise2/main.c b/regression/cbmc-incr-oneloop/cruise2/main.c index 42b49addaa2..26d397c06eb 100644 --- a/regression/cbmc-incr-oneloop/cruise2/main.c +++ b/regression/cbmc-incr-oneloop/cruise2/main.c @@ -5,7 +5,7 @@ /* modelled after */ /* Robert Bosch GmbH: Bosch Automotive Handbook. Bentley (2007) */ /* if you reuse this code, please cite also */ -/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for +/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for Reactive System Testing. In Testing Software and Systems LNCS Volume 8254, 2013, pp 133-148 */ /*******************************************************************************/ @@ -27,7 +27,7 @@ typedef struct state { #define I_BRAKE 5 typedef struct input { - int signal; + int signal; } t_input; void init(t_state *s) { @@ -48,7 +48,7 @@ void compute(t_input* i, t_state *s) { } else if((s->mode==0) && (s->speed==0) && (s->button==1)) { if((i->signal==I_GAS)||(i->signal==I_ACC)) {s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } else if((s->mode==1) && (s->speed==1) && (s->button==1)) { if(i->signal==I_GAS) { s->speed=2; s->mode=2; } @@ -64,12 +64,12 @@ void compute(t_input* i, t_state *s) { else if(i->signal==I_BUTTON) { s->mode=0; s->button=0; } } else if((s->mode==0) && (s->speed==2) && (s->button==0)) { - if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; - else if(i->signal==I_BUTTON) s->button=1; + if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; + else if(i->signal==I_BUTTON) s->button=1; } else if((s->mode==0) && (s->speed==2) && (s->button==1)) { if((i->signal==I_BRAKE)||(i->signal==I_DEC)) { s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } } diff --git a/regression/cbmc-incr-oneloop/induction1/main.c b/regression/cbmc-incr-oneloop/induction1/main.c index 63f82e856e5..2cc849ab513 100644 --- a/regression/cbmc-incr-oneloop/induction1/main.c +++ b/regression/cbmc-incr-oneloop/induction1/main.c @@ -3,13 +3,13 @@ int main() { signed x,y; - while(1) + while(1) { __CPROVER_assume(x>=10); signed t = x; - if((long)x+y<=INT_MAX) + if((long)x+y<=INT_MAX) x = x+y; y = t; - assert(x>=10); + assert(x>=10); } } diff --git a/regression/cbmc-incr-oneloop/simplifier1/main.c b/regression/cbmc-incr-oneloop/simplifier1/main.c index ece5871b540..fe64405ac9f 100644 --- a/regression/cbmc-incr-oneloop/simplifier1/main.c +++ b/regression/cbmc-incr-oneloop/simplifier1/main.c @@ -6,9 +6,9 @@ int main() __CPROVER_assume(0<=y && y<=1); while(1) { switch(x) { - case 0 : + case 0 : if(y<=2) { - if(nondet()) x=1; + if(nondet()) x=1; else y++; } else x=2; diff --git a/regression/cbmc-incr-oneloop/unwind-forever1/main.c b/regression/cbmc-incr-oneloop/unwind-forever1/main.c index ae0667f8d43..874425968ef 100644 --- a/regression/cbmc-incr-oneloop/unwind-forever1/main.c +++ b/regression/cbmc-incr-oneloop/unwind-forever1/main.c @@ -4,7 +4,7 @@ int main() int x = nondet_int(); __CPROVER_assume(0<=x && x<=1); //no error within loop => will unwind forever if no loop bound is given - while(x<4) { + while(x<4) { x=x+1; } assert(x<4); diff --git a/regression/cbmc-incr/Ackermann02_false1/main.c b/regression/cbmc-incr/Ackermann02_false1/main.c index ddeb622e3e1..ebf7929c123 100644 --- a/regression/cbmc-incr/Ackermann02_false1/main.c +++ b/regression/cbmc-incr/Ackermann02_false1/main.c @@ -1,10 +1,10 @@ /* * Implementation the Ackermann function. * http://en.wikipedia.org/wiki/Ackermann_function - * + * * Author: Matthias Heizmann * Date: 2013-07-13 - * + * */ extern int __VERIFIER_nondet_int(void); @@ -27,7 +27,7 @@ int main() { if (m < 2 || result >= 4) { return 0; } else { - ERROR: + ERROR: goto ERROR; } } diff --git a/regression/cbmc-incr/Makefile b/regression/cbmc-incr/Makefile index 39b586a364c..965ce493fc5 100644 --- a/regression/cbmc-incr/Makefile +++ b/regression/cbmc-incr/Makefile @@ -1,6 +1,6 @@ default: tests.log -PARAM = --incremental --magic-numbers +PARAM = --incremental --magic-numbers # --refine --slice-formula test: diff --git a/regression/cbmc-incr/MultCommutative_true1/main.c b/regression/cbmc-incr/MultCommutative_true1/main.c index e99ad8e6b61..746820e3b49 100644 --- a/regression/cbmc-incr/MultCommutative_true1/main.c +++ b/regression/cbmc-incr/MultCommutative_true1/main.c @@ -1,10 +1,10 @@ /* * Recursive implementation multiplication by repeated addition * Check that this multiplication is commutative - * + * * Author: Jan Leike * Date: 2013-07-17 - * + * */ extern int __VERIFIER_nondet_int(void); diff --git a/regression/cbmc-incr/alarm1/main.c b/regression/cbmc-incr/alarm1/main.c index 4896a14f3c2..4c485d71988 100644 --- a/regression/cbmc-incr/alarm1/main.c +++ b/regression/cbmc-incr/alarm1/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr/alarm2/main.c b/regression/cbmc-incr/alarm2/main.c index 952c8f698a3..c5b62d3037e 100644 --- a/regression/cbmc-incr/alarm2/main.c +++ b/regression/cbmc-incr/alarm2/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr/alarm3/main.c b/regression/cbmc-incr/alarm3/main.c index 420f0c33e8e..1df007abbc7 100644 --- a/regression/cbmc-incr/alarm3/main.c +++ b/regression/cbmc-incr/alarm3/main.c @@ -116,7 +116,7 @@ void Alarm_system_compute(t_Alarm_system_io *_io_, t_Alarm_system_state *_state_ } else { if (_io_->VehLocked == 0) { _state_->InitSystem_OPEN = FALSE; - _state_->VehicleOpen_OPEN = TRUE; //possible BUG + _state_->VehicleOpen_OPEN = TRUE; //possible BUG } else { /* Perform during and on-event actions of state InitSystem */ _io_->AlarmArmed = TO_BOOL(1); @@ -379,11 +379,11 @@ t_Alarm_system_io havocIO() { int main() { int k=0; - t_Alarm_system_state _state_; - t_Alarm_system_state _state_old; + t_Alarm_system_state _state_; + t_Alarm_system_state _state_old; t_Alarm_system_io _io_; Alarm_system_init(&_io_,&_state_); - while(1) { + while(1) { _state_old = _state_; _io_ = havocIO(); Alarm_system_compute(&_io_,&_state_); @@ -394,4 +394,3 @@ int main() { } return 0; } - diff --git a/regression/cbmc-incr/arrays3/test.desc b/regression/cbmc-incr/arrays3/test.desc index 62af57c7d63..e811d53f304 100644 --- a/regression/cbmc-incr/arrays3/test.desc +++ b/regression/cbmc-incr/arrays3/test.desc @@ -1,6 +1,6 @@ CORE main.c ---no-unwinding-assertions +--no-unwinding-assertions ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc-incr/arrays4/test.desc b/regression/cbmc-incr/arrays4/test.desc index 62af57c7d63..e811d53f304 100644 --- a/regression/cbmc-incr/arrays4/test.desc +++ b/regression/cbmc-incr/arrays4/test.desc @@ -1,6 +1,6 @@ CORE main.c ---no-unwinding-assertions +--no-unwinding-assertions ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc-incr/assertion-after-loop1/main.c b/regression/cbmc-incr/assertion-after-loop1/main.c index b23bea554a4..115c392b84e 100644 --- a/regression/cbmc-incr/assertion-after-loop1/main.c +++ b/regression/cbmc-incr/assertion-after-loop1/main.c @@ -3,7 +3,7 @@ int main() { int x = nondet_int(); __CPROVER_assume(0<=x && x<=1); - while(x<4) { + while(x<4) { x=x+1; } assert(x<4); diff --git a/regression/cbmc-incr/cruise1/main.c b/regression/cbmc-incr/cruise1/main.c index 8318e62fd5b..436b0f029b9 100644 --- a/regression/cbmc-incr/cruise1/main.c +++ b/regression/cbmc-incr/cruise1/main.c @@ -5,7 +5,7 @@ /* modelled after */ /* Robert Bosch GmbH: Bosch Automotive Handbook. Bentley (2007) */ /* if you reuse this code, please cite also */ -/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for +/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for Reactive System Testing. In Testing Software and Systems LNCS Volume 8254, 2013, pp 133-148 */ /*******************************************************************************/ @@ -27,7 +27,7 @@ typedef struct state { #define I_BRAKE 5 typedef struct input { - int signal; + int signal; } t_input; void init(t_state *s) { @@ -48,7 +48,7 @@ void compute(t_input* i, t_state *s) { } else if((s->mode==0) && (s->speed==0) && (s->button==1)) { if((i->signal==I_GAS)||(i->signal==I_ACC)) {s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } else if((s->mode==1) && (s->speed==1) && (s->button==1)) { if(i->signal==I_GAS) { s->speed=2; s->mode=2; } @@ -64,12 +64,12 @@ void compute(t_input* i, t_state *s) { else if(i->signal==I_BUTTON) { s->mode=0; s->button=0; } } else if((s->mode==0) && (s->speed==2) && (s->button==0)) { - if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; - else if(i->signal==I_BUTTON) s->button=1; + if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; + else if(i->signal==I_BUTTON) s->button=1; } else if((s->mode==0) && (s->speed==2) && (s->button==1)) { if((i->signal==I_BRAKE)||(i->signal==I_DEC)) { s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } } diff --git a/regression/cbmc-incr/cruise2/main.c b/regression/cbmc-incr/cruise2/main.c index 42b49addaa2..26d397c06eb 100644 --- a/regression/cbmc-incr/cruise2/main.c +++ b/regression/cbmc-incr/cruise2/main.c @@ -5,7 +5,7 @@ /* modelled after */ /* Robert Bosch GmbH: Bosch Automotive Handbook. Bentley (2007) */ /* if you reuse this code, please cite also */ -/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for +/* Peter Schrammel, Tom Melham, Daniel Kroening. Chaining Test Cases for Reactive System Testing. In Testing Software and Systems LNCS Volume 8254, 2013, pp 133-148 */ /*******************************************************************************/ @@ -27,7 +27,7 @@ typedef struct state { #define I_BRAKE 5 typedef struct input { - int signal; + int signal; } t_input; void init(t_state *s) { @@ -48,7 +48,7 @@ void compute(t_input* i, t_state *s) { } else if((s->mode==0) && (s->speed==0) && (s->button==1)) { if((i->signal==I_GAS)||(i->signal==I_ACC)) {s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } else if((s->mode==1) && (s->speed==1) && (s->button==1)) { if(i->signal==I_GAS) { s->speed=2; s->mode=2; } @@ -64,12 +64,12 @@ void compute(t_input* i, t_state *s) { else if(i->signal==I_BUTTON) { s->mode=0; s->button=0; } } else if((s->mode==0) && (s->speed==2) && (s->button==0)) { - if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; - else if(i->signal==I_BUTTON) s->button=1; + if((i->signal==I_BRAKE)||(i->signal==I_DEC)) s->speed=1; + else if(i->signal==I_BUTTON) s->button=1; } else if((s->mode==0) && (s->speed==2) && (s->button==1)) { if((i->signal==I_BRAKE)||(i->signal==I_DEC)) { s->speed=1; s->mode=1; } - else if(i->signal==I_BUTTON) s->button=0; + else if(i->signal==I_BUTTON) s->button=0; } } diff --git a/regression/cbmc-incr/email_spec27_product31_false1/main.c b/regression/cbmc-incr/email_spec27_product31_false1/main.c index 89a30992c6e..4b3f0c100eb 100644 --- a/regression/cbmc-incr/email_spec27_product31_false1/main.c +++ b/regression/cbmc-incr/email_spec27_product31_false1/main.c @@ -143,8 +143,8 @@ void chuckKeyAddRjh(void) ; #line 61 void rjhEnableForwarding(void) ; #line 18 "Test.c" -void setup_bob__wrappee__Base(int bob___0 ) -{ +void setup_bob__wrappee__Base(int bob___0 ) +{ { { @@ -156,8 +156,8 @@ void setup_bob__wrappee__Base(int bob___0 ) } } #line 23 "Test.c" -void setup_bob(int bob___0 ) -{ +void setup_bob(int bob___0 ) +{ { { @@ -171,8 +171,8 @@ void setup_bob(int bob___0 ) } } #line 33 "Test.c" -void setup_rjh__wrappee__Base(int rjh___0 ) -{ +void setup_rjh__wrappee__Base(int rjh___0 ) +{ { { @@ -184,8 +184,8 @@ void setup_rjh__wrappee__Base(int rjh___0 ) } } #line 40 "Test.c" -void setup_rjh(int rjh___0 ) -{ +void setup_rjh(int rjh___0 ) +{ { { @@ -199,8 +199,8 @@ void setup_rjh(int rjh___0 ) } } #line 50 "Test.c" -void setup_chuck__wrappee__Base(int chuck___0 ) -{ +void setup_chuck__wrappee__Base(int chuck___0 ) +{ { { @@ -212,8 +212,8 @@ void setup_chuck__wrappee__Base(int chuck___0 ) } } #line 57 "Test.c" -void setup_chuck(int chuck___0 ) -{ +void setup_chuck(int chuck___0 ) +{ { { @@ -227,7 +227,7 @@ void setup_chuck(int chuck___0 ) } } #line 69 "Test.c" -void bobToRjh(void) +void bobToRjh(void) { int tmp ; int tmp___0 ; int tmp___1 ; @@ -259,8 +259,8 @@ void bobToRjh(void) } } #line 81 "Test.c" -void rjhToBob(void) -{ +void rjhToBob(void) +{ { { @@ -275,7 +275,7 @@ void rjhToBob(void) } #line 88 "Test.c" #line 95 "Test.c" -void setup(void) +void setup(void) { char const * __restrict __cil_tmp1 ; char const * __restrict __cil_tmp2 ; char const * __restrict __cil_tmp3 ; @@ -312,7 +312,7 @@ void setup(void) } } #line 112 "Test.c" -int main(void) +int main(void) { int retValue_acc ; int tmp ; @@ -341,7 +341,7 @@ int main(void) } } #line 125 "Test.c" -void bobKeyAdd(void) +void bobKeyAdd(void) { int tmp ; int tmp___0 ; char const * __restrict __cil_tmp3 ; @@ -375,8 +375,8 @@ void bobKeyAdd(void) } } #line 137 "Test.c" -void rjhKeyAdd(void) -{ +void rjhKeyAdd(void) +{ { { @@ -392,8 +392,8 @@ void rjhKeyAdd(void) } } #line 146 "Test.c" -void rjhKeyAddChuck(void) -{ +void rjhKeyAddChuck(void) +{ { { @@ -409,8 +409,8 @@ void rjhKeyAddChuck(void) } } #line 156 "Test.c" -void bobKeyAddChuck(void) -{ +void bobKeyAddChuck(void) +{ { { @@ -426,8 +426,8 @@ void bobKeyAddChuck(void) } } #line 165 "Test.c" -void chuckKeyAdd(void) -{ +void chuckKeyAdd(void) +{ { { @@ -443,8 +443,8 @@ void chuckKeyAdd(void) } } #line 174 "Test.c" -void chuckKeyAddRjh(void) -{ +void chuckKeyAddRjh(void) +{ { { @@ -460,8 +460,8 @@ void chuckKeyAddRjh(void) } } #line 183 "Test.c" -void rjhDeletePrivateKey(void) -{ +void rjhDeletePrivateKey(void) +{ { { @@ -473,8 +473,8 @@ void rjhDeletePrivateKey(void) } } #line 190 "Test.c" -void bobKeyChange(void) -{ +void bobKeyChange(void) +{ { { @@ -486,8 +486,8 @@ void bobKeyChange(void) } } #line 197 "Test.c" -void rjhKeyChange(void) -{ +void rjhKeyChange(void) +{ { { @@ -499,8 +499,8 @@ void rjhKeyChange(void) } } #line 204 "Test.c" -void rjhEnableForwarding(void) -{ +void rjhEnableForwarding(void) +{ { { @@ -516,7 +516,7 @@ void rjhEnableForwarding(void) #line 41 "featureselect.h" int select_one(void) ; #line 8 "featureselect.c" -int select_one(void) +int select_one(void) { int retValue_acc ; int choice = __VERIFIER_nondet_int(); @@ -530,8 +530,8 @@ int select_one(void) } } #line 14 "featureselect.c" -void select_features(void) -{ +void select_features(void) +{ { #line 115 "featureselect.c" @@ -539,8 +539,8 @@ void select_features(void) } } #line 20 "featureselect.c" -void select_helpers(void) -{ +void select_helpers(void) +{ { #line 133 "featureselect.c" @@ -548,7 +548,7 @@ void select_helpers(void) } } #line 25 "featureselect.c" -int valid_product(void) +int valid_product(void) { int retValue_acc ; { @@ -607,7 +607,7 @@ void setEmailIsSignatureVerified(int handle , int value ) ; #line 5 "EmailLib.c" int __ste_Email_counter = 0; #line 7 "EmailLib.c" -int initEmail(void) +int initEmail(void) { int retValue_acc ; { @@ -634,7 +634,7 @@ int __ste_email_id0 = 0; #line 17 "EmailLib.c" int __ste_email_id1 = 0; #line 19 "EmailLib.c" -int getEmailId(int handle ) +int getEmailId(int handle ) { int retValue_acc ; { @@ -663,8 +663,8 @@ int getEmailId(int handle ) } } #line 29 "EmailLib.c" -void setEmailId(int handle , int value ) -{ +void setEmailId(int handle , int value ) +{ { #line 35 @@ -689,7 +689,7 @@ int __ste_email_from0 = 0; #line 39 "EmailLib.c" int __ste_email_from1 = 0; #line 41 "EmailLib.c" -int getEmailFrom(int handle ) +int getEmailFrom(int handle ) { int retValue_acc ; { @@ -718,8 +718,8 @@ int getEmailFrom(int handle ) } } #line 51 "EmailLib.c" -void setEmailFrom(int handle , int value ) -{ +void setEmailFrom(int handle , int value ) +{ { #line 57 @@ -744,7 +744,7 @@ int __ste_email_to0 = 0; #line 61 "EmailLib.c" int __ste_email_to1 = 0; #line 63 "EmailLib.c" -int getEmailTo(int handle ) +int getEmailTo(int handle ) { int retValue_acc ; { @@ -773,8 +773,8 @@ int getEmailTo(int handle ) } } #line 73 "EmailLib.c" -void setEmailTo(int handle , int value ) -{ +void setEmailTo(int handle , int value ) +{ { #line 79 @@ -799,7 +799,7 @@ char *__ste_email_subject0 ; #line 83 "EmailLib.c" char *__ste_email_subject1 ; #line 85 "EmailLib.c" -char *getEmailSubject(int handle ) +char *getEmailSubject(int handle ) { char *retValue_acc ; void *__cil_tmp3 ; @@ -831,8 +831,8 @@ char *getEmailSubject(int handle ) } } #line 95 "EmailLib.c" -void setEmailSubject(int handle , char *value ) -{ +void setEmailSubject(int handle , char *value ) +{ { #line 101 @@ -857,7 +857,7 @@ char *__ste_email_body0 = (char *)0; #line 105 "EmailLib.c" char *__ste_email_body1 = (char *)0; #line 107 "EmailLib.c" -char *getEmailBody(int handle ) +char *getEmailBody(int handle ) { char *retValue_acc ; void *__cil_tmp3 ; @@ -889,8 +889,8 @@ char *getEmailBody(int handle ) } } #line 117 "EmailLib.c" -void setEmailBody(int handle , char *value ) -{ +void setEmailBody(int handle , char *value ) +{ { #line 123 @@ -915,7 +915,7 @@ int __ste_email_isEncrypted0 = 0; #line 127 "EmailLib.c" int __ste_email_isEncrypted1 = 0; #line 129 "EmailLib.c" -int isEncrypted(int handle ) +int isEncrypted(int handle ) { int retValue_acc ; { @@ -944,8 +944,8 @@ int isEncrypted(int handle ) } } #line 139 "EmailLib.c" -void setEmailIsEncrypted(int handle , int value ) -{ +void setEmailIsEncrypted(int handle , int value ) +{ { #line 145 @@ -970,7 +970,7 @@ int __ste_email_encryptionKey0 = 0; #line 149 "EmailLib.c" int __ste_email_encryptionKey1 = 0; #line 151 "EmailLib.c" -int getEmailEncryptionKey(int handle ) +int getEmailEncryptionKey(int handle ) { int retValue_acc ; { @@ -999,8 +999,8 @@ int getEmailEncryptionKey(int handle ) } } #line 161 "EmailLib.c" -void setEmailEncryptionKey(int handle , int value ) -{ +void setEmailEncryptionKey(int handle , int value ) +{ { #line 167 @@ -1025,7 +1025,7 @@ int __ste_email_isSigned0 = 0; #line 171 "EmailLib.c" int __ste_email_isSigned1 = 0; #line 173 "EmailLib.c" -int isSigned(int handle ) +int isSigned(int handle ) { int retValue_acc ; { @@ -1054,8 +1054,8 @@ int isSigned(int handle ) } } #line 183 "EmailLib.c" -void setEmailIsSigned(int handle , int value ) -{ +void setEmailIsSigned(int handle , int value ) +{ { #line 189 @@ -1080,7 +1080,7 @@ int __ste_email_signKey0 = 0; #line 193 "EmailLib.c" int __ste_email_signKey1 = 0; #line 195 "EmailLib.c" -int getEmailSignKey(int handle ) +int getEmailSignKey(int handle ) { int retValue_acc ; { @@ -1109,8 +1109,8 @@ int getEmailSignKey(int handle ) } } #line 205 "EmailLib.c" -void setEmailSignKey(int handle , int value ) -{ +void setEmailSignKey(int handle , int value ) +{ { #line 211 @@ -1135,7 +1135,7 @@ int __ste_email_isSignatureVerified0 ; #line 215 "EmailLib.c" int __ste_email_isSignatureVerified1 ; #line 217 "EmailLib.c" -int isVerified(int handle ) +int isVerified(int handle ) { int retValue_acc ; { @@ -1164,8 +1164,8 @@ int isVerified(int handle ) } } #line 227 "EmailLib.c" -void setEmailIsSignatureVerified(int handle , int value ) -{ +void setEmailIsSignatureVerified(int handle , int value ) +{ { #line 233 @@ -1230,7 +1230,7 @@ int findClientAddressBookAlias(int handle , int userid ) ; #line 5 "ClientLib.c" int __ste_Client_counter = 0; #line 7 "ClientLib.c" -int initClient(void) +int initClient(void) { int retValue_acc ; { @@ -1259,7 +1259,7 @@ char *__ste_client_name1 = (char *)0; #line 19 "ClientLib.c" char *__ste_client_name2 = (char *)0; #line 22 "ClientLib.c" -char *getClientName(int handle ) +char *getClientName(int handle ) { char *retValue_acc ; void *__cil_tmp3 ; @@ -1299,8 +1299,8 @@ char *getClientName(int handle ) } } #line 34 "ClientLib.c" -void setClientName(int handle , char *value ) -{ +void setClientName(int handle , char *value ) +{ { #line 42 @@ -1335,7 +1335,7 @@ int __ste_client_outbuffer2 = 0; #line 50 "ClientLib.c" int __ste_client_outbuffer3 = 0; #line 53 "ClientLib.c" -int getClientOutbuffer(int handle ) +int getClientOutbuffer(int handle ) { int retValue_acc ; { @@ -1372,8 +1372,8 @@ int getClientOutbuffer(int handle ) } } #line 65 "ClientLib.c" -void setClientOutbuffer(int handle , int value ) -{ +void setClientOutbuffer(int handle , int value ) +{ { #line 73 @@ -1406,7 +1406,7 @@ int __ste_ClientAddressBook_size1 = 0; #line 81 "ClientLib.c" int __ste_ClientAddressBook_size2 = 0; #line 84 "ClientLib.c" -int getClientAddressBookSize(int handle ) +int getClientAddressBookSize(int handle ) { int retValue_acc ; { @@ -1443,8 +1443,8 @@ int getClientAddressBookSize(int handle ) } } #line 96 "ClientLib.c" -void setClientAddressBookSize(int handle , int value ) -{ +void setClientAddressBookSize(int handle , int value ) +{ { #line 104 @@ -1471,7 +1471,7 @@ void setClientAddressBookSize(int handle , int value ) } } #line 106 "ClientLib.c" -int createClientAddressBookEntry(int handle ) +int createClientAddressBookEntry(int handle ) { int retValue_acc ; int size ; int tmp ; @@ -1525,7 +1525,7 @@ int __ste_Client_AddressBook2_Alias1 = 0; #line 131 "ClientLib.c" int __ste_Client_AddressBook2_Alias2 = 0; #line 134 "ClientLib.c" -int getClientAddressBookAlias(int handle , int index ) +int getClientAddressBookAlias(int handle , int index ) { int retValue_acc ; { @@ -1634,7 +1634,7 @@ int getClientAddressBookAlias(int handle , int index ) } } #line 171 "ClientLib.c" -int findClientAddressBookAlias(int handle , int userid ) +int findClientAddressBookAlias(int handle , int userid ) { int retValue_acc ; { @@ -1743,8 +1743,8 @@ int findClientAddressBookAlias(int handle , int userid ) } } #line 208 "ClientLib.c" -void setClientAddressBookAlias(int handle , int index , int value ) -{ +void setClientAddressBookAlias(int handle , int index , int value ) +{ { #line 234 @@ -1840,7 +1840,7 @@ int __ste_Client_AddressBook2_Address1 = 0; #line 252 "ClientLib.c" int __ste_Client_AddressBook2_Address2 = 0; #line 255 "ClientLib.c" -int getClientAddressBookAddress(int handle , int index ) +int getClientAddressBookAddress(int handle , int index ) { int retValue_acc ; { @@ -1949,8 +1949,8 @@ int getClientAddressBookAddress(int handle , int index ) } } #line 291 "ClientLib.c" -void setClientAddressBookAddress(int handle , int index , int value ) -{ +void setClientAddressBookAddress(int handle , int index , int value ) +{ { #line 317 @@ -2034,7 +2034,7 @@ int __ste_client_autoResponse1 = 0; #line 323 "ClientLib.c" int __ste_client_autoResponse2 = 0; #line 326 "ClientLib.c" -int getClientAutoResponse(int handle ) +int getClientAutoResponse(int handle ) { int retValue_acc ; { @@ -2071,8 +2071,8 @@ int getClientAutoResponse(int handle ) } } #line 338 "ClientLib.c" -void setClientAutoResponse(int handle , int value ) -{ +void setClientAutoResponse(int handle , int value ) +{ { #line 346 @@ -2105,7 +2105,7 @@ int __ste_client_privateKey1 = 0; #line 352 "ClientLib.c" int __ste_client_privateKey2 = 0; #line 355 "ClientLib.c" -int getClientPrivateKey(int handle ) +int getClientPrivateKey(int handle ) { int retValue_acc ; { @@ -2142,8 +2142,8 @@ int getClientPrivateKey(int handle ) } } #line 367 "ClientLib.c" -void setClientPrivateKey(int handle , int value ) -{ +void setClientPrivateKey(int handle , int value ) +{ { #line 375 @@ -2176,7 +2176,7 @@ int __ste_ClientKeyring_size1 = 0; #line 381 "ClientLib.c" int __ste_ClientKeyring_size2 = 0; #line 384 "ClientLib.c" -int getClientKeyringSize(int handle ) +int getClientKeyringSize(int handle ) { int retValue_acc ; { @@ -2213,8 +2213,8 @@ int getClientKeyringSize(int handle ) } } #line 396 "ClientLib.c" -void setClientKeyringSize(int handle , int value ) -{ +void setClientKeyringSize(int handle , int value ) +{ { #line 404 @@ -2241,7 +2241,7 @@ void setClientKeyringSize(int handle , int value ) } } #line 406 "ClientLib.c" -int createClientKeyringEntry(int handle ) +int createClientKeyringEntry(int handle ) { int retValue_acc ; int size ; int tmp ; @@ -2295,7 +2295,7 @@ int __ste_Client_Keyring2_User1 = 0; #line 430 "ClientLib.c" int __ste_Client_Keyring2_User2 = 0; #line 433 "ClientLib.c" -int getClientKeyringUser(int handle , int index ) +int getClientKeyringUser(int handle , int index ) { int retValue_acc ; { @@ -2380,8 +2380,8 @@ int getClientKeyringUser(int handle , int index ) } } #line 473 "ClientLib.c" -void setClientKeyringUser(int handle , int index , int value ) -{ +void setClientKeyringUser(int handle , int index , int value ) +{ { #line 499 @@ -2459,7 +2459,7 @@ int __ste_Client_Keyring2_PublicKey1 = 0; #line 517 "ClientLib.c" int __ste_Client_Keyring2_PublicKey2 = 0; #line 520 "ClientLib.c" -int getClientKeyringPublicKey(int handle , int index ) +int getClientKeyringPublicKey(int handle , int index ) { int retValue_acc ; { @@ -2544,7 +2544,7 @@ int getClientKeyringPublicKey(int handle , int index ) } } #line 557 "ClientLib.c" -int findPublicKey(int handle , int userid ) +int findPublicKey(int handle , int userid ) { int retValue_acc ; { @@ -2629,8 +2629,8 @@ int findPublicKey(int handle , int userid ) } } #line 595 "ClientLib.c" -void setClientKeyringPublicKey(int handle , int index , int value ) -{ +void setClientKeyringPublicKey(int handle , int index , int value ) +{ { #line 621 @@ -2698,7 +2698,7 @@ int __ste_client_forwardReceiver2 = 0; #line 629 "ClientLib.c" int __ste_client_forwardReceiver3 = 0; #line 631 "ClientLib.c" -int getClientForwardReceiver(int handle ) +int getClientForwardReceiver(int handle ) { int retValue_acc ; { @@ -2735,8 +2735,8 @@ int getClientForwardReceiver(int handle ) } } #line 643 "ClientLib.c" -void setClientForwardReceiver(int handle , int value ) -{ +void setClientForwardReceiver(int handle , int value ) +{ { #line 651 @@ -2769,7 +2769,7 @@ int __ste_client_idCounter1 = 0; #line 657 "ClientLib.c" int __ste_client_idCounter2 = 0; #line 660 "ClientLib.c" -int getClientId(int handle ) +int getClientId(int handle ) { int retValue_acc ; { @@ -2806,8 +2806,8 @@ int getClientId(int handle ) } } #line 672 "ClientLib.c" -void setClientId(int handle , int value ) -{ +void setClientId(int handle , int value ) +{ { #line 680 @@ -2836,7 +2836,7 @@ void setClientId(int handle , int value ) #line 1 "scenario.o" #pragma merger(0,"scenario.i","") #line 1 "scenario.c" -void test(void) +void test(void) { int op1 ; int op2 ; int op3 ; @@ -2916,7 +2916,7 @@ void test(void) goto _L___8; } } else { - _L___8: /* CIL Label */ + _L___8: /* CIL Label */ #line 19 if (! op2) { { @@ -2931,7 +2931,7 @@ void test(void) goto _L___7; } } else { - _L___7: /* CIL Label */ + _L___7: /* CIL Label */ #line 22 if (! op3) { { @@ -2950,7 +2950,7 @@ void test(void) goto _L___6; } } else { - _L___6: /* CIL Label */ + _L___6: /* CIL Label */ #line 26 if (! op4) { { @@ -2969,7 +2969,7 @@ void test(void) goto _L___5; } } else { - _L___5: /* CIL Label */ + _L___5: /* CIL Label */ #line 30 if (! op5) { { @@ -2988,7 +2988,7 @@ void test(void) goto _L___4; } } else { - _L___4: /* CIL Label */ + _L___4: /* CIL Label */ #line 34 if (! op6) { { @@ -3007,7 +3007,7 @@ void test(void) goto _L___3; } } else { - _L___3: /* CIL Label */ + _L___3: /* CIL Label */ #line 38 if (! op7) { { @@ -3026,7 +3026,7 @@ void test(void) goto _L___2; } } else { - _L___2: /* CIL Label */ + _L___2: /* CIL Label */ #line 42 if (! op8) { { @@ -3041,7 +3041,7 @@ void test(void) goto _L___1; } } else { - _L___1: /* CIL Label */ + _L___1: /* CIL Label */ #line 45 if (! op9) { { @@ -3060,7 +3060,7 @@ void test(void) goto _L___0; } } else { - _L___0: /* CIL Label */ + _L___0: /* CIL Label */ #line 49 if (! op10) { { @@ -3079,7 +3079,7 @@ void test(void) goto _L; } } else { - _L: /* CIL Label */ + _L: /* CIL Label */ #line 53 if (! op11) { { @@ -3126,7 +3126,7 @@ void test(void) #line 4 "wsllib.h" void __automaton_fail(void) ; #line 12 "VerifyForward_spec.c" -__inline void __utac_acc__VerifyForward_spec__1(int client , int msg ) +__inline void __utac_acc__VerifyForward_spec__1(int client , int msg ) { int pubkey ; int tmp ; int tmp___0 ; @@ -3179,7 +3179,7 @@ extern __attribute__((__nothrow__)) void free(void *__ptr ) ; #line 32 "libacc.c" void __utac__exception__cf_handler_set(void *exception , int (*cflow_func)(int , int ) , - int val ) + int val ) { struct __UTAC__EXCEPTION *excep ; struct __UTAC__CFLOW_FUNC *cf ; void *tmp ; @@ -3245,7 +3245,7 @@ void __utac__exception__cf_handler_set(void *exception , int (*cflow_func)(int } } #line 44 "libacc.c" -void __utac__exception__cf_handler_free(void *exception ) +void __utac__exception__cf_handler_free(void *exception ) { struct __UTAC__EXCEPTION *excep ; struct __UTAC__CFLOW_FUNC *cf ; struct __UTAC__CFLOW_FUNC *tmp ; @@ -3324,7 +3324,7 @@ void __utac__exception__cf_handler_free(void *exception ) } } #line 59 "libacc.c" -void __utac__exception__cf_handler_reset(void *exception ) +void __utac__exception__cf_handler_reset(void *exception ) { struct __UTAC__EXCEPTION *excep ; struct __UTAC__CFLOW_FUNC *cf ; unsigned long __cil_tmp5 ; @@ -3412,7 +3412,7 @@ void *__utac__error_stack_mgt(void *env , int mode , int count ) ; #line 80 "libacc.c" static struct __ACC__ERR *head = (struct __ACC__ERR *)0; #line 79 "libacc.c" -void *__utac__error_stack_mgt(void *env , int mode , int count ) +void *__utac__error_stack_mgt(void *env , int mode , int count ) { void *retValue_acc ; struct __ACC__ERR *new ; void *tmp ; @@ -3564,7 +3564,7 @@ void *__utac__error_stack_mgt(void *env , int mode , int count ) } } #line 122 "libacc.c" -void *__utac__get_this_arg(int i , struct JoinPoint *this ) +void *__utac__get_this_arg(int i , struct JoinPoint *this ) { void *retValue_acc ; unsigned long __cil_tmp4 ; unsigned long __cil_tmp5 ; @@ -3628,7 +3628,7 @@ void *__utac__get_this_arg(int i , struct JoinPoint *this ) } } #line 129 "libacc.c" -char const *__utac__get_this_argtype(int i , struct JoinPoint *this ) +char const *__utac__get_this_argtype(int i , struct JoinPoint *this ) { char const *retValue_acc ; unsigned long __cil_tmp4 ; unsigned long __cil_tmp5 ; @@ -3696,7 +3696,7 @@ char const *__utac__get_this_argtype(int i , struct JoinPoint *this ) #line 1 "Util.h" int prompt(char *msg ) ; #line 9 "Util.c" -int prompt(char *msg ) +int prompt(char *msg ) { int retValue_acc ; int retval ; char const * __restrict __cil_tmp4 ; @@ -3749,7 +3749,7 @@ int queued_message ; #line 12 "Client.c" int queued_client ; #line 18 "Client.c" -void mail(int client , int msg ) +void mail(int client , int msg ) { int tmp ; { @@ -3766,7 +3766,7 @@ void mail(int client , int msg ) } } #line 27 "Client.c" -void outgoing__wrappee__Keys(int client , int msg ) +void outgoing__wrappee__Keys(int client , int msg ) { int tmp ; { @@ -3783,7 +3783,7 @@ void outgoing__wrappee__Keys(int client , int msg ) } } #line 33 "Client.c" -void outgoing__wrappee__Encrypt(int client , int msg ) +void outgoing__wrappee__Encrypt(int client , int msg ) { int receiver ; int tmp ; int pubkey ; @@ -3820,8 +3820,8 @@ void outgoing__wrappee__Encrypt(int client , int msg ) } } #line 51 "Client.c" -void outgoing(int client , int msg ) -{ +void outgoing(int client , int msg ) +{ { { @@ -3835,7 +3835,7 @@ void outgoing(int client , int msg ) } } #line 60 "Client.c" -void deliver(int client , int msg ) +void deliver(int client , int msg ) { int __utac__ad__arg1 ; int __utac__ad__arg2 ; @@ -3855,8 +3855,8 @@ void deliver(int client , int msg ) } } #line 68 "Client.c" -void incoming__wrappee__Sign(int client , int msg ) -{ +void incoming__wrappee__Sign(int client , int msg ) +{ { { @@ -3868,7 +3868,7 @@ void incoming__wrappee__Sign(int client , int msg ) } } #line 75 "Client.c" -void incoming__wrappee__Forward(int client , int msg ) +void incoming__wrappee__Forward(int client , int msg ) { int fwreceiver ; int tmp ; @@ -3897,8 +3897,8 @@ void incoming__wrappee__Forward(int client , int msg ) } } #line 89 "Client.c" -void incoming__wrappee__Verify(int client , int msg ) -{ +void incoming__wrappee__Verify(int client , int msg ) +{ { { @@ -3912,7 +3912,7 @@ void incoming__wrappee__Verify(int client , int msg ) } } #line 96 "Client.c" -void incoming(int client , int msg ) +void incoming(int client , int msg ) { int privkey ; int tmp ; int tmp___0 ; @@ -3966,7 +3966,7 @@ void incoming(int client , int msg ) } } #line 115 "Client.c" -int createClient(char *name ) +int createClient(char *name ) { int retValue_acc ; int client ; int tmp ; @@ -3987,7 +3987,7 @@ int createClient(char *name ) } } #line 123 "Client.c" -void sendEmail(int sender , int receiver ) +void sendEmail(int sender , int receiver ) { int email ; int tmp ; @@ -4005,8 +4005,8 @@ void sendEmail(int sender , int receiver ) } } #line 133 "Client.c" -void queue(int client , int msg ) -{ +void queue(int client , int msg ) +{ { #line 134 @@ -4020,7 +4020,7 @@ void queue(int client , int msg ) } } #line 142 "Client.c" -int is_queue_empty(void) +int is_queue_empty(void) { int retValue_acc ; { @@ -4033,7 +4033,7 @@ int is_queue_empty(void) } } #line 149 "Client.c" -int get_queued_client(void) +int get_queued_client(void) { int retValue_acc ; { @@ -4046,7 +4046,7 @@ int get_queued_client(void) } } #line 156 "Client.c" -int get_queued_email(void) +int get_queued_email(void) { int retValue_acc ; { @@ -4059,7 +4059,7 @@ int get_queued_email(void) } } #line 162 "Client.c" -int isKeyPairValid(int publicKey , int privateKey ) +int isKeyPairValid(int publicKey , int privateKey ) { int retValue_acc ; char const * __restrict __cil_tmp4 ; @@ -4096,8 +4096,8 @@ int isKeyPairValid(int publicKey , int privateKey ) } } #line 172 "Client.c" -void generateKeyPair(int client , int seed ) -{ +void generateKeyPair(int client , int seed ) +{ { { @@ -4109,7 +4109,7 @@ void generateKeyPair(int client , int seed ) } } #line 178 "Client.c" -void sign(int client , int msg ) +void sign(int client , int msg ) { int privkey ; int tmp ; @@ -4138,8 +4138,8 @@ void sign(int client , int msg ) } } #line 188 "Client.c" -void forward(int client , int msg ) -{ +void forward(int client , int msg ) +{ { { @@ -4155,7 +4155,7 @@ void forward(int client , int msg ) } } #line 197 "Client.c" -void verify(int client , int msg ) +void verify(int client , int msg ) { int tmp ; int tmp___0 ; int pubkey ; @@ -4221,8 +4221,8 @@ void verify(int client , int msg ) #line 1 "wsllib_check.o" #pragma merger(0,"wsllib_check.i","") #line 3 "wsllib_check.c" -void __automaton_fail(void) -{ +void __automaton_fail(void) +{ { goto ERROR; @@ -4236,7 +4236,7 @@ void __automaton_fail(void) #line 15 "Email.h" int cloneEmail(int msg ) ; #line 9 "Email.c" -void printMail__wrappee__Keys(int msg ) +void printMail__wrappee__Keys(int msg ) { int tmp ; int tmp___0 ; int tmp___1 ; @@ -4278,7 +4278,7 @@ void printMail__wrappee__Keys(int msg ) } } #line 17 "Email.c" -void printMail__wrappee__Encrypt(int msg ) +void printMail__wrappee__Encrypt(int msg ) { int tmp ; int tmp___0 ; char const * __restrict __cil_tmp4 ; @@ -4306,7 +4306,7 @@ void printMail__wrappee__Encrypt(int msg ) } } #line 26 "Email.c" -void printMail__wrappee__Forward(int msg ) +void printMail__wrappee__Forward(int msg ) { int tmp ; int tmp___0 ; char const * __restrict __cil_tmp4 ; @@ -4334,7 +4334,7 @@ void printMail__wrappee__Forward(int msg ) } } #line 33 "Email.c" -void printMail(int msg ) +void printMail(int msg ) { int tmp ; char const * __restrict __cil_tmp3 ; @@ -4354,7 +4354,7 @@ void printMail(int msg ) } } #line 41 "Email.c" -int isReadable__wrappee__Keys(int msg ) +int isReadable__wrappee__Keys(int msg ) { int retValue_acc ; { @@ -4367,7 +4367,7 @@ int isReadable__wrappee__Keys(int msg ) } } #line 49 "Email.c" -int isReadable(int msg ) +int isReadable(int msg ) { int retValue_acc ; int tmp ; @@ -4395,7 +4395,7 @@ int isReadable(int msg ) } } #line 57 "Email.c" -int cloneEmail(int msg ) +int cloneEmail(int msg ) { int retValue_acc ; { @@ -4408,7 +4408,7 @@ int cloneEmail(int msg ) } } #line 62 "Email.c" -int createEmail(int from , int to ) +int createEmail(int from , int to ) { int retValue_acc ; int msg ; diff --git a/regression/cbmc-incr/induction1/main.c b/regression/cbmc-incr/induction1/main.c index 63f82e856e5..2cc849ab513 100644 --- a/regression/cbmc-incr/induction1/main.c +++ b/regression/cbmc-incr/induction1/main.c @@ -3,13 +3,13 @@ int main() { signed x,y; - while(1) + while(1) { __CPROVER_assume(x>=10); signed t = x; - if((long)x+y<=INT_MAX) + if((long)x+y<=INT_MAX) x = x+y; y = t; - assert(x>=10); + assert(x>=10); } } diff --git a/regression/cbmc-incr/moreloops1/main.c b/regression/cbmc-incr/moreloops1/main.c index ff2941653fa..b2a49d88527 100644 --- a/regression/cbmc-incr/moreloops1/main.c +++ b/regression/cbmc-incr/moreloops1/main.c @@ -3,11 +3,11 @@ int main() { int x = nondet_int(); __CPROVER_assume(0<=x && x<=1); - while(x<4) + while(x<4) { x=x+1; } - while(x<10) + while(x<10) { x=x+1; assert(x<10); diff --git a/regression/cbmc-incr/simplifier1/main.c b/regression/cbmc-incr/simplifier1/main.c index ece5871b540..fe64405ac9f 100644 --- a/regression/cbmc-incr/simplifier1/main.c +++ b/regression/cbmc-incr/simplifier1/main.c @@ -6,9 +6,9 @@ int main() __CPROVER_assume(0<=y && y<=1); while(1) { switch(x) { - case 0 : + case 0 : if(y<=2) { - if(nondet()) x=1; + if(nondet()) x=1; else y++; } else x=2; diff --git a/regression/cbmc-incr/unwind-not-forever1/main.c b/regression/cbmc-incr/unwind-not-forever1/main.c index ae0667f8d43..874425968ef 100644 --- a/regression/cbmc-incr/unwind-not-forever1/main.c +++ b/regression/cbmc-incr/unwind-not-forever1/main.c @@ -4,7 +4,7 @@ int main() int x = nondet_int(); __CPROVER_assume(0<=x && x<=1); //no error within loop => will unwind forever if no loop bound is given - while(x<4) { + while(x<4) { x=x+1; } assert(x<4); diff --git a/regression/cbmc-with-incr/ASHR1/main.c b/regression/cbmc-with-incr/ASHR1/main.c index 1963700949a..a99bf808e8f 100644 --- a/regression/cbmc-with-incr/ASHR1/main.c +++ b/regression/cbmc-with-incr/ASHR1/main.c @@ -6,16 +6,16 @@ int main() x>>=1; assert(x==-2); assert(y==-2); - + // should also work with mixed types assert(((-2)>>1u)==-1); - // more arithmetic shifts for negative numbers + // more arithmetic shifts for negative numbers x=-1; - x=x>>1; + x=x>>1; assert(x==-1); - + x=-10; x=x>>10; - assert(x==-1); + assert(x==-1); } diff --git a/regression/cbmc-with-incr/Address_of1/main.c b/regression/cbmc-with-incr/Address_of1/main.c index cbb4756b046..f5fcb9c5f9f 100644 --- a/regression/cbmc-with-incr/Address_of1/main.c +++ b/regression/cbmc-with-incr/Address_of1/main.c @@ -5,29 +5,29 @@ int main() { int some_int=20; int *p; - + // Compound literals are l-values, so their address // can be taken. p=(int []){ 1, 2, 3, some_int }; - + assert(p[0]==1); assert(p[1]==2); assert(p[2]==3); assert(p[3]==20); - + struct S { int x, y; } *q; - + q=&(struct S){ .x=1 }; - + assert(q->x==1); assert(q->y==0); - + const char *sptr="asd"; assert(sptr[0]=='a'); assert(sptr[1]=='s'); assert(sptr[2]=='d'); assert(sptr[3]==0); - + const wchar_t *wsptr; wsptr=L"asd"; assert(wsptr[0]=='a'); diff --git a/regression/cbmc-with-incr/Anonymous_Struct2/main.c b/regression/cbmc-with-incr/Anonymous_Struct2/main.c index 9e4edd76b1b..ddfbe74bec6 100644 --- a/regression/cbmc-with-incr/Anonymous_Struct2/main.c +++ b/regression/cbmc-with-incr/Anonymous_Struct2/main.c @@ -29,7 +29,7 @@ struct S_struct union U_union { int x, y; }; - + int z; } s; @@ -40,7 +40,7 @@ int main() s.x=1; s.y=2; s.z=3; - + assert(s2.y==1); assert(s2.z==1); } diff --git a/regression/cbmc-with-incr/Anonymous_Struct3/main.c b/regression/cbmc-with-incr/Anonymous_Struct3/main.c index 8121e124e8d..f33d614045c 100644 --- a/regression/cbmc-with-incr/Anonymous_Struct3/main.c +++ b/regression/cbmc-with-incr/Anonymous_Struct3/main.c @@ -5,11 +5,11 @@ typedef union my_U { unsigned : 1; unsigned f1 : 1; }; - char raw; + char raw; } fields_t; fields_t x; - + int main() { x.f1 = 1; diff --git a/regression/cbmc-with-incr/Array_Initialization1/main.c b/regression/cbmc-with-incr/Array_Initialization1/main.c index db867b00d99..a9d976cf6f7 100644 --- a/regression/cbmc-with-incr/Array_Initialization1/main.c +++ b/regression/cbmc-with-incr/Array_Initialization1/main.c @@ -20,11 +20,10 @@ int main() // both must be complete sizeof(abc1); sizeof(abc2); - + assert(string_array[0][0][0]=='1'); assert(string_array[0][0][1]=='2'); assert(string_array[0][0][2]=='3'); assert(string_array[0][0][3]=='4'); assert(string_array[0][0][4]==0); } - diff --git a/regression/cbmc-with-incr/Array_Initialization3/main.c b/regression/cbmc-with-incr/Array_Initialization3/main.c index 5cfe8b93eb9..f9dc6e270f8 100644 --- a/regression/cbmc-with-incr/Array_Initialization3/main.c +++ b/regression/cbmc-with-incr/Array_Initialization3/main.c @@ -22,16 +22,16 @@ int main(void) { assert(array1[0][1]==2); assert(array1[1][0]==3); // returned false in this case - + assert(array2[0]==0); assert(array2[1]==10); assert(array2[10]==100); assert(sizeof(array2)==sizeof(int)*11); - + assert(sizeof(array3)==sizeof(int)*8); - + assert(sizeof(array7)==sizeof(int)*2); assert(sizeof(array8)==sizeof(int)*3); - + return 0; } diff --git a/regression/cbmc-with-incr/Assumption1/main.c b/regression/cbmc-with-incr/Assumption1/main.c index 25c8d4472f8..dfd9db4e67d 100644 --- a/regression/cbmc-with-incr/Assumption1/main.c +++ b/regression/cbmc-with-incr/Assumption1/main.c @@ -1,7 +1,7 @@ int main() { int x; - + __CPROVER_assume(x>=0); assert(x!=-1); @@ -10,4 +10,3 @@ int main() __CPROVER_assume(x==1); assert(x==1); // passes } - diff --git a/regression/cbmc-with-incr/BV_Arithmetic2/main.c b/regression/cbmc-with-incr/BV_Arithmetic2/main.c index b9cdf2cdce4..86c3911b20c 100644 --- a/regression/cbmc-with-incr/BV_Arithmetic2/main.c +++ b/regression/cbmc-with-incr/BV_Arithmetic2/main.c @@ -16,6 +16,6 @@ int main() r0=test_bit_parity(699050); assert(r0==0); - r1=test_bit_parity(699050+1); + r1=test_bit_parity(699050+1); assert(r1==1); } diff --git a/regression/cbmc-with-incr/BV_Arithmetic4/main.c b/regression/cbmc-with-incr/BV_Arithmetic4/main.c index 3321bcb90d7..3499cd5f66b 100644 --- a/regression/cbmc-with-incr/BV_Arithmetic4/main.c +++ b/regression/cbmc-with-incr/BV_Arithmetic4/main.c @@ -8,14 +8,14 @@ int test_extend2(int x, unsigned width) x = bit | (~mask & x); mask <<= 1; bit <<= 1; - } + } return x; } int main() { int r; - + r=test_extend2(4, 3); assert(r==-4); } diff --git a/regression/cbmc-with-incr/BV_Arithmetic5/main.c b/regression/cbmc-with-incr/BV_Arithmetic5/main.c index 130e7f1014d..bc013cc1a75 100644 --- a/regression/cbmc-with-incr/BV_Arithmetic5/main.c +++ b/regression/cbmc-with-incr/BV_Arithmetic5/main.c @@ -1,7 +1,7 @@ unsigned int test_log2(unsigned int v) { unsigned c = 0; // c will be lg(v) - while (v >>= 1) + while (v >>= 1) { c++; } @@ -11,7 +11,7 @@ unsigned int test_log2(unsigned int v) int main() { int r; - + r=test_log2(128); assert(r==7); } diff --git a/regression/cbmc-with-incr/BV_Arithmetic6/main.c b/regression/cbmc-with-incr/BV_Arithmetic6/main.c index 19af0c6b425..d971a119fd0 100644 --- a/regression/cbmc-with-incr/BV_Arithmetic6/main.c +++ b/regression/cbmc-with-incr/BV_Arithmetic6/main.c @@ -2,7 +2,7 @@ int main() { { unsigned i, j, k, l; - + j=k; i=j/2; l=j>>1; @@ -13,7 +13,7 @@ int main() l=j&1; assert(i==l); } - + { signed int i, j, k, l; @@ -28,6 +28,6 @@ int main() i=j%2; l=j&1; assert(i==l); - + } } diff --git a/regression/cbmc-with-incr/Bitfields1/main.c b/regression/cbmc-with-incr/Bitfields1/main.c index b05c2df095b..7ab19426ca3 100644 --- a/regression/cbmc-with-incr/Bitfields1/main.c +++ b/regression/cbmc-with-incr/Bitfields1/main.c @@ -15,45 +15,45 @@ struct bft { // an anonymous bitfield signed int :2; - + // with typedef INT x:1; - + // made of sizeof unsigned int abc: sizeof(int); // enums are integers! INTEL_CACHE_TYPE Type : 5; - + // and good as field sizes INTEL_CACHE_TYPE Field2 : IntelCacheTrace; }; int main() { struct bft bf; - + assert(bf.a<=7); assert(bf.b<=1); assert(bf.c<=1); - + bf.a&=0; assert(bf.a==0); - + bf.a+=9; assert(bf.a==1); - + bf.a<<=1; assert(bf.a==2); - + bf.a>>=1; assert(bf.a==1); - + bf.d=2; assert(bf.d==1); - + // assignments have the underlying type assert(sizeof(bf.d=1)==sizeof(_Bool)); assert(sizeof(bf.a+=1)==sizeof(unsigned)); - + bf.Type=IntelCacheTrace; } diff --git a/regression/cbmc-with-incr/Bitfields2/main.c b/regression/cbmc-with-incr/Bitfields2/main.c index 946cb66ba04..4322e6aa4f9 100644 --- a/regression/cbmc-with-incr/Bitfields2/main.c +++ b/regression/cbmc-with-incr/Bitfields2/main.c @@ -23,7 +23,7 @@ struct S0 { int64_t f2; uint32_t f3; // skipped over during initialization - signed : 0; + signed : 0; volatile int16_t f4; volatile uint32_t f5; int32_t f6; @@ -46,4 +46,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Bool1/main.c b/regression/cbmc-with-incr/Bool1/main.c index 90db3177189..4949781de4e 100644 --- a/regression/cbmc-with-incr/Bool1/main.c +++ b/regression/cbmc-with-incr/Bool1/main.c @@ -2,18 +2,18 @@ int main() { _Bool b1, b2, b3; - + b1=0; b1++; assert(b1); - + b2=1; b2+=10; assert(b2); - + b3=b1+b2; assert(b3==1); - + // a struct of _Bool struct { @@ -22,13 +22,13 @@ int main() { } s; assert(sizeof(s)==4); - + s.f1=2; assert(s.f1==1); - + s.f4=1; assert(s.f4); - + *((unsigned char *)(&s.f2))=1; assert(s.f2); } diff --git a/regression/cbmc-with-incr/Bool4/main.c b/regression/cbmc-with-incr/Bool4/main.c index e7d572ecc9c..4055cbf8d29 100644 --- a/regression/cbmc-with-incr/Bool4/main.c +++ b/regression/cbmc-with-incr/Bool4/main.c @@ -6,7 +6,7 @@ int main() { b1=1; b1 ^= (_Bool)1; assert(!b1); - + b1=1; b2=1; b1 ^= b2; diff --git a/regression/cbmc-with-incr/Boolean_Guards1/main.c b/regression/cbmc-with-incr/Boolean_Guards1/main.c index 6050ff6ef44..14f125ab4ad 100644 --- a/regression/cbmc-with-incr/Boolean_Guards1/main.c +++ b/regression/cbmc-with-incr/Boolean_Guards1/main.c @@ -3,7 +3,7 @@ int main() { int i; int a[100]; - // this is guaranteed not to be a buffer overflow + // this is guaranteed not to be a buffer overflow if(x<100 && a[x]) { i++; diff --git a/regression/cbmc-with-incr/Computed-Goto1/main.c b/regression/cbmc-with-incr/Computed-Goto1/main.c index efc34053a10..c31ed412069 100644 --- a/regression/cbmc-with-incr/Computed-Goto1/main.c +++ b/regression/cbmc-with-incr/Computed-Goto1/main.c @@ -2,17 +2,17 @@ int main() { void *table[]={ &&l0, &&l1, &&l2 }; int in, out; - + if(in>=0 && in<=2) { goto *(table[in]); l0: out=0; goto result; - + l1: out=1; goto result; - + l2: out=2; goto result; - + result: assert(in==out); } diff --git a/regression/cbmc-with-incr/Division1/main.c b/regression/cbmc-with-incr/Division1/main.c index bc0e1159868..67488d6027d 100644 --- a/regression/cbmc-with-incr/Division1/main.c +++ b/regression/cbmc-with-incr/Division1/main.c @@ -4,7 +4,7 @@ int main() { int k1 = 5 / 2; assert(k1 == 2); - + int k2 = -5 / 2; assert(k2 == -2); diff --git a/regression/cbmc-with-incr/Division2/main.c b/regression/cbmc-with-incr/Division2/main.c index 1da2d810afb..12a4acb209d 100644 --- a/regression/cbmc-with-incr/Division2/main.c +++ b/regression/cbmc-with-incr/Division2/main.c @@ -3,7 +3,7 @@ _Bool nondet_bool(); void main() { int i=2, j; - + if(nondet_bool()) i++; diff --git a/regression/cbmc-with-incr/Endianness1/main.c b/regression/cbmc-with-incr/Endianness1/main.c index 403825cec59..3bcfbfd4037 100644 --- a/regression/cbmc-with-incr/Endianness1/main.c +++ b/regression/cbmc-with-incr/Endianness1/main.c @@ -3,7 +3,7 @@ int main() unsigned int u=1; unsigned char *p; unsigned char x, y; - + p=(unsigned char *)&u; x=*p; diff --git a/regression/cbmc-with-incr/Endianness2/main.c b/regression/cbmc-with-incr/Endianness2/main.c index 283067502a0..16545374193 100644 --- a/regression/cbmc-with-incr/Endianness2/main.c +++ b/regression/cbmc-with-incr/Endianness2/main.c @@ -3,7 +3,7 @@ int main() unsigned int u=1; unsigned char *p; unsigned char x, y; - + p=(unsigned char *)&u; x=*p; diff --git a/regression/cbmc-with-incr/Endianness3/main.c b/regression/cbmc-with-incr/Endianness3/main.c index 7b2e8682fb2..8ea2b5600eb 100644 --- a/regression/cbmc-with-incr/Endianness3/main.c +++ b/regression/cbmc-with-incr/Endianness3/main.c @@ -2,13 +2,13 @@ int main() { unsigned int x; unsigned char *p; - + x=0xffff; - + p=(unsigned char *)&x; - + *p=1; - // assumes little endian + // assumes little endian assert(x==0xff01); } diff --git a/regression/cbmc-with-incr/Endianness4/main.c b/regression/cbmc-with-incr/Endianness4/main.c index c38bc507b28..85a22d3ffe9 100644 --- a/regression/cbmc-with-incr/Endianness4/main.c +++ b/regression/cbmc-with-incr/Endianness4/main.c @@ -7,6 +7,5 @@ void main() *(cp+i) = 0; // should work with any endianness - assert(x==0); + assert(x==0); } - diff --git a/regression/cbmc-with-incr/Endianness5/main.c b/regression/cbmc-with-incr/Endianness5/main.c index 83b6368dc6f..925f4c06044 100644 --- a/regression/cbmc-with-incr/Endianness5/main.c +++ b/regression/cbmc-with-incr/Endianness5/main.c @@ -5,8 +5,8 @@ unsigned short shortTmp; int main() { ptrUShort = (unsigned short*)(®b[12]); - shortTmp= *ptrUShort; + shortTmp= *ptrUShort; // should pass - *ptrUShort = 1234; + *ptrUShort = 1234; } diff --git a/regression/cbmc-with-incr/Endianness6/main.c b/regression/cbmc-with-incr/Endianness6/main.c index 1ffe35d380a..1f1085cb3ff 100644 --- a/regression/cbmc-with-incr/Endianness6/main.c +++ b/regression/cbmc-with-incr/Endianness6/main.c @@ -4,21 +4,21 @@ int main() { int *i_p; char c_array[10]; - + i_p=(int *)c_array; *i_p=0x01020304; - + // big-endian assert(c_array[0]==1 && c_array[1]==2 && c_array[2]==3 && c_array[3]==4); - + char *c_p; int i=0x01020304; - + c_p=(char *)&i; - + // big-endian assert(c_p[0]==1 && c_p[1]==2 && diff --git a/regression/cbmc-with-incr/Error_Label1/main.c b/regression/cbmc-with-incr/Error_Label1/main.c index 5104837ed3e..78d8a1b45fa 100644 --- a/regression/cbmc-with-incr/Error_Label1/main.c +++ b/regression/cbmc-with-incr/Error_Label1/main.c @@ -2,7 +2,7 @@ int main() { int i; - // this should fail + // this should fail goto ERROR; return 0; diff --git a/regression/cbmc-with-incr/Error_Label2/main.c b/regression/cbmc-with-incr/Error_Label2/main.c index 5104837ed3e..78d8a1b45fa 100644 --- a/regression/cbmc-with-incr/Error_Label2/main.c +++ b/regression/cbmc-with-incr/Error_Label2/main.c @@ -2,7 +2,7 @@ int main() { int i; - // this should fail + // this should fail goto ERROR; return 0; diff --git a/regression/cbmc-with-incr/Exceptions1/main.c b/regression/cbmc-with-incr/Exceptions1/main.c index c0308a84ff7..87ee3d50d40 100644 --- a/regression/cbmc-with-incr/Exceptions1/main.c +++ b/regression/cbmc-with-incr/Exceptions1/main.c @@ -10,7 +10,7 @@ void test_try_finally1() { global=2; } - + assert(global==2); } @@ -26,7 +26,7 @@ void helper() { global=3; } - + assert(global==2); } @@ -46,7 +46,7 @@ void test_try_catch1() { global=2; } - + assert(global==1); } @@ -62,7 +62,7 @@ void test_try_catch2() { global=3; } - + assert(global==3); } @@ -73,4 +73,3 @@ int main() test_try_catch1(); test_try_catch2(); } - diff --git a/regression/cbmc-with-incr/Fixedbv1/main.c b/regression/cbmc-with-incr/Fixedbv1/main.c index 7c3e6cf6e43..2b94133e7a6 100644 --- a/regression/cbmc-with-incr/Fixedbv1/main.c +++ b/regression/cbmc-with-incr/Fixedbv1/main.c @@ -1,16 +1,16 @@ int main() { double x; int y; - - x=2; + + x=2; x-=0.6; y=x; // this yields 1.4, which is cut off - + assert(y==1); - x=2; + x=2; x-=0.4; y=x; // this yields 1.6, which is cut off, too! - + assert(y==1); } diff --git a/regression/cbmc-with-incr/Fixedbv4/main.c b/regression/cbmc-with-incr/Fixedbv4/main.c index 91f499140cf..c04fa2bfc21 100644 --- a/regression/cbmc-with-incr/Fixedbv4/main.c +++ b/regression/cbmc-with-incr/Fixedbv4/main.c @@ -1,14 +1,14 @@ int main() { double f; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -37,7 +37,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -47,7 +47,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc-with-incr/Fixedbv5/main.c b/regression/cbmc-with-incr/Fixedbv5/main.c index fa62a78e408..f35749769ef 100644 --- a/regression/cbmc-with-incr/Fixedbv5/main.c +++ b/regression/cbmc-with-incr/Fixedbv5/main.c @@ -1,7 +1,7 @@ int main() { float a, b; - + __CPROVER_assume(a==1 || a==0.5 || a==2 || a==3 || a==0.1); b=a; a/=2; diff --git a/regression/cbmc-with-incr/Fixedbv6/main.c b/regression/cbmc-with-incr/Fixedbv6/main.c index f45c35f0444..f72d72c6975 100644 --- a/regression/cbmc-with-incr/Fixedbv6/main.c +++ b/regression/cbmc-with-incr/Fixedbv6/main.c @@ -18,8 +18,8 @@ int main() assert(1.0<=2.0); assert(!(-1.0<=-2.0)); assert(2.0>=1.0); - assert(!(-2.0>=-1.0)); - + assert(!(-2.0>=-1.0)); + // variables float a, b, _a=a, _b=b; __CPROVER_assume(a==1 && b==2); @@ -41,5 +41,5 @@ int main() assert(a<=b); assert(!(-a<=-b)); assert(b>=a); - assert(!(-b>=-a)); + assert(!(-b>=-a)); } diff --git a/regression/cbmc-with-incr/Fixedbv7/main.c b/regression/cbmc-with-incr/Fixedbv7/main.c index 91f499140cf..c04fa2bfc21 100644 --- a/regression/cbmc-with-incr/Fixedbv7/main.c +++ b/regression/cbmc-with-incr/Fixedbv7/main.c @@ -1,14 +1,14 @@ int main() { double f; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -37,7 +37,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -47,7 +47,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc-with-incr/Float-Rounding2/main.c b/regression/cbmc-with-incr/Float-Rounding2/main.c index b751938aa7c..4e5ff6403e4 100644 --- a/regression/cbmc-with-incr/Float-Rounding2/main.c +++ b/regression/cbmc-with-incr/Float-Rounding2/main.c @@ -1,6 +1,6 @@ // Visual Studio needs to be 2013 onwards #if defined(_MSC_VER) && !defined(__CYGWIN__) && _MSC_VER < 1800 - + // see http://www.johndcook.com/math_h.html int main() @@ -8,7 +8,7 @@ int main() } #else - + #include #include @@ -18,7 +18,7 @@ int main() fesetround(FE_DOWNWARD); assert(fegetround()==FE_DOWNWARD); #endif - + #ifdef FE_TONEAREST fesetround(FE_TONEAREST); assert(fegetround()==FE_TONEAREST); diff --git a/regression/cbmc-with-incr/Float-div1/main.c b/regression/cbmc-with-incr/Float-div1/main.c index 63f8512a7c2..49ee7110797 100644 --- a/regression/cbmc-with-incr/Float-div1/main.c +++ b/regression/cbmc-with-incr/Float-div1/main.c @@ -23,7 +23,7 @@ void simplifiedInductiveStepHunt (float nextState) // Implies nextState == 0x1p+124f; __CPROVER_assume((0x1.fffffep+123f < nextState) && (nextState < 0x1.000002p+124f)); - + float oneAfter = (target / nextState); // Is true and correctly proven by constant evaluation diff --git a/regression/cbmc-with-incr/Float-flags-no-simp1/main.c b/regression/cbmc-with-incr/Float-flags-no-simp1/main.c index d2f0833acc3..b41b115b6b9 100644 --- a/regression/cbmc-with-incr/Float-flags-no-simp1/main.c +++ b/regression/cbmc-with-incr/Float-flags-no-simp1/main.c @@ -9,7 +9,7 @@ int main() #ifndef _MSC_VER // first check constants - + assert(isnormal(FLT_MAX)); assert(isinf(HUGE_VAL)); assert(isinf(HUGE_VALF)); diff --git a/regression/cbmc-with-incr/Float-flags-simp1/main.c b/regression/cbmc-with-incr/Float-flags-simp1/main.c index d2f0833acc3..b41b115b6b9 100644 --- a/regression/cbmc-with-incr/Float-flags-simp1/main.c +++ b/regression/cbmc-with-incr/Float-flags-simp1/main.c @@ -9,7 +9,7 @@ int main() #ifndef _MSC_VER // first check constants - + assert(isnormal(FLT_MAX)); assert(isinf(HUGE_VAL)); assert(isinf(HUGE_VALF)); diff --git a/regression/cbmc-with-incr/Float-no-simp1/main.c b/regression/cbmc-with-incr/Float-no-simp1/main.c index de6091c82d2..e606d7b9d23 100644 --- a/regression/cbmc-with-incr/Float-no-simp1/main.c +++ b/regression/cbmc-with-incr/Float-no-simp1/main.c @@ -2,7 +2,7 @@ int main() { unsigned int i, j; double d; - + i=100.0; d=i; j=d; diff --git a/regression/cbmc-with-incr/Float-no-simp2/main.c b/regression/cbmc-with-incr/Float-no-simp2/main.c index 4fe132c1229..4914f3863ab 100644 --- a/regression/cbmc-with-incr/Float-no-simp2/main.c +++ b/regression/cbmc-with-incr/Float-no-simp2/main.c @@ -5,14 +5,14 @@ int main() __CPROVER_assume(!__CPROVER_isnand(f2)); __CPROVER_assume(__CPROVER_isfinited(f2)); f=f2; - + // addition assert(100.0+10==110); assert(0+f==f); // assert(f+0==f); assert(100+0.5==100.5); // assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); // assert(0-f==-f); @@ -41,7 +41,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -51,7 +51,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc-with-incr/Float-no-simp5/main.c b/regression/cbmc-with-incr/Float-no-simp5/main.c index ea2b8456667..7f4b1ed44a7 100644 --- a/regression/cbmc-with-incr/Float-no-simp5/main.c +++ b/regression/cbmc-with-incr/Float-no-simp5/main.c @@ -6,10 +6,9 @@ int main() double f; long long unsigned int i; // needs to have 64 bits } au, bu; - + au.f = a; bu.f = b; - + assert((au.i == bu.i) == __CPROVER_equal(a, b)); } - diff --git a/regression/cbmc-with-incr/Float-no-simp8/main.c b/regression/cbmc-with-incr/Float-no-simp8/main.c index a9234d20fbe..c75d7e231ac 100644 --- a/regression/cbmc-with-incr/Float-no-simp8/main.c +++ b/regression/cbmc-with-incr/Float-no-simp8/main.c @@ -9,7 +9,7 @@ int main (int argc, char **argv) { float result = f + g; assert(result == target); - + #ifndef _MSC_VER assert(signbit(result) == signbit(target)); #endif diff --git a/regression/cbmc-with-incr/Float-no-simp9/main.c b/regression/cbmc-with-incr/Float-no-simp9/main.c index 73253a909e8..9303a39d989 100644 --- a/regression/cbmc-with-incr/Float-no-simp9/main.c +++ b/regression/cbmc-with-incr/Float-no-simp9/main.c @@ -15,7 +15,7 @@ void testAdd (int mode, double f, double g, int sign) { assert(f_plus_g == 0.0); assert(g_plus_f == 0.0); - + assert(signbit(f_plus_g) == sign); assert(signbit(g_plus_f) == sign); #endif diff --git a/regression/cbmc-with-incr/Float1/main.c b/regression/cbmc-with-incr/Float1/main.c index 886c6c17684..b4d8dedca6d 100644 --- a/regression/cbmc-with-incr/Float1/main.c +++ b/regression/cbmc-with-incr/Float1/main.c @@ -1,17 +1,17 @@ int main() { double x; int y; - - x=2; + + x=2; x-=0.6; y=x; // this yields 1.4, which is cut off - + assert(y==1); - x=2; + x=2; x-=0.4; y=x; // this yields 1.6, which is cut off, too! // This is what the standard says! - + assert(y==1); } diff --git a/regression/cbmc-with-incr/Float11/main.c b/regression/cbmc-with-incr/Float11/main.c index 7514a3f37cb..f2e8b9e373d 100644 --- a/regression/cbmc-with-incr/Float11/main.c +++ b/regression/cbmc-with-incr/Float11/main.c @@ -31,7 +31,7 @@ int main() assert(0<1); assert(1>-0); assert(-0<1); - + assert(!(0.999f<0.0f)); assert(!(-0.999f>-0.0f)); assert(!(0.999f<=0.0f)); diff --git a/regression/cbmc-with-incr/Float12/main.c b/regression/cbmc-with-incr/Float12/main.c index a835646d1bf..3b88b9d576f 100644 --- a/regression/cbmc-with-incr/Float12/main.c +++ b/regression/cbmc-with-incr/Float12/main.c @@ -5,7 +5,7 @@ int main() unsigned char x; d=f; - + if(f==x) assert(d==x); } diff --git a/regression/cbmc-with-incr/Float14/main.c b/regression/cbmc-with-incr/Float14/main.c index b3de7013b6e..bafe611b05a 100644 --- a/regression/cbmc-with-incr/Float14/main.c +++ b/regression/cbmc-with-incr/Float14/main.c @@ -1,14 +1,14 @@ int main() { float temp; - + temp = 1.8e307f + 1.5e50f; // should produce overflow -> +infinity (according to standard) assert(__CPROVER_isinff(temp)); - + float x; - + x=temp-temp; - + // should be +inf assert(__CPROVER_isinff(temp)); } diff --git a/regression/cbmc-with-incr/Float18/main.c b/regression/cbmc-with-incr/Float18/main.c index 4f09b5429c2..4997219cd05 100644 --- a/regression/cbmc-with-incr/Float18/main.c +++ b/regression/cbmc-with-incr/Float18/main.c @@ -1,4 +1,4 @@ -#define _USE_MATH_DEFINES +#define _USE_MATH_DEFINES #include int main() @@ -16,5 +16,3 @@ int main() assert( n < 11 ); } - - diff --git a/regression/cbmc-with-incr/Float2/main.c b/regression/cbmc-with-incr/Float2/main.c index 1d41086f57a..9d9c877ea83 100644 --- a/regression/cbmc-with-incr/Float2/main.c +++ b/regression/cbmc-with-incr/Float2/main.c @@ -11,7 +11,7 @@ main() b=1.250; assert(b==1.25); - + // with exponent a=0.5e2; assert(a==50); diff --git a/regression/cbmc-with-incr/Float20/main.c b/regression/cbmc-with-incr/Float20/main.c index b730f0d4f18..5b1c69fe151 100644 --- a/regression/cbmc-with-incr/Float20/main.c +++ b/regression/cbmc-with-incr/Float20/main.c @@ -53,4 +53,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc-with-incr/Float21/main.c b/regression/cbmc-with-incr/Float21/main.c index 883e066cdfc..6eeda852be1 100644 --- a/regression/cbmc-with-incr/Float21/main.c +++ b/regression/cbmc-with-incr/Float21/main.c @@ -20,7 +20,7 @@ int main (void) float smallestNormalFloat = 0x1.0p-126f; float largestSubnormalFloat = 0x1.fffffcp-127f; - + double v = 0x1.FFFFFFp-127; float f; @@ -59,7 +59,7 @@ int main (void) f = nondet_float(); __CPROVER_assume(fpclassify(f) == FP_SUBNORMAL); assert( ((float)((double)f)) == f ); - + #endif return 0; diff --git a/regression/cbmc-with-incr/Float4/main.c b/regression/cbmc-with-incr/Float4/main.c index 08ff0cf255d..4b3fd112caa 100644 --- a/regression/cbmc-with-incr/Float4/main.c +++ b/regression/cbmc-with-incr/Float4/main.c @@ -5,14 +5,14 @@ int main() __CPROVER_assume(!__CPROVER_isnand(f2)); __CPROVER_assume(!__CPROVER_isinfd(f2)); f=f2; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -41,7 +41,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -51,7 +51,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc-with-incr/Float5/main.c b/regression/cbmc-with-incr/Float5/main.c index fa62a78e408..f35749769ef 100644 --- a/regression/cbmc-with-incr/Float5/main.c +++ b/regression/cbmc-with-incr/Float5/main.c @@ -1,7 +1,7 @@ int main() { float a, b; - + __CPROVER_assume(a==1 || a==0.5 || a==2 || a==3 || a==0.1); b=a; a/=2; diff --git a/regression/cbmc-with-incr/Float6/main.c b/regression/cbmc-with-incr/Float6/main.c index f45c35f0444..f72d72c6975 100644 --- a/regression/cbmc-with-incr/Float6/main.c +++ b/regression/cbmc-with-incr/Float6/main.c @@ -18,8 +18,8 @@ int main() assert(1.0<=2.0); assert(!(-1.0<=-2.0)); assert(2.0>=1.0); - assert(!(-2.0>=-1.0)); - + assert(!(-2.0>=-1.0)); + // variables float a, b, _a=a, _b=b; __CPROVER_assume(a==1 && b==2); @@ -41,5 +41,5 @@ int main() assert(a<=b); assert(!(-a<=-b)); assert(b>=a); - assert(!(-b>=-a)); + assert(!(-b>=-a)); } diff --git a/regression/cbmc-with-incr/Float7/main.c b/regression/cbmc-with-incr/Float7/main.c index 33f2923c7a7..fccaa083374 100644 --- a/regression/cbmc-with-incr/Float7/main.c +++ b/regression/cbmc-with-incr/Float7/main.c @@ -2,11 +2,11 @@ int main() { unsigned int i; i=0; - + float *p; p=(float *)&i; - + float f=*p; - + assert(f==0.0); } diff --git a/regression/cbmc-with-incr/Float_lib1/main.c b/regression/cbmc-with-incr/Float_lib1/main.c index 35dd4ba6302..c344517d28d 100644 --- a/regression/cbmc-with-incr/Float_lib1/main.c +++ b/regression/cbmc-with-incr/Float_lib1/main.c @@ -7,7 +7,7 @@ int main() { // Visual Studio needs to be 2013 onwards #if defined(_MSC_VER) && !defined(__CYGWIN__) && _MSC_VER < 1800 - + // see http://www.johndcook.com/math_h.html #else diff --git a/regression/cbmc-with-incr/Free1/main.c b/regression/cbmc-with-incr/Free1/main.c index f0f8c52117c..cd80759f9c6 100644 --- a/regression/cbmc-with-incr/Free1/main.c +++ b/regression/cbmc-with-incr/Free1/main.c @@ -7,7 +7,7 @@ int main() int *q=p; int i, x; i=x; - + if(i==4711) free(q); // should fail if i==4711 diff --git a/regression/cbmc-with-incr/Free2/main.c b/regression/cbmc-with-incr/Free2/main.c index 82ccf142962..f8d838d773a 100644 --- a/regression/cbmc-with-incr/Free2/main.c +++ b/regression/cbmc-with-incr/Free2/main.c @@ -7,7 +7,7 @@ int main() int x; int i, y; i=y; - + if(i==4711) p=&x; // should fail if i==4711 diff --git a/regression/cbmc-with-incr/Free3/main.c b/regression/cbmc-with-incr/Free3/main.c index 2328c7e5314..c85322e7813 100644 --- a/regression/cbmc-with-incr/Free3/main.c +++ b/regression/cbmc-with-incr/Free3/main.c @@ -10,6 +10,6 @@ int main() free(p); - // well, a double-free + // well, a double-free free(p); } diff --git a/regression/cbmc-with-incr/Free4/main.c b/regression/cbmc-with-incr/Free4/main.c index 3696af892b6..610c694580b 100644 --- a/regression/cbmc-with-incr/Free4/main.c +++ b/regression/cbmc-with-incr/Free4/main.c @@ -8,11 +8,11 @@ void my_free(int *q) int main() { int *p=malloc(sizeof(int)); - + *p=2; - + my_free(p); - // should fail + // should fail *p=3; } diff --git a/regression/cbmc-with-incr/Function-KnR1/main.c b/regression/cbmc-with-incr/Function-KnR1/main.c index 01cf0604fd7..2281ad04731 100644 --- a/regression/cbmc-with-incr/Function-KnR1/main.c +++ b/regression/cbmc-with-incr/Function-KnR1/main.c @@ -31,7 +31,6 @@ const char *msg; main() { struct X x; - + assert(f(0, 0, x, 0)==10); } - diff --git a/regression/cbmc-with-incr/Function10/main.c b/regression/cbmc-with-incr/Function10/main.c index a2c68510c6c..e80f816272b 100644 --- a/regression/cbmc-with-incr/Function10/main.c +++ b/regression/cbmc-with-incr/Function10/main.c @@ -26,7 +26,7 @@ int main() { int *p; my_f1(p); - + other_func1(1, whatnot); assert(global==2); } diff --git a/regression/cbmc-with-incr/Function13/main.c b/regression/cbmc-with-incr/Function13/main.c index aeaf224a5eb..8a90d748bb1 100644 --- a/regression/cbmc-with-incr/Function13/main.c +++ b/regression/cbmc-with-incr/Function13/main.c @@ -5,7 +5,7 @@ void f1() // goes into global name space! extern int i; assert(i==1); - + // and might have an incomplete type extern struct unknown_tag some_struct; extern char some_array[]; diff --git a/regression/cbmc-with-incr/Function4/main.c b/regression/cbmc-with-incr/Function4/main.c index 3873c30a2ee..dfdd644b79b 100644 --- a/regression/cbmc-with-incr/Function4/main.c +++ b/regression/cbmc-with-incr/Function4/main.c @@ -19,6 +19,6 @@ int main() st.x = f1(); x = nondet_int(); st.x = x; - + return 0; } diff --git a/regression/cbmc-with-incr/Function6/main.c b/regression/cbmc-with-incr/Function6/main.c index 865fda826a8..0d1fc7933aa 100644 --- a/regression/cbmc-with-incr/Function6/main.c +++ b/regression/cbmc-with-incr/Function6/main.c @@ -3,7 +3,7 @@ int global; void f() { void g(); - + g(); } diff --git a/regression/cbmc-with-incr/Function8/main.c b/regression/cbmc-with-incr/Function8/main.c index defb9b63c32..69c292e3f9c 100644 --- a/regression/cbmc-with-incr/Function8/main.c +++ b/regression/cbmc-with-incr/Function8/main.c @@ -21,7 +21,7 @@ int main() { foo(); - bar(); + bar(); return 0; } diff --git a/regression/cbmc-with-incr/Function9/main.c b/regression/cbmc-with-incr/Function9/main.c index f5000b3c0d1..03ad71720cd 100644 --- a/regression/cbmc-with-incr/Function9/main.c +++ b/regression/cbmc-with-incr/Function9/main.c @@ -27,7 +27,7 @@ int main() foo(); g=1; - bar(); + bar(); return 0; } diff --git a/regression/cbmc-with-incr/Function_Eval_Order1/main.c b/regression/cbmc-with-incr/Function_Eval_Order1/main.c index 814ff8d6a1c..0b0e230c995 100644 --- a/regression/cbmc-with-incr/Function_Eval_Order1/main.c +++ b/regression/cbmc-with-incr/Function_Eval_Order1/main.c @@ -25,4 +25,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc-with-incr/Function_Eval_Order2/main.c b/regression/cbmc-with-incr/Function_Eval_Order2/main.c index df3de56eb90..04926a3ab15 100644 --- a/regression/cbmc-with-incr/Function_Eval_Order2/main.c +++ b/regression/cbmc-with-incr/Function_Eval_Order2/main.c @@ -25,4 +25,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc-with-incr/Function_Pointer10/main.c b/regression/cbmc-with-incr/Function_Pointer10/main.c index 42d20ff6639..e974ca00403 100644 --- a/regression/cbmc-with-incr/Function_Pointer10/main.c +++ b/regression/cbmc-with-incr/Function_Pointer10/main.c @@ -20,12 +20,12 @@ void test2() { char a=5; int (*fun) (int, int); - + if(a) fun = func; else fun = func2; - + int b=(*fun) (a, a); } diff --git a/regression/cbmc-with-incr/Function_Pointer11/main.c b/regression/cbmc-with-incr/Function_Pointer11/main.c index a3c896d1015..0e6be48b479 100644 --- a/regression/cbmc-with-incr/Function_Pointer11/main.c +++ b/regression/cbmc-with-incr/Function_Pointer11/main.c @@ -17,4 +17,4 @@ int main(int argc, char **argv) // should be fine, and pass without warning f(x); -} +} diff --git a/regression/cbmc-with-incr/Function_Pointer13/main.c b/regression/cbmc-with-incr/Function_Pointer13/main.c index 52a68f23f4c..a3bac9430b3 100644 --- a/regression/cbmc-with-incr/Function_Pointer13/main.c +++ b/regression/cbmc-with-incr/Function_Pointer13/main.c @@ -33,4 +33,3 @@ value=fptr(value); //value should be 16 after this assert(value == 16); } - diff --git a/regression/cbmc-with-incr/Function_Pointer14/main.c b/regression/cbmc-with-incr/Function_Pointer14/main.c index 9c244af439d..ee74abfad03 100644 --- a/regression/cbmc-with-incr/Function_Pointer14/main.c +++ b/regression/cbmc-with-incr/Function_Pointer14/main.c @@ -7,7 +7,7 @@ void dll_create_generic(void (*insert_fnc)()) insert_fnc(&my_global); } -void dll_insert_master(int *a) +void dll_insert_master(int *a) { *a=123; } @@ -16,6 +16,6 @@ int main() { dll_create_generic(dll_insert_master); assert(my_global==123); - + return 0; } diff --git a/regression/cbmc-with-incr/Function_Pointer15/main.c b/regression/cbmc-with-incr/Function_Pointer15/main.c index 28cf42db770..5006540d4f5 100644 --- a/regression/cbmc-with-incr/Function_Pointer15/main.c +++ b/regression/cbmc-with-incr/Function_Pointer15/main.c @@ -6,7 +6,7 @@ void dll_create_generic(void (*insert_fnc)()) insert_fnc(&x); } -void dll_insert_master(int *a) +void dll_insert_master(int *a) { assert(0); } @@ -16,4 +16,3 @@ int main() dll_create_generic(dll_insert_master); return 0; } - diff --git a/regression/cbmc-with-incr/Function_Pointer2/main.c b/regression/cbmc-with-incr/Function_Pointer2/main.c index 8062f3c7724..ee419e426d9 100644 --- a/regression/cbmc-with-incr/Function_Pointer2/main.c +++ b/regression/cbmc-with-incr/Function_Pointer2/main.c @@ -14,10 +14,10 @@ int main() { void (*p)(int); __CPROVER_bool c; - + p=c?f:g; - + p(1); - + assert(global==c); } diff --git a/regression/cbmc-with-incr/Function_Pointer4/main.c b/regression/cbmc-with-incr/Function_Pointer4/main.c index 4422b736e58..8a58e610618 100644 --- a/regression/cbmc-with-incr/Function_Pointer4/main.c +++ b/regression/cbmc-with-incr/Function_Pointer4/main.c @@ -11,9 +11,9 @@ int main(void) { struct device devices[1]; int x; - + devices[0].func = one; - + x=(* devices[0].func)(); assert(x == 1); } diff --git a/regression/cbmc-with-incr/Function_Pointer6/main.c b/regression/cbmc-with-incr/Function_Pointer6/main.c index b1e8efeee88..78c7c2339ea 100644 --- a/regression/cbmc-with-incr/Function_Pointer6/main.c +++ b/regression/cbmc-with-incr/Function_Pointer6/main.c @@ -23,9 +23,9 @@ int main(void) ps->func = x?ten:twenty; ppp=ps->func; - + y=ps->func(); - + assert(y==10 || y==20); return 0; diff --git a/regression/cbmc-with-incr/Function_Pointer7/main.c b/regression/cbmc-with-incr/Function_Pointer7/main.c index 23c452ad61e..71f6c25d373 100644 --- a/regression/cbmc-with-incr/Function_Pointer7/main.c +++ b/regression/cbmc-with-incr/Function_Pointer7/main.c @@ -16,13 +16,13 @@ int my_open(int a) struct file_ops fops = { .open = my_open }; int main(void) -{ +{ struct dev tmp[4]; devs = &tmp; - + (devs+0)->ops = &fops; // does not work - + assert(10 == (* devs[0].ops->open)(10)); return 0; diff --git a/regression/cbmc-with-incr/Function_Pointer8/main.c b/regression/cbmc-with-incr/Function_Pointer8/main.c index 59603b43549..ff7dee40e91 100644 --- a/regression/cbmc-with-incr/Function_Pointer8/main.c +++ b/regression/cbmc-with-incr/Function_Pointer8/main.c @@ -26,7 +26,7 @@ void func1(int a) void run_irq_handler() { - (* ihandler.handler)(10); + (* ihandler.handler)(10); } void run_timer() @@ -37,7 +37,7 @@ void run_timer() int main() { ihandler.handler = func1; - + run_irq_handler(); run_timer(); } diff --git a/regression/cbmc-with-incr/Global_Initialization1/main.c b/regression/cbmc-with-incr/Global_Initialization1/main.c index f4ee15e1150..0ce23881c94 100644 --- a/regression/cbmc-with-incr/Global_Initialization1/main.c +++ b/regression/cbmc-with-incr/Global_Initialization1/main.c @@ -22,6 +22,6 @@ int main() assert(x == 123); assert(y == 0); assert(b[0]=='a'); - assert(some_func()==0); + assert(some_func()==0); assert(p==&y); } diff --git a/regression/cbmc-with-incr/Global_Initialization2/main.c b/regression/cbmc-with-incr/Global_Initialization2/main.c index 0a058acc2fc..0353ee2e015 100644 --- a/regression/cbmc-with-incr/Global_Initialization2/main.c +++ b/regression/cbmc-with-incr/Global_Initialization2/main.c @@ -22,4 +22,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Initialization1/main.c b/regression/cbmc-with-incr/Initialization1/main.c index 9e1f0d3c91b..7da12521ad5 100644 --- a/regression/cbmc-with-incr/Initialization1/main.c +++ b/regression/cbmc-with-incr/Initialization1/main.c @@ -2,10 +2,9 @@ int main() { char a; char b = a = 'a'; - + assert(a=='a'); assert(b=='a'); int i=(long int)&i; } - diff --git a/regression/cbmc-with-incr/Initialization3/main.c b/regression/cbmc-with-incr/Initialization3/main.c index 8ed9ef44325..7df573913aa 100644 --- a/regression/cbmc-with-incr/Initialization3/main.c +++ b/regression/cbmc-with-incr/Initialization3/main.c @@ -28,4 +28,3 @@ int main() Split(&t); return 0; } - diff --git a/regression/cbmc-with-incr/Initialization7/main.c b/regression/cbmc-with-incr/Initialization7/main.c index 92cad8f2221..435d2aba3a6 100644 --- a/regression/cbmc-with-incr/Initialization7/main.c +++ b/regression/cbmc-with-incr/Initialization7/main.c @@ -15,4 +15,3 @@ int main() __CPROVER_assert(x==42, ""); return 0; } - diff --git a/regression/cbmc-with-incr/Linking1/main.c b/regression/cbmc-with-incr/Linking1/main.c index 127290cffaa..248db3436c8 100644 --- a/regression/cbmc-with-incr/Linking1/main.c +++ b/regression/cbmc-with-incr/Linking1/main.c @@ -15,9 +15,9 @@ int main() { assert(i==1); assert(a_struct.asd==0); - + f(); - + assert(i==2); assert(a_struct.asd==123); } diff --git a/regression/cbmc-with-incr/Linking1/test.desc b/regression/cbmc-with-incr/Linking1/test.desc index de6f32ebf66..af20f90c655 100644 --- a/regression/cbmc-with-incr/Linking1/test.desc +++ b/regression/cbmc-with-incr/Linking1/test.desc @@ -1,6 +1,6 @@ CORE main.c -module.c +module.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc-with-incr/Linking2/main.c b/regression/cbmc-with-incr/Linking2/main.c index a5649307456..4a9d9634b81 100644 --- a/regression/cbmc-with-incr/Linking2/main.c +++ b/regression/cbmc-with-incr/Linking2/main.c @@ -21,13 +21,13 @@ int main() { assert(i==2); assert(j==3); - + f(); // does not change i, // but does change j - + assert(i==2); assert(j==4); - + struct my_struct xx; assert(sizeof(xx.t_field)==1); } diff --git a/regression/cbmc-with-incr/Linking2/module.c b/regression/cbmc-with-incr/Linking2/module.c index a23c19df0bc..f144ea8d4bd 100644 --- a/regression/cbmc-with-incr/Linking2/module.c +++ b/regression/cbmc-with-incr/Linking2/module.c @@ -9,7 +9,7 @@ typedef int t; struct my_struct { t t_field; -}; +}; // this one is local, tool! static t i=1; @@ -23,7 +23,7 @@ void f() assert(j==3); i=3; j=4; - + struct my_struct xx; assert(sizeof(xx.t_field)==sizeof(int)); } diff --git a/regression/cbmc-with-incr/Linking2/test.desc b/regression/cbmc-with-incr/Linking2/test.desc index de6f32ebf66..af20f90c655 100644 --- a/regression/cbmc-with-incr/Linking2/test.desc +++ b/regression/cbmc-with-incr/Linking2/test.desc @@ -1,6 +1,6 @@ CORE main.c -module.c +module.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc-with-incr/Local_out_of_scope1/main.c b/regression/cbmc-with-incr/Local_out_of_scope1/main.c index 596f6c3238a..04554ab6c6d 100644 --- a/regression/cbmc-with-incr/Local_out_of_scope1/main.c +++ b/regression/cbmc-with-incr/Local_out_of_scope1/main.c @@ -2,16 +2,16 @@ int main() { int *p, *q; int x, y, z; - + p=&x; q=p; - + if(z) { int l; q=&l; } - // this should fail, as *p is dead if z is true + // this should fail, as *p is dead if z is true y=*q; } diff --git a/regression/cbmc-with-incr/Malloc13/main.c b/regression/cbmc-with-incr/Malloc13/main.c index b069e222a31..d8ee44f2ffc 100644 --- a/regression/cbmc-with-incr/Malloc13/main.c +++ b/regression/cbmc-with-incr/Malloc13/main.c @@ -8,4 +8,3 @@ int main(int argc, char* argv[]) { assert(__CPROVER_buffer_size(str) == len); return 0; } - diff --git a/regression/cbmc-with-incr/Malloc15/main.c b/regression/cbmc-with-incr/Malloc15/main.c index 4654735e247..0a09bfac95b 100644 --- a/regression/cbmc-with-incr/Malloc15/main.c +++ b/regression/cbmc-with-incr/Malloc15/main.c @@ -7,7 +7,7 @@ int main() p = malloc(sizeof(int)); unsigned int r = p; if (r != 0) - *p = 1; + *p = 1; if (p != 0) __CPROVER_assert (*p == 1, "malloc"); diff --git a/regression/cbmc-with-incr/Malloc16/main.c b/regression/cbmc-with-incr/Malloc16/main.c index e64276e5e87..675b577f6ec 100644 --- a/regression/cbmc-with-incr/Malloc16/main.c +++ b/regression/cbmc-with-incr/Malloc16/main.c @@ -12,7 +12,7 @@ int main() tmp = malloc(sizeof(int)); dev = (int*)tmp; - + void *r = (void*)0; unsigned int q = r; unsigned int p = dev; diff --git a/regression/cbmc-with-incr/Malloc17/main.c b/regression/cbmc-with-incr/Malloc17/main.c index 6cac57c95de..bf13b054b2e 100644 --- a/regression/cbmc-with-incr/Malloc17/main.c +++ b/regression/cbmc-with-incr/Malloc17/main.c @@ -68,4 +68,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Malloc18/main.c b/regression/cbmc-with-incr/Malloc18/main.c index 4fcef7d9908..dc8d60bac01 100644 --- a/regression/cbmc-with-incr/Malloc18/main.c +++ b/regression/cbmc-with-incr/Malloc18/main.c @@ -24,4 +24,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Malloc19/main.c b/regression/cbmc-with-incr/Malloc19/main.c index df4ba61a870..6d5d041c541 100644 --- a/regression/cbmc-with-incr/Malloc19/main.c +++ b/regression/cbmc-with-incr/Malloc19/main.c @@ -42,4 +42,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Malloc20/main.c b/regression/cbmc-with-incr/Malloc20/main.c index ac76cc22367..728819c6a50 100644 --- a/regression/cbmc-with-incr/Malloc20/main.c +++ b/regression/cbmc-with-incr/Malloc20/main.c @@ -22,7 +22,7 @@ nettle_buffer_init(struct nettle_buffer *buffer) int nettle_buffer_grow(struct nettle_buffer *buffer, size_t length) { if (buffer->condition) return 0; // Uncommenting this line fixes the bug. - + size_t alloc = buffer->alloc * 2 + length + 100; // Replcing alloc size by a constant fixes the bug. //size_t alloc = 103; uint8_t *p = (uint8_t *) malloc(alloc); @@ -49,5 +49,3 @@ int main(void) __CPROVER_assert(buffer.contents[1] == 'o', "buffer.contents[1] == 'o'"); __CPROVER_assert(buffer.contents[2] == 'o', "buffer.contents[2] == 'o'"); } - - diff --git a/regression/cbmc-with-incr/Memmove1/main.c b/regression/cbmc-with-incr/Memmove1/main.c index ff0cdae7c3a..ecd39ff0d4c 100644 --- a/regression/cbmc-with-incr/Memmove1/main.c +++ b/regression/cbmc-with-incr/Memmove1/main.c @@ -43,4 +43,3 @@ int main(int argc, char * argv[]) { assert(a[0]==-2147483600); return 0; } - diff --git a/regression/cbmc-with-incr/Mod1/main.c b/regression/cbmc-with-incr/Mod1/main.c index 6fde263722d..31b3000a530 100644 --- a/regression/cbmc-with-incr/Mod1/main.c +++ b/regression/cbmc-with-incr/Mod1/main.c @@ -1,8 +1,8 @@ int main() { int x, y; - - x=y; + + x=y; x%=10; assert(x!=-1); // should fail } diff --git a/regression/cbmc-with-incr/Mod2/main.c b/regression/cbmc-with-incr/Mod2/main.c index 53b1ef269b8..13c715cb409 100644 --- a/regression/cbmc-with-incr/Mod2/main.c +++ b/regression/cbmc-with-incr/Mod2/main.c @@ -1,6 +1,6 @@ #include -static int +static int (safe_mod_func_int32_t_s_s)(int si1, int si2 ) { return @@ -21,7 +21,7 @@ int main() a=1; b=-2; #endif - int x=safe_mod_func_int32_t_s_s(a, b); + int x=safe_mod_func_int32_t_s_s(a, b); assert(x==1); return 0; } diff --git a/regression/cbmc-with-incr/Multi_Dimensional_Array1/main.c b/regression/cbmc-with-incr/Multi_Dimensional_Array1/main.c index eac543d4d8a..f814686bb94 100644 --- a/regression/cbmc-with-incr/Multi_Dimensional_Array1/main.c +++ b/regression/cbmc-with-incr/Multi_Dimensional_Array1/main.c @@ -9,11 +9,11 @@ int main() p=a[9]; assert(p==a[0]+9*4); - + *p=10; assert(a[9][0]==10); - p++; + p++; *p=20; assert(a[9][1]==20); diff --git a/regression/cbmc-with-incr/Multi_Dimensional_Array3/main.c b/regression/cbmc-with-incr/Multi_Dimensional_Array3/main.c index 607582a629f..3daa9f6d331 100644 --- a/regression/cbmc-with-incr/Multi_Dimensional_Array3/main.c +++ b/regression/cbmc-with-incr/Multi_Dimensional_Array3/main.c @@ -8,7 +8,7 @@ int main() { // this checks whether the alias analysis can // track pointers in multi-dimensional arrays - + iptr array[3][3]={{&x,0,0},{&y,0,0},{&z,0,0}}; unsigned int a, b; @@ -17,12 +17,12 @@ int main() __CPROVER_assume (a < 3 && b < 3); array[a][b] = &z; - + iptr p; p=array[a][b]; *p=1; - + assert(z==1); } /* end of case 2 */ diff --git a/regression/cbmc-with-incr/Multi_Dimensional_Array4/main.c b/regression/cbmc-with-incr/Multi_Dimensional_Array4/main.c index b07bdf3281d..e7ef2680438 100644 --- a/regression/cbmc-with-incr/Multi_Dimensional_Array4/main.c +++ b/regression/cbmc-with-incr/Multi_Dimensional_Array4/main.c @@ -1,26 +1,26 @@ void f(void * s1, void *s2) -{ - char *us1 = (char*) s1; - char *us2 = (char*) s2; - +{ + char *us1 = (char*) s1; + char *us2 = (char*) s2; + char us10=us1[0]; char us20=us2[0]; char us11=us1[1]; char us21=us2[1]; - assert(us10=='a'); - assert(us11=='b'); + assert(us10=='a'); + assert(us11=='b'); assert(us20=='g'); assert(us21=='b'); -} +} int main() -{ - char a[2][2]; - a[0][0] = 'a'; - a[0][1] = 'b'; - a[1][0] = 'g'; - a[1][1] = 'b'; - +{ + char a[2][2]; + a[0][0] = 'a'; + a[0][1] = 'b'; + a[1][0] = 'g'; + a[1][1] = 'b'; + f(&a[0], &a[1]); -} +} diff --git a/regression/cbmc-with-incr/Multi_Dimensional_Array5/main.c b/regression/cbmc-with-incr/Multi_Dimensional_Array5/main.c index 1d18c81a803..a54a3657ce2 100644 --- a/regression/cbmc-with-incr/Multi_Dimensional_Array5/main.c +++ b/regression/cbmc-with-incr/Multi_Dimensional_Array5/main.c @@ -17,4 +17,3 @@ int main () func_79(*(&(g_374[0][0]))); return 0; } - diff --git a/regression/cbmc-with-incr/Negation1/main.c b/regression/cbmc-with-incr/Negation1/main.c index facd2bcf91a..9e02cef5d9e 100644 --- a/regression/cbmc-with-incr/Negation1/main.c +++ b/regression/cbmc-with-incr/Negation1/main.c @@ -5,11 +5,11 @@ int main() test=0; test=~test; assert(test==-1); - + test=0; test=!test; assert(test==1); - + test=100; test=!test; assert(test==0); diff --git a/regression/cbmc-with-incr/Negation2/main.c b/regression/cbmc-with-incr/Negation2/main.c index 16971d58e32..33435a12435 100644 --- a/regression/cbmc-with-incr/Negation2/main.c +++ b/regression/cbmc-with-incr/Negation2/main.c @@ -12,4 +12,3 @@ int main() { f00(0); } - diff --git a/regression/cbmc-with-incr/Overflow_Addition1/main.c b/regression/cbmc-with-incr/Overflow_Addition1/main.c index 3d1288d0db3..706ee880796 100644 --- a/regression/cbmc-with-incr/Overflow_Addition1/main.c +++ b/regression/cbmc-with-incr/Overflow_Addition1/main.c @@ -1,7 +1,7 @@ int main() { signed int i, j; - + i=j; - + i++; } diff --git a/regression/cbmc-with-incr/Overflow_Multiplication1/falsealarm.c b/regression/cbmc-with-incr/Overflow_Multiplication1/falsealarm.c index 2ed10b653cb..c2f8173d8e1 100644 --- a/regression/cbmc-with-incr/Overflow_Multiplication1/falsealarm.c +++ b/regression/cbmc-with-incr/Overflow_Multiplication1/falsealarm.c @@ -6,7 +6,7 @@ void main() x=_x; y=_y; - + if((-4681 < y) && (y < 4681) && (x < 32767) && (-32767 < x) && ((7*y*y -1) == x*x)) { y=1/x; } diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic1/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic1/main.c index c31c0e7cc06..a882ca30700 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic1/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic1/main.c @@ -7,6 +7,6 @@ int main() p+=30; diff=(char *)p-(char *)array; - + assert(diff==30*sizeof(int)); } diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic11/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic11/main.c index 96849c12ab1..c1b2df18592 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic11/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic11/main.c @@ -4,9 +4,9 @@ int main() int data=0; char *p=(char *)&data; i=ii; - + __CPROVER_assume(i>=0 && i<4); - + p[i]++; if(i==0) diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic12/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic12/main.c index 3363b3c5440..6177b6f4f6f 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic12/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic12/main.c @@ -132,4 +132,3 @@ int main() L_0x416_2: esp+=0x4; L_0x417_0: return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic13/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic13/main.c index 4643b378877..a7063318bfc 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic13/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic13/main.c @@ -19,4 +19,3 @@ int main() { return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic2/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic2/main.c index 5fbe8956e3e..b7b9c687eef 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic2/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic2/main.c @@ -9,8 +9,8 @@ int main() q=(char *)p; q+=30*sizeof(int); p=(int *)q; - + *p=1; - + assert(my_array[30]==1); } diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic3/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic3/main.c index 86554c90f47..3d5ce10e214 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic3/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic3/main.c @@ -1,10 +1,10 @@ -int nums[2]; -int *p; +int nums[2]; +int *p; -int main() { - nums[1] = 1; - p = &nums[0]; - p++; +int main() { + nums[1] = 1; + p = &nums[0]; + p++; - assert(*p == 1); -} + assert(*p == 1); +} diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic5/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic5/main.c index 2bf0f10c353..a0fcc55be56 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic5/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic5/main.c @@ -7,6 +7,6 @@ void f() x=1; px++; - // now out of bounds + // now out of bounds y=*px; } diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic6/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic6/main.c index 263202f72e3..3ef83b5aed6 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic6/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic6/main.c @@ -2,10 +2,10 @@ int main() { int a[10]; int x; - + a[1]=1000; - + x=*(a+1); - + assert(x==1000); } diff --git a/regression/cbmc-with-incr/Pointer_Arithmetic7/main.c b/regression/cbmc-with-incr/Pointer_Arithmetic7/main.c index 82e918f9d54..cc1da6e6ee0 100644 --- a/regression/cbmc-with-incr/Pointer_Arithmetic7/main.c +++ b/regression/cbmc-with-incr/Pointer_Arithmetic7/main.c @@ -3,7 +3,7 @@ void f(char *p) p[1]=1; } -int main () +int main () { char dummy[10]; f(dummy); diff --git a/regression/cbmc-with-incr/Pointer_array1/main.c b/regression/cbmc-with-incr/Pointer_array1/main.c index 07a389cac31..b676f18294a 100644 --- a/regression/cbmc-with-incr/Pointer_array1/main.c +++ b/regression/cbmc-with-incr/Pointer_array1/main.c @@ -10,4 +10,3 @@ void main() { __cil_tmp24 = &(disk->disk_name); assert(__cil_tmp24!=0); } - diff --git a/regression/cbmc-with-incr/Pointer_array2/main.c b/regression/cbmc-with-incr/Pointer_array2/main.c index 07a389cac31..b676f18294a 100644 --- a/regression/cbmc-with-incr/Pointer_array2/main.c +++ b/regression/cbmc-with-incr/Pointer_array2/main.c @@ -10,4 +10,3 @@ void main() { __cil_tmp24 = &(disk->disk_name); assert(__cil_tmp24!=0); } - diff --git a/regression/cbmc-with-incr/Pointer_byte_extract1/main.c b/regression/cbmc-with-incr/Pointer_byte_extract1/main.c index ccb81bfc051..318d5c150f7 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract1/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract1/main.c @@ -71,4 +71,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_byte_extract3/main.c b/regression/cbmc-with-incr/Pointer_byte_extract3/main.c index 3be1a638faf..328a2b939a1 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract3/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract3/main.c @@ -24,4 +24,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_byte_extract5/main.c b/regression/cbmc-with-incr/Pointer_byte_extract5/main.c index e2d109fb7bd..b720d9ad132 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract5/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract5/main.c @@ -43,4 +43,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_byte_extract6/main.c b/regression/cbmc-with-incr/Pointer_byte_extract6/main.c index 79c7d634d39..324a980695f 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract6/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract6/main.c @@ -11,13 +11,13 @@ int main() { int f; }; - + assert(*(unsigned long long int *)&long_long_int==1); assert(*(unsigned int *)&signed_int==1); assert(((struct some *)&signed_int)->f==1); assert(*(int *)&a_float==1065353216); assert(*(long long int *)&a_double==4607182418800017408l); - + // other direction signed_int=1065353216; assert(*(float *)&signed_int==1.0f); diff --git a/regression/cbmc-with-incr/Pointer_byte_extract7/main.c b/regression/cbmc-with-incr/Pointer_byte_extract7/main.c index 3be1a638faf..328a2b939a1 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract7/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract7/main.c @@ -24,4 +24,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Pointer_byte_extract8/main.c b/regression/cbmc-with-incr/Pointer_byte_extract8/main.c index 499ab12fc2b..2266e0f4ef4 100644 --- a/regression/cbmc-with-incr/Pointer_byte_extract8/main.c +++ b/regression/cbmc-with-incr/Pointer_byte_extract8/main.c @@ -38,4 +38,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Promotion1/main.c b/regression/cbmc-with-incr/Promotion1/main.c index 6664d445f9f..8e127502edb 100644 --- a/regression/cbmc-with-incr/Promotion1/main.c +++ b/regression/cbmc-with-incr/Promotion1/main.c @@ -16,11 +16,11 @@ int main() // signed int if int is bigger! unsigned char a2=1; signed char b2=-1; - + if(sizeof(char)b2); else - assert(a29 || c[i]==i}); - return 0; + return 0; } diff --git a/regression/cbmc-with-incr/Recursion2/main.c b/regression/cbmc-with-incr/Recursion2/main.c index 0501acc9683..1866f780a0e 100644 --- a/regression/cbmc-with-incr/Recursion2/main.c +++ b/regression/cbmc-with-incr/Recursion2/main.c @@ -7,7 +7,7 @@ void f(unsigned int counter) { int main() { unsigned int x; __CPROVER_assume(x<=10); - + f(x); } diff --git a/regression/cbmc-with-incr/Recursion5/main.c b/regression/cbmc-with-incr/Recursion5/main.c index 26eb98f243f..4b7762123e0 100644 --- a/regression/cbmc-with-incr/Recursion5/main.c +++ b/regression/cbmc-with-incr/Recursion5/main.c @@ -19,4 +19,3 @@ int main() return 0; } - diff --git a/regression/cbmc-with-incr/Sideeffects1/main.c b/regression/cbmc-with-incr/Sideeffects1/main.c index 87b83b50dc7..6c51baf23d9 100644 --- a/regression/cbmc-with-incr/Sideeffects1/main.c +++ b/regression/cbmc-with-incr/Sideeffects1/main.c @@ -1,12 +1,12 @@ int main(void) { int x, y; - + x=100; - + y=x/=2; assert(x==50); - + y=x*=3; assert(x==150); diff --git a/regression/cbmc-with-incr/Sideeffects2/main.c b/regression/cbmc-with-incr/Sideeffects2/main.c index 46990fc8a94..1efa8b74737 100644 --- a/regression/cbmc-with-incr/Sideeffects2/main.c +++ b/regression/cbmc-with-incr/Sideeffects2/main.c @@ -17,7 +17,7 @@ int main() z=2; x=(f0() || (z==1)); assert(x); - + z=2; x=(f0() && (z=3)); assert(z==1); @@ -25,8 +25,8 @@ int main() z=2; x=(f1() || (z=3)); assert(z==1); - + z=2; x=(f1() && (z=3)); - assert(z==3); + assert(z==3); } diff --git a/regression/cbmc-with-incr/Sideeffects3/main.c b/regression/cbmc-with-incr/Sideeffects3/main.c index 7b032a3602d..5c49106b99c 100644 --- a/regression/cbmc-with-incr/Sideeffects3/main.c +++ b/regression/cbmc-with-incr/Sideeffects3/main.c @@ -10,9 +10,9 @@ int x, y, z; int main() { #ifdef _WIN32 - + // Visual Studio won't even parse most of these - + #else // a side effect inside an array type @@ -39,14 +39,14 @@ int main() int return_value=my_f(++x); assert(x==2); assert(return_value==2); - + // using a pointer x=1; int *p=&x; y=++(*p); assert(y==2); assert(x==2); - + // in a struct x=1; struct struct_type @@ -60,7 +60,7 @@ int main() // this is evaluated when the type is defined, not later x++; assert(sizeof(struct struct_type)==sizeof(int)*2+sizeof(int)); - + // only happens once x=1; y=1; @@ -73,27 +73,27 @@ int main() assert(sizeof(v1)==sizeof(int)*2*1); assert(sizeof(v2)==sizeof(int)*2*2); assert(sizeof(v3)==sizeof(int)*2*3); - + // inside a typecast (struct) x=1; (struct { int a[x++]; } *)0; assert(x==2); - + // inside a typecast (function pointer) x=1; (int (*)(int a[x++]))0; // This is ignored by gcc! Haha! assert(x==1); - + // inside sizeof x=1; assert(sizeof(struct { int a[x++]; })==sizeof(int)); assert(x==2); - + // multi-dimensional x=y=1; typedef int my_array1[x][y]; x++; assert(sizeof(my_array1)==sizeof(int)); - + #endif } diff --git a/regression/cbmc-with-incr/Sideeffects4/main.c b/regression/cbmc-with-incr/Sideeffects4/main.c index d2a16b49fe2..39c91b96734 100644 --- a/regression/cbmc-with-incr/Sideeffects4/main.c +++ b/regression/cbmc-with-incr/Sideeffects4/main.c @@ -11,10 +11,10 @@ _Bool my_f() int main() { // side-effect in ?: - glob=0; - result=glob?1:my_f(); + glob=0; + result=glob?1:my_f(); assert(result==0); - + // side-effect in || glob=0; result=glob||my_f(); @@ -24,9 +24,9 @@ int main() glob=0; result=glob||(0+my_f()); assert(result==0); - + // another variant of this - int r, c=1; + int r, c=1; r=c?(c=0, 10):20; assert(c==0 && r==10); } diff --git a/regression/cbmc-with-incr/Sideeffects6/main.c b/regression/cbmc-with-incr/Sideeffects6/main.c index 4175688e79f..db94ea1c047 100644 --- a/regression/cbmc-with-incr/Sideeffects6/main.c +++ b/regression/cbmc-with-incr/Sideeffects6/main.c @@ -4,6 +4,6 @@ int main() // we should be able to find this division by zero (void)(c?x/y:z); - + return 0; } diff --git a/regression/cbmc-with-incr/String1/main.c b/regression/cbmc-with-incr/String1/main.c index 448d45864fe..3b64fd0028c 100644 --- a/regression/cbmc-with-incr/String1/main.c +++ b/regression/cbmc-with-incr/String1/main.c @@ -10,18 +10,18 @@ int main() { assert(s[1]=='b'); assert(s[4]==0); - + // write to s s[0]='x'; - + assert(p[2]=='c'); - + p=s; // write to p p[1]='y'; - - assert(s[1]=='y'); + + assert(s[1]=='y'); { const char local_string[]="asd123"; @@ -40,15 +40,15 @@ int main() #else typedef __typeof__(L'X') wide_char_type; #endif - + unsigned width=sizeof(wide_char_type); - #ifdef _WIN32 + #ifdef _WIN32 assert(width==2); #else assert(width==4); #endif - + assert(sizeof(L"12" "34")==5*width); assert(sizeof("12" L"34")==5*width); diff --git a/regression/cbmc-with-incr/String2/main.c b/regression/cbmc-with-incr/String2/main.c index a1a32fa5e73..5c8bfcb93da 100644 --- a/regression/cbmc-with-incr/String2/main.c +++ b/regression/cbmc-with-incr/String2/main.c @@ -5,6 +5,6 @@ int main() int input; char ch; - /* should result in bounds violation */ + /* should result in bounds violation */ ch=p[input]; } diff --git a/regression/cbmc-with-incr/String5/main.c b/regression/cbmc-with-incr/String5/main.c index 851d482bb5e..e81ef607f7e 100644 --- a/regression/cbmc-with-incr/String5/main.c +++ b/regression/cbmc-with-incr/String5/main.c @@ -14,4 +14,3 @@ int main() assert(l==6); } - diff --git a/regression/cbmc-with-incr/String6/main.c b/regression/cbmc-with-incr/String6/main.c index cbe0887795c..9b165a6796a 100644 --- a/regression/cbmc-with-incr/String6/main.c +++ b/regression/cbmc-with-incr/String6/main.c @@ -1,13 +1,13 @@ #include -#include +#include void free(void *); int main() { - char str[500]="Hello"; + char str[500]="Hello"; assert(strcmp(str, "Hello")==0); - assert(strncmp(str, "Hello", 5)==0); + assert(strncmp(str, "Hello", 5)==0); assert(strcasecmp(str, "HELLO")==0); assert(strncasecmp(str, "HELLO", 5)==0); assert(strcmp(str, "\xff")<0); diff --git a/regression/cbmc-with-incr/String7/main.c b/regression/cbmc-with-incr/String7/main.c index 1785408b9e6..7bfacd1c12e 100644 --- a/regression/cbmc-with-incr/String7/main.c +++ b/regression/cbmc-with-incr/String7/main.c @@ -1,8 +1,8 @@ -struct S { +struct S { char *Operator; }; -const struct S b1006_props = { +const struct S b1006_props = { .Operator = "OR" }; diff --git a/regression/cbmc-with-incr/String_Literal1/main.c b/regression/cbmc-with-incr/String_Literal1/main.c index c7384ba6aed..0185fdf91b2 100644 --- a/regression/cbmc-with-incr/String_Literal1/main.c +++ b/regression/cbmc-with-incr/String_Literal1/main.c @@ -11,16 +11,16 @@ int main() assert("\""[0]=='"'); assert("\%"[0]=='%'); assert("\n"[0]==10); - + // spliced to avoid hex ambiguity assert("\x5" "five"[0]==0x5); // spliced accoss multiple lines const char some_string[]= - "\x5" + "\x5" #pragma whatnot "five"; - + assert(some_string[0]==0x5); // wide strings @@ -40,16 +40,16 @@ int main() assert(euro_sign[3]==0); assert(sizeof(euro_sign)==4); - // the following is C++ and C99 + // the following is C++ and C99 const wchar_t wide_amount[]=L"\u20AC123,00"; //€123,00 assert(wide_amount[0]==0x20ac); assert(wide_amount[1]=='1'); - + // C11 unicode string literals assert(sizeof(u8""[0])==sizeof(char)); assert(sizeof(u""[0])==2); assert(sizeof(U""[0])==4); - + // generic wide string, OS-dependent assert(sizeof(L""[0])==sizeof(wchar_t)); } diff --git a/regression/cbmc-with-incr/Struct_Bytewise1/struct_bytewise.c b/regression/cbmc-with-incr/Struct_Bytewise1/struct_bytewise.c index b5482988e8a..431372d1374 100644 --- a/regression/cbmc-with-incr/Struct_Bytewise1/struct_bytewise.c +++ b/regression/cbmc-with-incr/Struct_Bytewise1/struct_bytewise.c @@ -30,7 +30,7 @@ void CopyBuffer(unsigned char *src) { arrayTmp[i] = src[i]; } } - + int main() { logAppl.a=1; @@ -60,4 +60,3 @@ int main() assert(arrayTmp[7]==1); #endif } - diff --git a/regression/cbmc-with-incr/Struct_Initialization1/main.c b/regression/cbmc-with-incr/Struct_Initialization1/main.c index 7065af7690e..f89d06d08e3 100644 --- a/regression/cbmc-with-incr/Struct_Initialization1/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization1/main.c @@ -40,7 +40,7 @@ int main() { assert(S1.f==0); assert(S1.g==2); assert(S1.p==0); - + assert(S2.s1.a==1); assert(S2.s1.b==2); assert(S2.s2.a==3); diff --git a/regression/cbmc-with-incr/Struct_Initialization10/main.c b/regression/cbmc-with-incr/Struct_Initialization10/main.c index 30168dbeac4..130936a138c 100644 --- a/regression/cbmc-with-incr/Struct_Initialization10/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization10/main.c @@ -1,8 +1,8 @@ typedef unsigned blue; - + typedef struct { unsigned blue; } ar_t; typedef struct { ar_t ar; } format_t; - + int main () { // note that 'blue' is a type-token format_t data = { .ar.blue = 1 }; diff --git a/regression/cbmc-with-incr/Struct_Initialization2/main.c b/regression/cbmc-with-incr/Struct_Initialization2/main.c index bafcdc9b388..9a04c7fd804 100644 --- a/regression/cbmc-with-incr/Struct_Initialization2/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization2/main.c @@ -16,7 +16,7 @@ int main() assert(str_array[1].b==4); int x; - + // this also exists (GCC) str_array[0] = (struct teststr){ .a=1, .c=x }; assert(str_array[0].a==1); diff --git a/regression/cbmc-with-incr/Struct_Initialization3/main.c b/regression/cbmc-with-incr/Struct_Initialization3/main.c index c5b4814d117..6152b8442bf 100644 --- a/regression/cbmc-with-incr/Struct_Initialization3/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization3/main.c @@ -2,7 +2,7 @@ typedef struct { int a; } S; - + int main(void) { S s; diff --git a/regression/cbmc-with-incr/Struct_Initialization5/main.c b/regression/cbmc-with-incr/Struct_Initialization5/main.c index 47a662328ae..455c9e107c0 100644 --- a/regression/cbmc-with-incr/Struct_Initialization5/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization5/main.c @@ -10,7 +10,7 @@ int main() { struct X foo1; struct Y foo2; - + foo2=(struct Y){ foo1 }; assert(foo2.x.y==foo1.y); diff --git a/regression/cbmc-with-incr/Struct_Initialization6/main.c b/regression/cbmc-with-incr/Struct_Initialization6/main.c index a7a7ebde9f4..6e069783f54 100644 --- a/regression/cbmc-with-incr/Struct_Initialization6/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization6/main.c @@ -6,7 +6,7 @@ struct X { int z; } f [3]; - + int g, h; } foo = { .g=200, .f[1].z=100 }; @@ -30,7 +30,7 @@ int main() assert(z.a3==30); assert(z.a4==40); assert(z.a5==0); - + assert(enable[0]==1); assert(enable[30]==2); assert(enable[31]==3); diff --git a/regression/cbmc-with-incr/Struct_Initialization7/main.c b/regression/cbmc-with-incr/Struct_Initialization7/main.c index c9ffb6434c3..08498f9b46c 100644 --- a/regression/cbmc-with-incr/Struct_Initialization7/main.c +++ b/regression/cbmc-with-incr/Struct_Initialization7/main.c @@ -6,14 +6,14 @@ struct X { int a, b, c; } y; - + int z; }; int main() { struct X x={ 1, 2 }; - + assert(x.y.a==1); assert(x.z==2); } diff --git a/regression/cbmc-with-incr/Struct_Padding1/main.c b/regression/cbmc-with-incr/Struct_Padding1/main.c index 0412e6de630..5dd960bd6c4 100644 --- a/regression/cbmc-with-incr/Struct_Padding1/main.c +++ b/regression/cbmc-with-incr/Struct_Padding1/main.c @@ -7,13 +7,13 @@ struct my_struct1 { int i; char ch; - + struct { // this gets padded int j; }; - + // Bit-fields do not get padded in between, // but fill up an integer! unsigned bf1:1; @@ -27,7 +27,7 @@ struct my_struct2 { int i; char ch[4]; - + // no padding needed int j; @@ -48,7 +48,7 @@ int main() assert(xx1.i==1); assert(xx1.ch==2); assert(xx1.j==3); - + // let's probe the padding char *p=&xx1.ch; assert(p[0]==2); diff --git a/regression/cbmc-with-incr/Union_Initialization1/main.c b/regression/cbmc-with-incr/Union_Initialization1/main.c index 831d7b4a2d6..8d3374b1997 100644 --- a/regression/cbmc-with-incr/Union_Initialization1/main.c +++ b/regression/cbmc-with-incr/Union_Initialization1/main.c @@ -18,9 +18,9 @@ union trigger : 1, mask : 1, __reserved_2 : 15; - + unsigned __reserved_3 : 24, - dest : 8; + dest : 8; } entry; } u1 = { .entry.delivery_mode = 2, .entry.mask = 1 }; @@ -33,7 +33,7 @@ union { int d, e; } c; - + } u2 = { 1 }, u3 = { .c.e = 2 } ; int main() @@ -41,7 +41,7 @@ int main() assert(u1.entry.vector==0); assert(u1.entry.delivery_mode==2); assert(u1.entry.mask==1); - + assert(u2.a==1); assert(u3.a==0); assert(u3.c.e==2); diff --git a/regression/cbmc-with-incr/Unwinding_Locality1/main.c b/regression/cbmc-with-incr/Unwinding_Locality1/main.c index 91ac5057295..41a2fbdb017 100644 --- a/regression/cbmc-with-incr/Unwinding_Locality1/main.c +++ b/regression/cbmc-with-incr/Unwinding_Locality1/main.c @@ -1,17 +1,17 @@ int main() { int i; - + for(i=0; i<10; i++) { const int a=i; } - + int array[10]; for(i=0; i<10; i++) { const int a; array[i]=a; } - + // these should all be allowed to be different assert(array[0]==array[1]); } diff --git a/regression/cbmc-with-incr/Variadic1/main.c b/regression/cbmc-with-incr/Variadic1/main.c index 6040d61bba4..d634c6e90fd 100644 --- a/regression/cbmc-with-incr/Variadic1/main.c +++ b/regression/cbmc-with-incr/Variadic1/main.c @@ -37,4 +37,3 @@ int main (void) return 0; } - diff --git a/regression/cbmc-with-incr/Visual_Studio_Types1/main.c b/regression/cbmc-with-incr/Visual_Studio_Types1/main.c index 138a7b7cb1b..48f37c2175f 100644 --- a/regression/cbmc-with-incr/Visual_Studio_Types1/main.c +++ b/regression/cbmc-with-incr/Visual_Studio_Types1/main.c @@ -12,29 +12,29 @@ int main() assert(sizeof(i3)==4); assert(sizeof(i4)==8); #endif - + // general types - + char c; short s; int i; long l; long long ll; - + assert(sizeof(c)==1); assert(sizeof(s)==2); assert(sizeof(i)==4); assert(sizeof(l)==4); assert(sizeof(ll)==8); - - // these constants are Visual Studio-specific + + // these constants are Visual Studio-specific #ifdef _MSC_VER assert(sizeof(1i8)==1); assert(sizeof(1i16)==2); assert(sizeof(1i32)==4); assert(sizeof(1i64)==8); assert(sizeof(1i128)==16); - + // oh, and these pointer qualifiers are Visual Studio-specific int * __ptr32 p32; //int * __ptr64 p64; @@ -43,6 +43,6 @@ int main() assert(sizeof(p32)==4); //assert(sizeof(p64)==8); #endif - + assert(sizeof(void *)==4); } diff --git a/regression/cbmc-with-incr/Visual_Studio_Types2/main.c b/regression/cbmc-with-incr/Visual_Studio_Types2/main.c index 3daa245332e..921143e24a6 100644 --- a/regression/cbmc-with-incr/Visual_Studio_Types2/main.c +++ b/regression/cbmc-with-incr/Visual_Studio_Types2/main.c @@ -5,12 +5,12 @@ int main() int i; long l; long long ll; - + assert(sizeof(s)==2); assert(sizeof(i)==4); assert(sizeof(l)==4); assert(sizeof(ll)==8); - + // oh, and these pointer qualifiers are MS-specific #ifdef _MSC_VER int * __ptr32 p32; @@ -20,6 +20,6 @@ int main() assert(sizeof(p32)==4); assert(sizeof(p64)==8); #endif - + assert(sizeof(void *)==8); } diff --git a/regression/cbmc-with-incr/Volatile1/main.c b/regression/cbmc-with-incr/Volatile1/main.c index 383e71c59d7..84ac4837d1e 100644 --- a/regression/cbmc-with-incr/Volatile1/main.c +++ b/regression/cbmc-with-incr/Volatile1/main.c @@ -3,4 +3,3 @@ int main() { if (!x) assert(!x); } - diff --git a/regression/cbmc-with-incr/Zero_Initialization1/main.c b/regression/cbmc-with-incr/Zero_Initialization1/main.c index a051d31258c..e179f017d0c 100644 --- a/regression/cbmc-with-incr/Zero_Initialization1/main.c +++ b/regression/cbmc-with-incr/Zero_Initialization1/main.c @@ -8,7 +8,7 @@ union U my_u; union U { - int some; + int some; }; struct S my_s; diff --git a/regression/cbmc-with-incr/__func__1/main.c b/regression/cbmc-with-incr/__func__1/main.c index 93870e6abad..f87717d5a1a 100644 --- a/regression/cbmc-with-incr/__func__1/main.c +++ b/regression/cbmc-with-incr/__func__1/main.c @@ -1,13 +1,13 @@ int main() { char ch0, ch1, ch2, ch3, ch4; - + ch0=__func__[0]; ch1=__func__[1]; ch2=__func__[2]; ch3=__func__[3]; ch4=__func__[4]; - + assert(ch0=='m'); assert(ch1=='a'); assert(ch2=='i'); diff --git a/regression/cbmc-with-incr/abs1/main.c b/regression/cbmc-with-incr/abs1/main.c index bea310ae957..e3e149726a1 100644 --- a/regression/cbmc-with-incr/abs1/main.c +++ b/regression/cbmc-with-incr/abs1/main.c @@ -10,17 +10,17 @@ int main() { int my_i, iabs; double my_d, dabs; - + assert(abs(-1)==1); assert(abs(1)==1); assert(fabs(1.0)==1); assert(fabs(-1.0)==1); - + iabs=(my_i<0)?-my_i:my_i; assert(abs(my_i)==iabs); __CPROVER_assume(!isnan(my_d)); - + dabs=(my_d<0)?-my_d:my_d; assert(fabs(my_d)==dabs); } diff --git a/regression/cbmc-with-incr/atomic_section_seq1/main.c b/regression/cbmc-with-incr/atomic_section_seq1/main.c index 630056854c3..0e223b6b658 100644 --- a/regression/cbmc-with-incr/atomic_section_seq1/main.c +++ b/regression/cbmc-with-incr/atomic_section_seq1/main.c @@ -372,4 +372,3 @@ signed int main(void) ethoc_open(&netdev); return 0; } - diff --git a/regression/cbmc-with-incr/char1/main.c b/regression/cbmc-with-incr/char1/main.c index dd90a6a764a..7e0fe699d7a 100644 --- a/regression/cbmc-with-incr/char1/main.c +++ b/regression/cbmc-with-incr/char1/main.c @@ -7,7 +7,7 @@ int main() #error _CHAR_UNSIGNED should be set #endif #endif - + #ifdef __GNUC__ #ifndef __CHAR_UNSIGNED__ #error __CHAR_UNSIGNED__ should be set diff --git a/regression/cbmc-with-incr/character_handling1/main.c b/regression/cbmc-with-incr/character_handling1/main.c index f0ae7f185da..ca5a1067d94 100644 --- a/regression/cbmc-with-incr/character_handling1/main.c +++ b/regression/cbmc-with-incr/character_handling1/main.c @@ -1,16 +1,16 @@ -int isalnum(int c); -int isalpha(int c); -int isblank(int c); -int iscntrl(int c); -int isdigit(int c); -int isgraph(int c); -int islower(int c); -int isprint(int c); -int ispunct(int c); -int isspace(int c); -int isupper(int c); -int isxdigit(int c); -int tolower(int c); +int isalnum(int c); +int isalpha(int c); +int isblank(int c); +int iscntrl(int c); +int isdigit(int c); +int isgraph(int c); +int islower(int c); +int isprint(int c); +int ispunct(int c); +int isspace(int c); +int isupper(int c); +int isxdigit(int c); +int tolower(int c); int toupper(int c); int main() @@ -22,7 +22,7 @@ int main() assert(!isalnum(' ')); assert(!isalnum('.')); assert(!isalnum(0)); - + assert(isalpha('a')); assert(!isalpha('1')); assert(isalpha('A')); @@ -30,7 +30,7 @@ int main() assert(!isalpha(' ')); assert(!isalpha('.')); assert(!isalpha(0)); - + assert(!isblank('a')); assert(!isblank('1')); assert(!isblank('A')); @@ -38,7 +38,7 @@ int main() assert(isblank(' ')); assert(!isblank('.')); assert(!isblank(0)); - + assert(!iscntrl('a')); assert(!iscntrl('1')); assert(!iscntrl('A')); @@ -46,7 +46,7 @@ int main() assert(!iscntrl(' ')); assert(!iscntrl('.')); assert(iscntrl(0)); - + assert(!isdigit('a')); assert(isdigit('1')); assert(!isdigit('A')); @@ -54,7 +54,7 @@ int main() assert(!isdigit(' ')); assert(!isdigit('.')); assert(!isdigit(0)); - + assert(islower('a')); assert(!islower('1')); assert(!islower('A')); @@ -62,7 +62,7 @@ int main() assert(!islower(' ')); assert(!islower('.')); assert(!islower(0)); - + assert(!isupper('a')); assert(!isupper('1')); assert(isupper('A')); @@ -70,7 +70,7 @@ int main() assert(!isupper(' ')); assert(!isupper('.')); assert(!isupper(0)); - + assert(!isspace('a')); assert(!isspace('1')); assert(!isspace('A')); @@ -78,7 +78,7 @@ int main() assert(isspace(' ')); assert(!isspace('.')); assert(!isspace(0)); - + assert(tolower('a')=='a'); assert(tolower('1')=='1'); assert(tolower('A')=='a'); @@ -86,7 +86,7 @@ int main() assert(tolower(' ')==' '); assert(tolower('.')=='.'); assert(tolower(0)==0); - + assert(toupper('a')=='A'); assert(toupper('1')=='1'); assert(toupper('A')=='A'); @@ -94,5 +94,5 @@ int main() assert(toupper(' ')==' '); assert(toupper('.')=='.'); assert(toupper(0)==0); - + } diff --git a/regression/cbmc-with-incr/complex1/main.c b/regression/cbmc-with-incr/complex1/main.c index aebdad77108..72695b5edf9 100644 --- a/regression/cbmc-with-incr/complex1/main.c +++ b/regression/cbmc-with-incr/complex1/main.c @@ -8,15 +8,15 @@ int main() c=1.0i+2; assert(__real__ c == 2); - assert(__imag__ c == 1); - + assert(__imag__ c == 1); + _Complex double d; assert(sizeof(c)==sizeof(d)); - + _Complex signed char char_complex, char_complex2; - + char_complex=0x3i-2; - + assert(sizeof(d)==sizeof(c)); assert(sizeof(char_complex)==sizeof(signed char)*2); @@ -26,37 +26,37 @@ int main() assert(((signed char *)&char_complex)[0]==-2); assert(((signed char *)&char_complex)[1]==3); #endif - + assert(__real__ char_complex == -2); assert(__imag__ char_complex == 3); - + // the precedence of __imag__ is higher than that of + assert((__imag__ 1.0i + 1.0i) == 1.0i + 1.0); - + // complex conjugate char_complex2 = ~ char_complex; - + // __real__ something is an lvalue! - __real__ char_complex = 100; + __real__ char_complex = 100; assert(__real__ char_complex == 100); assert(__imag__ char_complex == 3); - // can be incremented + // can be incremented char_complex++; assert(__real__ char_complex == 101); assert(__imag__ char_complex == 3); - + // also separately (__real__ char_complex)++; - assert(__real__ char_complex == 102); + assert(__real__ char_complex == 102); assert(__imag__ char_complex == 3); - + // casts to reals produce the real part - assert((int) char_complex == 102); - + assert((int) char_complex == 102); + #else - - // Visual studio doesn't have it + + // Visual studio doesn't have it #endif } diff --git a/regression/cbmc-with-incr/compound_literal1/main.c b/regression/cbmc-with-incr/compound_literal1/main.c index 82d65125ab1..fb9374523f0 100644 --- a/regression/cbmc-with-incr/compound_literal1/main.c +++ b/regression/cbmc-with-incr/compound_literal1/main.c @@ -16,15 +16,15 @@ int main() assert(((float[2]) {2.7, 3.1})[1]==3.1f); assert(((struct POINT) {0, 1}).y==1); assert(((union U) {1.4}).f==1.4f); - + // Address can be taken, lifetime is that of the // containing block. int *p=&(int){ 42 }; assert(*p==42); - + // and modified *p=43; assert(*p==43); - + return 0; } diff --git a/regression/cbmc-with-incr/const_ptr1/main.c b/regression/cbmc-with-incr/const_ptr1/main.c index d0a109c690d..fb235940af3 100644 --- a/regression/cbmc-with-incr/const_ptr1/main.c +++ b/regression/cbmc-with-incr/const_ptr1/main.c @@ -15,13 +15,13 @@ int main() // to a constant pointer to pointers to constant-chars const char * const *p2; p2=my_array; - + const char *p3; char ch; - + p3=*p2; - + ch=*p3; - + assert(ch=='x'); } diff --git a/regression/cbmc-with-incr/enum1/main.c b/regression/cbmc-with-incr/enum1/main.c index 74d940ea1d0..ed76336f860 100644 --- a/regression/cbmc-with-incr/enum1/main.c +++ b/regression/cbmc-with-incr/enum1/main.c @@ -11,13 +11,13 @@ int array[E5]; int main() { int integer; - + a=E2; assert(a==1); - + assert(E4==4); assert(sizeof(array)==sizeof(int)*5); - + integer=a; assert(integer==1); } diff --git a/regression/cbmc-with-incr/enum3/main.c b/regression/cbmc-with-incr/enum3/main.c index 44d6a512bd0..256b046cb6a 100644 --- a/regression/cbmc-with-incr/enum3/main.c +++ b/regression/cbmc-with-incr/enum3/main.c @@ -9,4 +9,4 @@ int main(void) assert(token==Cx); return 1; -} +} diff --git a/regression/cbmc-with-incr/enum4/main.c b/regression/cbmc-with-incr/enum4/main.c index 682347573c1..27c717a3591 100644 --- a/regression/cbmc-with-incr/enum4/main.c +++ b/regression/cbmc-with-incr/enum4/main.c @@ -14,4 +14,3 @@ int main() void *(___args[1]) = {&_event_arg}; execute(___args); } - diff --git a/regression/cbmc-with-incr/equality_through_array3/main.c b/regression/cbmc-with-incr/equality_through_array3/main.c index e9768e552c0..9e94a5eba95 100644 --- a/regression/cbmc-with-incr/equality_through_array3/main.c +++ b/regression/cbmc-with-incr/equality_through_array3/main.c @@ -26,4 +26,3 @@ void main () return 1; } - diff --git a/regression/cbmc-with-incr/equality_through_array4/main.c b/regression/cbmc-with-incr/equality_through_array4/main.c index 72b3c671827..06fe628b50a 100644 --- a/regression/cbmc-with-incr/equality_through_array4/main.c +++ b/regression/cbmc-with-incr/equality_through_array4/main.c @@ -21,4 +21,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc-with-incr/equality_through_array5/main.c b/regression/cbmc-with-incr/equality_through_array5/main.c index f148f2f7fef..41102922960 100644 --- a/regression/cbmc-with-incr/equality_through_array5/main.c +++ b/regression/cbmc-with-incr/equality_through_array5/main.c @@ -22,4 +22,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc-with-incr/equality_through_struct1/main.c b/regression/cbmc-with-incr/equality_through_struct1/main.c index 02394abb3e2..5b78b7af31d 100644 --- a/regression/cbmc-with-incr/equality_through_struct1/main.c +++ b/regression/cbmc-with-incr/equality_through_struct1/main.c @@ -20,4 +20,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc-with-incr/equality_through_struct_containing_arrays1/main.c b/regression/cbmc-with-incr/equality_through_struct_containing_arrays1/main.c index 33893d5de03..4b88e22f3b9 100644 --- a/regression/cbmc-with-incr/equality_through_struct_containing_arrays1/main.c +++ b/regression/cbmc-with-incr/equality_through_struct_containing_arrays1/main.c @@ -41,4 +41,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc-with-incr/equality_through_struct_containing_arrays2/main.c b/regression/cbmc-with-incr/equality_through_struct_containing_arrays2/main.c index d6dd912406f..a10f7cf2ec4 100644 --- a/regression/cbmc-with-incr/equality_through_struct_containing_arrays2/main.c +++ b/regression/cbmc-with-incr/equality_through_struct_containing_arrays2/main.c @@ -46,4 +46,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc-with-incr/exit1/main.c b/regression/cbmc-with-incr/exit1/main.c index 0661315487b..c403cc204f0 100644 --- a/regression/cbmc-with-incr/exit1/main.c +++ b/regression/cbmc-with-incr/exit1/main.c @@ -2,7 +2,7 @@ void exit(int status); int main() { int x; - + if(x==10) exit(1); diff --git a/regression/cbmc-with-incr/extern_initialization1/file2.c b/regression/cbmc-with-incr/extern_initialization1/file2.c index 579cd194cb1..430d09c7316 100644 --- a/regression/cbmc-with-incr/extern_initialization1/file2.c +++ b/regression/cbmc-with-incr/extern_initialization1/file2.c @@ -1,2 +1 @@ extern int some_int; - diff --git a/regression/cbmc-with-incr/extern_initialization2/file2.c b/regression/cbmc-with-incr/extern_initialization2/file2.c index 894a5c09d13..f0bd0cbd8d1 100644 --- a/regression/cbmc-with-incr/extern_initialization2/file2.c +++ b/regression/cbmc-with-incr/extern_initialization2/file2.c @@ -4,4 +4,3 @@ extern int some_int; int some_int; extern int some_int; - diff --git a/regression/cbmc-with-incr/for-break1/main.c b/regression/cbmc-with-incr/for-break1/main.c index 88c5344cb36..c6fe8f78046 100644 --- a/regression/cbmc-with-incr/for-break1/main.c +++ b/regression/cbmc-with-incr/for-break1/main.c @@ -9,6 +9,6 @@ int main() b=1; } - + assert(a==b); } diff --git a/regression/cbmc-with-incr/for1/main.c b/regression/cbmc-with-incr/for1/main.c index 1a650444570..d3448117650 100644 --- a/regression/cbmc-with-incr/for1/main.c +++ b/regression/cbmc-with-incr/for1/main.c @@ -1,13 +1,13 @@ int main() { int i=0; - + for(;;) { i++; if(i==30) break; } - + assert(i==30); return 0; diff --git a/regression/cbmc-with-incr/gcc_conditional_expr1/main.c b/regression/cbmc-with-incr/gcc_conditional_expr1/main.c index 53c43ce675c..5f6f46bbba4 100644 --- a/regression/cbmc-with-incr/gcc_conditional_expr1/main.c +++ b/regression/cbmc-with-incr/gcc_conditional_expr1/main.c @@ -3,15 +3,15 @@ int g, k; int main() { int r1, r2; - + r1= (g++) ? : 2; - + assert(r1==2); assert(g==1); r2= (g++) ? : (k++); - + assert(r2==1); - assert(g==2); + assert(g==2); assert(k==0); } diff --git a/regression/cbmc-with-incr/gcc_local_label1/main.c b/regression/cbmc-with-incr/gcc_local_label1/main.c index 2bdea2be2d3..d9263aa3740 100644 --- a/regression/cbmc-with-incr/gcc_local_label1/main.c +++ b/regression/cbmc-with-incr/gcc_local_label1/main.c @@ -8,14 +8,14 @@ void other_f() #ifdef __GNUC__ here:; x++; - + { __label__ here, there; - + goto here; // not jumping up, but down! here:; // this would usually fail - + assert(0); } #else @@ -28,4 +28,3 @@ int main() { other_f(); } - diff --git a/regression/cbmc-with-incr/gcc_statement_expression1/main.c b/regression/cbmc-with-incr/gcc_statement_expression1/main.c index 539e53e4170..843323e4308 100644 --- a/regression/cbmc-with-incr/gcc_statement_expression1/main.c +++ b/regression/cbmc-with-incr/gcc_statement_expression1/main.c @@ -3,20 +3,20 @@ int main() int x; int y; - // as a side-effect + // as a side-effect ({ x=1; x;}); - + assert(x==1); - + x= ({ y=1; 2; }); assert(x==2); assert(y==1); - + // inside an initializer: a needs to be visible // before doing the initializer int a=({ int b=(long int)&a; b; }); - + return 0; } diff --git a/regression/cbmc-with-incr/gcc_statement_expression2/main.c b/regression/cbmc-with-incr/gcc_statement_expression2/main.c index a36b68191b8..c1bfc88eaa1 100644 --- a/regression/cbmc-with-incr/gcc_statement_expression2/main.c +++ b/regression/cbmc-with-incr/gcc_statement_expression2/main.c @@ -8,7 +8,7 @@ int f() int main() { int i; - + int x = ({f();}); assert(x==1); @@ -20,7 +20,7 @@ int main() int z = ({ i=1; i++; }); assert(z==1); assert(i==2); - + // same at top level ({ i=1; i++; }); assert(i==2); diff --git a/regression/cbmc-with-incr/gcc_vector1/main.c b/regression/cbmc-with-incr/gcc_vector1/main.c index 81ee89d5bfa..69121e20234 100644 --- a/regression/cbmc-with-incr/gcc_vector1/main.c +++ b/regression/cbmc-with-incr/gcc_vector1/main.c @@ -17,7 +17,7 @@ int main() assert(sizeof(v4si)==16); vector_u x, y, z; - + z.v=x.v+y.v; assert(z.members[0]==x.members[0]+y.members[0]); @@ -45,7 +45,7 @@ int main() assert(z.members[1]==~x.members[1]); assert(z.members[2]==~x.members[2]); assert(z.members[3]==~x.members[3]); - + // build vector with typecast z.v=(v4si){ 0, 1, 2, 3 }; assert(z.members[0]==0 && z.members[1]==1 && z.members[2]==2 && z.members[3]==3); @@ -54,14 +54,14 @@ int main() v4si some_vector={ 10, 11, 12, 13 }; z.v=some_vector; assert(z.members[0]==10 && z.members[1]==11 && z.members[2]==12 && z.members[3]==13); - + // same from one v4si other_vector={ 0 }; z.v=other_vector; // an array of vectors v4si image[] = { other_vector }; - + assert(z.members[1]==0); } diff --git a/regression/cbmc-with-incr/gcc_vector2/main.c b/regression/cbmc-with-incr/gcc_vector2/main.c index 89d2a9d9961..c35987af7c8 100644 --- a/regression/cbmc-with-incr/gcc_vector2/main.c +++ b/regression/cbmc-with-incr/gcc_vector2/main.c @@ -30,7 +30,7 @@ int main() assert(((int*) &a)[i]==((int*) &b)[i]); assert(((int*) &b)[i]==b[i]); } - + #endif return 0; diff --git a/regression/cbmc-with-incr/goto1/main.c b/regression/cbmc-with-incr/goto1/main.c index ceb93ebe0cb..1eaf79a78d0 100644 --- a/regression/cbmc-with-incr/goto1/main.c +++ b/regression/cbmc-with-incr/goto1/main.c @@ -1,14 +1,14 @@ int main() { int i, j; - + if(i) goto l; - + if(j) goto l; - + assert(!i && !j); - - l:; + + l:; } diff --git a/regression/cbmc-with-incr/goto2/main.c b/regression/cbmc-with-incr/goto2/main.c index 320c107fb8e..26219e65fe3 100644 --- a/regression/cbmc-with-incr/goto2/main.c +++ b/regression/cbmc-with-incr/goto2/main.c @@ -8,8 +8,8 @@ int main() goto l; i=2; - - l:; - + + l:; + assert(i==1 || !j); } diff --git a/regression/cbmc-with-incr/goto3/main.c b/regression/cbmc-with-incr/goto3/main.c index 19d27206bd8..985725bc086 100644 --- a/regression/cbmc-with-incr/goto3/main.c +++ b/regression/cbmc-with-incr/goto3/main.c @@ -1,15 +1,15 @@ int main() { int i; - + i=0; loop: assert(i<10); i++; - + if(i<10) goto loop; - + assert(i==10); } diff --git a/regression/cbmc-with-incr/if2/main.c b/regression/cbmc-with-incr/if2/main.c index 94ba1071143..bec127110bc 100644 --- a/regression/cbmc-with-incr/if2/main.c +++ b/regression/cbmc-with-incr/if2/main.c @@ -3,10 +3,10 @@ int nondet_int(); int main() { int i, j, k; - + i=nondet_int(); k=nondet_int(); - + if(i) { } diff --git a/regression/cbmc-with-incr/if3/main.c b/regression/cbmc-with-incr/if3/main.c index 08c20e43bf0..be1474285e1 100644 --- a/regression/cbmc-with-incr/if3/main.c +++ b/regression/cbmc-with-incr/if3/main.c @@ -1,11 +1,11 @@ int main() { goto ERROR; - + if(0) { ERROR: assert(0); } - + return 0; } diff --git a/regression/cbmc-with-incr/if4/main.c b/regression/cbmc-with-incr/if4/main.c index 1a67c7ebbbd..e109c21dbd5 100644 --- a/regression/cbmc-with-incr/if4/main.c +++ b/regression/cbmc-with-incr/if4/main.c @@ -3,10 +3,10 @@ int main() int x; __CPROVER_assume(x==1); - + if(x==2) x++; - + // this should pass assert(x==1); } diff --git a/regression/cbmc-with-incr/inline1/header.h b/regression/cbmc-with-incr/inline1/header.h index c18b4ee55a3..3aea02623ce 100644 --- a/regression/cbmc-with-incr/inline1/header.h +++ b/regression/cbmc-with-incr/inline1/header.h @@ -6,4 +6,3 @@ static inline void f() { x=1; } - diff --git a/regression/cbmc-with-incr/int-to-float2/main.c b/regression/cbmc-with-incr/int-to-float2/main.c index ae817fabf69..5c095d2849e 100644 --- a/regression/cbmc-with-incr/int-to-float2/main.c +++ b/regression/cbmc-with-incr/int-to-float2/main.c @@ -44,7 +44,7 @@ int main(void) assert(castWithRounding(FE_DOWNWARD,x) == low); assert(castWithRounding(FE_DOWNWARD,-x) == -high); #endif - + assert(castWithRounding(FE_TOWARDZERO,x) == low); assert(castWithRounding(FE_TOWARDZERO,-x) == -low); #endif diff --git a/regression/cbmc-with-incr/locations1/main.c b/regression/cbmc-with-incr/locations1/main.c index 3b59c036d56..163cb1d5e74 100644 --- a/regression/cbmc-with-incr/locations1/main.c +++ b/regression/cbmc-with-incr/locations1/main.c @@ -35,4 +35,3 @@ int8_t StateMachines_testFlightAnalyzer(void) { int main() {} - diff --git a/regression/cbmc-with-incr/noop1/main.c b/regression/cbmc-with-incr/noop1/main.c index a24eb909bb1..5341fb34ad1 100644 --- a/regression/cbmc-with-incr/noop1/main.c +++ b/regression/cbmc-with-incr/noop1/main.c @@ -10,6 +10,6 @@ int main() { // http://msdn.microsoft.com/en-us/library/s6btaxcs%28v=vs.80%29.aspx // the arguments of __noop are _not_ evaluated - + __noop(some_function()); } diff --git a/regression/cbmc-with-incr/offsetof1/main.c b/regression/cbmc-with-incr/offsetof1/main.c index bc6d6db14e9..392747e1aca 100644 --- a/regression/cbmc-with-incr/offsetof1/main.c +++ b/regression/cbmc-with-incr/offsetof1/main.c @@ -5,7 +5,7 @@ struct S int i; char ch; int j; // this gets aligned - + struct Ssub { int x, y; @@ -42,10 +42,10 @@ int main(void) assert((long int)&((struct S *)0)->array==16+4); assert((long int)&((struct S *)0)->array[1]==16+12); assert((long int)&((struct S *)0)->array[1].y==16+12+4); - + // these are _constants_! - #ifdef __GNUC__ + #ifdef __GNUC__ enum { E1 = __builtin_offsetof(struct S, ch) }; #endif diff --git a/regression/cbmc-with-incr/pipe1/main.c b/regression/cbmc-with-incr/pipe1/main.c index 17d282c945d..7bfb9f80f1d 100644 --- a/regression/cbmc-with-incr/pipe1/main.c +++ b/regression/cbmc-with-incr/pipe1/main.c @@ -13,7 +13,7 @@ int main() #ifdef _WIN32 int ret=_pipe(filedesc, 1000, O_BINARY); - #else + #else int ret=pipe(filedesc); #endif diff --git a/regression/cbmc-with-incr/return5/main.c b/regression/cbmc-with-incr/return5/main.c index 40f889b7978..ca143df9e00 100644 --- a/regression/cbmc-with-incr/return5/main.c +++ b/regression/cbmc-with-incr/return5/main.c @@ -39,6 +39,6 @@ int main() res1 = f1(a); assert(res0 == res1); /* <-- should fail */ - + return 0; } diff --git a/regression/cbmc-with-incr/struct4/main.c b/regression/cbmc-with-incr/struct4/main.c index c6f4dd7e2bd..6406255b45e 100644 --- a/regression/cbmc-with-incr/struct4/main.c +++ b/regression/cbmc-with-incr/struct4/main.c @@ -2,7 +2,7 @@ #ifdef PRINT #include -void assert(int cond) +void assert(int cond) { if(!cond) printf("assert failed!\n"); } #endif diff --git a/regression/cbmc-with-incr/struct6/main.c b/regression/cbmc-with-incr/struct6/main.c index 4bf4e892fb2..c83aeeff695 100644 --- a/regression/cbmc-with-incr/struct6/main.c +++ b/regression/cbmc-with-incr/struct6/main.c @@ -10,7 +10,7 @@ struct S int main() { struct S *p=malloc(sizeof(struct S)+10); - + p->x=1; p->a[0]=3; p->a[9]=3; diff --git a/regression/cbmc-with-incr/struct7/main.c b/regression/cbmc-with-incr/struct7/main.c index b9983f37509..45c5798a48e 100644 --- a/regression/cbmc-with-incr/struct7/main.c +++ b/regression/cbmc-with-incr/struct7/main.c @@ -7,7 +7,7 @@ struct my_struct void f(int *p) { int diff; - + diff=p-&s.array[0]; // should pass @@ -19,7 +19,7 @@ int main() int ind, x; ind=x; int *p=&s.array[ind]; - + if(ind>=0 && ind<=9) f(p); } diff --git a/regression/cbmc-with-incr/struct8/main.c b/regression/cbmc-with-incr/struct8/main.c index b16d954ec30..c8e65e7bcd0 100644 --- a/regression/cbmc-with-incr/struct8/main.c +++ b/regression/cbmc-with-incr/struct8/main.c @@ -6,11 +6,11 @@ struct X int main() { int aa, bb, cc; - + struct X foo; - + foo=(struct X) { aa, bb, cc }; - + assert(foo.a==aa); assert(foo.b==bb); assert(foo.c==cc); diff --git a/regression/cbmc-with-incr/switch1/main.c b/regression/cbmc-with-incr/switch1/main.c index 197e17d7b16..cb69400a25d 100644 --- a/regression/cbmc-with-incr/switch1/main.c +++ b/regression/cbmc-with-incr/switch1/main.c @@ -1,7 +1,7 @@ int main() { int i; - + switch(i) { case 0: @@ -12,7 +12,7 @@ int main() case 2: assert(i==2); break; - + default: assert(i!=0 && i!=1 && i!=2); } diff --git a/regression/cbmc-with-incr/switch2/main.c b/regression/cbmc-with-incr/switch2/main.c index 173e5a7a3d7..41d8afa789d 100644 --- a/regression/cbmc-with-incr/switch2/main.c +++ b/regression/cbmc-with-incr/switch2/main.c @@ -6,7 +6,7 @@ int f(int j) { case 3: return 4; - + default: return 5; } @@ -15,15 +15,15 @@ int f(int j) int main() { int i; - + __CPROVER_assume(i==3 || i==4); - + switch(f(i)) { case 4: assert(i==3); break; - + case 5: assert(i==4); break; diff --git a/regression/cbmc-with-incr/switch3/main.c b/regression/cbmc-with-incr/switch3/main.c index c6e393d45ba..3fd83d24c23 100644 --- a/regression/cbmc-with-incr/switch3/main.c +++ b/regression/cbmc-with-incr/switch3/main.c @@ -3,15 +3,15 @@ char nondet_char(); int main() { char ch=nondet_char(); - + switch(ch) { case 'P': case 'p': assert(ch==80 || ch==112); break; - + default: - assert(ch!=80 && ch!=112); + assert(ch!=80 && ch!=112); } } diff --git a/regression/cbmc-with-incr/switch4/main.c b/regression/cbmc-with-incr/switch4/main.c index ed69fa3c776..b2337cbce06 100644 --- a/regression/cbmc-with-incr/switch4/main.c +++ b/regression/cbmc-with-incr/switch4/main.c @@ -6,7 +6,7 @@ main() { case 0: goto end; - + default: x = 0; } diff --git a/regression/cbmc-with-incr/switch5/main.c b/regression/cbmc-with-incr/switch5/main.c index 89222d1bcfb..17db2cd5ad2 100644 --- a/regression/cbmc-with-incr/switch5/main.c +++ b/regression/cbmc-with-incr/switch5/main.c @@ -1,13 +1,13 @@ int main() { unsigned int i, j; - + switch(i) { case 10: j=10; break; - + default:; j=i+1; } diff --git a/regression/cbmc-with-incr/switch6/main.c b/regression/cbmc-with-incr/switch6/main.c index e61cc2775a4..7e9e73261e5 100644 --- a/regression/cbmc-with-incr/switch6/main.c +++ b/regression/cbmc-with-incr/switch6/main.c @@ -5,14 +5,14 @@ enum { ASD1, ASD2 } e; int main() { const char *p; - + e=ASD1; - + p=({ const char *tmp; switch(e) { case ASD1: tmp="abc"; } tmp; }); - assert(p[0]=='a'); - assert(p[1]=='b'); - assert(p[2]=='c'); + assert(p[0]=='a'); + assert(p[1]=='b'); + assert(p[2]=='c'); assert(p[3]==0); } diff --git a/regression/cbmc-with-incr/union1/main.c b/regression/cbmc-with-incr/union1/main.c index a78135bff1f..0b0dc8a8a26 100644 --- a/regression/cbmc-with-incr/union1/main.c +++ b/regression/cbmc-with-incr/union1/main.c @@ -5,18 +5,18 @@ union u_type }; // rest of my_U should be zero -union u_type my_U = { .ch = 1 }; +union u_type my_U = { .ch = 1 }; int main() { // little and big endian case, assuming sizeof(int)==4 - assert(my_U.i==1 || my_U.i==0x01000000); + assert(my_U.i==1 || my_U.i==0x01000000); union u_type u; - + u.i=1; assert(u.i==1); - + u.ch=2; assert(u.ch==2); } diff --git a/regression/cbmc-with-incr/union3/main.c b/regression/cbmc-with-incr/union3/main.c index e50ee188af5..205989d0e9c 100644 --- a/regression/cbmc-with-incr/union3/main.c +++ b/regression/cbmc-with-incr/union3/main.c @@ -9,7 +9,7 @@ int main(void) { int x; assert(my_func(x)==x); - + // this is yet another gcc extension union my_U { @@ -17,10 +17,10 @@ int main(void) char ch; float f; } union_object; - + float some_float=1.5; - + union_object=(union my_U)some_float; - + assert(union_object.f==1.5); -} +} diff --git a/regression/cbmc-with-incr/union5/main.c b/regression/cbmc-with-incr/union5/main.c index c1cdd66560f..908ebba3297 100644 --- a/regression/cbmc-with-incr/union5/main.c +++ b/regression/cbmc-with-incr/union5/main.c @@ -7,7 +7,7 @@ union u_type int main() { // rest of my_U should be non-deterministic - union u_type my_U = { .ch = 1 }; + union u_type my_U = { .ch = 1 }; // should fail assert(my_U.i==1); diff --git a/regression/cbmc-with-incr/va_list1/main.c b/regression/cbmc-with-incr/va_list1/main.c index 6a5c0a625a2..4748baf01ab 100644 --- a/regression/cbmc-with-incr/va_list1/main.c +++ b/regression/cbmc-with-incr/va_list1/main.c @@ -6,15 +6,15 @@ int my_f(int x, ...) { __builtin_va_list list; __builtin_va_start(list, x); - + int value; unsigned i; - + for(i=0; i>=1; assert(x==-2); assert(y==-2); - + // should also work with mixed types assert(((-2)>>1u)==-1); - // more arithmetic shifts for negative numbers + // more arithmetic shifts for negative numbers x=-1; - x=x>>1; + x=x>>1; assert(x==-1); - + x=-10; x=x>>10; - assert(x==-1); + assert(x==-1); } diff --git a/regression/cbmc/Address_of1/main.c b/regression/cbmc/Address_of1/main.c index cbb4756b046..f5fcb9c5f9f 100644 --- a/regression/cbmc/Address_of1/main.c +++ b/regression/cbmc/Address_of1/main.c @@ -5,29 +5,29 @@ int main() { int some_int=20; int *p; - + // Compound literals are l-values, so their address // can be taken. p=(int []){ 1, 2, 3, some_int }; - + assert(p[0]==1); assert(p[1]==2); assert(p[2]==3); assert(p[3]==20); - + struct S { int x, y; } *q; - + q=&(struct S){ .x=1 }; - + assert(q->x==1); assert(q->y==0); - + const char *sptr="asd"; assert(sptr[0]=='a'); assert(sptr[1]=='s'); assert(sptr[2]=='d'); assert(sptr[3]==0); - + const wchar_t *wsptr; wsptr=L"asd"; assert(wsptr[0]=='a'); diff --git a/regression/cbmc/Anonymous_Struct2/main.c b/regression/cbmc/Anonymous_Struct2/main.c index 8396c4ecf38..ac80b39f43c 100644 --- a/regression/cbmc/Anonymous_Struct2/main.c +++ b/regression/cbmc/Anonymous_Struct2/main.c @@ -32,7 +32,7 @@ struct S_struct union U_union { int x, y; }; - + int z; } s; @@ -43,7 +43,7 @@ int main() s.x=1; s.y=2; s.z=3; - + assert(s2.y==1); assert(s2.z==1); } diff --git a/regression/cbmc/Anonymous_Struct3/main.c b/regression/cbmc/Anonymous_Struct3/main.c index 2bd6ccc4cfd..4179acb303c 100644 --- a/regression/cbmc/Anonymous_Struct3/main.c +++ b/regression/cbmc/Anonymous_Struct3/main.c @@ -7,11 +7,11 @@ typedef union my_U { unsigned : 1; unsigned f1 : 1; }; - char raw; + char raw; } fields_t; fields_t x; - + int main() { unsigned word=1; diff --git a/regression/cbmc/Array_Initialization1/main.c b/regression/cbmc/Array_Initialization1/main.c index db867b00d99..a9d976cf6f7 100644 --- a/regression/cbmc/Array_Initialization1/main.c +++ b/regression/cbmc/Array_Initialization1/main.c @@ -20,11 +20,10 @@ int main() // both must be complete sizeof(abc1); sizeof(abc2); - + assert(string_array[0][0][0]=='1'); assert(string_array[0][0][1]=='2'); assert(string_array[0][0][2]=='3'); assert(string_array[0][0][3]=='4'); assert(string_array[0][0][4]==0); } - diff --git a/regression/cbmc/Array_Initialization3/main.c b/regression/cbmc/Array_Initialization3/main.c index 5cfe8b93eb9..f9dc6e270f8 100644 --- a/regression/cbmc/Array_Initialization3/main.c +++ b/regression/cbmc/Array_Initialization3/main.c @@ -22,16 +22,16 @@ int main(void) { assert(array1[0][1]==2); assert(array1[1][0]==3); // returned false in this case - + assert(array2[0]==0); assert(array2[1]==10); assert(array2[10]==100); assert(sizeof(array2)==sizeof(int)*11); - + assert(sizeof(array3)==sizeof(int)*8); - + assert(sizeof(array7)==sizeof(int)*2); assert(sizeof(array8)==sizeof(int)*3); - + return 0; } diff --git a/regression/cbmc/Assumption1/main.c b/regression/cbmc/Assumption1/main.c index 25c8d4472f8..dfd9db4e67d 100644 --- a/regression/cbmc/Assumption1/main.c +++ b/regression/cbmc/Assumption1/main.c @@ -1,7 +1,7 @@ int main() { int x; - + __CPROVER_assume(x>=0); assert(x!=-1); @@ -10,4 +10,3 @@ int main() __CPROVER_assume(x==1); assert(x==1); // passes } - diff --git a/regression/cbmc/BV_Arithmetic2/main.c b/regression/cbmc/BV_Arithmetic2/main.c index b9cdf2cdce4..86c3911b20c 100644 --- a/regression/cbmc/BV_Arithmetic2/main.c +++ b/regression/cbmc/BV_Arithmetic2/main.c @@ -16,6 +16,6 @@ int main() r0=test_bit_parity(699050); assert(r0==0); - r1=test_bit_parity(699050+1); + r1=test_bit_parity(699050+1); assert(r1==1); } diff --git a/regression/cbmc/BV_Arithmetic4/main.c b/regression/cbmc/BV_Arithmetic4/main.c index d5dde5769a2..36f03a6778d 100644 --- a/regression/cbmc/BV_Arithmetic4/main.c +++ b/regression/cbmc/BV_Arithmetic4/main.c @@ -10,14 +10,14 @@ int test_extend2(int x, unsigned width) x = bit | (~mask & x); mask <<= 1; bit <<= 1; - } + } return x; } int main() { int r; - + r=test_extend2(4, 3); assert(r==-4); } diff --git a/regression/cbmc/BV_Arithmetic5/main.c b/regression/cbmc/BV_Arithmetic5/main.c index 130e7f1014d..bc013cc1a75 100644 --- a/regression/cbmc/BV_Arithmetic5/main.c +++ b/regression/cbmc/BV_Arithmetic5/main.c @@ -1,7 +1,7 @@ unsigned int test_log2(unsigned int v) { unsigned c = 0; // c will be lg(v) - while (v >>= 1) + while (v >>= 1) { c++; } @@ -11,7 +11,7 @@ unsigned int test_log2(unsigned int v) int main() { int r; - + r=test_log2(128); assert(r==7); } diff --git a/regression/cbmc/BV_Arithmetic6/main.c b/regression/cbmc/BV_Arithmetic6/main.c index 19af0c6b425..d971a119fd0 100644 --- a/regression/cbmc/BV_Arithmetic6/main.c +++ b/regression/cbmc/BV_Arithmetic6/main.c @@ -2,7 +2,7 @@ int main() { { unsigned i, j, k, l; - + j=k; i=j/2; l=j>>1; @@ -13,7 +13,7 @@ int main() l=j&1; assert(i==l); } - + { signed int i, j, k, l; @@ -28,6 +28,6 @@ int main() i=j%2; l=j&1; assert(i==l); - + } } diff --git a/regression/cbmc/Bitfields1/main.c b/regression/cbmc/Bitfields1/main.c index b05c2df095b..7ab19426ca3 100644 --- a/regression/cbmc/Bitfields1/main.c +++ b/regression/cbmc/Bitfields1/main.c @@ -15,45 +15,45 @@ struct bft { // an anonymous bitfield signed int :2; - + // with typedef INT x:1; - + // made of sizeof unsigned int abc: sizeof(int); // enums are integers! INTEL_CACHE_TYPE Type : 5; - + // and good as field sizes INTEL_CACHE_TYPE Field2 : IntelCacheTrace; }; int main() { struct bft bf; - + assert(bf.a<=7); assert(bf.b<=1); assert(bf.c<=1); - + bf.a&=0; assert(bf.a==0); - + bf.a+=9; assert(bf.a==1); - + bf.a<<=1; assert(bf.a==2); - + bf.a>>=1; assert(bf.a==1); - + bf.d=2; assert(bf.d==1); - + // assignments have the underlying type assert(sizeof(bf.d=1)==sizeof(_Bool)); assert(sizeof(bf.a+=1)==sizeof(unsigned)); - + bf.Type=IntelCacheTrace; } diff --git a/regression/cbmc/Bitfields2/main.c b/regression/cbmc/Bitfields2/main.c index 946cb66ba04..4322e6aa4f9 100644 --- a/regression/cbmc/Bitfields2/main.c +++ b/regression/cbmc/Bitfields2/main.c @@ -23,7 +23,7 @@ struct S0 { int64_t f2; uint32_t f3; // skipped over during initialization - signed : 0; + signed : 0; volatile int16_t f4; volatile uint32_t f5; int32_t f6; @@ -46,4 +46,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Bool1/main.c b/regression/cbmc/Bool1/main.c index 90db3177189..4949781de4e 100644 --- a/regression/cbmc/Bool1/main.c +++ b/regression/cbmc/Bool1/main.c @@ -2,18 +2,18 @@ int main() { _Bool b1, b2, b3; - + b1=0; b1++; assert(b1); - + b2=1; b2+=10; assert(b2); - + b3=b1+b2; assert(b3==1); - + // a struct of _Bool struct { @@ -22,13 +22,13 @@ int main() { } s; assert(sizeof(s)==4); - + s.f1=2; assert(s.f1==1); - + s.f4=1; assert(s.f4); - + *((unsigned char *)(&s.f2))=1; assert(s.f2); } diff --git a/regression/cbmc/Bool4/main.c b/regression/cbmc/Bool4/main.c index e7d572ecc9c..4055cbf8d29 100644 --- a/regression/cbmc/Bool4/main.c +++ b/regression/cbmc/Bool4/main.c @@ -6,7 +6,7 @@ int main() { b1=1; b1 ^= (_Bool)1; assert(!b1); - + b1=1; b2=1; b1 ^= b2; diff --git a/regression/cbmc/Boolean_Guards1/main.c b/regression/cbmc/Boolean_Guards1/main.c index 6050ff6ef44..14f125ab4ad 100644 --- a/regression/cbmc/Boolean_Guards1/main.c +++ b/regression/cbmc/Boolean_Guards1/main.c @@ -3,7 +3,7 @@ int main() { int i; int a[100]; - // this is guaranteed not to be a buffer overflow + // this is guaranteed not to be a buffer overflow if(x<100 && a[x]) { i++; diff --git a/regression/cbmc/Computed-Goto1/main.c b/regression/cbmc/Computed-Goto1/main.c index efc34053a10..c31ed412069 100644 --- a/regression/cbmc/Computed-Goto1/main.c +++ b/regression/cbmc/Computed-Goto1/main.c @@ -2,17 +2,17 @@ int main() { void *table[]={ &&l0, &&l1, &&l2 }; int in, out; - + if(in>=0 && in<=2) { goto *(table[in]); l0: out=0; goto result; - + l1: out=1; goto result; - + l2: out=2; goto result; - + result: assert(in==out); } diff --git a/regression/cbmc/Division1/main.c b/regression/cbmc/Division1/main.c index bc0e1159868..67488d6027d 100644 --- a/regression/cbmc/Division1/main.c +++ b/regression/cbmc/Division1/main.c @@ -4,7 +4,7 @@ int main() { int k1 = 5 / 2; assert(k1 == 2); - + int k2 = -5 / 2; assert(k2 == -2); diff --git a/regression/cbmc/Division2/main.c b/regression/cbmc/Division2/main.c index 1da2d810afb..12a4acb209d 100644 --- a/regression/cbmc/Division2/main.c +++ b/regression/cbmc/Division2/main.c @@ -3,7 +3,7 @@ _Bool nondet_bool(); void main() { int i=2, j; - + if(nondet_bool()) i++; diff --git a/regression/cbmc/Endianness1/main.c b/regression/cbmc/Endianness1/main.c index 403825cec59..3bcfbfd4037 100644 --- a/regression/cbmc/Endianness1/main.c +++ b/regression/cbmc/Endianness1/main.c @@ -3,7 +3,7 @@ int main() unsigned int u=1; unsigned char *p; unsigned char x, y; - + p=(unsigned char *)&u; x=*p; diff --git a/regression/cbmc/Endianness2/main.c b/regression/cbmc/Endianness2/main.c index 283067502a0..16545374193 100644 --- a/regression/cbmc/Endianness2/main.c +++ b/regression/cbmc/Endianness2/main.c @@ -3,7 +3,7 @@ int main() unsigned int u=1; unsigned char *p; unsigned char x, y; - + p=(unsigned char *)&u; x=*p; diff --git a/regression/cbmc/Endianness3/main.c b/regression/cbmc/Endianness3/main.c index 7b2e8682fb2..8ea2b5600eb 100644 --- a/regression/cbmc/Endianness3/main.c +++ b/regression/cbmc/Endianness3/main.c @@ -2,13 +2,13 @@ int main() { unsigned int x; unsigned char *p; - + x=0xffff; - + p=(unsigned char *)&x; - + *p=1; - // assumes little endian + // assumes little endian assert(x==0xff01); } diff --git a/regression/cbmc/Endianness4/main.c b/regression/cbmc/Endianness4/main.c index c38bc507b28..85a22d3ffe9 100644 --- a/regression/cbmc/Endianness4/main.c +++ b/regression/cbmc/Endianness4/main.c @@ -7,6 +7,5 @@ void main() *(cp+i) = 0; // should work with any endianness - assert(x==0); + assert(x==0); } - diff --git a/regression/cbmc/Endianness5/main.c b/regression/cbmc/Endianness5/main.c index 83b6368dc6f..925f4c06044 100644 --- a/regression/cbmc/Endianness5/main.c +++ b/regression/cbmc/Endianness5/main.c @@ -5,8 +5,8 @@ unsigned short shortTmp; int main() { ptrUShort = (unsigned short*)(®b[12]); - shortTmp= *ptrUShort; + shortTmp= *ptrUShort; // should pass - *ptrUShort = 1234; + *ptrUShort = 1234; } diff --git a/regression/cbmc/Endianness6/main.c b/regression/cbmc/Endianness6/main.c index 1ffe35d380a..1f1085cb3ff 100644 --- a/regression/cbmc/Endianness6/main.c +++ b/regression/cbmc/Endianness6/main.c @@ -4,21 +4,21 @@ int main() { int *i_p; char c_array[10]; - + i_p=(int *)c_array; *i_p=0x01020304; - + // big-endian assert(c_array[0]==1 && c_array[1]==2 && c_array[2]==3 && c_array[3]==4); - + char *c_p; int i=0x01020304; - + c_p=(char *)&i; - + // big-endian assert(c_p[0]==1 && c_p[1]==2 && diff --git a/regression/cbmc/Error_Label1/main.c b/regression/cbmc/Error_Label1/main.c index 5104837ed3e..78d8a1b45fa 100644 --- a/regression/cbmc/Error_Label1/main.c +++ b/regression/cbmc/Error_Label1/main.c @@ -2,7 +2,7 @@ int main() { int i; - // this should fail + // this should fail goto ERROR; return 0; diff --git a/regression/cbmc/Error_Label2/main.c b/regression/cbmc/Error_Label2/main.c index 5104837ed3e..78d8a1b45fa 100644 --- a/regression/cbmc/Error_Label2/main.c +++ b/regression/cbmc/Error_Label2/main.c @@ -2,7 +2,7 @@ int main() { int i; - // this should fail + // this should fail goto ERROR; return 0; diff --git a/regression/cbmc/Exceptions1/main.c b/regression/cbmc/Exceptions1/main.c index c0308a84ff7..87ee3d50d40 100644 --- a/regression/cbmc/Exceptions1/main.c +++ b/regression/cbmc/Exceptions1/main.c @@ -10,7 +10,7 @@ void test_try_finally1() { global=2; } - + assert(global==2); } @@ -26,7 +26,7 @@ void helper() { global=3; } - + assert(global==2); } @@ -46,7 +46,7 @@ void test_try_catch1() { global=2; } - + assert(global==1); } @@ -62,7 +62,7 @@ void test_try_catch2() { global=3; } - + assert(global==3); } @@ -73,4 +73,3 @@ int main() test_try_catch1(); test_try_catch2(); } - diff --git a/regression/cbmc/Fixedbv1/main.c b/regression/cbmc/Fixedbv1/main.c index 7c3e6cf6e43..2b94133e7a6 100644 --- a/regression/cbmc/Fixedbv1/main.c +++ b/regression/cbmc/Fixedbv1/main.c @@ -1,16 +1,16 @@ int main() { double x; int y; - - x=2; + + x=2; x-=0.6; y=x; // this yields 1.4, which is cut off - + assert(y==1); - x=2; + x=2; x-=0.4; y=x; // this yields 1.6, which is cut off, too! - + assert(y==1); } diff --git a/regression/cbmc/Fixedbv4/main.c b/regression/cbmc/Fixedbv4/main.c index 91f499140cf..c04fa2bfc21 100644 --- a/regression/cbmc/Fixedbv4/main.c +++ b/regression/cbmc/Fixedbv4/main.c @@ -1,14 +1,14 @@ int main() { double f; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -37,7 +37,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -47,7 +47,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc/Fixedbv5/main.c b/regression/cbmc/Fixedbv5/main.c index fa62a78e408..f35749769ef 100644 --- a/regression/cbmc/Fixedbv5/main.c +++ b/regression/cbmc/Fixedbv5/main.c @@ -1,7 +1,7 @@ int main() { float a, b; - + __CPROVER_assume(a==1 || a==0.5 || a==2 || a==3 || a==0.1); b=a; a/=2; diff --git a/regression/cbmc/Fixedbv6/main.c b/regression/cbmc/Fixedbv6/main.c index f45c35f0444..f72d72c6975 100644 --- a/regression/cbmc/Fixedbv6/main.c +++ b/regression/cbmc/Fixedbv6/main.c @@ -18,8 +18,8 @@ int main() assert(1.0<=2.0); assert(!(-1.0<=-2.0)); assert(2.0>=1.0); - assert(!(-2.0>=-1.0)); - + assert(!(-2.0>=-1.0)); + // variables float a, b, _a=a, _b=b; __CPROVER_assume(a==1 && b==2); @@ -41,5 +41,5 @@ int main() assert(a<=b); assert(!(-a<=-b)); assert(b>=a); - assert(!(-b>=-a)); + assert(!(-b>=-a)); } diff --git a/regression/cbmc/Fixedbv7/main.c b/regression/cbmc/Fixedbv7/main.c index 91f499140cf..c04fa2bfc21 100644 --- a/regression/cbmc/Fixedbv7/main.c +++ b/regression/cbmc/Fixedbv7/main.c @@ -1,14 +1,14 @@ int main() { double f; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -37,7 +37,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -47,7 +47,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc/Float-Rounding2/main.c b/regression/cbmc/Float-Rounding2/main.c index b751938aa7c..4e5ff6403e4 100644 --- a/regression/cbmc/Float-Rounding2/main.c +++ b/regression/cbmc/Float-Rounding2/main.c @@ -1,6 +1,6 @@ // Visual Studio needs to be 2013 onwards #if defined(_MSC_VER) && !defined(__CYGWIN__) && _MSC_VER < 1800 - + // see http://www.johndcook.com/math_h.html int main() @@ -8,7 +8,7 @@ int main() } #else - + #include #include @@ -18,7 +18,7 @@ int main() fesetround(FE_DOWNWARD); assert(fegetround()==FE_DOWNWARD); #endif - + #ifdef FE_TONEAREST fesetround(FE_TONEAREST); assert(fegetround()==FE_TONEAREST); diff --git a/regression/cbmc/Float-data-dependent-rounding/main.c b/regression/cbmc/Float-data-dependent-rounding/main.c index 495bb5fad84..44f8457a90e 100644 --- a/regression/cbmc/Float-data-dependent-rounding/main.c +++ b/regression/cbmc/Float-data-dependent-rounding/main.c @@ -10,7 +10,7 @@ int main (void) { #if defined(_MSC_VER) && _MSC_VER < 1800 #else - + #ifdef FE_UPWARD #ifdef FW_DOWNWARD float f; @@ -33,7 +33,7 @@ int main (void) { } #endif #endif - + #endif return 1; diff --git a/regression/cbmc/Float-div1/main.c b/regression/cbmc/Float-div1/main.c index 63f8512a7c2..49ee7110797 100644 --- a/regression/cbmc/Float-div1/main.c +++ b/regression/cbmc/Float-div1/main.c @@ -23,7 +23,7 @@ void simplifiedInductiveStepHunt (float nextState) // Implies nextState == 0x1p+124f; __CPROVER_assume((0x1.fffffep+123f < nextState) && (nextState < 0x1.000002p+124f)); - + float oneAfter = (target / nextState); // Is true and correctly proven by constant evaluation diff --git a/regression/cbmc/Float-flags-no-simp1/main.c b/regression/cbmc/Float-flags-no-simp1/main.c index d2f0833acc3..b41b115b6b9 100644 --- a/regression/cbmc/Float-flags-no-simp1/main.c +++ b/regression/cbmc/Float-flags-no-simp1/main.c @@ -9,7 +9,7 @@ int main() #ifndef _MSC_VER // first check constants - + assert(isnormal(FLT_MAX)); assert(isinf(HUGE_VAL)); assert(isinf(HUGE_VALF)); diff --git a/regression/cbmc/Float-flags-simp1/main.c b/regression/cbmc/Float-flags-simp1/main.c index d2f0833acc3..b41b115b6b9 100644 --- a/regression/cbmc/Float-flags-simp1/main.c +++ b/regression/cbmc/Float-flags-simp1/main.c @@ -9,7 +9,7 @@ int main() #ifndef _MSC_VER // first check constants - + assert(isnormal(FLT_MAX)); assert(isinf(HUGE_VAL)); assert(isinf(HUGE_VALF)); diff --git a/regression/cbmc/Float-no-simp1/main.c b/regression/cbmc/Float-no-simp1/main.c index de6091c82d2..e606d7b9d23 100644 --- a/regression/cbmc/Float-no-simp1/main.c +++ b/regression/cbmc/Float-no-simp1/main.c @@ -2,7 +2,7 @@ int main() { unsigned int i, j; double d; - + i=100.0; d=i; j=d; diff --git a/regression/cbmc/Float-no-simp2/main.c b/regression/cbmc/Float-no-simp2/main.c index 4fe132c1229..4914f3863ab 100644 --- a/regression/cbmc/Float-no-simp2/main.c +++ b/regression/cbmc/Float-no-simp2/main.c @@ -5,14 +5,14 @@ int main() __CPROVER_assume(!__CPROVER_isnand(f2)); __CPROVER_assume(__CPROVER_isfinited(f2)); f=f2; - + // addition assert(100.0+10==110); assert(0+f==f); // assert(f+0==f); assert(100+0.5==100.5); // assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); // assert(0-f==-f); @@ -41,7 +41,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -51,7 +51,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc/Float-no-simp5/main.c b/regression/cbmc/Float-no-simp5/main.c index ea2b8456667..7f4b1ed44a7 100644 --- a/regression/cbmc/Float-no-simp5/main.c +++ b/regression/cbmc/Float-no-simp5/main.c @@ -6,10 +6,9 @@ int main() double f; long long unsigned int i; // needs to have 64 bits } au, bu; - + au.f = a; bu.f = b; - + assert((au.i == bu.i) == __CPROVER_equal(a, b)); } - diff --git a/regression/cbmc/Float-no-simp8/main.c b/regression/cbmc/Float-no-simp8/main.c index a9234d20fbe..c75d7e231ac 100644 --- a/regression/cbmc/Float-no-simp8/main.c +++ b/regression/cbmc/Float-no-simp8/main.c @@ -9,7 +9,7 @@ int main (int argc, char **argv) { float result = f + g; assert(result == target); - + #ifndef _MSC_VER assert(signbit(result) == signbit(target)); #endif diff --git a/regression/cbmc/Float-no-simp9/main.c b/regression/cbmc/Float-no-simp9/main.c index 73253a909e8..9303a39d989 100644 --- a/regression/cbmc/Float-no-simp9/main.c +++ b/regression/cbmc/Float-no-simp9/main.c @@ -15,7 +15,7 @@ void testAdd (int mode, double f, double g, int sign) { assert(f_plus_g == 0.0); assert(g_plus_f == 0.0); - + assert(signbit(f_plus_g) == sign); assert(signbit(g_plus_f) == sign); #endif diff --git a/regression/cbmc/Float1/main.c b/regression/cbmc/Float1/main.c index 886c6c17684..b4d8dedca6d 100644 --- a/regression/cbmc/Float1/main.c +++ b/regression/cbmc/Float1/main.c @@ -1,17 +1,17 @@ int main() { double x; int y; - - x=2; + + x=2; x-=0.6; y=x; // this yields 1.4, which is cut off - + assert(y==1); - x=2; + x=2; x-=0.4; y=x; // this yields 1.6, which is cut off, too! // This is what the standard says! - + assert(y==1); } diff --git a/regression/cbmc/Float11/main.c b/regression/cbmc/Float11/main.c index 7514a3f37cb..f2e8b9e373d 100644 --- a/regression/cbmc/Float11/main.c +++ b/regression/cbmc/Float11/main.c @@ -31,7 +31,7 @@ int main() assert(0<1); assert(1>-0); assert(-0<1); - + assert(!(0.999f<0.0f)); assert(!(-0.999f>-0.0f)); assert(!(0.999f<=0.0f)); diff --git a/regression/cbmc/Float12/main.c b/regression/cbmc/Float12/main.c index a835646d1bf..3b88b9d576f 100644 --- a/regression/cbmc/Float12/main.c +++ b/regression/cbmc/Float12/main.c @@ -5,7 +5,7 @@ int main() unsigned char x; d=f; - + if(f==x) assert(d==x); } diff --git a/regression/cbmc/Float14/main.c b/regression/cbmc/Float14/main.c index b3de7013b6e..bafe611b05a 100644 --- a/regression/cbmc/Float14/main.c +++ b/regression/cbmc/Float14/main.c @@ -1,14 +1,14 @@ int main() { float temp; - + temp = 1.8e307f + 1.5e50f; // should produce overflow -> +infinity (according to standard) assert(__CPROVER_isinff(temp)); - + float x; - + x=temp-temp; - + // should be +inf assert(__CPROVER_isinff(temp)); } diff --git a/regression/cbmc/Float18/main.c b/regression/cbmc/Float18/main.c index 4f09b5429c2..4997219cd05 100644 --- a/regression/cbmc/Float18/main.c +++ b/regression/cbmc/Float18/main.c @@ -1,4 +1,4 @@ -#define _USE_MATH_DEFINES +#define _USE_MATH_DEFINES #include int main() @@ -16,5 +16,3 @@ int main() assert( n < 11 ); } - - diff --git a/regression/cbmc/Float2/main.c b/regression/cbmc/Float2/main.c index 1d41086f57a..9d9c877ea83 100644 --- a/regression/cbmc/Float2/main.c +++ b/regression/cbmc/Float2/main.c @@ -11,7 +11,7 @@ main() b=1.250; assert(b==1.25); - + // with exponent a=0.5e2; assert(a==50); diff --git a/regression/cbmc/Float20/main.c b/regression/cbmc/Float20/main.c index b730f0d4f18..5b1c69fe151 100644 --- a/regression/cbmc/Float20/main.c +++ b/regression/cbmc/Float20/main.c @@ -53,4 +53,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc/Float21/main.c b/regression/cbmc/Float21/main.c index 883e066cdfc..6eeda852be1 100644 --- a/regression/cbmc/Float21/main.c +++ b/regression/cbmc/Float21/main.c @@ -20,7 +20,7 @@ int main (void) float smallestNormalFloat = 0x1.0p-126f; float largestSubnormalFloat = 0x1.fffffcp-127f; - + double v = 0x1.FFFFFFp-127; float f; @@ -59,7 +59,7 @@ int main (void) f = nondet_float(); __CPROVER_assume(fpclassify(f) == FP_SUBNORMAL); assert( ((float)((double)f)) == f ); - + #endif return 0; diff --git a/regression/cbmc/Float4/main.c b/regression/cbmc/Float4/main.c index 08ff0cf255d..4b3fd112caa 100644 --- a/regression/cbmc/Float4/main.c +++ b/regression/cbmc/Float4/main.c @@ -5,14 +5,14 @@ int main() __CPROVER_assume(!__CPROVER_isnand(f2)); __CPROVER_assume(!__CPROVER_isinfd(f2)); f=f2; - + // addition assert(100.0+10==110); assert(0+f==f); assert(f+0==f); assert(100+0.5==100.5); assert(0.0+0.0+f==f); - + // subtraction assert(100.0-10==90); assert(0-f==-f); @@ -41,7 +41,7 @@ int main() assert(100.0/0.5==200); assert(0/1.0==0); assert(f/1.0==f); - + // conversion assert(((double)(float)100)==100.0); assert(((unsigned int)100.0)==100.0); @@ -51,7 +51,7 @@ int main() assert((int)0.49==0); assert((int)-1.5==-1); assert((int)-10.49==-10); - + // relations assert(1.0<2.5); assert(1.0<=2.5); diff --git a/regression/cbmc/Float5/main.c b/regression/cbmc/Float5/main.c index fa62a78e408..f35749769ef 100644 --- a/regression/cbmc/Float5/main.c +++ b/regression/cbmc/Float5/main.c @@ -1,7 +1,7 @@ int main() { float a, b; - + __CPROVER_assume(a==1 || a==0.5 || a==2 || a==3 || a==0.1); b=a; a/=2; diff --git a/regression/cbmc/Float6/main.c b/regression/cbmc/Float6/main.c index f45c35f0444..f72d72c6975 100644 --- a/regression/cbmc/Float6/main.c +++ b/regression/cbmc/Float6/main.c @@ -18,8 +18,8 @@ int main() assert(1.0<=2.0); assert(!(-1.0<=-2.0)); assert(2.0>=1.0); - assert(!(-2.0>=-1.0)); - + assert(!(-2.0>=-1.0)); + // variables float a, b, _a=a, _b=b; __CPROVER_assume(a==1 && b==2); @@ -41,5 +41,5 @@ int main() assert(a<=b); assert(!(-a<=-b)); assert(b>=a); - assert(!(-b>=-a)); + assert(!(-b>=-a)); } diff --git a/regression/cbmc/Float7/main.c b/regression/cbmc/Float7/main.c index 33f2923c7a7..fccaa083374 100644 --- a/regression/cbmc/Float7/main.c +++ b/regression/cbmc/Float7/main.c @@ -2,11 +2,11 @@ int main() { unsigned int i; i=0; - + float *p; p=(float *)&i; - + float f=*p; - + assert(f==0.0); } diff --git a/regression/cbmc/Float_lib1/main.c b/regression/cbmc/Float_lib1/main.c index 35dd4ba6302..c344517d28d 100644 --- a/regression/cbmc/Float_lib1/main.c +++ b/regression/cbmc/Float_lib1/main.c @@ -7,7 +7,7 @@ int main() { // Visual Studio needs to be 2013 onwards #if defined(_MSC_VER) && !defined(__CYGWIN__) && _MSC_VER < 1800 - + // see http://www.johndcook.com/math_h.html #else diff --git a/regression/cbmc/Free1/main.c b/regression/cbmc/Free1/main.c index ef23ab68a1a..0d6eb009f64 100644 --- a/regression/cbmc/Free1/main.c +++ b/regression/cbmc/Free1/main.c @@ -7,7 +7,7 @@ int main() int *q=p; int i, x; i=x; - + if(i==4711) free(q); // should fail if i==4711 diff --git a/regression/cbmc/Free2/main.c b/regression/cbmc/Free2/main.c index 82ccf142962..f8d838d773a 100644 --- a/regression/cbmc/Free2/main.c +++ b/regression/cbmc/Free2/main.c @@ -7,7 +7,7 @@ int main() int x; int i, y; i=y; - + if(i==4711) p=&x; // should fail if i==4711 diff --git a/regression/cbmc/Free3/main.c b/regression/cbmc/Free3/main.c index 2328c7e5314..c85322e7813 100644 --- a/regression/cbmc/Free3/main.c +++ b/regression/cbmc/Free3/main.c @@ -10,6 +10,6 @@ int main() free(p); - // well, a double-free + // well, a double-free free(p); } diff --git a/regression/cbmc/Free4/main.c b/regression/cbmc/Free4/main.c index 3696af892b6..610c694580b 100644 --- a/regression/cbmc/Free4/main.c +++ b/regression/cbmc/Free4/main.c @@ -8,11 +8,11 @@ void my_free(int *q) int main() { int *p=malloc(sizeof(int)); - + *p=2; - + my_free(p); - // should fail + // should fail *p=3; } diff --git a/regression/cbmc/Function-KnR1/main.c b/regression/cbmc/Function-KnR1/main.c index 01cf0604fd7..2281ad04731 100644 --- a/regression/cbmc/Function-KnR1/main.c +++ b/regression/cbmc/Function-KnR1/main.c @@ -31,7 +31,6 @@ const char *msg; main() { struct X x; - + assert(f(0, 0, x, 0)==10); } - diff --git a/regression/cbmc/Function10/main.c b/regression/cbmc/Function10/main.c index a2c68510c6c..e80f816272b 100644 --- a/regression/cbmc/Function10/main.c +++ b/regression/cbmc/Function10/main.c @@ -26,7 +26,7 @@ int main() { int *p; my_f1(p); - + other_func1(1, whatnot); assert(global==2); } diff --git a/regression/cbmc/Function13/main.c b/regression/cbmc/Function13/main.c index aeaf224a5eb..8a90d748bb1 100644 --- a/regression/cbmc/Function13/main.c +++ b/regression/cbmc/Function13/main.c @@ -5,7 +5,7 @@ void f1() // goes into global name space! extern int i; assert(i==1); - + // and might have an incomplete type extern struct unknown_tag some_struct; extern char some_array[]; diff --git a/regression/cbmc/Function4/main.c b/regression/cbmc/Function4/main.c index 3873c30a2ee..dfdd644b79b 100644 --- a/regression/cbmc/Function4/main.c +++ b/regression/cbmc/Function4/main.c @@ -19,6 +19,6 @@ int main() st.x = f1(); x = nondet_int(); st.x = x; - + return 0; } diff --git a/regression/cbmc/Function6/main.c b/regression/cbmc/Function6/main.c index 865fda826a8..0d1fc7933aa 100644 --- a/regression/cbmc/Function6/main.c +++ b/regression/cbmc/Function6/main.c @@ -3,7 +3,7 @@ int global; void f() { void g(); - + g(); } diff --git a/regression/cbmc/Function8/main.c b/regression/cbmc/Function8/main.c index defb9b63c32..69c292e3f9c 100644 --- a/regression/cbmc/Function8/main.c +++ b/regression/cbmc/Function8/main.c @@ -21,7 +21,7 @@ int main() { foo(); - bar(); + bar(); return 0; } diff --git a/regression/cbmc/Function9/main.c b/regression/cbmc/Function9/main.c index f5000b3c0d1..03ad71720cd 100644 --- a/regression/cbmc/Function9/main.c +++ b/regression/cbmc/Function9/main.c @@ -27,7 +27,7 @@ int main() foo(); g=1; - bar(); + bar(); return 0; } diff --git a/regression/cbmc/Function_Eval_Order1/main.c b/regression/cbmc/Function_Eval_Order1/main.c index 814ff8d6a1c..0b0e230c995 100644 --- a/regression/cbmc/Function_Eval_Order1/main.c +++ b/regression/cbmc/Function_Eval_Order1/main.c @@ -25,4 +25,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc/Function_Eval_Order2/main.c b/regression/cbmc/Function_Eval_Order2/main.c index df3de56eb90..04926a3ab15 100644 --- a/regression/cbmc/Function_Eval_Order2/main.c +++ b/regression/cbmc/Function_Eval_Order2/main.c @@ -25,4 +25,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc/Function_Pointer10/main.c b/regression/cbmc/Function_Pointer10/main.c index 42d20ff6639..e974ca00403 100644 --- a/regression/cbmc/Function_Pointer10/main.c +++ b/regression/cbmc/Function_Pointer10/main.c @@ -20,12 +20,12 @@ void test2() { char a=5; int (*fun) (int, int); - + if(a) fun = func; else fun = func2; - + int b=(*fun) (a, a); } diff --git a/regression/cbmc/Function_Pointer11/main.c b/regression/cbmc/Function_Pointer11/main.c index a3c896d1015..0e6be48b479 100644 --- a/regression/cbmc/Function_Pointer11/main.c +++ b/regression/cbmc/Function_Pointer11/main.c @@ -17,4 +17,4 @@ int main(int argc, char **argv) // should be fine, and pass without warning f(x); -} +} diff --git a/regression/cbmc/Function_Pointer13/main.c b/regression/cbmc/Function_Pointer13/main.c index 52a68f23f4c..a3bac9430b3 100644 --- a/regression/cbmc/Function_Pointer13/main.c +++ b/regression/cbmc/Function_Pointer13/main.c @@ -33,4 +33,3 @@ value=fptr(value); //value should be 16 after this assert(value == 16); } - diff --git a/regression/cbmc/Function_Pointer14/main.c b/regression/cbmc/Function_Pointer14/main.c index 9c244af439d..ee74abfad03 100644 --- a/regression/cbmc/Function_Pointer14/main.c +++ b/regression/cbmc/Function_Pointer14/main.c @@ -7,7 +7,7 @@ void dll_create_generic(void (*insert_fnc)()) insert_fnc(&my_global); } -void dll_insert_master(int *a) +void dll_insert_master(int *a) { *a=123; } @@ -16,6 +16,6 @@ int main() { dll_create_generic(dll_insert_master); assert(my_global==123); - + return 0; } diff --git a/regression/cbmc/Function_Pointer15/main.c b/regression/cbmc/Function_Pointer15/main.c index 28cf42db770..5006540d4f5 100644 --- a/regression/cbmc/Function_Pointer15/main.c +++ b/regression/cbmc/Function_Pointer15/main.c @@ -6,7 +6,7 @@ void dll_create_generic(void (*insert_fnc)()) insert_fnc(&x); } -void dll_insert_master(int *a) +void dll_insert_master(int *a) { assert(0); } @@ -16,4 +16,3 @@ int main() dll_create_generic(dll_insert_master); return 0; } - diff --git a/regression/cbmc/Function_Pointer2/main.c b/regression/cbmc/Function_Pointer2/main.c index 8062f3c7724..ee419e426d9 100644 --- a/regression/cbmc/Function_Pointer2/main.c +++ b/regression/cbmc/Function_Pointer2/main.c @@ -14,10 +14,10 @@ int main() { void (*p)(int); __CPROVER_bool c; - + p=c?f:g; - + p(1); - + assert(global==c); } diff --git a/regression/cbmc/Function_Pointer4/main.c b/regression/cbmc/Function_Pointer4/main.c index 4422b736e58..8a58e610618 100644 --- a/regression/cbmc/Function_Pointer4/main.c +++ b/regression/cbmc/Function_Pointer4/main.c @@ -11,9 +11,9 @@ int main(void) { struct device devices[1]; int x; - + devices[0].func = one; - + x=(* devices[0].func)(); assert(x == 1); } diff --git a/regression/cbmc/Function_Pointer6/main.c b/regression/cbmc/Function_Pointer6/main.c index c4f09bdc874..afb9a644d97 100644 --- a/regression/cbmc/Function_Pointer6/main.c +++ b/regression/cbmc/Function_Pointer6/main.c @@ -23,9 +23,9 @@ int main(void) ps->func = x?ten:twenty; ppp=ps->func; - + y=ps->func(); - + assert(y==10 || y==20); return 0; diff --git a/regression/cbmc/Function_Pointer7/main.c b/regression/cbmc/Function_Pointer7/main.c index 82817cc64b8..44caa240988 100644 --- a/regression/cbmc/Function_Pointer7/main.c +++ b/regression/cbmc/Function_Pointer7/main.c @@ -18,13 +18,13 @@ int my_open(int a) struct file_ops fops = { .open = my_open }; int main(void) -{ +{ struct dev tmp[4]; devs = &tmp; - + (devs+0)->ops = &fops; // does not work - + assert(10 == (* devs[0].ops->open)(10)); return 0; diff --git a/regression/cbmc/Function_Pointer8/main.c b/regression/cbmc/Function_Pointer8/main.c index 59603b43549..ff7dee40e91 100644 --- a/regression/cbmc/Function_Pointer8/main.c +++ b/regression/cbmc/Function_Pointer8/main.c @@ -26,7 +26,7 @@ void func1(int a) void run_irq_handler() { - (* ihandler.handler)(10); + (* ihandler.handler)(10); } void run_timer() @@ -37,7 +37,7 @@ void run_timer() int main() { ihandler.handler = func1; - + run_irq_handler(); run_timer(); } diff --git a/regression/cbmc/Global_Initialization1/main.c b/regression/cbmc/Global_Initialization1/main.c index f4ee15e1150..0ce23881c94 100644 --- a/regression/cbmc/Global_Initialization1/main.c +++ b/regression/cbmc/Global_Initialization1/main.c @@ -22,6 +22,6 @@ int main() assert(x == 123); assert(y == 0); assert(b[0]=='a'); - assert(some_func()==0); + assert(some_func()==0); assert(p==&y); } diff --git a/regression/cbmc/Global_Initialization2/main.c b/regression/cbmc/Global_Initialization2/main.c index 0a058acc2fc..0353ee2e015 100644 --- a/regression/cbmc/Global_Initialization2/main.c +++ b/regression/cbmc/Global_Initialization2/main.c @@ -22,4 +22,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Initialization1/main.c b/regression/cbmc/Initialization1/main.c index 9e1f0d3c91b..7da12521ad5 100644 --- a/regression/cbmc/Initialization1/main.c +++ b/regression/cbmc/Initialization1/main.c @@ -2,10 +2,9 @@ int main() { char a; char b = a = 'a'; - + assert(a=='a'); assert(b=='a'); int i=(long int)&i; } - diff --git a/regression/cbmc/Initialization3/main.c b/regression/cbmc/Initialization3/main.c index 8ed9ef44325..7df573913aa 100644 --- a/regression/cbmc/Initialization3/main.c +++ b/regression/cbmc/Initialization3/main.c @@ -28,4 +28,3 @@ int main() Split(&t); return 0; } - diff --git a/regression/cbmc/Initialization7/main.c b/regression/cbmc/Initialization7/main.c index 059d2109ffe..32c9ab62337 100644 --- a/regression/cbmc/Initialization7/main.c +++ b/regression/cbmc/Initialization7/main.c @@ -20,4 +20,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Linking1/main.c b/regression/cbmc/Linking1/main.c index 127290cffaa..248db3436c8 100644 --- a/regression/cbmc/Linking1/main.c +++ b/regression/cbmc/Linking1/main.c @@ -15,9 +15,9 @@ int main() { assert(i==1); assert(a_struct.asd==0); - + f(); - + assert(i==2); assert(a_struct.asd==123); } diff --git a/regression/cbmc/Linking1/test.desc b/regression/cbmc/Linking1/test.desc index de6f32ebf66..af20f90c655 100644 --- a/regression/cbmc/Linking1/test.desc +++ b/regression/cbmc/Linking1/test.desc @@ -1,6 +1,6 @@ CORE main.c -module.c +module.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc/Linking2/main.c b/regression/cbmc/Linking2/main.c index a5649307456..4a9d9634b81 100644 --- a/regression/cbmc/Linking2/main.c +++ b/regression/cbmc/Linking2/main.c @@ -21,13 +21,13 @@ int main() { assert(i==2); assert(j==3); - + f(); // does not change i, // but does change j - + assert(i==2); assert(j==4); - + struct my_struct xx; assert(sizeof(xx.t_field)==1); } diff --git a/regression/cbmc/Linking2/module.c b/regression/cbmc/Linking2/module.c index a23c19df0bc..f144ea8d4bd 100644 --- a/regression/cbmc/Linking2/module.c +++ b/regression/cbmc/Linking2/module.c @@ -9,7 +9,7 @@ typedef int t; struct my_struct { t t_field; -}; +}; // this one is local, tool! static t i=1; @@ -23,7 +23,7 @@ void f() assert(j==3); i=3; j=4; - + struct my_struct xx; assert(sizeof(xx.t_field)==sizeof(int)); } diff --git a/regression/cbmc/Linking2/test.desc b/regression/cbmc/Linking2/test.desc index de6f32ebf66..af20f90c655 100644 --- a/regression/cbmc/Linking2/test.desc +++ b/regression/cbmc/Linking2/test.desc @@ -1,6 +1,6 @@ CORE main.c -module.c +module.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc/Linking5/link2.c b/regression/cbmc/Linking5/link2.c index c06a326ee75..30114125c0f 100644 --- a/regression/cbmc/Linking5/link2.c +++ b/regression/cbmc/Linking5/link2.c @@ -3,4 +3,3 @@ int tbl2[2]; void main() { } - diff --git a/regression/cbmc/Local_out_of_scope1/main.c b/regression/cbmc/Local_out_of_scope1/main.c index 596f6c3238a..04554ab6c6d 100644 --- a/regression/cbmc/Local_out_of_scope1/main.c +++ b/regression/cbmc/Local_out_of_scope1/main.c @@ -2,16 +2,16 @@ int main() { int *p, *q; int x, y, z; - + p=&x; q=p; - + if(z) { int l; q=&l; } - // this should fail, as *p is dead if z is true + // this should fail, as *p is dead if z is true y=*q; } diff --git a/regression/cbmc/Malloc13/main.c b/regression/cbmc/Malloc13/main.c index 633629f0862..0c39afb2cca 100644 --- a/regression/cbmc/Malloc13/main.c +++ b/regression/cbmc/Malloc13/main.c @@ -8,4 +8,3 @@ int main(int argc, char* argv[]) { __CPROVER_assert(__CPROVER_buffer_size(str) == len, "buffer size ok"); return 0; } - diff --git a/regression/cbmc/Malloc15/main.c b/regression/cbmc/Malloc15/main.c index 4654735e247..0a09bfac95b 100644 --- a/regression/cbmc/Malloc15/main.c +++ b/regression/cbmc/Malloc15/main.c @@ -7,7 +7,7 @@ int main() p = malloc(sizeof(int)); unsigned int r = p; if (r != 0) - *p = 1; + *p = 1; if (p != 0) __CPROVER_assert (*p == 1, "malloc"); diff --git a/regression/cbmc/Malloc16/main.c b/regression/cbmc/Malloc16/main.c index e64276e5e87..675b577f6ec 100644 --- a/regression/cbmc/Malloc16/main.c +++ b/regression/cbmc/Malloc16/main.c @@ -12,7 +12,7 @@ int main() tmp = malloc(sizeof(int)); dev = (int*)tmp; - + void *r = (void*)0; unsigned int q = r; unsigned int p = dev; diff --git a/regression/cbmc/Malloc17/main.c b/regression/cbmc/Malloc17/main.c index 6cac57c95de..bf13b054b2e 100644 --- a/regression/cbmc/Malloc17/main.c +++ b/regression/cbmc/Malloc17/main.c @@ -68,4 +68,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Malloc18/main.c b/regression/cbmc/Malloc18/main.c index 7111f8e5f52..047ada2b009 100644 --- a/regression/cbmc/Malloc18/main.c +++ b/regression/cbmc/Malloc18/main.c @@ -23,4 +23,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Malloc19/main.c b/regression/cbmc/Malloc19/main.c index df4ba61a870..6d5d041c541 100644 --- a/regression/cbmc/Malloc19/main.c +++ b/regression/cbmc/Malloc19/main.c @@ -42,4 +42,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Malloc20/main.c b/regression/cbmc/Malloc20/main.c index ac76cc22367..728819c6a50 100644 --- a/regression/cbmc/Malloc20/main.c +++ b/regression/cbmc/Malloc20/main.c @@ -22,7 +22,7 @@ nettle_buffer_init(struct nettle_buffer *buffer) int nettle_buffer_grow(struct nettle_buffer *buffer, size_t length) { if (buffer->condition) return 0; // Uncommenting this line fixes the bug. - + size_t alloc = buffer->alloc * 2 + length + 100; // Replcing alloc size by a constant fixes the bug. //size_t alloc = 103; uint8_t *p = (uint8_t *) malloc(alloc); @@ -49,5 +49,3 @@ int main(void) __CPROVER_assert(buffer.contents[1] == 'o', "buffer.contents[1] == 'o'"); __CPROVER_assert(buffer.contents[2] == 'o', "buffer.contents[2] == 'o'"); } - - diff --git a/regression/cbmc/Malloc21/main.c b/regression/cbmc/Malloc21/main.c index 0c0bb561e5e..5db374c940d 100644 --- a/regression/cbmc/Malloc21/main.c +++ b/regression/cbmc/Malloc21/main.c @@ -21,14 +21,12 @@ int main(void) if (!(v1 <= 0)) { len = __VERIFIER_nondet_int(); __CPROVER_assume(len > 0); - data = malloc(len * sizeof(int)); + data = malloc(len * sizeof(int)); } data[0] = 0; - int tmp = data[0]; + int tmp = data[0]; assert(tmp == 0); return 0; } - - diff --git a/regression/cbmc/Malloc22/main.c b/regression/cbmc/Malloc22/main.c index ff2eb949b69..10420360ed1 100644 --- a/regression/cbmc/Malloc22/main.c +++ b/regression/cbmc/Malloc22/main.c @@ -19,4 +19,3 @@ int main() { return 0; } - diff --git a/regression/cbmc/Memmove1/main.c b/regression/cbmc/Memmove1/main.c index ff0cdae7c3a..ecd39ff0d4c 100644 --- a/regression/cbmc/Memmove1/main.c +++ b/regression/cbmc/Memmove1/main.c @@ -43,4 +43,3 @@ int main(int argc, char * argv[]) { assert(a[0]==-2147483600); return 0; } - diff --git a/regression/cbmc/Mod1/main.c b/regression/cbmc/Mod1/main.c index 6fde263722d..31b3000a530 100644 --- a/regression/cbmc/Mod1/main.c +++ b/regression/cbmc/Mod1/main.c @@ -1,8 +1,8 @@ int main() { int x, y; - - x=y; + + x=y; x%=10; assert(x!=-1); // should fail } diff --git a/regression/cbmc/Mod2/main.c b/regression/cbmc/Mod2/main.c index 53b1ef269b8..13c715cb409 100644 --- a/regression/cbmc/Mod2/main.c +++ b/regression/cbmc/Mod2/main.c @@ -1,6 +1,6 @@ #include -static int +static int (safe_mod_func_int32_t_s_s)(int si1, int si2 ) { return @@ -21,7 +21,7 @@ int main() a=1; b=-2; #endif - int x=safe_mod_func_int32_t_s_s(a, b); + int x=safe_mod_func_int32_t_s_s(a, b); assert(x==1); return 0; } diff --git a/regression/cbmc/Multi_Dimensional_Array1/main.c b/regression/cbmc/Multi_Dimensional_Array1/main.c index eac543d4d8a..f814686bb94 100644 --- a/regression/cbmc/Multi_Dimensional_Array1/main.c +++ b/regression/cbmc/Multi_Dimensional_Array1/main.c @@ -9,11 +9,11 @@ int main() p=a[9]; assert(p==a[0]+9*4); - + *p=10; assert(a[9][0]==10); - p++; + p++; *p=20; assert(a[9][1]==20); diff --git a/regression/cbmc/Multi_Dimensional_Array3/main.c b/regression/cbmc/Multi_Dimensional_Array3/main.c index 607582a629f..3daa9f6d331 100644 --- a/regression/cbmc/Multi_Dimensional_Array3/main.c +++ b/regression/cbmc/Multi_Dimensional_Array3/main.c @@ -8,7 +8,7 @@ int main() { // this checks whether the alias analysis can // track pointers in multi-dimensional arrays - + iptr array[3][3]={{&x,0,0},{&y,0,0},{&z,0,0}}; unsigned int a, b; @@ -17,12 +17,12 @@ int main() __CPROVER_assume (a < 3 && b < 3); array[a][b] = &z; - + iptr p; p=array[a][b]; *p=1; - + assert(z==1); } /* end of case 2 */ diff --git a/regression/cbmc/Multi_Dimensional_Array4/main.c b/regression/cbmc/Multi_Dimensional_Array4/main.c index b07bdf3281d..e7ef2680438 100644 --- a/regression/cbmc/Multi_Dimensional_Array4/main.c +++ b/regression/cbmc/Multi_Dimensional_Array4/main.c @@ -1,26 +1,26 @@ void f(void * s1, void *s2) -{ - char *us1 = (char*) s1; - char *us2 = (char*) s2; - +{ + char *us1 = (char*) s1; + char *us2 = (char*) s2; + char us10=us1[0]; char us20=us2[0]; char us11=us1[1]; char us21=us2[1]; - assert(us10=='a'); - assert(us11=='b'); + assert(us10=='a'); + assert(us11=='b'); assert(us20=='g'); assert(us21=='b'); -} +} int main() -{ - char a[2][2]; - a[0][0] = 'a'; - a[0][1] = 'b'; - a[1][0] = 'g'; - a[1][1] = 'b'; - +{ + char a[2][2]; + a[0][0] = 'a'; + a[0][1] = 'b'; + a[1][0] = 'g'; + a[1][1] = 'b'; + f(&a[0], &a[1]); -} +} diff --git a/regression/cbmc/Multi_Dimensional_Array5/main.c b/regression/cbmc/Multi_Dimensional_Array5/main.c index 1d18c81a803..a54a3657ce2 100644 --- a/regression/cbmc/Multi_Dimensional_Array5/main.c +++ b/regression/cbmc/Multi_Dimensional_Array5/main.c @@ -17,4 +17,3 @@ int main () func_79(*(&(g_374[0][0]))); return 0; } - diff --git a/regression/cbmc/Multiple_Properties1/main.c b/regression/cbmc/Multiple_Properties1/main.c index 633ee3adb15..5d5a109776b 100644 --- a/regression/cbmc/Multiple_Properties1/main.c +++ b/regression/cbmc/Multiple_Properties1/main.c @@ -2,13 +2,13 @@ int main () { int x, y; __CPROVER_assume(x>=100 && y<=1000 & x>y+2); x--; - assert(x>y); + assert(x>y); x--; - assert(x>y); + assert(x>y); x--; - assert(x>y); + assert(x>y); y=0; - assert(x>y); + assert(x>y); return 0; } diff --git a/regression/cbmc/Negation1/main.c b/regression/cbmc/Negation1/main.c index facd2bcf91a..9e02cef5d9e 100644 --- a/regression/cbmc/Negation1/main.c +++ b/regression/cbmc/Negation1/main.c @@ -5,11 +5,11 @@ int main() test=0; test=~test; assert(test==-1); - + test=0; test=!test; assert(test==1); - + test=100; test=!test; assert(test==0); diff --git a/regression/cbmc/Negation2/main.c b/regression/cbmc/Negation2/main.c index 16971d58e32..33435a12435 100644 --- a/regression/cbmc/Negation2/main.c +++ b/regression/cbmc/Negation2/main.c @@ -12,4 +12,3 @@ int main() { f00(0); } - diff --git a/regression/cbmc/Overflow_Addition1/main.c b/regression/cbmc/Overflow_Addition1/main.c index 3d1288d0db3..706ee880796 100644 --- a/regression/cbmc/Overflow_Addition1/main.c +++ b/regression/cbmc/Overflow_Addition1/main.c @@ -1,7 +1,7 @@ int main() { signed int i, j; - + i=j; - + i++; } diff --git a/regression/cbmc/Overflow_Multiplication1/falsealarm.c b/regression/cbmc/Overflow_Multiplication1/falsealarm.c index 2ed10b653cb..c2f8173d8e1 100644 --- a/regression/cbmc/Overflow_Multiplication1/falsealarm.c +++ b/regression/cbmc/Overflow_Multiplication1/falsealarm.c @@ -6,7 +6,7 @@ void main() x=_x; y=_y; - + if((-4681 < y) && (y < 4681) && (x < 32767) && (-32767 < x) && ((7*y*y -1) == x*x)) { y=1/x; } diff --git a/regression/cbmc/Overflow_Subtraction1/main.c b/regression/cbmc/Overflow_Subtraction1/main.c index 010f26c229f..5765eccf3f9 100644 --- a/regression/cbmc/Overflow_Subtraction1/main.c +++ b/regression/cbmc/Overflow_Subtraction1/main.c @@ -3,14 +3,14 @@ int main() { int a, b, neg; - + // this should not overflow, even not for a=INT_MIN b=a-a; - + // this should also not overflow as long as pos<0 if(neg<0) b=neg-INT_MIN; - + int x, y, z; x = INT_MIN+1; diff --git a/regression/cbmc/Pointer_Arithmetic1/main.c b/regression/cbmc/Pointer_Arithmetic1/main.c index c31c0e7cc06..a882ca30700 100644 --- a/regression/cbmc/Pointer_Arithmetic1/main.c +++ b/regression/cbmc/Pointer_Arithmetic1/main.c @@ -7,6 +7,6 @@ int main() p+=30; diff=(char *)p-(char *)array; - + assert(diff==30*sizeof(int)); } diff --git a/regression/cbmc/Pointer_Arithmetic11/main.c b/regression/cbmc/Pointer_Arithmetic11/main.c index 96849c12ab1..c1b2df18592 100644 --- a/regression/cbmc/Pointer_Arithmetic11/main.c +++ b/regression/cbmc/Pointer_Arithmetic11/main.c @@ -4,9 +4,9 @@ int main() int data=0; char *p=(char *)&data; i=ii; - + __CPROVER_assume(i>=0 && i<4); - + p[i]++; if(i==0) diff --git a/regression/cbmc/Pointer_Arithmetic12/main.c b/regression/cbmc/Pointer_Arithmetic12/main.c index 3363b3c5440..6177b6f4f6f 100644 --- a/regression/cbmc/Pointer_Arithmetic12/main.c +++ b/regression/cbmc/Pointer_Arithmetic12/main.c @@ -132,4 +132,3 @@ int main() L_0x416_2: esp+=0x4; L_0x417_0: return 0; } - diff --git a/regression/cbmc/Pointer_Arithmetic13/main.c b/regression/cbmc/Pointer_Arithmetic13/main.c index 4643b378877..a7063318bfc 100644 --- a/regression/cbmc/Pointer_Arithmetic13/main.c +++ b/regression/cbmc/Pointer_Arithmetic13/main.c @@ -19,4 +19,3 @@ int main() { return 0; } - diff --git a/regression/cbmc/Pointer_Arithmetic2/main.c b/regression/cbmc/Pointer_Arithmetic2/main.c index 5fbe8956e3e..b7b9c687eef 100644 --- a/regression/cbmc/Pointer_Arithmetic2/main.c +++ b/regression/cbmc/Pointer_Arithmetic2/main.c @@ -9,8 +9,8 @@ int main() q=(char *)p; q+=30*sizeof(int); p=(int *)q; - + *p=1; - + assert(my_array[30]==1); } diff --git a/regression/cbmc/Pointer_Arithmetic3/main.c b/regression/cbmc/Pointer_Arithmetic3/main.c index 86554c90f47..3d5ce10e214 100644 --- a/regression/cbmc/Pointer_Arithmetic3/main.c +++ b/regression/cbmc/Pointer_Arithmetic3/main.c @@ -1,10 +1,10 @@ -int nums[2]; -int *p; +int nums[2]; +int *p; -int main() { - nums[1] = 1; - p = &nums[0]; - p++; +int main() { + nums[1] = 1; + p = &nums[0]; + p++; - assert(*p == 1); -} + assert(*p == 1); +} diff --git a/regression/cbmc/Pointer_Arithmetic5/main.c b/regression/cbmc/Pointer_Arithmetic5/main.c index 2bf0f10c353..a0fcc55be56 100644 --- a/regression/cbmc/Pointer_Arithmetic5/main.c +++ b/regression/cbmc/Pointer_Arithmetic5/main.c @@ -7,6 +7,6 @@ void f() x=1; px++; - // now out of bounds + // now out of bounds y=*px; } diff --git a/regression/cbmc/Pointer_Arithmetic6/main.c b/regression/cbmc/Pointer_Arithmetic6/main.c index 263202f72e3..3ef83b5aed6 100644 --- a/regression/cbmc/Pointer_Arithmetic6/main.c +++ b/regression/cbmc/Pointer_Arithmetic6/main.c @@ -2,10 +2,10 @@ int main() { int a[10]; int x; - + a[1]=1000; - + x=*(a+1); - + assert(x==1000); } diff --git a/regression/cbmc/Pointer_Arithmetic7/main.c b/regression/cbmc/Pointer_Arithmetic7/main.c index 82e918f9d54..cc1da6e6ee0 100644 --- a/regression/cbmc/Pointer_Arithmetic7/main.c +++ b/regression/cbmc/Pointer_Arithmetic7/main.c @@ -3,7 +3,7 @@ void f(char *p) p[1]=1; } -int main () +int main () { char dummy[10]; f(dummy); diff --git a/regression/cbmc/Pointer_array1/main.c b/regression/cbmc/Pointer_array1/main.c index 07a389cac31..b676f18294a 100644 --- a/regression/cbmc/Pointer_array1/main.c +++ b/regression/cbmc/Pointer_array1/main.c @@ -10,4 +10,3 @@ void main() { __cil_tmp24 = &(disk->disk_name); assert(__cil_tmp24!=0); } - diff --git a/regression/cbmc/Pointer_array2/main.c b/regression/cbmc/Pointer_array2/main.c index 854fbd946a9..8de99a513e2 100644 --- a/regression/cbmc/Pointer_array2/main.c +++ b/regression/cbmc/Pointer_array2/main.c @@ -13,4 +13,3 @@ int main() { assert(__cil_tmp24!=0); return 0; } - diff --git a/regression/cbmc/Pointer_array5/main.c b/regression/cbmc/Pointer_array5/main.c index b0fb00e5c61..b8893782411 100644 --- a/regression/cbmc/Pointer_array5/main.c +++ b/regression/cbmc/Pointer_array5/main.c @@ -18,7 +18,7 @@ int main() { array_init[2] = &a2; void **local_array=(void**)array_init; - + int *address=(int *)local_array[0]; assert(address==&a0); } diff --git a/regression/cbmc/Pointer_array6/main.c b/regression/cbmc/Pointer_array6/main.c index 0ce086787f9..6cad47cd7b2 100644 --- a/regression/cbmc/Pointer_array6/main.c +++ b/regression/cbmc/Pointer_array6/main.c @@ -14,14 +14,14 @@ int main() { // mis-align that pointer! char * char_ptr = (char *) array_init; char_ptr++; - + int local_var; int **array2=(int**)char_ptr; - + // write array2[0]=&local_var; - + // check int value=*array2[0]; diff --git a/regression/cbmc/Pointer_byte_extract1/main.c b/regression/cbmc/Pointer_byte_extract1/main.c index ccb81bfc051..318d5c150f7 100644 --- a/regression/cbmc/Pointer_byte_extract1/main.c +++ b/regression/cbmc/Pointer_byte_extract1/main.c @@ -71,4 +71,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Pointer_byte_extract3/main.c b/regression/cbmc/Pointer_byte_extract3/main.c index 3be1a638faf..328a2b939a1 100644 --- a/regression/cbmc/Pointer_byte_extract3/main.c +++ b/regression/cbmc/Pointer_byte_extract3/main.c @@ -24,4 +24,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Pointer_byte_extract5/main.c b/regression/cbmc/Pointer_byte_extract5/main.c index e2d109fb7bd..b720d9ad132 100644 --- a/regression/cbmc/Pointer_byte_extract5/main.c +++ b/regression/cbmc/Pointer_byte_extract5/main.c @@ -43,4 +43,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Pointer_byte_extract6/main.c b/regression/cbmc/Pointer_byte_extract6/main.c index 79c7d634d39..324a980695f 100644 --- a/regression/cbmc/Pointer_byte_extract6/main.c +++ b/regression/cbmc/Pointer_byte_extract6/main.c @@ -11,13 +11,13 @@ int main() { int f; }; - + assert(*(unsigned long long int *)&long_long_int==1); assert(*(unsigned int *)&signed_int==1); assert(((struct some *)&signed_int)->f==1); assert(*(int *)&a_float==1065353216); assert(*(long long int *)&a_double==4607182418800017408l); - + // other direction signed_int=1065353216; assert(*(float *)&signed_int==1.0f); diff --git a/regression/cbmc/Pointer_byte_extract7/main.c b/regression/cbmc/Pointer_byte_extract7/main.c index 3be1a638faf..328a2b939a1 100644 --- a/regression/cbmc/Pointer_byte_extract7/main.c +++ b/regression/cbmc/Pointer_byte_extract7/main.c @@ -24,4 +24,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Pointer_byte_extract8/main.c b/regression/cbmc/Pointer_byte_extract8/main.c index 499ab12fc2b..2266e0f4ef4 100644 --- a/regression/cbmc/Pointer_byte_extract8/main.c +++ b/regression/cbmc/Pointer_byte_extract8/main.c @@ -38,4 +38,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Promotion1/main.c b/regression/cbmc/Promotion1/main.c index 6664d445f9f..8e127502edb 100644 --- a/regression/cbmc/Promotion1/main.c +++ b/regression/cbmc/Promotion1/main.c @@ -16,11 +16,11 @@ int main() // signed int if int is bigger! unsigned char a2=1; signed char b2=-1; - + if(sizeof(char)b2); else - assert(a2=0 && i<2) ==> (!__CPROVER_forall{int j; (j>=0 && j<2) ==> c[i][j]>=1 && c[i][j]<=10}) }, "NotForall-NotForall: successful"); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-assignment/main.c b/regression/cbmc/Quantifiers-assignment/main.c index 02b3318d789..3d1efd43bd2 100644 --- a/regression/cbmc/Quantifiers-assignment/main.c +++ b/regression/cbmc/Quantifiers-assignment/main.c @@ -14,5 +14,5 @@ int main() assert(z1); assert(z2); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-copy/main.c b/regression/cbmc/Quantifiers-copy/main.c index d25cf714b74..d939227149f 100644 --- a/regression/cbmc/Quantifiers-copy/main.c +++ b/regression/cbmc/Quantifiers-copy/main.c @@ -2,7 +2,7 @@ int main() { int a[5]; int b[5]; - + a[0]=0; a[1]=1; a[2]=2; @@ -16,5 +16,5 @@ int main() assert(b[2]==2); assert(b[3]==3); assert(b[4]==4); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-if/main.c b/regression/cbmc/Quantifiers-if/main.c index 998c57e1bce..f8c0bb33f9d 100644 --- a/regression/cbmc/Quantifiers-if/main.c +++ b/regression/cbmc/Quantifiers-if/main.c @@ -19,5 +19,5 @@ int main() if(__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 }) __CPROVER_assert(0, "success 2"); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-initialisation/main.c b/regression/cbmc/Quantifiers-initialisation/main.c index bdbcecafb5c..99eaa53de95 100644 --- a/regression/cbmc/Quantifiers-initialisation/main.c +++ b/regression/cbmc/Quantifiers-initialisation/main.c @@ -1,7 +1,7 @@ int main() { int a[5]; - + __CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<5) ==> a[i]==i+1}); assert(a[0]==1); @@ -9,5 +9,5 @@ int main() assert(a[2]==3); assert(a[3]==4); assert(a[4]==5); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-initialisation2/main.c b/regression/cbmc/Quantifiers-initialisation2/main.c index 26db7982f27..c4996c3b485 100644 --- a/regression/cbmc/Quantifiers-initialisation2/main.c +++ b/regression/cbmc/Quantifiers-initialisation2/main.c @@ -14,5 +14,5 @@ int main() assert(a[2]>a[3]); __CPROVER_assert(__CPROVER_forall {unsigned i; (i>=1 && i<10) ==> c[i-1]<=c[i]}, "forall c[]"); assert(c[3]>=c[1]); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-invalid-var-range/main.c b/regression/cbmc/Quantifiers-invalid-var-range/main.c index 6dde23d384d..5bcb3d7c535 100644 --- a/regression/cbmc/Quantifiers-invalid-var-range/main.c +++ b/regression/cbmc/Quantifiers-invalid-var-range/main.c @@ -6,5 +6,5 @@ int main() assert(a[0][0]==10||a[0][1]==10||a[0][2]==10); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-not-exists/main.c b/regression/cbmc/Quantifiers-not-exists/main.c index adb76cbbee8..d19124f4548 100644 --- a/regression/cbmc/Quantifiers-not-exists/main.c +++ b/regression/cbmc/Quantifiers-not-exists/main.c @@ -26,5 +26,5 @@ int main() assert( ((d[1][0]<1||d[1][0]>10) || (d[1][1]<1||d[1][1]>10)) ); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-not/main.c b/regression/cbmc/Quantifiers-not/main.c index 10a4b5944c1..e5759bd8d22 100644 --- a/regression/cbmc/Quantifiers-not/main.c +++ b/regression/cbmc/Quantifiers-not/main.c @@ -19,5 +19,5 @@ int main() if(!__CPROVER_exists { int i; (i>=0 && i<2) ==> a[i]>=5 && a[i]<=10 }) __CPROVER_assert(0, "failure 2"); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-two-dimension-array/main.c b/regression/cbmc/Quantifiers-two-dimension-array/main.c index a389a3af3ad..b0be6e32f7a 100644 --- a/regression/cbmc/Quantifiers-two-dimension-array/main.c +++ b/regression/cbmc/Quantifiers-two-dimension-array/main.c @@ -2,7 +2,7 @@ int main() { int a[2][2]; int b[2][2]; - + __CPROVER_assume(__CPROVER_forall { int i; (i>=0 && i<2) ==> (__CPROVER_forall{int j; (j>=0 && j<2) ==> a[i][j]==i+j}) }); __CPROVER_assume(__CPROVER_exists { int i; (i>=0 && i<2) ==> (__CPROVER_exists{int j; (j>=0 && j<2) ==> b[i][j]==i+j+1}) }); @@ -11,5 +11,5 @@ int main() assert(a[1][0]==1); assert(a[1][1]==2); assert(b[0][0]==1 || b[0][1]==2 || b[1][0]==2 || b[1][1]==3); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers-type/main.c b/regression/cbmc/Quantifiers-type/main.c index 89ca37731bc..33d6e48305b 100644 --- a/regression/cbmc/Quantifiers-type/main.c +++ b/regression/cbmc/Quantifiers-type/main.c @@ -9,5 +9,5 @@ int main() assert(a[0]==10 && a[1]==10); assert(b[0]==10 && b[1]==10); - return 0; + return 0; } diff --git a/regression/cbmc/Quantifiers1/main.c b/regression/cbmc/Quantifiers1/main.c index 822b9df578b..19b2fa9a47c 100644 --- a/regression/cbmc/Quantifiers1/main.c +++ b/regression/cbmc/Quantifiers1/main.c @@ -16,5 +16,5 @@ int main() c[i]=i; assert(__CPROVER_forall {unsigned i; i>9 || c[i]==i}); - return 0; + return 0; } diff --git a/regression/cbmc/Recursion2/main.c b/regression/cbmc/Recursion2/main.c index 0501acc9683..1866f780a0e 100644 --- a/regression/cbmc/Recursion2/main.c +++ b/regression/cbmc/Recursion2/main.c @@ -7,7 +7,7 @@ void f(unsigned int counter) { int main() { unsigned int x; __CPROVER_assume(x<=10); - + f(x); } diff --git a/regression/cbmc/Recursion5/main.c b/regression/cbmc/Recursion5/main.c index 135e39ea14f..6bfd92e4c83 100644 --- a/regression/cbmc/Recursion5/main.c +++ b/regression/cbmc/Recursion5/main.c @@ -19,4 +19,3 @@ int main() return 0; } - diff --git a/regression/cbmc/Sideeffects1/main.c b/regression/cbmc/Sideeffects1/main.c index 87b83b50dc7..6c51baf23d9 100644 --- a/regression/cbmc/Sideeffects1/main.c +++ b/regression/cbmc/Sideeffects1/main.c @@ -1,12 +1,12 @@ int main(void) { int x, y; - + x=100; - + y=x/=2; assert(x==50); - + y=x*=3; assert(x==150); diff --git a/regression/cbmc/Sideeffects2/main.c b/regression/cbmc/Sideeffects2/main.c index 46990fc8a94..1efa8b74737 100644 --- a/regression/cbmc/Sideeffects2/main.c +++ b/regression/cbmc/Sideeffects2/main.c @@ -17,7 +17,7 @@ int main() z=2; x=(f0() || (z==1)); assert(x); - + z=2; x=(f0() && (z=3)); assert(z==1); @@ -25,8 +25,8 @@ int main() z=2; x=(f1() || (z=3)); assert(z==1); - + z=2; x=(f1() && (z=3)); - assert(z==3); + assert(z==3); } diff --git a/regression/cbmc/Sideeffects3/main.c b/regression/cbmc/Sideeffects3/main.c index 7b032a3602d..5c49106b99c 100644 --- a/regression/cbmc/Sideeffects3/main.c +++ b/regression/cbmc/Sideeffects3/main.c @@ -10,9 +10,9 @@ int x, y, z; int main() { #ifdef _WIN32 - + // Visual Studio won't even parse most of these - + #else // a side effect inside an array type @@ -39,14 +39,14 @@ int main() int return_value=my_f(++x); assert(x==2); assert(return_value==2); - + // using a pointer x=1; int *p=&x; y=++(*p); assert(y==2); assert(x==2); - + // in a struct x=1; struct struct_type @@ -60,7 +60,7 @@ int main() // this is evaluated when the type is defined, not later x++; assert(sizeof(struct struct_type)==sizeof(int)*2+sizeof(int)); - + // only happens once x=1; y=1; @@ -73,27 +73,27 @@ int main() assert(sizeof(v1)==sizeof(int)*2*1); assert(sizeof(v2)==sizeof(int)*2*2); assert(sizeof(v3)==sizeof(int)*2*3); - + // inside a typecast (struct) x=1; (struct { int a[x++]; } *)0; assert(x==2); - + // inside a typecast (function pointer) x=1; (int (*)(int a[x++]))0; // This is ignored by gcc! Haha! assert(x==1); - + // inside sizeof x=1; assert(sizeof(struct { int a[x++]; })==sizeof(int)); assert(x==2); - + // multi-dimensional x=y=1; typedef int my_array1[x][y]; x++; assert(sizeof(my_array1)==sizeof(int)); - + #endif } diff --git a/regression/cbmc/Sideeffects4/main.c b/regression/cbmc/Sideeffects4/main.c index d2a16b49fe2..39c91b96734 100644 --- a/regression/cbmc/Sideeffects4/main.c +++ b/regression/cbmc/Sideeffects4/main.c @@ -11,10 +11,10 @@ _Bool my_f() int main() { // side-effect in ?: - glob=0; - result=glob?1:my_f(); + glob=0; + result=glob?1:my_f(); assert(result==0); - + // side-effect in || glob=0; result=glob||my_f(); @@ -24,9 +24,9 @@ int main() glob=0; result=glob||(0+my_f()); assert(result==0); - + // another variant of this - int r, c=1; + int r, c=1; r=c?(c=0, 10):20; assert(c==0 && r==10); } diff --git a/regression/cbmc/Sideeffects6/main.c b/regression/cbmc/Sideeffects6/main.c index 4175688e79f..db94ea1c047 100644 --- a/regression/cbmc/Sideeffects6/main.c +++ b/regression/cbmc/Sideeffects6/main.c @@ -4,6 +4,6 @@ int main() // we should be able to find this division by zero (void)(c?x/y:z); - + return 0; } diff --git a/regression/cbmc/String1/main.c b/regression/cbmc/String1/main.c index 448d45864fe..3b64fd0028c 100644 --- a/regression/cbmc/String1/main.c +++ b/regression/cbmc/String1/main.c @@ -10,18 +10,18 @@ int main() { assert(s[1]=='b'); assert(s[4]==0); - + // write to s s[0]='x'; - + assert(p[2]=='c'); - + p=s; // write to p p[1]='y'; - - assert(s[1]=='y'); + + assert(s[1]=='y'); { const char local_string[]="asd123"; @@ -40,15 +40,15 @@ int main() #else typedef __typeof__(L'X') wide_char_type; #endif - + unsigned width=sizeof(wide_char_type); - #ifdef _WIN32 + #ifdef _WIN32 assert(width==2); #else assert(width==4); #endif - + assert(sizeof(L"12" "34")==5*width); assert(sizeof("12" L"34")==5*width); diff --git a/regression/cbmc/String2/main.c b/regression/cbmc/String2/main.c index a1a32fa5e73..5c8bfcb93da 100644 --- a/regression/cbmc/String2/main.c +++ b/regression/cbmc/String2/main.c @@ -5,6 +5,6 @@ int main() int input; char ch; - /* should result in bounds violation */ + /* should result in bounds violation */ ch=p[input]; } diff --git a/regression/cbmc/String5/main.c b/regression/cbmc/String5/main.c index 851d482bb5e..e81ef607f7e 100644 --- a/regression/cbmc/String5/main.c +++ b/regression/cbmc/String5/main.c @@ -14,4 +14,3 @@ int main() assert(l==6); } - diff --git a/regression/cbmc/String6/main.c b/regression/cbmc/String6/main.c index cbe0887795c..9b165a6796a 100644 --- a/regression/cbmc/String6/main.c +++ b/regression/cbmc/String6/main.c @@ -1,13 +1,13 @@ #include -#include +#include void free(void *); int main() { - char str[500]="Hello"; + char str[500]="Hello"; assert(strcmp(str, "Hello")==0); - assert(strncmp(str, "Hello", 5)==0); + assert(strncmp(str, "Hello", 5)==0); assert(strcasecmp(str, "HELLO")==0); assert(strncasecmp(str, "HELLO", 5)==0); assert(strcmp(str, "\xff")<0); diff --git a/regression/cbmc/String7/main.c b/regression/cbmc/String7/main.c index 1785408b9e6..7bfacd1c12e 100644 --- a/regression/cbmc/String7/main.c +++ b/regression/cbmc/String7/main.c @@ -1,8 +1,8 @@ -struct S { +struct S { char *Operator; }; -const struct S b1006_props = { +const struct S b1006_props = { .Operator = "OR" }; diff --git a/regression/cbmc/String_Literal1/main.c b/regression/cbmc/String_Literal1/main.c index c7384ba6aed..0185fdf91b2 100644 --- a/regression/cbmc/String_Literal1/main.c +++ b/regression/cbmc/String_Literal1/main.c @@ -11,16 +11,16 @@ int main() assert("\""[0]=='"'); assert("\%"[0]=='%'); assert("\n"[0]==10); - + // spliced to avoid hex ambiguity assert("\x5" "five"[0]==0x5); // spliced accoss multiple lines const char some_string[]= - "\x5" + "\x5" #pragma whatnot "five"; - + assert(some_string[0]==0x5); // wide strings @@ -40,16 +40,16 @@ int main() assert(euro_sign[3]==0); assert(sizeof(euro_sign)==4); - // the following is C++ and C99 + // the following is C++ and C99 const wchar_t wide_amount[]=L"\u20AC123,00"; //€123,00 assert(wide_amount[0]==0x20ac); assert(wide_amount[1]=='1'); - + // C11 unicode string literals assert(sizeof(u8""[0])==sizeof(char)); assert(sizeof(u""[0])==2); assert(sizeof(U""[0])==4); - + // generic wide string, OS-dependent assert(sizeof(L""[0])==sizeof(wchar_t)); } diff --git a/regression/cbmc/Struct_Bytewise1/struct_bytewise.c b/regression/cbmc/Struct_Bytewise1/struct_bytewise.c index b5482988e8a..431372d1374 100644 --- a/regression/cbmc/Struct_Bytewise1/struct_bytewise.c +++ b/regression/cbmc/Struct_Bytewise1/struct_bytewise.c @@ -30,7 +30,7 @@ void CopyBuffer(unsigned char *src) { arrayTmp[i] = src[i]; } } - + int main() { logAppl.a=1; @@ -60,4 +60,3 @@ int main() assert(arrayTmp[7]==1); #endif } - diff --git a/regression/cbmc/Struct_Initialization1/main.c b/regression/cbmc/Struct_Initialization1/main.c index 7065af7690e..f89d06d08e3 100644 --- a/regression/cbmc/Struct_Initialization1/main.c +++ b/regression/cbmc/Struct_Initialization1/main.c @@ -40,7 +40,7 @@ int main() { assert(S1.f==0); assert(S1.g==2); assert(S1.p==0); - + assert(S2.s1.a==1); assert(S2.s1.b==2); assert(S2.s2.a==3); diff --git a/regression/cbmc/Struct_Initialization10/main.c b/regression/cbmc/Struct_Initialization10/main.c index 30168dbeac4..130936a138c 100644 --- a/regression/cbmc/Struct_Initialization10/main.c +++ b/regression/cbmc/Struct_Initialization10/main.c @@ -1,8 +1,8 @@ typedef unsigned blue; - + typedef struct { unsigned blue; } ar_t; typedef struct { ar_t ar; } format_t; - + int main () { // note that 'blue' is a type-token format_t data = { .ar.blue = 1 }; diff --git a/regression/cbmc/Struct_Initialization2/main.c b/regression/cbmc/Struct_Initialization2/main.c index bafcdc9b388..9a04c7fd804 100644 --- a/regression/cbmc/Struct_Initialization2/main.c +++ b/regression/cbmc/Struct_Initialization2/main.c @@ -16,7 +16,7 @@ int main() assert(str_array[1].b==4); int x; - + // this also exists (GCC) str_array[0] = (struct teststr){ .a=1, .c=x }; assert(str_array[0].a==1); diff --git a/regression/cbmc/Struct_Initialization3/main.c b/regression/cbmc/Struct_Initialization3/main.c index c5b4814d117..6152b8442bf 100644 --- a/regression/cbmc/Struct_Initialization3/main.c +++ b/regression/cbmc/Struct_Initialization3/main.c @@ -2,7 +2,7 @@ typedef struct { int a; } S; - + int main(void) { S s; diff --git a/regression/cbmc/Struct_Initialization5/main.c b/regression/cbmc/Struct_Initialization5/main.c index 47a662328ae..455c9e107c0 100644 --- a/regression/cbmc/Struct_Initialization5/main.c +++ b/regression/cbmc/Struct_Initialization5/main.c @@ -10,7 +10,7 @@ int main() { struct X foo1; struct Y foo2; - + foo2=(struct Y){ foo1 }; assert(foo2.x.y==foo1.y); diff --git a/regression/cbmc/Struct_Initialization6/main.c b/regression/cbmc/Struct_Initialization6/main.c index a7a7ebde9f4..6e069783f54 100644 --- a/regression/cbmc/Struct_Initialization6/main.c +++ b/regression/cbmc/Struct_Initialization6/main.c @@ -6,7 +6,7 @@ struct X { int z; } f [3]; - + int g, h; } foo = { .g=200, .f[1].z=100 }; @@ -30,7 +30,7 @@ int main() assert(z.a3==30); assert(z.a4==40); assert(z.a5==0); - + assert(enable[0]==1); assert(enable[30]==2); assert(enable[31]==3); diff --git a/regression/cbmc/Struct_Initialization7/main.c b/regression/cbmc/Struct_Initialization7/main.c index c9ffb6434c3..08498f9b46c 100644 --- a/regression/cbmc/Struct_Initialization7/main.c +++ b/regression/cbmc/Struct_Initialization7/main.c @@ -6,14 +6,14 @@ struct X { int a, b, c; } y; - + int z; }; int main() { struct X x={ 1, 2 }; - + assert(x.y.a==1); assert(x.z==2); } diff --git a/regression/cbmc/Struct_Padding1/main.c b/regression/cbmc/Struct_Padding1/main.c index 0412e6de630..5dd960bd6c4 100644 --- a/regression/cbmc/Struct_Padding1/main.c +++ b/regression/cbmc/Struct_Padding1/main.c @@ -7,13 +7,13 @@ struct my_struct1 { int i; char ch; - + struct { // this gets padded int j; }; - + // Bit-fields do not get padded in between, // but fill up an integer! unsigned bf1:1; @@ -27,7 +27,7 @@ struct my_struct2 { int i; char ch[4]; - + // no padding needed int j; @@ -48,7 +48,7 @@ int main() assert(xx1.i==1); assert(xx1.ch==2); assert(xx1.j==3); - + // let's probe the padding char *p=&xx1.ch; assert(p[0]==2); diff --git a/regression/cbmc/Union_Initialization1/main.c b/regression/cbmc/Union_Initialization1/main.c index 831d7b4a2d6..8d3374b1997 100644 --- a/regression/cbmc/Union_Initialization1/main.c +++ b/regression/cbmc/Union_Initialization1/main.c @@ -18,9 +18,9 @@ union trigger : 1, mask : 1, __reserved_2 : 15; - + unsigned __reserved_3 : 24, - dest : 8; + dest : 8; } entry; } u1 = { .entry.delivery_mode = 2, .entry.mask = 1 }; @@ -33,7 +33,7 @@ union { int d, e; } c; - + } u2 = { 1 }, u3 = { .c.e = 2 } ; int main() @@ -41,7 +41,7 @@ int main() assert(u1.entry.vector==0); assert(u1.entry.delivery_mode==2); assert(u1.entry.mask==1); - + assert(u2.a==1); assert(u3.a==0); assert(u3.c.e==2); diff --git a/regression/cbmc/Unwinding_Locality1/main.c b/regression/cbmc/Unwinding_Locality1/main.c index 91ac5057295..41a2fbdb017 100644 --- a/regression/cbmc/Unwinding_Locality1/main.c +++ b/regression/cbmc/Unwinding_Locality1/main.c @@ -1,17 +1,17 @@ int main() { int i; - + for(i=0; i<10; i++) { const int a=i; } - + int array[10]; for(i=0; i<10; i++) { const int a; array[i]=a; } - + // these should all be allowed to be different assert(array[0]==array[1]); } diff --git a/regression/cbmc/Variadic1/main.c b/regression/cbmc/Variadic1/main.c index 6040d61bba4..d634c6e90fd 100644 --- a/regression/cbmc/Variadic1/main.c +++ b/regression/cbmc/Variadic1/main.c @@ -37,4 +37,3 @@ int main (void) return 0; } - diff --git a/regression/cbmc/Visual_Studio_Types1/main.c b/regression/cbmc/Visual_Studio_Types1/main.c index 138a7b7cb1b..48f37c2175f 100644 --- a/regression/cbmc/Visual_Studio_Types1/main.c +++ b/regression/cbmc/Visual_Studio_Types1/main.c @@ -12,29 +12,29 @@ int main() assert(sizeof(i3)==4); assert(sizeof(i4)==8); #endif - + // general types - + char c; short s; int i; long l; long long ll; - + assert(sizeof(c)==1); assert(sizeof(s)==2); assert(sizeof(i)==4); assert(sizeof(l)==4); assert(sizeof(ll)==8); - - // these constants are Visual Studio-specific + + // these constants are Visual Studio-specific #ifdef _MSC_VER assert(sizeof(1i8)==1); assert(sizeof(1i16)==2); assert(sizeof(1i32)==4); assert(sizeof(1i64)==8); assert(sizeof(1i128)==16); - + // oh, and these pointer qualifiers are Visual Studio-specific int * __ptr32 p32; //int * __ptr64 p64; @@ -43,6 +43,6 @@ int main() assert(sizeof(p32)==4); //assert(sizeof(p64)==8); #endif - + assert(sizeof(void *)==4); } diff --git a/regression/cbmc/Visual_Studio_Types2/main.c b/regression/cbmc/Visual_Studio_Types2/main.c index 3daa245332e..921143e24a6 100644 --- a/regression/cbmc/Visual_Studio_Types2/main.c +++ b/regression/cbmc/Visual_Studio_Types2/main.c @@ -5,12 +5,12 @@ int main() int i; long l; long long ll; - + assert(sizeof(s)==2); assert(sizeof(i)==4); assert(sizeof(l)==4); assert(sizeof(ll)==8); - + // oh, and these pointer qualifiers are MS-specific #ifdef _MSC_VER int * __ptr32 p32; @@ -20,6 +20,6 @@ int main() assert(sizeof(p32)==4); assert(sizeof(p64)==8); #endif - + assert(sizeof(void *)==8); } diff --git a/regression/cbmc/Volatile1/main.c b/regression/cbmc/Volatile1/main.c index 383e71c59d7..84ac4837d1e 100644 --- a/regression/cbmc/Volatile1/main.c +++ b/regression/cbmc/Volatile1/main.c @@ -3,4 +3,3 @@ int main() { if (!x) assert(!x); } - diff --git a/regression/cbmc/Zero_Initialization1/main.c b/regression/cbmc/Zero_Initialization1/main.c index a051d31258c..e179f017d0c 100644 --- a/regression/cbmc/Zero_Initialization1/main.c +++ b/regression/cbmc/Zero_Initialization1/main.c @@ -8,7 +8,7 @@ union U my_u; union U { - int some; + int some; }; struct S my_s; diff --git a/regression/cbmc/__func__1/main.c b/regression/cbmc/__func__1/main.c index 93870e6abad..f87717d5a1a 100644 --- a/regression/cbmc/__func__1/main.c +++ b/regression/cbmc/__func__1/main.c @@ -1,13 +1,13 @@ int main() { char ch0, ch1, ch2, ch3, ch4; - + ch0=__func__[0]; ch1=__func__[1]; ch2=__func__[2]; ch3=__func__[3]; ch4=__func__[4]; - + assert(ch0=='m'); assert(ch1=='a'); assert(ch2=='i'); diff --git a/regression/cbmc/abs1/main.c b/regression/cbmc/abs1/main.c index bea310ae957..e3e149726a1 100644 --- a/regression/cbmc/abs1/main.c +++ b/regression/cbmc/abs1/main.c @@ -10,17 +10,17 @@ int main() { int my_i, iabs; double my_d, dabs; - + assert(abs(-1)==1); assert(abs(1)==1); assert(fabs(1.0)==1); assert(fabs(-1.0)==1); - + iabs=(my_i<0)?-my_i:my_i; assert(abs(my_i)==iabs); __CPROVER_assume(!isnan(my_d)); - + dabs=(my_d<0)?-my_d:my_d; assert(fabs(my_d)==dabs); } diff --git a/regression/cbmc/array-tests/main.c b/regression/cbmc/array-tests/main.c index 0f738bf6263..8a0e96753d4 100644 --- a/regression/cbmc/array-tests/main.c +++ b/regression/cbmc/array-tests/main.c @@ -60,25 +60,25 @@ int main (void) { /*** Direct use ***/ // No changes - + // Constant accesss : should simplify away assert(uninitialisedGlobalArray1[31] == 0); assert(uninitialisedGlobalArray1[23] == 0); assert(uninitialisedGlobalArray2[37] == 0); - + assert(initialisedUniform1[11] == 0); assert(initialisedUniform2[13] == 0); assert(initialisedUniform2[15] == 0); assert(initialisedUniform3[17] == 1); - + assert(initialisedNonUniform1[3] == 3); assert(initialisedNonUniform1[5] == 5); assert(initialisedNonUniform2[7] == 7); assert(initialisedNonUniform3[9] == 6); - + // Variable access int directUseReadLocation[8]; // Non-det - + if (0 <= directUseReadLocation[0] && directUseReadLocation[0] < 256) assert(uninitialisedGlobalArray1[directUseReadLocation[0]] == 0); @@ -108,7 +108,7 @@ int main (void) { } else if (test == 1) { - + /*** Constant redundant update ***/ // Updates should simplify away. // Shouldn't require array_of to array conversion. @@ -117,7 +117,7 @@ int main (void) { uninitialisedGlobalArray1[23] = 0; uninitialisedGlobalArray1[33] = 0; uninitialisedGlobalArray2[63] = 0; - + initialisedUniform1[13] = 0; initialisedUniform2[11] = 0; initialisedUniform2[15] = 0; @@ -129,7 +129,7 @@ int main (void) { // These two check write re-ordering and coalescing initialisedNonUniform1[2] = 11; initialisedNonUniform1[3] = 25; - + initialisedNonUniform1[2] = 2; initialisedNonUniform1[3] = 3; initialisedNonUniform1[4] = 4; @@ -146,15 +146,15 @@ int main (void) { assert(initialisedUniform2[13] == 0); assert(initialisedUniform2[15] == 0); assert(initialisedUniform3[17] == 1); - + assert(initialisedNonUniform1[3] == 3); assert(initialisedNonUniform1[5] == 5); assert(initialisedNonUniform2[7] == 7); assert(initialisedNonUniform3[9] == 6); - + // Variable access int constantRedundantUpdateReadLocation[8]; // Non-det - + if (0 <= constantRedundantUpdateReadLocation[0] && constantRedundantUpdateReadLocation[0] < 256) assert(uninitialisedGlobalArray1[constantRedundantUpdateReadLocation[0]] == 0); @@ -191,7 +191,7 @@ int main (void) { uninitialisedGlobalArray1[23] = 2; uninitialisedGlobalArray1[53] = 3; uninitialisedGlobalArray2[62] = 4; - + initialisedUniform1[12] = 1; initialisedUniform2[10] = 1; initialisedUniform2[15] = 1; @@ -199,16 +199,16 @@ int main (void) { initialisedUniform3[13] = 0; initialisedUniform3[15] = 0; initialisedUniform3[17] = 0; - + initialisedNonUniform1[2] = -2; initialisedNonUniform1[3] = -3; initialisedNonUniform1[7] = -4; initialisedNonUniform2[3] = 11; initialisedNonUniform3[9] = 11; initialisedNonUniform3[7] = 10; - - + + // Constant accesss : should still simplify away assert(uninitialisedGlobalArray1[31] == 0); assert(uninitialisedGlobalArray1[23] == 2); @@ -226,7 +226,7 @@ int main (void) { // Variable access int constantNonRedundantUpdateReadLocation[8]; // Non-det - + if (0 <= constantNonRedundantUpdateReadLocation[0] && constantNonRedundantUpdateReadLocation[0] < 5) assert(uninitialisedGlobalArray1[constantNonRedundantUpdateReadLocation[0]] == 0); @@ -268,9 +268,9 @@ int main (void) { // context-free rewriter. // * For the non-uniform arrays some complex reasoning is needed. // * Simplification across Phi nodes is needed as well - + int redundantWriteLocation[16]; - + if (0 <= redundantWriteLocation[0] && redundantWriteLocation[0] < 256) uninitialisedGlobalArray1[redundantWriteLocation[0]] = 0; @@ -283,7 +283,7 @@ int main (void) { redundantWriteLocation[2] < 256) uninitialisedGlobalArray2[redundantWriteLocation[2]] = 0; - + if (0 <= redundantWriteLocation[3] && redundantWriteLocation[3] < 64) @@ -323,7 +323,7 @@ int main (void) { // Check write coallescing and reordering // Can re-order writes if the indexes being equal implies the // values are equal. - + initialisedNonUniform1[redundantWriteLocation[10]] = 29; initialisedNonUniform1[redundantWriteLocation[11]] = 29; @@ -351,8 +351,8 @@ int main (void) { // If the array is simplified then this should simplify as well // If not then they likely won't and thus an example of a constant // index into a non-constant (but completely known) array. - - + + assert(uninitialisedGlobalArray1[31] == 0); assert(uninitialisedGlobalArray1[23] == 0); assert(uninitialisedGlobalArray2[37] == 0); @@ -361,16 +361,16 @@ int main (void) { assert(initialisedUniform2[13] == 0); assert(initialisedUniform2[15] == 0); assert(initialisedUniform3[17] == 1); - + assert(initialisedNonUniform1[3] == 3); assert(initialisedNonUniform1[5] == 5); assert(initialisedNonUniform2[7] == 7); assert(initialisedNonUniform3[9] == 6); - + // Variable access int variableRedundantUpdateReadLocation[8]; // Non-det - + if (0 <= variableRedundantUpdateReadLocation[0] && variableRedundantUpdateReadLocation[0] < 256) assert(uninitialisedGlobalArray1[variableRedundantUpdateReadLocation[0]] == 0); @@ -398,14 +398,14 @@ int main (void) { variableRedundantUpdateReadLocation[7] < 16) assert(initialisedNonUniform3[variableRedundantUpdateReadLocation[7]] == 15 - variableRedundantUpdateReadLocation[7]); - + } else if (test == 4) { /*** Variable non-redundant update ***/ // No obvious simplifications to writes int nonRedundantWriteLocation[16]; - + if (0 <= nonRedundantWriteLocation[0] && nonRedundantWriteLocation[0] < 256 && nonRedundantWriteLocation[0] != 31) @@ -421,7 +421,7 @@ int main (void) { nonRedundantWriteLocation[2] < 256) uninitialisedGlobalArray2[nonRedundantWriteLocation[2]] = (nonRedundantWriteLocation[2] & 0xFF); - + if (0 <= nonRedundantWriteLocation[3] && nonRedundantWriteLocation[3] < 10) @@ -464,7 +464,7 @@ int main (void) { // Check write coallescing and reordering // Can re-order writes if the indexes being equal implies the // values are equal. - + initialisedNonUniform1[nonRedundantWriteLocation[10]] = 29; initialisedNonUniform1[nonRedundantWriteLocation[11]] = 29; @@ -487,7 +487,7 @@ int main (void) { initialisedNonUniform3[nonRedundantWriteLocation[15]] += 1; } - + // Constant access // Again, constant index into a fully known but non-constant array assert(uninitialisedGlobalArray1[31] == 0); @@ -498,7 +498,7 @@ int main (void) { assert((initialisedUniform2[13] & 0xE) == 0); assert(initialisedUniform2[15] == 0); assert(initialisedUniform3[17] == 1); - + assert(initialisedNonUniform1[3] - 2 >= 0); assert(initialisedNonUniform1[5] - 4 >= 0); assert(initialisedNonUniform2[7] == 7); @@ -506,7 +506,7 @@ int main (void) { // Variable access int variableNonRedundantUpdateReadLocation[8]; // Non-det - + if (0 <= variableNonRedundantUpdateReadLocation[0] && variableNonRedundantUpdateReadLocation[0] < 256) assert(uninitialisedGlobalArray1[variableNonRedundantUpdateReadLocation[0]] >= 0); @@ -541,4 +541,3 @@ int main (void) { return 0; } - diff --git a/regression/cbmc/atomic_section_seq1/main.c b/regression/cbmc/atomic_section_seq1/main.c index 630056854c3..0e223b6b658 100644 --- a/regression/cbmc/atomic_section_seq1/main.c +++ b/regression/cbmc/atomic_section_seq1/main.c @@ -372,4 +372,3 @@ signed int main(void) ethoc_open(&netdev); return 0; } - diff --git a/regression/cbmc/big-endian-array1/main.c b/regression/cbmc/big-endian-array1/main.c index 56fe657d9e3..71dc797caf0 100644 --- a/regression/cbmc/big-endian-array1/main.c +++ b/regression/cbmc/big-endian-array1/main.c @@ -23,7 +23,7 @@ int main() __CPROVER_assert(p1==2, "p[1] matches"); __CPROVER_assert(p2==3, "p[2] matches"); __CPROVER_assert(p3==4, "p[3] matches"); - + unsigned short *q=(unsigned short *)array; unsigned short q0=q[0]; __CPROVER_assert(q0==0x0102, "p[0,1] matches"); diff --git a/regression/cbmc/char1/main.c b/regression/cbmc/char1/main.c index dd90a6a764a..7e0fe699d7a 100644 --- a/regression/cbmc/char1/main.c +++ b/regression/cbmc/char1/main.c @@ -7,7 +7,7 @@ int main() #error _CHAR_UNSIGNED should be set #endif #endif - + #ifdef __GNUC__ #ifndef __CHAR_UNSIGNED__ #error __CHAR_UNSIGNED__ should be set diff --git a/regression/cbmc/character_handling1/main.c b/regression/cbmc/character_handling1/main.c index f0ae7f185da..ca5a1067d94 100644 --- a/regression/cbmc/character_handling1/main.c +++ b/regression/cbmc/character_handling1/main.c @@ -1,16 +1,16 @@ -int isalnum(int c); -int isalpha(int c); -int isblank(int c); -int iscntrl(int c); -int isdigit(int c); -int isgraph(int c); -int islower(int c); -int isprint(int c); -int ispunct(int c); -int isspace(int c); -int isupper(int c); -int isxdigit(int c); -int tolower(int c); +int isalnum(int c); +int isalpha(int c); +int isblank(int c); +int iscntrl(int c); +int isdigit(int c); +int isgraph(int c); +int islower(int c); +int isprint(int c); +int ispunct(int c); +int isspace(int c); +int isupper(int c); +int isxdigit(int c); +int tolower(int c); int toupper(int c); int main() @@ -22,7 +22,7 @@ int main() assert(!isalnum(' ')); assert(!isalnum('.')); assert(!isalnum(0)); - + assert(isalpha('a')); assert(!isalpha('1')); assert(isalpha('A')); @@ -30,7 +30,7 @@ int main() assert(!isalpha(' ')); assert(!isalpha('.')); assert(!isalpha(0)); - + assert(!isblank('a')); assert(!isblank('1')); assert(!isblank('A')); @@ -38,7 +38,7 @@ int main() assert(isblank(' ')); assert(!isblank('.')); assert(!isblank(0)); - + assert(!iscntrl('a')); assert(!iscntrl('1')); assert(!iscntrl('A')); @@ -46,7 +46,7 @@ int main() assert(!iscntrl(' ')); assert(!iscntrl('.')); assert(iscntrl(0)); - + assert(!isdigit('a')); assert(isdigit('1')); assert(!isdigit('A')); @@ -54,7 +54,7 @@ int main() assert(!isdigit(' ')); assert(!isdigit('.')); assert(!isdigit(0)); - + assert(islower('a')); assert(!islower('1')); assert(!islower('A')); @@ -62,7 +62,7 @@ int main() assert(!islower(' ')); assert(!islower('.')); assert(!islower(0)); - + assert(!isupper('a')); assert(!isupper('1')); assert(isupper('A')); @@ -70,7 +70,7 @@ int main() assert(!isupper(' ')); assert(!isupper('.')); assert(!isupper(0)); - + assert(!isspace('a')); assert(!isspace('1')); assert(!isspace('A')); @@ -78,7 +78,7 @@ int main() assert(isspace(' ')); assert(!isspace('.')); assert(!isspace(0)); - + assert(tolower('a')=='a'); assert(tolower('1')=='1'); assert(tolower('A')=='a'); @@ -86,7 +86,7 @@ int main() assert(tolower(' ')==' '); assert(tolower('.')=='.'); assert(tolower(0)==0); - + assert(toupper('a')=='A'); assert(toupper('1')=='1'); assert(toupper('A')=='A'); @@ -94,5 +94,5 @@ int main() assert(toupper(' ')==' '); assert(toupper('.')=='.'); assert(toupper(0)==0); - + } diff --git a/regression/cbmc/complex1/main.c b/regression/cbmc/complex1/main.c index aebdad77108..72695b5edf9 100644 --- a/regression/cbmc/complex1/main.c +++ b/regression/cbmc/complex1/main.c @@ -8,15 +8,15 @@ int main() c=1.0i+2; assert(__real__ c == 2); - assert(__imag__ c == 1); - + assert(__imag__ c == 1); + _Complex double d; assert(sizeof(c)==sizeof(d)); - + _Complex signed char char_complex, char_complex2; - + char_complex=0x3i-2; - + assert(sizeof(d)==sizeof(c)); assert(sizeof(char_complex)==sizeof(signed char)*2); @@ -26,37 +26,37 @@ int main() assert(((signed char *)&char_complex)[0]==-2); assert(((signed char *)&char_complex)[1]==3); #endif - + assert(__real__ char_complex == -2); assert(__imag__ char_complex == 3); - + // the precedence of __imag__ is higher than that of + assert((__imag__ 1.0i + 1.0i) == 1.0i + 1.0); - + // complex conjugate char_complex2 = ~ char_complex; - + // __real__ something is an lvalue! - __real__ char_complex = 100; + __real__ char_complex = 100; assert(__real__ char_complex == 100); assert(__imag__ char_complex == 3); - // can be incremented + // can be incremented char_complex++; assert(__real__ char_complex == 101); assert(__imag__ char_complex == 3); - + // also separately (__real__ char_complex)++; - assert(__real__ char_complex == 102); + assert(__real__ char_complex == 102); assert(__imag__ char_complex == 3); - + // casts to reals produce the real part - assert((int) char_complex == 102); - + assert((int) char_complex == 102); + #else - - // Visual studio doesn't have it + + // Visual studio doesn't have it #endif } diff --git a/regression/cbmc/compound_literal1/main.c b/regression/cbmc/compound_literal1/main.c index 82d65125ab1..fb9374523f0 100644 --- a/regression/cbmc/compound_literal1/main.c +++ b/regression/cbmc/compound_literal1/main.c @@ -16,15 +16,15 @@ int main() assert(((float[2]) {2.7, 3.1})[1]==3.1f); assert(((struct POINT) {0, 1}).y==1); assert(((union U) {1.4}).f==1.4f); - + // Address can be taken, lifetime is that of the // containing block. int *p=&(int){ 42 }; assert(*p==42); - + // and modified *p=43; assert(*p==43); - + return 0; } diff --git a/regression/cbmc/const_ptr1/main.c b/regression/cbmc/const_ptr1/main.c index d0a109c690d..fb235940af3 100644 --- a/regression/cbmc/const_ptr1/main.c +++ b/regression/cbmc/const_ptr1/main.c @@ -15,13 +15,13 @@ int main() // to a constant pointer to pointers to constant-chars const char * const *p2; p2=my_array; - + const char *p3; char ch; - + p3=*p2; - + ch=*p3; - + assert(ch=='x'); } diff --git a/regression/cbmc/constant_folding2/main.c b/regression/cbmc/constant_folding2/main.c index a7d2c227d44..4bcb4ed5c73 100644 --- a/regression/cbmc/constant_folding2/main.c +++ b/regression/cbmc/constant_folding2/main.c @@ -9,13 +9,13 @@ int main (void) pair p; p.x = 0; p.y = 0; - + int array[2]; array[0] = 0; array[1] = 0; - + int i=0; - + while (i < p.x) i++; while (i < array[0]) i++; diff --git a/regression/cbmc/divide-by-one-simplify/main.c b/regression/cbmc/divide-by-one-simplify/main.c index 4c457111406..dfe632ba932 100644 --- a/regression/cbmc/divide-by-one-simplify/main.c +++ b/regression/cbmc/divide-by-one-simplify/main.c @@ -4,7 +4,7 @@ int main (void) { float f; float g; int i; - + __CPROVER_assume(f == f); // I.E. not NaN g = f; diff --git a/regression/cbmc/enum1/main.c b/regression/cbmc/enum1/main.c index 74d940ea1d0..ed76336f860 100644 --- a/regression/cbmc/enum1/main.c +++ b/regression/cbmc/enum1/main.c @@ -11,13 +11,13 @@ int array[E5]; int main() { int integer; - + a=E2; assert(a==1); - + assert(E4==4); assert(sizeof(array)==sizeof(int)*5); - + integer=a; assert(integer==1); } diff --git a/regression/cbmc/enum3/main.c b/regression/cbmc/enum3/main.c index 44d6a512bd0..256b046cb6a 100644 --- a/regression/cbmc/enum3/main.c +++ b/regression/cbmc/enum3/main.c @@ -9,4 +9,4 @@ int main(void) assert(token==Cx); return 1; -} +} diff --git a/regression/cbmc/enum4/main.c b/regression/cbmc/enum4/main.c index 682347573c1..27c717a3591 100644 --- a/regression/cbmc/enum4/main.c +++ b/regression/cbmc/enum4/main.c @@ -14,4 +14,3 @@ int main() void *(___args[1]) = {&_event_arg}; execute(___args); } - diff --git a/regression/cbmc/enum5/main.c b/regression/cbmc/enum5/main.c index 41f7a18c9b4..a249dfc4fba 100644 --- a/regression/cbmc/enum5/main.c +++ b/regression/cbmc/enum5/main.c @@ -18,4 +18,3 @@ int main() __CPROVER_assert(0, ""); return 0; } - diff --git a/regression/cbmc/equality_through_array3/main.c b/regression/cbmc/equality_through_array3/main.c index e9768e552c0..9e94a5eba95 100644 --- a/regression/cbmc/equality_through_array3/main.c +++ b/regression/cbmc/equality_through_array3/main.c @@ -26,4 +26,3 @@ void main () return 1; } - diff --git a/regression/cbmc/equality_through_array4/main.c b/regression/cbmc/equality_through_array4/main.c index 72b3c671827..06fe628b50a 100644 --- a/regression/cbmc/equality_through_array4/main.c +++ b/regression/cbmc/equality_through_array4/main.c @@ -21,4 +21,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc/equality_through_array5/main.c b/regression/cbmc/equality_through_array5/main.c index f148f2f7fef..41102922960 100644 --- a/regression/cbmc/equality_through_array5/main.c +++ b/regression/cbmc/equality_through_array5/main.c @@ -22,4 +22,3 @@ int main (void) { return 1; } - diff --git a/regression/cbmc/equality_through_struct1/main.c b/regression/cbmc/equality_through_struct1/main.c index 02394abb3e2..5b78b7af31d 100644 --- a/regression/cbmc/equality_through_struct1/main.c +++ b/regression/cbmc/equality_through_struct1/main.c @@ -20,4 +20,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc/equality_through_struct_containing_arrays1/main.c b/regression/cbmc/equality_through_struct_containing_arrays1/main.c index 33893d5de03..4b88e22f3b9 100644 --- a/regression/cbmc/equality_through_struct_containing_arrays1/main.c +++ b/regression/cbmc/equality_through_struct_containing_arrays1/main.c @@ -41,4 +41,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc/equality_through_struct_containing_arrays2/main.c b/regression/cbmc/equality_through_struct_containing_arrays2/main.c index d6dd912406f..a10f7cf2ec4 100644 --- a/regression/cbmc/equality_through_struct_containing_arrays2/main.c +++ b/regression/cbmc/equality_through_struct_containing_arrays2/main.c @@ -46,4 +46,3 @@ int main (void) return 1; } - diff --git a/regression/cbmc/exit1/main.c b/regression/cbmc/exit1/main.c index 0661315487b..c403cc204f0 100644 --- a/regression/cbmc/exit1/main.c +++ b/regression/cbmc/exit1/main.c @@ -2,7 +2,7 @@ void exit(int status); int main() { int x; - + if(x==10) exit(1); diff --git a/regression/cbmc/extern_initialization1/file2.c b/regression/cbmc/extern_initialization1/file2.c index 579cd194cb1..430d09c7316 100644 --- a/regression/cbmc/extern_initialization1/file2.c +++ b/regression/cbmc/extern_initialization1/file2.c @@ -1,2 +1 @@ extern int some_int; - diff --git a/regression/cbmc/extern_initialization2/file2.c b/regression/cbmc/extern_initialization2/file2.c index 894a5c09d13..f0bd0cbd8d1 100644 --- a/regression/cbmc/extern_initialization2/file2.c +++ b/regression/cbmc/extern_initialization2/file2.c @@ -4,4 +4,3 @@ extern int some_int; int some_int; extern int some_int; - diff --git a/regression/cbmc/for-break1/main.c b/regression/cbmc/for-break1/main.c index 88c5344cb36..c6fe8f78046 100644 --- a/regression/cbmc/for-break1/main.c +++ b/regression/cbmc/for-break1/main.c @@ -9,6 +9,6 @@ int main() b=1; } - + assert(a==b); } diff --git a/regression/cbmc/for1/main.c b/regression/cbmc/for1/main.c index 1a650444570..d3448117650 100644 --- a/regression/cbmc/for1/main.c +++ b/regression/cbmc/for1/main.c @@ -1,13 +1,13 @@ int main() { int i=0; - + for(;;) { i++; if(i==30) break; } - + assert(i==30); return 0; diff --git a/regression/cbmc/gcc_conditional_expr1/main.c b/regression/cbmc/gcc_conditional_expr1/main.c index 53c43ce675c..5f6f46bbba4 100644 --- a/regression/cbmc/gcc_conditional_expr1/main.c +++ b/regression/cbmc/gcc_conditional_expr1/main.c @@ -3,15 +3,15 @@ int g, k; int main() { int r1, r2; - + r1= (g++) ? : 2; - + assert(r1==2); assert(g==1); r2= (g++) ? : (k++); - + assert(r2==1); - assert(g==2); + assert(g==2); assert(k==0); } diff --git a/regression/cbmc/gcc_local_label1/main.c b/regression/cbmc/gcc_local_label1/main.c index 2bdea2be2d3..d9263aa3740 100644 --- a/regression/cbmc/gcc_local_label1/main.c +++ b/regression/cbmc/gcc_local_label1/main.c @@ -8,14 +8,14 @@ void other_f() #ifdef __GNUC__ here:; x++; - + { __label__ here, there; - + goto here; // not jumping up, but down! here:; // this would usually fail - + assert(0); } #else @@ -28,4 +28,3 @@ int main() { other_f(); } - diff --git a/regression/cbmc/gcc_statement_expression1/main.c b/regression/cbmc/gcc_statement_expression1/main.c index 539e53e4170..843323e4308 100644 --- a/regression/cbmc/gcc_statement_expression1/main.c +++ b/regression/cbmc/gcc_statement_expression1/main.c @@ -3,20 +3,20 @@ int main() int x; int y; - // as a side-effect + // as a side-effect ({ x=1; x;}); - + assert(x==1); - + x= ({ y=1; 2; }); assert(x==2); assert(y==1); - + // inside an initializer: a needs to be visible // before doing the initializer int a=({ int b=(long int)&a; b; }); - + return 0; } diff --git a/regression/cbmc/gcc_statement_expression2/main.c b/regression/cbmc/gcc_statement_expression2/main.c index a36b68191b8..c1bfc88eaa1 100644 --- a/regression/cbmc/gcc_statement_expression2/main.c +++ b/regression/cbmc/gcc_statement_expression2/main.c @@ -8,7 +8,7 @@ int f() int main() { int i; - + int x = ({f();}); assert(x==1); @@ -20,7 +20,7 @@ int main() int z = ({ i=1; i++; }); assert(z==1); assert(i==2); - + // same at top level ({ i=1; i++; }); assert(i==2); diff --git a/regression/cbmc/gcc_vector1/main.c b/regression/cbmc/gcc_vector1/main.c index 81ee89d5bfa..69121e20234 100644 --- a/regression/cbmc/gcc_vector1/main.c +++ b/regression/cbmc/gcc_vector1/main.c @@ -17,7 +17,7 @@ int main() assert(sizeof(v4si)==16); vector_u x, y, z; - + z.v=x.v+y.v; assert(z.members[0]==x.members[0]+y.members[0]); @@ -45,7 +45,7 @@ int main() assert(z.members[1]==~x.members[1]); assert(z.members[2]==~x.members[2]); assert(z.members[3]==~x.members[3]); - + // build vector with typecast z.v=(v4si){ 0, 1, 2, 3 }; assert(z.members[0]==0 && z.members[1]==1 && z.members[2]==2 && z.members[3]==3); @@ -54,14 +54,14 @@ int main() v4si some_vector={ 10, 11, 12, 13 }; z.v=some_vector; assert(z.members[0]==10 && z.members[1]==11 && z.members[2]==12 && z.members[3]==13); - + // same from one v4si other_vector={ 0 }; z.v=other_vector; // an array of vectors v4si image[] = { other_vector }; - + assert(z.members[1]==0); } diff --git a/regression/cbmc/gcc_vector2/main.c b/regression/cbmc/gcc_vector2/main.c index 89d2a9d9961..c35987af7c8 100644 --- a/regression/cbmc/gcc_vector2/main.c +++ b/regression/cbmc/gcc_vector2/main.c @@ -30,7 +30,7 @@ int main() assert(((int*) &a)[i]==((int*) &b)[i]); assert(((int*) &b)[i]==b[i]); } - + #endif return 0; diff --git a/regression/cbmc/goto1/main.c b/regression/cbmc/goto1/main.c index ceb93ebe0cb..1eaf79a78d0 100644 --- a/regression/cbmc/goto1/main.c +++ b/regression/cbmc/goto1/main.c @@ -1,14 +1,14 @@ int main() { int i, j; - + if(i) goto l; - + if(j) goto l; - + assert(!i && !j); - - l:; + + l:; } diff --git a/regression/cbmc/goto2/main.c b/regression/cbmc/goto2/main.c index 320c107fb8e..26219e65fe3 100644 --- a/regression/cbmc/goto2/main.c +++ b/regression/cbmc/goto2/main.c @@ -8,8 +8,8 @@ int main() goto l; i=2; - - l:; - + + l:; + assert(i==1 || !j); } diff --git a/regression/cbmc/goto3/main.c b/regression/cbmc/goto3/main.c index 19d27206bd8..985725bc086 100644 --- a/regression/cbmc/goto3/main.c +++ b/regression/cbmc/goto3/main.c @@ -1,15 +1,15 @@ int main() { int i; - + i=0; loop: assert(i<10); i++; - + if(i<10) goto loop; - + assert(i==10); } diff --git a/regression/cbmc/if2/main.c b/regression/cbmc/if2/main.c index 94ba1071143..bec127110bc 100644 --- a/regression/cbmc/if2/main.c +++ b/regression/cbmc/if2/main.c @@ -3,10 +3,10 @@ int nondet_int(); int main() { int i, j, k; - + i=nondet_int(); k=nondet_int(); - + if(i) { } diff --git a/regression/cbmc/if3/main.c b/regression/cbmc/if3/main.c index 08c20e43bf0..be1474285e1 100644 --- a/regression/cbmc/if3/main.c +++ b/regression/cbmc/if3/main.c @@ -1,11 +1,11 @@ int main() { goto ERROR; - + if(0) { ERROR: assert(0); } - + return 0; } diff --git a/regression/cbmc/if4/main.c b/regression/cbmc/if4/main.c index 1a67c7ebbbd..e109c21dbd5 100644 --- a/regression/cbmc/if4/main.c +++ b/regression/cbmc/if4/main.c @@ -3,10 +3,10 @@ int main() int x; __CPROVER_assume(x==1); - + if(x==2) x++; - + // this should pass assert(x==1); } diff --git a/regression/cbmc/inline1/header.h b/regression/cbmc/inline1/header.h index c18b4ee55a3..3aea02623ce 100644 --- a/regression/cbmc/inline1/header.h +++ b/regression/cbmc/inline1/header.h @@ -6,4 +6,3 @@ static inline void f() { x=1; } - diff --git a/regression/cbmc/int-to-float2/main.c b/regression/cbmc/int-to-float2/main.c index ae817fabf69..5c095d2849e 100644 --- a/regression/cbmc/int-to-float2/main.c +++ b/regression/cbmc/int-to-float2/main.c @@ -44,7 +44,7 @@ int main(void) assert(castWithRounding(FE_DOWNWARD,x) == low); assert(castWithRounding(FE_DOWNWARD,-x) == -high); #endif - + assert(castWithRounding(FE_TOWARDZERO,x) == low); assert(castWithRounding(FE_TOWARDZERO,-x) == -low); #endif diff --git a/regression/cbmc/locations1/main.c b/regression/cbmc/locations1/main.c index 3b59c036d56..163cb1d5e74 100644 --- a/regression/cbmc/locations1/main.c +++ b/regression/cbmc/locations1/main.c @@ -35,4 +35,3 @@ int8_t StateMachines_testFlightAnalyzer(void) { int main() {} - diff --git a/regression/cbmc/noop1/main.c b/regression/cbmc/noop1/main.c index a24eb909bb1..5341fb34ad1 100644 --- a/regression/cbmc/noop1/main.c +++ b/regression/cbmc/noop1/main.c @@ -10,6 +10,6 @@ int main() { // http://msdn.microsoft.com/en-us/library/s6btaxcs%28v=vs.80%29.aspx // the arguments of __noop are _not_ evaluated - + __noop(some_function()); } diff --git a/regression/cbmc/null3/main.c b/regression/cbmc/null3/main.c index 4ec274503c4..7b948c939e2 100644 --- a/regression/cbmc/null3/main.c +++ b/regression/cbmc/null3/main.c @@ -20,4 +20,3 @@ int main() return 0; } - diff --git a/regression/cbmc/offsetof1/main.c b/regression/cbmc/offsetof1/main.c index bc6d6db14e9..392747e1aca 100644 --- a/regression/cbmc/offsetof1/main.c +++ b/regression/cbmc/offsetof1/main.c @@ -5,7 +5,7 @@ struct S int i; char ch; int j; // this gets aligned - + struct Ssub { int x, y; @@ -42,10 +42,10 @@ int main(void) assert((long int)&((struct S *)0)->array==16+4); assert((long int)&((struct S *)0)->array[1]==16+12); assert((long int)&((struct S *)0)->array[1].y==16+12+4); - + // these are _constants_! - #ifdef __GNUC__ + #ifdef __GNUC__ enum { E1 = __builtin_offsetof(struct S, ch) }; #endif diff --git a/regression/cbmc/pipe1/main.c b/regression/cbmc/pipe1/main.c index 17d282c945d..7bfb9f80f1d 100644 --- a/regression/cbmc/pipe1/main.c +++ b/regression/cbmc/pipe1/main.c @@ -13,7 +13,7 @@ int main() #ifdef _WIN32 int ret=_pipe(filedesc, 1000, O_BINARY); - #else + #else int ret=pipe(filedesc); #endif diff --git a/regression/cbmc/return5/main.c b/regression/cbmc/return5/main.c index 40f889b7978..ca143df9e00 100644 --- a/regression/cbmc/return5/main.c +++ b/regression/cbmc/return5/main.c @@ -39,6 +39,6 @@ int main() res1 = f1(a); assert(res0 == res1); /* <-- should fail */ - + return 0; } diff --git a/regression/cbmc/scanf1/main.c b/regression/cbmc/scanf1/main.c index 36ec6495594..55ca6a4af5f 100644 --- a/regression/cbmc/scanf1/main.c +++ b/regression/cbmc/scanf1/main.c @@ -12,7 +12,7 @@ int main(void) long int li=0; void *p=0; char buffer[10]; - + __CPROVER_scanf("%c", &c); __CPROVER_scanf("%hhd", &si); __CPROVER_scanf("%d", &i); @@ -34,4 +34,3 @@ int main(void) return 0; } - diff --git a/regression/cbmc/strchr1/main.c b/regression/cbmc/strchr1/main.c index a6ad943a1ab..b7ea6a92649 100644 --- a/regression/cbmc/strchr1/main.c +++ b/regression/cbmc/strchr1/main.c @@ -4,7 +4,7 @@ int main() { // "The terminating null character is considered to be part of the string." - + char arr[] = { 'a', 'a', 'a', 0}; assert(strchr(arr, 0) == arr + sizeof(arr) - 1); assert(strrchr(arr, 0) == arr + sizeof(arr) - 1); diff --git a/regression/cbmc/struct4/main.c b/regression/cbmc/struct4/main.c index c6f4dd7e2bd..6406255b45e 100644 --- a/regression/cbmc/struct4/main.c +++ b/regression/cbmc/struct4/main.c @@ -2,7 +2,7 @@ #ifdef PRINT #include -void assert(int cond) +void assert(int cond) { if(!cond) printf("assert failed!\n"); } #endif diff --git a/regression/cbmc/struct6/main.c b/regression/cbmc/struct6/main.c index 4bf4e892fb2..c83aeeff695 100644 --- a/regression/cbmc/struct6/main.c +++ b/regression/cbmc/struct6/main.c @@ -10,7 +10,7 @@ struct S int main() { struct S *p=malloc(sizeof(struct S)+10); - + p->x=1; p->a[0]=3; p->a[9]=3; diff --git a/regression/cbmc/struct7/main.c b/regression/cbmc/struct7/main.c index b9983f37509..45c5798a48e 100644 --- a/regression/cbmc/struct7/main.c +++ b/regression/cbmc/struct7/main.c @@ -7,7 +7,7 @@ struct my_struct void f(int *p) { int diff; - + diff=p-&s.array[0]; // should pass @@ -19,7 +19,7 @@ int main() int ind, x; ind=x; int *p=&s.array[ind]; - + if(ind>=0 && ind<=9) f(p); } diff --git a/regression/cbmc/struct8/main.c b/regression/cbmc/struct8/main.c index b16d954ec30..c8e65e7bcd0 100644 --- a/regression/cbmc/struct8/main.c +++ b/regression/cbmc/struct8/main.c @@ -6,11 +6,11 @@ struct X int main() { int aa, bb, cc; - + struct X foo; - + foo=(struct X) { aa, bb, cc }; - + assert(foo.a==aa); assert(foo.b==bb); assert(foo.c==cc); diff --git a/regression/cbmc/struct9/main.c b/regression/cbmc/struct9/main.c index 3c16aecdaa6..acc4b459a91 100644 --- a/regression/cbmc/struct9/main.c +++ b/regression/cbmc/struct9/main.c @@ -9,17 +9,17 @@ struct outer_struct { struct inner_struct inner; }; -void foo(struct inner_struct *inner) +void foo(struct inner_struct *inner) { assert(*(inner->GUARDp) != 1); } int main() { - struct outer_struct outer; + struct outer_struct outer; outer.GUARD = 2; outer.inner.GUARDp = &outer.GUARD; - + foo(&outer.inner); } diff --git a/regression/cbmc/switch1/main.c b/regression/cbmc/switch1/main.c index 197e17d7b16..cb69400a25d 100644 --- a/regression/cbmc/switch1/main.c +++ b/regression/cbmc/switch1/main.c @@ -1,7 +1,7 @@ int main() { int i; - + switch(i) { case 0: @@ -12,7 +12,7 @@ int main() case 2: assert(i==2); break; - + default: assert(i!=0 && i!=1 && i!=2); } diff --git a/regression/cbmc/switch2/main.c b/regression/cbmc/switch2/main.c index 173e5a7a3d7..41d8afa789d 100644 --- a/regression/cbmc/switch2/main.c +++ b/regression/cbmc/switch2/main.c @@ -6,7 +6,7 @@ int f(int j) { case 3: return 4; - + default: return 5; } @@ -15,15 +15,15 @@ int f(int j) int main() { int i; - + __CPROVER_assume(i==3 || i==4); - + switch(f(i)) { case 4: assert(i==3); break; - + case 5: assert(i==4); break; diff --git a/regression/cbmc/switch3/main.c b/regression/cbmc/switch3/main.c index c6e393d45ba..3fd83d24c23 100644 --- a/regression/cbmc/switch3/main.c +++ b/regression/cbmc/switch3/main.c @@ -3,15 +3,15 @@ char nondet_char(); int main() { char ch=nondet_char(); - + switch(ch) { case 'P': case 'p': assert(ch==80 || ch==112); break; - + default: - assert(ch!=80 && ch!=112); + assert(ch!=80 && ch!=112); } } diff --git a/regression/cbmc/switch4/main.c b/regression/cbmc/switch4/main.c index ed69fa3c776..b2337cbce06 100644 --- a/regression/cbmc/switch4/main.c +++ b/regression/cbmc/switch4/main.c @@ -6,7 +6,7 @@ main() { case 0: goto end; - + default: x = 0; } diff --git a/regression/cbmc/switch5/main.c b/regression/cbmc/switch5/main.c index 89222d1bcfb..17db2cd5ad2 100644 --- a/regression/cbmc/switch5/main.c +++ b/regression/cbmc/switch5/main.c @@ -1,13 +1,13 @@ int main() { unsigned int i, j; - + switch(i) { case 10: j=10; break; - + default:; j=i+1; } diff --git a/regression/cbmc/switch6/main.c b/regression/cbmc/switch6/main.c index e61cc2775a4..7e9e73261e5 100644 --- a/regression/cbmc/switch6/main.c +++ b/regression/cbmc/switch6/main.c @@ -5,14 +5,14 @@ enum { ASD1, ASD2 } e; int main() { const char *p; - + e=ASD1; - + p=({ const char *tmp; switch(e) { case ASD1: tmp="abc"; } tmp; }); - assert(p[0]=='a'); - assert(p[1]=='b'); - assert(p[2]=='c'); + assert(p[0]=='a'); + assert(p[1]=='b'); + assert(p[2]=='c'); assert(p[3]==0); } diff --git a/regression/cbmc/union1/main.c b/regression/cbmc/union1/main.c index 1eb6fa1e55a..5680e3ceebc 100644 --- a/regression/cbmc/union1/main.c +++ b/regression/cbmc/union1/main.c @@ -7,18 +7,18 @@ union u_type }; // rest of my_U should be zero -union u_type my_U = { .ch = 1 }; +union u_type my_U = { .ch = 1 }; int main() { // little and big endian case, assuming sizeof(int)==4 - assert(my_U.i==1 || my_U.i==0x01000000); + assert(my_U.i==1 || my_U.i==0x01000000); union u_type u; - + u.i=1; assert(u.i==1); - + u.ch=2; assert(u.ch==2); } diff --git a/regression/cbmc/union3/main.c b/regression/cbmc/union3/main.c index ffef14b306a..7a255cf6ca4 100644 --- a/regression/cbmc/union3/main.c +++ b/regression/cbmc/union3/main.c @@ -15,21 +15,21 @@ int main(void) #ifdef __GNUC__ int x; assert(my_func(x)==x); - + union my_U { int z; char ch; float f; } union_object; - + float some_float=1.5f; - + // This is the 'union constructor', which is // yet another gcc extension. // Visual Studio won't do it. union_object=(union my_U)some_float; - + assert(union_object.f==1.5f); #endif -} +} diff --git a/regression/cbmc/union5/main.c b/regression/cbmc/union5/main.c index c1cdd66560f..908ebba3297 100644 --- a/regression/cbmc/union5/main.c +++ b/regression/cbmc/union5/main.c @@ -7,7 +7,7 @@ union u_type int main() { // rest of my_U should be non-deterministic - union u_type my_U = { .ch = 1 }; + union u_type my_U = { .ch = 1 }; // should fail assert(my_U.i==1); diff --git a/regression/cbmc/va_list1/main.c b/regression/cbmc/va_list1/main.c index 6a5c0a625a2..4748baf01ab 100644 --- a/regression/cbmc/va_list1/main.c +++ b/regression/cbmc/va_list1/main.c @@ -6,15 +6,15 @@ int my_f(int x, ...) { __builtin_va_list list; __builtin_va_start(list, x); - + int value; unsigned i; - + for(i=0; ir == 10); } - diff --git a/regression/cpp-from-CVS/Constructor2/main.cpp b/regression/cpp-from-CVS/Constructor2/main.cpp index 0e63e9a8bdd..0dd3b7cdaf7 100644 --- a/regression/cpp-from-CVS/Constructor2/main.cpp +++ b/regression/cpp-from-CVS/Constructor2/main.cpp @@ -2,7 +2,7 @@ class t1 { public: int i; - + t1(); t1(int z); }; @@ -20,7 +20,7 @@ class t2 { public: int i; - + t2(); t2(int z); }; @@ -36,5 +36,5 @@ t2::t2(int z) int main() { t1 instance1(5); - assert(instance1.i==5); + assert(instance1.i==5); } diff --git a/regression/cpp-from-CVS/Constructor3/main.cpp b/regression/cpp-from-CVS/Constructor3/main.cpp index ab73ee687e1..68403e21ef9 100644 --- a/regression/cpp-from-CVS/Constructor3/main.cpp +++ b/regression/cpp-from-CVS/Constructor3/main.cpp @@ -14,4 +14,3 @@ int main() x a(5); assert(a.i==5); } - diff --git a/regression/cpp-from-CVS/Constructor4/main.cpp b/regression/cpp-from-CVS/Constructor4/main.cpp index 79a6b894426..d099a90572d 100644 --- a/regression/cpp-from-CVS/Constructor4/main.cpp +++ b/regression/cpp-from-CVS/Constructor4/main.cpp @@ -1,7 +1,7 @@ struct x { int *q; - + x(); }; diff --git a/regression/cpp-from-CVS/Constructor5/main.cpp b/regression/cpp-from-CVS/Constructor5/main.cpp index 929c3798d23..9d90aed92a4 100644 --- a/regression/cpp-from-CVS/Constructor5/main.cpp +++ b/regression/cpp-from-CVS/Constructor5/main.cpp @@ -2,7 +2,7 @@ class x { private: int i; - + public: x(); diff --git a/regression/cpp-from-CVS/Constructor6/main.cpp b/regression/cpp-from-CVS/Constructor6/main.cpp index d2112af27e0..a5f9a26f7a8 100644 --- a/regression/cpp-from-CVS/Constructor6/main.cpp +++ b/regression/cpp-from-CVS/Constructor6/main.cpp @@ -3,7 +3,7 @@ int counter=1; struct T { int z; - + T(); }; diff --git a/regression/cpp-from-CVS/Constructor9/main.cpp b/regression/cpp-from-CVS/Constructor9/main.cpp index 0bd5dd80574..0bf1f800562 100644 --- a/regression/cpp-from-CVS/Constructor9/main.cpp +++ b/regression/cpp-from-CVS/Constructor9/main.cpp @@ -29,7 +29,7 @@ int main() assert(a.b_array[1].i==1); B b_array[2]; - + assert(b_array[0].i==1); assert(b_array[1].i==1); } diff --git a/regression/cpp-from-CVS/Conversion1/main.cpp b/regression/cpp-from-CVS/Conversion1/main.cpp index ce1fe6952b1..586182a19c6 100644 --- a/regression/cpp-from-CVS/Conversion1/main.cpp +++ b/regression/cpp-from-CVS/Conversion1/main.cpp @@ -8,7 +8,7 @@ class T T(int i, int j):x(i) { } - + int x; }; @@ -18,7 +18,7 @@ int main() assert(unsigned(-1)==(unsigned)-1); assert(bool(10)); - + T t=T(2, 3); assert(t.x==2); } diff --git a/regression/cpp-from-CVS/Conversion10/main.cpp b/regression/cpp-from-CVS/Conversion10/main.cpp index e2abde74775..78ebff4a465 100644 --- a/regression/cpp-from-CVS/Conversion10/main.cpp +++ b/regression/cpp-from-CVS/Conversion10/main.cpp @@ -1,7 +1,7 @@ struct A {}; struct B { - explicit B(A&){} + explicit B(A&){} }; void test(const B& b){}; diff --git a/regression/cpp-from-CVS/Conversion6/main.cpp b/regression/cpp-from-CVS/Conversion6/main.cpp index c7636e73956..4feb9caeb5a 100644 --- a/regression/cpp-from-CVS/Conversion6/main.cpp +++ b/regression/cpp-from-CVS/Conversion6/main.cpp @@ -20,6 +20,6 @@ int main() assert((* ((A*)&b)).i == 1); // This works fine. int bi = func( * ((A*)&b)); // Satabs Ok. - // cbmc error + // cbmc error assert(bi == 1); } diff --git a/regression/cpp-from-CVS/Conversion_Operator1/main.cpp b/regression/cpp-from-CVS/Conversion_Operator1/main.cpp index 6b6e9d69881..757506d1d64 100644 --- a/regression/cpp-from-CVS/Conversion_Operator1/main.cpp +++ b/regression/cpp-from-CVS/Conversion_Operator1/main.cpp @@ -17,7 +17,7 @@ int main() int i1 = int(I1); assert(i1==1); - + Int I2(2); int i2 = (int&)I2; assert(i2==2); diff --git a/regression/cpp-from-CVS/Default_Arguments1/main.cpp b/regression/cpp-from-CVS/Default_Arguments1/main.cpp index 2e96e556430..2e3c96e423d 100644 --- a/regression/cpp-from-CVS/Default_Arguments1/main.cpp +++ b/regression/cpp-from-CVS/Default_Arguments1/main.cpp @@ -32,4 +32,3 @@ int main() { doit(); } - diff --git a/regression/cpp-from-CVS/Destructor1/main.cpp b/regression/cpp-from-CVS/Destructor1/main.cpp index c3c25d8f808..205da5fe5e0 100644 --- a/regression/cpp-from-CVS/Destructor1/main.cpp +++ b/regression/cpp-from-CVS/Destructor1/main.cpp @@ -15,6 +15,6 @@ int main() t1 instance1; assert(g==1); } - + assert(g==2); } diff --git a/regression/cpp-from-CVS/Destructor2/main.cpp b/regression/cpp-from-CVS/Destructor2/main.cpp index 8f0bbf2084c..8a09834a255 100644 --- a/regression/cpp-from-CVS/Destructor2/main.cpp +++ b/regression/cpp-from-CVS/Destructor2/main.cpp @@ -20,6 +20,6 @@ int main() } } - + assert(g==2); } diff --git a/regression/cpp-from-CVS/Destructor5/main.cpp b/regression/cpp-from-CVS/Destructor5/main.cpp index 5dde25b97e7..8a3d9bb4ff4 100644 --- a/regression/cpp-from-CVS/Destructor5/main.cpp +++ b/regression/cpp-from-CVS/Destructor5/main.cpp @@ -11,6 +11,6 @@ int main() const X *p=new X; // this is to work even though p is const, and the destructor - // isn't. + // isn't. delete p; } diff --git a/regression/cpp-from-CVS/Destructor_with_PtrMember/main.cpp b/regression/cpp-from-CVS/Destructor_with_PtrMember/main.cpp index fd3ee163c29..87aeca536dc 100644 --- a/regression/cpp-from-CVS/Destructor_with_PtrMember/main.cpp +++ b/regression/cpp-from-CVS/Destructor_with_PtrMember/main.cpp @@ -11,18 +11,18 @@ int main() { p=&c; p -> ~test_class(); - + assert(global==1); - + // The notation for explicit calls to destructors can be used regardless // of whether the type defines a destructor. This allows you to make such - // explicit calls without knowing if a destructor is defined for the type. + // explicit calls without knowing if a destructor is defined for the type. // An explicit call to a destructor where none is defined has no effect. typedef char TT; - + TT *q; q->~TT(); - + return 0; } diff --git a/regression/cpp-from-CVS/Exception1/main.cpp b/regression/cpp-from-CVS/Exception1/main.cpp index 2c065c75b18..dfaf154ab20 100644 --- a/regression/cpp-from-CVS/Exception1/main.cpp +++ b/regression/cpp-from-CVS/Exception1/main.cpp @@ -16,7 +16,7 @@ int main() throw (int)0; assert(0); } - + catch(int i) { // yes @@ -29,7 +29,7 @@ int main() { assert(0); } - + // example 2 try @@ -37,7 +37,7 @@ int main() throw (char)0; assert(0); } - + catch(int i) { assert(0); @@ -57,7 +57,7 @@ int main() throw whatnot(1); assert(0); } - + catch(int i) { assert(0); diff --git a/regression/cpp-from-CVS/Friend1/main.cpp b/regression/cpp-from-CVS/Friend1/main.cpp index eb7ef0c302e..b32e8c26ab1 100644 --- a/regression/cpp-from-CVS/Friend1/main.cpp +++ b/regression/cpp-from-CVS/Friend1/main.cpp @@ -10,7 +10,7 @@ class C T x=1; return x; } - + int base; }; @@ -18,5 +18,5 @@ int main() { C c(1); - assert(f()==1); + assert(f()==1); } diff --git a/regression/cpp-from-CVS/Friend6/main.cpp b/regression/cpp-from-CVS/Friend6/main.cpp index 66102b3b243..b5e2148fa08 100644 --- a/regression/cpp-from-CVS/Friend6/main.cpp +++ b/regression/cpp-from-CVS/Friend6/main.cpp @@ -13,7 +13,7 @@ class B { }; template -int A::get_i(B& b){return b.i;} +int A::get_i(B& b){return b.i;} int main() { diff --git a/regression/cpp-from-CVS/Function_Arguments3/main.cpp b/regression/cpp-from-CVS/Function_Arguments3/main.cpp index 131ced2710e..52860aae61a 100644 --- a/regression/cpp-from-CVS/Function_Arguments3/main.cpp +++ b/regression/cpp-from-CVS/Function_Arguments3/main.cpp @@ -25,7 +25,7 @@ int main() { f(0); assert(global==10); - + g((int *)0); assert(global==20); diff --git a/regression/cpp-from-CVS/Function_Arguments4/main.cpp b/regression/cpp-from-CVS/Function_Arguments4/main.cpp index db9d5eca420..82555544910 100644 --- a/regression/cpp-from-CVS/Function_Arguments4/main.cpp +++ b/regression/cpp-from-CVS/Function_Arguments4/main.cpp @@ -12,7 +12,7 @@ struct B B f(B b) { assert(i==11); - return b; + return b; } diff --git a/regression/cpp-from-CVS/Function_Pointer1/main.cpp b/regression/cpp-from-CVS/Function_Pointer1/main.cpp index 7dfa46f59a1..723671c5780 100644 --- a/regression/cpp-from-CVS/Function_Pointer1/main.cpp +++ b/regression/cpp-from-CVS/Function_Pointer1/main.cpp @@ -6,8 +6,8 @@ int f(int x) int main() { int (*p)(int); - + p=f; - + p(1); } diff --git a/regression/cpp-from-CVS/Implicit_Conversion2/main.cpp b/regression/cpp-from-CVS/Implicit_Conversion2/main.cpp index eba8dbd7463..0ab7eeeae49 100644 --- a/regression/cpp-from-CVS/Implicit_Conversion2/main.cpp +++ b/regression/cpp-from-CVS/Implicit_Conversion2/main.cpp @@ -7,7 +7,7 @@ char func1(const char& c) int main() { assert(func1((char)10)==10); - + int i(20); assert(func1((char)i)==20); diff --git a/regression/cpp-from-CVS/Implicit_Conversion4/main.cpp b/regression/cpp-from-CVS/Implicit_Conversion4/main.cpp index 9a8513de779..3c97123c83e 100644 --- a/regression/cpp-from-CVS/Implicit_Conversion4/main.cpp +++ b/regression/cpp-from-CVS/Implicit_Conversion4/main.cpp @@ -78,5 +78,5 @@ int main() const C& r6 = c2; assert(func1(r6)==50); assert(func3(r6)==50); - + } diff --git a/regression/cpp-from-CVS/Implicit_Conversion8/main.cpp b/regression/cpp-from-CVS/Implicit_Conversion8/main.cpp index a188ed2af0b..2d8bed0470f 100644 --- a/regression/cpp-from-CVS/Implicit_Conversion8/main.cpp +++ b/regression/cpp-from-CVS/Implicit_Conversion8/main.cpp @@ -37,4 +37,3 @@ int main() b_not(b1,b2); assert(b1.b != b2.b); } - diff --git a/regression/cpp-from-CVS/Implicit_Conversion9/main.cpp b/regression/cpp-from-CVS/Implicit_Conversion9/main.cpp index f826ddbc605..39dc405df5b 100644 --- a/regression/cpp-from-CVS/Implicit_Conversion9/main.cpp +++ b/regression/cpp-from-CVS/Implicit_Conversion9/main.cpp @@ -13,4 +13,3 @@ int main() { return 0; } - diff --git a/regression/cpp-from-CVS/Inheritance1/main.cpp b/regression/cpp-from-CVS/Inheritance1/main.cpp index 6e8b77c4d3e..f7c4cccd9c5 100644 --- a/regression/cpp-from-CVS/Inheritance1/main.cpp +++ b/regression/cpp-from-CVS/Inheritance1/main.cpp @@ -2,7 +2,7 @@ class b { public: int x; - + void f(); }; diff --git a/regression/cpp-from-CVS/Inheritance2/main.cpp b/regression/cpp-from-CVS/Inheritance2/main.cpp index bd6c4ab5865..c75d001b75e 100644 --- a/regression/cpp-from-CVS/Inheritance2/main.cpp +++ b/regression/cpp-from-CVS/Inheritance2/main.cpp @@ -26,9 +26,9 @@ int main() B b; b.i = 0; b.B::i++; - + b.A::i = 10; - + b.f(); assert(b.i == 2); assert(b.A::i == 11); diff --git a/regression/cpp-from-CVS/Linking1/main.cpp b/regression/cpp-from-CVS/Linking1/main.cpp index 0d70f66761e..6cd912dc4ab 100644 --- a/regression/cpp-from-CVS/Linking1/main.cpp +++ b/regression/cpp-from-CVS/Linking1/main.cpp @@ -5,9 +5,9 @@ extern int i; int main() { assert(i==1); - + T t; t.f(); - + assert(i==2); } diff --git a/regression/cpp-from-CVS/Linking1/module.h b/regression/cpp-from-CVS/Linking1/module.h index dd1235418b2..594df2edcb7 100644 --- a/regression/cpp-from-CVS/Linking1/module.h +++ b/regression/cpp-from-CVS/Linking1/module.h @@ -3,4 +3,3 @@ class T public: void f(); }; - diff --git a/regression/cpp-from-CVS/Linking1/test.desc b/regression/cpp-from-CVS/Linking1/test.desc index d7a65ef7f34..2449051ba1d 100644 --- a/regression/cpp-from-CVS/Linking1/test.desc +++ b/regression/cpp-from-CVS/Linking1/test.desc @@ -1,6 +1,6 @@ CORE main.cpp -module.cpp +module.cpp ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cpp-from-CVS/Linking2/test_link1.cpp b/regression/cpp-from-CVS/Linking2/test_link1.cpp index 12c4ff5dcb5..0d45e4fa116 100644 --- a/regression/cpp-from-CVS/Linking2/test_link1.cpp +++ b/regression/cpp-from-CVS/Linking2/test_link1.cpp @@ -6,7 +6,7 @@ extern int f(void); int main() { int z; - + x=z; assert(f()==z); } diff --git a/regression/cpp-from-CVS/Lvalue1/main.cpp b/regression/cpp-from-CVS/Lvalue1/main.cpp index a6ed23d71e6..5c2dbcc2c30 100644 --- a/regression/cpp-from-CVS/Lvalue1/main.cpp +++ b/regression/cpp-from-CVS/Lvalue1/main.cpp @@ -20,7 +20,7 @@ int main() // // It's not clear what the best is. Should this code be rejected? // Is the compatibility with gcc more important? - + assert(factory().get_i() == 0); - + } diff --git a/regression/cpp-from-CVS/Multiple_Inheritance2/main.cpp b/regression/cpp-from-CVS/Multiple_Inheritance2/main.cpp index ab83d1d60e9..cca4f3ce8da 100644 --- a/regression/cpp-from-CVS/Multiple_Inheritance2/main.cpp +++ b/regression/cpp-from-CVS/Multiple_Inheritance2/main.cpp @@ -12,4 +12,3 @@ int main() d.i = 10; assert(d.i == 10); } - diff --git a/regression/cpp-from-CVS/Overloading_Functions2/main.cpp b/regression/cpp-from-CVS/Overloading_Functions2/main.cpp index 9441d29ef93..2fec1d62fc3 100644 --- a/regression/cpp-from-CVS/Overloading_Functions2/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Functions2/main.cpp @@ -15,4 +15,3 @@ int main() C c; assert(f1(c)==false); } - diff --git a/regression/cpp-from-CVS/Overloading_Operators1/main.cpp b/regression/cpp-from-CVS/Overloading_Operators1/main.cpp index 8f3676a9acb..1dfeeebe1f6 100644 --- a/regression/cpp-from-CVS/Overloading_Operators1/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators1/main.cpp @@ -18,10 +18,10 @@ int main() T x; int temp; - + temp=x+2; assert(temp==2); - + temp=x-3; assert(temp==-3); } diff --git a/regression/cpp-from-CVS/Overloading_Operators11/main.cpp b/regression/cpp-from-CVS/Overloading_Operators11/main.cpp index f8994077ad6..c8ab83dbe71 100644 --- a/regression/cpp-from-CVS/Overloading_Operators11/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators11/main.cpp @@ -5,7 +5,7 @@ struct C { struct A { C c1; - + A():c1(false){} const C* operator->() const {return &c1;} }; diff --git a/regression/cpp-from-CVS/Overloading_Operators16/main.cpp b/regression/cpp-from-CVS/Overloading_Operators16/main.cpp index e909c927fe8..1ef26c04484 100644 --- a/regression/cpp-from-CVS/Overloading_Operators16/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators16/main.cpp @@ -8,7 +8,7 @@ class module_name operator unsigned int(); operator bool(); }; - + void f (module_name name) { (const char*) name; name .operator const char *(); diff --git a/regression/cpp-from-CVS/Overloading_Operators2/main.cpp b/regression/cpp-from-CVS/Overloading_Operators2/main.cpp index 829e0c620a4..9e58e301bd0 100644 --- a/regression/cpp-from-CVS/Overloading_Operators2/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators2/main.cpp @@ -7,19 +7,19 @@ class C { return base+x; } - + int operator [] (class Z &z) { return 0; } - + int base; }; int main() { C c(1); - + assert(c[0]==1); assert(c[2]==3); } diff --git a/regression/cpp-from-CVS/Overloading_Operators3/main.cpp b/regression/cpp-from-CVS/Overloading_Operators3/main.cpp index bf920e2e82d..9cbf9d66274 100644 --- a/regression/cpp-from-CVS/Overloading_Operators3/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators3/main.cpp @@ -4,4 +4,3 @@ int operator[](int *p, int i); int main() { } - diff --git a/regression/cpp-from-CVS/Overloading_Operators4/main.cpp b/regression/cpp-from-CVS/Overloading_Operators4/main.cpp index c77d4234a4d..74851a8b218 100644 --- a/regression/cpp-from-CVS/Overloading_Operators4/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators4/main.cpp @@ -6,7 +6,7 @@ struct X int i; int j; - + bool operator == (const struct X &o) { return i==o.i && diff --git a/regression/cpp-from-CVS/Overloading_Operators5/main.cpp b/regression/cpp-from-CVS/Overloading_Operators5/main.cpp index 241c4c289ae..5110a7aef0b 100644 --- a/regression/cpp-from-CVS/Overloading_Operators5/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators5/main.cpp @@ -8,7 +8,7 @@ struct X int i; int j; - + X &operator= (const struct X &r); }; @@ -23,9 +23,9 @@ void doit() X a, b; g=1; - + a=b; - + assert(g==2); } diff --git a/regression/cpp-from-CVS/Overloading_Operators6/main.cpp b/regression/cpp-from-CVS/Overloading_Operators6/main.cpp index c647267cf28..cd79b851225 100644 --- a/regression/cpp-from-CVS/Overloading_Operators6/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators6/main.cpp @@ -2,7 +2,7 @@ struct A { int i; A():i(1){} - + int& operator* () {return i;} int operator+ (int j){return i+j;} int operator~ (){return ~i;} @@ -18,7 +18,7 @@ struct A assert(a[2] == *a); assert(a == 1); } - + void func2() { A a; @@ -28,7 +28,7 @@ struct A assert((*this)[2] == *(*this)); assert((*this) == 1); } - + }; diff --git a/regression/cpp-from-CVS/Overloading_Operators9/main.cpp b/regression/cpp-from-CVS/Overloading_Operators9/main.cpp index c37c9baed18..2ad8eac075d 100644 --- a/regression/cpp-from-CVS/Overloading_Operators9/main.cpp +++ b/regression/cpp-from-CVS/Overloading_Operators9/main.cpp @@ -15,7 +15,7 @@ struct B struct A { - B b; + B b; B& operator->() { return b; diff --git a/regression/cpp-from-CVS/Pointer_Conversion3/main.cpp b/regression/cpp-from-CVS/Pointer_Conversion3/main.cpp index fd134cb0cb2..7a39cde597d 100644 --- a/regression/cpp-from-CVS/Pointer_Conversion3/main.cpp +++ b/regression/cpp-from-CVS/Pointer_Conversion3/main.cpp @@ -1,6 +1,6 @@ struct A { int i; - + }; struct B diff --git a/regression/cpp-from-CVS/Pointer_To_Member5/main.cpp b/regression/cpp-from-CVS/Pointer_To_Member5/main.cpp index 6ed723b6761..7aa906ae1de 100644 --- a/regression/cpp-from-CVS/Pointer_To_Member5/main.cpp +++ b/regression/cpp-from-CVS/Pointer_To_Member5/main.cpp @@ -10,7 +10,7 @@ struct B A* pa; int (A::* pmethod)(); B(A* pa, int (A::* pmethod)()):pa(pa),pmethod(pmethod){} - int eval(){return (pa->*pmethod)();} + int eval(){return (pa->*pmethod)();} }; int main() diff --git a/regression/cpp-from-CVS/Protection1/main.cpp b/regression/cpp-from-CVS/Protection1/main.cpp index 405df7f7363..cdecf5b6c59 100644 --- a/regression/cpp-from-CVS/Protection1/main.cpp +++ b/regression/cpp-from-CVS/Protection1/main.cpp @@ -9,4 +9,3 @@ class A class B: A { }; - diff --git a/regression/cpp-from-CVS/Protection3/main.cpp b/regression/cpp-from-CVS/Protection3/main.cpp index 58021fcd369..4938a6831ca 100644 --- a/regression/cpp-from-CVS/Protection3/main.cpp +++ b/regression/cpp-from-CVS/Protection3/main.cpp @@ -1,7 +1,7 @@ class A { int i; - + public: class B { diff --git a/regression/cpp-from-CVS/Protection4/main.cpp b/regression/cpp-from-CVS/Protection4/main.cpp index 009f17dc3eb..08bf0c0a00a 100644 --- a/regression/cpp-from-CVS/Protection4/main.cpp +++ b/regression/cpp-from-CVS/Protection4/main.cpp @@ -10,4 +10,3 @@ class B: public A void set(int i){this->i = i;} int get() const {return i;} }; - diff --git a/regression/cpp-from-CVS/Protection5/main.cpp b/regression/cpp-from-CVS/Protection5/main.cpp index 5546308060f..0922af3797d 100644 --- a/regression/cpp-from-CVS/Protection5/main.cpp +++ b/regression/cpp-from-CVS/Protection5/main.cpp @@ -6,7 +6,7 @@ class A class B: A { - + }; void set_one(A& a) diff --git a/regression/cpp-from-CVS/Protection6/main.cpp b/regression/cpp-from-CVS/Protection6/main.cpp index b350c734a79..ae2a646f168 100644 --- a/regression/cpp-from-CVS/Protection6/main.cpp +++ b/regression/cpp-from-CVS/Protection6/main.cpp @@ -6,4 +6,3 @@ int main() { A::func(); } - diff --git a/regression/cpp-from-CVS/Protection7/main.cpp b/regression/cpp-from-CVS/Protection7/main.cpp index ba752641a13..a96487a2ed3 100644 --- a/regression/cpp-from-CVS/Protection7/main.cpp +++ b/regression/cpp-from-CVS/Protection7/main.cpp @@ -4,12 +4,12 @@ struct A A(){}; protected: A(int i):i(i){}; - + }; struct B: A { - B():A(0){} + B():A(0){} }; B b; diff --git a/regression/cpp-from-CVS/Protection8/main.cpp b/regression/cpp-from-CVS/Protection8/main.cpp index c4765594553..6db34b0320e 100644 --- a/regression/cpp-from-CVS/Protection8/main.cpp +++ b/regression/cpp-from-CVS/Protection8/main.cpp @@ -5,7 +5,7 @@ struct A int get_i(){return i;} A(int i):i(i){}; - + }; struct B: A diff --git a/regression/cpp-from-CVS/Qualifier1/main.cpp b/regression/cpp-from-CVS/Qualifier1/main.cpp index 29b6c68fb7f..674220824a9 100644 --- a/regression/cpp-from-CVS/Qualifier1/main.cpp +++ b/regression/cpp-from-CVS/Qualifier1/main.cpp @@ -7,6 +7,6 @@ struct B void f() { A::a = 1; // ill-formed - + } }; diff --git a/regression/cpp-from-CVS/Qualifier2/main.cpp b/regression/cpp-from-CVS/Qualifier2/main.cpp index 3da0df8490e..1fff2ce8662 100644 --- a/regression/cpp-from-CVS/Qualifier2/main.cpp +++ b/regression/cpp-from-CVS/Qualifier2/main.cpp @@ -20,5 +20,5 @@ int main() assert(B::i == 2); obj.A::i++; assert(A::i == 1); - + } diff --git a/regression/cpp-from-CVS/Reference1/main.cpp b/regression/cpp-from-CVS/Reference1/main.cpp index ba9f94907ee..b14812ada8f 100644 --- a/regression/cpp-from-CVS/Reference1/main.cpp +++ b/regression/cpp-from-CVS/Reference1/main.cpp @@ -8,15 +8,15 @@ void function(int &ref) int main() { int &r=g; - + r=1; - + assert(g==1); - + function(r); - + assert(g==2); - + // ?: does produce an l-value, apparently int &s=g?r:g; } diff --git a/regression/cpp-from-CVS/Reference2/main.cpp b/regression/cpp-from-CVS/Reference2/main.cpp index cbdb2304f78..69c74c1f18e 100644 --- a/regression/cpp-from-CVS/Reference2/main.cpp +++ b/regression/cpp-from-CVS/Reference2/main.cpp @@ -15,12 +15,12 @@ int main() function()=2; assert(g==2); - { + { int *p=&g; int &r=*p; assert(r==2); } - + { X x; X *p=&x; diff --git a/regression/cpp-from-CVS/Reference6/main.cpp b/regression/cpp-from-CVS/Reference6/main.cpp index 145b160e0b3..cb407b9bb13 100644 --- a/regression/cpp-from-CVS/Reference6/main.cpp +++ b/regression/cpp-from-CVS/Reference6/main.cpp @@ -1,8 +1,8 @@ class X { -public: +public: int x; - + X():x(0) { } @@ -20,6 +20,6 @@ int main() y.x=10; r()=y; - + assert(g.x==10); } diff --git a/regression/cpp-from-CVS/Resolver5/main.cpp b/regression/cpp-from-CVS/Resolver5/main.cpp index cb005bf98a4..f0584280047 100644 --- a/regression/cpp-from-CVS/Resolver5/main.cpp +++ b/regression/cpp-from-CVS/Resolver5/main.cpp @@ -13,6 +13,6 @@ int main() obj1.i = 200; assert(func(obj1) == 200); // Argument-dependant name lookup - + return 0; } diff --git a/regression/cpp-from-CVS/Resolver8/main.cpp b/regression/cpp-from-CVS/Resolver8/main.cpp index 7b2c7084afb..bff2111885a 100644 --- a/regression/cpp-from-CVS/Resolver8/main.cpp +++ b/regression/cpp-from-CVS/Resolver8/main.cpp @@ -11,5 +11,3 @@ int main() { assert(func(1)); } - - diff --git a/regression/cpp-from-CVS/STL1/main.cpp b/regression/cpp-from-CVS/STL1/main.cpp index eb0b426f7e5..065d7d250e2 100644 --- a/regression/cpp-from-CVS/STL1/main.cpp +++ b/regression/cpp-from-CVS/STL1/main.cpp @@ -19,24 +19,24 @@ void test_vector() assert(*int_vector.begin()==1); it=int_vector.begin(); assert(*it==1); - - int_vector.pop_back(); - int_vector.pop_back(); + + int_vector.pop_back(); + int_vector.pop_back(); assert(int_vector.empty()); } void test_list() { std::list int_list; - + int_list.push_back(1); int_list.push_back(2); assert(int_list.front()==1); assert(int_list.back()==2); assert(*int_list.begin()==1); - - int_list.pop_back(); - int_list.pop_back(); + + int_list.pop_back(); + int_list.pop_back(); assert(int_list.empty()); } @@ -53,7 +53,7 @@ int main() case 0: test_vector(); break; case 1: test_list(); break; case 2: test_set(); break; - + default:; } } diff --git a/regression/cpp-from-CVS/STL2/main.cpp b/regression/cpp-from-CVS/STL2/main.cpp index 99dfd37f500..e382495df27 100644 --- a/regression/cpp-from-CVS/STL2/main.cpp +++ b/regression/cpp-from-CVS/STL2/main.cpp @@ -13,7 +13,7 @@ int main() v.push_back(nondet_int()); vector::iterator it; - + for(it = v.begin(); it != v.end(); it++) if(*it == 10) v.erase(it); } diff --git a/regression/cpp-from-CVS/Static_Member1/main.cpp b/regression/cpp-from-CVS/Static_Member1/main.cpp index 28cc8e6c020..782d57862d7 100644 --- a/regression/cpp-from-CVS/Static_Member1/main.cpp +++ b/regression/cpp-from-CVS/Static_Member1/main.cpp @@ -4,7 +4,7 @@ class B static int A1; static int A2; static const int A3=20; - + // the const ones are good as array size int table[A3]; }; diff --git a/regression/cpp-from-CVS/Templates15/main.cpp b/regression/cpp-from-CVS/Templates15/main.cpp index 3df15d7281e..6e925db41b7 100644 --- a/regression/cpp-from-CVS/Templates15/main.cpp +++ b/regression/cpp-from-CVS/Templates15/main.cpp @@ -5,4 +5,3 @@ struct A { template struct A; - diff --git a/regression/cpp-from-CVS/Templates3/main.cpp b/regression/cpp-from-CVS/Templates3/main.cpp index 5e1ccb4c1e1..13250692098 100644 --- a/regression/cpp-from-CVS/Templates3/main.cpp +++ b/regression/cpp-from-CVS/Templates3/main.cpp @@ -3,7 +3,7 @@ class int_array { public: int array[size]; - + int read(unsigned int x) { assert(x(3)); } - - + + bool t; T1():t(false) { } }; @@ -29,7 +29,7 @@ class T1 int main() { T1 x; - + x.g(); assert(1==x.f(1)); assert(true==x.f(true)); diff --git a/regression/cpp-from-CVS/Templates6/main.cpp b/regression/cpp-from-CVS/Templates6/main.cpp index 383b562f6cf..48169e50a7f 100644 --- a/regression/cpp-from-CVS/Templates6/main.cpp +++ b/regression/cpp-from-CVS/Templates6/main.cpp @@ -34,7 +34,7 @@ int main() assert(g==20); { - D d; + D d; assert(g==10); } diff --git a/regression/cpp-from-CVS/Templates8/main.cpp b/regression/cpp-from-CVS/Templates8/main.cpp index c1208e17b47..69d92bb3a45 100644 --- a/regression/cpp-from-CVS/Templates8/main.cpp +++ b/regression/cpp-from-CVS/Templates8/main.cpp @@ -9,5 +9,5 @@ struct A int main() { int v = A::some_function(10); - assert(v==10); + assert(v==10); } diff --git a/regression/cpp-from-CVS/Templates9/main.cpp b/regression/cpp-from-CVS/Templates9/main.cpp index 801956cce23..8fd52766b70 100644 --- a/regression/cpp-from-CVS/Templates9/main.cpp +++ b/regression/cpp-from-CVS/Templates9/main.cpp @@ -33,7 +33,7 @@ int main() { A obj0; // general one assert(obj0.a == 0); - + A obj1; // specialized assert(obj1.a == 1); diff --git a/regression/cpp-from-CVS/Temporary2/main.cpp b/regression/cpp-from-CVS/Temporary2/main.cpp index bd0cc8d97a9..ffeee9869c9 100644 --- a/regression/cpp-from-CVS/Temporary2/main.cpp +++ b/regression/cpp-from-CVS/Temporary2/main.cpp @@ -8,7 +8,7 @@ class X X(int i):z(i) { } - + int z; }; diff --git a/regression/cpp-from-CVS/Typecast1/main.cpp b/regression/cpp-from-CVS/Typecast1/main.cpp index e4da7636758..f510200b81e 100644 --- a/regression/cpp-from-CVS/Typecast1/main.cpp +++ b/regression/cpp-from-CVS/Typecast1/main.cpp @@ -1,6 +1,6 @@ int main() { const int *p; - + p=(int *)0; } diff --git a/regression/cpp-from-CVS/Vector1/main.cpp b/regression/cpp-from-CVS/Vector1/main.cpp index ea46937b9d5..57a16592dd9 100644 --- a/regression/cpp-from-CVS/Vector1/main.cpp +++ b/regression/cpp-from-CVS/Vector1/main.cpp @@ -5,7 +5,7 @@ using namespace std; void sort(vector& c) { if (c.begin() == c.end()) return; - + for(int i=0; i < c.size(); i++) { for(vector::iterator it = c.begin(); @@ -17,7 +17,7 @@ void sort(vector& c) if(it_inc == c.end()) break; - + if(it_inc < it) { vector::value_type tmp = * it; @@ -43,7 +43,7 @@ int main() { vector::iterator it_inc = it; it_inc++; - + if(it_inc == vec.end()) break; __CPROVER_assert(*it <= *it_inc, "sorting error"); } diff --git a/regression/cpp-from-CVS/for1/main.cpp b/regression/cpp-from-CVS/for1/main.cpp index b458495089e..4db76dd1179 100644 --- a/regression/cpp-from-CVS/for1/main.cpp +++ b/regression/cpp-from-CVS/for1/main.cpp @@ -5,5 +5,5 @@ int main() { assert(i<10); } - + } diff --git a/regression/cpp-from-CVS/new1/main.cpp b/regression/cpp-from-CVS/new1/main.cpp index e8baa923357..e0c73bb2a2a 100644 --- a/regression/cpp-from-CVS/new1/main.cpp +++ b/regression/cpp-from-CVS/new1/main.cpp @@ -1,22 +1,22 @@ void single_object() { int *p; - + p=new int(2); assert(*p==2); - + delete p; } void array() { int *q; - + q=new int[100]; - + q[50]=1; - + // _must_ use delete[] here delete[] q; } diff --git a/regression/cpp-from-CVS/reinterpret_cast1/test.desc b/regression/cpp-from-CVS/reinterpret_cast1/test.desc index 8fd158f00f4..5249662e6aa 100644 --- a/regression/cpp-from-CVS/reinterpret_cast1/test.desc +++ b/regression/cpp-from-CVS/reinterpret_cast1/test.desc @@ -1,6 +1,6 @@ CORE main.cpp ---little-endian +--little-endian ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cpp-from-CVS/reinterpret_cast2/main.cpp b/regression/cpp-from-CVS/reinterpret_cast2/main.cpp index ee85ab4e50d..bfe183eeaab 100644 --- a/regression/cpp-from-CVS/reinterpret_cast2/main.cpp +++ b/regression/cpp-from-CVS/reinterpret_cast2/main.cpp @@ -1,15 +1,15 @@ struct A { int* pi; - + }; int main() { A a; const A* cpa = &a; - + int* ptr = reinterpret_cast(cpa->pi); return 0; - + } diff --git a/regression/cpp-from-CVS/static_cast1/main.cpp b/regression/cpp-from-CVS/static_cast1/main.cpp index 08ce2224608..0e06d85ac00 100644 --- a/regression/cpp-from-CVS/static_cast1/main.cpp +++ b/regression/cpp-from-CVS/static_cast1/main.cpp @@ -4,6 +4,6 @@ int main() double xd=2.3; int xi=static_cast(xd); - + assert(xi==2); } diff --git a/regression/cpp-from-CVS/struct1/main.cpp b/regression/cpp-from-CVS/struct1/main.cpp index 6cf4c695aea..780ee20fd4c 100644 --- a/regression/cpp-from-CVS/struct1/main.cpp +++ b/regression/cpp-from-CVS/struct1/main.cpp @@ -33,7 +33,7 @@ void f() int main() { int z; - + z=sizeof(struct AA); } diff --git a/regression/cpp-from-CVS/typecast_ambiguity3/main.cpp b/regression/cpp-from-CVS/typecast_ambiguity3/main.cpp index 5359e2fb494..ad03e797cf4 100644 --- a/regression/cpp-from-CVS/typecast_ambiguity3/main.cpp +++ b/regression/cpp-from-CVS/typecast_ambiguity3/main.cpp @@ -6,7 +6,7 @@ int main() // this is to parse as (bool(i)) & 0x1fff // and not as bool(i&0x1fff) - + assert(sizeof((bool)(i) & 0x1fff)==sizeof(int)); return 0; diff --git a/regression/cpp-from-CVS/typename1/main.cpp b/regression/cpp-from-CVS/typename1/main.cpp index 8afb43ca5a4..fe91f31bbc6 100644 --- a/regression/cpp-from-CVS/typename1/main.cpp +++ b/regression/cpp-from-CVS/typename1/main.cpp @@ -8,17 +8,17 @@ template class Y { public: typename X::T g; - + void f() { typename X::T l; - + } }; int main() { Y o; - + o.g=1; } diff --git a/regression/cpp-from-CVS/typename2/main.cpp b/regression/cpp-from-CVS/typename2/main.cpp index f826ddbc605..39dc405df5b 100644 --- a/regression/cpp-from-CVS/typename2/main.cpp +++ b/regression/cpp-from-CVS/typename2/main.cpp @@ -13,4 +13,3 @@ int main() { return 0; } - diff --git a/regression/cpp-from-CVS/union1/main.cpp b/regression/cpp-from-CVS/union1/main.cpp index f4c4ad9513a..f112a5e8653 100644 --- a/regression/cpp-from-CVS/union1/main.cpp +++ b/regression/cpp-from-CVS/union1/main.cpp @@ -6,7 +6,7 @@ int main() union { int a; - char b; + char b; }; a = 'z'; diff --git a/regression/cpp-from-CVS/virtual1/main.cpp b/regression/cpp-from-CVS/virtual1/main.cpp index e3f77dedd47..540af426a25 100644 --- a/regression/cpp-from-CVS/virtual1/main.cpp +++ b/regression/cpp-from-CVS/virtual1/main.cpp @@ -7,9 +7,9 @@ class A { g=1; } - + int mA; - + A(); }; @@ -30,7 +30,7 @@ class B: public A g=2; mB=3; } - + int mB; }; @@ -38,11 +38,11 @@ int main() { B b; A *p; - + p=&b; - + p->f(); - + assert(g==2); assert(b.mB==3); } diff --git a/regression/cpp-from-CVS/virtual13/main.cpp b/regression/cpp-from-CVS/virtual13/main.cpp index a0a5e841b29..8484831ef0c 100644 --- a/regression/cpp-from-CVS/virtual13/main.cpp +++ b/regression/cpp-from-CVS/virtual13/main.cpp @@ -10,4 +10,3 @@ int main(int argc, char* argv[]) assert(((A&)c2).f() == ((B&)c2).f()); return 0; } - diff --git a/regression/cpp-from-CVS/virtual2/main.cpp b/regression/cpp-from-CVS/virtual2/main.cpp index 679085f3769..9ef8f7de453 100644 --- a/regression/cpp-from-CVS/virtual2/main.cpp +++ b/regression/cpp-from-CVS/virtual2/main.cpp @@ -4,7 +4,7 @@ class X { public: virtual int f(); - + int m; }; @@ -21,8 +21,8 @@ class Y:public X int main() { Y y; - + y.f(); - + assert(g==10); } diff --git a/regression/cpp/Address_of_Method2/main.cpp b/regression/cpp/Address_of_Method2/main.cpp index 1e3f0f2636f..aed7a46d386 100644 --- a/regression/cpp/Address_of_Method2/main.cpp +++ b/regression/cpp/Address_of_Method2/main.cpp @@ -11,7 +11,7 @@ int main() { x a; void *p; - + // this should fail p=a.f; } diff --git a/regression/cpp/Address_of_Method3/main.cpp b/regression/cpp/Address_of_Method3/main.cpp index c1bf6e2cb65..ffad3b91fb7 100644 --- a/regression/cpp/Address_of_Method3/main.cpp +++ b/regression/cpp/Address_of_Method3/main.cpp @@ -2,7 +2,7 @@ struct x { void f(); void f(int); - + }; void x::f() diff --git a/regression/cpp/Bit_fields1/main.cpp b/regression/cpp/Bit_fields1/main.cpp index 888d0247c54..435da18867c 100644 --- a/regression/cpp/Bit_fields1/main.cpp +++ b/regression/cpp/Bit_fields1/main.cpp @@ -9,16 +9,16 @@ struct some_struct { // an anonymous bitfield signed int :2; - + // with typedef INT x:1; - + // made of sizeof unsigned int abc: sizeof(int); // enums are integers! some_enum_type enum_field1 : 5; - + // and good as field sizes some_enum_type enum_field2 : E1; } X; diff --git a/regression/cpp/Friend2/main.cpp b/regression/cpp/Friend2/main.cpp index a03a7eb7806..ceeb4be689c 100644 --- a/regression/cpp/Friend2/main.cpp +++ b/regression/cpp/Friend2/main.cpp @@ -8,7 +8,7 @@ class X X aa; aa.x=1; } - + public: X() { } }; diff --git a/regression/cpp/Function_Overloading1/main.cpp b/regression/cpp/Function_Overloading1/main.cpp index 4be1d167dd6..de23c697a2c 100644 --- a/regression/cpp/Function_Overloading1/main.cpp +++ b/regression/cpp/Function_Overloading1/main.cpp @@ -9,7 +9,7 @@ namespace std { extern "C" { int abs(int) __attribute__((nothrow)) ; } - extern "C++" { + extern "C++" { inline long abs(long n) __attribute__((nothrow)); inline long long abs(long long n) __attribute__((nothrow)); } @@ -25,4 +25,3 @@ int main(int argc, char* argv[]) return 1; return 0; } - diff --git a/regression/cpp/Function_Overloading2/main.cpp b/regression/cpp/Function_Overloading2/main.cpp index b68fb37f5f7..06204bf75ed 100644 --- a/regression/cpp/Function_Overloading2/main.cpp +++ b/regression/cpp/Function_Overloading2/main.cpp @@ -29,4 +29,3 @@ int main(int argc, char* argv[]) if(fabs(x) >= 50) return 0; } - diff --git a/regression/cpp/Method_qualifier1/main.cpp b/regression/cpp/Method_qualifier1/main.cpp index 0bde6744ea8..33479b6ee6d 100644 --- a/regression/cpp/Method_qualifier1/main.cpp +++ b/regression/cpp/Method_qualifier1/main.cpp @@ -15,7 +15,7 @@ int main() const my_class &zz_const=zz; volatile my_class &zz_volatile=zz; const volatile my_class &zz_const_volatile=zz; - + assert(zz.my_method()==1); assert(zz_const.my_method()==2); assert(zz_volatile.my_method()==3); diff --git a/regression/cpp/ModeC2/main.cpp b/regression/cpp/ModeC2/main.cpp index e2ef4a07da3..e7b0ee799f8 100644 --- a/regression/cpp/ModeC2/main.cpp +++ b/regression/cpp/ModeC2/main.cpp @@ -22,7 +22,7 @@ namespace SOME extern "C" void somef(char) { } - + extern "C++" void somef(int) { } diff --git a/regression/cpp/Pointer_Conversion2/main.cpp b/regression/cpp/Pointer_Conversion2/main.cpp index e988d4b9d46..3b10b78a6d5 100644 --- a/regression/cpp/Pointer_Conversion2/main.cpp +++ b/regression/cpp/Pointer_Conversion2/main.cpp @@ -6,7 +6,7 @@ int main() int some_struct::* ptr2; // this is a member pointer int (some_struct::*ptr3)(int); // this is a pointer to a method int (*ptr4)(int); // function pointer - + // The number '0' can be converted to any pointer ptr1=0; ptr2=0; diff --git a/regression/cpp/Qualifiers_In_Template_Specialisation1/main.cpp b/regression/cpp/Qualifiers_In_Template_Specialisation1/main.cpp index 25cf6b9bd4e..20af2cb6769 100644 --- a/regression/cpp/Qualifiers_In_Template_Specialisation1/main.cpp +++ b/regression/cpp/Qualifiers_In_Template_Specialisation1/main.cpp @@ -13,4 +13,3 @@ int main(void) { return 0; } - diff --git a/regression/cpp/Resolver1/main.cpp b/regression/cpp/Resolver1/main.cpp index 91620c92389..8624a0cd366 100644 --- a/regression/cpp/Resolver1/main.cpp +++ b/regression/cpp/Resolver1/main.cpp @@ -4,9 +4,9 @@ class T T() { } - + typedef int my_type; - + void f() { T::my_type x; diff --git a/regression/cpp/Resolver12/main.cpp b/regression/cpp/Resolver12/main.cpp index 8f3c5bebff0..a21acbceadc 100644 --- a/regression/cpp/Resolver12/main.cpp +++ b/regression/cpp/Resolver12/main.cpp @@ -5,4 +5,3 @@ int main() A a; a.x; // bad } - diff --git a/regression/cpp/Resolver4/main.cpp b/regression/cpp/Resolver4/main.cpp index 66b3221df2f..2e862e9a04b 100644 --- a/regression/cpp/Resolver4/main.cpp +++ b/regression/cpp/Resolver4/main.cpp @@ -7,4 +7,3 @@ int main() { A::f(0); } - diff --git a/regression/cpp/Scope1/main.cpp b/regression/cpp/Scope1/main.cpp index 3d022c0e3a1..6c55979eca1 100644 --- a/regression/cpp/Scope1/main.cpp +++ b/regression/cpp/Scope1/main.cpp @@ -7,7 +7,7 @@ class A public: typedef int tt; }; - + class C { public: diff --git a/regression/cpp/Template_Instantiation2/main.cpp b/regression/cpp/Template_Instantiation2/main.cpp index 5fead23248b..244d242732e 100644 --- a/regression/cpp/Template_Instantiation2/main.cpp +++ b/regression/cpp/Template_Instantiation2/main.cpp @@ -6,5 +6,3 @@ public : template<> int c::f00(const char*); - - diff --git a/regression/cpp/Template_Instantiation3/main.cpp b/regression/cpp/Template_Instantiation3/main.cpp index 066719e1187..0e01d2f2adf 100644 --- a/regression/cpp/Template_Instantiation3/main.cpp +++ b/regression/cpp/Template_Instantiation3/main.cpp @@ -18,7 +18,7 @@ struct sc_ufixed const sc_ufixed<1, 1> one(1U); int main (void) { - //const sc_ufixed<1, 1> one(1U); + //const sc_ufixed<1, 1> one(1U); one.multiply(one); return 0; } diff --git a/regression/cpp/Template_Instantiation4/main.cpp b/regression/cpp/Template_Instantiation4/main.cpp index d1f3dfe9295..36746126b0b 100644 --- a/regression/cpp/Template_Instantiation4/main.cpp +++ b/regression/cpp/Template_Instantiation4/main.cpp @@ -4,7 +4,7 @@ class X { X() { } - + static void some_func() { // This is an unbounded expansion, diff --git a/regression/cpp/Template_Instantiation5/main.cpp b/regression/cpp/Template_Instantiation5/main.cpp index 9875dd52404..1d71d999e69 100644 --- a/regression/cpp/Template_Instantiation5/main.cpp +++ b/regression/cpp/Template_Instantiation5/main.cpp @@ -14,7 +14,7 @@ class template_test //printf ("elem is '%c' \n", elem); return elem; } - + void add(void) { int c = elem + elem; diff --git a/regression/cpp/Trailing_Return_Type1/main.cpp b/regression/cpp/Trailing_Return_Type1/main.cpp index 6db117efe50..45531ec5d66 100644 --- a/regression/cpp/Trailing_Return_Type1/main.cpp +++ b/regression/cpp/Trailing_Return_Type1/main.cpp @@ -16,7 +16,7 @@ class some_class return x + 1; } #endif - + // template function template static auto f003(int x) -> someT diff --git a/regression/cpp/Unary_Function_Overload1/main.cpp b/regression/cpp/Unary_Function_Overload1/main.cpp index 951be62b468..da623789a9d 100644 --- a/regression/cpp/Unary_Function_Overload1/main.cpp +++ b/regression/cpp/Unary_Function_Overload1/main.cpp @@ -13,4 +13,3 @@ int main (void) { return 1; } - diff --git a/regression/cpp/Unary_Function_Overload2/main.cpp b/regression/cpp/Unary_Function_Overload2/main.cpp index 25e562ced50..732ba2cc5c6 100644 --- a/regression/cpp/Unary_Function_Overload2/main.cpp +++ b/regression/cpp/Unary_Function_Overload2/main.cpp @@ -13,4 +13,3 @@ int main (void) { return 1; } - diff --git a/regression/cpp/Unary_Function_Overload3/main.cpp b/regression/cpp/Unary_Function_Overload3/main.cpp index a09edff1318..58b9a139c8a 100644 --- a/regression/cpp/Unary_Function_Overload3/main.cpp +++ b/regression/cpp/Unary_Function_Overload3/main.cpp @@ -10,4 +10,3 @@ int main (void) { return 1; } - diff --git a/regression/cpp/bitwise_and1/main.cpp b/regression/cpp/bitwise_and1/main.cpp index 522e9ed30a2..c26474125bd 100644 --- a/regression/cpp/bitwise_and1/main.cpp +++ b/regression/cpp/bitwise_and1/main.cpp @@ -7,7 +7,7 @@ int main() // This should be converted into a bit-wise AND // (not an address-of). i=(intx)&i; - + // This is an address-of. i=(long int)&i; } diff --git a/regression/cpp/enum1/main.cpp b/regression/cpp/enum1/main.cpp index b49c168dca5..e593bc7eda0 100644 --- a/regression/cpp/enum1/main.cpp +++ b/regression/cpp/enum1/main.cpp @@ -27,4 +27,3 @@ int main() namespace whereever { enum some_tag { something }; } enum whereever::some_tag whatnot = whereever::something; - diff --git a/regression/cpp/enum4/main.cpp b/regression/cpp/enum4/main.cpp index 172868b6b4a..d3f9ed38ff7 100644 --- a/regression/cpp/enum4/main.cpp +++ b/regression/cpp/enum4/main.cpp @@ -6,6 +6,6 @@ typedef enum enumname enumname; int main() { enumname x; - + x=ASD; } diff --git a/regression/cpp/enum5/main.cpp b/regression/cpp/enum5/main.cpp index ce70e9edfd3..3921e5c185c 100644 --- a/regression/cpp/enum5/main.cpp +++ b/regression/cpp/enum5/main.cpp @@ -19,13 +19,13 @@ int main() // conversion from int assert(IMPH_STATE(2)==IMPH_BGF_STOPPED); - + // comparison with int assert(IMPH_BGF_STOPPED==2); - + // implicit conversion to int int z= IMPH_ENABLED | IMPH_BGF_STOPPED; - + // operator overloading IMPH_STATE x = IMPH_ENABLED & IMPH_BGF_STOPPED; assert(x==IMPH_BGF_STOPPED); diff --git a/regression/cpp/enum8/main.cpp b/regression/cpp/enum8/main.cpp index 23257b30dc9..b948ef723b0 100644 --- a/regression/cpp/enum8/main.cpp +++ b/regression/cpp/enum8/main.cpp @@ -39,4 +39,3 @@ int main() assert(f(some_struct_var.e1)==1); assert(f(some_struct_var.e2)==2); } - diff --git a/regression/cpp/lvalue1/main.cpp b/regression/cpp/lvalue1/main.cpp index ced96f1e2eb..f6977c20167 100644 --- a/regression/cpp/lvalue1/main.cpp +++ b/regression/cpp/lvalue1/main.cpp @@ -6,7 +6,7 @@ int main() // casts to references are lvalues asd &c=(asd &)((int &)a |= (int &)b); - + // in C++, comma expressions are lvalues (a, b)=ASD; } diff --git a/regression/cpp/nullptr1/main.cpp b/regression/cpp/nullptr1/main.cpp index d0d35592605..6d178630634 100644 --- a/regression/cpp/nullptr1/main.cpp +++ b/regression/cpp/nullptr1/main.cpp @@ -17,12 +17,10 @@ int main() nullptr_t my_null; my_null=nullptr; my_null=0; - + char buffer[10]; void *p=my_null, *q=buffer; assert(q!=nullptr); - + something(nullptr); } - - diff --git a/regression/cpp/sizeof1/main.cpp b/regression/cpp/sizeof1/main.cpp index 94035f69d4d..d6667784463 100644 --- a/regression/cpp/sizeof1/main.cpp +++ b/regression/cpp/sizeof1/main.cpp @@ -4,7 +4,7 @@ class C public: int i; int j; - + void f() { } @@ -20,7 +20,7 @@ static_assert(sizeof(class C)==sizeof c, "size of class C"); int i; static_assert(sizeof(i)==4, "size of i"); - + // and this, too typedef unsigned int UINT32; static_assert(sizeof(UINT32)==4, "size of UINT32"); diff --git a/regression/cpp/sizeof3/main.cpp b/regression/cpp/sizeof3/main.cpp index 1e05d8ab5fc..9de2f38b1b2 100644 --- a/regression/cpp/sizeof3/main.cpp +++ b/regression/cpp/sizeof3/main.cpp @@ -12,4 +12,3 @@ int main() bar(); return 0; } - diff --git a/regression/cpp/static_assert1/main.cpp b/regression/cpp/static_assert1/main.cpp index 61a2e699500..f0587527c70 100644 --- a/regression/cpp/static_assert1/main.cpp +++ b/regression/cpp/static_assert1/main.cpp @@ -5,7 +5,7 @@ static_assert(sizeof(int)==sizeof(int), "sizeof(int)==sizeof(int)"); class C1 { static_assert(2==2, "2==2"); - + typedef int T; static_assert(sizeof(T)==sizeof(int), "sizeof(T)==sizeof(int)"); }; diff --git a/regression/cpp/switch1/main.cpp b/regression/cpp/switch1/main.cpp index 247a8570596..873f8fcdff1 100644 --- a/regression/cpp/switch1/main.cpp +++ b/regression/cpp/switch1/main.cpp @@ -3,7 +3,7 @@ int main() { int i; - + switch(i) { case 0: assert(i==0); @@ -14,9 +14,9 @@ int main() default: assert(i!=0 && i!=1); } - + int z=0; - + // a declaration is ok here switch(int z=123) { @@ -24,6 +24,6 @@ int main() default: assert(0); } - // and there is scope! + // and there is scope! assert(z==0); } diff --git a/regression/cpp/typecast_ambiguity1/main.cpp b/regression/cpp/typecast_ambiguity1/main.cpp index 46a49ce387d..bd26527ef5e 100644 --- a/regression/cpp/typecast_ambiguity1/main.cpp +++ b/regression/cpp/typecast_ambiguity1/main.cpp @@ -8,13 +8,13 @@ int main() (X) + z; // this is a typecast (Y) + z; // this is an addition - + (X) - z; // this is a typecast (Y) - z; // this is a subtraction - + (X) & z; // this is a typecast (Y) & z; // this is a bitwise and - + (X) * p; // this is a typecast z=(int)(p) & 0x1fff; // this is bitwise and diff --git a/regression/cpp/typecast_ambiguity2/main.cpp b/regression/cpp/typecast_ambiguity2/main.cpp index 0d41f881af5..47fca7cb8e1 100644 --- a/regression/cpp/typecast_ambiguity2/main.cpp +++ b/regression/cpp/typecast_ambiguity2/main.cpp @@ -14,4 +14,3 @@ int main() return (foo)((1)); } - diff --git a/regression/cpp/typedef2/main.cpp b/regression/cpp/typedef2/main.cpp index 502104cbbcd..f0e222ea20f 100644 --- a/regression/cpp/typedef2/main.cpp +++ b/regression/cpp/typedef2/main.cpp @@ -12,4 +12,3 @@ void func2(TP tp) int main() { } - diff --git a/regression/cpp/union4/main.cpp b/regression/cpp/union4/main.cpp index 4daf13a3dcb..0de32e22347 100644 --- a/regression/cpp/union4/main.cpp +++ b/regression/cpp/union4/main.cpp @@ -4,4 +4,3 @@ struct A union {int a;}; char a; }; - diff --git a/regression/fault-localization/all_properties1/main.c b/regression/fault-localization/all_properties1/main.c index e66a3212556..f948457cd29 100644 --- a/regression/fault-localization/all_properties1/main.c +++ b/regression/fault-localization/all_properties1/main.c @@ -1,4 +1,4 @@ -#include +#include void main() { diff --git a/regression/fault-localization/all_properties2/main.c b/regression/fault-localization/all_properties2/main.c index b575e995d47..8cffac4abe1 100644 --- a/regression/fault-localization/all_properties2/main.c +++ b/regression/fault-localization/all_properties2/main.c @@ -1,4 +1,4 @@ -#include +#include void main() { diff --git a/regression/fault-localization/stop_on_fail1/main.c b/regression/fault-localization/stop_on_fail1/main.c index e66a3212556..f948457cd29 100644 --- a/regression/fault-localization/stop_on_fail1/main.c +++ b/regression/fault-localization/stop_on_fail1/main.c @@ -1,4 +1,4 @@ -#include +#include void main() { diff --git a/regression/goto-analyzer/intervals1/intervals1.c b/regression/goto-analyzer/intervals1/intervals1.c index 026e572f8ef..a797452b198 100644 --- a/regression/goto-analyzer/intervals1/intervals1.c +++ b/regression/goto-analyzer/intervals1/intervals1.c @@ -3,10 +3,10 @@ int main() { int i, j; - + if(i>=20) assert(i>=10); - + if(i>=10 && i<=20) assert(i!=30); diff --git a/regression/goto-analyzer/intervals4/intervals4.c b/regression/goto-analyzer/intervals4/intervals4.c index e9bc51f30b5..790a5f1379f 100644 --- a/regression/goto-analyzer/intervals4/intervals4.c +++ b/regression/goto-analyzer/intervals4/intervals4.c @@ -3,10 +3,10 @@ int main() { int i; - + if(i>0) if(i<3) assert(i>=1 && i<=2); - + return 0; -} +} diff --git a/regression/goto-analyzer/intervals5/intervals5.c b/regression/goto-analyzer/intervals5/intervals5.c index 960e7473cc6..ed19ba71590 100644 --- a/regression/goto-analyzer/intervals5/intervals5.c +++ b/regression/goto-analyzer/intervals5/intervals5.c @@ -3,10 +3,10 @@ int main() { int i; - + if(i>0) if(i<3) assert(i>=1 || i<=2); - + return 0; -} +} diff --git a/regression/goto-instrument-unwind/Makefile b/regression/goto-instrument-unwind/Makefile index 45c2db4d8c2..8346f07d4d1 100644 --- a/regression/goto-instrument-unwind/Makefile +++ b/regression/goto-instrument-unwind/Makefile @@ -13,10 +13,10 @@ testnew: @../test.pl -c ../unwind-chain.sh -F test: - @../test.pl -c ../unwind-chain.sh + @../test.pl -c ../unwind-chain.sh tests.log: ../test.pl - @../test.pl -c ../unwind-chain.sh + @../test.pl -c ../unwind-chain.sh clean: @for dir in *; do \ diff --git a/regression/goto-instrument-unwind/break-loop1/main.c b/regression/goto-instrument-unwind/break-loop1/main.c index b5323c4ff5d..eed96ccbb21 100644 --- a/regression/goto-instrument-unwind/break-loop1/main.c +++ b/regression/goto-instrument-unwind/break-loop1/main.c @@ -8,7 +8,7 @@ int main() * every loop will be unwound K times **/ const unsigned K=10; - + const unsigned n=100; unsigned c=0, i; unsigned tres=K/2;; @@ -24,7 +24,7 @@ int main() unsigned eva=n; if(K=0, "property"); } } diff --git a/regression/k-induction/basic3/main.c b/regression/k-induction/basic3/main.c index d3504140457..8bf287b84f4 100644 --- a/regression/k-induction/basic3/main.c +++ b/regression/k-induction/basic3/main.c @@ -3,7 +3,7 @@ int glob; int main() { int loc=0; - + while(glob!=1000) { if(glob<10) glob++; diff --git a/regression/k-induction/chain.sh b/regression/k-induction/chain.sh index 7b4653ae5d0..1bf168f0764 100755 --- a/regression/k-induction/chain.sh +++ b/regression/k-induction/chain.sh @@ -22,5 +22,3 @@ if [ $? == 0 ] ; then echo "## Base case passes" ; else echo "## Base case fails $goto_instrument --k-induction $k --step-case $name.o $name.step.o $cbmc $name.step.o if [ $? == 0 ] ; then echo "## Step case passes" ; else echo "## Step case fails" ; fi - - diff --git a/regression/strings/cprover-string-hack.h b/regression/strings/cprover-string-hack.h index 8a560e9d70d..9160e935529 100644 --- a/regression/strings/cprover-string-hack.h +++ b/regression/strings/cprover-string-hack.h @@ -70,4 +70,3 @@ extern __CPROVER_string __CPROVER_uninterpreted_string_char_set_func(__CPROVER_s extern __CPROVER_string __CPROVER_uninterpreted_string_copy_func(__CPROVER_string str); extern unsigned __CPROVER_uninterpreted_string_parse_int_func(__CPROVER_string str); extern __CPROVER_string __CPROVER_uninterpreted_string_of_int_func(unsigned i); - diff --git a/regression/strings/java_case/test.desc b/regression/strings/java_case/test.desc index 7397314cca8..49ea16d56ff 100644 --- a/regression/strings/java_case/test.desc +++ b/regression/strings/java_case/test.desc @@ -7,4 +7,4 @@ test_case.class ^\[assertion.2\] assertion at file test_case.java line 12: SUCCESS$ ^\[assertion.3\] assertion at file test_case.java line 13: SUCCESS$ ^\[assertion.4\] assertion at file test_case.java line 14: FAILURE$ --- \ No newline at end of file +-- diff --git a/regression/strings/java_code_point/test.desc b/regression/strings/java_code_point/test.desc index bb69366ce61..1543a327fa4 100644 --- a/regression/strings/java_code_point/test.desc +++ b/regression/strings/java_code_point/test.desc @@ -8,4 +8,4 @@ test_code_point.class ^\[assertion.3\] assertion at file test_code_point.java line 7: SUCCESS$ ^\[assertion.4\] assertion at file test_code_point.java line 8: SUCCESS$ ^\[assertion.5\] assertion at file test_code_point.java line 11: SUCCESS$ --- \ No newline at end of file +-- diff --git a/regression/strings/java_float/test.desc b/regression/strings/java_float/test.desc index 47e915cda98..5edfd6eea22 100644 --- a/regression/strings/java_float/test.desc +++ b/regression/strings/java_float/test.desc @@ -7,4 +7,4 @@ test_float.class ^\[assertion.2\] assertion at file test_float.java line 15: SUCCESS$ ^\[assertion.3\] assertion at file test_float.java line 16: SUCCESS$ ^\[assertion.4\] assertion at file test_float.java line 17: FAILURE$ --- \ No newline at end of file +-- diff --git a/regression/strings/java_set_length/test.desc b/regression/strings/java_set_length/test.desc index 59204c9c5a8..66cf52835ac 100644 --- a/regression/strings/java_set_length/test.desc +++ b/regression/strings/java_set_length/test.desc @@ -6,4 +6,4 @@ test_set_length.class ^\[assertion.1\] assertion at file test_set_length.java line 8: SUCCESS$ ^\[assertion.2\] assertion at file test_set_length.java line 9: SUCCESS$ ^\[assertion.3\] assertion at file test_set_length.java line 10: FAILURE$ --- \ No newline at end of file +-- diff --git a/regression/strings/test1/test.desc b/regression/strings/test1/test.desc index 3483081c0f0..f622390356d 100644 --- a/regression/strings/test1/test.desc +++ b/regression/strings/test1/test.desc @@ -1,6 +1,6 @@ CORE test.c ---pass +--pass ^EXIT=10$ ^SIGNAL=0$ ^\[main.assertion.1\] assertion c1 == c2: SUCCESS$ diff --git a/regression/strings/test_char_set/test.c b/regression/strings/test_char_set/test.c index 61aaf9b768e..bd19cbaa46d 100644 --- a/regression/strings/test_char_set/test.c +++ b/regression/strings/test_char_set/test.c @@ -7,7 +7,7 @@ int main() __CPROVER_string s = __CPROVER_string_literal("abc");; char c = 'p'; __CPROVER_string t = __CPROVER_char_set(s,1,c);; - + assert(__CPROVER_string_equal(t, __CPROVER_string_literal("apc"))); assert(__CPROVER_string_equal(t, __CPROVER_string_literal("abc"))); return 0; diff --git a/regression/strings/test_concat/test.c b/regression/strings/test_concat/test.c index ceab520e960..007b9ca1b5c 100644 --- a/regression/strings/test_concat/test.c +++ b/regression/strings/test_concat/test.c @@ -9,7 +9,7 @@ int main() t = __CPROVER_string_literal("ppo"); u = __CPROVER_string_concat(s, t); __CPROVER_char c = __CPROVER_char_at(u,i); - + assert(c == __CPROVER_char_literal("p")); assert(__CPROVER_char_at(u,2) == __CPROVER_char_literal("p")); return 0; diff --git a/regression/strings/test_contains/test.c b/regression/strings/test_contains/test.c index 9e7c627f3c4..89749e487b7 100644 --- a/regression/strings/test_contains/test.c +++ b/regression/strings/test_contains/test.c @@ -7,11 +7,11 @@ int main() __CPROVER_string s1 = __CPROVER_string_literal("a1"); __CPROVER_string s2 = __CPROVER_string_literal("2b"); __CPROVER_string t = __CPROVER_string_concat(s1, s2); - + int i = nondet_int(); - - if(i==1) + + if(i==1) assert(!__CPROVER_string_contains(t,__CPROVER_string_literal("3"))); else if(i==2) assert(__CPROVER_string_contains(t,__CPROVER_string_literal("12"))); diff --git a/regression/strings/test_easychair/test.c b/regression/strings/test_easychair/test.c index 5d249225280..617cbfd7196 100644 --- a/regression/strings/test_easychair/test.c +++ b/regression/strings/test_easychair/test.c @@ -40,4 +40,3 @@ int main(){ // s survived all checks return true; } - diff --git a/regression/strings/test_equal/test.c b/regression/strings/test_equal/test.c index 2f26689589d..de70cc9d3fc 100644 --- a/regression/strings/test_equal/test.c +++ b/regression/strings/test_equal/test.c @@ -8,6 +8,6 @@ int main() s = __CPROVER_string_literal("pippo"); assert(__CPROVER_string_equal(s, __CPROVER_string_literal("pippo"))); assert(__CPROVER_string_equal(s, __CPROVER_string_literal("mippo"))); - + return 0; } diff --git a/regression/strings/test_index_of/test.desc b/regression/strings/test_index_of/test.desc index af22cc2efb5..6d9ddbc6281 100644 --- a/regression/strings/test_index_of/test.desc +++ b/regression/strings/test_index_of/test.desc @@ -6,4 +6,4 @@ test.c ^\[main.assertion.1\] assertion firstSlash == 3: SUCCESS$ ^\[main.assertion.2\] assertion lastSlash == 7: SUCCESS$ ^\[main.assertion.3\] assertion firstSlash != 3 || lastSlash != 7: FAILURE$ --- \ No newline at end of file +-- diff --git a/regression/strings/test_pass1/test.c b/regression/strings/test_pass1/test.c index 0ec758c9f64..abc3e9ed50a 100644 --- a/regression/strings/test_pass1/test.c +++ b/regression/strings/test_pass1/test.c @@ -7,8 +7,8 @@ int main() __CPROVER_string t; __CPROVER_string s = __CPROVER_string_concat(t, t); __CPROVER_assume(__CPROVER_string_equal(s, __CPROVER_string_literal("aa"))); - - assert(__CPROVER_string_equal(t,__CPROVER_string_literal("a"))); + + assert(__CPROVER_string_equal(t,__CPROVER_string_literal("a"))); assert(!__CPROVER_string_equal(t,__CPROVER_string_literal("a"))); // Warning the following does not express the same thing, because // equality can fail while the two sides represent the same thing: diff --git a/regression/strings/test_pass1/test.desc b/regression/strings/test_pass1/test.desc index 2531c253510..7548b6e91ef 100644 --- a/regression/strings/test_pass1/test.desc +++ b/regression/strings/test_pass1/test.desc @@ -6,4 +6,3 @@ test.c ^\[main.assertion.1\] assertion __CPROVER_uninterpreted_string_equal_func(t, __CPROVER_uninterpreted_string_literal_func(\"a\")): SUCCESS ^\[main.assertion.2\] assertion !__CPROVER_uninterpreted_string_equal_func(t, __CPROVER_uninterpreted_string_literal_func(\"a\")): FAILURE$ ^\*\* 1 of 2 failed (2 iterations)$ - diff --git a/regression/strings/test_pass_pc1/test.c b/regression/strings/test_pass_pc1/test.c index 95dadef8c1d..d1697fc990b 100644 --- a/regression/strings/test_pass_pc1/test.c +++ b/regression/strings/test_pass_pc1/test.c @@ -7,7 +7,7 @@ int main() __CPROVER_string s1,s2; __CPROVER_string t = __CPROVER_string_concat(s1, s2); __CPROVER_assume(__CPROVER_string_isprefix(__CPROVER_string_literal("a1"),s1)); - + __CPROVER_assume(__CPROVER_string_contains(s2,__CPROVER_string_literal("12"))); __CPROVER_assume(__CPROVER_string_issuffix(__CPROVER_string_literal("cd"),t)); diff --git a/regression/strings/test_pass_pc3/test.desc b/regression/strings/test_pass_pc3/test.desc index b4c45aee0ee..88f4659c45d 100644 --- a/regression/strings/test_pass_pc3/test.desc +++ b/regression/strings/test_pass_pc3/test.desc @@ -6,4 +6,3 @@ test.c ^\[main.assertion.1\] assertion __CPROVER_uninterpreted_string_length_func(s3) == 0: FAILURE$ ^\[main.assertion.2\] assertion __CPROVER_uninterpreted_string_length_func(s3) < 2: SUCCESS$ ^VERIFICATION FAILED$ - diff --git a/regression/strings/test_prefix/test.c b/regression/strings/test_prefix/test.c index 041a6a3ed41..d3ba0388d54 100644 --- a/regression/strings/test_prefix/test.c +++ b/regression/strings/test_prefix/test.c @@ -12,6 +12,6 @@ int main() __CPROVER_bool c = __CPROVER_string_isprefix(__CPROVER_string_literal("Wello"),s); assert(b); assert(c); - + return 0; } diff --git a/regression/strings/test_substring/test.c b/regression/strings/test_substring/test.c index d2c26eca01a..b86f4f88cd7 100644 --- a/regression/strings/test_substring/test.c +++ b/regression/strings/test_substring/test.c @@ -6,7 +6,7 @@ int main() { __CPROVER_string s = __CPROVER_string_literal("abcdef"); __CPROVER_string t = __CPROVER_string_substring(s,2,4); - + assert(__CPROVER_string_equal(t,__CPROVER_string_literal("cd"))); assert(__CPROVER_string_equal(t,__CPROVER_string_literal("cc"))); assert(!__CPROVER_string_equal(t,__CPROVER_string_literal("bc"))); diff --git a/regression/strings/test_substring/test.desc b/regression/strings/test_substring/test.desc index 6fe9134b59d..327d5bbe1f2 100644 --- a/regression/strings/test_substring/test.desc +++ b/regression/strings/test_substring/test.desc @@ -7,4 +7,4 @@ test.c ^\[main.assertion.2\] assertion __CPROVER_uninterpreted_string_equal_func(t, __CPROVER_uninterpreted_string_literal_func(\"cc\")): FAILURE$ ^\[main.assertion.3\] assertion !__CPROVER_uninterpreted_string_equal_func(t, __CPROVER_uninterpreted_string_literal_func(\"bc\")): SUCCESS$ ^\[main.assertion.4\] assertion !__CPROVER_uninterpreted_string_equal_func(t, __CPROVER_uninterpreted_string_literal_func(\"cd\")): FAILURE$ --- \ No newline at end of file +-- diff --git a/regression/strings/test_suffix/test.c b/regression/strings/test_suffix/test.c index d28bde61712..f623f4d7342 100644 --- a/regression/strings/test_suffix/test.c +++ b/regression/strings/test_suffix/test.c @@ -10,6 +10,6 @@ int main() assert(__CPROVER_string_issuffix(__CPROVER_string_literal("po"),s)); assert(__CPROVER_string_issuffix(__CPROVER_string_literal("pp"),s)); - + return 0; } diff --git a/regression/symex-infeasibility/bst-safe/main.c b/regression/symex-infeasibility/bst-safe/main.c index 35c0e33a30a..868a2049a0d 100644 --- a/regression/symex-infeasibility/bst-safe/main.c +++ b/regression/symex-infeasibility/bst-safe/main.c @@ -99,4 +99,3 @@ int main() { return 0; } - diff --git a/regression/symex-infeasibility/counter-unsafe/main.c b/regression/symex-infeasibility/counter-unsafe/main.c index 8d0b9b75b36..909459094cd 100644 --- a/regression/symex-infeasibility/counter-unsafe/main.c +++ b/regression/symex-infeasibility/counter-unsafe/main.c @@ -37,4 +37,3 @@ int main() { assert(0 <= y && y != n); return 0; } - diff --git a/regression/symex-infeasibility/insertion-sort-safe/main.c b/regression/symex-infeasibility/insertion-sort-safe/main.c index 0b194efde58..df01181380b 100644 --- a/regression/symex-infeasibility/insertion-sort-safe/main.c +++ b/regression/symex-infeasibility/insertion-sort-safe/main.c @@ -44,4 +44,3 @@ int main() { return 0; } - diff --git a/regression/symex-infeasibility/insertion-sort-unsafe/main.c b/regression/symex-infeasibility/insertion-sort-unsafe/main.c index 1aad931c710..21960ff19e5 100644 --- a/regression/symex-infeasibility/insertion-sort-unsafe/main.c +++ b/regression/symex-infeasibility/insertion-sort-unsafe/main.c @@ -45,4 +45,3 @@ int main() { return 0; } - diff --git a/regression/symex-infeasibility/tp5/main.c b/regression/symex-infeasibility/tp5/main.c index e56d7bff20c..b8b2df491fe 100644 --- a/regression/symex-infeasibility/tp5/main.c +++ b/regression/symex-infeasibility/tp5/main.c @@ -23,4 +23,3 @@ int main(void) { assert(f(x) == g(x)); } } - diff --git a/regression/symex/array1/main.c b/regression/symex/array1/main.c index 332c5d20323..6f172867b3a 100644 --- a/regression/symex/array1/main.c +++ b/regression/symex/array1/main.c @@ -12,10 +12,10 @@ int main() int i; // zero initialization - assert(some_int_array[1]==0); + assert(some_int_array[1]==0); if(i>=0 && i<10) assert(some_int_array[i]==0); some_int_array[5]=5; - assert(some_int_array[1]==0); + assert(some_int_array[1]==0); assert(some_int_array[5]==5); } diff --git a/regression/symex/function_pointer1/main.c b/regression/symex/function_pointer1/main.c index 3d578de8eec..80ed753180c 100644 --- a/regression/symex/function_pointer1/main.c +++ b/regression/symex/function_pointer1/main.c @@ -21,7 +21,7 @@ int main() f_ptr=f1; f_ptr(); assert(global==1); - + f_ptr=f2; f_ptr(); assert(global==2); diff --git a/regression/symex/if1/main.c b/regression/symex/if1/main.c index 42ee8b1b318..ab5dda196d9 100644 --- a/regression/symex/if1/main.c +++ b/regression/symex/if1/main.c @@ -3,7 +3,7 @@ int main() { int i; - + if(i==1) assert(i==1); else diff --git a/regression/symex/malloc1/main.c b/regression/symex/malloc1/main.c index 3d27ae92d39..e5fe1e6f14b 100644 --- a/regression/symex/malloc1/main.c +++ b/regression/symex/malloc1/main.c @@ -4,12 +4,12 @@ int main() { int *p; - + p=(int *)malloc(sizeof(int)); - + *p=1; - + assert(*p==1); - + free(p); } diff --git a/regression/symex/pointer1/main.c b/regression/symex/pointer1/main.c index 23ff39299d6..b03fc8e4a9a 100644 --- a/regression/symex/pointer1/main.c +++ b/regression/symex/pointer1/main.c @@ -8,7 +8,7 @@ int main() // pointer into an integer q=(char *)&i; - + i=0x03020100; // endianness-dependent @@ -21,15 +21,15 @@ int main() assert(ch1==1); assert(ch2==2); assert(ch3==3); - + unsigned int *up=(unsigned int *)q; assert(*up==i); - + // pointer with conditional int input, x, y; p=input?&x:&y; *p=1; - + if(input) assert(x==1); else diff --git a/regression/symex/pointer3/main.c b/regression/symex/pointer3/main.c index 332327a640f..29661994a99 100644 --- a/regression/symex/pointer3/main.c +++ b/regression/symex/pointer3/main.c @@ -4,9 +4,9 @@ int main() { int choice; int x=1, y=2, *p=choice?&x:&y; - + *p=3; - + if(choice) assert(x==3 && y==2); else diff --git a/regression/symex/show-trace1/main.c b/regression/symex/show-trace1/main.c index 57bc6bb1288..e5a7ae24717 100644 --- a/regression/symex/show-trace1/main.c +++ b/regression/symex/show-trace1/main.c @@ -3,11 +3,11 @@ int input(); int main() { int i, j, k; - + i=input(); j=input(); k=input(); - + if(i==2) if(j==i+1) if(k==i*j) diff --git a/regression/symex/struct2/main.c b/regression/symex/struct2/main.c index 9d5126ee006..a0781a64a3f 100644 --- a/regression/symex/struct2/main.c +++ b/regression/symex/struct2/main.c @@ -8,7 +8,7 @@ struct X int main() { int *p; - + p=&x.a; *p=10; p++; diff --git a/regression/symex/struct3/main.c b/regression/symex/struct3/main.c index 4c2c7287041..6f9ac01146a 100644 --- a/regression/symex/struct3/main.c +++ b/regression/symex/struct3/main.c @@ -9,9 +9,9 @@ int main() { int i; char *p; - + p=&x.a; - + p[0]=1; p[1]=2; p[2]=3; @@ -24,7 +24,7 @@ int main() // same again, directly to head of struct p=(char *)&y; - + p[0]=1; p[1]=2; p[2]=3; diff --git a/src/Makefile b/src/Makefile index 06a973118dd..0ba04a97a1d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -53,7 +53,7 @@ $(patsubst %, %.dir, $(DIRS)): $(patsubst %, %_generated_files, $(DIRS)): $(MAKE) $(MAKEARGS) -C $(patsubst %_generated_files, %, $@) generated_files - + generated_files: $(patsubst %, %_generated_files, $(DIRS)) # cleaning diff --git a/src/aa-path-symex/Makefile b/src/aa-path-symex/Makefile index f25bb6288b8..272a422aac0 100644 --- a/src/aa-path-symex/Makefile +++ b/src/aa-path-symex/Makefile @@ -14,4 +14,3 @@ all: aa-path-symex$(LIBEXT) aa-path-symex$(LIBEXT): $(OBJ) $(LINKLIB) - diff --git a/src/aa-path-symex/build_goto_trace.cpp b/src/aa-path-symex/build_goto_trace.cpp index dd7fedfc02c..ac37f4ea6fb 100644 --- a/src/aa-path-symex/build_goto_trace.cpp +++ b/src/aa-path-symex/build_goto_trace.cpp @@ -27,25 +27,25 @@ void build_goto_trace( { // follow the history in the state, // but in a forwards-fashion - + std::vector steps; state.history.build_history(steps); - + unsigned step_nr; - + for(step_nr=0; step_nr target_mapt; target_mapt target_map; - + forall_goto_functions(f_it, goto_functions) { const goto_functionst::goto_functiont &goto_function = f_it->second; @@ -68,12 +68,12 @@ void locst::build(const goto_functionst &goto_functions) else function_entry.first_loc=loc_reft::nil(); } - + if(function_map.find(ID_main)==function_map.end()) throw "no entry point"; - + entry_loc=function_map[ID_main].first_loc; - + // build branch targets for(unsigned l=0; ltype << " " // << loc.target->location << " " << as_string(ns, *loc.target) << "\n"; - + if(!loc.branch_target.is_nil()) out << " T: " << loc.branch_target << "\n"; } - + out << "\n"; out << "The entry location is L" << entry_loc << ".\n"; } - diff --git a/src/aa-path-symex/locs.h b/src/aa-path-symex/locs.h index 94f00c0316d..bf83d504ada 100644 --- a/src/aa-path-symex/locs.h +++ b/src/aa-path-symex/locs.h @@ -24,47 +24,47 @@ struct loct function(_function) { } - + goto_programt::const_targett target; irep_idt function; - + // we only support a single branch target loc_reft branch_target; }; class locst -{ +{ public: typedef std::vector loc_vectort; loc_vectort loc_vector; loc_reft entry_loc; - + class function_entryt { public: loc_reft first_loc; code_typet type; }; - + typedef std::map function_mapt; function_mapt function_map; - + locst(const namespacet &_ns); void build(const goto_functionst &goto_functions); void output(std::ostream &out) const; - + inline loct &operator[] (loc_reft l) { assert(l.loc_number>=0 && l.loc_number < loc_vector.size()); return loc_vector[l.loc_number]; } - + inline const loct &operator[] (loc_reft l) const { assert(l.loc_number>=0 && l.loc_number < loc_vector.size()); return loc_vector[l.loc_number]; } - + static inline loc_reft begin() { loc_reft tmp; @@ -91,14 +91,14 @@ class target_to_loc_mapt for(loc_reft it=locs.begin(); it!=locs.end(); ++it) map[locs[it].target]=it; } - + inline loc_reft operator[](const goto_programt::const_targett t) const { mapt::const_iterator it=map.find(t); assert(it!=map.end()); return it->second; } - + protected: typedef std::map mapt; mapt map; diff --git a/src/aa-path-symex/path_symex.cpp b/src/aa-path-symex/path_symex.cpp index dd23210b958..6ea307ca058 100644 --- a/src/aa-path-symex/path_symex.cpp +++ b/src/aa-path-symex/path_symex.cpp @@ -33,7 +33,7 @@ class path_symext inline path_symext() { } - + void operator()( path_symex_statet &state, std::list &furter_states); @@ -43,17 +43,17 @@ class path_symext void do_goto( path_symex_statet &state, bool taken); - + void do_assert_fail(path_symex_statet &state) { const goto_programt::instructiont &instruction= *state.get_instruction(); - + state.record_step(); state.next_pc(); exprt guard=state.read(not_exprt(instruction.guard)); state.history->guard=guard; - } + } protected: void do_goto( @@ -68,13 +68,13 @@ class path_symext exprt f=state.read(call.function()); function_call_rec(state, call, f, further_states); } - + void function_call_rec( path_symex_statet &state, const code_function_callt &function_call, const exprt &function, std::list &further_states); - + void return_from_function( path_symex_statet &state, const exprt &return_value); @@ -208,7 +208,7 @@ void path_symext::assign( // read the address of the lhs, with propagation exprt lhs_address=state.read(address_of_exprt(lhs)); - + // now SSA it, no propagation exprt ssa_lhs= state.read_no_propagate(dereference_exprt(lhs_address)); @@ -249,7 +249,7 @@ inline static typet c_sizeof_type_rec(const exprt &expr) if(t.is_not_nil()) return t; } } - + return nil_typet(); } @@ -260,16 +260,16 @@ void path_symext::symex_malloc( { if(code.operands().size()!=1) throw "malloc expected to have one operand"; - + // increment dynamic object counter unsigned dynamic_count=++state.var_map.dynamic_count; - + exprt size=code.op0(); typet object_type=nil_typet(); - + { exprt tmp_size=state.read(size); // to allow constant propagation - + // special treatment for sizeof(T)*x if(tmp_size.id()==ID_mult && tmp_size.operands().size()==2 && @@ -277,12 +277,12 @@ void path_symext::symex_malloc( { object_type=array_typet( c_sizeof_type_rec(tmp_size.op0()), - tmp_size.op1()); + tmp_size.op1()); } else { typet tmp_type=c_sizeof_type_rec(tmp_size); - + if(tmp_type.is_not_nil()) { // Did the size get multiplied? @@ -298,25 +298,25 @@ void path_symext::symex_malloc( else { mp_integer elements=alloc_size/elem_size; - + if(elements*elem_size==alloc_size) object_type=array_typet(tmp_type, from_integer(elements, tmp_size.type())); } } } } - + if(object_type.is_nil()) object_type=array_typet(unsigned_char_type(), tmp_size); // we introduce a fresh symbol for the size // to prevent any issues of the size getting ever changed - + if(object_type.id()==ID_array && !to_array_type(object_type).size().is_constant()) { exprt &size=to_array_type(object_type).size(); - + symbolt size_symbol; size_symbol.base_name="dynamic_object_size"+i2string(dynamic_count); @@ -328,13 +328,13 @@ void path_symext::symex_malloc( //state.var_map(size_symbol.name, suffix, size_symbol.type); assign(state, - size_symbol.symbol_expr(), + size_symbol.symbol_expr(), size); size=size_symbol.symbol_expr(); } } - + // value symbolt value_symbol; @@ -348,7 +348,7 @@ void path_symext::symex_malloc( //state.var_map(value_symbol.name, suffix, value_symbol.type); address_of_exprt rhs; - + if(object_type.id()==ID_array) { rhs.type()=pointer_typet(value_symbol.type.subtype()); @@ -362,7 +362,7 @@ void path_symext::symex_malloc( rhs.op0()=value_symbol.symbol_expr(); rhs.type()=pointer_typet(value_symbol.type); } - + if(rhs.type()!=lhs.type()) rhs.make_typecast(lhs.type()); @@ -383,31 +383,31 @@ Function: path_symext::assign_rec void path_symext::assign_rec( path_symex_statet &state, - exprt::operandst &guard, - const exprt &ssa_lhs, + exprt::operandst &guard, + const exprt &ssa_lhs, const exprt &ssa_rhs) { //const typet &ssa_lhs_type=state.var_map.ns.follow(ssa_lhs.type()); - + #ifdef DEBUG std::cout << "assign_rec: " << ssa_lhs.pretty() << std::endl; //std::cout << "ssa_lhs_type: " << ssa_lhs_type.id() << std::endl; #endif - + if(ssa_lhs.id()==ID_symbol) { // These are expected to the SSA symbols assert(ssa_lhs.get_bool(ID_C_SSA_symbol)); - + const symbol_exprt &symbol_expr=to_symbol_expr(ssa_lhs); const irep_idt &full_identifier=symbol_expr.get(ID_C_full_identifier); - + #ifdef DEBUG const irep_idt &ssa_identifier=symbol_expr.get_identifier(); std::cout << "SSA symbol identifier: " << ssa_identifier << std::endl; std::cout << "full identifier: " << full_identifier << std::endl; #endif - + var_mapt::var_infot &var_info=state.var_map[full_identifier]; assert(var_info.full_identifier==full_identifier); @@ -447,7 +447,7 @@ void path_symext::assign_rec( // record the step state.record_step(); path_symex_stept &step=*state.history; - + if(!guard.empty()) step.guard=conjunction(guard); step.full_lhs=ssa_lhs; step.ssa_lhs=new_lhs; @@ -469,7 +469,7 @@ void path_symext::assign_rec( const typet &compound_type= state.var_map.ns.follow(struct_op.type()); - + if(compound_type.id()==ID_struct) { throw "unexpected struct member on lhs"; @@ -481,7 +481,7 @@ void path_symext::assign_rec( new_rhs.type()=struct_op.type(); new_rhs.set_component_name(ssa_lhs_member_expr.get_component_name()); new_rhs.op()=ssa_rhs; - + assign_rec(state, guard, struct_op, new_rhs); } else @@ -493,7 +493,7 @@ void path_symext::assign_rec( std::cout << "assign_rec ID_index" << std::endl; #endif - throw "unexpected array index on lhs"; + throw "unexpected array index on lhs"; } else if(ssa_lhs.id()==ID_dereference) { @@ -516,7 +516,7 @@ void path_symext::assign_rec( guard.push_back(cond); assign_rec(state, guard, lhs_if_expr.true_case(), ssa_rhs); guard.pop_back(); - + // false guard.push_back(not_exprt(cond)); assign_rec(state, guard, lhs_if_expr.false_case(), ssa_rhs); @@ -531,12 +531,12 @@ void path_symext::assign_rec( const byte_extract_exprt &byte_extract_expr= to_byte_extract_expr(ssa_lhs); - + // assignment to byte_extract operators: // turn into byte_update operator - + irep_idt new_id; - + if(ssa_lhs.id()==ID_byte_extract_little_endian) new_id=ID_byte_update_little_endian; else if(ssa_lhs.id()==ID_byte_extract_big_endian) @@ -550,7 +550,7 @@ void path_symext::assign_rec( new_rhs.op()=byte_extract_expr.op(); new_rhs.offset()=byte_extract_expr.offset(); new_rhs.value()=ssa_rhs; - + const exprt new_lhs=byte_extract_expr.op(); assign_rec(state, guard, new_lhs, new_rhs); @@ -561,12 +561,12 @@ void path_symext::assign_rec( to_struct_type(state.var_map.ns.follow(ssa_lhs.type())); const struct_typet::componentst &components= struct_type.components(); - + // split up into components const exprt::operandst &operands=ssa_lhs.operands(); - + assert(operands.size()==components.size()); - + for(unsigned i=0; isecond; loc_reft function_entry_point=function_entry.first_loc; - + // do we have a body? if(function_entry_point==loc_reft()) { @@ -678,7 +678,7 @@ void path_symext::function_call_rec( state.next_pc(); return; } - + // push a frame on the call stack path_symex_statet::threadt &thread=state.threads[state.get_current_thread()]; thread.call_stack.push_back(path_symex_statet::framet()); @@ -686,7 +686,7 @@ void path_symext::function_call_rec( thread.call_stack.back().return_location=thread.pc.next_loc(); thread.call_stack.back().return_lhs=call.lhs(); thread.call_stack.back().saved_local_vars=thread.local_vars; - + // update statistics state.recursion_map[function_identifier]++; @@ -695,7 +695,7 @@ void path_symext::function_call_rec( const code_typet::argumentst &function_arguments=code_type.arguments(); const exprt::operandst &call_arguments=call.arguments(); - + // now assign the argument values for(unsigned i=0; iguard=guard; } break; - + case ASSERT: case SKIP: case LOCATION: @@ -1074,17 +1074,17 @@ void path_symext::operator()( state.next_pc(); state.inside_atomic_section=false; break; - + case ASSIGN: assign(state, to_code_assign(instruction.code)); state.next_pc(); break; - + case FUNCTION_CALL: state.record_step(); function_call(state, to_code_function_call(instruction.code), further_states); break; - + case OTHER: state.record_step(); @@ -1218,4 +1218,3 @@ void path_symex_assert_fail(path_symex_statet &state) path_symext path_symex; path_symex.do_assert_fail(state); } - diff --git a/src/aa-path-symex/path_symex_history.cpp b/src/aa-path-symex/path_symex_history.cpp index 6ddd2bb0f12..33ed11f4f5d 100644 --- a/src/aa-path-symex/path_symex_history.cpp +++ b/src/aa-path-symex/path_symex_history.cpp @@ -33,9 +33,9 @@ void path_symex_stept::output(std::ostream &out) const p_it!=pc_vector.end(); p_it++) out << " " << *p_it; - */ + */ out << "\n"; - + out << "Guard: " << from_expr(guard) << "\n"; out << "Full LHS: " << from_expr(full_lhs) << "\n"; out << "SSA LHS: " << from_expr(ssa_lhs) << "\n"; diff --git a/src/aa-path-symex/path_symex_history.h b/src/aa-path-symex/path_symex_history.h index 5f499807770..85eb9ea8248 100644 --- a/src/aa-path-symex/path_symex_history.h +++ b/src/aa-path-symex/path_symex_history.h @@ -35,34 +35,34 @@ class path_symex_step_reft index(std::numeric_limits::max()), history(0) { } - + inline bool is_nil() const { return index==std::numeric_limits::max(); } - + inline path_symex_historyt &get_history() const { assert(history!=0); return *history; } - + // pre-decrement inline path_symex_step_reft &operator--(); - + inline path_symex_stept &operator*() const { return get(); } inline path_symex_stept *operator->() const { return &get(); } - + void generate_successor(); - // build a forward-traversible version of the history + // build a forward-traversible version of the history void build_history(std::vector &dest) const; protected: // we use a vector to store all steps std::size_t index; class path_symex_historyt *history; - + inline path_symex_stept &get() const; }; @@ -73,10 +73,10 @@ class path_symex_stept { public: path_symex_step_reft predecessor; - + // the thread that did the step unsigned thread_nr; - + // the instruction that was executed loc_reft pc; @@ -84,8 +84,8 @@ class path_symex_stept exprt full_lhs; symbol_exprt ssa_lhs; - bool hidden; - + bool hidden; + path_symex_stept(): guard(nil_exprt()), ssa_rhs(nil_exprt()), @@ -93,10 +93,10 @@ class path_symex_stept hidden(false) { } - + // interface to solvers; this converts a single step void convert(decision_proceduret &dest) const; - + void output(std::ostream &) const; }; @@ -110,7 +110,7 @@ static inline decision_proceduret &operator << ( src->convert(dest); --src; } - + return dest; } diff --git a/src/aa-path-symex/path_symex_state.cpp b/src/aa-path-symex/path_symex_state.cpp index 3fc43a01cba..08397535741 100644 --- a/src/aa-path-symex/path_symex_state.cpp +++ b/src/aa-path-symex/path_symex_state.cpp @@ -156,21 +156,21 @@ exprt path_symex_statet::read(const exprt &src, bool propagate) #ifdef DEBUG //std::cout << "path_symex_statet::read " << src.pretty() << std::endl; #endif - + // This has four phases! // 1. Floating-point expression adjustment (rounding mode) // 2. Dereferencing, including propagation of pointers. // 3. Rewriting to SSA symbols // 4. Simplifier - + exprt tmp1=src; adjust_float_expressions(tmp1, var_map.ns); // we force propagation for dereferencing exprt tmp2=dereference_rec(tmp1, true); - + exprt tmp3=instantiate_rec(tmp2, propagate); - + exprt tmp4=simplify_expr(tmp3, var_map.ns); #ifdef DEBUG @@ -202,12 +202,12 @@ exprt path_symex_statet::instantiate_rec( #endif const typet &src_type=var_map.ns.follow(src.type()); - + if(src_type.id()==ID_struct) // src is a struct { const struct_typet &struct_type=to_struct_type(src_type); const struct_typet::componentst &components=struct_type.components(); - + struct_exprt result(src.type()); result.operands().resize(components.size()); @@ -225,43 +225,43 @@ exprt path_symex_statet::instantiate_rec( } else new_src=member_exprt(src, component_name, subtype); - + // recursive call result.operands()[i]=instantiate_rec(new_src, propagate); } return result; // done - } + } else if(src_type.id()==ID_array) // src is an array { const array_typet &array_type=to_array_type(src_type); const typet &subtype=array_type.subtype(); - + if(array_type.size().is_constant()) { mp_integer size; if(to_integer(array_type.size(), size)) throw "failed to convert array size"; - + unsigned long long size_int=integer2unsigned(size); - + array_exprt result(array_type); result.operands().resize(size_int); - + // split it up into elements for(unsigned long long i=0; ithread_nr!=current_thread) no_thread_interleavings++; - + // update our statistics depth++; @@ -726,18 +726,18 @@ bool path_symex_statet::is_feasible( { // feed path constraint to decision procedure decision_procedure << history; - + // check whether SAT switch(decision_procedure()) { case decision_proceduret::D_TAUTOLOGY: case decision_proceduret::D_SATISFIABLE: return true; - + case decision_proceduret::D_UNSATISFIABLE: return false; - + case decision_proceduret::D_ERROR: throw "error from decsion procedure"; } - + return true; // not really reachable } @@ -763,7 +763,7 @@ bool path_symex_statet::check_assertion( // the assertion in SSA exprt assertion=read(instruction.guard); - + // trivial? if(assertion.is_true()) return true; // no error @@ -773,20 +773,19 @@ bool path_symex_statet::check_assertion( // negate the assertion decision_procedure.set_to(assertion, false); - // check whether SAT + // check whether SAT switch(decision_procedure.dec_solve()) { case decision_proceduret::D_TAUTOLOGY: case decision_proceduret::D_SATISFIABLE: return false; // error - + case decision_proceduret::D_UNSATISFIABLE: return true; // no error - + default: throw "error from decision procedure"; } return true; // not really reachable } - diff --git a/src/aa-path-symex/path_symex_state.h b/src/aa-path-symex/path_symex_state.h index f29d39da5c5..5663e07ce9a 100644 --- a/src/aa-path-symex/path_symex_state.h +++ b/src/aa-path-symex/path_symex_state.h @@ -104,7 +104,7 @@ class path_symex_statet // it's a given explicit value or a symbol with given identifier exprt value; symbol_exprt ssa_symbol; - + // for uninterpreted functions or arrays we maintain an index set typedef std::set index_sett; index_sett index_set; @@ -115,11 +115,11 @@ class path_symex_statet { } }; - + // the values of the shared variables typedef std::vector var_valt; var_valt shared_vars; - + // procedure frame struct framet { @@ -129,31 +129,31 @@ class path_symex_statet var_valt saved_local_vars; }; - // call stack + // call stack typedef std::vector call_stackt; - + // the state of a thread struct threadt { public: - loc_reft pc; + loc_reft pc; call_stackt call_stack; // the call stack var_valt local_vars; // thread-local variables bool active; - + threadt():active(true) { } }; - + typedef std::vector threadst; threadst threads; // warning: reference is not stable var_statet &get_var_state(const var_mapt::var_infot &var_info); - + bool inside_atomic_section; - + inline unsigned get_current_thread() const { return current_thread; @@ -163,7 +163,7 @@ class path_symex_statet { current_thread=_thread; } - + goto_programt::const_targett get_instruction() const; // branch taken case @@ -198,7 +198,7 @@ class path_symex_statet // execution history path_symex_step_reft history; - + // adds an entry to the history void record_step(); @@ -206,13 +206,13 @@ class path_symex_statet void record_branch_step(bool taken); // various state transformers - + inline threadt &add_thread() { threads.resize(threads.size()+1); return threads.back(); } - + inline void disable_current_thread() { threads[current_thread].active=false; @@ -232,8 +232,8 @@ class path_symex_statet { threads[current_thread].pc=new_pc; } - - // output + + // output void output(std::ostream &out) const; void output(const threadt &thread, std::ostream &out) const; @@ -242,7 +242,7 @@ class path_symex_statet { return read(src, true); } - + // instantiate without constant propagation inline exprt read_no_propagate(const exprt &src) { @@ -252,17 +252,17 @@ class path_symex_statet exprt dereference_rec(const exprt &src, bool propagate); std::string array_index_as_string(const exprt &) const; - + inline unsigned get_no_thread_interleavings() const { return no_thread_interleavings; } - + inline unsigned get_depth() const { return depth; } - + bool is_feasible(class decision_proceduret &) const; bool check_assertion(class decision_proceduret &); @@ -346,5 +346,5 @@ path_symex_statet initial_state( var_mapt &var_map, const locst &locs, path_symex_historyt &); - + #endif diff --git a/src/aa-path-symex/var_map.cpp b/src/aa-path-symex/var_map.cpp index fc4ec91ef31..a487db47bfd 100644 --- a/src/aa-path-symex/var_map.cpp +++ b/src/aa-path-symex/var_map.cpp @@ -41,13 +41,13 @@ void var_mapt::var_infot::output(std::ostream &out) const case THREAD_LOCAL: out << "THREAD_LOCAL"; break; case SHARED: out << "SHARED"; break; } - + out << "\n"; - + out << "number: " << number << "\n"; - + out << "type: " << type << "\n"; - + out << "\n"; } @@ -85,7 +85,7 @@ void var_mapt::init(var_infot &var_info) else var_info.kind=var_infot::PROCEDURE_LOCAL; } - + catch(std::string s) { throw "var_mapt::init identifier \"" + diff --git a/src/aa-path-symex/var_map.h b/src/aa-path-symex/var_map.h index c7b5bf50c03..e21c6d8e4d7 100644 --- a/src/aa-path-symex/var_map.h +++ b/src/aa-path-symex/var_map.h @@ -25,7 +25,7 @@ class var_mapt struct var_infot { enum { SHARED, THREAD_LOCAL, PROCEDURE_LOCAL } kind; - + inline bool is_shared() const { return kind==SHARED; @@ -39,13 +39,13 @@ class var_mapt // the type of the identifier (struct member or array) typet type; - + unsigned ssa_counter; - + var_infot():kind(SHARED), number(0), ssa_counter(0) { } - + irep_idt ssa_identifier() const; symbol_exprt ssa_symbol() const @@ -56,14 +56,14 @@ class var_mapt return s; } - inline void increment_ssa_counter() + inline void increment_ssa_counter() { ++ssa_counter; } - + void output(std::ostream &out) const; }; - + typedef std::map id_mapt; id_mapt id_map; @@ -79,7 +79,7 @@ class var_mapt result=id_map.insert(std::pair( full_identifier, var_infot())); - + if(result.second) // inserted? { result.first->second.full_identifier=full_identifier; @@ -88,10 +88,10 @@ class var_mapt result.first->second.type=type; init(result.first->second); } - + return result.first->second; } - + inline var_infot &operator[](const irep_idt &full_identifier) { return id_map[full_identifier]; @@ -105,7 +105,7 @@ class var_mapt dynamic_count=0; id_map.clear(); } - + void init(var_infot &var_info); const namespacet &ns; @@ -115,7 +115,7 @@ class var_mapt public: unsigned nondet_count; // free inputs - unsigned dynamic_count; // memory allocation + unsigned dynamic_count; // memory allocation }; #endif diff --git a/src/aa-symex/Makefile b/src/aa-symex/Makefile index 1a9068fb97c..5ff56e5ded2 100644 --- a/src/aa-symex/Makefile +++ b/src/aa-symex/Makefile @@ -59,4 +59,3 @@ symex$(EXEEXT): $(OBJ) symex-mac-signed: cbmc$(EXEEXT) strip symex$(EXEEXT) ; codesign -v -s $(OSX_IDENTITY) symex$(EXEEXT) - diff --git a/src/aa-symex/path_search.cpp b/src/aa-symex/path_search.cpp index 103e23515ff..8ad24bc828e 100644 --- a/src/aa-symex/path_search.cpp +++ b/src/aa-symex/path_search.cpp @@ -49,14 +49,14 @@ path_searcht::resultt path_searcht::operator()( locst locs(ns); var_mapt var_map(ns); - + locs.build(goto_functions); - // this is the container for the history-forest + // this is the container for the history-forest path_symex_historyt history; - + queue.push_back(initial_state(var_map, locs, history)); - + // set up the statistics number_of_paths=0; number_of_instructions=0; @@ -68,9 +68,9 @@ path_searcht::resultt path_searcht::operator()( // stop the time start_time=current_time(); - + initialize_property_map(goto_functions); - + while(!queue.empty()) { // Pick a state from the queue, @@ -106,7 +106,7 @@ path_searcht::resultt path_searcht::operator()( while(state->is_lazy() && state->is_executable()); assert(queue.size() == queue_size); } - + // TODO: check lazy states before fast forwarding, or perhaps it // is better to even check before inserting into queue if(drop_state(*state)) @@ -115,13 +115,13 @@ path_searcht::resultt path_searcht::operator()( queue.erase(state); continue; } - + if(!state->is_executable()) { queue.erase(state); continue; } - + // count only executable instructions number_of_instructions++; @@ -140,7 +140,7 @@ path_searcht::resultt path_searcht::operator()( else { check_assertion(*state, ns); - + // all assertions failed? if(number_of_failed_properties==property_map.size()) break; @@ -241,7 +241,7 @@ Function: path_searcht::try_await() Inputs: Outputs: returns true if and only if at least one child process - has terminated + has terminated Purpose: POSIX-compliant nonblocking wait on child processes, child's status is preserved for await() function @@ -287,7 +287,7 @@ void path_searcht::report_statistics() << number_of_VCCs_after_simplification << " remaining after simplification" << messaget::eom; - + time_periodt total_time=current_time()-start_time; status() << "Runtime: " << total_time << "s total, " << sat_time << "s SAT" << messaget::eom; @@ -329,20 +329,20 @@ void path_searcht::do_show_vcc( { // keep statistics number_of_VCCs++; - + const goto_programt::instructiont &instruction= *state.get_instruction(); - + mstreamt &out=result(); if(instruction.location.is_not_nil()) out << instruction.location << "\n"; - + if(instruction.location.get_comment()!="") out << instruction.location.get_comment() << "\n"; - + unsigned count=1; - + std::vector steps; state.history.build_history(steps); @@ -350,7 +350,7 @@ void path_searcht::do_show_vcc( s_it=steps.begin(); s_it!=steps.end(); s_it++) - { + { if((*s_it)->guard.is_not_nil()) { std::string string_value=from_expr(ns, "", (*s_it)->guard); @@ -368,7 +368,7 @@ void path_searcht::do_show_vcc( } out << "|--------------------------" << "\n"; - + exprt assertion=state.read(instruction.guard); out << "{" << 1 << "} " @@ -376,7 +376,7 @@ void path_searcht::do_show_vcc( if(!assertion.is_true()) number_of_VCCs_after_simplification++; - + out << eom; } @@ -396,10 +396,10 @@ bool path_searcht::drop_state(const statet &state) const { // depth if(depth_limit!=-1 && state.get_depth()>depth_limit) return true; - + // context bound if(context_bound!=-1 && state.get_no_thread_interleavings()) return true; - + // unwinding limit -- loops if(unwind_limit!=-1 && state.get_instruction()->is_backwards_goto()) { @@ -410,7 +410,7 @@ bool path_searcht::drop_state(const statet &state) const if(it->second>unwind_limit) return true; } - + // unwinding limit -- recursion if(unwind_limit!=-1 && state.get_instruction()->is_function_call()) { @@ -421,7 +421,7 @@ bool path_searcht::drop_state(const statet &state) const if(it->second>unwind_limit) return true; } - + return false; } @@ -443,13 +443,13 @@ void path_searcht::check_assertion( { // keep statistics number_of_VCCs++; - + const goto_programt::instructiont &instruction= *state.get_instruction(); irep_idt property_name=instruction.location.get_property_id(); property_entryt &property_entry=property_map[property_name]; - + if(property_entry.status==FAIL) return; // already failed else if(property_entry.status==NOT_REACHED) @@ -463,7 +463,7 @@ void path_searcht::check_assertion( // keep statistics number_of_VCCs_after_simplification++; - + status() << "Checking property " << property_name << eom; // take the time @@ -471,7 +471,7 @@ void path_searcht::check_assertion( satcheckt satcheck; bv_pointerst bv_pointers(ns, satcheck); - + satcheck.set_message_handler(get_message_handler()); bv_pointers.set_message_handler(get_message_handler()); @@ -481,7 +481,7 @@ void path_searcht::check_assertion( property_entry.status=FAIL; number_of_failed_properties++; } - + sat_time+=current_time()-sat_start_time; } @@ -507,7 +507,7 @@ void path_searcht::initialize_property_map( if(!it->second.is_inlined()) { const goto_programt &goto_program=it->second.body; - + for(goto_programt::instructionst::const_iterator it=goto_program.instructions.begin(); it!=goto_program.instructions.end(); @@ -515,14 +515,14 @@ void path_searcht::initialize_property_map( { if(!it->is_assert()) continue; - + const locationt &location=it->location; - + irep_idt property_name=location.get_property_id(); - + property_entryt &property_entry=property_map[property_name]; property_entry.status=NOT_REACHED; property_entry.description=location.get_comment(); } - } + } } diff --git a/src/aa-symex/path_search.h b/src/aa-symex/path_search.h index f10c9659ff6..4557f0736e2 100644 --- a/src/aa-symex/path_search.h +++ b/src/aa-symex/path_search.h @@ -32,7 +32,7 @@ class path_searcht:public safety_checkert const goto_functionst &goto_functions); bool show_vcc; - + unsigned depth_limit; unsigned context_bound; unsigned unwind_limit; @@ -56,7 +56,7 @@ class path_searcht:public safety_checkert irep_idt description; goto_tracet error_trace; }; - + typedef std::map property_mapt; property_mapt property_map; @@ -75,18 +75,18 @@ class path_searcht:public safety_checkert // State queue. Iterators are stable. typedef std::list queuet; queuet queue; - + queuet::iterator pick_state(); - + bool execute(queuet::iterator state, const namespacet &); - + void check_assertion(statet &state, const namespacet &); void do_show_vcc(statet &state, const namespacet &); - + bool drop_state(const statet &state) const; - + void report_statistics(); - + void initialize_property_map( const goto_functionst &goto_functions); }; diff --git a/src/aa-symex/symex_main.cpp b/src/aa-symex/symex_main.cpp index 4f0c56c15b3..eed970eb5cc 100644 --- a/src/aa-symex/symex_main.cpp +++ b/src/aa-symex/symex_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: Symex Main Module +Module: Symex Main Module Author: Daniel Kroening, kroening@kroening.com diff --git a/src/aa-symex/symex_parseoptions.cpp b/src/aa-symex/symex_parseoptions.cpp index 11f1e7cfae2..a83ce22223f 100644 --- a/src/aa-symex/symex_parseoptions.cpp +++ b/src/aa-symex/symex_parseoptions.cpp @@ -56,7 +56,7 @@ symex_parseoptionst::symex_parseoptionst(int argc, const char **argv): language_uit("Symex " CBMC_VERSION, cmdline) { } - + /*******************************************************************\ Function: symex_parseoptionst::eval_verbosity @@ -73,7 +73,7 @@ void symex_parseoptionst::eval_verbosity() { // this is our default verbosity int v=messaget::M_STATISTICS; - + if(cmdline.isset("verbosity")) { v=unsafe_string2int(cmdline.getval("verbosity")); @@ -82,7 +82,7 @@ void symex_parseoptionst::eval_verbosity() else if(v>10) v=10; } - + set_verbosity(v); } @@ -207,7 +207,7 @@ int symex_parseoptionst::doit() if(get_goto_program(options, goto_functions)) return 6; - + label_properties(goto_functions); if(cmdline.isset("show-properties")) @@ -219,13 +219,13 @@ int symex_parseoptionst::doit() if(set_properties(goto_functions)) return 7; - + if(cmdline.isset("show-locs")) { const namespacet ns(symbol_table); locst locs(ns); locs.build(goto_functions); - locs.output(std::cout); + locs.output(std::cout); return 0; } @@ -235,7 +235,7 @@ int symex_parseoptionst::doit() { const namespacet ns(symbol_table); path_searcht path_search(ns); - + path_search.set_message_handler(get_message_handler()); path_search.set_verbosity(get_verbosity()); @@ -262,17 +262,17 @@ int symex_parseoptionst::doit() report_properties(path_search.property_map); report_success(); return 0; - + case safety_checkert::UNSAFE: report_properties(path_search.property_map); report_failure(); return 10; - + default: return 8; } } - + catch(const std::string error_msg) { error() << error_msg << messaget::eom; @@ -285,7 +285,7 @@ int symex_parseoptionst::doit() return 8; } - #if 0 + #if 0 // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); @@ -324,12 +324,12 @@ bool symex_parseoptionst::set_properties(goto_functionst &goto_functions) error(e); return true; } - + catch(int) { return true; } - + return false; } @@ -344,7 +344,7 @@ Function: symex_parseoptionst::get_goto_program Purpose: \*******************************************************************/ - + bool symex_parseoptionst::get_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -365,7 +365,7 @@ bool symex_parseoptionst::get_goto_program( if(read_goto_binary(cmdline.args[0], symbol_table, goto_functions, get_message_handler())) return true; - + config.ansi_c.set_from_symbol_table(symbol_table); if(cmdline.isset("show-symbol-table")) @@ -373,9 +373,9 @@ bool symex_parseoptionst::get_goto_program( show_symbol_table(); return true; } - + irep_idt entry_point=goto_functions.entry_point(); - + if(symbol_table.symbols.find(entry_point)==symbol_table.symbols.end()) { error() << "The goto binary has no entry point; please complete linking" << eom; @@ -389,43 +389,43 @@ bool symex_parseoptionst::get_goto_program( error() << "Please give one source file only" << eom; return true; } - + std::string filename=cmdline.args[0]; - + #ifdef _MSC_VER std::ifstream infile(widen(filename).c_str()); #else std::ifstream infile(filename.c_str()); #endif - + if(!infile) { error() << "failed to open input file `" << filename << "'" << eom; return true; } - + languaget *language=get_language_from_filename(filename); - + if(language==NULL) { error() << "failed to figure out type of file `" << filename << "'" << eom; return true; } - + status("Parsing", filename); - + if(language->parse(infile, filename, get_message_handler())) { error() << "PARSING ERROR" << eom; return true; } - + language->show_parse(std::cout); return true; } else { - + if(parse()) return true; if(typecheck()) return true; if(final()) return true; @@ -440,7 +440,7 @@ bool symex_parseoptionst::get_goto_program( } irep_idt entry_point=goto_functions.entry_point(); - + if(symbol_table.symbols.find(entry_point)==symbol_table.symbols.end()) { error() << "No entry point; please provide a main function" << eom; @@ -471,18 +471,18 @@ bool symex_parseoptionst::get_goto_program( error(e); return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -497,7 +497,7 @@ Function: symex_parseoptionst::process_goto_program Purpose: \*******************************************************************/ - + bool symex_parseoptionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -509,20 +509,20 @@ bool symex_parseoptionst::process_goto_program( // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); - + // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); - + // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); - + // if we aim to cover, replace // all assertions by false to prevent simplification - + if(cmdline.isset("cover-assertions")) make_assertions_false(goto_functions); @@ -552,18 +552,18 @@ bool symex_parseoptionst::process_goto_program( error(e); return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -635,10 +635,10 @@ void symex_parseoptionst::report_properties( it++) if(it->second.status==path_searcht::FAIL) failed++; - + status() << "** " << failed << " of " << property_map.size() << " failed" - << eom; + << eom; } } @@ -662,7 +662,7 @@ void symex_parseoptionst::report_success() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -671,7 +671,7 @@ void symex_parseoptionst::report_success() std::cout << std::endl; } break; - + default: assert(false); } @@ -700,7 +700,7 @@ void symex_parseoptionst::show_counterexample( std::cout << std::endl << "Counterexample:" << std::endl; show_goto_trace(std::cout, ns, error_trace); break; - + case ui_message_handlert::XML_UI: { xmlt xml; @@ -708,7 +708,7 @@ void symex_parseoptionst::show_counterexample( std::cout << xml << std::endl; } break; - + default: assert(false); } @@ -734,7 +734,7 @@ void symex_parseoptionst::report_failure() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -743,7 +743,7 @@ void symex_parseoptionst::report_failure() std::cout << std::endl; } break; - + default: assert(false); } @@ -766,11 +766,11 @@ void symex_parseoptionst::help() std::cout << "\n" "* * Symex " CBMC_VERSION " - Copyright (C) 2013 "; - + std::cout << "(" << (sizeof(void *)*8) << "-bit version)"; - + std::cout << " * *\n"; - + std::cout << "* * Daniel Kroening * *\n" "* * University of Oxford * *\n" diff --git a/src/aa-symex/symex_parseoptions.h b/src/aa-symex/symex_parseoptions.h index ba70d68c242..4c2ba908088 100644 --- a/src/aa-symex/symex_parseoptions.h +++ b/src/aa-symex/symex_parseoptions.h @@ -63,14 +63,14 @@ class symex_parseoptionst: bool process_goto_program( const optionst &options, goto_functionst &goto_functions); - + bool set_properties(goto_functionst &goto_functions); void report_success(); void report_failure(); void report_properties(const path_searcht::property_mapt &); void show_counterexample(const class goto_tracet &); - + void eval_verbosity(); }; diff --git a/src/analyses/Makefile b/src/analyses/Makefile index 4aa6927e205..89f14e4f768 100644 --- a/src/analyses/Makefile +++ b/src/analyses/Makefile @@ -19,6 +19,5 @@ all: analyses$(LIBEXT) ############################################################################### -analyses$(LIBEXT): $(OBJ) +analyses$(LIBEXT): $(OBJ) $(LINKLIB) - diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index dd976334aae..2b8f46d08cd 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -98,10 +98,10 @@ Function: ai_baset::entry_state void ai_baset::entry_state(const goto_functionst &goto_functions) { // find the 'entry function' - + goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.find(goto_functions.entry_point()); - + if(f_it!=goto_functions.function_map.end()) entry_state(f_it->second.body); } @@ -122,7 +122,7 @@ void ai_baset::entry_state(const goto_programt &goto_program) { // The first instruction of 'goto_program' is the entry point, // and we make that 'top'. - get_state(goto_program.instructions.begin()).make_top(); + get_state(goto_program.instructions.begin()).make_top(); } /*******************************************************************\ @@ -199,11 +199,11 @@ ai_baset::locationt ai_baset::get_next( working_sett &working_set) { assert(!working_set.empty()); - + working_sett::iterator i=working_set.begin(); locationt l=i->second; working_set.erase(i); - + return l; } @@ -229,13 +229,13 @@ bool ai_baset::fixedpoint( // We will put all locations at least once into the working set. forall_goto_program_instructions(i_it, goto_program) put_in_working_set(working_set, i_it); - + bool new_data=false; while(!working_set.empty()) { locationt l=get_next(working_set); - + if(visit(l, working_set, goto_program, goto_functions, ns)) new_data=true; } @@ -282,9 +282,9 @@ bool ai_baset::visit( std::unique_ptr tmp_state( make_temporary_state(current)); - + statet &new_values=*tmp_state; - + bool have_new_values=false; if(l->is_function_call() && @@ -307,18 +307,18 @@ bool ai_baset::visit( get_state(to_l); new_values.transform(l, to_l, *this, ns); - + if(merge(new_values, l, to_l)) have_new_values=true; } - + if(have_new_values) { new_data=true; put_in_working_set(working_set, to_l); } } - + return new_data; } @@ -355,17 +355,17 @@ bool ai_baset::do_function_call( return merge(*tmp_state, l_call, l_return); } - + assert(!goto_function.body.instructions.empty()); // This is the edge from call site to function head. - + { // get the state at the beginning of the function locationt l_begin=goto_function.body.instructions.begin(); // initialize state, if necessary get_state(l_begin); - + // do the edge from the call site to the beginning of the function std::unique_ptr tmp_state(make_temporary_state(get_state(l_call))); tmp_state->transform(l_call, l_begin, *this, ns); @@ -395,7 +395,7 @@ bool ai_baset::do_function_call( // Propagate those return merge(*tmp_state, l_end, l_return); } -} +} /*******************************************************************\ @@ -417,13 +417,13 @@ bool ai_baset::do_function_call_rec( const namespacet &ns) { assert(!goto_functions.function_map.empty()); - + bool new_data=false; if(function.id()==ID_symbol) { const irep_idt &identifier=function.get(ID_identifier); - + if(recursion_set.find(identifier)!=recursion_set.end()) { // recursion detected! @@ -431,27 +431,27 @@ bool ai_baset::do_function_call_rec( } else recursion_set.insert(identifier); - + goto_functionst::function_mapt::const_iterator it= goto_functions.function_map.find(identifier); - + if(it==goto_functions.function_map.end()) throw "failed to find function "+id2string(identifier); - + new_data=do_function_call( l_call, l_return, goto_functions, it, arguments, ns); - + recursion_set.erase(identifier); } else if(function.id()==ID_if) { if(function.operands().size()!=3) throw "if has three operands"; - + bool new_data1= do_function_call_rec( l_call, l_return, @@ -489,7 +489,7 @@ bool ai_baset::do_function_call_rec( throw "unexpected function_call argument: "+ function.id_string(); } - + return new_data; } @@ -596,4 +596,3 @@ void ai_baset::concurrent_fixedpoint( } } } - diff --git a/src/analyses/ai.h b/src/analyses/ai.h index 5265830c1e0..c362cce8474 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -31,9 +31,9 @@ class ai_domain_baset virtual ~ai_domain_baset() { } - + typedef goto_programt::const_targett locationt; - + // how function calls are treated: // a) there is an edge from each call site to the function head // b) there is an edge from the last instruction (END_FUNCTION) of the function @@ -52,7 +52,7 @@ class ai_domain_baset const namespacet &ns) const { } - + // no states virtual void make_bottom() { @@ -62,12 +62,12 @@ class ai_domain_baset virtual void make_top() { } - + // a reasonable entry-point state virtual void make_entry() { } - + // also add // // bool merge(const T &b, locationt from, locationt to); @@ -87,7 +87,7 @@ class ai_baset ai_baset() { } - + virtual ~ai_baset() { } @@ -101,7 +101,7 @@ class ai_baset entry_state(goto_program); fixedpoint(goto_program, goto_functions, ns); } - + inline void operator()( const goto_functionst &goto_functions, const namespacet &ns) @@ -132,7 +132,7 @@ class ai_baset virtual void clear() { } - + virtual void output( const namespacet &ns, const goto_functionst &goto_functions, @@ -179,9 +179,9 @@ class ai_baset // the work-queue is sorted by location number typedef std::map working_sett; - + locationt get_next(working_sett &working_set); - + void put_in_working_set( working_sett &working_set, locationt l) @@ -189,13 +189,13 @@ class ai_baset working_set.insert( std::pair(l->location_number, l)); } - + // true = found s.th. new bool fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns); - + virtual void fixedpoint( const goto_functionst &goto_functions, const namespacet &ns)=0; @@ -214,10 +214,10 @@ class ai_baset const goto_programt &goto_program, const goto_functionst &goto_functions, const namespacet &ns); - + typedef std::set recursion_sett; recursion_sett recursion_set; - + // function calls bool do_function_call_rec( locationt l_call, locationt l_return, @@ -234,7 +234,7 @@ class ai_baset const namespacet &ns); // abstract methods - + virtual bool merge(const statet &src, locationt from, locationt to)=0; // for concurrent fixedpoint virtual bool merge_shared( @@ -265,14 +265,14 @@ class ait:public ai_baset if(it==state_map.end()) throw "failed to find state"; return it->second; } - + inline const domainT &operator[](locationt l) const { typename state_mapt::const_iterator it=state_map.find(l); if(it==state_map.end()) throw "failed to find state"; return it->second; } - + virtual void clear() { state_map.clear(); @@ -302,7 +302,7 @@ class ait:public ai_baset statet &dest=get_state(to); return static_cast(dest).merge(static_cast(src), from, to); } - + virtual statet *make_temporary_state(const statet &s) { return new domainT(static_cast(s)); @@ -315,7 +315,7 @@ class ait:public ai_baset sequential_fixedpoint(goto_functions, ns); } -private: +private: // to enforce that domainT is derived from ai_domain_baset void dummy(const domainT &s) { const statet &x=s; (void)x; } diff --git a/src/analyses/call_graph.cpp b/src/analyses/call_graph.cpp index adefb37fb06..347bcd0a0b2 100644 --- a/src/analyses/call_graph.cpp +++ b/src/analyses/call_graph.cpp @@ -19,7 +19,7 @@ Function: call_grapht::call_grapht Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -35,7 +35,7 @@ Function: call_grapht::call_grapht Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -56,7 +56,7 @@ Function: call_grapht::add Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -83,7 +83,7 @@ Function: call_grapht::add Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -102,7 +102,7 @@ Function: call_grapht::output_dot Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -119,7 +119,7 @@ void call_grapht::output_dot(std::ostream &out) const << " [arrowhead=\"vee\"];" << "\n"; } - + out << "}\n"; } @@ -131,7 +131,7 @@ Function: call_grapht::output Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -154,7 +154,7 @@ Function: call_grapht::output_xml Outputs: - Purpose: + Purpose: \*******************************************************************/ diff --git a/src/analyses/call_graph.h b/src/analyses/call_graph.h index beceb50b792..935f6a94f9d 100644 --- a/src/analyses/call_graph.h +++ b/src/analyses/call_graph.h @@ -28,7 +28,7 @@ class call_grapht grapht graph; void add(const irep_idt &caller, const irep_idt &callee); - + protected: void add(const irep_idt &function, const goto_programt &body); diff --git a/src/analyses/cfg_dominators.h b/src/analyses/cfg_dominators.h index 8fda453a7eb..c80754e4f1f 100644 --- a/src/analyses/cfg_dominators.h +++ b/src/analyses/cfg_dominators.h @@ -136,7 +136,7 @@ void cfg_dominators_templatet::fixedpoint(P &program) typename cfgt::nodet &n=cfg[cfg.entry_map[entry_node]]; n.dominators.insert(entry_node); - for(typename cfgt::edgest::const_iterator + for(typename cfgt::edgest::const_iterator s_it=(post_dom?n.in:n.out).begin(); s_it!=(post_dom?n.in:n.out).end(); ++s_it) @@ -151,7 +151,7 @@ void cfg_dominators_templatet::fixedpoint(P &program) bool changed=false; typename cfgt::nodet &node=cfg[cfg.entry_map[current]]; if(node.dominators.empty()) - for(typename cfgt::edgest::const_iterator + for(typename cfgt::edgest::const_iterator p_it=(post_dom?node.out:node.in).begin(); !changed && p_it!=(post_dom?node.out:node.in).end(); ++p_it) @@ -163,11 +163,11 @@ void cfg_dominators_templatet::fixedpoint(P &program) } // compute intersection of predecessors - for(typename cfgt::edgest::const_iterator + for(typename cfgt::edgest::const_iterator p_it=(post_dom?node.out:node.in).begin(); p_it!=(post_dom?node.out:node.in).end(); ++p_it) - { + { const target_sett &other=cfg[p_it->first].dominators; if(other.empty()) continue; @@ -198,7 +198,7 @@ void cfg_dominators_templatet::fixedpoint(P &program) if(changed) // fixed point for node reached? { - for(typename cfgt::edgest::const_iterator + for(typename cfgt::edgest::const_iterator s_it=(post_dom?node.in:node.out).begin(); s_it!=(post_dom?node.in:node.out).end(); ++s_it) @@ -229,7 +229,7 @@ void cfg_dominators_templatet::output(std::ostream &out) const it!=cfg.entry_map.end(); ++it) { unsigned n=it->first->location_number; - + if(post_dom) out << n << " post-dominated by "; else @@ -238,7 +238,7 @@ void cfg_dominators_templatet::output(std::ostream &out) const d_it!=it->second.dominators.end();) { out << (*d_it)->location_number; - if (++d_it!=it->second.dominators.end()) + if (++d_it!=it->second.dominators.end()) out << ", "; } out << "\n"; diff --git a/src/analyses/constant_propagator.cpp b/src/analyses/constant_propagator.cpp index 7e66937efee..66fb6ef71b3 100644 --- a/src/analyses/constant_propagator.cpp +++ b/src/analyses/constant_propagator.cpp @@ -85,7 +85,7 @@ void constant_propagator_domaint::transform( std::cout << "before:\n"; output(std::cout,ai,ns); #endif - + if(from->is_decl()) { const code_declt &code_decl=to_code_decl(from->code); @@ -105,7 +105,7 @@ void constant_propagator_domaint::transform( } else if(from->is_goto()) { - exprt g; + exprt g; if(from->get_target()==to) g = simplify_expr(from->guard, ns); else @@ -121,7 +121,7 @@ void constant_propagator_domaint::transform( else if(from->is_function_call()) { const exprt &function=to_code_function_call(from->code).function(); - + if(function.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(function).get_identifier(); @@ -168,14 +168,14 @@ bool constant_propagator_domaint::two_way_propagate_rec( std::cout << "two_way_propagate_rec: " << from_expr(ns,"",expr) << '\n'; #endif bool change = false; - + if(expr.id()==ID_and) { // need a fixed point here to get the most out of it do { change = false; - + forall_operands(it, expr) if(two_way_propagate_rec(*it, ns)) change = true; @@ -184,10 +184,10 @@ bool constant_propagator_domaint::two_way_propagate_rec( } else if(expr.id()==ID_equal) { - const exprt &lhs = expr.op0(); + const exprt &lhs = expr.op0(); const exprt &rhs = expr.op1(); - // two-way propagation + // two-way propagation valuest copy_values = values; assign_rec(copy_values, lhs, rhs, ns); if(!values.is_constant(rhs) || values.is_constant(lhs)) @@ -238,12 +238,12 @@ Function: constant_propagator_domaint::valuest::is_constant bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const { - if(expr.id()==ID_side_effect && - to_side_effect_expr(expr).get_statement()==ID_nondet) + if(expr.id()==ID_side_effect && + to_side_effect_expr(expr).get_statement()==ID_nondet) return false; - if(expr.id()==ID_side_effect && - to_side_effect_expr(expr).get_statement()==ID_malloc) + if(expr.id()==ID_side_effect && + to_side_effect_expr(expr).get_statement()==ID_malloc) return false; if(expr.id()==ID_symbol) @@ -278,16 +278,16 @@ bool constant_propagator_domaint::valuest::is_constant_address_of(const exprt &e if(expr.id()==ID_index) return is_constant_address_of(to_index_expr(expr).array()) && is_constant(to_index_expr(expr).index()); - + if(expr.id()==ID_member) return is_constant_address_of(to_member_expr(expr).struct_op()); - + if(expr.id()==ID_dereference) return is_constant(to_dereference_expr(expr).pointer()); if(expr.id()==ID_string_constant) return true; - + return true; } @@ -341,7 +341,7 @@ void constant_propagator_domaint::valuest::output( if(is_bottom) out << " bottom\n"; - for(replace_symbolt::expr_mapt::const_iterator + for(replace_symbolt::expr_mapt::const_iterator it=replace_const.expr_map.begin(); it!=replace_const.expr_map.end(); ++it) @@ -383,7 +383,7 @@ Function: constant_propagator_domaint::valuest::merge bool constant_propagator_domaint::valuest::merge(const valuest &src) { - //nothing to do + //nothing to do if(src.is_bottom) return false; @@ -394,11 +394,11 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) is_bottom = src.is_bottom; return true; } - + bool changed = false; //set everything to top that is not in src - for(replace_symbolt::expr_mapt::const_iterator + for(replace_symbolt::expr_mapt::const_iterator it=replace_const.expr_map.begin(); it!=replace_const.expr_map.end(); ) @@ -413,12 +413,12 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) else ++it; } - for(replace_symbolt::expr_mapt::const_iterator + for(replace_symbolt::expr_mapt::const_iterator it=src.replace_const.expr_map.begin(); it!=src.replace_const.expr_map.end(); ++it) - { - replace_symbolt::expr_mapt::iterator + { + replace_symbolt::expr_mapt::iterator c_it = replace_const.expr_map.find(it->first); if(c_it != replace_const.expr_map.end()) @@ -457,15 +457,15 @@ bool constant_propagator_domaint::valuest::meet(const valuest &src) { if(src.is_bottom || is_bottom) return false; - + bool changed = false; - for(replace_symbolt::expr_mapt::const_iterator + for(replace_symbolt::expr_mapt::const_iterator it=src.replace_const.expr_map.begin(); it!=src.replace_const.expr_map.end(); ++it) { - replace_symbolt::expr_mapt::iterator + replace_symbolt::expr_mapt::iterator c_it = replace_const.expr_map.find(it->first); if(c_it != replace_const.expr_map.end()) @@ -513,7 +513,7 @@ Function: constant_propagator_ait::replace Inputs: - Outputs: + Outputs: Purpose: @@ -533,7 +533,7 @@ Function: constant_propagator_ait::replace Inputs: - Outputs: + Outputs: Purpose: @@ -568,8 +568,8 @@ void constant_propagator_ait::replace( { s_it->second.values.replace_const(to_code_function_call(it->code).function()); simplify_expr(to_code_function_call(it->code).function(), ns); - - exprt::operandst &args = + + exprt::operandst &args = to_code_function_call(it->code).arguments(); for(exprt::operandst::iterator o_it = args.begin(); @@ -593,14 +593,14 @@ Function: constant_propagator_ait::replace_types_rec Inputs: - Outputs: + Outputs: Purpose: \*******************************************************************/ void constant_propagator_ait::replace_types_rec( - const replace_symbolt &replace_const, + const replace_symbolt &replace_const, exprt &expr) { replace_const(expr.type()); @@ -608,4 +608,3 @@ void constant_propagator_ait::replace_types_rec( Forall_operands(it, expr) replace_types_rec(replace_const, *it); } - diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 7c7d7086373..36170c71a74 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -24,22 +24,22 @@ class constant_propagator_domaint:public ai_domain_baset { public: valuest():is_bottom(true) { } - + // maps variables to constants replace_symbol_extt replace_const; bool is_bottom; - + void output(std::ostream &, const namespacet &) const; - + bool merge(const valuest &src); bool meet(const valuest &src); - + inline void set_to_bottom() { replace_const.clear(); is_bottom = true; } - + inline void set_to(const irep_idt &lhs_id, const exprt &rhs_val) { replace_const.expr_map[lhs_id] = rhs_val; @@ -59,7 +59,7 @@ class constant_propagator_domaint:public ai_domain_baset { return set_to_top(expr.get_identifier()); } - + inline void set_to_top() { replace_const.clear(); @@ -68,7 +68,7 @@ class constant_propagator_domaint:public ai_domain_baset }; valuest values; - + protected: void assign( valuest &dest, @@ -115,7 +115,7 @@ class constant_propagator_ait:public ait const namespacet &); void replace_types_rec( - const replace_symbolt &replace_const, + const replace_symbolt &replace_const, exprt &expr); }; diff --git a/src/analyses/custom_bitvector_analysis.cpp b/src/analyses/custom_bitvector_analysis.cpp index 8ed4da40997..883ea1ef188 100644 --- a/src/analyses/custom_bitvector_analysis.cpp +++ b/src/analyses/custom_bitvector_analysis.cpp @@ -21,7 +21,7 @@ Function: custom_bitvector_domaint::set_bit Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -35,15 +35,15 @@ void custom_bitvector_domaint::set_bit( case SET_MUST: set_bit(must_bits[identifier], bit_nr); break; - + case CLEAR_MUST: clear_bit(must_bits[identifier], bit_nr); break; - + case SET_MAY: set_bit(may_bits[identifier], bit_nr); break; - + case CLEAR_MAY: clear_bit(may_bits[identifier], bit_nr); break; @@ -58,7 +58,7 @@ Function: custom_bitvector_domaint::set_bit Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -79,7 +79,7 @@ Function: custom_bitvector_domaint::object2id Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -92,7 +92,7 @@ irep_idt custom_bitvector_domaint::object2id(const exprt &src) else if(src.id()==ID_dereference) { const exprt &op=to_dereference_expr(src).pointer(); - + if(op.id()==ID_address_of) { return object2id(to_address_of_expr(op).object()); @@ -124,7 +124,7 @@ Function: custom_bitvector_domaint::assign_lhs Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -144,7 +144,7 @@ Function: custom_bitvector_domaint::assign_lhs Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -158,7 +158,7 @@ void custom_bitvector_domaint::assign_lhs( must_bits.erase(identifier); else must_bits[identifier]=vectors.must_bits; - + if(vectors.may_bits==0) may_bits.erase(identifier); else @@ -173,7 +173,7 @@ Function: custom_bitvector_domaint::get_rhs Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -184,10 +184,10 @@ custom_bitvector_domaint::vectorst bitst::const_iterator may_it=may_bits.find(identifier); if(may_it!=may_bits.end()) vectors.may_bits=may_it->second; - + bitst::const_iterator must_it=must_bits.find(identifier); if(must_it!=must_bits.end()) vectors.must_bits=must_it->second; - + return vectors; } @@ -199,7 +199,7 @@ Function: custom_bitvector_domaint::get_rhs Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -223,7 +223,7 @@ custom_bitvector_domaint::vectorst vectorst v_false=get_rhs(to_if_expr(rhs).false_case()); return merge(v_true, v_false); } - + return vectorst(); } @@ -235,7 +235,7 @@ Function: custom_bitvector_analysist::get_bit_nr Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -250,9 +250,9 @@ unsigned custom_bitvector_analysist::get_bit_nr( return get_bit_nr(to_index_expr(string_expr).array()); else if(string_expr.id()==ID_string_constant) { - irep_idt value=string_expr.get(ID_value); + irep_idt value=string_expr.get(ID_value); return bits(value); - } + } else return bits("(unknown)"); } @@ -265,7 +265,7 @@ Function: custom_bitvector_domaint::aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -282,7 +282,7 @@ std::set custom_bitvector_analysist::aliases( else if(src.id()==ID_dereference) { exprt pointer=to_dereference_expr(src).pointer(); - + std::set pointer_set= local_may_alias_factory(loc).get(loc, pointer); @@ -295,9 +295,9 @@ std::set custom_bitvector_analysist::aliases( { result.insert(dereference_exprt(*p_it)); } - + result.insert(src); - + return result; } else if(src.id()==ID_typecast) @@ -316,7 +316,7 @@ Function: custom_bitvector_domaint::transform Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -340,15 +340,15 @@ void custom_bitvector_domaint::transform( // may alias other stuff std::set lhs_set=cba.aliases(code_assign.lhs(), from); - + vectorst rhs_vectors=get_rhs(code_assign.rhs()); - + for(std::set::const_iterator l_it=lhs_set.begin(); l_it!=lhs_set.end(); l_it++) { assign_lhs(*l_it, rhs_vectors); } - + // is it a pointer? if(code_assign.lhs().type().id()==ID_pointer) { @@ -386,7 +386,7 @@ void custom_bitvector_domaint::transform( { const code_function_callt &code_function_call=to_code_function_call(instruction.code); const exprt &function=code_function_call.function(); - + if(function.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(function).get_identifier(); @@ -400,9 +400,9 @@ void custom_bitvector_domaint::transform( { unsigned bit_nr= cba.get_bit_nr(code_function_call.arguments()[1]); - + modet mode; - + if(identifier=="__CPROVER_set_must") mode=SET_MUST; else if(identifier=="__CPROVER_clear_must") @@ -413,9 +413,9 @@ void custom_bitvector_domaint::transform( mode=CLEAR_MAY; else assert(false); - + exprt lhs=code_function_call.arguments()[0]; - + if(lhs.is_constant() && to_constant_expr(lhs).get_value()==ID_NULL) // NULL means all { @@ -443,10 +443,10 @@ void custom_bitvector_domaint::transform( else { dereference_exprt deref(lhs); - + // may alias other stuff std::set lhs_set=cba.aliases(deref, from); - + for(std::set::const_iterator l_it=lhs_set.begin(); l_it!=lhs_set.end(); l_it++) { @@ -458,11 +458,11 @@ void custom_bitvector_domaint::transform( } } break; - + case OTHER: { const irep_idt &statement=instruction.code.get_statement(); - + if(statement=="set_may" || statement=="set_must" || statement=="clear_may" || @@ -472,9 +472,9 @@ void custom_bitvector_domaint::transform( unsigned bit_nr= cba.get_bit_nr(instruction.code.op1()); - + modet mode; - + if(statement=="set_must") mode=SET_MUST; else if(statement=="clear_must") @@ -485,9 +485,9 @@ void custom_bitvector_domaint::transform( mode=CLEAR_MAY; else assert(false); - + exprt lhs=instruction.code.op0(); - + if(lhs.is_constant() && to_constant_expr(lhs).get_value()==ID_NULL) // NULL means all { @@ -515,10 +515,10 @@ void custom_bitvector_domaint::transform( else { dereference_exprt deref(lhs); - + // may alias other stuff std::set lhs_set=cba.aliases(deref, from); - + for(std::set::const_iterator l_it=lhs_set.begin(); l_it!=lhs_set.end(); l_it++) { @@ -528,12 +528,12 @@ void custom_bitvector_domaint::transform( } } break; - + case GOTO: if(has_get_must_or_may(instruction.guard)) { exprt guard=instruction.guard; - + if(to!=from->get_target()) guard.make_not(); exprt result=eval(guard, cba); @@ -556,7 +556,7 @@ Function: custom_bitvector_domaint::output Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -570,14 +570,14 @@ void custom_bitvector_domaint::output( const custom_bitvector_analysist &cba= static_cast(ai); - + for(bitst::const_iterator it=may_bits.begin(); it!=may_bits.end(); it++) { out << it->first << " MAY:"; bit_vectort b=it->second; - + for(unsigned i=0; b!=0; i++, b>>=1) if(b&1) { @@ -616,7 +616,7 @@ Function: custom_bitvector_domaint::merge Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -667,7 +667,7 @@ bool custom_bitvector_domaint::merge( if(old!=a_it->second) changed=true; } } - + // erase blank ones erase_blank_vectors(may_bits); erase_blank_vectors(must_bits); @@ -708,7 +708,7 @@ Function: custom_bitvector_domaint::has_get_must_or_may Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -717,7 +717,7 @@ bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) if(src.id()=="get_must" || src.id()=="get_may") return true; - + forall_operands(it, src) if(has_get_must_or_may(*it)) return true; @@ -732,7 +732,7 @@ Function: custom_bitvector_domaint::eval Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -748,7 +748,7 @@ exprt custom_bitvector_domaint::eval( custom_bitvector_analysis.get_bit_nr(src.op1()); exprt pointer=src.op0(); - + if(pointer.is_constant() && to_constant_expr(pointer).get_value()==ID_NULL) // NULL means all { @@ -761,7 +761,7 @@ exprt custom_bitvector_domaint::eval( { if(get_bit(b_it->second, bit_nr)) return true_exprt(); } - + return false_exprt(); } else if(src.id()=="get_must") @@ -797,7 +797,7 @@ exprt custom_bitvector_domaint::eval( exprt tmp=src; Forall_operands(it, tmp) *it=eval(*it, custom_bitvector_analysis); - + return tmp; } } @@ -810,7 +810,7 @@ Function: custom_bitvector_analysist::instrument Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -826,7 +826,7 @@ Function: custom_bitvector_analysist::check Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -841,7 +841,7 @@ void custom_bitvector_analysist::check( forall_goto_functions(f_it, goto_functions) { if(!f_it->second.body.has_assertion()) continue; - + if(f_it->first=="__actual_thread_spawn") continue; @@ -852,7 +852,7 @@ void custom_bitvector_analysist::check( { exprt result; irep_idt description; - + if(i_it->is_assert()) { if(!custom_bitvector_domaint::has_get_must_or_may(i_it->guard)) @@ -862,7 +862,7 @@ void custom_bitvector_analysist::check( exprt tmp=eval(i_it->guard, i_it); result=simplify_expr(tmp, ns); - + description=i_it->source_location.get_comment(); } else @@ -875,7 +875,7 @@ void custom_bitvector_analysist::check( out << "SUCCESS"; else if(result.is_false()) out << "FAILURE"; - else + else out << "UNKNOWN"; out << "\">\n"; out << xml(i_it->source_location); @@ -905,7 +905,7 @@ void custom_bitvector_analysist::check( if(!use_xml) out << '\n'; } - + if(!use_xml) out << "SUMMARY: " << pass << " pass, " << fail << " fail, " << unknown << " unknown\n"; diff --git a/src/analyses/custom_bitvector_analysis.h b/src/analyses/custom_bitvector_analysis.h index 9433b919408..b700c0b35ed 100644 --- a/src/analyses/custom_bitvector_analysis.h +++ b/src/analyses/custom_bitvector_analysis.h @@ -17,7 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com /*******************************************************************\ Class: custom_bitvector_domaint - + Purpose: \*******************************************************************/ @@ -65,9 +65,9 @@ class custom_bitvector_domaint:public ai_domain_baset locationt to); typedef unsigned long long bit_vectort; - + typedef std::map bitst; - + struct vectorst { bit_vectort may_bits, must_bits; @@ -75,7 +75,7 @@ class custom_bitvector_domaint:public ai_domain_baset { } }; - + static vectorst merge(const vectorst &a, const vectorst &b) { vectorst result; @@ -83,16 +83,16 @@ class custom_bitvector_domaint:public ai_domain_baset result.must_bits=a.must_bits&b.must_bits; return result; } - + bitst may_bits, must_bits; - + void assign_lhs(const exprt &, const vectorst &); void assign_lhs(const irep_idt &, const vectorst &); vectorst get_rhs(const exprt &) const; vectorst get_rhs(const irep_idt &) const; bool is_bottom; - + custom_bitvector_domaint():is_bottom(true) { } @@ -102,7 +102,7 @@ class custom_bitvector_domaint:public ai_domain_baset const exprt &src, custom_bitvector_analysist &) const; -protected: +protected: typedef enum { SET_MUST, CLEAR_MUST, SET_MAY, CLEAR_MAY } modet; void set_bit(const exprt &, unsigned bit_nr, modet); @@ -112,24 +112,24 @@ class custom_bitvector_domaint:public ai_domain_baset { dest|=(1ll< +class custom_bitvector_analysist:public ait { public: void instrument(goto_functionst &); @@ -144,7 +144,7 @@ class custom_bitvector_analysist:public ait typedef numbering bitst; bitst bits; - + protected: virtual void initialize(const goto_functionst &_goto_functions) { @@ -154,7 +154,7 @@ class custom_bitvector_analysist:public ait friend class custom_bitvector_domaint; local_may_alias_factoryt local_may_alias_factory; - + std::set aliases(const exprt &, locationt loc); }; diff --git a/src/analyses/dependence_graph.cpp b/src/analyses/dependence_graph.cpp index 44bcf2211eb..2e20389259d 100644 --- a/src/analyses/dependence_graph.cpp +++ b/src/analyses/dependence_graph.cpp @@ -379,4 +379,3 @@ void dependence_grapht::add_dep( nodes[n_from].out[n_to].add(kind); nodes[n_to].in[n_from].add(kind); } - diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index 1b07b4ec140..cb25b7ff88b 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -177,4 +177,3 @@ class dependence_grapht: }; #endif - diff --git a/src/analyses/dirty.cpp b/src/analyses/dirty.cpp index aa1f4db55e1..bc4327581cd 100644 --- a/src/analyses/dirty.cpp +++ b/src/analyses/dirty.cpp @@ -53,7 +53,7 @@ void dirtyt::find_dirty(const exprt &expr) find_dirty_address_of(address_of_expr.object()); return; } - + forall_operands(it, expr) find_dirty(*it); } diff --git a/src/analyses/dirty.h b/src/analyses/dirty.h index 709366ad33a..a200690b963 100644 --- a/src/analyses/dirty.h +++ b/src/analyses/dirty.h @@ -47,13 +47,13 @@ class dirtyt { return dirty; } - + protected: void build(const goto_functiont &goto_function); // variables whose address is taken id_sett dirty; - + void find_dirty(const exprt &expr); void find_dirty_address_of(const exprt &expr); }; diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index 1cc15cd43c8..7d610c3198a 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -20,7 +20,7 @@ Function: escape_domaint::is_tracked Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -32,7 +32,7 @@ bool escape_domaint::is_tracked(const symbol_exprt &symbol) identifier=="__CPROVER_dead_object" || identifier=="__CPROVER_deallocated") return false; - + return true; } @@ -44,7 +44,7 @@ Function: escape_domaint::get_function Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -59,7 +59,7 @@ irep_idt escape_domaint::get_function(const exprt &lhs) irep_idt identifier=to_symbol_expr(lhs).get_identifier(); return identifier; } - + return irep_idt(); } @@ -71,7 +71,7 @@ Function: escape_domaint::assign_lhs_cleanup Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -85,7 +85,7 @@ void escape_domaint::assign_lhs_cleanup( if(is_tracked(symbol_expr)) { irep_idt identifier=symbol_expr.get_identifier(); - + if(cleanup_functions.empty()) cleanup_map.erase(identifier); else @@ -102,7 +102,7 @@ Function: escape_domaint::assign_lhs_aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -137,7 +137,7 @@ Function: escape_domaint::get_rhs_cleanup Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -154,7 +154,7 @@ void escape_domaint::get_rhs_cleanup( const escape_domaint::cleanup_mapt::const_iterator m_it= cleanup_map.find(identifier); - + if(m_it!=cleanup_map.end()) cleanup_functions.insert(m_it->second.cleanup_functions.begin(), m_it->second.cleanup_functions.end()); @@ -179,7 +179,7 @@ Function: escape_domaint::get_rhs_aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -194,7 +194,7 @@ void escape_domaint::get_rhs_aliases( { irep_idt identifier=symbol_expr.get_identifier(); alias_set.insert(identifier); - + for(aliasest::const_iterator it=aliases.begin(); it!=aliases.end(); it++) @@ -225,7 +225,7 @@ Function: escape_domaint::get_rhs_aliases_address_of Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -256,7 +256,7 @@ Function: escape_domaint::transform Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -277,7 +277,7 @@ void escape_domaint::transform( case ASSIGN: { const code_assignt &code_assign=to_code_assign(instruction.code); - + std::set cleanup_functions; get_rhs_cleanup(code_assign.rhs(), cleanup_functions); assign_lhs_cleanup(code_assign.lhs(), cleanup_functions); @@ -308,7 +308,7 @@ void escape_domaint::transform( { const code_function_callt &code_function_call=to_code_function_call(instruction.code); const exprt &function=code_function_call.function(); - + if(function.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(function).get_identifier(); @@ -326,7 +326,7 @@ void escape_domaint::transform( // may alias other stuff std::set lhs_set; get_rhs_aliases(lhs, lhs_set); - + for(std::set::const_iterator l_it=lhs_set.begin(); l_it!=lhs_set.end(); l_it++) { @@ -338,7 +338,7 @@ void escape_domaint::transform( } } break; - + case END_FUNCTION: // This is the edge to the call site. break; @@ -355,7 +355,7 @@ Function: escape_domaint::output Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -382,13 +382,13 @@ void escape_domaint::output( out << ' ' << *c_it; out << '\n'; } - + for(aliasest::const_iterator a_it1=aliases.begin(); a_it1!=aliases.end(); a_it1++) { bool first=true; - + for(aliasest::const_iterator a_it2=aliases.begin(); a_it2!=aliases.end(); a_it2++) @@ -413,7 +413,7 @@ Function: escape_domaint::merge Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -443,9 +443,9 @@ bool escape_domaint::merge( a_cleanup.insert(b_cleanup.begin(), b_cleanup.end()); if(a_cleanup.size()!=old_size) changed=true; } - + // kill empty ones - + for(cleanup_mapt::iterator a_it=cleanup_map.begin(); a_it!=cleanup_map.end(); ) // no a_it++ @@ -455,13 +455,13 @@ bool escape_domaint::merge( else a_it++; } - + // do union for(aliasest::const_iterator it=b.aliases.begin(); it!=b.aliases.end(); it++) { irep_idt b_root=b.aliases.find(it); - + if(!aliases.same_set(*it, b_root)) { aliases.make_union(*it, b_root); @@ -478,7 +478,7 @@ bool escape_domaint::merge( aliases.isolate(it); } #endif - + return changed; } @@ -490,18 +490,18 @@ Function: escape_domaint::check_lhs Outputs: - Purpose: + Purpose: \*******************************************************************/ void escape_domaint::check_lhs( const exprt &lhs, - std::set &cleanup_functions) + std::set &cleanup_functions) { if(lhs.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(lhs).get_identifier(); - + // pointer with aleanup function? const escape_domaint::cleanup_mapt::const_iterator m_it= cleanup_map.find(identifier); @@ -511,7 +511,7 @@ void escape_domaint::check_lhs( // count the aliases unsigned count=0; - + for(aliasest::const_iterator a_it=aliases.begin(); a_it!=aliases.end(); @@ -540,7 +540,7 @@ Function: escape_analysist::insert_cleanup Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -553,14 +553,14 @@ void escape_analysist::insert_cleanup( const namespacet &ns) { source_locationt source_location=location->source_location; - + for(std::set::const_iterator c_it=cleanup_functions.begin(); c_it!=cleanup_functions.end(); c_it++) { symbol_exprt function=ns.lookup(*c_it).symbol_expr(); const code_typet &function_type=to_code_type(function.type()); - + goto_function.body.insert_before_swap(location); code_function_callt code; code.lhs().make_nil(); @@ -575,7 +575,7 @@ void escape_analysist::insert_cleanup( if(arg.type()!=param_type) arg.make_typecast(param_type); code.arguments().push_back(arg); } - + location->make_function_call(code); location->source_location=source_location; } @@ -589,7 +589,7 @@ Function: escape_analysist::instrument Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -604,7 +604,7 @@ void escape_analysist::instrument( get_state(i_it); const goto_programt::instructiont &instruction=*i_it; - + switch(instruction.type) { case ASSIGN: @@ -620,14 +620,14 @@ void escape_analysist::instrument( case DEAD: { const code_deadt &code_dead=to_code_dead(instruction.code); - + std::set cleanup_functions1; - + escape_domaint &d=operator[](i_it); const escape_domaint::cleanup_mapt::const_iterator m_it= d.cleanup_map.find("&"+id2string(code_dead.get_identifier())); - + // does it have a cleanup function for the object? if(m_it!=d.cleanup_map.end()) { @@ -637,12 +637,12 @@ void escape_analysist::instrument( } std::set cleanup_functions2; - + d.check_lhs(code_dead.symbol(), cleanup_functions2); insert_cleanup(f_it->second, i_it, code_dead.symbol(), cleanup_functions1, true, ns); insert_cleanup(f_it->second, i_it, code_dead.symbol(), cleanup_functions2, false, ns); - + for(unsigned i=0; i aliasest; aliasest aliases; - + struct cleanupt { std::set cleanup_functions; }; - + typedef std::map cleanup_mapt; cleanup_mapt cleanup_map; - + bool is_bottom; -protected: +protected: void assign_lhs_cleanup(const exprt &, const std::set &); void get_rhs_cleanup(const exprt &, std::set &); void assign_lhs_aliases(const exprt &, const std::set &); @@ -81,13 +81,13 @@ class escape_domaint:public ai_domain_baset void get_rhs_aliases_address_of(const exprt &, std::set &); irep_idt get_function(const exprt &); void check_lhs(const exprt &, std::set &); - + friend class escape_analysist; - + bool is_tracked(const symbol_exprt &); }; -class escape_analysist:public ait +class escape_analysist:public ait { public: void instrument( @@ -102,7 +102,7 @@ class escape_analysist:public ait friend class escape_domaint; numbering bits; - + void insert_cleanup( goto_functionst::goto_functiont &, goto_programt::targett, diff --git a/src/analyses/flow_insensitive_analysis.cpp b/src/analyses/flow_insensitive_analysis.cpp index 43df95892ee..e4782b76e73 100644 --- a/src/analyses/flow_insensitive_analysis.cpp +++ b/src/analyses/flow_insensitive_analysis.cpp @@ -43,7 +43,7 @@ exprt flow_insensitive_abstract_domain_baset::get_guard( tmp.make_not(); return tmp; } - + return from->guard; } @@ -67,13 +67,13 @@ exprt flow_insensitive_abstract_domain_baset::get_return_lhs(locationt to) const if(to->is_end_function()) return static_cast(get_nil_irep()); - + // must be the function call assert(to->is_function_call()); const code_function_callt &code= to_code_function_call(to_code(to->code)); - + return code.lhs(); } @@ -163,7 +163,7 @@ void flow_insensitive_analysis_baset::output( const irep_idt &identifier, std::ostream &out) const { - get_state().output(ns, out); + get_state().output(ns, out); } /*******************************************************************\ @@ -182,15 +182,15 @@ flow_insensitive_analysis_baset::locationt flow_insensitive_analysis_baset::get_ working_sett &working_set) { assert(!working_set.empty()); - + // working_sett::iterator i=working_set.begin(); // locationt l=i->second; // working_set.erase(i); - + // pop_heap(working_set.begin(), working_set.end()); locationt l=working_set.top(); working_set.pop(); - + return l; } @@ -212,21 +212,21 @@ bool flow_insensitive_analysis_baset::fixedpoint( { if(goto_program.instructions.empty()) return false; - + working_sett working_set; - + // make_heap(working_set.begin(), working_set.end()); put_in_working_set( working_set, goto_program.instructions.begin()); - + bool new_data=false; while(!working_set.empty()) { locationt l=get_next(working_set); - + if(visit(l, working_set, goto_program, goto_functions)) new_data=true; } @@ -253,15 +253,15 @@ bool flow_insensitive_analysis_baset::visit( const goto_functionst &goto_functions) { bool new_data=false; - + #if 0 - std::cout << "Visiting: " << l->function << " " << + std::cout << "Visiting: " << l->function << " " << l->location_number << std::endl; #endif goto_programt::const_targetst successors; goto_program.get_successors(l, successors); - + seen_locations.insert(l); if (statistics.find(l)==statistics.end()) statistics[l]=1; @@ -277,15 +277,15 @@ bool flow_insensitive_analysis_baset::visit( if(to_l==goto_program.instructions.end()) continue; - + bool changed=false; - + if(l->is_function_call()) { // this is a big special case const code_function_callt &code= to_code_function_call(to_code(l->code)); - + changed= do_function_call_rec( l, @@ -296,17 +296,17 @@ bool flow_insensitive_analysis_baset::visit( } else changed = get_state().transform(ns, l, to_l); - + if(changed || !seen(to_l)) { - new_data=true; - put_in_working_set(working_set, to_l); + new_data=true; + put_in_working_set(working_set, to_l); } } - + // if (id2string(l->function).find("debug")!=std::string::npos) // std::cout << l->function << std::endl; //=="messages::debug") - + // { // static unsigned state_cntr=0; // std::string s("pastate"); s += i2string(state_cntr); @@ -344,33 +344,33 @@ bool flow_insensitive_analysis_baset::do_function_call( if(!goto_function.body_available()) { - const code_function_callt &code = + const code_function_callt &code = to_code_function_call(to_code(l_call->code)); - + goto_programt temp; - + goto_programt::targett r=temp.add_instruction(); r->make_return(); r->code=code_returnt(); r->function=f_it->first; r->location_number=0; - + exprt rhs=side_effect_expr_nondett(code.lhs().type()); - r->code.move_to_operands(rhs); - - goto_programt::targett t=temp.add_instruction(END_FUNCTION); + r->code.move_to_operands(rhs); + + goto_programt::targett t=temp.add_instruction(END_FUNCTION); t->code.set(ID_identifier, code.function()); t->function=f_it->first; t->location_number=1; - + locationt l_next=l_call; l_next++; bool new_data=state.transform(ns, l_call, r); new_data = state.transform(ns, r, t) || new_data; new_data = state.transform(ns, t, l_next) || new_data; - + return new_data; } - + assert(!goto_function.body.instructions.empty()); bool new_data=false; @@ -378,9 +378,9 @@ bool flow_insensitive_analysis_baset::do_function_call( { // get the state at the beginning of the function locationt l_begin=goto_function.body.instructions.begin(); - + // do the edge from the call site to the beginning of the function - new_data=state.transform(ns, l_call, l_begin); + new_data=state.transform(ns, l_call, l_begin); // do each function at least once if(functions_done.find(f_it->first)== @@ -410,9 +410,9 @@ bool flow_insensitive_analysis_baset::do_function_call( l_next++; new_data = state.transform(ns, l_end, l_next) || new_data; } - + return new_data; -} +} /*******************************************************************\ @@ -432,13 +432,13 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( const exprt::operandst &arguments, statet &state, const goto_functionst &goto_functions) -{ +{ bool new_data = false; - + if(function.id()==ID_symbol) { const irep_idt &identifier=function.get(ID_identifier); - + if(recursion_set.find(identifier)!=recursion_set.end()) { // recursion detected! @@ -446,29 +446,29 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( } else recursion_set.insert(identifier); - + goto_functionst::function_mapt::const_iterator it= goto_functions.function_map.find(identifier); - + if(it==goto_functions.function_map.end()) throw "failed to find function "+id2string(identifier); - - new_data = + + new_data = do_function_call( l_call, goto_functions, it, arguments, state); - + recursion_set.erase(identifier); } else if(function.id()==ID_if) { if(function.operands().size()!=3) throw "if takes three arguments"; - - new_data = + + new_data = do_function_call_rec( l_call, function.op1(), @@ -488,7 +488,7 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( { // get value set expr_sett values; - + get_reference_set(function, values); // now call all of these @@ -499,19 +499,19 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( if(it->id()==ID_object_descriptor) { const object_descriptor_exprt &o=to_object_descriptor_expr(*it); - + // ... but only if they are actually functions. goto_functionst::function_mapt::const_iterator it= goto_functions.function_map.find(o.object().get(ID_identifier)); - + if (it!=goto_functions.function_map.end()) { new_data = do_function_call_rec( - l_call, - o.object(), - arguments, - state, + l_call, + o.object(), + arguments, + state, goto_functions) || new_data; } } diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index 8906a40b39d..ffe5f3671ad 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -37,15 +37,15 @@ class flow_insensitive_abstract_domain_baset virtual ~flow_insensitive_abstract_domain_baset() { } - + virtual void output( const namespacet &ns, std::ostream &out) const { } - + typedef hash_set_cont expr_sett; - + virtual void get_reference_set( const namespacet &ns, const exprt &expr, @@ -54,17 +54,17 @@ class flow_insensitive_abstract_domain_baset // dummy, overload me! expr_set.clear(); } - + virtual void clear(void)=0; - + protected: friend class flow_insensitive_analysis_baset; bool changed; - // utilities - + // utilities + // get guard of a conditional edge exprt get_guard(locationt from, locationt to) const; - + // get lhs that return value is assigned to // for an edge that returns from a function exprt get_return_lhs(locationt to) const; @@ -75,11 +75,11 @@ class flow_insensitive_analysis_baset public: typedef flow_insensitive_abstract_domain_baset statet; typedef goto_programt::const_targett locationt; - + std::set seen_locations; - + std::map statistics; - + bool seen( const locationt& l ) { return (seen_locations.find(l)!=seen_locations.end()); @@ -90,7 +90,7 @@ class flow_insensitive_analysis_baset initialized(false) { } - + virtual void initialize( const goto_programt &goto_program) { @@ -99,23 +99,23 @@ class flow_insensitive_analysis_baset initialized=true; } } - + virtual void initialize( const goto_functionst &goto_functions) { if(!initialized) { - initialized=true; + initialized=true; } } - + virtual void update(const goto_programt &goto_program); - + virtual void update(const goto_functionst &goto_functions); - + virtual void operator()( const goto_programt &goto_program); - + virtual void operator()( const goto_functionst &goto_functions); @@ -127,7 +127,7 @@ class flow_insensitive_analysis_baset { initialized=false; } - + virtual void output( const goto_functionst &goto_functions, std::ostream &out); @@ -141,16 +141,16 @@ class flow_insensitive_analysis_baset protected: const namespacet &ns; - + virtual void output( const goto_programt &goto_program, const irep_idt &identifier, std::ostream &out) const; typedef std::priority_queue working_sett; - + locationt get_next(working_sett &working_set); - + void put_in_working_set( working_sett &working_set, locationt l) @@ -162,11 +162,11 @@ class flow_insensitive_analysis_baset bool fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions); - + bool fixedpoint( goto_functionst::function_mapt::const_iterator it, const goto_functionst &goto_functions); - + void fixedpoint( const goto_functionst &goto_functions); @@ -176,21 +176,21 @@ class flow_insensitive_analysis_baset working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions); - + static locationt successor(locationt l) { l++; return l; } - + typedef std::set functions_donet; functions_donet functions_done; typedef std::set recursion_sett; recursion_sett recursion_set; - + bool initialized; - + // function calls bool do_function_call_rec( locationt l_call, @@ -207,10 +207,10 @@ class flow_insensitive_analysis_baset statet &new_state); // abstract methods - + virtual statet &get_state()=0; virtual const statet &get_state() const=0; - + typedef flow_insensitive_abstract_domain_baset::expr_sett expr_sett; virtual void get_reference_set( @@ -230,13 +230,13 @@ class flow_insensitive_analysist:public flow_insensitive_analysis_baset } typedef goto_programt::const_targett locationt; - + virtual void clear() { state.clear(); flow_insensitive_analysis_baset::clear(); } - + inline T& get_data() { return state; } inline const T& get_data() const { return state; } @@ -245,7 +245,7 @@ class flow_insensitive_analysist:public flow_insensitive_analysis_baset virtual statet &get_state() { return state; } - virtual const statet &get_state() const { return state; } + virtual const statet &get_state() const { return state; } void get_reference_set( const exprt &expr, @@ -254,7 +254,7 @@ class flow_insensitive_analysist:public flow_insensitive_analysis_baset state.get_reference_set(ns, expr, expr_set); } -private: +private: // to enforce that T is derived from abstract_domain_baset void dummy(const T &s) { const statet &x=dummy1(s); (void)x; } }; diff --git a/src/analyses/global_may_alias.cpp b/src/analyses/global_may_alias.cpp index 41ba46985e7..0e3e190aa29 100644 --- a/src/analyses/global_may_alias.cpp +++ b/src/analyses/global_may_alias.cpp @@ -16,7 +16,7 @@ Function: global_may_alias_domaint::assign_lhs_aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -47,7 +47,7 @@ Function: global_may_alias_domaint::get_rhs_aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -59,7 +59,7 @@ void global_may_alias_domaint::get_rhs_aliases( { irep_idt identifier=to_symbol_expr(rhs).get_identifier(); alias_set.insert(identifier); - + for(aliasest::const_iterator it=aliases.begin(); it!=aliases.end(); it++) @@ -89,7 +89,7 @@ Function: global_may_alias_domaint::get_rhs_aliases_address_of Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -120,7 +120,7 @@ Function: global_may_alias_domaint::transform Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -137,7 +137,7 @@ void global_may_alias_domaint::transform( case ASSIGN: { const code_assignt &code_assign=to_code_assign(instruction.code); - + std::set aliases; get_rhs_aliases(code_assign.rhs(), aliases); assign_lhs_aliases(code_assign.lhs(), aliases); @@ -170,7 +170,7 @@ Function: global_may_alias_domaint::output Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -184,7 +184,7 @@ void global_may_alias_domaint::output( a_it1++) { bool first=true; - + for(aliasest::const_iterator a_it2=aliases.begin(); a_it2!=aliases.end(); a_it2++) @@ -209,7 +209,7 @@ Function: global_may_alias_domaint::merge Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -225,7 +225,7 @@ bool global_may_alias_domaint::merge( it!=b.aliases.end(); it++) { irep_idt b_root=b.aliases.find(it); - + if(!aliases.same_set(*it, b_root)) { aliases.make_union(*it, b_root); @@ -242,6 +242,6 @@ bool global_may_alias_domaint::merge( aliases.isolate(it); } #endif - + return changed; } diff --git a/src/analyses/global_may_alias.h b/src/analyses/global_may_alias.h index 26d5469a2f9..49f6d7f8688 100644 --- a/src/analyses/global_may_alias.h +++ b/src/analyses/global_may_alias.h @@ -18,7 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com /*******************************************************************\ Class: global_may_alias_domaint - + Purpose: \*******************************************************************/ @@ -43,27 +43,27 @@ class global_may_alias_domaint:public ai_domain_baset const global_may_alias_domaint &b, locationt from, locationt to); - + void make_bottom() { aliases.clear(); } - + void make_top() { aliases.clear(); } - + typedef union_find aliasest; aliasest aliases; - -protected: + +protected: void assign_lhs_aliases(const exprt &, const std::set &); void get_rhs_aliases(const exprt &, std::set &); void get_rhs_aliases_address_of(const exprt &, std::set &); }; -class global_may_alias_analysist:public ait +class global_may_alias_analysist:public ait { protected: virtual void initialize(const goto_functionst &_goto_functions) diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index 40e4fa860cd..8aa43ba9769 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -46,14 +46,14 @@ class goto_checkt retain_trivial=_options.get_bool_option("retain-trivial"); enable_assert_to_assume=_options.get_bool_option("assert-to-assume"); enable_assertions=_options.get_bool_option("assertions"); - enable_assumptions=_options.get_bool_option("assumptions"); + enable_assumptions=_options.get_bool_option("assumptions"); error_labels=_options.get_list_option("error-label"); } typedef goto_functionst::goto_functiont goto_functiont; void goto_check(goto_functiont &goto_function); - + irep_idt mode; protected: @@ -84,20 +84,20 @@ class goto_checkt const source_locationt &, const exprt &src_expr, const guardt &guard); - + goto_programt new_code; typedef std::set assertionst; assertionst assertions; - + void invalidate(const exprt &lhs); - + inline static bool has_dereference(const exprt &src) { return has_subexpr(src, ID_dereference); } bool enable_bounds_check; - bool enable_pointer_check; + bool enable_pointer_check; bool enable_memory_leak_check; bool enable_div_by_zero_check; bool enable_signed_overflow_check; @@ -138,7 +138,7 @@ void goto_checkt::invalidate(const exprt &lhs) // clear all assertions about 'symbol' find_symbols_sett find_symbols_set; find_symbols_set.insert(to_symbol_expr(lhs).get_identifier()); - + for(assertionst::iterator it=assertions.begin(); it!=assertions.end(); @@ -146,11 +146,11 @@ void goto_checkt::invalidate(const exprt &lhs) { assertionst::iterator next=it; next++; - + if(has_symbol(*it, find_symbols_set) || has_dereference(*it)) assertions.erase(it); - + it=next; } } @@ -220,10 +220,10 @@ void goto_checkt::undefined_shift_check( // Undefined for all types and shifts if distance exceeds width, // and also undefined for negative distances. - + const typet &distance_type= ns.follow(expr.distance().type()); - + if(distance_type.id()==ID_signedbv) { binary_relation_exprt inequality( @@ -240,15 +240,15 @@ void goto_checkt::undefined_shift_check( const typet &op_type= ns.follow(expr.op().type()); - + if(op_type.id()==ID_unsignedbv || op_type.id()==ID_signedbv) - { + { exprt width_expr= from_integer(to_bitvector_type(op_type).get_width(), distance_type); if(width_expr.is_nil()) throw "no number for width for operator "+expr.id_string(); - + binary_relation_exprt inequality( expr.distance(), ID_lt, width_expr); @@ -322,24 +322,24 @@ void goto_checkt::integer_overflow_check( // First, check type. const typet &type=ns.follow(expr.type()); - + if(type.id()==ID_signedbv && !enable_signed_overflow_check) return; if(type.id()==ID_unsignedbv && !enable_unsigned_overflow_check) return; - + // add overflow subgoal if(expr.id()==ID_typecast) { // conversion to signed int may overflow - + if(expr.operands().size()!=1) throw "typecast takes one operand"; const typet &old_type=ns.follow(expr.op0().type()); - + if(type.id()==ID_signedbv) { std::size_t new_width=to_signedbv_type(type).get_width(); @@ -514,7 +514,7 @@ void goto_checkt::integer_overflow_check( expr, guard); } - + return; } else if(expr.id()==ID_mod) @@ -528,7 +528,7 @@ void goto_checkt::integer_overflow_check( { // overflow on unary- can only happen with the smallest // representable number 100....0 - + equal_exprt int_min_eq( expr.op0(), to_signedbv_type(type).smallest_expr()); @@ -540,7 +540,7 @@ void goto_checkt::integer_overflow_check( expr, guard); } - + return; } @@ -551,11 +551,11 @@ void goto_checkt::integer_overflow_check( { // The overflow checks are binary! // We break these up. - + for(unsigned i=1; i=3) { assert(expr.id()!=ID_minus); - + // break up exprt tmp=make_binary(expr); float_overflow_check(tmp, guard); @@ -751,7 +751,7 @@ void goto_checkt::nan_check( // first, check type if(expr.type().id()!=ID_floatbv) return; - + if(expr.id()!=ID_plus && expr.id()!=ID_mult && expr.id()!=ID_div && @@ -759,9 +759,9 @@ void goto_checkt::nan_check( return; // add NaN subgoal - + exprt isnan; - + if(expr.id()==ID_div) { assert(expr.operands().size()==2); @@ -774,7 +774,7 @@ void goto_checkt::nan_check( ieee_float_equal_exprt(expr.op1(), gen_zero(expr.op1().type()))); exprt div_inf=unary_exprt(ID_isinf, expr.op1(), bool_typet()); - + isnan=or_exprt(zero_div_zero, div_inf); } else if(expr.id()==ID_mult) @@ -946,7 +946,7 @@ void goto_checkt::pointer_validity_check( local_bitvector_analysist::flagst flags= local_bitvector_analysis->get(t, pointer); - + const typet &dereference_type=pointer_type.subtype(); // For Java, we only need to check for null @@ -1108,7 +1108,7 @@ void goto_checkt::bounds_check( +array_type.id_string(); std::string name=array_name(expr.array()); - + const exprt &index=expr.index(); object_descriptor_exprt ode; ode.build(expr, ns); @@ -1125,7 +1125,7 @@ void goto_checkt::bounds_check( else { mp_integer i; - + if(!to_integer(index, i) && i>=0) { // ok @@ -1275,14 +1275,14 @@ void goto_checkt::add_guarded_claim( new_expr=exprt(ID_implies, bool_typet()); new_expr.move_to_operands(guard_expr, expr); } - + if(assertions.insert(new_expr).second) { goto_program_instruction_typet type= enable_assert_to_assume?ASSUME:ASSERT; - + goto_programt::targett t=new_code.add_instruction(type); - + std::string source_expr_string=from_expr(ns, "", src_expr); t->guard.swap(new_expr); @@ -1410,7 +1410,7 @@ void goto_checkt::check_rec( else if(expr.id()==ID_div) { div_by_zero_check(to_div_expr(expr), guard); - + if(expr.type().id()==ID_signedbv) integer_overflow_check(expr, guard); else if(expr.type().id()==ID_floatbv) @@ -1497,7 +1497,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) } assertions.clear(); - + local_bitvector_analysist local_bitvector_analysis_obj(goto_function); local_bitvector_analysis=&local_bitvector_analysis_obj; @@ -1507,7 +1507,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) { t=it; goto_programt::instructiont &i=*it; - + new_code.clear(); // we clear all recorded assertions if @@ -1516,7 +1516,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) if(retain_trivial || i.is_target()) assertions.clear(); - + check(i.guard); // magic ERROR label? @@ -1539,11 +1539,11 @@ void goto_checkt::goto_check(goto_functiont &goto_function) t->source_location.set("user-provided", true); } } - + if(i.is_other()) { const irep_idt &statement=i.code.get(ID_statement); - + if(statement==ID_expression) { check(i.code); @@ -1557,10 +1557,10 @@ void goto_checkt::goto_check(goto_functiont &goto_function) else if(i.is_assign()) { const code_assignt &code_assign=to_code_assign(i.code); - + check(code_assign.lhs()); check(code_assign.rhs()); - + // the LHS might invalidate any assertion invalidate(code_assign.lhs()); } @@ -1568,7 +1568,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) { const code_function_callt &code_function_call= to_code_function_call(i.code); - + // for Java, need to check whether 'this' is null // on non-static method invocations if(mode==ID_java && @@ -1578,10 +1578,10 @@ void goto_checkt::goto_check(goto_functiont &goto_function) to_code_type(code_function_call.function().type()).has_this()) { exprt pointer=code_function_call.arguments()[0]; - + local_bitvector_analysist::flagst flags= local_bitvector_analysis->get(t, pointer); - + if(flags.is_unknown() || flags.is_null()) { notequal_exprt not_eq_null(pointer, gen_zero(pointer.type())); @@ -1595,7 +1595,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) guardt()); } } - + forall_operands(it, code_function_call) check(*it); @@ -1618,11 +1618,11 @@ void goto_checkt::goto_check(goto_functiont &goto_function) i.code.op0().operands().size()==1) { // must not throw NULL - + exprt pointer=i.code.op0().op0(); if(pointer.type().subtype().get(ID_identifier)!="java::java.lang.AssertionError") - { + { notequal_exprt not_eq_null(pointer, gen_zero(pointer.type())); add_guarded_claim( @@ -1656,7 +1656,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) { assert(i.code.operands().size()==1); const symbol_exprt &variable=to_symbol_expr(i.code.op0()); - + // is it dirty? if(local_bitvector_analysis->dirty(variable)) { @@ -1686,7 +1686,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) goto_programt::targett t=new_code.add_instruction(); t->make_assignment(); t->code=code_assignt(leak_expr, leak_expr); - + source_locationt source_location; source_location.set_function(i.function); @@ -1722,10 +1722,10 @@ void goto_checkt::goto_check(goto_functiont &goto_function) if(it->source_location.get_column()!=irep_idt()) i_it->source_location.set_column(it->source_location.get_column()); } - + if(i_it->function==irep_idt()) i_it->function=it->function; } - + // insert new instructions -- make sure targets are not moved while(!new_code.instructions.empty()) @@ -1756,7 +1756,7 @@ void goto_check( { goto_checkt goto_check(ns, options); goto_check.goto_check(goto_function); -} +} /*******************************************************************\ @@ -1776,7 +1776,7 @@ void goto_check( goto_functionst &goto_functions) { goto_checkt goto_check(ns, options); - + for(goto_functionst::function_mapt::iterator it=goto_functions.function_map.begin(); it!=goto_functions.function_map.end(); @@ -1784,7 +1784,7 @@ void goto_check( { goto_check.goto_check(it->second); } -} +} /*******************************************************************\ @@ -1804,7 +1804,7 @@ void goto_check( { const namespacet ns(goto_model.symbol_table); goto_checkt goto_check(ns, options); - + for(goto_functionst::function_mapt::iterator it=goto_model.goto_functions.function_map.begin(); it!=goto_model.goto_functions.function_map.end(); @@ -1812,4 +1812,4 @@ void goto_check( { goto_check.goto_check(it->second); } -} +} diff --git a/src/analyses/goto_rw.cpp b/src/analyses/goto_rw.cpp index 0efe8d2ff85..2d84edc27ea 100644 --- a/src/analyses/goto_rw.cpp +++ b/src/analyses/goto_rw.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: +Module: Author: Daniel Kroening @@ -1015,7 +1015,7 @@ void goto_rw(goto_programt::const_targett target, case NO_INSTRUCTION_TYPE: assert(false); break; - + case GOTO: case ASSUME: case ASSERT: @@ -1024,7 +1024,7 @@ void goto_rw(goto_programt::const_targett target, rw_range_sett::READ, target->guard); break; - + case RETURN: { const code_returnt &code_return= @@ -1036,7 +1036,7 @@ void goto_rw(goto_programt::const_targett target, code_return.return_value()); } break; - + case OTHER: //if it's printf, mark the operands as read here if (target->code.get(ID_statement)==ID_printf) @@ -1045,7 +1045,7 @@ void goto_rw(goto_programt::const_targett target, rw_set.get_objects_rec(target, rw_range_sett::READ, *it); } break; - + case SKIP: case START_THREAD: case END_THREAD: @@ -1056,12 +1056,12 @@ void goto_rw(goto_programt::const_targett target, case THROW: case CATCH: // these don't read or write anything - break; + break; case ASSIGN: goto_rw(target, to_code_assign(target->code), rw_set); break; - + case DEAD: rw_set.get_objects_rec( target, @@ -1077,7 +1077,7 @@ void goto_rw(goto_programt::const_targett target, rw_range_sett::LHS_W, to_code_decl(target->code).symbol()); break; - + case FUNCTION_CALL: goto_rw(target, to_code_function_call(target->code), rw_set); break; @@ -1128,4 +1128,3 @@ void goto_rw(const goto_functionst &goto_functions, goto_rw(body, rw_set); } } - diff --git a/src/analyses/goto_rw.h b/src/analyses/goto_rw.h index ab324d4e801..54b8bb309f8 100644 --- a/src/analyses/goto_rw.h +++ b/src/analyses/goto_rw.h @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: +Module: Author: Daniel Kroening diff --git a/src/analyses/interval_analysis.cpp b/src/analyses/interval_analysis.cpp index 80183b3516e..f260c10372d 100644 --- a/src/analyses/interval_analysis.cpp +++ b/src/analyses/interval_analysis.cpp @@ -34,7 +34,7 @@ void instrument_intervals( find_symbols(i_it->code, symbols); find_symbols(i_it->guard, symbols); } - + Forall_goto_program_instructions(i_it, goto_function.body) { if(i_it==goto_function.body.instructions.begin()) @@ -60,7 +60,7 @@ void instrument_intervals( else continue; // don't instrument } - + const interval_domaint &d=interval_analysis[i_it]; exprt::operandst assertion; @@ -74,7 +74,7 @@ void instrument_intervals( if(!tmp.is_true()) assertion.push_back(tmp); } - + if(!assertion.empty()) { goto_programt::targett t=i_it; @@ -104,7 +104,7 @@ void interval_analysis( goto_functionst &goto_functions) { ait interval_analysis; - + interval_analysis(goto_functions, ns); Forall_goto_functions(f_it, goto_functions) diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index 4f8aca54d4b..93a487f6c41 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -90,15 +90,15 @@ void interval_domaint::transform( case DECL: havoc_rec(to_code_decl(instruction.code).symbol()); break; - + case DEAD: havoc_rec(to_code_dead(instruction.code).symbol()); break; - + case ASSIGN: assign(to_code_assign(instruction.code)); break; - + case GOTO: { locationt next=from; @@ -109,11 +109,11 @@ void interval_domaint::transform( assume(instruction.guard, ns); } break; - + case ASSUME: assume(instruction.guard, ns); break; - + case FUNCTION_CALL: { const code_function_callt &code_function_call= @@ -122,7 +122,7 @@ void interval_domaint::transform( havoc_rec(code_function_call.lhs()); } break; - + default:; } } @@ -163,7 +163,7 @@ bool interval_domaint::merge( integer_intervalt previous=it->second; it->second.join(b_it->second); if(it->second!=previous) result=true; - + it++; } } @@ -182,7 +182,7 @@ bool interval_domaint::merge( ieee_float_intervalt previous=it->second; it->second.join(b_it->second); if(it->second!=previous) result=true; - + it++; } } @@ -269,27 +269,27 @@ void interval_domaint::assume_rec( assume_rec(lhs, ID_le, rhs); return; } - + if(id==ID_notequal) return; // won't do split - + if(id==ID_ge) - return assume_rec(rhs, ID_le, lhs); - + return assume_rec(rhs, ID_le, lhs); + if(id==ID_gt) - return assume_rec(rhs, ID_lt, lhs); + return assume_rec(rhs, ID_lt, lhs); // we now have lhs < rhs or // lhs <= rhs assert(id==ID_lt || id==ID_le); - #ifdef DEBUG - std::cout << "assume_rec: " + #ifdef DEBUG + std::cout << "assume_rec: " << from_expr(lhs) << " " << id << " " << from_expr(rhs) << "\n"; #endif - + if(lhs.id()==ID_symbol && rhs.id()==ID_constant) { irep_idt lhs_identifier=to_symbol_expr(lhs).get_identifier(); @@ -315,7 +315,7 @@ void interval_domaint::assume_rec( else if(lhs.id()==ID_constant && rhs.id()==ID_symbol) { irep_idt rhs_identifier=to_symbol_expr(rhs).get_identifier(); - + if(is_int(lhs.type()) && is_int(rhs.type())) { mp_integer tmp; @@ -338,7 +338,7 @@ void interval_domaint::assume_rec( { irep_idt lhs_identifier=to_symbol_expr(lhs).get_identifier(); irep_idt rhs_identifier=to_symbol_expr(rhs).get_identifier(); - + if(is_int(lhs.type()) && is_int(rhs.type())) { integer_intervalt &lhs_i=int_map[lhs_identifier]; @@ -459,18 +459,18 @@ exprt interval_domaint::make_expression(const symbol_exprt &src) const exprt::operandst conjuncts; - if(interval.upper_set) + if(interval.upper_set) { exprt tmp=from_integer(interval.upper, src.type()); conjuncts.push_back(binary_relation_exprt(src, ID_le, tmp)); } - if(interval.lower_set) + if(interval.lower_set) { exprt tmp=from_integer(interval.lower, src.type()); conjuncts.push_back(binary_relation_exprt(tmp, ID_le, src)); } - + return conjunction(conjuncts); } else if(is_float(src.type())) @@ -483,18 +483,18 @@ exprt interval_domaint::make_expression(const symbol_exprt &src) const exprt::operandst conjuncts; - if(interval.upper_set) + if(interval.upper_set) { exprt tmp=interval.upper.to_expr(); conjuncts.push_back(binary_relation_exprt(src, ID_le, tmp)); } - if(interval.lower_set) + if(interval.lower_set) { exprt tmp=interval.lower.to_expr(); conjuncts.push_back(binary_relation_exprt(tmp, ID_le, src)); } - + return conjunction(conjuncts); } else diff --git a/src/analyses/interval_domain.h b/src/analyses/interval_domain.h index 0c3d9aa68c9..b8cc21fa0d9 100644 --- a/src/analyses/interval_domain.h +++ b/src/analyses/interval_domain.h @@ -24,13 +24,13 @@ class interval_domaint:public ai_domain_baset // Trivial, conjunctive interval domain for both float // and integers. The categorization 'float' and 'integers' // is done by is_int and is_float. - + virtual void transform( locationt from, locationt to, ai_baset &ai, const namespacet &ns); - + virtual void output( std::ostream &out, const ai_baset &ai, @@ -40,7 +40,7 @@ class interval_domaint:public ai_domain_baset const interval_domaint &b, locationt from, locationt to); - + // no states virtual void make_bottom() { @@ -48,7 +48,7 @@ class interval_domaint:public ai_domain_baset float_map.clear(); bottom=true; } - + // all states virtual void make_top() { @@ -58,14 +58,14 @@ class interval_domaint:public ai_domain_baset } exprt make_expression(const symbol_exprt &) const; - + void assume(const exprt &, const namespacet &); inline static bool is_int(const typet &src) { return src.id()==ID_signedbv || src.id()==ID_unsignedbv; } - + inline static bool is_float(const typet &src) { return src.id()==ID_floatbv; diff --git a/src/analyses/invariant_propagation.cpp b/src/analyses/invariant_propagation.cpp index 3c244ed0bc4..56e285247e0 100644 --- a/src/analyses/invariant_propagation.cpp +++ b/src/analyses/invariant_propagation.cpp @@ -72,12 +72,12 @@ void invariant_propagationt::add_objects( // get the globals object_listt globals; get_globals(globals); - + // get the locals goto_programt::decl_identifierst locals; goto_program.get_decl_identifiers(locals); - // cache the list for the locals to speed things up + // cache the list for the locals to speed things up typedef hash_map_cont object_cachet; object_cachet object_cache; @@ -88,7 +88,7 @@ void invariant_propagationt::add_objects( { #if 0 invariant_sett &is=(*this)[i_it].invariant_set; - + is.add_objects(globals); #endif @@ -103,7 +103,7 @@ void invariant_propagationt::add_objects( if(e_it==object_cache.end()) { const symbolt &symbol=ns.lookup(*l_it); - + object_listt &objects=object_cache[*l_it]; get_objects(symbol, objects); #if 0 @@ -116,7 +116,7 @@ void invariant_propagationt::add_objects( #endif } } -} +} /*******************************************************************\ @@ -137,7 +137,7 @@ void invariant_propagationt::get_objects( std::list object_list; get_objects_rec(symbol.symbol_expr(), object_list); - + for(std::list::const_iterator it=object_list.begin(); it!=object_list.end(); @@ -167,12 +167,12 @@ void invariant_propagationt::get_objects_rec( t.id()==ID_union) { const struct_typet &struct_type=to_struct_type(t); - + const struct_typet::componentst &c=struct_type.components(); - + exprt member_expr(ID_member); member_expr.copy_to_operands(src); - + for(struct_typet::componentst::const_iterator it=c.begin(); it!=c.end(); @@ -213,7 +213,7 @@ void invariant_propagationt::add_objects( // get the globals object_listt globals; get_globals(globals); - + for(goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.begin(); f_it!=goto_functions.function_map.end(); @@ -222,10 +222,10 @@ void invariant_propagationt::add_objects( // get the locals std::set locals; get_local_identifiers(f_it->second, locals); - + const goto_programt &goto_program=f_it->second.body; - // cache the list for the locals to speed things up + // cache the list for the locals to speed things up typedef hash_map_cont object_cachet; object_cachet object_cache; @@ -236,7 +236,7 @@ void invariant_propagationt::add_objects( { #if 0 invariant_sett &is=(*this)[i_it].invariant_set; - + is.add_objects(globals); #endif @@ -251,7 +251,7 @@ void invariant_propagationt::add_objects( if(e_it==object_cache.end()) { const symbolt &symbol=ns.lookup(*l_it); - + object_listt &objects=object_cache[*l_it]; get_objects(symbol, objects); #if 0 @@ -265,7 +265,7 @@ void invariant_propagationt::add_objects( } } } -} +} /*******************************************************************\ @@ -287,7 +287,7 @@ void invariant_propagationt::get_globals( if(it->second.is_lvalue && it->second.is_static_lifetime) get_objects(it->second, dest); -} +} /*******************************************************************\ @@ -317,9 +317,9 @@ bool invariant_propagationt::check_type(const typet &type) const return true; else if(type.id()==ID_bool) return true; - + return false; -} +} /*******************************************************************\ @@ -340,12 +340,12 @@ void invariant_propagationt::initialize(const goto_programt &goto_program) forall_goto_program_instructions(it, goto_program) { invariant_sett &s=state_map[it].invariant_set; - + if(it==goto_program.instructions.begin()) s.make_true(); else s.make_false(); - + s.set_value_sets(value_sets); s.set_object_store(object_store); s.set_namespace(ns); @@ -372,7 +372,7 @@ void invariant_propagationt::initialize(const goto_functionst &goto_functions) for(goto_functionst::function_mapt::const_iterator f_it= goto_functions.function_map.begin(); - f_it!=goto_functions.function_map.end(); + f_it!=goto_functions.function_map.end(); f_it++) initialize(f_it->second.body); } @@ -417,14 +417,14 @@ void invariant_propagationt::simplify(goto_programt &goto_program) state_mapt::const_iterator s_it=state_map.find(i_it); if(s_it==state_map.end()) continue; - + const invariant_sett &invariant_set=s_it->second.invariant_set; - + exprt simplified_guard(i_it->guard); - + invariant_set.simplify(simplified_guard); ::simplify(simplified_guard, ns); - + if(invariant_set.implies(simplified_guard).is_true()) i_it->guard=true_exprt(); } diff --git a/src/analyses/invariant_propagation.h b/src/analyses/invariant_propagation.h index 0e89339ee12..5df6f6925d7 100644 --- a/src/analyses/invariant_propagation.h +++ b/src/analyses/invariant_propagation.h @@ -27,7 +27,7 @@ class invariant_propagationt:public object_store(_ns) { } - + const invariant_sett &lookup(locationt l) const { return (*this)[l].invariant_set; @@ -38,16 +38,16 @@ class invariant_propagationt:public void make_all_true(); void make_all_false(); - + void simplify(goto_programt &goto_program); void simplify(goto_functionst &goto_functions); - + typedef ait baset; - + protected: const namespacet &ns; value_setst &value_sets; - + inv_object_storet object_store; typedef std::list object_listt; @@ -62,9 +62,9 @@ class invariant_propagationt:public void get_objects_rec( const exprt &src, std::list &dest); - + void get_globals(object_listt &globals); - + bool check_type(const typet &type) const; }; diff --git a/src/analyses/invariant_set.cpp b/src/analyses/invariant_set.cpp index 5ad5404a863..c5cfac661a5 100644 --- a/src/analyses/invariant_set.cpp +++ b/src/analyses/invariant_set.cpp @@ -56,25 +56,25 @@ bool inv_object_storet::get(const exprt &expr, unsigned &n) { std::string s=build_string(expr); if(s=="") return true; - + // if it's a constant, we add it in any case if(is_constant(expr)) { n=map.number(s); - + if(n>=entries.size()) { entries.resize(n+1); entries[n].expr=expr; entries[n].is_constant=true; } - + return false; } return map.get_number(s, n); } - + /*******************************************************************\ Function: inv_object_storet::add @@ -90,21 +90,21 @@ Function: inv_object_storet::add unsigned inv_object_storet::add(const exprt &expr) { std::string s=build_string(expr); - + assert(s!=""); unsigned n=map.number(s); - + if(n>=entries.size()) { entries.resize(n+1); entries[n].expr=expr; entries[n].is_constant=is_constant(expr); } - + return n; } - + /*******************************************************************\ Function: inv_object_storet::is_constant @@ -121,7 +121,7 @@ bool inv_object_storet::is_constant(unsigned n) const { assert(n &p) // check if there is a contradiction with two constants unsigned r=eq_set.find(p.first); - + bool constant_seen=false; mp_integer c; - + for(unsigned i=0; iis_constant(i)) @@ -343,12 +343,12 @@ void invariant_sett::add_eq(const std::pair &p) make_false(); return; } - else + else constant_seen=true; } // replicate <= and != constraints - + for(ineq_sett::const_iterator it=le_set.begin(); it!=le_set.end(); it++) @@ -384,24 +384,24 @@ void invariant_sett::add_eq( if(eq.first==ineq.first) { n=ineq; - n.first=eq.second; + n.first=eq.second; dest.insert(n); } - + if(eq.first==ineq.second) { n=ineq; n.second=eq.second; dest.insert(n); } - + if(eq.second==ineq.first) { n=ineq; - n.first=eq.first; + n.first=eq.first; dest.insert(n); } - + if(eq.second==ineq.second) { n=ineq; @@ -426,16 +426,16 @@ tvt invariant_sett::is_eq(std::pair p) const { std::pair s=p; std::swap(s.first, s.second); - + if(has_eq(p)) return tvt(true); - + if(has_ne(p) || has_ne(s)) return tvt(false); return tvt::unknown(); } - + /*******************************************************************\ Function: invariant_sett::is_le @@ -452,17 +452,17 @@ tvt invariant_sett::is_le(std::pair p) const { std::pair s=p; std::swap(s.first, s.second); - + if(has_eq(p)) return tvt(true); - + if(has_le(p)) return tvt(true); - + if(has_le(s)) if(has_ne(s) || has_ne(p)) return tvt(false); - + return tvt::unknown(); } @@ -505,7 +505,7 @@ void invariant_sett::output( out << to_string(j, identifier); } - + out << std::endl; } @@ -561,7 +561,7 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) { unsigned a; if(get_object(expr, a)) return; - + add_bounds(a, boundst(0, power(2, op_width)-1)); } } @@ -606,13 +606,13 @@ void invariant_sett::strengthen_rec(const exprt &expr) #if 0 std::cout << "S: " << from_expr(*ns, "", expr) << std::endl; #endif - + if(is_false) { // we can't get any stronger return; } - + if(expr.is_true()) { // do nothing, it's useless @@ -635,26 +635,26 @@ void invariant_sett::strengthen_rec(const exprt &expr) expr.id()==ID_lt) { assert(expr.operands().size()==2); - + // special rule: x <= (a & b) // implies: x<=a && x<=b if(expr.op1().id()==ID_bitand) { const exprt &bitand_op=expr.op1(); - + forall_operands(it, bitand_op) { exprt tmp(expr); tmp.op1()=*it; strengthen_rec(tmp); } - + return; } std::pair p; - + if(get_object(expr.op0(), p.first) || get_object(expr.op1(), p.second)) return; @@ -662,7 +662,7 @@ void invariant_sett::strengthen_rec(const exprt &expr) mp_integer i0, i1; bool have_i0=!to_integer(expr.op0(), i0); bool have_i1=!to_integer(expr.op1(), i1); - + if(expr.id()==ID_le) { if(have_i0) @@ -690,20 +690,20 @@ void invariant_sett::strengthen_rec(const exprt &expr) else if(expr.id()==ID_equal) { assert(expr.operands().size()==2); - + const typet &op_type=ns->follow(expr.op0().type()); - + if(op_type.id()==ID_struct) { const struct_typet &struct_type=to_struct_type(op_type); - + const struct_typet::componentst &c=struct_type.components(); - + exprt lhs_member_expr(ID_member); exprt rhs_member_expr(ID_member); lhs_member_expr.copy_to_operands(expr.op0()); rhs_member_expr.copy_to_operands(expr.op1()); - + for(struct_typet::componentst::const_iterator it=c.begin(); it!=c.end(); @@ -719,21 +719,21 @@ void invariant_sett::strengthen_rec(const exprt &expr) equal_exprt equality; equality.lhs()=lhs_member_expr; equality.rhs()=rhs_member_expr; - + // recursive call strengthen_rec(equality); } - + return; } - + // special rule: x = (a & b) // implies: x<=a && x<=b if(expr.op1().id()==ID_bitand) { const exprt &bitand_op=expr.op1(); - + forall_operands(it, bitand_op) { exprt tmp(expr); @@ -741,7 +741,7 @@ void invariant_sett::strengthen_rec(const exprt &expr) tmp.id(ID_le); strengthen_rec(tmp); } - + return; } else if(expr.op0().id()==ID_bitand) @@ -751,7 +751,7 @@ void invariant_sett::strengthen_rec(const exprt &expr) strengthen_rec(tmp); return; } - + // special rule: x = (type) y if(expr.op1().id()==ID_typecast) { @@ -763,9 +763,9 @@ void invariant_sett::strengthen_rec(const exprt &expr) assert(expr.op0().operands().size()==1); add_type_bounds(expr.op1(), expr.op0().op0().type()); } - + std::pair p, s; - + if(get_object(expr.op0(), p.first) || get_object(expr.op1(), p.second)) return; @@ -789,13 +789,13 @@ void invariant_sett::strengthen_rec(const exprt &expr) else if(expr.id()==ID_notequal) { assert(expr.operands().size()==2); - + std::pair p; - + if(get_object(expr.op0(), p.first) || get_object(expr.op1(), p.second)) return; - + // check if this is a contradiction if(has_eq(p)) make_false(); @@ -822,7 +822,7 @@ tvt invariant_sett::implies(const exprt &expr) const nnf(tmp); return implies_rec(tmp); } - + /*******************************************************************\ Function: invariant_sett::implies @@ -839,11 +839,11 @@ tvt invariant_sett::implies_rec(const exprt &expr) const { if(expr.type().id()!=ID_bool) throw "implies: non-Boolean expression"; - + #if 0 std::cout << "I: " << from_expr(*ns, "", expr) << std::endl; #endif - + if(is_false) // can't get any stronger return tvt(true); @@ -858,7 +858,7 @@ tvt invariant_sett::implies_rec(const exprt &expr) const forall_operands(it, expr) if(implies_rec(*it)!=tvt(true)) return tvt::unknown(); - + return tvt(true); } else if(expr.id()==ID_or) @@ -875,23 +875,23 @@ tvt invariant_sett::implies_rec(const exprt &expr) const assert(expr.operands().size()==2); std::pair p; - + bool ob0=get_object(expr.op0(), p.first); bool ob1=get_object(expr.op1(), p.second); - + if(ob0 || ob1) return tvt::unknown(); - + tvt r; - + if(expr.id()==ID_le) { r=is_le(p); if(!r.is_unknown()) return r; - + boundst b0, b1; get_bounds(p.first, b0); get_bounds(p.second, b1); - + return b0<=b1; } else if(expr.id()==ID_lt) @@ -902,7 +902,7 @@ tvt invariant_sett::implies_rec(const exprt &expr) const boundst b0, b1; get_bounds(p.first, b0); get_bounds(p.second, b1); - + return b0second; } @@ -987,14 +987,14 @@ void invariant_sett::nnf(exprt &expr, bool negate) else if(expr.id()==ID_and) { if(negate) expr.id(ID_or); - + Forall_operands(it, expr) nnf(*it, negate); } else if(expr.id()==ID_or) { if(negate) expr.id(ID_and); - + Forall_operands(it, expr) nnf(*it, negate); } @@ -1116,10 +1116,10 @@ exprt invariant_sett::get_constant(const exprt &expr) const unsigned a; if(!get_object(expr, a)) - { + { // bounds? bounds_mapt::const_iterator it=bounds_map.find(a); - + if(it!=bounds_map.end()) { if(it->second.singleton()) @@ -1133,12 +1133,12 @@ exprt invariant_sett::get_constant(const exprt &expr) const if(eq_set.find(i)==r) { const exprt &e=object_store->get_expr(i); - + if(e.is_constant()) { mp_integer value; assert(!to_integer(e, value)); - + if(expr.type().id()==ID_pointer) { if(value==0) @@ -1155,14 +1155,14 @@ exprt invariant_sett::get_constant(const exprt &expr) const { if(e.type()==expr.type()) return e; - + exprt tmp(ID_typecast, expr.type()); tmp.copy_to_operands(e); return tmp; } } } - + return static_cast(get_nil_irep()); } @@ -1226,13 +1226,13 @@ bool invariant_sett::make_union(const invariant_sett &other) make_threaded(); return true; // change } - + if(threaded) return false; // no change if(other.is_false) return false; // no change - + if(is_false) { // copy @@ -1241,22 +1241,22 @@ bool invariant_sett::make_union(const invariant_sett &other) le_set=other.le_set; ne_set=other.ne_set; bounds_map=other.bounds_map; - + return true; // change } - + // equalities first unsigned old_eq_roots=eq_set.count_roots(); - + eq_set.intersection(other.eq_set); // inequalities unsigned old_ne_set=ne_set.size(); unsigned old_le_set=le_set.size(); - + intersection(ne_set, other.ne_set); intersection(le_set, other.le_set); - + // bounds if(make_union_bounds_map(other.bounds_map)) return true; @@ -1264,7 +1264,7 @@ bool invariant_sett::make_union(const invariant_sett &other) if(old_eq_roots!=eq_set.count_roots()) return true; if(old_ne_set!=ne_set.size()) return true; if(old_le_set!=le_set.size()) return true; - + return false; // no change } @@ -1283,7 +1283,7 @@ Function: invariant_sett::make_union_bounds_map bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) { bool changed=false; - + for(bounds_mapt::iterator it=bounds_map.begin(); it!=bounds_map.end(); @@ -1307,7 +1307,7 @@ bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) it++; } } - + return changed; } @@ -1421,14 +1421,14 @@ void invariant_sett::assignment( equal_exprt equality; equality.lhs()=lhs; equality.rhs()=rhs; - + // first evaluate RHS simplify(equality.rhs()); ::simplify(equality.rhs(), *ns); - + // now kill LHS modifies(lhs); - + // and put it back strengthen(equality); } @@ -1491,7 +1491,7 @@ void invariant_sett::apply_code(const codet &code) { // does nothing } - else if(statement=="lock" || + else if(statement=="lock" || statement=="unlock" || statement==ID_asm) { diff --git a/src/analyses/invariant_set.h b/src/analyses/invariant_set.h index b15c70c856b..3420b67c21f 100644 --- a/src/analyses/invariant_set.h +++ b/src/analyses/invariant_set.h @@ -26,14 +26,14 @@ class inv_object_storet } bool get(const exprt &expr, unsigned &n); - + unsigned add(const exprt &expr); - + bool is_constant(unsigned n) const; bool is_constant(const exprt &expr) const; static bool is_constant_address(const exprt &expr); - + const irep_idt &operator[](unsigned n) const { return map[n]; @@ -44,9 +44,9 @@ class inv_object_storet assert(n mapt; mapt map; - + struct entryt { bool is_constant; exprt expr; }; - + std::vector entries; - + std::string build_string(const exprt &expr) const; static bool is_constant_address_rec(const exprt &expr); @@ -75,22 +75,22 @@ class invariant_sett public: // equalities == unsigned_union_find eq_set; - + // <= typedef std::set > ineq_sett; ineq_sett le_set; - + // != ineq_sett ne_set; - + // bounds typedef interval_template boundst; typedef std::map bounds_mapt; bounds_mapt bounds_map; - + bool threaded; bool is_false; - + invariant_sett(): threaded(false), is_false(false), @@ -99,16 +99,16 @@ class invariant_sett ns(NULL) { } - + void output( const irep_idt &identifier, std::ostream &out) const; // true = added s.th. bool make_union(const invariant_sett &other_invariants); - + void strengthen(const exprt &expr); - + void make_true() { eq_set.clear(); @@ -140,7 +140,7 @@ class invariant_sett void assignment( const exprt &lhs, const exprt &rhs); - + void set_value_sets(value_setst &_value_sets) { value_sets=&_value_sets; @@ -150,16 +150,16 @@ class invariant_sett { object_store=&_object_store; } - + void set_namespace(const namespacet &_ns) { ns=&_ns; } - + static void intersection(ineq_sett &dest, const ineq_sett &other) { ineq_sett::iterator it_d=dest.begin(); - + while(it_d!=dest.end()) { ineq_sett::iterator next_d(it_d); @@ -167,11 +167,11 @@ class invariant_sett if(other.find(*it_d)==other.end()) dest.erase(it_d); - + it_d=next_d; - } + } } - + static void remove(ineq_sett &dest, unsigned a) { for(ineq_sett::iterator it=dest.begin(); @@ -187,34 +187,34 @@ class invariant_sett it=next; } } - + tvt implies(const exprt &expr) const; - + void simplify(exprt &expr) const; - + protected: value_setst *value_sets; inv_object_storet *object_store; const namespacet *ns; - + tvt implies_rec(const exprt &expr) const; static void nnf(exprt &expr, bool negate=false); void strengthen_rec(const exprt &expr); - + void add_type_bounds(const exprt &expr, const typet &type); void add_bounds(unsigned a, const boundst &bound) { bounds_map[a].intersect_with(bound); } - + void get_bounds(unsigned a, boundst &dest) const; // true = added s.th. bool make_union_bounds_map(const bounds_mapt &other); void modifies(unsigned a); - + std::string to_string( unsigned a, const irep_idt &identifier) const; @@ -222,7 +222,7 @@ class invariant_sett bool get_object( const exprt &expr, unsigned &n) const; - + exprt get_constant(const exprt &expr) const; // queries @@ -230,31 +230,31 @@ class invariant_sett { return eq_set.same_set(p.first, p.second); } - + bool has_le(const std::pair &p) const { return le_set.find(p)!=le_set.end(); } - + bool has_ne(const std::pair &p) const { return ne_set.find(p)!=ne_set.end(); } - + tvt is_eq(std::pair p) const; tvt is_le(std::pair p) const; - + tvt is_lt(std::pair p) const { return is_le(p) && !is_eq(p); } - + tvt is_ge(std::pair p) const { std::swap(p.first, p.second); return is_eq(p) || is_lt(p); } - + tvt is_gt(std::pair p) const { return !is_le(p); @@ -271,7 +271,7 @@ class invariant_sett { add(p, le_set); } - + void add_ne(const std::pair &p) { add(p, ne_set); diff --git a/src/analyses/invariant_set_domain.cpp b/src/analyses/invariant_set_domain.cpp index 0302c336e36..6ee0be8e6e0 100644 --- a/src/analyses/invariant_set_domain.cpp +++ b/src/analyses/invariant_set_domain.cpp @@ -42,7 +42,7 @@ void invariant_set_domaint::transform( invariant_set.strengthen(tmp); } break; - + case ASSERT: case ASSUME: { @@ -51,7 +51,7 @@ void invariant_set_domaint::transform( invariant_set.strengthen(tmp); } break; - + case RETURN: // ignore break; @@ -62,24 +62,24 @@ void invariant_set_domaint::transform( invariant_set.assignment(assignment.lhs(), assignment.rhs()); } break; - + case OTHER: if(from_l->code.is_not_nil()) invariant_set.apply_code(from_l->code); break; - + case DECL: invariant_set.apply_code(from_l->code); break; - + case FUNCTION_CALL: invariant_set.apply_code(from_l->code); break; - + case START_THREAD: - invariant_set.make_threaded(); + invariant_set.make_threaded(); break; - + default:; // do nothing } diff --git a/src/analyses/invariant_set_domain.h b/src/analyses/invariant_set_domain.h index 5ab7f8015f8..528e5b404e2 100644 --- a/src/analyses/invariant_set_domain.h +++ b/src/analyses/invariant_set_domain.h @@ -17,7 +17,7 @@ class invariant_set_domaint:public ai_domain_baset public: invariant_sett invariant_set; - // overloading + // overloading inline bool merge( const invariant_set_domaint &other, @@ -34,7 +34,7 @@ class invariant_set_domaint:public ai_domain_baset { invariant_set.output("", out); } - + virtual void initialize( const namespacet &ns, locationt l) diff --git a/src/analyses/is_threaded.cpp b/src/analyses/is_threaded.cpp index 310b3e4ac06..ba3121717cb 100644 --- a/src/analyses/is_threaded.cpp +++ b/src/analyses/is_threaded.cpp @@ -16,7 +16,7 @@ class is_threaded_domaint:public ai_domain_baset bool has_spawn; public: bool is_threaded; - + inline is_threaded_domaint():has_spawn(false), is_threaded(false) { } @@ -40,7 +40,7 @@ class is_threaded_domaint:public ai_domain_baset return old_i_t!=is_threaded || old_h_s!=has_spawn; } - + void transform( locationt from, locationt to, @@ -75,9 +75,9 @@ void is_threadedt::compute(const goto_functionst &goto_functions) const namespacet ns(symbol_table); ait is_threaded_analysis; - + is_threaded_analysis(goto_functions, ns); - + for(goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.begin(); f_it!=goto_functions.function_map.end(); @@ -92,4 +92,3 @@ void is_threadedt::compute(const goto_functionst &goto_functions) is_threaded_set.insert(i_it); } } - diff --git a/src/analyses/is_threaded.h b/src/analyses/is_threaded.h index 88a785a71b9..7b68e62c6f3 100644 --- a/src/analyses/is_threaded.h +++ b/src/analyses/is_threaded.h @@ -28,7 +28,7 @@ class is_threadedt { return is_threaded_set.find(t)!=is_threaded_set.end(); } - + protected: typedef std::set is_threaded_sett; is_threaded_sett is_threaded_set; diff --git a/src/analyses/local_bitvector_analysis.cpp b/src/analyses/local_bitvector_analysis.cpp index d2ccb7e785e..9e01e9cb283 100644 --- a/src/analyses/local_bitvector_analysis.cpp +++ b/src/analyses/local_bitvector_analysis.cpp @@ -26,7 +26,7 @@ Function: local_bitvector_analysist::flagst::print Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -50,14 +50,14 @@ Function: local_bitvector_analysist::loc_infot::merge Outputs: - Purpose: + Purpose: \*******************************************************************/ bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) { bool result=false; - + std::size_t max_index= std::max(src.points_to.size(), points_to.size()); @@ -66,7 +66,7 @@ bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) if(points_to[i].merge(src.points_to[i])) result=true; } - + return result; } @@ -100,7 +100,7 @@ Function: local_bitvector_analysist::assign_lhs Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -142,7 +142,7 @@ void local_bitvector_analysist::assign_lhs( assign_lhs(to_if_expr(lhs).false_case(), rhs, loc_info_src, loc_info_dest); } } - + /*******************************************************************\ Function: local_bitvector_analysist::get @@ -151,7 +151,7 @@ Function: local_bitvector_analysist::get Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -160,9 +160,9 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get( const exprt &rhs) { local_cfgt::loc_mapt::const_iterator loc_it=cfg.loc_map.find(t); - + assert(loc_it!=cfg.loc_map.end()); - + const loc_infot &loc_info_src=loc_infos[loc_it->second]; return get_rec(rhs, loc_info_src); @@ -176,7 +176,7 @@ Function: local_bitvector_analysist::get_rec Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -205,7 +205,7 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( else if(rhs.id()==ID_address_of) { const exprt &object=to_address_of_expr(rhs).object(); - + if(object.id()==ID_symbol) { if(locals.is_local(to_symbol_expr(object).get_identifier())) @@ -298,7 +298,7 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( else return flagst::mk_unknown(); } - + /*******************************************************************\ Function: local_bitvector_analysist::build @@ -307,7 +307,7 @@ Function: local_bitvector_analysist::build Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -316,10 +316,10 @@ void local_bitvector_analysist::build(const goto_functiont &goto_function) if(cfg.nodes.empty()) return; work_queuet work_queue; - work_queue.push(0); - + work_queue.push(0); + loc_infos.resize(cfg.nodes.size()); - + // Gather the objects we track, and // feed in sufficiently bad defaults for their value // in the entry location. @@ -336,10 +336,10 @@ void local_bitvector_analysist::build(const goto_functiont &goto_function) const local_cfgt::nodet &node=cfg.nodes[loc_nr]; const goto_programt::instructiont &instruction=*node.t; work_queue.pop(); - + const loc_infot &loc_info_src=loc_infos[loc_nr]; loc_infot loc_info_dest=loc_infos[loc_nr]; - + switch(instruction.type) { case ASSIGN: @@ -393,7 +393,7 @@ Function: local_bitvector_analysist::output Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -424,8 +424,7 @@ void local_bitvector_analysist::output( out << "\n"; goto_function.body.output_instruction(ns, "", out, i_it); out << "\n"; - + l++; } } - diff --git a/src/analyses/local_bitvector_analysis.h b/src/analyses/local_bitvector_analysis.h index e36b7470cac..788f7d34c14 100644 --- a/src/analyses/local_bitvector_analysis.h +++ b/src/analyses/local_bitvector_analysis.h @@ -20,7 +20,7 @@ Author: Daniel Kroening, kroening@kroening.com /*******************************************************************\ Class: local_bitvector_analysist - + Purpose: \*******************************************************************/ @@ -29,7 +29,7 @@ class local_bitvector_analysist { public: typedef goto_functionst::goto_functiont goto_functiont; - + explicit local_bitvector_analysist( const goto_functiont &_goto_function): dirty(_goto_function), @@ -43,7 +43,7 @@ class local_bitvector_analysist std::ostream &out, const goto_functiont &goto_function, const namespacet &ns) const; - + dirtyt dirty; localst locals; local_cfgt cfg; @@ -54,7 +54,7 @@ class local_bitvector_analysist inline flagst():bits(0) { } - + void clear() { bits=0; @@ -76,16 +76,16 @@ class local_bitvector_analysist explicit inline flagst(const bitst _bits):bits(_bits) { } - + unsigned bits; - + inline bool merge(const flagst &other) { unsigned old=bits; bits|=other.bits; // bit-wise or return old!=bits; } - + inline static flagst mk_unknown() { return flagst(B_unknown); @@ -174,7 +174,7 @@ class local_bitvector_analysist f.print(out); return out; } - + inline friend flagst operator|(const flagst f1, const flagst f2) { flagst result=f1; @@ -185,40 +185,40 @@ class local_bitvector_analysist flagst get( const goto_programt::const_targett t, const exprt &src); - + protected: void build(const goto_functiont &goto_function); typedef std::stack work_queuet; numbering pointers; - + // pointers -> flagst // This is a vector, so it's fast. typedef expanding_vector points_tot; - // the information tracked per program location + // the information tracked per program location class loc_infot { public: points_tot points_to; - + bool merge(const loc_infot &src); }; typedef std::vector loc_infost; loc_infost loc_infos; - + void assign_lhs( const exprt &lhs, const exprt &rhs, const loc_infot &loc_info_src, loc_infot &loc_info_dest); - + flagst get_rec( const exprt &rhs, const loc_infot &loc_info_src); - + bool is_tracked(const irep_idt &identifier); }; diff --git a/src/analyses/local_cfg.cpp b/src/analyses/local_cfg.cpp index 7ed586278be..0f70def622b 100644 --- a/src/analyses/local_cfg.cpp +++ b/src/analyses/local_cfg.cpp @@ -29,7 +29,7 @@ Function: local_cfgt::build Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -37,9 +37,9 @@ void local_cfgt::build(const goto_programt &goto_program) { nodes.resize(goto_program.instructions.size()); - { + { node_nrt loc_nr=0; - + for(goto_programt::const_targett it=goto_program.instructions.begin(); it!=goto_program.instructions.end(); it++, loc_nr++) @@ -53,36 +53,36 @@ void local_cfgt::build(const goto_programt &goto_program) { nodet &node=nodes[loc_nr]; const goto_programt::instructiont &instruction=*node.t; - + switch(instruction.type) { case GOTO: if(!instruction.guard.is_true()) node.successors.push_back(loc_nr+1); - + for(goto_programt::targetst::const_iterator t_it=instruction.targets.begin(); t_it!=instruction.targets.end(); t_it++) { node_nrt l=loc_map.find(*t_it)->second; - node.successors.push_back(l); + node.successors.push_back(l); } break; - + case START_THREAD: node.successors.push_back(loc_nr+1); - + for(goto_programt::targetst::const_iterator t_it=instruction.targets.begin(); t_it!=instruction.targets.end(); t_it++) { node_nrt l=loc_map.find(*t_it)->second; - node.successors.push_back(l); + node.successors.push_back(l); } break; - + case THROW: case END_FUNCTION: case END_THREAD: @@ -91,6 +91,5 @@ void local_cfgt::build(const goto_programt &goto_program) default: node.successors.push_back(loc_nr+1); } - } + } } - diff --git a/src/analyses/local_cfg.h b/src/analyses/local_cfg.h index 687fa7fc8f3..92eda353932 100644 --- a/src/analyses/local_cfg.h +++ b/src/analyses/local_cfg.h @@ -16,7 +16,7 @@ Author: Daniel Kroening, kroening@kroening.com /*******************************************************************\ Class: local_cfgt - + Purpose: \*******************************************************************/ @@ -36,16 +36,16 @@ class local_cfgt typedef std::map loc_mapt; loc_mapt loc_map; - + typedef std::vector nodest; nodest nodes; - + inline explicit local_cfgt(const goto_programt &_goto_program) { build(_goto_program); } -protected: +protected: void build(const goto_programt &goto_program); }; diff --git a/src/analyses/local_may_alias.cpp b/src/analyses/local_may_alias.cpp index 787648554c6..c69158aebd7 100644 --- a/src/analyses/local_may_alias.cpp +++ b/src/analyses/local_may_alias.cpp @@ -33,7 +33,7 @@ Function: local_may_aliast::loc_infot::merge bool local_may_aliast::loc_infot::merge(const loc_infot &src) { bool changed=false; - + // do union; this should be amortized linear for(std::size_t i=0; i local_may_aliast::get( const exprt &rhs) const { local_cfgt::loc_mapt::const_iterator loc_it=cfg.loc_map.find(t); - + assert(loc_it!=cfg.loc_map.end()); - + const loc_infot &loc_info_src=loc_infos[loc_it->second]; - + object_sett result_tmp; get_rec(result_tmp, rhs, loc_info_src); @@ -165,7 +165,7 @@ std::set local_may_aliast::get( { result.insert(objects[*it]); } - + return result; } @@ -177,7 +177,7 @@ Function: local_may_aliast::aliases Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -186,11 +186,11 @@ bool local_may_aliast::aliases( const exprt &src1, const exprt &src2) const { local_cfgt::loc_mapt::const_iterator loc_it=cfg.loc_map.find(t); - + assert(loc_it!=cfg.loc_map.end()); - + const loc_infot &loc_info_src=loc_infos[loc_it->second]; - + object_sett tmp1, tmp2; get_rec(tmp1, src1, loc_info_src); get_rec(tmp2, src2, loc_info_src); @@ -200,12 +200,12 @@ bool local_may_aliast::aliases( return true; std::list result; - + std::set_intersection( tmp1.begin(), tmp1.end(), tmp2.begin(), tmp2.end(), std::back_inserter(result)); - + return !result.empty(); } @@ -217,7 +217,7 @@ Function: local_may_aliast::get_rec Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -238,9 +238,9 @@ void local_may_aliast::get_rec( if(rhs.type().id()==ID_pointer) { unsigned src_pointer=objects.number(rhs); - + dest.insert(src_pointer); - + for(std::size_t i=0; isource_location << "\n"; const loc_infot &loc_info=loc_infos[l]; - + for(std::size_t i=0; i work_queuet; mutable numbering objects; - + typedef unsigned_union_find alias_sett; - // the information tracked per program location + // the information tracked per program location class loc_infot { public: alias_sett aliases; - + bool merge(const loc_infot &src); }; typedef std::vector loc_infost; loc_infost loc_infos; - + void assign_lhs( const exprt &lhs, const exprt &rhs, const loc_infot &loc_info_src, loc_infot &loc_info_dest); - - typedef std::set object_sett; - + + typedef std::set object_sett; + void get_rec( object_sett &dest, const exprt &rhs, const loc_infot &loc_info_src) const; - + unsigned unknown_object; }; @@ -102,7 +102,7 @@ class local_may_alias_factoryt inline local_may_alias_factoryt():goto_functions(NULL) { } - + inline void operator()(const goto_functionst &_goto_functions) { goto_functions=&_goto_functions; @@ -111,7 +111,7 @@ class local_may_alias_factoryt forall_goto_program_instructions(i_it, f_it->second.body) target_map[i_it]=f_it->first; } - + local_may_aliast & operator()(const irep_idt &fkt) { assert(goto_functions!=NULL); @@ -123,7 +123,7 @@ class local_may_alias_factoryt return *(fkt_map[fkt]=std::unique_ptr( new local_may_aliast(f_it2->second))); } - + local_may_aliast & operator()(goto_programt::const_targett t) { target_mapt::const_iterator t_it= @@ -131,13 +131,13 @@ class local_may_alias_factoryt assert(t_it!=target_map.end()); return operator()(t_it->second); } - + std::set get( const goto_programt::const_targett t, const exprt &src) const; protected: - const goto_functionst *goto_functions; + const goto_functionst *goto_functions; typedef std::map > fkt_mapt; fkt_mapt fkt_map; diff --git a/src/analyses/locals.cpp b/src/analyses/locals.cpp index 590da4bcd9e..e9a41949e50 100644 --- a/src/analyses/locals.cpp +++ b/src/analyses/locals.cpp @@ -33,10 +33,10 @@ void localst::build(const goto_functiont &goto_function) locals_map[code_decl.get_identifier()]= to_symbol_expr(code_decl.symbol()); } - + const code_typet::parameterst ¶meters= goto_function.type.parameters(); - + for(code_typet::parameterst::const_iterator it=parameters.begin(); it!=parameters.end(); diff --git a/src/analyses/locals.h b/src/analyses/locals.h index 3732d3a58b1..78883ad4699 100644 --- a/src/analyses/locals.h +++ b/src/analyses/locals.h @@ -35,7 +35,7 @@ class localst typedef std::map locals_mapt; locals_mapt locals_map; - + protected: void build(const goto_functiont &goto_function); }; diff --git a/src/analyses/natural_loops.cpp b/src/analyses/natural_loops.cpp index 5fa585db07a..92a1dc1efce 100644 --- a/src/analyses/natural_loops.cpp +++ b/src/analyses/natural_loops.cpp @@ -33,8 +33,7 @@ void show_natural_loops(const goto_functionst &goto_functions) natural_loopst natural_loops; natural_loops(it->second.body); natural_loops.output(std::cout); - + std::cout << std::endl; } } - diff --git a/src/analyses/natural_loops.h b/src/analyses/natural_loops.h index 204cf3362ae..50f84183370 100644 --- a/src/analyses/natural_loops.h +++ b/src/analyses/natural_loops.h @@ -26,7 +26,7 @@ class natural_loops_templatet // map loop headers to loops typedef std::map loop_mapt; - + loop_mapt loop_map; inline void operator()(P &program) @@ -35,12 +35,12 @@ class natural_loops_templatet } void output(std::ostream &) const; - + inline const cfg_dominators_templatet& get_dominator_info() const { return cfg_dominators; } - + inline natural_loops_templatet() { } @@ -55,7 +55,7 @@ class natural_loops_templatet typedef typename cfg_dominators_templatet::cfgt::nodet nodet; void compute(P &program); - void compute_natural_loop(T, T); + void compute_natural_loop(T, T); }; class natural_loopst: @@ -109,10 +109,10 @@ void natural_loops_templatet::compute(P &program) { const nodet &node= cfg_dominators.cfg[cfg_dominators.cfg.entry_map[m_it]]; - + #ifdef DEBUG - std::cout << "Computing loop for " - << m_it->location_number << " -> " + std::cout << "Computing loop for " + << m_it->location_number << " -> " << (*n_it)->location_number << "\n"; #endif if(node.dominators.find(*n_it)!=node.dominators.end()) @@ -142,7 +142,7 @@ template void natural_loops_templatet::compute_natural_loop(T m, T n) { assert(n->location_number<=m->location_number); - + std::stack stack; natural_loopt &loop=loop_map[n]; @@ -194,7 +194,7 @@ void natural_loops_templatet::output(std::ostream &out) const h_it!=loop_map.end(); ++h_it) { unsigned n=h_it->first->location_number; - + out << n << " is head of { "; for(typename natural_loopt::const_iterator l_it=h_it->second.begin(); l_it!=h_it->second.end(); ++l_it) diff --git a/src/analyses/reaching_definitions.cpp b/src/analyses/reaching_definitions.cpp index ea43251fb97..c0cda391b9e 100644 --- a/src/analyses/reaching_definitions.cpp +++ b/src/analyses/reaching_definitions.cpp @@ -961,4 +961,3 @@ void reaching_definitions_analysist::initialize( concurrency_aware_ait::initialize(goto_functions); } - diff --git a/src/analyses/reaching_definitions.h b/src/analyses/reaching_definitions.h index 4eb76ffaae0..91225e8fc86 100644 --- a/src/analyses/reaching_definitions.h +++ b/src/analyses/reaching_definitions.h @@ -249,4 +249,3 @@ class reaching_definitions_analysist : }; #endif - diff --git a/src/analyses/replace_symbol_ext.cpp b/src/analyses/replace_symbol_ext.cpp index 2a53bca1faf..801ce69e881 100644 --- a/src/analyses/replace_symbol_ext.cpp +++ b/src/analyses/replace_symbol_ext.cpp @@ -32,7 +32,7 @@ bool replace_symbol_extt::replace(exprt &dest) const if(have_to_replace(dest.type())) if(!replace_symbolt::replace(dest.type())) result=false; - + // now do expression itself if(!have_to_replace(dest)) diff --git a/src/analyses/static_analysis.cpp b/src/analyses/static_analysis.cpp index 656644d42c9..3737e109ab7 100644 --- a/src/analyses/static_analysis.cpp +++ b/src/analyses/static_analysis.cpp @@ -46,7 +46,7 @@ exprt static_analysis_baset::get_guard( tmp.make_not(); return tmp; } - + return from->guard; } @@ -70,13 +70,13 @@ exprt static_analysis_baset::get_return_lhs(locationt to) if(to->is_end_function()) return static_cast(get_nil_irep()); - + // must be the function call assert(to->is_function_call()); const code_function_callt &code= to_code_function_call(to->code); - + return code.lhs(); } @@ -270,11 +270,11 @@ void static_analysis_baset::update( if(!has_location(i_it)) { generate_state(i_it); - + if(!first) merge(get_state(i_it), get_state(previous), i_it); } - + first=false; previous=i_it; } @@ -296,11 +296,11 @@ static_analysis_baset::locationt static_analysis_baset::get_next( working_sett &working_set) { assert(!working_set.empty()); - + working_sett::iterator i=working_set.begin(); locationt l=i->second; working_set.erase(i); - + return l; } @@ -322,19 +322,19 @@ bool static_analysis_baset::fixedpoint( { if(goto_program.instructions.empty()) return false; - + working_sett working_set; put_in_working_set( working_set, goto_program.instructions.begin()); - + bool new_data=false; while(!working_set.empty()) { locationt l=get_next(working_set); - + if(visit(l, working_set, goto_program, goto_functions)) new_data=true; } @@ -365,7 +365,7 @@ bool static_analysis_baset::visit( statet ¤t=get_state(l); current.seen=true; - + goto_programt::const_targetst successors; goto_program.get_successors(l, successors); @@ -382,7 +382,7 @@ bool static_analysis_baset::visit( std::unique_ptr tmp_state( make_temporary_state(current)); - + statet &new_values=*tmp_state; if(l->is_function_call()) @@ -400,19 +400,19 @@ bool static_analysis_baset::visit( } else new_values.transform(ns, l, to_l); - + statet &other=get_state(to_l); bool have_new_values= merge(other, new_values, to_l); - + if(have_new_values) new_data=true; - + if(have_new_values || !other.seen) put_in_working_set(working_set, to_l); } - + return new_data; } @@ -439,17 +439,17 @@ void static_analysis_baset::do_function_call( if(!goto_function.body_available()) return; // do nothing - + assert(!goto_function.body.instructions.empty()); { // get the state at the beginning of the function locationt l_begin=goto_function.body.instructions.begin(); - + // do the edge from the call site to the beginning of the function std::unique_ptr tmp_state(make_temporary_state(new_state)); - tmp_state->transform(ns, l_call, l_begin); - + tmp_state->transform(ns, l_call, l_begin); + statet &begin_state=get_state(l_begin); bool new_data=false; @@ -497,7 +497,7 @@ void static_analysis_baset::do_function_call( // effect on current procedure (if any) new_state.transform(ns, l_call, l_return); } -} +} /*******************************************************************\ @@ -525,7 +525,7 @@ void static_analysis_baset::do_function_call_rec( if(function.id()==ID_symbol) { const irep_idt &identifier=function.get(ID_identifier); - + if(recursion_set.find(identifier)!=recursion_set.end()) { // recursion detected! @@ -533,29 +533,29 @@ void static_analysis_baset::do_function_call_rec( } else recursion_set.insert(identifier); - + goto_functionst::function_mapt::const_iterator it= goto_functions.function_map.find(identifier); - + if(it==goto_functions.function_map.end()) throw "failed to find function "+id2string(identifier); - + do_function_call( l_call, l_return, goto_functions, it, arguments, new_state); - + recursion_set.erase(identifier); } else if(function.id()==ID_if) { if(function.operands().size()!=3) throw "if takes three arguments"; - + std::unique_ptr n2(make_temporary_state(new_state)); - + do_function_call_rec( l_call, l_return, function.op1(), @@ -569,7 +569,7 @@ void static_analysis_baset::do_function_call_rec( arguments, *n2, goto_functions); - + merge(new_state, *n2, l_return); } else if(function.id()==ID_dereference) @@ -588,7 +588,7 @@ void static_analysis_baset::do_function_call_rec( if(it->id()==ID_object_descriptor) { const object_descriptor_exprt &o=to_object_descriptor_expr(*it); - std::unique_ptr n2(make_temporary_state(new_state)); + std::unique_ptr n2(make_temporary_state(new_state)); do_function_call_rec(l_call, l_return, o.object(), arguments, *n2, goto_functions); merge(new_state, *n2, l_return); } @@ -718,4 +718,3 @@ void static_analysis_baset::concurrent_fixedpoint( } } } - diff --git a/src/analyses/static_analysis.h b/src/analyses/static_analysis.h index 830918f53e3..4d289296938 100644 --- a/src/analyses/static_analysis.h +++ b/src/analyses/static_analysis.h @@ -30,7 +30,7 @@ class domain_baset virtual ~domain_baset() { } - + typedef goto_programt::const_targett locationt; // will go away, @@ -59,10 +59,10 @@ class domain_baset std::ostream &out) const { } - + typedef hash_set_cont expr_sett; - // will go away + // will go away virtual void get_reference_set( const namespacet &ns, const exprt &expr, @@ -71,17 +71,17 @@ class domain_baset // dummy, overload me! dest.clear(); } - + // also add // // bool merge(const T &b, locationt to); // // this computes the join between "this" and "b" // return true if "this" has changed - + protected: bool seen; - + friend class static_analysis_baset; }; @@ -98,7 +98,7 @@ class static_analysis_baset initialized(false) { } - + virtual void initialize( const goto_programt &goto_program) { @@ -108,7 +108,7 @@ class static_analysis_baset generate_states(goto_program); } } - + virtual void initialize( const goto_functionst &goto_functions) { @@ -118,13 +118,13 @@ class static_analysis_baset generate_states(goto_functions); } } - + virtual void update(const goto_programt &goto_program); virtual void update(const goto_functionst &goto_functions); - + virtual void operator()( const goto_programt &goto_program); - + virtual void operator()( const goto_functionst &goto_functions); @@ -136,7 +136,7 @@ class static_analysis_baset { initialized=false; } - + virtual void output( const goto_functionst &goto_functions, std::ostream &out) const; @@ -149,33 +149,33 @@ class static_analysis_baset } virtual bool has_location(locationt l) const=0; - + void insert(locationt l) { generate_state(l); } - // utilities - + // utilities + // get guard of a conditional edge static exprt get_guard(locationt from, locationt to); - + // get lhs that return value is assigned to // for an edge that returns from a function static exprt get_return_lhs(locationt to); protected: const namespacet &ns; - + virtual void output( const goto_programt &goto_program, const irep_idt &identifier, std::ostream &out) const; typedef std::map working_sett; - + locationt get_next(working_sett &working_set); - + void put_in_working_set( working_sett &working_set, locationt l) @@ -188,7 +188,7 @@ class static_analysis_baset bool fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions); - + virtual void fixedpoint( const goto_functionst &goto_functions)=0; @@ -203,31 +203,31 @@ class static_analysis_baset working_sett &working_set, const goto_programt &goto_program, const goto_functionst &goto_functions); - + static locationt successor(locationt l) { l++; return l; } - + virtual bool merge(statet &a, const statet &b, locationt to)=0; // for concurrent fixedpoint virtual bool merge_shared(statet &a, const statet &b, locationt to)=0; - + typedef std::set functions_donet; functions_donet functions_done; typedef std::set recursion_sett; recursion_sett recursion_set; - + void generate_states( const goto_functionst &goto_functions); void generate_states( const goto_programt &goto_program); - + bool initialized; - + // function calls void do_function_call_rec( locationt l_call, locationt l_return, @@ -244,7 +244,7 @@ class static_analysis_baset statet &new_state); // abstract methods - + virtual void generate_state(locationt l)=0; virtual statet &get_state(locationt l)=0; virtual const statet &get_state(locationt l) const=0; @@ -277,14 +277,14 @@ class static_analysist:public static_analysis_baset if(it==state_map.end()) throw "failed to find state"; return it->second; } - + inline const T &operator[](locationt l) const { typename state_mapt::const_iterator it=state_map.find(l); if(it==state_map.end()) throw "failed to find state"; return it->second; } - + virtual void clear() { state_map.clear(); @@ -295,7 +295,7 @@ class static_analysist:public static_analysis_baset { return state_map.count(l)!=0; } - + protected: typedef std::map state_mapt; state_mapt state_map; @@ -318,7 +318,7 @@ class static_analysist:public static_analysis_baset { return static_cast(a).merge(static_cast(b), to); } - + virtual statet *make_temporary_state(statet &s) { return new T(static_cast(s)); @@ -342,7 +342,7 @@ class static_analysist:public static_analysis_baset sequential_fixedpoint(goto_functions); } -private: +private: // to enforce that T is derived from domain_baset void dummy(const T &s) { const statet &x=dummy1(s); (void)x; } diff --git a/src/analyses/uninitialized_domain.cpp b/src/analyses/uninitialized_domain.cpp index 4967df42c80..cb58c208158 100644 --- a/src/analyses/uninitialized_domain.cpp +++ b/src/analyses/uninitialized_domain.cpp @@ -50,7 +50,7 @@ void uninitialized_domaint::transform( std::list written=expressions_written(*from); forall_expr_list(it, written) assign(*it); - + // we only care about the *first* uninitalized use forall_expr_list(it, read) assign(*it); } @@ -121,7 +121,7 @@ bool uninitialized_domaint::merge( locationt to) { unsigned old_uninitialized=uninitialized.size(); - + uninitialized.insert( other.uninitialized.begin(), other.uninitialized.end()); diff --git a/src/analyses/uninitialized_domain.h b/src/analyses/uninitialized_domain.h index 78064e86c37..04066fe4b47 100644 --- a/src/analyses/uninitialized_domain.h +++ b/src/analyses/uninitialized_domain.h @@ -27,17 +27,16 @@ class uninitialized_domaint:public ai_domain_baset std::ostream &out, const ai_baset &ai, const namespacet &ns) const; - + // returns true iff there is s.th. new bool merge( const uninitialized_domaint &other, locationt from, locationt to); - + protected: void assign(const exprt &lhs); }; typedef ait uninitialized_analysist; - diff --git a/src/ansi-c/Makefile b/src/ansi-c/Makefile index 0764c137f49..5d6381c6b00 100644 --- a/src/ansi-c/Makefile +++ b/src/ansi-c/Makefile @@ -79,7 +79,7 @@ library_check: library/*.c [ $$ec -eq 0 ] || exit $$ec ; \ done touch $@ - + cprover_library.inc: library/converter$(EXEEXT) library/*.c cat library/*.c | library/converter$(EXEEXT) > $@ @@ -108,6 +108,5 @@ generated_files: cprover_library.inc gcc_builtin_headers_generic.inc \ ############################################################################### -ansi-c$(LIBEXT): $(OBJ) +ansi-c$(LIBEXT): $(OBJ) $(LINKLIB) - diff --git a/src/ansi-c/anonymous_member.cpp b/src/ansi-c/anonymous_member.cpp index b4309576fa8..9aa1d2317b9 100644 --- a/src/ansi-c/anonymous_member.cpp +++ b/src/ansi-c/anonymous_member.cpp @@ -34,7 +34,7 @@ static exprt make_member_expr( if(struct_union.get_bool(ID_C_lvalue)) result.set(ID_C_lvalue, true); - // todo: should to typedef chains properly + // todo: should to typedef chains properly const typet &type= ns.follow(struct_union.type()); @@ -42,7 +42,7 @@ static exprt make_member_expr( type.get_bool(ID_C_constant) || struct_union.type().get_bool(ID_C_constant)) result.set(ID_C_constant, true); - + return result; } @@ -75,7 +75,7 @@ exprt get_component_rec( it++) { const typet &type=ns.follow(it->type()); - + if(it->get_name()==component_name) { return make_member_expr(struct_union, *it, ns); @@ -88,7 +88,7 @@ exprt get_component_rec( if(result.is_not_nil()) return result; } } - + return nil_exprt(); } @@ -130,6 +130,6 @@ bool has_component_rec( return true; } } - + return false; } diff --git a/src/ansi-c/anonymous_member.h b/src/ansi-c/anonymous_member.h index 865066f8e5b..df76e716427 100644 --- a/src/ansi-c/anonymous_member.h +++ b/src/ansi-c/anonymous_member.h @@ -18,4 +18,3 @@ bool has_component_rec( const typet &struct_union_type, const irep_idt &component_name, const namespacet &ns); - diff --git a/src/ansi-c/ansi_c_convert_type.cpp b/src/ansi-c/ansi_c_convert_type.cpp index b445aa5f2d1..8fde8c57c4d 100644 --- a/src/ansi-c/ansi_c_convert_type.cpp +++ b/src/ansi-c/ansi_c_convert_type.cpp @@ -119,7 +119,7 @@ void ansi_c_convert_typet::read_rec(const typet &type) bv_cnt++; const exprt &size_expr= static_cast(type.find(ID_size)); - + bv_width=size_expr; } else if(type.id()==ID_custom_floatbv) @@ -207,7 +207,7 @@ void ansi_c_convert_typet::read_rec(const typet &type) { const exprt &as_expr= static_cast(static_cast(type)); - + forall_operands(it, as_expr) { // these are symbols @@ -254,7 +254,7 @@ Function: ansi_c_convert_typet::write void ansi_c_convert_typet::write(typet &type) { type.clear(); - + // first, do "other" if(!other.empty()) @@ -437,7 +437,7 @@ void ansi_c_convert_typet::write(typet &type) else { // it is integer -- signed or unsigned? - + bool is_signed=true; // default if(signed_cnt && unsigned_cnt) @@ -459,7 +459,7 @@ void ansi_c_convert_typet::write(typet &type) error() << "conflicting type modifiers" << eom; throw 0; } - + if(int8_cnt) type=is_signed?signed_char_type():unsigned_char_type(); else if(int16_cnt) @@ -535,7 +535,7 @@ void ansi_c_convert_typet::write(typet &type) new_type.subtype().swap(type); type=new_type; } - + if(complex_cnt) { // These take more or less arbitrary subtypes. @@ -551,7 +551,7 @@ void ansi_c_convert_typet::write(typet &type) new_type.subtype()=type; type.swap(new_type); } - + c_qualifiers.write(type); if(packed) diff --git a/src/ansi-c/ansi_c_convert_type.h b/src/ansi-c/ansi_c_convert_type.h index b8060b80dcf..f87e4c86a8f 100644 --- a/src/ansi-c/ansi_c_convert_type.h +++ b/src/ansi-c/ansi_c_convert_type.h @@ -22,7 +22,7 @@ class ansi_c_convert_typet:public messaget int_cnt, short_cnt, long_cnt, double_cnt, float_cnt, c_bool_cnt, proper_bool_cnt, complex_cnt; - + // extensions unsigned int8_cnt, int16_cnt, int32_cnt, int64_cnt, ptr32_cnt, ptr64_cnt, @@ -30,7 +30,7 @@ class ansi_c_convert_typet:public messaget floatbv_cnt, fixedbv_cnt; typet gcc_attribute_mode; - + bool packed, aligned; exprt vector_size, alignment, bv_width, fraction_width; exprt msc_based; // this is Visual Studio @@ -38,22 +38,22 @@ class ansi_c_convert_typet:public messaget // storage spec c_storage_spect c_storage_spec; - + // qualifiers c_qualifierst c_qualifiers; void read(const typet &type); void write(typet &type); - + source_locationt source_location; - + std::list other; - + ansi_c_convert_typet(message_handlert &_message_handler): messaget(_message_handler) { } - + void clear() { unsigned_cnt=signed_cnt=char_cnt=int_cnt=short_cnt= @@ -67,14 +67,14 @@ class ansi_c_convert_typet:public messaget fraction_width.make_nil(); msc_based.make_nil(); gcc_attribute_mode.make_nil(); - + packed=aligned=constructor=destructor=false; other.clear(); c_storage_spec.clear(); c_qualifiers.clear(); } - + protected: void read_rec(const typet &type); }; diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index c006c34cd5e..f9dea43c02b 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -29,7 +29,7 @@ Function: ansi_c_declaratort::build void ansi_c_declaratort::build(irept &src) { typet *p=static_cast(&src); - + // walk down subtype until we hit symbol or "abstract" while(true) { @@ -62,7 +62,7 @@ void ansi_c_declaratort::build(irept &src) else p=&t.subtype(); } - + type()=static_cast(src); value().make_nil(); } @@ -95,7 +95,7 @@ void ansi_c_declarationt::output(std::ostream &out) const out << "\n"; out << "Type: " << type().pretty() << "\n"; - + for(declaratorst::const_iterator d_it=declarators().begin(); d_it!=declarators().end(); d_it++) @@ -123,7 +123,7 @@ typet ansi_c_declarationt::full_type( // this gets types that are still raw parse trees while(p->is_not_nil()) { - if(p->id()==ID_pointer || p->id()==ID_array || + if(p->id()==ID_pointer || p->id()==ID_array || p->id()==ID_vector || p->id()==ID_c_bit_field || p->id()==ID_block_pointer || p->id()==ID_code) p=&p->subtype(); @@ -138,7 +138,7 @@ typet ansi_c_declarationt::full_type( } *p=type(); - + return result; } @@ -158,7 +158,7 @@ void ansi_c_declarationt::to_symbol( const ansi_c_declaratort &declarator, symbolt &symbol) const { - symbol.clear(); + symbol.clear(); symbol.value=declarator.value(); symbol.type=full_type(declarator); symbol.name=declarator.get_name(); @@ -169,16 +169,16 @@ void ansi_c_declarationt::to_symbol( symbol.is_macro=get_is_typedef() || get_is_enum_constant(); symbol.is_parameter=get_is_parameter(); symbol.is_weak=get_is_weak(); - + // is it a function? - + if(symbol.type.id()==ID_code && !symbol.is_type) { symbol.is_static_lifetime=false; symbol.is_thread_local=false; symbol.is_file_local=get_is_static(); - + if(get_is_inline()) symbol.type.set(ID_C_inlined, true); @@ -205,13 +205,13 @@ void ansi_c_declarationt::to_symbol( !symbol.is_macro && !symbol.is_type && (get_is_global() || get_is_static()); - + symbol.is_thread_local= (!symbol.is_static_lifetime && !get_is_extern()) || get_is_thread_local(); - + symbol.is_file_local= - symbol.is_macro || + symbol.is_macro || (!get_is_global() && !get_is_extern()) || (get_is_global() && get_is_static()) || symbol.is_parameter; diff --git a/src/ansi-c/ansi_c_declaration.h b/src/ansi-c/ansi_c_declaration.h index 25c00feda6f..87ea59a818a 100644 --- a/src/ansi-c/ansi_c_declaration.h +++ b/src/ansi-c/ansi_c_declaration.h @@ -24,27 +24,27 @@ class ansi_c_declaratort:public exprt { return static_cast(add(ID_value)); } - + inline const exprt &value() const { return static_cast(find(ID_value)); } - + inline void set_name(const irep_idt &name) { return set(ID_name, name); } - + inline irep_idt get_name() const { return get(ID_name); } - + inline irep_idt get_base_name() const { return get(ID_base_name); } - + inline void set_base_name(const irep_idt &base_name) { return set(ID_base_name, base_name); @@ -71,112 +71,112 @@ class ansi_c_declarationt:public exprt inline ansi_c_declarationt():exprt(ID_declaration) { } - + inline bool get_is_typedef() const { return get_bool(ID_is_typedef); } - + inline void set_is_typedef(bool is_typedef) { set(ID_is_typedef, is_typedef); } - + inline bool get_is_enum_constant() const { return get_bool(ID_is_enum_constant); } - + inline void set_is_enum_constant(bool is_enum_constant) { set(ID_is_enum_constant, is_enum_constant); } - + inline bool get_is_static() const { return get_bool(ID_is_static); } - + inline void set_is_static(bool is_static) { set(ID_is_static, is_static); } - + inline bool get_is_parameter() const { return get_bool(ID_is_parameter); } - + inline void set_is_parameter(bool is_parameter) { set(ID_is_parameter, is_parameter); } - + inline bool get_is_member() const { return get_bool(ID_is_member); } - + inline void set_is_member(bool is_member) { set(ID_is_member, is_member); } - + inline bool get_is_global() const { return get_bool(ID_is_global); } - + inline void set_is_global(bool is_global) { set(ID_is_global, is_global); } - + inline bool get_is_register() const { return get_bool(ID_is_register); } - + inline void set_is_register(bool is_register) { set(ID_is_register, is_register); } - + inline bool get_is_thread_local() const { return get_bool(ID_is_thread_local); } - + inline void set_is_thread_local(bool is_thread_local) { set(ID_is_thread_local, is_thread_local); } - + inline bool get_is_inline() const { return get_bool(ID_is_inline); } - + inline void set_is_inline(bool is_inline) { set(ID_is_inline, is_inline); } - + inline bool get_is_extern() const { return get_bool(ID_is_extern); } - + inline void set_is_extern(bool is_extern) { set(ID_is_extern, is_extern); } - + inline bool get_is_static_assert() const { return get_bool(ID_is_static_assert); } - + inline void set_is_static_assert(bool is_static_assert) { set(ID_is_static_assert, is_static_assert); @@ -191,7 +191,7 @@ class ansi_c_declarationt:public exprt { set(ID_is_weak, is_weak); } - + void to_symbol( const ansi_c_declaratort &, symbolt &symbol) const; @@ -210,7 +210,7 @@ class ansi_c_declarationt:public exprt return (declaratorst &)operands(); } - // special case of a declaration with exactly one declarator + // special case of a declaration with exactly one declarator inline const ansi_c_declaratort &declarator() const { assert(declarators().size()==1); @@ -222,9 +222,9 @@ class ansi_c_declarationt:public exprt assert(declarators().size()==1); return declarators()[0]; } - + void output(std::ostream &) const; - + inline void add_initializer(exprt &value) { assert(!declarators().empty()); diff --git a/src/ansi-c/ansi_c_entry_point.cpp b/src/ansi-c/ansi_c_entry_point.cpp index f4db1403fbd..1acfb7d4459 100644 --- a/src/ansi-c/ansi_c_entry_point.cpp +++ b/src/ansi-c/ansi_c_entry_point.cpp @@ -46,7 +46,7 @@ exprt::operandst build_function_environment( { exprt::operandst result; result.resize(parameters.size()); - + std::size_t i=0; for(const auto & p : parameters) @@ -55,25 +55,25 @@ exprt::operandst build_function_environment( if(base_name.empty()) base_name="argument#"+i2string(i); irep_idt identifier=id2string(goto_functionst::entry_point())+ "::"+id2string(base_name); - - { + + { auxiliary_symbolt new_symbol; new_symbol.mode=ID_C; new_symbol.is_static_lifetime=false; new_symbol.name=identifier; new_symbol.base_name=base_name; new_symbol.type=p.type(); - + symbol_table.move(new_symbol); } - + symbol_exprt symbol_expr(identifier, p.type()); code_declt decl; decl.symbol()=symbol_expr; - + init_code.add(decl); - + codet input(ID_input); input.operands().resize(2); @@ -82,13 +82,13 @@ exprt::operandst build_function_environment( index_exprt(string_constantt(base_name), gen_zero(index_type()))); input.op1()=symbol_expr; input.add_source_location()=p.source_location(); - + init_code.move_to_operands(input); - + result[i]=symbol_expr; i++; } - + return result; } @@ -124,7 +124,7 @@ void record_function_outputs( const symbolt &return_symbol=symbol_table.lookup("return'"); output.op0()=address_of_exprt( - index_exprt(string_constantt(return_symbol.base_name), + index_exprt(string_constantt(return_symbol.base_name), gen_zero(index_type()))); output.op1()=return_symbol.symbol_expr(); @@ -149,7 +149,7 @@ void record_function_outputs( output.operands().resize(2); output.op0()=address_of_exprt( - index_exprt(string_constantt(symbol.base_name), + index_exprt(string_constantt(symbol.base_name), gen_zero(index_type()))); output.op1()=symbol.symbol_expr(); output.add_source_location()=p.source_location(); @@ -185,35 +185,35 @@ bool ansi_c_entry_point( return false; // silently ignore irep_idt main_symbol; - + // find main symbol if(config.main!="") { std::list matches; - + forall_symbol_base_map(it, symbol_table.symbol_base_map, config.main) { // look it up symbol_tablet::symbolst::const_iterator s_it=symbol_table.symbols.find(it->second); - + if(s_it==symbol_table.symbols.end()) continue; - + if(s_it->second.type.id()==ID_code) matches.push_back(it->second); } - + if(matches.empty()) { messaget message(message_handler); - message.error() << "main symbol `" << config.main + message.error() << "main symbol `" << config.main << "' not found" << messaget::eom; return true; // give up } - + if(matches.size()>=2) { messaget message(message_handler); - message.error() << "main symbol `" << config.main + message.error() << "main symbol `" << config.main << "' is ambiguous" << messaget::eom; return true; } @@ -222,16 +222,16 @@ bool ansi_c_entry_point( } else main_symbol=standard_main; - + // look it up symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(main_symbol); - + if(s_it==symbol_table.symbols.end()) return false; // give up silently - + const symbolt &symbol=s_it->second; - + // check if it has a body if(symbol.value.is_nil()) { @@ -243,9 +243,9 @@ bool ansi_c_entry_point( if(static_lifetime_init(symbol_table, symbol.location, message_handler)) return true; - + code_blockt init_code; - + // build call to initialization function { @@ -259,7 +259,7 @@ bool ansi_c_entry_point( << messaget::eom; return true; } - + code_function_callt call_init; call_init.lhs().make_nil(); call_init.add_source_location()=symbol.location; @@ -269,7 +269,7 @@ bool ansi_c_entry_point( } // build call to main function - + code_function_callt call_main; call_main.add_source_location()=symbol.location; call_main.function()=symbol.symbol_expr(); @@ -303,36 +303,36 @@ bool ansi_c_entry_point( const symbolt &argc_symbol=ns.lookup("argc'"); const symbolt &argv_symbol=ns.lookup("argv'"); - + { // assume argc is at least one exprt one=from_integer(1, argc_symbol.type); - + exprt ge(ID_ge, typet(ID_bool)); ge.copy_to_operands(argc_symbol.symbol_expr(), one); - + codet assumption; assumption.set_statement(ID_assume); assumption.move_to_operands(ge); init_code.move_to_operands(assumption); } - + { // assume argc is at most MAX/8-1 mp_integer upper_bound= power(2, config.ansi_c.int_width-4); - + exprt bound_expr=from_integer(upper_bound, argc_symbol.type); - + exprt le(ID_le, typet(ID_bool)); le.copy_to_operands(argc_symbol.symbol_expr(), bound_expr); - + codet assumption; assumption.set_statement(ID_assume); assumption.move_to_operands(le); init_code.move_to_operands(assumption); } - + { // record argc as an input codet input(ID_input); @@ -342,14 +342,14 @@ bool ansi_c_entry_point( input.op1()=argc_symbol.symbol_expr(); init_code.move_to_operands(input); } - + if(parameters.size()==3) - { + { const symbolt &envp_size_symbol=ns.lookup("envp_size'"); // assume envp_size is INTMAX-1 mp_integer max; - + if(envp_size_symbol.type.id()==ID_signedbv) { max=to_signedbv_type(envp_size_symbol.type).largest(); @@ -360,21 +360,21 @@ bool ansi_c_entry_point( } else assert(false); - + exprt max_minus_one=from_integer(max-1, envp_size_symbol.type); - + exprt le(ID_le, bool_typet()); le.copy_to_operands(envp_size_symbol.symbol_expr(), max_minus_one); - + codet assumption; assumption.set_statement(ID_assume); assumption.move_to_operands(le); init_code.move_to_operands(assumption); } - + { /* zero_string doesn't work yet */ - + /* exprt zero_string(ID_zero_string, array_typet()); zero_string.type().subtype()=char_type(); @@ -387,11 +387,11 @@ bool ansi_c_entry_point( if(argv_symbol.type.subtype()!=address_of.type()) address_of.make_typecast(argv_symbol.type.subtype()); - + // assign argv[*] to the address of a string-object exprt array_of("array_of", argv_symbol.type); array_of.copy_to_operands(address_of); - + init_code.copy_to_operands( code_assignt(argv_symbol.symbol_expr(), array_of)); */ @@ -401,12 +401,12 @@ bool ansi_c_entry_point( // assign argv[argc] to NULL exprt null(ID_constant, argv_symbol.type.subtype()); null.set(ID_value, ID_NULL); - + exprt index_expr(ID_index, argv_symbol.type.subtype()); index_expr.copy_to_operands( argv_symbol.symbol_expr(), argc_symbol.symbol_expr()); - + // disable bounds check on that one index_expr.set("bounds_check", false); @@ -414,44 +414,44 @@ bool ansi_c_entry_point( } if(parameters.size()==3) - { + { const symbolt &envp_symbol=ns.lookup("envp'"); const symbolt &envp_size_symbol=ns.lookup("envp_size'"); - + // assume envp[envp_size] is NULL exprt null(ID_constant, envp_symbol.type.subtype()); null.set(ID_value, ID_NULL); - + exprt index_expr(ID_index, envp_symbol.type.subtype()); index_expr.copy_to_operands( envp_symbol.symbol_expr(), envp_size_symbol.symbol_expr()); - + // disable bounds check on that one index_expr.set("bounds_check", false); - + exprt is_null(ID_equal, typet(ID_bool)); is_null.copy_to_operands(index_expr, null); - + codet assumption2; assumption2.set_statement(ID_assume); assumption2.move_to_operands(is_null); init_code.move_to_operands(assumption2); } - + { exprt::operandst &operands=call_main.arguments(); if(parameters.size()==3) operands.resize(3); - else + else operands.resize(2); - + exprt &op0=operands[0]; exprt &op1=operands[1]; - + op0=argc_symbol.symbol_expr(); - + { const exprt &arg1=parameters[1]; @@ -460,7 +460,7 @@ bool ansi_c_entry_point( // disable bounds check on that one index_expr.set("bounds_check", false); - + op1=exprt(ID_address_of, arg1.type()); op1.move_to_operands(index_expr); } @@ -472,11 +472,11 @@ bool ansi_c_entry_point( exprt &op2=operands[2]; const exprt &arg2=parameters[2]; - + exprt index_expr(ID_index, arg2.type().subtype()); index_expr.copy_to_operands( envp_symbol.symbol_expr(), gen_zero(index_type())); - + op2=exprt(ID_address_of, arg2.type()); op2.move_to_operands(index_expr); } @@ -503,12 +503,12 @@ bool ansi_c_entry_point( code_typet main_type; main_type.return_type()=empty_typet(); - + new_symbol.name=goto_functionst::entry_point(); new_symbol.type.swap(main_type); new_symbol.value.swap(init_code); new_symbol.mode=symbol.mode; - + if(symbol_table.move(new_symbol)) { messaget message; @@ -516,6 +516,6 @@ bool ansi_c_entry_point( message.error() << "failed to move main symbol" << messaget::eom; return true; } - + return false; } diff --git a/src/ansi-c/ansi_c_internal_additions.cpp b/src/ansi-c/ansi_c_internal_additions.cpp index dc424d6cd57..ca4cf92f637 100644 --- a/src/ansi-c/ansi_c_internal_additions.cpp +++ b/src/ansi-c/ansi_c_internal_additions.cpp @@ -140,7 +140,7 @@ void ansi_c_internal_additions(std::string &code) "void __CPROVER_input(const char *id, ...);\n" "void __CPROVER_output(const char *id, ...);\n" "void __CPROVER_cover(__CPROVER_bool condition);\n" - + // concurrency-related "void __CPROVER_atomic_begin();\n" "void __CPROVER_atomic_end();\n" @@ -151,13 +151,13 @@ void ansi_c_internal_additions(std::string &code) // traces "void CBMC_trace(int lvl, const char *event, ...);\n" - + // pointers "unsigned __CPROVER_POINTER_OBJECT(const void *p);\n" "signed __CPROVER_POINTER_OFFSET(const void *p);\n" "__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *p);\n" "extern unsigned char __CPROVER_memory[__CPROVER_constant_infinity_uint];\n" - + // malloc "void *__CPROVER_malloc(__CPROVER_size_t size);\n" "const void *__CPROVER_deallocated=0;\n" @@ -169,7 +169,7 @@ void ansi_c_internal_additions(std::string &code) // this is ANSI-C "extern __CPROVER_thread_local const char __func__[__CPROVER_constant_infinity_uint];\n" - + // this is GCC "extern __CPROVER_thread_local const char __FUNCTION__[__CPROVER_constant_infinity_uint];\n" "extern __CPROVER_thread_local const char __PRETTY_FUNCTION__[__CPROVER_constant_infinity_uint];\n" @@ -202,7 +202,7 @@ void ansi_c_internal_additions(std::string &code) "double __CPROVER_fabs(double x);\n" "long double __CPROVER_fabsl(long double x);\n" "float __CPROVER_fabsf(float x);\n" - + // arrays "__CPROVER_bool __CPROVER_array_equal(const void *array1, const void *array2);\n" "void __CPROVER_array_copy(const void *dest, const void *src);\n" @@ -211,10 +211,10 @@ void ansi_c_internal_additions(std::string &code) // k-induction "void __CPROVER_k_induction_hint(unsigned min, unsigned max, " "unsigned step, unsigned loop_free);\n" - + // format string-related "int __CPROVER_scanf(const char *, ...);\n" - + // pipes, write, read, close "struct __CPROVER_pipet {\n" " _Bool widowed;\n" @@ -228,7 +228,7 @@ void ansi_c_internal_additions(std::string &code) "unsigned __CPROVER_pipe_count=0;\n" "\n"; - + // GCC junk stuff, also for CLANG and ARM if(config.ansi_c.mode==configt::ansi_ct::flavourt::GCC || config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE || @@ -246,7 +246,7 @@ void ansi_c_internal_additions(std::string &code) { if(config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE) code+="typedef double __float128;\n"; // clang doesn't do __float128 - + code+=gcc_builtin_headers_ia32; code+=gcc_builtin_headers_ia32_2; } @@ -290,15 +290,15 @@ void ansi_c_internal_additions(std::string &code) if(config.ansi_c.os==configt::ansi_ct::ost::OS_WIN) code+="int __noop();\n" "int __assume(int);\n"; - + // ARM stuff if(config.ansi_c.mode==configt::ansi_ct::flavourt::ARM) code+=arm_builtin_headers; - + // CW stuff if(config.ansi_c.mode==configt::ansi_ct::flavourt::CODEWARRIOR) code+=cw_builtin_headers; - + // Architecture strings ansi_c_architecture_strings(code); } diff --git a/src/ansi-c/ansi_c_internal_additions.h b/src/ansi-c/ansi_c_internal_additions.h index 366af5f85a4..9ac0dc3a269 100644 --- a/src/ansi-c/ansi_c_internal_additions.h +++ b/src/ansi-c/ansi_c_internal_additions.h @@ -14,4 +14,3 @@ void ansi_c_architecture_strings(std::string &code); extern const char gcc_builtin_headers_generic[]; extern const char gcc_builtin_headers_ia32[]; extern const char arm_builtin_headers[]; - diff --git a/src/ansi-c/ansi_c_language.cpp b/src/ansi-c/ansi_c_language.cpp index 5c80e6905a6..6e3b587d248 100644 --- a/src/ansi-c/ansi_c_language.cpp +++ b/src/ansi-c/ansi_c_language.cpp @@ -86,7 +86,7 @@ bool ansi_c_languaget::preprocess( return c_preprocess(path, outstream, get_message_handler()); } - + /*******************************************************************\ Function: ansi_c_languaget::parse @@ -150,7 +150,7 @@ bool ansi_c_languaget::parse( return result; } - + /*******************************************************************\ Function: ansi_c_languaget::typecheck @@ -173,10 +173,10 @@ bool ansi_c_languaget::typecheck( return true; remove_internal_symbols(new_symbol_table); - + if(linking(symbol_table, new_symbol_table, get_message_handler())) return true; - + return false; } @@ -196,7 +196,7 @@ bool ansi_c_languaget::final(symbol_tablet &symbol_table) { if(ansi_c_entry_point(symbol_table, "main", get_message_handler())) return true; - + return false; } @@ -211,7 +211,7 @@ Function: ansi_c_languaget::show_parse Purpose: \*******************************************************************/ - + void ansi_c_languaget::show_parse(std::ostream &out) { parse_tree.output(out); @@ -308,7 +308,7 @@ Function: ansi_c_languaget::to_expr Purpose: \*******************************************************************/ - + bool ansi_c_languaget::to_expr( const std::string &code, const std::string &module, @@ -321,7 +321,7 @@ bool ansi_c_languaget::to_expr( std::istringstream i_preprocessed( "void __my_expression = (void) (\n"+code+"\n);"); - + // parsing ansi_c_parser.clear(); @@ -338,14 +338,14 @@ bool ansi_c_languaget::to_expr( else { expr=ansi_c_parser.parse_tree.items.front().declarator().value(); - + // typecheck it result=ansi_c_typecheck(expr, get_message_handler(), ns); } // save some memory ansi_c_parser.clear(); - + // now remove that (void) cast if(expr.id()==ID_typecast && expr.type().id()==ID_empty && diff --git a/src/ansi-c/ansi_c_language.h b/src/ansi-c/ansi_c_language.h index 901df70df7c..5344bce5ebb 100644 --- a/src/ansi-c/ansi_c_language.h +++ b/src/ansi-c/ansi_c_language.h @@ -29,7 +29,7 @@ class ansi_c_languaget:public languaget virtual bool parse( std::istream &instream, const std::string &path); - + virtual bool typecheck( symbol_tablet &symbol_table, const std::string &module); @@ -38,10 +38,10 @@ class ansi_c_languaget:public languaget symbol_tablet &symbol_table); virtual void show_parse(std::ostream &out); - + virtual ~ansi_c_languaget(); ansi_c_languaget() { } - + virtual bool from_expr( const exprt &expr, std::string &code, @@ -62,21 +62,21 @@ class ansi_c_languaget:public languaget const std::string &module, exprt &expr, const namespacet &ns); - + virtual languaget *new_language() { return new ansi_c_languaget; } - + virtual std::string id() const { return "C"; } virtual std::string description() const { return "ANSI-C 99"; } virtual std::set extensions() const; - virtual void modules_provided(std::set &modules); - + virtual void modules_provided(std::set &modules); + protected: ansi_c_parse_treet parse_tree; std::string parse_path; }; - + languaget *new_ansi_c_language(); - + #endif diff --git a/src/ansi-c/ansi_c_parser.cpp b/src/ansi-c/ansi_c_parser.cpp index 5454b26f5f8..88787d4b519 100644 --- a/src/ansi-c/ansi_c_parser.cpp +++ b/src/ansi-c/ansi_c_parser.cpp @@ -36,7 +36,7 @@ ansi_c_id_classt ansi_c_parsert::lookup( tag?"tag-"+id2string(base_name): label?"label-"+id2string(base_name): base_name; - + for(scopest::const_reverse_iterator it=scopes.rbegin(); it!=scopes.rend(); it++) @@ -51,7 +51,7 @@ ansi_c_id_classt ansi_c_parsert::lookup( return n_it->second.id_class; } } - + // Not found. // If it's a tag, we will add to current scope. if(tag) @@ -87,7 +87,7 @@ void ansi_c_parsert::add_tag_with_body(irept &tag) "tag-"+tag.get_string(ID_C_base_name); irep_idt prefixed_name=current_scope().prefix+scope_name; - + if(prefixed_name!=tag.get(ID_identifier)) { // re-defined in a deeper scope @@ -138,15 +138,15 @@ void ansi_c_parsert::add_declarator( assert(declarator.is_not_nil()); ansi_c_declarationt &ansi_c_declaration= to_ansi_c_declaration(declaration); - + ansi_c_declaratort new_declarator; new_declarator.build(declarator); irep_idt base_name=new_declarator.get_base_name(); - + bool is_member=ansi_c_declaration.get_is_member(); bool is_parameter=ansi_c_declaration.get_is_parameter(); - + if(is_member) { // we don't put them into a struct scope (unlike C++) @@ -154,7 +154,7 @@ void ansi_c_parsert::add_declarator( ansi_c_declaration.declarators().push_back(new_declarator); return; // done } - + // global? if(current_scope().prefix=="") ansi_c_declaration.set_is_global(true); @@ -167,14 +167,14 @@ void ansi_c_parsert::add_declarator( bool is_extern=c_storage_spec.is_extern; bool force_root_scope=false; - + // Functions always go into global scope, unless // declared as a parameter or are typedefs. if(new_declarator.type().id()==ID_code && !is_parameter && !is_typedef) force_root_scope=true; - + // variables marked as 'extern' always go into global scope if(is_extern) force_root_scope=true; @@ -185,18 +185,18 @@ void ansi_c_parsert::add_declarator( scopet &scope= force_root_scope?root_scope():current_scope(); - // set the final name + // set the final name irep_idt prefixed_name=force_root_scope? base_name: current_scope().prefix+id2string(base_name); new_declarator.set_name(prefixed_name); - // add to scope + // add to scope ansi_c_identifiert &identifier=scope.name_map[base_name]; identifier.id_class=id_class; identifier.prefixed_name=prefixed_name; } - + ansi_c_declaration.declarators().push_back(new_declarator); } @@ -211,7 +211,7 @@ Function: ansi_c_parsert::get_class Purpose: \*******************************************************************/ - + ansi_c_id_classt ansi_c_parsert::get_class(const typet &type) { if(type.id()==ID_typedef) diff --git a/src/ansi-c/ansi_c_parser.h b/src/ansi-c/ansi_c_parser.h index b6440e815f5..0ca7f4f5b89 100644 --- a/src/ansi-c/ansi_c_parser.h +++ b/src/ansi-c/ansi_c_parser.h @@ -28,30 +28,30 @@ class ansi_c_parsert:public parsert { public: ansi_c_parse_treet parse_tree; - + ansi_c_parsert(): cpp98(false), cpp11(false), for_has_scope(false) { } - + virtual bool parse() override { return yyansi_cparse()!=0; } - virtual void clear() override + virtual void clear() override { parsert::clear(); parse_tree.clear(); - + // scanner state tag_following=false; asm_block_following=false; parenthesis_counter=0; string_literal.clear(); pragma_pack.clear(); - + // setup global scope scopes.clear(); scopes.push_back(scopet()); @@ -67,33 +67,33 @@ class ansi_c_parsert:public parsert typedef configt::ansi_ct::flavourt modet; modet mode; - // recognize C++98 and C++11 keywords + // recognize C++98 and C++11 keywords bool cpp98, cpp11; - + // in C99 and upwards, for(;;) has a scope bool for_has_scope; - typedef ansi_c_identifiert identifiert; + typedef ansi_c_identifiert identifiert; typedef ansi_c_scopet scopet; typedef std::list scopest; scopest scopes; - + scopet &root_scope() { return scopes.front(); } - + const scopet &root_scope() const { return scopes.front(); } - + void pop_scope() { scopes.pop_back(); } - + scopet ¤t_scope() { assert(!scopes.empty()); @@ -113,7 +113,7 @@ class ansi_c_parsert:public parsert assert(declaration.id()==ID_declaration); parse_tree.items.push_back(declaration); } - + void new_scope(const std::string &prefix) { const scopet ¤t=current_scope(); @@ -128,7 +128,7 @@ class ansi_c_parsert:public parsert bool label); static ansi_c_id_classt get_class(const typet &type); - + irep_idt lookup_label(const irep_idt base_name) { irep_idt identifier; diff --git a/src/ansi-c/ansi_c_scope.cpp b/src/ansi-c/ansi_c_scope.cpp index 4807916f4a6..8c2bcc4e589 100644 --- a/src/ansi-c/ansi_c_scope.cpp +++ b/src/ansi-c/ansi_c_scope.cpp @@ -36,4 +36,3 @@ void ansi_c_scopet::print(std::ostream &out) const << "\n"; } } - diff --git a/src/ansi-c/ansi_c_scope.h b/src/ansi-c/ansi_c_scope.h index 7bd953dca9e..b95cdcb06f7 100644 --- a/src/ansi-c/ansi_c_scope.h +++ b/src/ansi-c/ansi_c_scope.h @@ -20,12 +20,12 @@ class ansi_c_identifiert public: ansi_c_id_classt id_class; irep_idt base_name, prefixed_name; - + ansi_c_identifiert():id_class(ANSI_C_UNKNOWN) { } }; - + class ansi_c_scopet { public: @@ -33,19 +33,19 @@ class ansi_c_scopet // ansi_c_identifiert. typedef hash_map_cont name_mapt; name_mapt name_map; - + std::string prefix; - + // We remember the last declarator for the benefit // of function argument scoping. irep_idt last_declarator; - + // for(;;) and { } scopes are numbered unsigned compound_counter; unsigned anon_counter; - + ansi_c_scopet():compound_counter(0), anon_counter(0) { } - + void swap(ansi_c_scopet &scope) { name_map.swap(scope.name_map); @@ -53,7 +53,7 @@ class ansi_c_scopet last_declarator.swap(scope.last_declarator); std::swap(compound_counter, scope.compound_counter); } - + void print(std::ostream &out) const; }; diff --git a/src/ansi-c/ansi_c_typecheck.cpp b/src/ansi-c/ansi_c_typecheck.cpp index 5abe39acef5..53daf912dc2 100644 --- a/src/ansi-c/ansi_c_typecheck.cpp +++ b/src/ansi-c/ansi_c_typecheck.cpp @@ -97,6 +97,6 @@ bool ansi_c_typecheck( { ansi_c_typecheck.error() << e << messaget::eom; } - + return ansi_c_typecheck.get_error_found(); } diff --git a/src/ansi-c/c_preprocess.cpp b/src/ansi-c/c_preprocess.cpp index 28523fff96c..0177d5950eb 100644 --- a/src/ansi-c/c_preprocess.cpp +++ b/src/ansi-c/c_preprocess.cpp @@ -46,7 +46,7 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTMAX_TYPE__=\"long long int\""\ " -D__UINTMAX_TYPE__=\"long long unsigned int\""\ " -D__INTPTR_TYPE__=\"int\""\ - " -D__UINTPTR_TYPE__=\"unsigned int\"" + " -D__UINTPTR_TYPE__=\"unsigned int\"" #define GCC_DEFINES_32 \ " -D__INT_MAX__=2147483647"\ @@ -61,8 +61,8 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTMAX_TYPE__=\"long long int\""\ " -D__UINTMAX_TYPE__=\"long long unsigned int\""\ " -D__INTPTR_TYPE__=\"long int\""\ - " -D__UINTPTR_TYPE__=\"long unsigned int\"" - + " -D__UINTPTR_TYPE__=\"long unsigned int\"" + #define GCC_DEFINES_LP64 \ " -D__INT_MAX__=2147483647"\ " -D__CHAR_BIT__=8"\ @@ -76,7 +76,7 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTMAX_TYPE__=\"long int\""\ " -D__UINTMAX_TYPE__=\"long unsigned int\""\ " -D__INTPTR_TYPE__=\"long int\""\ - " -D__UINTPTR_TYPE__=\"long unsigned int\"" + " -D__UINTPTR_TYPE__=\"long unsigned int\"" #define GCC_DEFINES_LLP64 \ " -D__INT_MAX__=2147483647"\ @@ -91,7 +91,7 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTMAX_TYPE__=\"long long int\""\ " -D__UINTMAX_TYPE__=\"long long unsigned int\""\ " -D__INTPTR_TYPE__=\"long long int\""\ - " -D__UINTPTR_TYPE__=\"long long unsigned int\"" + " -D__UINTPTR_TYPE__=\"long long unsigned int\"" /*******************************************************************\ @@ -133,7 +133,7 @@ static std::string shell_quote(const std::string &src) { #ifdef _WIN32 // first check if quoting is needed at all - + if(src.find(' ')==std::string::npos && src.find('"')==std::string::npos && src.find('&')==std::string::npos && @@ -147,9 +147,9 @@ static std::string shell_quote(const std::string &src) // seems fine -- return as is return src; } - + std::string result; - + result+='"'; for(unsigned i=0; i::const_iterator it=config.ansi_c.defines.begin(); it!=config.ansi_c.defines.end(); @@ -542,9 +542,9 @@ bool c_preprocess_visual_studio( // (this is already in UTF-8). command_file << shell_quote(file) << "\n"; } - + std::string tmpi=get_temporary_file("tmp.cl", ""); - + std::string command="CL @\""+command_file_name+"\""; command+=" > \""+tmpi+"\""; command+=" 2> \""+stderr_file+"\""; @@ -615,13 +615,13 @@ void postprocess_codewarrior( // /* #line 1 "__ppc_eabi_init.cpp" /* stack depth 0 */ // // We remove the initial '/* ' prefix - + std::string line; - + while(instream) { std::getline(instream, line); - + if(line.size()>=2 && line[0]=='#' && (line[1]=='#' || line[1]==' ' || line[1]=='\t')) { @@ -664,7 +664,7 @@ bool c_preprocess_codewarrior( std::string stderr_file=get_temporary_file("tmp.stderr", ""); std::string command; - + command="mwcceppc -E -P -D__CPROVER__ -ppopt line -ppopt full"; for(std::list::const_iterator @@ -690,7 +690,7 @@ bool c_preprocess_codewarrior( it!=config.ansi_c.preprocessor_options.end(); it++) command+=" "+*it; - + int result; std::string tmpi=get_temporary_file("tmp.cl", ""); @@ -761,16 +761,16 @@ bool c_preprocess_gcc_clang( std::string stderr_file=get_temporary_file("tmp.stderr", ""); std::string command; - + if(preprocessor==configt::ansi_ct::preprocessort::CLANG) command="clang"; else command="gcc"; - + command +=" -E -undef -D__CPROVER__"; command+=" -D__WORDSIZE="+i2string(config.ansi_c.pointer_width); - + command+=" -D__DBL_MIN_EXP__=\"(-1021)\""; command+=" -D__FLT_MIN__=1.17549435e-38F"; command+=" -D__DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD"; @@ -876,13 +876,13 @@ bool c_preprocess_gcc_clang( else command+=GCC_DEFINES_32; } - + // The width of wchar_t depends on the OS! { command+=" -D__WCHAR_MAX__="+type_max(wchar_t_type()); - + std::string sig=config.ansi_c.wchar_t_is_unsigned?"unsigned":"signed"; - + if(config.ansi_c.wchar_t_width==config.ansi_c.short_int_width) command+=" -D__WCHAR_TYPE__=\""+sig+" short int\""; else if(config.ansi_c.wchar_t_width==config.ansi_c.int_width) @@ -928,11 +928,11 @@ bool c_preprocess_gcc_clang( case configt::ansi_ct::ost::NO_OS: command+=" -nostdinc"; // make sure we don't mess with the system library break; - + default: assert(false); } - + // Standard Defines, ANSI9899 6.10.8 switch(config.ansi_c.c_standard) { @@ -951,7 +951,7 @@ bool c_preprocess_gcc_clang( command += " -D __STDC_IEC_559__=1"; command += " -D __STDC_IEC_559_COMPLEX__=1"; command += " -D __STDC_ISO_10646__=1"; - + for(std::list::const_iterator it=config.ansi_c.defines.begin(); it!=config.ansi_c.defines.end(); @@ -975,10 +975,10 @@ bool c_preprocess_gcc_clang( it!=config.ansi_c.preprocessor_options.end(); it++) command+=" "+*it; - + int result; - #if 0 + #if 0 // the following forces the mode switch(config.ansi_c.mode) { @@ -1087,9 +1087,9 @@ bool c_preprocess_arm( std::string stderr_file=get_temporary_file("tmp.stderr", ""); std::string command; - + command="armcc -E -D__CPROVER__"; - + // command+=" -D__sizeof_int="+i2string(config.ansi_c.int_width/8); // command+=" -D__sizeof_long="+i2string(config.ansi_c.long_int_width/8); // command+=" -D__sizeof_ptr="+i2string(config.ansi_c.pointer_width/8); @@ -1104,7 +1104,7 @@ bool c_preprocess_arm( // if(config.ansi_c.char_is_unsigned) // command+=" -D__CHAR_UNSIGNED__"; - + if(config.ansi_c.os!=configt::ansi_ct::ost::OS_WIN) { command+=" -D__WORDSIZE="+i2string(config.ansi_c.pointer_width); @@ -1116,7 +1116,7 @@ bool c_preprocess_arm( else if(config.ansi_c.int_width==64) command+=GCC_DEFINES_LP64; } - + // Standard Defines, ANSI9899 6.10.8 command+=" -D__STDC__"; //command+=" -D__STDC_VERSION__=199901L"; @@ -1224,14 +1224,14 @@ bool c_preprocess_none( #else std::ifstream infile(file); #endif - + if(!infile) { messaget message(message_handler); message.error() << "failed to open `" << file << "'" << messaget::eom; return true; } - + if(config.ansi_c.mode==configt::ansi_ct::flavourt::CODEWARRIOR) { // special treatment for "/* #line" @@ -1269,6 +1269,6 @@ bool test_c_preprocessor(message_handlert &message_handler) { std::ostringstream out; std::istringstream in(c_test_program); - + return c_preprocess(in, out, message_handler); } diff --git a/src/ansi-c/c_preprocess.h b/src/ansi-c/c_preprocess.h index a9f4cb2d83e..37b6bfa83c1 100644 --- a/src/ansi-c/c_preprocess.h +++ b/src/ansi-c/c_preprocess.h @@ -18,7 +18,7 @@ bool c_preprocess( const std::string &path, std::ostream &outstream, message_handlert &message_handler); - + bool c_preprocess( std::istream &instream, std::ostream &outstream, @@ -26,5 +26,5 @@ bool c_preprocess( // returns 'true' in case of error bool test_c_preprocessor(message_handlert &message_handler); - + #endif diff --git a/src/ansi-c/c_qualifiers.cpp b/src/ansi-c/c_qualifiers.cpp index 2602565810c..75ca8bf9c05 100644 --- a/src/ansi-c/c_qualifiers.cpp +++ b/src/ansi-c/c_qualifiers.cpp @@ -25,7 +25,7 @@ Function: c_qualifierst::as_string std::string c_qualifierst::as_string() const { std::string qualifiers; - + if(is_constant) qualifiers+="const "; @@ -34,19 +34,19 @@ std::string c_qualifierst::as_string() const if(is_restricted) qualifiers+="restrict "; - + if(is_atomic) qualifiers+="_Atomic "; - + if(is_ptr32) qualifiers+="__ptr32 "; - + if(is_ptr64) qualifiers+="__ptr64 "; if(is_noreturn) qualifiers+="_Noreturn "; - + return qualifiers; } @@ -185,4 +185,3 @@ std::ostream &operator << ( { return out << c_qualifiers.as_string(); } - diff --git a/src/ansi-c/c_qualifiers.h b/src/ansi-c/c_qualifiers.h index 006b3f481df..f676d12b2b7 100644 --- a/src/ansi-c/c_qualifiers.h +++ b/src/ansi-c/c_qualifiers.h @@ -20,13 +20,13 @@ class c_qualifierst { clear(); } - + explicit c_qualifierst(const typet &src) { clear(); read(src); } - + void clear() { is_constant=false; @@ -40,21 +40,21 @@ class c_qualifierst // standard ones bool is_constant, is_volatile, is_restricted, is_atomic, is_noreturn; - + // MS Visual Studio extension bool is_ptr32, is_ptr64; - + // gcc extension bool is_transparent_union; - + // will likely add alignment here as well - + std::string as_string() const; void read(const typet &src); void write(typet &src) const; - + static void clear(typet &dest); - + bool is_subset_of(const c_qualifierst &q) const { return (!is_constant || q.is_constant) && @@ -67,7 +67,7 @@ class c_qualifierst // is_transparent_union isn't checked } - + friend bool operator == ( const c_qualifierst &a, const c_qualifierst &b) @@ -88,7 +88,7 @@ class c_qualifierst { return !(a==b); } - + c_qualifierst &operator += ( const c_qualifierst &b) { @@ -102,7 +102,7 @@ class c_qualifierst is_noreturn|=b.is_noreturn; return *this; } - + friend unsigned count(const c_qualifierst &q) { return q.is_constant+q.is_volatile+q.is_restricted+q.is_atomic+ diff --git a/src/ansi-c/c_sizeof.cpp b/src/ansi-c/c_sizeof.cpp index c39c7e2080e..4de0d9dd22b 100644 --- a/src/ansi-c/c_sizeof.cpp +++ b/src/ansi-c/c_sizeof.cpp @@ -32,7 +32,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) // this implementation will eventually be replaced // by size_of_expr in util/pointer_offset_size.h exprt dest; - + if(type.id()==ID_signedbv || type.id()==ID_unsignedbv || type.id()==ID_floatbv || @@ -66,7 +66,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) // the following is an MS extension if(type.get_bool(ID_C_ptr32)) return from_integer(4, size_type()); - + std::size_t bits=config.ansi_c.pointer_width; std::size_t bytes=bits/8; if((bits%8)!=0) bytes++; @@ -82,7 +82,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) { const exprt &size_expr= to_array_type(type).size(); - + if(size_expr.is_nil()) { // treated like an empty array @@ -119,7 +119,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) to_struct_type(type).components(); dest=from_integer(0, size_type()); - + mp_integer bit_field_width=0; for(struct_typet::componentst::const_iterator @@ -151,7 +151,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) dest=plus_exprt(dest, tmp); } } - + if(bit_field_width!=0) dest=plus_exprt(dest, from_integer(bit_field_width/8, size_type())); } @@ -159,7 +159,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) { // the empty union will have size 0 exprt max_size=from_integer(0, size_type()); - + const union_typet::componentst &components= to_union_type(type).components(); @@ -172,7 +172,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) continue; const typet &sub_type=it->type(); - + exprt tmp; if(sub_type.id()==ID_c_bit_field) @@ -212,7 +212,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) // simply multiply const exprt &size_expr= to_vector_type(type).size(); - + exprt tmp_dest=sizeof_rec(type.subtype()); if(tmp_dest.is_nil()) @@ -258,7 +258,7 @@ exprt c_sizeoft::sizeof_rec(const typet &type) // meaningful size. dest.make_nil(); } - + return dest; } @@ -282,7 +282,7 @@ exprt c_sizeoft::c_offsetof( type.components(); exprt dest=from_integer(0, size_type()); - + mp_integer bit_field_width=0; for(struct_typet::componentst::const_iterator @@ -297,10 +297,10 @@ exprt c_sizeoft::c_offsetof( dest=plus_exprt(dest, from_integer(bit_field_width/8, size_type())); return dest; } - + if(it->get_bool(ID_is_type)) continue; - + const typet &sub_type=ns.follow(it->type()); if(sub_type.id()==ID_code) @@ -369,4 +369,3 @@ exprt c_offsetof( simplify(tmp, ns); return tmp; } - diff --git a/src/ansi-c/c_sizeof.h b/src/ansi-c/c_sizeof.h index b4ebc041951..2ec8508f928 100644 --- a/src/ansi-c/c_sizeof.h +++ b/src/ansi-c/c_sizeof.h @@ -15,7 +15,7 @@ class c_sizeoft c_sizeoft(const namespacet &_ns):ns(_ns) { } - + virtual ~c_sizeoft() { } diff --git a/src/ansi-c/c_storage_spec.h b/src/ansi-c/c_storage_spec.h index 05a4941b0af..b4a28c117c9 100644 --- a/src/ansi-c/c_storage_spec.h +++ b/src/ansi-c/c_storage_spec.h @@ -18,13 +18,13 @@ class c_storage_spect { clear(); } - + explicit c_storage_spect(const typet &type) { clear(); read(type); } - + void clear() { is_typedef=false; @@ -38,7 +38,7 @@ class c_storage_spect asm_label.clear(); section.clear(); } - + bool is_typedef, is_extern, is_static, is_register, is_inline, is_thread_local, is_weak; @@ -48,7 +48,7 @@ class c_storage_spect // GCC asm labels __asm__("foo") - these change the symbol name irep_idt asm_label; irep_idt section; - + friend bool operator == ( const c_storage_spect &a, const c_storage_spect &b) @@ -83,10 +83,10 @@ class c_storage_spect a.is_inline |=b.is_inline; a.is_thread_local |=b.is_thread_local; // attributes belong to the declarator, don't replace them - + return a; } - + void read(const typet &type); }; diff --git a/src/ansi-c/c_typecast.cpp b/src/ansi-c/c_typecast.cpp index 6e8f432711e..43bbbc7c7bb 100644 --- a/src/ansi-c/c_typecast.cpp +++ b/src/ansi-c/c_typecast.cpp @@ -106,7 +106,7 @@ bool is_void_pointer(const typet &type) { if(type.subtype().id()==ID_empty) return true; - + return is_void_pointer(type.subtype()); } else @@ -129,7 +129,7 @@ bool check_c_implicit_typecast( const typet &src_type, const typet &dest_type) { - // check qualifiers + // check qualifiers if(src_type.id()==ID_pointer && dest_type.id()==ID_pointer && src_type.subtype().get_bool(ID_C_constant) && @@ -137,7 +137,7 @@ bool check_c_implicit_typecast( return true; if(src_type==dest_type) return false; - + const irep_idt &src_type_id=src_type.id(); if(src_type_id==ID_c_bit_field) @@ -251,7 +251,7 @@ bool check_c_implicit_typecast( // imaginary part of the complex value is discarded and the value of the // real part is converted according to the conversion rules for the // corresponding real type. - + return check_c_implicit_typecast(src_type.subtype(), dest_type); } } @@ -269,7 +269,7 @@ bool check_c_implicit_typecast( is_void_pointer(dest_type)) // to void from anything return false; } - + if(dest_type.id()==ID_array && src_type.subtype()==dest_type.subtype()) return false; @@ -312,12 +312,12 @@ Function: c_typecastt::follow_with_qualifiers typet c_typecastt::follow_with_qualifiers(const typet &src_type) { if(src_type.id()!=ID_symbol) return src_type; - + typet result_type=src_type; - + // collect qualifiers c_qualifierst qualifiers(src_type); - + while(result_type.id()==ID_symbol) { const symbolt &followed_type_symbol= @@ -422,8 +422,8 @@ c_typecastt::c_typet c_typecastt::get_c_type( return COMPLEX; else if(type.id()==ID_c_bit_field) return get_c_type(to_c_bit_field_type(type).subtype()); - - return OTHER; + + return OTHER; } /*******************************************************************\ @@ -443,9 +443,9 @@ void c_typecastt::implicit_typecast_arithmetic( c_typet c_type) { typet new_type; - + const typet &expr_type=ns.follow(expr.type()); - + switch(c_type) { case PTR: @@ -561,10 +561,10 @@ Function: c_typecastt::implicit_typecast void c_typecastt::implicit_typecast( exprt &expr, const typet &type) -{ +{ typet src_type=follow_with_qualifiers(expr.type()), dest_type=follow_with_qualifiers(type); - + typet type_qual=type; c_qualifierst qualifiers(dest_type); qualifiers.write(type_qual); @@ -607,7 +607,7 @@ void c_typecastt::implicit_typecast_followed( if(src_type.id()==ID_pointer && src_type.subtype().get_bool(ID_C_constant)) src_type_no_const.subtype().remove(ID_C_constant); - + // Check union members. const union_typet &dest_union_type=to_union_type(dest_type); @@ -644,12 +644,12 @@ void c_typecastt::implicit_typecast_followed( expr.set(ID_value, ID_NULL); return; // ok } - + if(src_type.id()==ID_pointer || src_type.id()==ID_array) { // we are quite generous about pointers - + const typet &src_sub=ns.follow(src_type.subtype()); const typet &dest_sub=ns.follow(dest_type.subtype()); @@ -699,7 +699,7 @@ void c_typecastt::implicit_typecast_followed( return; // ok } } - + if(check_c_implicit_typecast(src_type, dest_type)) errors.push_back("implicit conversion not permitted"); else if(src_type!=dest_type) @@ -735,7 +735,7 @@ void c_typecastt::implicit_typecast_arithmetic( // get the biggest width of both unsigned width1=type1.get_int(ID_width); unsigned width2=type2.get_int(ID_width); - + // produce type typet result_type; @@ -753,7 +753,7 @@ void c_typecastt::implicit_typecast_arithmetic( do_typecast(expr1, result_type); do_typecast(expr2, result_type); - + return; } else if(max_type==COMPLEX) @@ -801,7 +801,7 @@ void c_typecastt::implicit_typecast_arithmetic( { if(c_type1==VOIDPTR) do_typecast(expr1, expr2.type()); - + if(c_type2==VOIDPTR) do_typecast(expr2, expr1.type()); } @@ -824,7 +824,7 @@ void c_typecastt::do_typecast(exprt &expr, const typet &dest_type) { // special case: array -> pointer is actually // something like address_of - + const typet &src_type=ns.follow(expr.type()); if(src_type.id()==ID_array) @@ -845,7 +845,7 @@ void c_typecastt::do_typecast(exprt &expr, const typet &dest_type) // explicit comparision with zero. // Note that this requires ieee_float_notequal // in case of floating-point numbers. - + if(dest_type.get(ID_C_c_type)==ID_bool) { expr=is_not_zero(expr, ns); @@ -856,7 +856,7 @@ void c_typecastt::do_typecast(exprt &expr, const typet &dest_type) expr=is_not_zero(expr, ns); } else - { + { expr.make_typecast(dest_type); } } diff --git a/src/ansi-c/c_typecast.h b/src/ansi-c/c_typecast.h index 203d00477c9..d2039237000 100644 --- a/src/ansi-c/c_typecast.h +++ b/src/ansi-c/c_typecast.h @@ -56,13 +56,13 @@ class c_typecastt virtual void implicit_typecast_arithmetic( exprt &expr1, exprt &expr2); - + std::list errors; std::list warnings; protected: const namespacet &ns; - + // these are in promotion order enum c_typet { BOOL, @@ -83,7 +83,7 @@ class c_typecastt void implicit_typecast_arithmetic( exprt &expr, c_typet c_type); - + typet follow_with_qualifiers(const typet &src); // after follow_with_qualifiers diff --git a/src/ansi-c/c_typecheck_argc_argv.cpp b/src/ansi-c/c_typecheck_argc_argv.cpp index 5e77cbf0600..71ac609d4b3 100644 --- a/src/ansi-c/c_typecheck_argc_argv.cpp +++ b/src/ansi-c/c_typecheck_argc_argv.cpp @@ -40,7 +40,7 @@ void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) } symbolt *argc_new_symbol; - + const exprt &op0=static_cast(parameters[0]); const exprt &op1=static_cast(parameters[1]); @@ -83,7 +83,7 @@ void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) // need to add one to the size -- the array is terminated // with NULL exprt one_expr=from_integer(1, argc_new_symbol->type); - + exprt size_expr(ID_plus, argc_new_symbol->type); size_expr.copy_to_operands(argc_new_symbol->symbol_expr(), one_expr); argv_type.add(ID_size).swap(size_expr); @@ -99,21 +99,21 @@ void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) symbolt *argv_new_symbol; move_symbol(argv_symbol, argv_new_symbol); } - + if(parameters.size()==3) - { - symbolt envp_symbol; + { + symbolt envp_symbol; envp_symbol.base_name="envp'"; envp_symbol.name="envp'"; envp_symbol.type=(static_cast(parameters[2])).type(); envp_symbol.is_static_lifetime=true; - + symbolt envp_size_symbol, *envp_new_size_symbol; envp_size_symbol.base_name="envp_size"; envp_size_symbol.name="envp_size'"; envp_size_symbol.type=op0.type(); // same type as argc! - envp_size_symbol.is_static_lifetime=true; - move_symbol(envp_size_symbol, envp_new_size_symbol); + envp_size_symbol.is_static_lifetime=true; + move_symbol(envp_size_symbol, envp_new_size_symbol); if(envp_symbol.type.id()!=ID_pointer) { @@ -122,12 +122,12 @@ void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) << to_string(envp_symbol.type) << '\'' << eom; throw 0; } - + exprt size_expr = envp_new_size_symbol->symbol_expr(); envp_symbol.type.id(ID_array); envp_symbol.type.add(ID_size).swap(size_expr); - + symbolt *envp_new_symbol; move_symbol(envp_symbol, envp_new_symbol); } diff --git a/src/ansi-c/c_typecheck_base.cpp b/src/ansi-c/c_typecheck_base.cpp index e055236d12f..be7c58cc197 100644 --- a/src/ansi-c/c_typecheck_base.cpp +++ b/src/ansi-c/c_typecheck_base.cpp @@ -30,7 +30,7 @@ Function: c_typecheck_baset::to_string \*******************************************************************/ std::string c_typecheck_baset::to_string(const exprt &expr) -{ +{ return expr2c(expr, *this); } @@ -47,7 +47,7 @@ Function: c_typecheck_baset::to_string \*******************************************************************/ std::string c_typecheck_baset::to_string(const typet &type) -{ +{ return type2c(type, *this); } @@ -96,10 +96,10 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) bool is_function=symbol.type.id()==ID_code; const typet &final_type=follow(symbol.type); - + // set a few flags symbol.is_lvalue=!symbol.is_type && !symbol.is_macro; - + irep_idt root_name=symbol.base_name; irep_idt new_name=symbol.name; @@ -121,7 +121,7 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) error() << "only functions can have a function body" << eom; throw 0; } - + // set the pretty name if(symbol.is_type && (final_type.id()==ID_struct || @@ -145,18 +145,18 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) { symbol.pretty_name=new_name; } - + // see if we have it already symbol_tablet::symbolst::iterator old_it=symbol_table.symbols.find(symbol.name); - + if(old_it==symbol_table.symbols.end()) { // just put into symbol_table symbolt *new_symbol; move_symbol(symbol, new_symbol); - + typecheck_new_symbol(*new_symbol); - } + } else { if(old_it->second.is_type!=symbol.is_type) @@ -221,13 +221,13 @@ void c_typecheck_baset::typecheck_new_symbol(symbolt &symbol) type_symbolt new_symbol(symbol.type); new_symbol.name=id2string(symbol.name)+"$type"; - new_symbol.base_name=id2string(symbol.base_name)+"$type"; + new_symbol.base_name=id2string(symbol.base_name)+"$type"; new_symbol.location=symbol.location; new_symbol.mode=symbol.mode; new_symbol.module=symbol.module; - + symbol.type=symbol_typet(new_symbol.name); - + symbolt *new_sp; symbol_table.move(new_symbol, new_sp); } @@ -266,7 +266,7 @@ void c_typecheck_baset::typecheck_redefinition_type( { // overwrite location old_symbol.location=new_symbol.location; - + // move body old_symbol.type.swap(new_symbol.type); } @@ -290,7 +290,7 @@ void c_typecheck_baset::typecheck_redefinition_type( { if("incomplete_"+final_old.id_string()==final_new.id_string()) { - // just ignore silently + // just ignore silently } else { @@ -303,8 +303,8 @@ void c_typecheck_baset::typecheck_redefinition_type( } } else if(config.ansi_c.os==configt::ansi_ct::ost::OS_WIN && - final_new.id()==ID_c_enum && final_old.id()==ID_c_enum) - { + final_new.id()==ID_c_enum && final_old.id()==ID_c_enum) + { // under Windows, ignore this silently; // MSC doesn't think this is a problem, but GCC complains. } @@ -365,9 +365,9 @@ void c_typecheck_baset::typecheck_redefinition_non_type( if(follow(new_symbol.type).id()!=ID_code && !new_symbol.is_macro) do_initializer(new_symbol); - + const typet &final_new=follow(new_symbol.type); - + // K&R stuff? if(old_symbol.type.id()==ID_KnR) { @@ -379,18 +379,18 @@ void c_typecheck_baset::typecheck_redefinition_non_type( << eom; throw 0; } - + // fix up old symbol -- we now got the type old_symbol.type=new_symbol.type; return; } - + if(final_new.id()==ID_code) { bool inlined= (new_symbol.type.get_bool(ID_C_inlined) || old_symbol.type.get_bool(ID_C_inlined)); - + if(final_old.id()!=ID_code) { error().source_location=new_symbol.location; @@ -404,7 +404,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type( code_typet &old_ct=to_code_type(old_symbol.type); code_typet &new_ct=to_code_type(new_symbol.type); - + if(old_ct.has_ellipsis() && !new_ct.has_ellipsis()) old_ct=new_ct; else if(!old_ct.has_ellipsis() && new_ct.has_ellipsis()) @@ -417,14 +417,14 @@ void c_typecheck_baset::typecheck_redefinition_non_type( } // do body - + if(new_symbol.value.is_not_nil()) - { + { if(old_symbol.value.is_not_nil()) { // gcc allows re-definition if the first // definition is marked as "extern inline" - + if(old_symbol.type.get_bool(ID_C_inlined) && (config.ansi_c.mode==configt::ansi_ct::flavourt::GCC || config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE || @@ -473,10 +473,10 @@ void c_typecheck_baset::typecheck_redefinition_non_type( old_symbol.is_macro=true; else typecheck_function_body(new_symbol); - + // overwrite location old_symbol.location=new_symbol.location; - + // move body old_symbol.value.swap(new_symbol.value); @@ -503,7 +503,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type( to_symbol_type(old_symbol.type).get_identifier(); symbol_tablet::symbolst::iterator s_it=symbol_table.symbols.find(identifier); - + if(s_it==symbol_table.symbols.end()) { error().source_location=old_symbol.location; @@ -512,10 +512,10 @@ void c_typecheck_baset::typecheck_redefinition_non_type( << eom; throw 0; } - + symbolt &symbol=s_it->second; - - symbol.type=final_new; + + symbol.type=final_new; } else old_symbol.type=new_symbol.type; @@ -533,7 +533,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type( final_new.id()==ID_pointer && follow(final_new).subtype().id()==ID_code) { - // to allow + // to allow // int (*f) (); // int (*f) (int)=0; old_symbol.type=new_symbol.type; @@ -544,7 +544,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type( follow(final_new).subtype().id()==ID_code && to_code_type(follow(final_new).subtype()).has_ellipsis()) { - // to allow + // to allow // int (*f) (int)=0; // int (*f) (); } @@ -603,13 +603,13 @@ void c_typecheck_baset::typecheck_redefinition_non_type( old_symbol.is_macro=new_symbol.is_macro; } } - + // take care of some flags if(old_symbol.is_extern && !new_symbol.is_extern) old_symbol.location=new_symbol.location; old_symbol.is_extern=old_symbol.is_extern && new_symbol.is_extern; - + // We should likely check is_volatile and // is_thread_local for consistency. GCC complains if these // mismatch. @@ -630,21 +630,21 @@ Function: c_typecheck_baset::typecheck_function_body void c_typecheck_baset::typecheck_function_body(symbolt &symbol) { code_typet &code_type=to_code_type(symbol.type); - + assert(symbol.value.is_not_nil()); - + // reset labels labels_used.clear(); labels_defined.clear(); // fix type symbol.value.type()=code_type; - + // set return type return_type=code_type.return_type(); - + unsigned anon_counter=0; - + // Add the parameter declarations into the symbol table. code_typet::parameterst ¶meters=code_type.parameters(); for(code_typet::parameterst::iterator @@ -658,7 +658,7 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) irep_idt base_name="#anon"+i2string(anon_counter++); p_it->set_base_name(base_name); } - + // produce identifier irep_idt base_name=p_it->get_base_name(); irep_idt identifier=id2string(symbol.name)+"::"+id2string(base_name); @@ -666,7 +666,7 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) p_it->set_identifier(identifier); parameter_symbolt p_symbol; - + p_symbol.type=p_it->type(); p_symbol.name=identifier; p_symbol.base_name=base_name; @@ -676,10 +676,10 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) move_symbol(p_symbol, new_p_symbol); } - // typecheck the body code + // typecheck the body code typecheck_code(to_code(symbol.value)); - // special case for main() + // special case for main() if(symbol.name==ID_main) add_argc_argv(symbol); @@ -805,7 +805,7 @@ void c_typecheck_baset::typecheck_declaration( // first typecheck the type of the declaration typecheck_type(declaration.type()); - + // mark as 'already typechecked' make_already_typechecked(declaration.type()); @@ -906,4 +906,3 @@ void c_typecheck_baset::typecheck_declaration( } } } - diff --git a/src/ansi-c/c_typecheck_base.h b/src/ansi-c/c_typecheck_base.h index 32bb18633ca..eb2d6e66c3a 100644 --- a/src/ansi-c/c_typecheck_base.h +++ b/src/ansi-c/c_typecheck_base.h @@ -62,11 +62,11 @@ class c_typecheck_baset: typedef hash_map_cont id_type_mapt; id_type_mapt parameter_map; - + // overload to use language specific syntax virtual std::string to_string(const exprt &expr); virtual std::string to_string(const typet &type); - + // // service functions // @@ -91,13 +91,13 @@ class c_typecheck_baset: designatort &designator, const exprt &value, bool force_constant); - + designatort make_designator(const typet &type, const exprt &src); void designator_enter(const typet &type, designatort &designator); // go down void increment_designator(designatort &designator); // typecasts - + bool gcc_vector_types_compatible(const vector_typet &, const vector_typet &); virtual void implicit_typecast(exprt &expr, const typet &type); @@ -108,7 +108,7 @@ class c_typecheck_baset: { implicit_typecast(expr, bool_typet()); } - + // code virtual void start_typecheck_code(); virtual void typecheck_code(codet &code); @@ -134,16 +134,16 @@ class c_typecheck_baset: virtual void typecheck_dowhile(code_dowhilet &code); virtual void typecheck_start_thread(codet &code); virtual void typecheck_spec_expr(codet &code, const irep_idt &spec); - + bool break_is_allowed; bool continue_is_allowed; bool case_is_allowed; typet switch_op_type; typet return_type; - + // to check that all labels used are also defined std::map labels_defined, labels_used; - + // expressions virtual void typecheck_expr_builtin_va_arg(exprt &expr); virtual void typecheck_expr_builtin_offsetof(exprt &expr); @@ -186,9 +186,9 @@ class c_typecheck_baset: virtual void make_constant(exprt &expr); virtual void make_constant_index(exprt &expr); virtual void make_constant_rec(exprt &expr); - + virtual bool gcc_types_compatible_p(const typet &, const typet &); - + // types virtual void typecheck_type(typet &type); virtual void typecheck_compound_type(struct_union_typet &type); @@ -204,14 +204,14 @@ class c_typecheck_baset: virtual void typecheck_custom_type(typet &type); virtual void adjust_function_parameter(typet &type) const; virtual bool is_complete_type(const typet &type) const; - + typet enum_constant_type( const mp_integer &min, const mp_integer &max) const; - + typet enum_underlying_type( const mp_integer &min, const mp_integer &max, bool is_packed) const; - + void make_already_typechecked(typet &dest) { typet result(ID_already_typechecked); @@ -229,7 +229,7 @@ class c_typecheck_baset: void move_symbol(symbolt &symbol, symbolt *&new_symbol); void move_symbol(symbolt &symbol) { symbolt *new_symbol; move_symbol(symbol, new_symbol); } - + // top-level stuff void typecheck_declaration(ansi_c_declarationt &); void typecheck_symbol(symbolt &symbol); @@ -239,14 +239,14 @@ class c_typecheck_baset: void typecheck_function_body(symbolt &symbol); virtual void do_initializer(symbolt &symbol); - + inline static bool is_numeric_type(const typet &src) { return src.id()==ID_complex || src.id()==ID_unsignedbv || src.id()==ID_signedbv || - src.id()==ID_floatbv || - src.id()==ID_fixedbv || + src.id()==ID_floatbv || + src.id()==ID_fixedbv || src.id()==ID_c_bool || src.id()==ID_bool || src.id()==ID_c_enum_tag || diff --git a/src/ansi-c/c_typecheck_code.cpp b/src/ansi-c/c_typecheck_code.cpp index 5b8fd61d325..77f3bf3ba50 100644 --- a/src/ansi-c/c_typecheck_code.cpp +++ b/src/ansi-c/c_typecheck_code.cpp @@ -167,22 +167,22 @@ Function: c_typecheck_baset::typecheck_asm void c_typecheck_baset::typecheck_asm(codet &code) { const irep_idt flavor=to_code_asm(code).get_flavor(); - + if(flavor==ID_gcc) { // These have 5 operands. // The first parameter is a string. // Parameters 1, 2, 3, 4 are lists of expressions. - + // Parameter 1: OutputOperands // Parameter 2: InputOperands // Parameter 3: Clobbers // Parameter 4: GotoLabels assert(code.operands().size()==5); - + typecheck_expr(code.op0()); - + for(unsigned i=1; iis_nil()) continue; codet &code_op=to_code(*it1); - + if(code_op.get_statement()==ID_label) { // these may be nested codet *code_ptr=&code_op; - + while(code_ptr->get_statement()==ID_label) { assert(code_ptr->operands().size()==1); code_ptr=&to_code(code_ptr->op0()); } - + //codet &label_op=*code_ptr; new_ops.move_to_operands(code_op); @@ -352,7 +352,7 @@ void c_typecheck_baset::typecheck_decl(codet &code) ansi_c_declarationt declaration; declaration.swap(code.op0()); - + if(declaration.get_is_static_assert()) { assert(declaration.operands().size()==2); @@ -363,13 +363,13 @@ void c_typecheck_baset::typecheck_decl(codet &code) typecheck_code(code); return; // done } - + typecheck_declaration(declaration); - + std::list new_code; - + // iterate over declarators - + for(ansi_c_declarationt::declaratorst::const_iterator d_it=declaration.declarators().begin(); d_it!=declaration.declarators().end(); @@ -390,8 +390,8 @@ void c_typecheck_baset::typecheck_decl(codet &code) } symbolt &symbol=s_it->second; - - // This must not be an incomplete type, unless it's 'extern' + + // This must not be an incomplete type, unless it's 'extern' // or a typedef. if(!symbol.is_type && !symbol.is_extern && @@ -401,7 +401,7 @@ void c_typecheck_baset::typecheck_decl(codet &code) error() << "incomplete type not permitted here" << eom; throw 0; } - + // see if it's a typedef // or a function // or static @@ -417,21 +417,21 @@ void c_typecheck_baset::typecheck_decl(codet &code) code.add_source_location()=symbol.location; code.symbol()=symbol.symbol_expr(); code.symbol().add_source_location()=symbol.location; - + // add initializer, if any if(symbol.value.is_not_nil()) { code.operands().resize(2); - code.op1()=symbol.value; + code.op1()=symbol.value; } - + new_code.push_back(code); } } - + // stash away any side-effects in the declaration new_code.splice(new_code.begin(), clean_code); - + if(new_code.empty()) { source_locationt source_location=code.source_location(); @@ -488,7 +488,7 @@ bool c_typecheck_baset::is_complete_type(const typet &type) const return is_complete_type(type.subtype()); else if(type.id()==ID_symbol) return is_complete_type(follow(type)); - + return true; } @@ -538,7 +538,7 @@ void c_typecheck_baset::typecheck_for(codet &code) error() << "for expected to have four operands" << eom; throw 0; } - + // the "for" statement has an implicit block around it, // since code.op0() may contain declarations // @@ -677,7 +677,7 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code) error() << "did not expect `case' here" << eom; throw 0; } - + exprt &case_expr=code.case_op(); typecheck_expr(case_expr); implicit_typecast(case_expr, switch_op_type); @@ -779,7 +779,7 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) } exprt &dest=code.op0(); - + if(dest.id()!=ID_dereference) { err_location(dest); @@ -787,7 +787,7 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) << eom; throw 0; } - + assert(dest.operands().size()==1); typecheck_expr(dest.op0()); @@ -837,7 +837,7 @@ void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code) code_block.move_to_operands(code.then_case()); code.then_case().swap(code_block); } - + typecheck_code(to_code(code.then_case())); if(!code.else_case().is_nil()) diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index 884cf94d94d..94a861e7a7d 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -133,7 +133,7 @@ bool c_typecheck_baset::gcc_types_compatible_p( // check qualifiers first if(c_qualifierst(type1)!=c_qualifierst(type2)) return false; - + if(type1.id()==ID_c_enum_tag) return gcc_types_compatible_p(follow_tag(to_c_enum_tag_type(type1)), type2); else if(type2.id()==ID_c_enum_tag) @@ -190,12 +190,12 @@ bool c_typecheck_baset::gcc_types_compatible_p( // Need to distinguish e.g. long int from int or // long long int from long int. // The rules appear to match those of C++. - + if(type1.get(ID_C_c_type)==type2.get(ID_C_c_type)) return true; } } - + return false; } @@ -283,7 +283,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) typecheck_type(subtypes[0]); typecheck_type(subtypes[1]); source_locationt source_location=expr.source_location(); - + // ignores top-level qualifiers subtypes[0].remove(ID_C_constant); subtypes[0].remove(ID_C_volatile); @@ -291,7 +291,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) subtypes[1].remove(ID_C_constant); subtypes[1].remove(ID_C_volatile); subtypes[1].remove(ID_C_restricted); - + expr.make_bool(gcc_types_compatible_p(subtypes[0], subtypes[1])); expr.add_source_location()=source_location; } @@ -331,7 +331,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) // op1 the bound expression assert(expr.operands().size()==2); expr.type()=bool_typet(); - + if(expr.op0().get(ID_statement)!=ID_decl) { err_location(expr); @@ -372,18 +372,18 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) throw 0; } - // we could compile away, I suppose + // we could compile away, I suppose expr.type()=op_type; expr.op0().make_typecast(complex_typet(op_type)); } else { expr.type()=op_type.subtype(); - + // these are lvalues if the operand is one if(expr.op0().get_bool(ID_C_lvalue)) expr.set(ID_C_lvalue, true); - + if(expr.op0().get_bool(ID_C_constant)) expr.set(ID_C_constant, true); } @@ -393,7 +393,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) // This is C11. // The operand is already typechecked. Depending // on it's type, we return one of the generic associatios. - + if(expr.operands().size()!=1) { err_location(expr); @@ -409,7 +409,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) irept::subt &generic_associations= expr.add(ID_generic_associations).get_sub(); - + // first typecheck all types Forall_irep(it, generic_associations) if(it->get(ID_type_arg)!=ID_default) @@ -421,9 +421,9 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) // first try non-default match exprt default_match=nil_exprt(); exprt assoc_match=nil_exprt(); - + const typet &op_type=follow(expr.op0().type()); - + forall_irep(it, generic_associations) { if(it->get(ID_type_arg)==ID_default) @@ -431,7 +431,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) else if(op_type==follow(static_cast(it->find(ID_type_arg)))) assoc_match=static_cast(it->find(ID_value)); } - + if(assoc_match.is_nil()) { if(default_match.is_not_nil()) @@ -511,13 +511,13 @@ void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) typet arg_type=expr.type(); typecheck_type(arg_type); - + code_typet new_type; new_type.return_type().swap(arg_type); new_type.parameters().resize(1); new_type.parameters()[0].type()=pointer_type(void_type()); - assert(expr.operands().size()==1); + assert(expr.operands().size()==1); exprt arg=expr.op0(); implicit_typecast(arg, pointer_type(void_type())); @@ -530,21 +530,21 @@ void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) result.function().type()=new_type; result.arguments().push_back(arg); result.type()=new_type.return_type(); - + expr.swap(result); - + // Make sure symbol exists, but we have it return void // to avoid collisions of the same symbol with different // types. - + code_typet symbol_type=new_type; symbol_type.return_type()=void_type(); - + symbolt symbol; symbol.base_name=ID_gcc_builtin_va_arg; symbol.name=ID_gcc_builtin_va_arg; symbol.type=symbol_type; - + symbol_table.move(symbol); } @@ -602,7 +602,7 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) typet &type=static_cast(expr.add(ID_type_arg)); typecheck_type(type); - + exprt &member=static_cast(expr.add(ID_designator)); exprt result=gen_zero(size_type()); @@ -621,17 +621,17 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) << "but got `" << to_string(type) << "'" << eom; throw 0; } - + bool found=false; irep_idt component_name=m_it->get(ID_component_name); while(!found) { assert(type.id()==ID_union || type.id()==ID_struct); - + const struct_union_typet &struct_union_type= to_struct_union_type(type); - + // direct member? if(struct_union_type.has_component(component_name)) { @@ -648,24 +648,24 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) << component_name << "'" << eom; throw 0; } - + if(o.type()!=size_type()) o.make_typecast(size_type()); result=plus_exprt(result, o); } - + type=struct_union_type.get_component(component_name).type(); } else { // maybe anonymous? - + const struct_union_typet::componentst &components= struct_union_type.components(); - + bool found2=false; - + for(struct_union_typet::componentst::const_iterator c_it=components.begin(); c_it!=components.end(); @@ -688,7 +688,7 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) << component_name << "'" << eom; throw 0; } - + if(o.type()!=size_type()) o.make_typecast(size_type()); @@ -703,10 +703,10 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) } } } - + if(!found2) { - err_location(expr); + err_location(expr); error() << "offset-of of member failed to find component `" << component_name << "' in `" << to_string(type) << "'" << eom; @@ -718,7 +718,7 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) else if(m_it->id()==ID_index) { assert(m_it->operands().size()==1); - + if(type.id()!=ID_array) { err_location(expr); @@ -783,7 +783,7 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr) to_ansi_c_declaration(expr.op0()); typecheck_declaration(declaration); - + if(declaration.declarators().size()!=1) { err_location(expr); @@ -807,7 +807,7 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr) } symbolt &symbol=s_it->second; - + if(symbol.is_type || symbol.is_extern || symbol.is_static_lifetime || !is_complete_type(symbol.type) || symbol.type.id()==ID_code) { @@ -815,12 +815,12 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr) error() << "unexpected quantified symbol" << eom; throw 0; } - + code_declt decl; decl.add_source_location()=declaration.source_location(); decl.symbol()=symbol.symbol_expr(); - expr.op0()=decl; + expr.op0()=decl; typecheck_expr(expr.op1()); } @@ -846,7 +846,7 @@ Function: c_typecheck_baset::typecheck_expr_symbol void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) { irep_idt identifier=to_symbol_expr(expr).get_identifier(); - + // Is it a parameter? We do this while checking parameter lists. id_type_mapt::const_iterator p_it=parameter_map.find(identifier); if(p_it!=parameter_map.end()) @@ -875,7 +875,7 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) << identifier << "'" << eom; throw 0; } - + const symbolt &symbol=*symbol_ptr; if(symbol.is_type) @@ -972,9 +972,9 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression( // the type is the type of the last statement in the // block, but do worry about labels! - + codet &last=to_code_block(code).find_last_statement(); - + irep_idt last_statement=last.get_statement(); if(last_statement==ID_expression) @@ -986,13 +986,13 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression( if(op.type().id()==ID_array) implicit_typecast(op, pointer_type(op.type().subtype())); - expr.type()=op.type(); + expr.type()=op.type(); } else if(last_statement==ID_function_call) { // this is suspected to be dead assert(false); - + // make the last statement an expression code_function_callt &fc=to_code_function_call(last); @@ -1066,14 +1066,14 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) "but got " << expr.operands().size() << eom; throw 0; } - + if(type.id()==ID_c_bit_field) { err_location(expr); error() << "sizeof cannot be applied to bit fields" << eom; throw 0; } - + exprt new_expr=c_sizeof(type, *this); if(new_expr.is_nil()) @@ -1095,13 +1095,13 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) decl_block.set_statement(ID_decl_block); side_effect_expr.copy_to_operands(decl_block); clean_code.clear(); - + // We merge the side-effect into the operand of the typecast, // using a comma-expression. // I.e., (type)e becomes (type)(side-effect, e) // It is not obvious whether the type or 'e' should be evaluated // first. - + exprt comma_expr(ID_comma, expr.type()); comma_expr.copy_to_operands(side_effect_expr, expr); expr.swap(comma_expr); @@ -1135,10 +1135,10 @@ void c_typecheck_baset::typecheck_expr_alignof(exprt &expr) // we only care about the type mp_integer a=alignment(argument_type, *this); - + exprt tmp=from_integer(a, size_type()); tmp.add_source_location()=expr.source_location(); - + expr.swap(tmp); } @@ -1175,13 +1175,13 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) decl_block.set_statement(ID_decl_block); side_effect_expr.copy_to_operands(decl_block); clean_code.clear(); - + // We merge the side-effect into the operand of the typecast, // using a comma-expression. // I.e., (type)e becomes (type)(side-effect, e) // It is not obvious whether the type or 'e' should be evaluated // first. - + exprt comma_expr(ID_comma, op.type()); comma_expr.copy_to_operands(side_effect_expr, op); op.swap(comma_expr); @@ -1195,7 +1195,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) { // This is a GCC extension. It's either a 'temporary union', // where the argument is one of the member types. - + // This is one of the few places where it's detectable // that we are using "bool" for boolean operators instead // of "int". We convert for this reason. @@ -1205,7 +1205,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) // we need to find a member with the right type const union_typet &union_type=to_union_type(expr_type); const union_typet::componentst &components=union_type.components(); - + for(union_typet::componentst::const_iterator it=components.begin(); it!=components.end(); @@ -1223,7 +1223,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) return; } } - + // not found, complain err_location(expr); error() << "type cast to union: type `" @@ -1238,7 +1238,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) { // just do a normal initialization do_initializer(op, expr.type(), false); - + // This produces a struct-expression, // union-expression, array-expression, // or an expression for a pointer or scalar. @@ -1249,19 +1249,19 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) expr.set(ID_C_lvalue, true); // these are l-values return; } - + // a cast to void is always fine if(expr_type.id()==ID_empty) return; const typet op_type=follow(op.type()); - + // cast to same type? if(base_type_eq(expr_type, op_type, *this)) return; // it's ok // vectors? - + if(expr_type.id()==ID_vector) { // we are generous -- any vector to vector is fine @@ -1271,7 +1271,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) op_type.id()==ID_unsignedbv) return; } - + if(!is_numeric_type(expr_type) && expr_type.id()!=ID_pointer) { err_location(expr); @@ -1305,7 +1305,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) { const vector_typet &op_vector_type= to_vector_type(op_type); - + // gcc allows conversion of a vector of size 1 to // an integer/float of the same size if((expr_type.id()==ID_signedbv || @@ -1336,9 +1336,9 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) // Note that gcc says "warning: target of assignment not really an lvalue; // this will be a hard error in the future", i.e., we // can hope that the code below will one day simply go away. - + // Current versions of gcc in fact refuse to do this! Yay! - + if(expr.op0().get_bool(ID_C_lvalue)) { if(expr_type.id()==ID_pointer) @@ -1406,7 +1406,7 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr) make_index_type(index_expr); const typet &final_array_type=follow(array_expr.type()); - + if(final_array_type.id()==ID_array || final_array_type.id()==ID_vector) { @@ -1689,7 +1689,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) typet type=op0.type(); follow_symbol(type); - + if(type.id()==ID_incomplete_struct) { err_location(expr); @@ -1715,7 +1715,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) << to_string(type) << "'" << eom; throw 0; } - + const struct_union_typet &struct_union_type= to_struct_union_type(type); @@ -1741,14 +1741,14 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) << to_string(type) << "'" << eom; throw 0; } - + // done! expr.swap(tmp); return; } expr.type()=component.type(); - + if(op0.get_bool(ID_C_lvalue)) expr.set(ID_C_lvalue, true); @@ -1858,15 +1858,15 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr) if(follow(operands[1].type())==follow(operands[2].type())) { expr.type()=operands[1].type(); - + // GCC says: "A conditional expression is a valid lvalue // if its type is not void and the true and false branches // are both valid lvalues." - + if(operands[1].get_bool(ID_C_lvalue) && operands[2].get_bool(ID_C_lvalue)) expr.set(ID_C_lvalue, true); - + return; } @@ -1942,19 +1942,19 @@ void c_typecheck_baset::typecheck_expr_address_of(exprt &expr) } exprt &op=expr.op0(); - + if(op.type().id()==ID_c_bit_field) { err_location(expr); error() << "cannot take address of a bit field" << eom; throw 0; } - + // special case: address of label if(op.id()==ID_label) { expr.type()=pointer_type(void_type()); - + // remember the label labels_used[op.get(ID_identifier)]=op.source_location(); return; @@ -2224,7 +2224,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call( // This is an undeclared function. Let's just add it. // We do a bit of return-type guessing, but just a bit. typet return_type=signed_int_type(); - + // The following isn't really right and sound, but there // are too many idiots out there who use malloc and the like // without the right header file. @@ -2292,11 +2292,11 @@ void c_typecheck_baset::typecheck_side_effect_function_call( } const code_typet &code_type=to_code_type(f_op.type()); - + expr.type()=code_type.return_type(); - + exprt tmp=do_special_functions(expr); - + if(tmp.is_not_nil()) expr.swap(tmp); else @@ -2324,7 +2324,7 @@ exprt c_typecheck_baset::do_special_functions( // some built-in functions if(f_op.id()!=ID_symbol) return nil_exprt(); - + const irep_idt &identifier=to_symbol_expr(f_op).get_identifier(); if(identifier==CPROVER_PREFIX "same_object") @@ -2494,14 +2494,14 @@ exprt c_typecheck_baset::do_special_functions( error() << identifier << " expects one operand" << eom; throw 0; } - + exprt bswap_expr(ID_bswap, expr.type()); bswap_expr.operands()=expr.arguments(); bswap_expr.add_source_location()=source_location; - + return bswap_expr; } - else if(identifier==CPROVER_PREFIX "isnanf" || + else if(identifier==CPROVER_PREFIX "isnanf" || identifier==CPROVER_PREFIX "isnand" || identifier==CPROVER_PREFIX "isnanld" || identifier=="__builtin_isnan") @@ -2516,7 +2516,7 @@ exprt c_typecheck_baset::do_special_functions( exprt isnan_expr(ID_isnan, bool_typet()); isnan_expr.operands()=expr.arguments(); isnan_expr.add_source_location()=source_location; - + return isnan_expr; } else if(identifier==CPROVER_PREFIX "isfinitef" || @@ -2633,7 +2633,7 @@ exprt c_typecheck_baset::do_special_functions( return isnormal_expr; } - else if(identifier==CPROVER_PREFIX "signf" || + else if(identifier==CPROVER_PREFIX "signf" || identifier==CPROVER_PREFIX "signd" || identifier==CPROVER_PREFIX "signld" || identifier=="__builtin_signbit" || @@ -2681,11 +2681,11 @@ exprt c_typecheck_baset::do_special_functions( error() << "equal expects two operands" << eom; throw 0; } - + equal_exprt equality_expr; equality_expr.operands()=expr.arguments(); equality_expr.add_source_location()=source_location; - + if(!base_type_eq(equality_expr.lhs().type(), equality_expr.rhs().type(), *this)) { @@ -2718,7 +2718,7 @@ exprt c_typecheck_baset::do_special_functions( // this is a gcc extension to provide information about // object sizes at compile time // http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html - + if(expr.arguments().size()!=2) { err_location(f_op); @@ -2727,9 +2727,9 @@ exprt c_typecheck_baset::do_special_functions( } make_constant(expr.arguments()[1]); - + mp_integer arg1; - + if(expr.arguments()[1].is_true()) arg1=1; else if(expr.arguments()[1].is_false()) @@ -2744,7 +2744,7 @@ exprt c_typecheck_baset::do_special_functions( exprt tmp; - // the followin means "don't know" + // the followin means "don't know" if(arg1==0 || arg1==1) { tmp=from_integer(-1, size_type()); @@ -2755,7 +2755,7 @@ exprt c_typecheck_baset::do_special_functions( tmp=from_integer(0, size_type()); tmp.add_source_location()=f_op.source_location(); } - + return tmp; } else if(identifier=="__builtin_choose_expr") @@ -2767,10 +2767,10 @@ exprt c_typecheck_baset::do_special_functions( error() << "__builtin_choose_expr expects three arguments" << eom; throw 0; } - + expr.arguments()[0].make_typecast(bool_typet()); make_constant(expr.arguments()[0]); - + if(expr.arguments()[0].is_true()) return expr.arguments()[1]; else @@ -2790,9 +2790,9 @@ exprt c_typecheck_baset::do_special_functions( // try to produce constant exprt tmp1=expr.arguments().front(); simplify(tmp1, *this); - + bool is_constant=false; - + // Need to do some special treatment for string literals, // which are (void *)&("lit"[0]) if(tmp1.id()==ID_typecast && @@ -2807,7 +2807,7 @@ exprt c_typecheck_baset::do_special_functions( } else is_constant=tmp1.is_constant(); - + exprt tmp2=from_integer(is_constant, expr.type()); tmp2.add_source_location()=source_location; @@ -2823,13 +2823,13 @@ exprt c_typecheck_baset::do_special_functions( error() << "__builtin_classify_type expects one argument" << eom; throw 0; } - + exprt object=expr.arguments()[0]; // The value doesn't matter at all, we only care about the type. // Need to sync with typeclass.h. const typet &type=follow(object.type()); - + unsigned type_number= type.id()==ID_empty?0: type.id()==ID_c_enum_tag?3: @@ -2841,10 +2841,10 @@ exprt c_typecheck_baset::do_special_functions( type.id()==ID_union?13: type.id()==ID_array?14: 1; // int, short - + // clang returns 15 for the three 'char' types, // gcc treats these as 'int' - + exprt tmp=from_integer(type_number, expr.type()); tmp.add_source_location()=source_location; @@ -2888,7 +2888,7 @@ exprt c_typecheck_baset::do_special_functions( { // These are polymorphic, see // http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html - + // adjust return type of function to match pointer subtype if(expr.arguments().size()<1) { @@ -2896,7 +2896,7 @@ exprt c_typecheck_baset::do_special_functions( error() << "__sync_* primitives take as least one argument" << eom; throw 0; } - + exprt &ptr_arg=expr.arguments().front(); if(ptr_arg.type().id()!=ID_pointer) @@ -2905,9 +2905,9 @@ exprt c_typecheck_baset::do_special_functions( error() << "__sync_* primitives take pointer as first argument" << eom; throw 0; } - + expr.type()=expr.arguments().front().type().subtype(); - + return expr; } else @@ -2934,7 +2934,7 @@ void c_typecheck_baset::typecheck_function_call_arguments( exprt::operandst &arguments=expr.arguments(); const code_typet::parameterst ¶meter_types= code_type.parameters(); - + // no. of arguments test if(code_type.get_bool(ID_C_incomplete)) @@ -2966,7 +2966,7 @@ void c_typecheck_baset::typecheck_function_call_arguments( << ", but got " << arguments.size() << eom; throw 0; } - + for(unsigned i=0; itype()=full_type.subtype(); @@ -119,7 +119,7 @@ exprt c_typecheck_baset::do_initializer_rec( << to_string(to_array_type(full_type).size()) << eom; throw 0; } - + if(array_size<0) { err_location(value); @@ -142,10 +142,10 @@ exprt c_typecheck_baset::do_initializer_rec( tmp.operands().resize(integer2size_t(array_size), zero); } } - + return tmp; } - + if(value.id()==ID_string_constant && full_type.id()==ID_array && (full_type.subtype().id()==ID_signedbv || @@ -153,7 +153,7 @@ exprt c_typecheck_baset::do_initializer_rec( full_type.subtype().get(ID_width)==char_type().get(ID_width)) { // will go away, to be replaced by the above block - + string_constantt tmp1=to_string_constant(value); // adjust char type tmp1.type().subtype()=full_type.subtype(); @@ -172,7 +172,7 @@ exprt c_typecheck_baset::do_initializer_rec( << to_string(to_array_type(full_type).size()) << eom; throw 0; } - + if(array_size<0) { err_location(value); @@ -195,10 +195,10 @@ exprt c_typecheck_baset::do_initializer_rec( tmp2.operands().resize(integer2size_t(array_size), zero); } } - + return tmp2; } - + if(full_type.id()==ID_array && to_array_type(full_type).size().is_nil()) { @@ -269,7 +269,7 @@ void c_typecheck_baset::do_initializer(symbolt &symbol) { typecheck_expr(symbol.value); do_initializer(symbol.value, symbol.type, true); - + // need to adjust size? if(follow(symbol.type).id()==ID_array && to_array_type(follow(symbol.type)).size().is_nil()) @@ -299,7 +299,7 @@ void c_typecheck_baset::designator_enter( entry.index=0; const typet &full_type=follow(type); - + if(full_type.id()==ID_struct) { const struct_typet &struct_type=to_struct_type(full_type); @@ -406,22 +406,22 @@ void c_typecheck_baset::do_designated_initializer( bool force_constant) { assert(!designator.empty()); - + if(value.id()==ID_designated_initializer) { assert(value.operands().size()==1); - designator= + designator= make_designator( designator.front().type, static_cast(value.find(ID_designator))); - + assert(!designator.empty()); - + return do_designated_initializer( result, designator, value.op0(), force_constant); } - + exprt *dest=&result; // first phase: follow given designator @@ -444,7 +444,7 @@ void c_typecheck_baset::do_designated_initializer( // we are willing to grow an incomplete or zero-sized array exprt zero=zero_initializer(full_type.subtype(), value.source_location(), *this, get_message_handler()); dest->operands().resize(integer2size_t(index)+1, zero); - + // todo: adjust type! } else @@ -512,10 +512,10 @@ void c_typecheck_baset::do_designated_initializer( else assert(false); } - + // second phase: assign value // for this, we may need to go down, adding to the designator - + while(true) { // see what type we have to initialize @@ -532,7 +532,7 @@ void c_typecheck_baset::do_designated_initializer( { // The initializer for a scalar shall be a single expression, // * optionally enclosed in braces. * - + if(value.id()==ID_initializer_list && value.operands().size()==1) *dest=do_initializer_rec(value.op0(), type, force_constant); @@ -540,10 +540,10 @@ void c_typecheck_baset::do_designated_initializer( *dest=do_initializer_rec(value, type, force_constant); assert(full_type==follow(dest->type())); - + return; // done } - + // union? The component in the zero initializer might // not be the first one. if(full_type.id()==ID_union) @@ -602,12 +602,12 @@ void c_typecheck_baset::do_designated_initializer( full_type.id()==ID_union || full_type.id()==ID_array || full_type.id()==ID_vector); - + // we are initializing a compound type, and enter it! // this may change the type, full_type might not be valid anymore const typet dest_type=full_type; designator_enter(type, designator); - + if(dest->operands().empty()) { err_location(value); @@ -645,7 +645,7 @@ void c_typecheck_baset::increment_designator(designatort &designator) const typet &full_type=follow(entry.type); entry.index++; - + if(full_type.id()==ID_array && to_array_type(full_type).size().is_nil()) return; // we will keep going forever @@ -659,7 +659,7 @@ void c_typecheck_baset::increment_designator(designatort &designator) const struct_typet::componentst &components= struct_type.components(); assert(components.size()==entry.size); - + // we skip over any padding or code while(entry.index(type.find(ID_size)); typecheck_expr(size_expr); - source_locationt source_location=size_expr.source_location(); + source_locationt source_location=size_expr.source_location(); make_constant_index(size_expr); mp_integer size_int; @@ -280,19 +280,19 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) error() << "bit vector width invalid" << eom; throw 0; } - + type.remove(ID_size); type.set(ID_width, integer2string(size_int)); // depending on type, there may be a number of fractional bits - + if(type.id()==ID_custom_unsignedbv) - type.id(ID_unsignedbv); + type.id(ID_unsignedbv); else if(type.id()==ID_custom_signedbv) - type.id(ID_signedbv); + type.id(ID_signedbv); else if(type.id()==ID_custom_fixedbv) { - type.id(ID_fixedbv); + type.id(ID_fixedbv); exprt f_expr= static_cast(type.find(ID_f)); @@ -300,7 +300,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) source_locationt source_location=f_expr.find_source_location(); typecheck_expr(f_expr); - + make_constant_index(f_expr); mp_integer f_int; @@ -317,21 +317,21 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) error() << "fixedbv fraction width invalid" << eom; throw 0; } - + type.remove(ID_f); type.set(ID_integer_bits, integer2string(size_int-f_int)); } else if(type.id()==ID_custom_floatbv) { - type.id(ID_floatbv); + type.id(ID_floatbv); exprt f_expr= static_cast(type.find(ID_f)); - + source_locationt source_location=f_expr.find_source_location(); typecheck_expr(f_expr); - + make_constant_index(f_expr); mp_integer f_int; @@ -348,7 +348,7 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) error() << "floatbv fraction width invalid" << eom; throw 0; } - + type.remove(ID_f); type.set(ID_f, integer2string(f_int)); } @@ -375,7 +375,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) type.remove_subtype(); code_typet::parameterst ¶meters=type.parameters(); - + // if we don't have any parameters, we assume it's (...) if(parameters.empty()) { @@ -389,9 +389,9 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) type.make_ellipsis(); type.parameters().pop_back(); } - + parameter_map.clear(); - + for(code_typet::parameterst::iterator p_it=type.parameters().begin(); p_it!=type.parameters().end(); @@ -401,7 +401,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) if(p_it->id()==ID_declaration) { ansi_c_declarationt &declaration=to_ansi_c_declaration(*p_it); - + code_typet::parametert parameter; // first fix type @@ -412,7 +412,7 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) typecheck_type(type); tmp_clean_code.swap(clean_code); adjust_function_parameter(type); - + // adjust the identifier irep_idt identifier=declaration.declarator().get_name(); @@ -429,14 +429,14 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) parameter.set_base_name(declaration.declarator().get_base_name()); parameter.add_source_location()=declaration.declarator().source_location(); } - + // put the parameter in place of the declaration p_it->swap(parameter); } } - + parameter_map.clear(); - + if(parameters.size()==1 && follow(parameters[0].type()).id()==ID_empty) { @@ -446,20 +446,20 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) } typecheck_type(type.return_type()); - + // 6.7.6.3: // "A function declarator shall not specify a return type that // is a function type or an array type." - + const typet &return_type=follow(type.return_type()); - + if(return_type.id()==ID_array) { error().source_location=type.source_location(); error() << "function must not return array" << eom; throw 0; } - + if(return_type.id()==ID_code) { error().source_location=type.source_location(); @@ -487,7 +487,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) // check subtype typecheck_type(type.subtype()); - + // we don't allow void as subtype if(follow(type.subtype()).id()==ID_empty) { @@ -497,19 +497,19 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) } // check size, if any - + if(size.is_not_nil()) { typecheck_expr(size); make_index_type(size); - + // The size need not be a constant! // We simplify it, for the benefit of array initialisation. - + exprt tmp_size=size; add_rounding_mode(tmp_size); simplify(tmp_size, *this); - + if(tmp_size.is_constant()) { mp_integer s; @@ -528,7 +528,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) "but got " << s << eom; throw 0; } - + size=tmp_size; } else if(tmp_size.id()==ID_infinity) @@ -549,15 +549,15 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) else { // not a constant and not infinity - + assert(current_symbol_id!=irep_idt()); - + const symbolt &base_symbol= lookup( //base_symbol_identifier!=irep_idt()? //base_symbol_identifier: current_symbol_id); - + // Need to pull out! We insert new symbol. source_locationt source_location=size.find_source_location(); unsigned count=0; @@ -583,14 +583,14 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) new_symbol.is_static_lifetime=false; new_symbol.value.make_nil(); new_symbol.location=source_location; - + symbol_table.add(new_symbol); // produce the code that declares and initializes the symbol symbol_exprt symbol_expr; symbol_expr.set_identifier(temp_identifier); symbol_expr.type()=new_symbol.type; - + code_declt declaration(symbol_expr); declaration.add_source_location()=source_location; @@ -627,7 +627,7 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) source_locationt source_location=size.find_source_location(); typecheck_expr(size); - + typet &subtype=type.subtype(); typecheck_type(subtype); @@ -663,14 +663,14 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) "but got " << s << eom; throw 0; } - + // the subtype must have constant size exprt size_expr=c_sizeof(type.subtype(), *this); simplify(size_expr, *this); mp_integer sub_size; - + if(to_integer(size_expr, sub_size)) { error().source_location=source_location; @@ -686,7 +686,7 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) << to_string(type.subtype()) << "'" << eom; throw 0; } - + // adjust by width of base type if(s%sub_size!=0) { @@ -696,7 +696,7 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) << ")" << eom; throw 0; } - + s/=sub_size; type.size()=from_integer(s, signed_size_type()); @@ -718,9 +718,9 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) { // These get replaced by symbol types later. irep_idt identifier; - + bool have_body=type.find(ID_components).is_not_nil(); - + if(type.find(ID_tag).is_nil()) { // Anonymous? Must come with body. @@ -738,7 +738,7 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) compound_symbol.base_name="#anon-"+typestr; compound_symbol.name="tag-#anon#"+typestr; identifier=compound_symbol.name; - + // We might already have the same anonymous union/struct, // and this is simply ok. Note that the C standard treats // these as different types. @@ -751,7 +751,7 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) else { identifier=type.find(ID_tag).get(ID_identifier); - + // does it exist already? symbol_tablet::symbolst::iterator s_it= symbol_table.symbols.find(identifier); @@ -852,10 +852,10 @@ void c_typecheck_baset::typecheck_compound_body( { // the arguments are member declarations or static assertions assert(it->id()==ID_declaration); - + ansi_c_declarationt &declaration= to_ansi_c_declaration(static_cast(*it)); - + if(declaration.get_is_static_assert()) { struct_union_typet::componentt new_component; @@ -870,7 +870,7 @@ void c_typecheck_baset::typecheck_compound_body( // do first half of type typecheck_type(declaration.type()); make_already_typechecked(declaration.type()); - + for(ansi_c_declarationt::declaratorst::iterator d_it=declaration.declarators().begin(); d_it!=declaration.declarators().end(); @@ -929,7 +929,7 @@ void c_typecheck_baset::typecheck_compound_body( } } } - + // We allow an incomplete (C99) array as _last_ member! // Zero-length is allowed everywhere. @@ -942,7 +942,7 @@ void c_typecheck_baset::typecheck_compound_body( it++) { typet &c_type=it->type(); - + if(c_type.id()==ID_array && to_array_type(c_type).is_incomplete()) { @@ -953,12 +953,12 @@ void c_typecheck_baset::typecheck_compound_body( error() << "flexible struct member must be last member" << eom; throw 0; } - + // make it zero-length c_type.id(ID_array); c_type.set(ID_size, gen_zero(index_type())); } - } + } } // We may add some minimal padding inside and at @@ -998,7 +998,7 @@ void c_typecheck_baset::typecheck_compound_body( typecheck_expr(it->op1()); assertion.make_typecast(bool_typet()); make_constant(assertion); - + if(assertion.is_false()) { error().source_location=it->source_location(); @@ -1009,12 +1009,12 @@ void c_typecheck_baset::typecheck_compound_body( { // should warn/complain } - + it=components.erase(it); } else it++; - } + } } /*******************************************************************\ @@ -1098,7 +1098,7 @@ typet c_typecheck_baset::enum_underlying_type( min_value>=-(mp_integer(1)<<(config.ansi_c.short_int_width-1))) return signed_short_int_type(); } - + if(max_value<(mp_integer(1)<<(config.ansi_c.int_width-1)) && min_value>=-(mp_integer(1)<<(config.ansi_c.int_width-1))) return signed_int_type(); @@ -1111,7 +1111,7 @@ typet c_typecheck_baset::enum_underlying_type( else { // We'll want an unsigned type. - + if(is_packed) { // If packed, there are smaller options. @@ -1120,7 +1120,7 @@ typet c_typecheck_baset::enum_underlying_type( else if(max_value<(mp_integer(1)<(static_cast(type)); source_locationt source_location=type.source_location(); // We allow empty enums in the grammar to get better - // error messages. + // error messages. if(as_expr.operands().empty()) { error().source_location=source_location; error() << "empty enum" << eom; throw 0; } - + // enums start at zero; // we also track min and max to find a nice base type mp_integer value=0, min_value=0, max_value=0; std::list enum_members; - + // We need to determine a width, and a signedness // to obtain an 'underlying type'. // We just do int, but gcc might pick smaller widths @@ -1203,19 +1203,19 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) typet constant_type= enum_constant_type(min_value, max_value); - + v=from_integer(value, constant_type); - declaration.type()=constant_type; + declaration.type()=constant_type; typecheck_declaration(declaration); irep_idt base_name= declaration.declarator().get_base_name(); - + irep_idt identifier= declaration.declarator().get_name(); - - // store + + // store c_enum_typet::c_enum_membert member; member.set_identifier(identifier); member.set_base_name(base_name); @@ -1248,7 +1248,7 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) anon_identifier+='='; anon_identifier+=id2string(it->get_value()); } - + if(is_packed) anon_identifier+="#packed"; @@ -1268,10 +1268,10 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) enum_tag_symbol.is_file_local=true; enum_tag_symbol.base_name=base_name; enum_tag_symbol.name=identifier; - + // throw in the enum members as 'body' irept::subt &body=enum_tag_symbol.type.add(ID_body).get_sub(); - + for(std::list::const_iterator it=enum_members.begin(); it!=enum_members.end(); @@ -1287,12 +1287,12 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) // is it in the symbol table already? symbol_tablet::symbolst::iterator s_it= symbol_table.symbols.find(identifier); - + if(s_it!=symbol_table.symbols.end()) { // Yes. symbolt &symbol=s_it->second; - + if(symbol.type.id()==ID_incomplete_c_enum) { // Ok, overwrite the type in the symbol table. @@ -1352,22 +1352,22 @@ void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) error() << "anonymous enum tag without members" << eom; throw 0; } - + source_locationt source_location=type.source_location(); - + irept &tag=type.add(ID_tag); irep_idt base_name=tag.get(ID_C_base_name); irep_idt identifier=tag.get(ID_identifier); - - // is it in the symbol table? + + // is it in the symbol table? symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(identifier); - + if(s_it!=symbol_table.symbols.end()) { // Yes. const symbolt &symbol=s_it->second; - + if(symbol.type.id()!=ID_c_enum && symbol.type.id()!=ID_incomplete_c_enum) { @@ -1384,18 +1384,18 @@ void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) new_type.add(ID_tag)=tag; symbolt enum_tag_symbol; - + enum_tag_symbol.is_type=true; enum_tag_symbol.type=new_type; enum_tag_symbol.location=source_location; enum_tag_symbol.is_file_local=true; enum_tag_symbol.base_name=base_name; enum_tag_symbol.name=identifier; - + symbolt *new_symbol; move_symbol(enum_tag_symbol, new_symbol); } - + // Clean up resulting type type.remove(ID_tag); type.set_identifier(identifier); @@ -1435,16 +1435,16 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) if(i<0) { error().source_location=type.source_location(); - error() << "bit field width is negative" << eom; + error() << "bit field width is negative" << eom; throw 0; } - + type.set_width(integer2size_t(i)); type.remove(ID_size); } - + const typet &subtype=follow(type.subtype()); - + std::size_t sub_width=0; if(subtype.id()==ID_bool) @@ -1472,7 +1472,7 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) error() << "bit field has incomplete enum type" << eom; throw 0; } - + sub_width=c_enum_type.subtype().get_int(ID_width); } else @@ -1537,7 +1537,7 @@ void c_typecheck_baset::typecheck_typeof_type(typet &type) type.swap(expr.type()); } - + type.add_source_location()=source_location; c_qualifiers.write(type); } @@ -1578,7 +1578,7 @@ void c_typecheck_baset::typecheck_symbol_type(typet &type) error() << "expected type symbol" << eom; throw 0; } - + if(symbol.is_macro) { // overwrite, but preserve (add) any qualifiers and other flags @@ -1586,15 +1586,15 @@ void c_typecheck_baset::typecheck_symbol_type(typet &type) c_qualifierst c_qualifiers(type); bool is_packed=type.get_bool(ID_C_packed); irept alignment=type.find(ID_C_alignment); - + c_qualifiers+=c_qualifierst(symbol.type); type=symbol.type; c_qualifiers.write(type); - + if(is_packed) type.set(ID_C_packed, true); if(alignment.is_not_nil()) type.set(ID_C_alignment, alignment); } - + // CPROVER extensions if(symbol.base_name=="__CPROVER_rational") { @@ -1640,4 +1640,3 @@ void c_typecheck_baset::adjust_function_parameter(typet &type) const type=signed_int_type(); // the default is integer! } } - diff --git a/src/ansi-c/c_typecheck_typecast.cpp b/src/ansi-c/c_typecheck_typecast.cpp index 6d89d7487e4..5d1cfad1332 100644 --- a/src/ansi-c/c_typecheck_typecast.cpp +++ b/src/ansi-c/c_typecheck_typecast.cpp @@ -27,9 +27,9 @@ void c_typecheck_baset::implicit_typecast( const typet &dest_type) { c_typecastt c_typecast(*this); - + typet src_type=expr.type(); - + c_typecast.implicit_typecast(expr, dest_type); for(std::list::const_iterator @@ -44,10 +44,10 @@ void c_typecheck_baset::implicit_typecast( << to_string(dest_type) << "': " << *it << eom; } - + if(!c_typecast.errors.empty()) throw 0; // give up - + for(std::list::const_iterator it=c_typecast.warnings.begin(); it!=c_typecast.warnings.end(); diff --git a/src/ansi-c/c_types.cpp b/src/ansi-c/c_types.cpp index 8542ffedead..1c4794e9a2c 100644 --- a/src/ansi-c/c_types.cpp +++ b/src/ansi-c/c_types.cpp @@ -62,7 +62,7 @@ Function: signed_int_type typet signed_int_type() { - typet result=signedbv_typet(config.ansi_c.int_width); + typet result=signedbv_typet(config.ansi_c.int_width); result.set(ID_C_c_type, ID_signed_int); return result; } @@ -100,7 +100,7 @@ Function: unsigned_int_type typet unsigned_int_type() { - typet result=unsignedbv_typet(config.ansi_c.int_width); + typet result=unsignedbv_typet(config.ansi_c.int_width); result.set(ID_C_c_type, ID_unsigned_int); return result; } @@ -119,7 +119,7 @@ Function: unsigned_short_int_type typet unsigned_short_int_type() { - typet result=unsignedbv_typet(config.ansi_c.short_int_width); + typet result=unsignedbv_typet(config.ansi_c.short_int_width); result.set(ID_C_c_type, ID_unsigned_short_int); return result; } @@ -222,7 +222,7 @@ Function: unsigned_long_int_type typet unsigned_long_int_type() { - typet result=unsignedbv_typet(config.ansi_c.long_int_width); + typet result=unsignedbv_typet(config.ansi_c.long_int_width); result.set(ID_C_c_type, ID_unsigned_long_int); return result; } @@ -289,9 +289,9 @@ typet char_type() // There are 3 char types, i.e., this one is // different from either signed char or unsigned char! - + result.set(ID_C_c_type, ID_char); - + return result; } @@ -312,7 +312,7 @@ typet unsigned_char_type() typet result=unsignedbv_typet(config.ansi_c.char_width); result.set(ID_C_c_type, ID_unsigned_char); - + return result; } @@ -333,7 +333,7 @@ typet signed_char_type() typet result=signedbv_typet(config.ansi_c.char_width); result.set(ID_C_c_type, ID_signed_char); - + return result; } @@ -352,7 +352,7 @@ Function: wchar_t_type typet wchar_t_type() { typet result; - + if(config.ansi_c.wchar_t_is_unsigned) result=unsignedbv_typet(config.ansi_c.wchar_t_width); else @@ -404,7 +404,7 @@ Function: char32_t_type typet char32_t_type() { typet result; - + // Types char16_t and char32_t denote distinct types with the same size, // signedness, and alignment as uint_least16_t and uint_least32_t, // respectively, in , called the underlying types. @@ -430,7 +430,7 @@ Function: float_type typet float_type() { typet result; - + if(config.ansi_c.use_fixed_for_float) { fixedbv_typet tmp; @@ -461,7 +461,7 @@ Function: double_type typet double_type() { typet result; - + if(config.ansi_c.use_fixed_for_float) { fixedbv_typet tmp; @@ -471,7 +471,7 @@ typet double_type() } else result=ieee_float_spect::double_precision().to_type(); - + result.set(ID_C_c_type, ID_double); return result; @@ -492,7 +492,7 @@ Function: long_double_type typet long_double_type() { typet result; - + if(config.ansi_c.use_fixed_for_float) { fixedbv_typet tmp; @@ -521,7 +521,7 @@ typet long_double_type() else assert(false); } - + result.set(ID_C_c_type, ID_long_double); return result; @@ -542,7 +542,7 @@ Function: gcc_float128_type typet gcc_float128_type() { typet result; - + if(config.ansi_c.use_fixed_for_float) { fixedbv_typet tmp; @@ -555,7 +555,7 @@ typet gcc_float128_type() result=ieee_float_spect::quadruple_precision().to_type(); } - // not same as long double! + // not same as long double! result.set(ID_C_c_type, ID_gcc_float128); return result; diff --git a/src/ansi-c/clang_builtin_headers.h b/src/ansi-c/clang_builtin_headers.h index 1b9dc551318..9d266dda42e 100644 --- a/src/ansi-c/clang_builtin_headers.h +++ b/src/ansi-c/clang_builtin_headers.h @@ -1,4 +1,3 @@ typedef float __gcc_v4sf __attribute__ ((__vector_size__ (16))); __gcc_v4sf __builtin_shufflevector(__gcc_v4sf, __gcc_v4sf, ...); - diff --git a/src/ansi-c/cprover_library.cpp b/src/ansi-c/cprover_library.cpp index 4f1295f0f95..bc05e0eb749 100644 --- a/src/ansi-c/cprover_library.cpp +++ b/src/ansi-c/cprover_library.cpp @@ -67,7 +67,7 @@ std::string get_cprover_library_text( } } } - + if(count==0) return std::string(); else @@ -93,11 +93,11 @@ void add_cprover_library( { if(config.ansi_c.lib==configt::ansi_ct::libt::LIB_NONE) return; - + std::string library_text; library_text=get_cprover_library_text(functions, symbol_table); - + add_library(library_text, symbol_table, message_handler); } @@ -125,6 +125,6 @@ void add_library( ansi_c_languaget ansi_c_language; ansi_c_language.set_message_handler(message_handler); ansi_c_language.parse(in, ""); - + ansi_c_language.typecheck(symbol_table, ""); } diff --git a/src/ansi-c/designator.h b/src/ansi-c/designator.h index c84d64c27b9..a340c57ff7c 100644 --- a/src/ansi-c/designator.h +++ b/src/ansi-c/designator.h @@ -22,13 +22,13 @@ class designatort size_t index; size_t size; typet type, subtype; - + entryt():index(0), size(0) { } }; - bool empty() const { return index_list.empty(); } + bool empty() const { return index_list.empty(); } size_t size() const { return index_list.size(); } const entryt &operator[](size_t i) const { return index_list[i]; } entryt &operator[](size_t i) { return index_list[i]; } @@ -41,7 +41,7 @@ class designatort { index_list.push_back(entry); } - + void pop_entry() { index_list.pop_back(); diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index db81fa137f5..78ced9c86a3 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -226,7 +226,7 @@ std::string expr2ct::convert_rec( new_qualifiers.read(src); std::string q=new_qualifiers.as_string(); - + std::string d= declarator==""?declarator:" "+declarator; @@ -312,7 +312,7 @@ std::string expr2ct::convert_rec( } else if(c_type!=ID_wchar_t && !c_type_str.empty()) return q+c_type_str+d; - + // There is also wchar_t among the above, but this isn't a C type. mp_integer width=string2integer(src.get_string(ID_width)); @@ -359,13 +359,13 @@ std::string expr2ct::convert_rec( else if(src.id()==ID_struct) { const struct_typet &struct_type=to_struct_type(src); - + std::string dest=q+"struct"; const irep_idt &tag=struct_type.get_tag(); if(tag!="") dest+=" "+id2string(tag); dest+=" {"; - + for(struct_typet::componentst::const_iterator it=struct_type.components().begin(); it!=struct_type.components().end(); @@ -375,11 +375,11 @@ std::string expr2ct::convert_rec( dest+=convert_rec(it->type(), c_qualifierst(), id2string(it->get_name())); dest+=';'; } - + dest+=" }"; - + dest+=d; - + return dest; } else if(src.id()==ID_incomplete_struct) @@ -389,19 +389,19 @@ std::string expr2ct::convert_rec( const std::string &tag=src.get_string(ID_tag); if(tag!="") dest+=" "+tag; dest+=d; - + return dest; } else if(src.id()==ID_union) { const union_typet &union_type=to_union_type(src); - + std::string dest=q+"union"; const irep_idt &tag=union_type.get_tag(); if(tag!="") dest+=" "+id2string(tag); dest+=" {"; - + for(union_typet::componentst::const_iterator it=union_type.components().begin(); it!=union_type.components().end(); @@ -411,11 +411,11 @@ std::string expr2ct::convert_rec( dest+=convert_rec(it->type(), c_qualifierst(), id2string(it->get_name())); dest+=';'; } - + dest+=" }"; - + dest+=d; - + return dest; } else if(src.id()==ID_incomplete_union) @@ -436,7 +436,7 @@ std::string expr2ct::convert_rec( // do we have a tag? const irept &tag=src.find(ID_tag); - + if(tag.is_nil()) { } @@ -445,13 +445,13 @@ std::string expr2ct::convert_rec( result+=' '; result+=tag.get_string(ID_C_base_name); } - + result+=' '; result+='{'; - + // add members const c_enum_typet::memberst &members=to_c_enum_type(src).members(); - + for(c_enum_typet::memberst::const_iterator it=members.begin(); it!=members.end(); @@ -472,7 +472,7 @@ std::string expr2ct::convert_rec( else if(src.id()==ID_incomplete_c_enum) { const irept &tag=src.find(ID_tag); - + if(tag.is_not_nil()) { std::string result=q+"enum"; @@ -495,14 +495,14 @@ std::string expr2ct::convert_rec( c_qualifierst sub_qualifiers; sub_qualifiers.read(src.subtype()); const typet &subtype_followed=ns.follow(src.subtype()); - + // The star gets attached to the declarator. std::string new_declarator="*"; if(q!="" && (!declarator.empty() || subtype_followed.id()==ID_pointer)) new_declarator+=" "+q; - + new_declarator+=declarator; // Depending on precedences, we may add parentheses. @@ -511,19 +511,19 @@ std::string expr2ct::convert_rec( (subtype_followed.id()==ID_array || subtype_followed.id()==ID_incomplete_array))) new_declarator="("+new_declarator+")"; - + return convert_rec(src.subtype(), sub_qualifiers, new_declarator); } else if(src.id()==ID_array) { // The [...] gets attached to the declarator. std::string array_suffix; - + if(to_array_type(src).size().is_nil()) array_suffix="[]"; else array_suffix="["+convert(to_array_type(src).size())+"]"; - + // This won't really parse without declarator. // Note that qualifiers are passed down. return convert_rec( @@ -539,7 +539,7 @@ std::string expr2ct::convert_rec( else if(src.id()==ID_symbol) { const typet &followed=ns.follow(src); - + if(followed.id()==ID_struct) { std::string dest=q+"struct"; @@ -586,13 +586,13 @@ std::string expr2ct::convert_rec( else if(src.id()==ID_code) { const code_typet &code_type=to_code_type(src); - + // C doesn't really have syntax for function types, // i.e., the following won't parse without declarator std::string dest=declarator+"("; const code_typet::parameterst ¶meters=code_type.parameters(); - + if(parameters.empty()) { if(code_type.has_ellipsis()) @@ -654,7 +654,7 @@ std::string expr2ct::convert_rec( else if(src.id()==ID_vector) { const vector_typet &vector_type=to_vector_type(src); - + mp_integer size_int; to_integer(vector_type.size(), size_int); @@ -728,11 +728,11 @@ std::string expr2ct::convert_typecast( const typet &to_type=ns.follow(src.type()); const typet &from_type=ns.follow(src.op().type()); - + if(to_type.id()==ID_c_bool && from_type.id()==ID_bool) return convert(src.op(), precedence); - + if(to_type.id()==ID_bool && from_type.id()==ID_c_bool) return convert(src.op(), precedence); @@ -832,7 +832,7 @@ std::string expr2ct::convert_quantifier( std::string op1=convert(src.op1(), p1); std::string dest=symbol+" { "; - dest+=convert(src.op0().type()); + dest+=convert(src.op0().type()); dest+=" "+op0+"; "; dest+=op1; dest+=" }"; @@ -889,16 +889,16 @@ std::string expr2ct::convert_with( const struct_union_typet::componentt &comp_expr= struct_union_type.get_component(component_name); - + assert(comp_expr.is_not_nil()); - + irep_idt display_component_name; - + if(comp_expr.get_pretty_name().empty()) display_component_name=component_name; else display_component_name=comp_expr.get_pretty_name(); - + op1="."+id2string(display_component_name); p1=10; } @@ -943,21 +943,21 @@ std::string expr2ct::convert_update( std::string op0, op1, op2; unsigned p0, p2; - + op0=convert(src.op0(), p0); op2=convert(src.op2(), p2); if(precedence>p0) dest+='('; dest+=op0; if(precedence>p0) dest+=')'; - + dest+=", "; - + const exprt &designator=src.op1(); forall_operands(it, designator) dest+=convert(*it); - + dest+=", "; if(precedence>p2) dest+='('; @@ -1051,19 +1051,19 @@ std::string expr2ct::convert_binary( unsigned p; std::string op=convert(*it, p); - + // In pointer arithmetic, x+(y-z) is unfortunately // not the same as (x+y)-z, even though + and - // have the same precedence. We thus add parentheses // for the case x+(y-z). Similarly, (x*y)/z is not // the same as x*(y/z), but * and / have the same // precedence. - + bool use_parentheses= - precedence>p || + precedence>p || (precedence==p && full_parentheses) || (precedence==p && src.id()!=it->id()); - + if(use_parentheses) dest+='('; dest+=op; if(use_parentheses) dest+=')'; @@ -1170,7 +1170,7 @@ std::string expr2ct::convert_malloc( dest+=convert(src.type().subtype()); dest+=", "; } - + dest+=op0; dest+=')'; @@ -1385,12 +1385,12 @@ std::string expr2ct::convert_complex( // double complex CMPLX(double x, double y); // float complex CMPLXF(float x, float y); // long double complex CMPLXL(long double x, long double y); - + const typet &subtype= ns.follow(ns.follow(src.type()).subtype()); std::string name; - + if(subtype==double_type()) name="CMPLX"; else if(subtype==float_type()) @@ -1602,22 +1602,22 @@ std::string expr2ct::convert_pointer_arithmetic( { if(src.operands().size()!=2) return convert_norep(src, precedence); - + std::string dest="POINTER_ARITHMETIC("; unsigned p; std::string op; - + op=convert(src.op0().type()); dest+=op; - + dest+=", "; op=convert(src.op0(), p); if(precedence>p) dest+='('; dest+=op; if(precedence>p) dest+=')'; - + dest+=", "; op=convert(src.op1(), p); @@ -1647,22 +1647,22 @@ std::string expr2ct::convert_pointer_difference( { if(src.operands().size()!=2) return convert_norep(src, precedence); - + std::string dest="POINTER_DIFFERENCE("; unsigned p; std::string op; - + op=convert(src.op0().type()); dest+=op; - + dest+=", "; op=convert(src.op0(), p); if(precedence>p) dest+='('; dest+=op; if(precedence>p) dest+=')'; - + dest+=", "; op=convert(src.op1(), p); @@ -1693,7 +1693,7 @@ std::string expr2ct::convert_member_designator(const exprt &src) if(!src.operands().empty()) return convert_norep(src, precedence); - + return "."+src.get_string(ID_component_name); } @@ -1715,7 +1715,7 @@ std::string expr2ct::convert_index_designator(const exprt &src) if(src.operands().size()!=1) return convert_norep(src, precedence); - + return "["+convert(src.op0())+"]"; } @@ -1773,7 +1773,7 @@ std::string expr2ct::convert_member( to_struct_union_type(full_type); irep_idt component_name=src.get_component_name(); - + if(component_name!="") { const exprt comp_expr= @@ -1781,23 +1781,23 @@ std::string expr2ct::convert_member( if(comp_expr.is_nil()) return convert_norep(src, precedence); - + if(!comp_expr.get(ID_pretty_name).empty()) dest+=comp_expr.get_string(ID_pretty_name); else dest+=id2string(component_name); return dest; - } + } std::size_t n=src.get_component_number(); - + if(n>=struct_union_type.components().size()) return convert_norep(src, precedence); const exprt comp_expr= struct_union_type.components()[n]; - + dest+=comp_expr.get_string(ID_pretty_name); return dest; @@ -2067,7 +2067,7 @@ std::string expr2ct::convert_object_descriptor( result+=", "; result+=convert(src.op1()); result+=", "; - + if(src.type().is_nil()) result+='?'; else @@ -2119,12 +2119,12 @@ std::string expr2ct::convert_constant( mp_integer int_value=binary2integer(id2string(value), is_signed); mp_integer i=0; - + irep_idt int_value_string=integer2string(int_value); const c_enum_typet::memberst &members= to_c_enum_type(c_enum_type).members(); - + for(c_enum_typet::memberst::const_iterator it=members.begin(); it!=members.end(); @@ -2159,7 +2159,7 @@ std::string expr2ct::convert_constant( { mp_integer int_value= binary2integer(id2string(value), type.id()==ID_signedbv); - + const irep_idt &c_type= type.id()==ID_c_bit_field?type.subtype().get(ID_C_c_type): type.get(ID_C_c_type); @@ -2203,7 +2203,7 @@ std::string expr2ct::convert_constant( dest="0b"+integer2string(int_value, 2); else dest=integer2string(int_value); - + if(c_type==ID_unsigned_int) dest+='u'; else if(c_type==ID_unsigned_long_int) @@ -2276,7 +2276,7 @@ std::string expr2ct::convert_constant( else if(type.id()==ID_pointer) { const irep_idt &value=to_constant_expr(src).get_value(); - + if(value==ID_NULL) { dest="NULL"; @@ -2297,9 +2297,9 @@ std::string expr2ct::convert_constant( return convert_norep(src, precedence); if(src.op0().id()==ID_constant) - { + { const irep_idt &op_value=src.op0().get(ID_value); - + if(op_value=="INVALID" || has_prefix(id2string(op_value), "INVALID-") || op_value=="NULL+offset") @@ -2341,7 +2341,7 @@ std::string expr2ct::convert_struct( if(full_type.id()!=ID_struct) return convert_norep(src, precedence); - + const struct_typet &struct_type= to_struct_type(full_type); @@ -2514,36 +2514,36 @@ std::string expr2ct::convert_array( // we treat arrays of characters as string constants, // and arrays of wchar_t as wide strings - + const typet &subtype=ns.follow(ns.follow(src.type()).subtype()); - + bool all_constant=true; - + forall_operands(it, src) if(!it->is_constant()) all_constant=false; - + if(src.get_bool(ID_C_string_constant) && all_constant && (subtype==char_type() || subtype==wchar_t_type())) { bool wide=subtype==wchar_t_type(); - + if(wide) dest+='L'; dest+="\""; - + dest.reserve(dest.size()+1+src.operands().size()); - + bool last_was_hex=false; - + forall_operands(it, src) { // these have a trailing zero if(it==--src.operands().end()) break; - + assert(it->is_constant()); mp_integer i; to_integer(*it, i); @@ -2554,10 +2554,10 @@ std::string expr2ct::convert_array( // we use "string splicing" to avoid ambiguity if(isxdigit(ch)) dest+="\" \""; - + last_was_hex=false; } - + switch(ch) { case '\n': dest+="\\n"; break; /* NL (0x0a) */ @@ -2569,7 +2569,7 @@ std::string expr2ct::convert_array( case '\a': dest+="\\a"; break; /* BEL (0x07) */ case '\\': dest+="\\\\"; break; case '"': dest+="\\\""; break; - + default: if(ch>=' ' && ch!=127 && ch<0xff) dest+=(char)ch; @@ -2584,7 +2584,7 @@ std::string expr2ct::convert_array( } dest+="\""; - + return dest; } @@ -2826,7 +2826,7 @@ std::string expr2ct::convert_overflow( std::string dest="overflow(\""; dest+=src.id().c_str()+9; dest+="\""; - + if(!src.operands().empty()) { dest+=", "; @@ -3079,7 +3079,7 @@ std::string expr2ct::convert_code_ifthenelse( to_code(src.else_case()), to_code(src.else_case()).get_statement()==ID_block ? indent : indent+2); } - + return dest; } @@ -3264,7 +3264,7 @@ std::string expr2ct::convert_code_decl( unsigned precedence; return convert_norep(src, precedence); } - + std::string declarator=convert(src.op0()); std::string dest=indent_str(indent); @@ -3315,7 +3315,7 @@ std::string expr2ct::convert_code_dead( unsigned precedence; return convert_norep(src, precedence); } - + return "dead "+convert(src.op0())+";"; } @@ -3827,14 +3827,14 @@ std::string expr2ct::convert_code_fence( unsigned indent) { std::string dest=indent_str(indent)+"FENCE("; - + irep_idt att[]= { ID_WRfence, ID_RRfence, ID_RWfence, ID_WWfence, ID_RRcumul, ID_RWcumul, ID_WWcumul, ID_WRcumul, irep_idt() }; bool first=true; - + for(unsigned i=0; !att[i].empty(); i++) { if(src.get_bool(att[i])) @@ -3847,7 +3847,7 @@ std::string expr2ct::convert_code_fence( dest+=id2string(att[i]); } } - + dest+=");"; return dest; } @@ -4052,7 +4052,7 @@ std::string expr2ct::convert_code_label( std::string labels_string; irep_idt label=src.get_label(); - + labels_string+="\n"; labels_string+=indent_str(indent); labels_string+=clean_identifier(label); @@ -4377,7 +4377,7 @@ std::string expr2ct::convert( { return id2string(src.id()); } - + else if(src.id()==ID_infinity) return convert_function(src, "INFINITY", precedence=16); @@ -4509,7 +4509,7 @@ std::string expr2ct::convert( else if(src.id()==ID_function_application) return convert_function_application(to_function_application_expr(src), precedence); - + else if(src.id()==ID_side_effect) { const irep_idt &statement=src.get(ID_statement); @@ -4565,7 +4565,7 @@ std::string expr2ct::convert( else if(src.id()==ID_literal) return convert_literal(src, precedence=16); - + else if(src.id()==ID_not) return convert_unary(src, "!", precedence=15); @@ -4759,7 +4759,7 @@ std::string expr2ct::convert( else if(src.id()==ID_sizeof) return convert_sizeof(src, precedence); - + else if(src.id()==ID_type) return convert(src.type()); diff --git a/src/ansi-c/expr2c_class.h b/src/ansi-c/expr2c_class.h index c501b720ffb..2f38aae71cc 100644 --- a/src/ansi-c/expr2c_class.h +++ b/src/ansi-c/expr2c_class.h @@ -133,7 +133,7 @@ class expr2ct unsigned precedence); std::string convert_complex( - const exprt &src, + const exprt &src, unsigned precedence); std::string convert_comma( diff --git a/src/ansi-c/file_converter.cpp b/src/ansi-c/file_converter.cpp index e911a200c56..ebb7867af18 100644 --- a/src/ansi-c/file_converter.cpp +++ b/src/ansi-c/file_converter.cpp @@ -8,7 +8,7 @@ int main() while(getline(std::cin, line)) { std::cout << "\""; - + for(std::size_t i=0; i='a' && c<='z')?c-('a'-'A'):c; } - diff --git a/src/ansi-c/library/errno.c b/src/ansi-c/library/errno.c index 6fa711ec5cf..7c5a9bcbce0 100644 --- a/src/ansi-c/library/errno.c +++ b/src/ansi-c/library/errno.c @@ -44,4 +44,3 @@ extern int *__errno(void) { return &__CPROVER_errno; } - diff --git a/src/ansi-c/library/float.c b/src/ansi-c/library/float.c index a182008641e..ef82057ab44 100644 --- a/src/ansi-c/library/float.c +++ b/src/ansi-c/library/float.c @@ -5,7 +5,7 @@ __CPROVER_thread_local unsigned __CPROVER_fpu_control_word; -unsigned int _controlfp( +unsigned int _controlfp( unsigned int new_value, unsigned int mask) { @@ -14,7 +14,7 @@ unsigned int _controlfp( if((mask&_MCW_RC)!=0) __CPROVER_rounding_mode=(new_value&_MCW_RC)>>8; - + return __CPROVER_fpu_control_word; } diff --git a/src/ansi-c/library/inet.c b/src/ansi-c/library/inet.c index 58748d1cf17..0d24a393620 100644 --- a/src/ansi-c/library/inet.c +++ b/src/ansi-c/library/inet.c @@ -42,4 +42,3 @@ in_addr_t inet_network(const char *cp) in_addr_t result; return result; } - diff --git a/src/ansi-c/library/intrin.c b/src/ansi-c/library/intrin.c index 9a5f237a5ac..34de9f548ee 100644 --- a/src/ansi-c/library/intrin.c +++ b/src/ansi-c/library/intrin.c @@ -6,7 +6,7 @@ inline long _InterlockedDecrement(long volatile *p) { __CPROVER_HIDE:; // This function generates a full memory barrier (or fence) to ensure that - // memory operations are completed in order. + // memory operations are completed in order. __CPROVER_atomic_begin(); long result=--(*p); __CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence"); @@ -342,4 +342,3 @@ inline char _InterlockedCompareExchange8(char volatile *p, char v1, char v2) __CPROVER_atomic_end(); return old; } - diff --git a/src/ansi-c/library/math.c b/src/ansi-c/library/math.c index 48bd24e8d53..7312708fb8c 100644 --- a/src/ansi-c/library/math.c +++ b/src/ansi-c/library/math.c @@ -636,7 +636,7 @@ float sqrtf(float f) float upperSquare = upper * upper; // Might be +Inf // Restrict these to bound f and thus compute the possible - // values for the square root. Note that the lower bound + // values for the square root. Note that the lower bound // can be equal, this is important to catch edge cases such as // 0x1.fffffep+127f and relies on the smallest normal number // being a perfect square (which it will be for any sensible diff --git a/src/ansi-c/library/netdb.c b/src/ansi-c/library/netdb.c index 8b29acc49ae..40cb4e4eecc 100644 --- a/src/ansi-c/library/netdb.c +++ b/src/ansi-c/library/netdb.c @@ -12,10 +12,10 @@ struct hostent *gethostbyname(const char *name) __CPROVER_bool error; if(error) return 0; - + // quite restrictive, as will alias between calls static struct hostent result; - + // we whould be filling in the fields of this return &result; } @@ -31,10 +31,10 @@ struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) __CPROVER_bool error; if(error) return 0; - + // quite restrictive, as will alias between calls static struct hostent result; - + // we whould be filling in the fields of this return &result; } @@ -47,10 +47,10 @@ struct hostent *gethostent(void) __CPROVER_bool error; if(error) return 0; - + // quite restrictive, as will alias between calls static struct hostent result; - + // we whould be filling in the fields of this return &result; } diff --git a/src/ansi-c/library/new.c b/src/ansi-c/library/new.c index d44510f0210..beb4e70e1bf 100644 --- a/src/ansi-c/library/new.c +++ b/src/ansi-c/library/new.c @@ -10,13 +10,13 @@ inline void *__new(__typeof__(sizeof(int)) malloc_size) // ensure it's not recorded as deallocated __CPROVER_deallocated=(res==__CPROVER_deallocated)?0:__CPROVER_deallocated; - + // non-derministically record the object size for bounds checking __CPROVER_bool record_malloc; __CPROVER_malloc_object=record_malloc?res:__CPROVER_malloc_object; __CPROVER_malloc_size=record_malloc?malloc_size:__CPROVER_malloc_size; __CPROVER_malloc_is_new_array=record_malloc?0:__CPROVER_malloc_is_new_array; - + // detect memory leaks __CPROVER_bool record_may_leak; __CPROVER_memory_leak=record_may_leak?res:__CPROVER_memory_leak; @@ -36,13 +36,13 @@ inline void *__new_array(__CPROVER_size_t count, __CPROVER_size_t size) // ensure it's not recorded as deallocated __CPROVER_deallocated=(res==__CPROVER_deallocated)?0:__CPROVER_deallocated; - + // non-deterministically record the object size for bounds checking __CPROVER_bool record_malloc; __CPROVER_malloc_object=record_malloc?res:__CPROVER_malloc_object; __CPROVER_malloc_size=record_malloc?size*count:__CPROVER_malloc_size; __CPROVER_malloc_is_new_array=record_malloc?1:__CPROVER_malloc_is_new_array; - + // detect memory leaks __CPROVER_bool record_may_leak; __CPROVER_memory_leak=record_may_leak?res:__CPROVER_memory_leak; @@ -78,12 +78,12 @@ inline void __delete(void *ptr) // catch double delete __CPROVER_assert(__CPROVER_deallocated!=ptr, "double delete"); - + // catch people who call delete for objects allocated with new[] __CPROVER_assert(__CPROVER_malloc_object!=ptr || !__CPROVER_malloc_is_new_array, "delete of array object"); - + // non-deterministically record as deallocated __CPROVER_bool record; __CPROVER_deallocated=record?ptr:__CPROVER_deallocated; @@ -107,7 +107,7 @@ inline void __delete_array(void *ptr) // catch double delete __CPROVER_assert(__CPROVER_deallocated!=ptr, "double delete"); - + // catch people who call delete[] for objects allocated with new __CPROVER_assert(__CPROVER_malloc_object!=ptr || __CPROVER_malloc_is_new_array, @@ -118,4 +118,3 @@ inline void __delete_array(void *ptr) __CPROVER_deallocated=record?ptr:__CPROVER_deallocated; } } - diff --git a/src/ansi-c/library/process.c b/src/ansi-c/library/process.c index ad3df409b3a..c7de7fa5746 100644 --- a/src/ansi-c/library/process.c +++ b/src/ansi-c/library/process.c @@ -1,6 +1,6 @@ /* FUNCTION: _beginthread */ -__CPROVER_size_t _beginthread( +__CPROVER_size_t _beginthread( void (*start_address)(void *), unsigned stack_size, void *arglist) @@ -14,7 +14,7 @@ __CPROVER_size_t _beginthread( /* FUNCTION: _beginthreadex */ -__CPROVER_size_t _beginthreadex( +__CPROVER_size_t _beginthreadex( void *security, unsigned stack_size, unsigned (*start_address )(void *), @@ -32,4 +32,3 @@ __CPROVER_size_t _beginthreadex( __CPROVER_size_t handle; return handle; } - diff --git a/src/ansi-c/library/pthread_lib.c b/src/ansi-c/library/pthread_lib.c index 730d30b7471..d5bb0e1e759 100644 --- a/src/ansi-c/library/pthread_lib.c +++ b/src/ansi-c/library/pthread_lib.c @@ -75,7 +75,7 @@ inline int pthread_mutex_init( __CPROVER_HIDE:; *((__CPROVER_mutex_t *)mutex)=0; if(mutexattr!=0) (void)*mutexattr; - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_cleanup(mutex, pthread_mutex_cleanup); __CPROVER_set_must(mutex, "mutex-init"); @@ -219,7 +219,7 @@ inline int pthread_mutex_unlock(pthread_mutex_t *mutex) "mutex must not be destroyed"); __CPROVER_clear_may(mutex, "mutex-locked"); - + #else // the fence must be before the unlock @@ -380,8 +380,8 @@ inline int pthread_rwlock_destroy(pthread_rwlock_t *lock) __CPROVER_assert(*((signed char *)lock)==0, "rwlock held upon destroy"); *((signed char *)lock)=-1; - - #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS + + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_set_must(lock, "rwlock_destroyed"); #endif @@ -395,7 +395,7 @@ inline int pthread_rwlock_destroy(pthread_rwlock_t *lock) #define __CPROVER_PTHREAD_H_INCLUDED #endif -#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS +#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS inline void pthread_rwlock_cleanup(void *p) { __CPROVER_HIDE:; @@ -404,14 +404,14 @@ inline void pthread_rwlock_cleanup(void *p) } #endif -inline int pthread_rwlock_init(pthread_rwlock_t *lock, +inline int pthread_rwlock_init(pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr) { __CPROVER_HIDE:; (*(signed char *)lock)=0; if(attr!=0) (void)*attr; - #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_cleanup(lock, pthread_rwlock_cleanup); #endif @@ -529,7 +529,7 @@ inline int pthread_create( __CPROVER_atomic_begin(); this_thread_id=++__CPROVER_next_thread_id; __CPROVER_atomic_end(); - + if(thread) { #ifdef __APPLE__ @@ -545,10 +545,10 @@ inline int pthread_create( #endif if(attr) (void)*attr; - + __CPROVER_ASYNC_1: __CPROVER_thread_id=this_thread_id, - #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS // Clear all locked mutexes; locking must happen in same thread. __CPROVER_clear_must(0, "mutex-locked"), __CPROVER_clear_may(0, "mutex-locked"), @@ -660,7 +660,7 @@ int pthread_spin_lock(pthread_spinlock_t *lock) __CPROVER_assume(!*((unsigned *)lock)); (*((unsigned *)lock))=1; __CPROVER_atomic_end(); - + __CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence", "WWcumul", "RRcumul", "RWcumul", "WRcumul"); return 0; @@ -715,7 +715,7 @@ int pthread_spin_trylock(pthread_spinlock_t *lock) (*((unsigned *)lock))=1; } __CPROVER_atomic_end(); - + __CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence", "WWcumul", "RRcumul", "RWcumul", "WRcumul"); return result; @@ -739,15 +739,15 @@ inline int pthread_barrier_init( (void)barrier; (void)attr; (void)count; - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_set_must(barrier, "barrier-init"); __CPROVER_clear_may(barrier, "barrier-destroyed"); #endif - + int result; return result; -} +} #endif /* FUNCTION: pthread_barrier_destroy */ @@ -762,9 +762,9 @@ inline int pthread_barrier_init( inline int pthread_barrier_destroy(pthread_barrier_t *barrier) { __CPROVER_HIDE:; - + (void)barrier; - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_assert(__CPROVER_get_must(barrier, "barrier-init"), "pthread barrier must be initialized"); @@ -790,9 +790,9 @@ inline int pthread_barrier_destroy(pthread_barrier_t *barrier) inline int pthread_barrier_wait(pthread_barrier_t *barrier) { __CPROVER_HIDE:; - + (void)barrier; - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_assert(__CPROVER_get_must(barrier, "barrier-init"), "pthread barrier must be initialized"); diff --git a/src/ansi-c/library/semaphore.c b/src/ansi-c/library/semaphore.c index 1b2a618f1f3..5499a8ca72f 100644 --- a/src/ansi-c/library/semaphore.c +++ b/src/ansi-c/library/semaphore.c @@ -8,7 +8,7 @@ inline int sem_init(sem_t *sem, int pshared, unsigned int value) (void)pshared; (void)value; (void)sem; - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_set_must(sem, "sem-init"); __CPROVER_clear_may(sem, "sem-destroyed"); diff --git a/src/ansi-c/library/setjmp.c b/src/ansi-c/library/setjmp.c index 7d28d939df1..64e99e98f8b 100644 --- a/src/ansi-c/library/setjmp.c +++ b/src/ansi-c/library/setjmp.c @@ -13,7 +13,7 @@ inline void longjmp(jmp_buf env, int val) (void)val; __CPROVER_assume(0); } - + /* FUNCTION: _longjmp */ #ifndef __CPROVER_SETJMP_H_INCLUDED @@ -28,7 +28,7 @@ inline void _longjmp(jmp_buf env, int val) (void)val; __CPROVER_assume(0); } - + /* FUNCTION: siglongjmp */ #ifndef __CPROVER_SETJMP_H_INCLUDED @@ -58,4 +58,3 @@ inline int setjmp(jmp_buf env) (void)env; return retval; } - diff --git a/src/ansi-c/library/stdio.c b/src/ansi-c/library/stdio.c index 62685609753..6b285484da3 100644 --- a/src/ansi-c/library/stdio.c +++ b/src/ansi-c/library/stdio.c @@ -245,11 +245,11 @@ inline int ferror(FILE *stream) int return_value; (void)*stream; - #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_assert(__CPROVER_get_must(stream, "open"), "feof file must be open"); #endif - + return return_value; } @@ -361,12 +361,12 @@ inline int fgetc(FILE *stream) __CPROVER_assume(return_value>=-1 && return_value<=255); __CPROVER_input("fgetc", return_value); - + #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS __CPROVER_assert(__CPROVER_get_must(stream, "open"), "fgetc file must be open"); #endif - + return return_value; } @@ -390,9 +390,9 @@ inline int getc(FILE *stream) // It's a byte or EOF, which we fix to -1. __CPROVER_assume(return_value>=-1 && return_value<=255); - + __CPROVER_input("getc", return_value); - + return return_value; } @@ -546,7 +546,7 @@ void perror(const char *s) if(s[0]!=0) printf("%s: ", s); } - + // TODO: print errno error } @@ -734,4 +734,3 @@ inline int vfprintf(FILE *stream, const char *restrict format, va_list arg) return result; } - diff --git a/src/ansi-c/library/stdlib.c b/src/ansi-c/library/stdlib.c index 31676ea521c..b6f13e9e9a2 100644 --- a/src/ansi-c/library/stdlib.c +++ b/src/ansi-c/library/stdlib.c @@ -96,13 +96,13 @@ inline void *malloc(__CPROVER_size_t malloc_size) // make sure it's not recorded as deallocated __CPROVER_deallocated=(malloc_res==__CPROVER_deallocated)?0:__CPROVER_deallocated; - + // record the object size for non-determistic bounds checking __CPROVER_bool record_malloc; __CPROVER_malloc_object=record_malloc?malloc_res:__CPROVER_malloc_object; __CPROVER_malloc_size=record_malloc?malloc_size:__CPROVER_malloc_size; __CPROVER_malloc_is_new_array=record_malloc?0:__CPROVER_malloc_is_new_array; - + // detect memory leaks __CPROVER_bool record_may_leak; __CPROVER_memory_leak=record_may_leak?malloc_res:__CPROVER_memory_leak; @@ -120,7 +120,7 @@ inline void *__builtin_alloca(__CPROVER_size_t alloca_size) // make sure it's not recorded as deallocated __CPROVER_deallocated=(res==__CPROVER_deallocated)?0:__CPROVER_deallocated; - + // record the object size for non-determistic bounds checking __CPROVER_bool record_malloc; __CPROVER_malloc_object=record_malloc?res:__CPROVER_malloc_object; @@ -149,13 +149,13 @@ inline void free(void *ptr) // catch double free if(__CPROVER_deallocated==ptr) __CPROVER_assert(0, "double free"); - + // catch people who try to use free(...) for stuff // allocated with new[] __CPROVER_assert(__CPROVER_malloc_object!=ptr || !__CPROVER_malloc_is_new_array, "free called for new[] object"); - + // non-deterministically record as deallocated __CPROVER_bool record; if(record) __CPROVER_deallocated=ptr; @@ -377,7 +377,7 @@ inline void *valloc(__CPROVER_size_t malloc_size) { // The allocated memory is aligned on a page // boundary, which we don't model. - + __CPROVER_HIDE:; return malloc(malloc_size); } @@ -392,4 +392,3 @@ long random(void) __CPROVER_assume(result>=0 && result<=2147483647); return result; } - diff --git a/src/ansi-c/library/string.c b/src/ansi-c/library/string.c index aaa6e3fa6ef..29af627d318 100644 --- a/src/ansi-c/library/string.c +++ b/src/ansi-c/library/string.c @@ -59,7 +59,7 @@ __inline char *__builtin___strcat_chk(char *dst, const char *src, __CPROVER_size while(i=n, "strncat zero-termination of 2nd argument"); __CPROVER_assert(__CPROVER_buffer_size(dst)==s, "builtin object size"); additional=(n<__CPROVER_zero_string_length(src))?n:__CPROVER_zero_string_length(src); - new_size=__CPROVER_is_zero_string(dst)+additional; + new_size=__CPROVER_is_zero_string(dst)+additional; __CPROVER_assert(__CPROVER_buffer_size(dst)>new_size, "strncat buffer overflow"); - __CPROVER_size_t dest_len=__CPROVER_zero_string_length(dst); + __CPROVER_size_t dest_len=__CPROVER_zero_string_length(dst); __CPROVER_size_t i; for (i = 0 ; i < n && i<__CPROVER_zero_string_length(src) ; i++) dst[dest_len + i] = src[i]; @@ -140,7 +140,7 @@ inline char *strncpy(char *dst, const char *src, size_t n) __CPROVER_assert(__CPROVER_is_zero_string(src), "strncpy zero-termination of 2nd argument"); __CPROVER_assert(__CPROVER_buffer_size(dst)>=n, "strncpy buffer overflow"); __CPROVER_is_zero_string(dst)=__CPROVER_zero_string_length(src)=n, "strncpy buffer overflow"); __CPROVER_assert(__CPROVER_buffer_size(dst)==object_size, "builtin object size"); __CPROVER_is_zero_string(dst)=__CPROVER_zero_string_length(src)=n, "strncat zero-termination of 2nd argument"); additional=(n<__CPROVER_zero_string_length(src))?n:__CPROVER_zero_string_length(src); - new_size=__CPROVER_is_zero_string(dst)+additional; + new_size=__CPROVER_is_zero_string(dst)+additional; __CPROVER_assert(__CPROVER_buffer_size(dst)>new_size, "strncat buffer overflow"); - __CPROVER_size_t dest_len=__CPROVER_zero_string_length(dst); + __CPROVER_size_t dest_len=__CPROVER_zero_string_length(dst); __CPROVER_size_t i; for (i = 0 ; i < n && i<__CPROVER_zero_string_length(src) ; i++) dst[dest_len + i] = src[i]; @@ -338,7 +338,7 @@ inline int strcasecmp(const char *s1, const char *s2) { ch1=s1[i]; ch2=s2[i]; - + if(ch1>='A' && ch1<='Z') ch1+=('a'-'A'); if(ch2>='A' && ch2<='Z') ch2+=('a'-'A'); @@ -421,7 +421,7 @@ inline int strncasecmp(const char *s1, const char *s2, size_t n) { ch1=s1[i]; ch2=s2[i]; - + if(ch1>='A' && ch1<='Z') ch1+=('a'-'A'); if(ch2>='A' && ch2<='Z') ch2+=('a'-'A'); @@ -639,7 +639,7 @@ inline void *memmove(void *dest, const void *src, size_t n) { for(__CPROVER_size_t i=0; i0; i--) ((char *)dest)[i-1]=((const char *)src)[i-1]; } diff --git a/src/ansi-c/library/threads.c b/src/ansi-c/library/threads.c index d53c6f1a739..d0c10ac03e0 100644 --- a/src/ansi-c/library/threads.c +++ b/src/ansi-c/library/threads.c @@ -205,4 +205,3 @@ int cnd_timedwait(cnd_t* restrict cond, mtx_t* restrict mutex, void cnd_destroy(cnd_t* cond) { } - diff --git a/src/ansi-c/library/time.c b/src/ansi-c/library/time.c index fadc175cdb6..6c1fb1259a8 100644 --- a/src/ansi-c/library/time.c +++ b/src/ansi-c/library/time.c @@ -169,4 +169,3 @@ char *ctime(const time_t *clock) return ctime_result; #endif } - diff --git a/src/ansi-c/library/unistd.c b/src/ansi-c/library/unistd.c index 8587036ddea..b9c632fcb77 100644 --- a/src/ansi-c/library/unistd.c +++ b/src/ansi-c/library/unistd.c @@ -5,9 +5,9 @@ unsigned int sleep(unsigned int seconds) __CPROVER_HIDE:; // do nothing, but return nondet value unsigned remaining_time; - + if(remaining_time>seconds) remaining_time=seconds; - + return remaining_time; } diff --git a/src/ansi-c/library/windows.c b/src/ansi-c/library/windows.c index 3a18a55f47b..1c6b5e758bf 100644 --- a/src/ansi-c/library/windows.c +++ b/src/ansi-c/library/windows.c @@ -46,7 +46,7 @@ inline HANDLE CreateThread( if(lpThreadId) *lpThreadId=thread_id; __CPROVER_ASYNC_1: lpStartAddress(lpParameter); - + HANDLE handle; return handle; } diff --git a/src/ansi-c/library/x86_assembler.c b/src/ansi-c/library/x86_assembler.c index 9264022e1eb..d1e5517ea0d 100644 --- a/src/ansi-c/library/x86_assembler.c +++ b/src/ansi-c/library/x86_assembler.c @@ -49,4 +49,3 @@ inline void __asm_lfence(void) { __CPROVER_fence("WWfence", "RRfence", "RWfence", "WRfence"); } - diff --git a/src/ansi-c/literals/convert_character_literal.cpp b/src/ansi-c/literals/convert_character_literal.cpp index a2929fabee4..51e7b9b6fdc 100644 --- a/src/ansi-c/literals/convert_character_literal.cpp +++ b/src/ansi-c/literals/convert_character_literal.cpp @@ -34,20 +34,20 @@ exprt convert_character_literal( bool force_integer_type) { assert(src.size()>=2); - + exprt result; if(src[0]=='L' || src[0]=='u' || src[0]=='U') { assert(src[1]=='\''); assert(src[src.size()-1]=='\''); - + std::basic_string value= unescape_wide_string(std::string(src, 2, src.size()-3)); - + // L is wchar_t, u is char16_t, U is char32_t typet type=wchar_t_type(); - + if(value.empty()) throw "empty wide character literal"; else if(value.size()==1) @@ -107,6 +107,6 @@ exprt convert_character_literal( throw "literals with "+i2string(value.size())+ " characters are not supported"; } - + return result; } diff --git a/src/ansi-c/literals/convert_float_literal.cpp b/src/ansi-c/literals/convert_float_literal.cpp index 9328788afcf..c7a66c60f04 100644 --- a/src/ansi-c/literals/convert_float_literal.cpp +++ b/src/ansi-c/literals/convert_float_literal.cpp @@ -38,13 +38,13 @@ exprt convert_float_literal(const std::string &src) bool is_float, is_long, is_imaginary; bool is_decimal, is_float80, is_float128; // GCC extensions unsigned base; - + parse_float(src, significand, exponent, base, is_float, is_long, is_imaginary, is_decimal, is_float80, is_float128); exprt result=exprt(ID_constant); - + // In ANSI-C, float literals are double by default, // unless marked with 'f'. // All of these can be complex as well. @@ -79,13 +79,13 @@ exprt convert_float_literal(const std::string &src) // TODO - should set ID_gcc_decimal32/ID_gcc_decimal64/ID_gcc_decimal128, // but these aren't handled anywhere } - + if(config.ansi_c.use_fixed_for_float) { unsigned width=result.type().get_int(ID_width); unsigned fraction_bits; const irep_idt integer_bits=result.type().get(ID_integer_bits); - + assert(width!=0); if(integer_bits==irep_idt()) @@ -95,14 +95,14 @@ exprt convert_float_literal(const std::string &src) mp_integer factor=mp_integer(1)<=power(2, width-1)) { @@ -117,14 +117,14 @@ exprt convert_float_literal(const std::string &src) } } - result.set(ID_value, integer2binary(value, width)); + result.set(ID_value, integer2binary(value, width)); } else { ieee_floatt a; a.spec=to_floatbv_type(result.type()); - + if(base==10) a.from_base10(significand, exponent); else if(base==2) // hex @@ -133,7 +133,7 @@ exprt convert_float_literal(const std::string &src) assert(false); result.set(ID_value, - integer2binary(a.pack(), a.spec.width())); + integer2binary(a.pack(), a.spec.width())); } if(is_imaginary) @@ -146,6 +146,6 @@ exprt convert_float_literal(const std::string &src) complex_expr.op1()=result; return complex_expr; } - + return result; } diff --git a/src/ansi-c/literals/convert_integer_literal.cpp b/src/ansi-c/literals/convert_integer_literal.cpp index 3848ff405b1..10d149c8291 100644 --- a/src/ansi-c/literals/convert_integer_literal.cpp +++ b/src/ansi-c/literals/convert_integer_literal.cpp @@ -36,7 +36,7 @@ exprt convert_integer_literal(const std::string &src) unsigned long_cnt=0; unsigned width_suffix=0; unsigned base=10; - + for(unsigned i=0; ivalue_abs)) @@ -173,10 +173,10 @@ exprt convert_integer_literal(const std::string &src) else c_type=ID_signed_long_long_int; } - + typet type=typet(is_signed?ID_signedbv:ID_unsignedbv); - type.set(ID_width, width); + type.set(ID_width, width); type.set(ID_C_c_type, c_type); exprt result; diff --git a/src/ansi-c/literals/convert_string_literal.cpp b/src/ansi-c/literals/convert_string_literal.cpp index d354690d539..bf928e1cf6a 100644 --- a/src/ansi-c/literals/convert_string_literal.cpp +++ b/src/ansi-c/literals/convert_string_literal.cpp @@ -33,7 +33,7 @@ std::basic_string convert_one_string_literal( const std::string &src) { assert(src.size()>=2); - + if(src[0]=='u' && src[1]=='8') { assert(src[src.size()-1]=='"'); @@ -41,7 +41,7 @@ std::basic_string convert_one_string_literal( std::basic_string value= unescape_wide_string(std::string(src, 3, src.size()-4)); - + // turn into utf-8 std::string utf8_value=utf32_to_utf8(value); @@ -56,7 +56,7 @@ std::basic_string convert_one_string_literal( { assert(src[src.size()-1]=='"'); assert(src[1]=='"'); - + return unescape_wide_string(std::string(src, 2, src.size()-3)); } else @@ -98,9 +98,9 @@ exprt convert_string_literal(const std::string &src) // GCC allows "asd" L"xyz"! std::basic_string value; - + char wide=0; - + for(unsigned i=0; i255. // gcc issues a warning in this case. char_value[i]=value[i]; } - + string_constantt result; result.set_value(char_value); - + return result; } } diff --git a/src/ansi-c/literals/parse_float.cpp b/src/ansi-c/literals/parse_float.cpp index a6fa2cb06e5..674e986e35a 100644 --- a/src/ansi-c/literals/parse_float.cpp +++ b/src/ansi-c/literals/parse_float.cpp @@ -44,18 +44,18 @@ void parse_float( std::string str_whole_number, str_fraction_part, str_exponent; - + exponent_base=10; - + // is this hex? - + if(src.size()>=2 && src[0]=='0' && tolower(src[1])=='x') { // skip the 0x p+=2; - + exponent_base=2; - + // get whole number part while(*p!='.' && *p!=0 && *p!='p' && *p!='P') { @@ -92,7 +92,7 @@ void parse_float( std::string str_number=str_whole_number+ str_fraction_part; - + // The significand part is interpreted as a (decimal or hexadecimal) // rational number; the digit sequence in the exponent part is // interpreted as a decimal integer. diff --git a/src/ansi-c/literals/unescape_string.cpp b/src/ansi-c/literals/unescape_string.cpp index b890731b605..827f08f280b 100644 --- a/src/ansi-c/literals/unescape_string.cpp +++ b/src/ansi-c/literals/unescape_string.cpp @@ -37,7 +37,7 @@ std::string unescape_string(const std::string &src) // go to next character i++; assert(i unescape_wide_string( std::basic_string dest; dest.reserve(src.size()); // about that long, but may be shorter - + for(unsigned i=0; i unescape_wide_string( case 'a': dest.push_back('\a'); break; /* BEL (0x07) */ case '"': dest.push_back('"'); break; case '\'': dest.push_back('\''); break; - + case 'u': // universal character case 'U': // universal character i++; { std::string hex; - + unsigned count=(ch=='u')?4:8; hex.reserve(count); @@ -190,12 +190,12 @@ std::basic_string unescape_wide_string( // go back i--; - + unsigned int result; sscanf(hex.c_str(), "%x", &result); ch=result; } - + dest.push_back(ch); break; @@ -209,7 +209,7 @@ std::basic_string unescape_wide_string( hex+=src[i]; i++; } - + // go back i--; @@ -217,24 +217,24 @@ std::basic_string unescape_wide_string( sscanf(hex.c_str(), "%x", &result); ch=result; } - - dest.push_back(ch); + + dest.push_back(ch); break; - + default: if(isdigit(ch)) // octal { std::string octal; - + while(ibit_field_bits; ++bytes, bit_field_bits+=8); @@ -234,14 +234,14 @@ void add_padding(struct_typet &type, const namespacet &ns) } else a=alignment(it_type, ns); - + // check minimum alignment if(a1) { // we may need to align it @@ -307,7 +307,7 @@ void add_padding(struct_typet &type, const namespacet &ns) if(displacement!=0) { mp_integer pad=max_alignment-displacement; - + unsignedbv_typet padding_type; padding_type.set_width(integer2unsigned(pad*8)); @@ -316,7 +316,7 @@ void add_padding(struct_typet &type, const namespacet &ns) component.type()=padding_type; component.set_name("$pad"+i2string(padding_counter++)); component.set_is_padding(true); - + components.push_back(component); } } @@ -348,10 +348,10 @@ void add_padding(union_typet &type, const namespacet &ns) // The size needs to be a multiple of 8 only. max_alignment=8; } - + // The size must be a multiple of the alignment, or // we add a padding member to the union. - + if(size_bits%max_alignment!=0) { mp_integer padding=max_alignment-(size_bits%max_alignment); @@ -363,7 +363,7 @@ void add_padding(union_typet &type, const namespacet &ns) component.type()=padding_type; component.set_name("$pad"); component.set_is_padding(true); - + components.push_back(component); } } diff --git a/src/ansi-c/parser_static.inc b/src/ansi-c/parser_static.inc index 6b31168845d..7e0936727a4 100644 --- a/src/ansi-c/parser_static.inc +++ b/src/ansi-c/parser_static.inc @@ -177,18 +177,18 @@ Function: make_subtype \*******************************************************************/ static void make_subtype(typet &dest, typet &src) -{ +{ // inserts "src" into "dest" // e.g., src is a pointer or array, // dest is a symbol or type - + // find spot in 'dest' where to insert 'src' - + #if 0 std::cout << "D: " << dest.pretty() << std::endl; std::cout << "S: " << src.pretty() << std::endl; #endif - + assert(src.id()==ID_array || src.id()==ID_pointer || src.id()==ID_code || @@ -202,7 +202,7 @@ static void make_subtype(typet &dest, typet &src) { // see if we need to walk down typet *sub=p; - + if(p->id()==ID_merged_type) { // do last one @@ -215,7 +215,7 @@ static void make_subtype(typet &dest, typet &src) sub->id()==ID_code) { // walk down - p=&sub->subtype(); + p=&sub->subtype(); } else { @@ -231,11 +231,11 @@ static void make_subtype(typet &dest, typet &src) else { // *p is now type or symbol - + // save symbol typet symbol=*p; p->swap(src); - + // find spot where to put symbol while(true) { @@ -278,7 +278,7 @@ static void make_subtype(YYSTYPE dest, YYSTYPE src) { make_subtype(stack_type(dest), stack_type(src)); } - + /*******************************************************************\ Function: make_pointer @@ -347,9 +347,9 @@ static void create_function_scope(const YYSTYPE d) if(declarator.type().id()==ID_code) { code_typet &code_type=to_code_type(declarator.type()); - + code_typet::parameterst ¶meters=code_type.parameters(); - + // Add the parameter declarations to the scope. for(auto & it : parameters) { @@ -359,7 +359,7 @@ static void create_function_scope(const YYSTYPE d) // we record the function name in the location param_decl.add_source_location().set_function(function_name); - + if(!param_decl.declarators().empty()) { // add to scope diff --git a/src/ansi-c/preprocessor_line.cpp b/src/ansi-c/preprocessor_line.cpp index 0fb9d6cfd54..845ca937c60 100644 --- a/src/ansi-c/preprocessor_line.cpp +++ b/src/ansi-c/preprocessor_line.cpp @@ -32,7 +32,7 @@ void preprocessor_line( { const char *ptr=text; std::string line_number; - + // skip WS while(*ptr==' ' || *ptr=='\t') ptr++; @@ -58,7 +58,7 @@ void preprocessor_line( line_number+=*ptr; ptr++; } - + // skip until " while(*ptr!='\n' && *ptr!='"') ptr++; @@ -67,9 +67,9 @@ void preprocessor_line( // skip " if(*ptr!='"') return; - + ptr++; - + std::string file_name_tmp; // get file name diff --git a/src/ansi-c/printf_formatter.h b/src/ansi-c/printf_formatter.h index 614af7ec5cd..8af65a78fce 100644 --- a/src/ansi-c/printf_formatter.h +++ b/src/ansi-c/printf_formatter.h @@ -21,7 +21,7 @@ class printf_formattert void print(std::ostream &out); std::string as_string(); - + explicit printf_formattert(const namespacet &_ns):ns(_ns) { } @@ -33,7 +33,7 @@ class printf_formattert std::list::const_iterator next_operand; unsigned format_pos; inline bool eol() const { return format_pos>=format.size(); } - + class eol_exception { }; char next() @@ -41,7 +41,7 @@ class printf_formattert if(eol()) throw eol_exception(); return format[format_pos++]; } - + void process_char(std::ostream &out); void process_format(std::ostream &out); diff --git a/src/ansi-c/string_constant.cpp b/src/ansi-c/string_constant.cpp index b8adab33193..995eca61418 100644 --- a/src/ansi-c/string_constant.cpp +++ b/src/ansi-c/string_constant.cpp @@ -114,7 +114,7 @@ array_exprt string_constantt::to_array_expr() const ch_str+="'"; } } - + return dest; } @@ -134,16 +134,16 @@ bool string_constantt::from_array_expr(const array_exprt &src) { id(ID_string_constant); type()=src.type(); - + const typet &subtype=type().subtype(); // check subtype if(subtype!=signed_char_type() && subtype!=unsigned_char_type()) return true; - + std::string value; - + forall_operands(it, src) { mp_integer int_value=0; @@ -151,14 +151,13 @@ bool string_constantt::from_array_expr(const array_exprt &src) unsigned unsigned_value=integer2unsigned(int_value); value+=(char)unsigned_value; } - + // Drop the implicit zero at the end. // Not clear what the semantics should be if it's not there. if(!value.empty() && value[value.size()-1]==0) value.resize(value.size()-1); - + set_value(value); - + return false; } - diff --git a/src/ansi-c/string_constant.h b/src/ansi-c/string_constant.h index 760c2c2bd70..0d57246673a 100644 --- a/src/ansi-c/string_constant.h +++ b/src/ansi-c/string_constant.h @@ -29,14 +29,14 @@ class string_constantt:public exprt assert(expr.id()==ID_string_constant); return static_cast(expr); } - + void set_value(const irep_idt &value); inline const irep_idt &get_value() const { return get(ID_value); } - + array_exprt to_array_expr() const; bool from_array_expr(const array_exprt &); }; diff --git a/src/ansi-c/type2name.cpp b/src/ansi-c/type2name.cpp index af24fd311ef..f34ee45d29f 100644 --- a/src/ansi-c/type2name.cpp +++ b/src/ansi-c/type2name.cpp @@ -110,7 +110,7 @@ static std::string type2name( symbol_numbert &symbol_number) { std::string result; - + // qualifiers first if(type.get_bool(ID_C_constant)) result+='c'; @@ -141,17 +141,17 @@ static std::string type2name( else if(type.id()==ID_unsignedbv) result+="U" + type.get_string(ID_width); else if(type.id()==ID_bool || - type.id()==ID_c_bool) + type.id()==ID_c_bool) result+='B'; - else if(type.id()==ID_integer) + else if(type.id()==ID_integer) result+='I'; - else if(type.id()==ID_real) + else if(type.id()==ID_real) result+='R'; - else if(type.id()==ID_complex) + else if(type.id()==ID_complex) result+='C'; - else if(type.id()==ID_floatbv) + else if(type.id()==ID_floatbv) result+="F" + type.get_string(ID_width); - else if(type.id()==ID_fixedbv) + else if(type.id()==ID_fixedbv) result+="X" + type.get_string(ID_width); else if(type.id()==ID_natural) result+='N'; @@ -169,7 +169,7 @@ static std::string type2name( it=parameters.begin(); it!=parameters.end(); it++) - { + { if(it!=parameters.begin()) result+='|'; result+=type2name(it->type(), ns, symbol_number); } @@ -202,7 +202,7 @@ static std::string type2name( parent_is_sym_check=true; result+=type2name_symbol(type, ns, symbol_number); } - else if(type.id()==ID_struct || + else if(type.id()==ID_struct || type.id()==ID_union) { assert(parent_is_sym_check); @@ -216,7 +216,7 @@ static std::string type2name( it=components.begin(); it!=components.end(); it++) - { + { if(it!=components.begin()) result+='|'; result+=type2name(it->type(), ns, symbol_number); result+="'"+it->get_string(ID_name)+"'"; @@ -250,10 +250,10 @@ static std::string type2name( else if(type.id()==ID_vector) result+="VEC"+type.get_string(ID_size); else - throw (std::string("Unknown type '") + - type.id_string() + - "' encountered."); - + throw (std::string("Unknown type '") + + type.id_string() + + "' encountered."); + if(type.has_subtype()) { result+='{'; @@ -265,13 +265,13 @@ static std::string type2name( { result+='$'; forall_subtypes(it, type) - { + { result+=type2name(*it, ns, symbol_number); result+='|'; } result[result.size()-1]='$'; } - + return result; } @@ -311,4 +311,3 @@ std::string type2name(const typet &type) symbol_tablet symbol_table; return type2name(type, namespacet(symbol_table)); } - diff --git a/src/assembler/Makefile b/src/assembler/Makefile index 065d73105fb..90b2562f1d4 100644 --- a/src/assembler/Makefile +++ b/src/assembler/Makefile @@ -19,6 +19,5 @@ generated_files: assembler_lex.yy.cpp ############################################################################### -assembler$(LIBEXT): $(OBJ) +assembler$(LIBEXT): $(OBJ) $(LINKLIB) - diff --git a/src/assembler/assembler_parser.cpp b/src/assembler/assembler_parser.cpp index 88bdfb07a7e..59367857340 100644 --- a/src/assembler/assembler_parser.cpp +++ b/src/assembler/assembler_parser.cpp @@ -31,4 +31,3 @@ int yyassemblererror(const std::string &error) assembler_parser.parse_error(error, yyassemblertext); return 0; } - diff --git a/src/assembler/assembler_parser.h b/src/assembler/assembler_parser.h index 3fe5742a807..b2094f3feb0 100644 --- a/src/assembler/assembler_parser.h +++ b/src/assembler/assembler_parser.h @@ -21,7 +21,7 @@ class assembler_parsert:public parsert public: typedef std::vector instructiont; std::list instructions; - + void add_token(const irept &irep) { if(instructions.empty()) @@ -29,16 +29,16 @@ class assembler_parsert:public parsert instructions.back().push_back(irep); } - + void new_instruction() { instructions.push_back(instructiont()); } - + assembler_parsert() { } - + virtual bool parse() { yyassemblerlex(); diff --git a/src/big-int/bigint-test.cc b/src/big-int/bigint-test.cc index 6e0d90f0f91..6c8b9c84b64 100644 --- a/src/big-int/bigint-test.cc +++ b/src/big-int/bigint-test.cc @@ -324,7 +324,7 @@ run_floorPow2_tests () } else { putchar ('X'); } - + } N = pow(2,0); // 1 @@ -339,14 +339,14 @@ run_floorPow2_tests () } else { putchar ('X'); } - + N -= 1; // 0 if (N.floorPow2() == 0) { putchar ('.'); } else { putchar ('X'); } - + N += 2; // 2 if (N.floorPow2() == 1) { putchar ('.'); diff --git a/src/big-int/bigint.cc b/src/big-int/bigint.cc index dc7467544ea..a53e42ebdbc 100644 --- a/src/big-int/bigint.cc +++ b/src/big-int/bigint.cc @@ -1298,19 +1298,19 @@ BigInt::floorPow2 () const while ((power << 1) <= (twodig_t)digit[i]) { ++count, power <<= 1; } - + return (single_bits * i) + count; } // Not part of original BigInt. -void +void BigInt::setPower2 (unsigned exponent) { unsigned digitOffset = exponent / single_bits; unsigned bitOffset = exponent % single_bits; unsigned digitsNeeded = 1 + digitOffset; reallocate(digitsNeeded); - this->length = digitsNeeded; + this->length = digitsNeeded; this->positive = true; unsigned i; diff --git a/src/cbmc/Makefile b/src/cbmc/Makefile index 8440c92fa1b..79f7a4fd982 100644 --- a/src/cbmc/Makefile +++ b/src/cbmc/Makefile @@ -77,4 +77,3 @@ cbmc$(EXEEXT): $(OBJ) cbmc-mac-signed: cbmc$(EXEEXT) strip cbmc$(EXEEXT) ; codesign -v -s $(OSX_IDENTITY) cbmc$(EXEEXT) - diff --git a/src/cbmc/all_properties.cpp b/src/cbmc/all_properties.cpp index b314eed8556..290c2f14a18 100644 --- a/src/cbmc/all_properties.cpp +++ b/src/cbmc/all_properties.cpp @@ -41,18 +41,18 @@ void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &) { // failed already? if(g.second.status==goalt::statust::FAILURE) continue; - + // check whether failed for(auto &c : g.second.instances) { literalt cond=c->cond_literal; - + if(solver.l_get(cond).is_false()) { g.second.status=goalt::statust::FAILURE; symex_target_equationt::SSA_stepst::iterator next=c; next++; // include the assertion - build_goto_trace(bmc.equation, next, solver, bmc.ns, + build_goto_trace(bmc.equation, next, solver, bmc.ns, g.second.goto_trace); break; } @@ -80,9 +80,9 @@ safety_checkert::resultt bmc_all_propertiest::operator()() // stop the time absolute_timet sat_start=current_time(); - - bmc.do_conversion(); - + + bmc.do_conversion(); + // Collect _all_ goals in `goal_map'. // This maps property IDs to 'goalt' forall_goto_functions(f_it, goto_functions) @@ -113,18 +113,18 @@ safety_checkert::resultt bmc_all_propertiest::operator()() } else continue; - + goal_map[property_id].instances.push_back(it); } } - + do_before_solving(); cover_goalst cover_goals(solver); - cover_goals.set_message_handler(get_message_handler()); + cover_goals.set_message_handler(get_message_handler()); cover_goals.register_observer(*this); - + for(const auto & g : goal_map) { // Our goal is to falsify a property, i.e., we will @@ -136,7 +136,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()() status() << "Running " << solver.decision_procedure_text() << eom; bool error=false; - + decision_proceduret::resultt result=cover_goals(); if(result==decision_proceduret::D_ERROR) @@ -160,7 +160,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()() status() << "Runtime decision procedure: " << (sat_stop-sat_start) << "s" << eom; } - + // report report(cover_goals); @@ -173,7 +173,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()() bmc.report_success(); // legacy, might go away else bmc.report_failure(); // legacy, might go away - + return safe?safety_checkert::SAFE:safety_checkert::UNSAFE; } diff --git a/src/cbmc/all_properties_class.h b/src/cbmc/all_properties_class.h index 1cef4b5526e..3409c00a43d 100644 --- a/src/cbmc/all_properties_class.h +++ b/src/cbmc/all_properties_class.h @@ -45,11 +45,11 @@ class bmc_all_propertiest: typedef std::vector instancest; instancest instances; std::string description; - + // if failed, we compute a goto_trace for the first failing instance enum statust { UNKNOWN, FAILURE, SUCCESS, ERROR } status; goto_tracet goto_trace; - + std::string status_string() const { switch(status) @@ -64,18 +64,18 @@ class bmc_all_propertiest: assert(false); return ""; } - + explicit goalt( const goto_programt::instructiont &instruction): status(statust::UNKNOWN) { description=id2string(instruction.source_location.get_comment()); } - + goalt():status(statust::UNKNOWN) { } - + exprt as_expr() const { std::vector tmp; @@ -99,4 +99,3 @@ class bmc_all_propertiest: virtual void report(const cover_goalst &cover_goals); virtual void do_before_solving() {} }; - diff --git a/src/cbmc/bmc.cpp b/src/cbmc/bmc.cpp index 5b56eca546d..4982c1e38b3 100644 --- a/src/cbmc/bmc.cpp +++ b/src/cbmc/bmc.cpp @@ -73,14 +73,14 @@ void bmct::error_trace() goto_tracet &goto_trace=safety_checkert::error_trace; build_goto_trace(equation, prop_conv, ns, goto_trace); - + switch(ui) { case ui_message_handlert::PLAIN: std::cout << "\n" << "Counterexample:" << "\n"; show_goto_trace(std::cout, ns, goto_trace); break; - + case ui_message_handlert::XML_UI: { xmlt xml; @@ -88,7 +88,7 @@ void bmct::error_trace() std::cout << xml << "\n"; } break; - + case ui_message_handlert::JSON_UI: { json_objectt json_result; @@ -139,7 +139,7 @@ void bmct::do_conversion() { // convert HDL (hook for hw-cbmc) do_unwind_module(); - + status() << "converting SSA" << eom; // convert SSA @@ -149,7 +149,7 @@ void bmct::do_conversion() if(!bmc_constraints.empty()) { status() << "converting constraints" << eom; - + forall_expr_list(it, bmc_constraints) prop_conv.set_to_true(*it); } @@ -170,14 +170,14 @@ Function: bmct::run_decision_procedure decision_proceduret::resultt bmct::run_decision_procedure(prop_convt &prop_conv) { - status() << "Passing problem to " + status() << "Passing problem to " << prop_conv.decision_procedure_text() << eom; prop_conv.set_message_handler(get_message_handler()); // stop the time absolute_timet sat_start=current_time(); - + do_conversion(); status() << "Running " << prop_conv.decision_procedure_text() << eom; @@ -214,7 +214,7 @@ void bmct::report_success() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -254,7 +254,7 @@ void bmct::report_failure() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -291,7 +291,7 @@ void bmct::show_program() unsigned count=1; languagest languages(ns, new_ansi_c_language()); - + std::cout << "\n" << "Program constraints:" << "\n"; for(symex_target_equationt::SSA_stepst::const_iterator @@ -313,7 +313,7 @@ void bmct::show_program() std::cout << std::string(i2string(count).size()+3, ' '); std::cout << "guard: " << string_value << "\n"; } - + count++; } else if(it->is_assert()) @@ -331,7 +331,7 @@ void bmct::show_program() } count++; - } + } else if(it->is_assume()) { std::string string_value; @@ -347,7 +347,7 @@ void bmct::show_program() } count++; - } + } else if(it->is_constraint()) { std::string string_value; @@ -356,7 +356,7 @@ void bmct::show_program() << string_value <<") " << "\n"; count++; - } + } else if(it->is_shared_read() || it->is_shared_write()) { std::string string_value; @@ -372,7 +372,7 @@ void bmct::show_program() } count++; - } + } } } @@ -393,7 +393,7 @@ safety_checkert::resultt bmct::run( { const std::string mm=options.get_option("mm"); std::unique_ptr memory_model; - + if(mm.empty() || mm=="sc") memory_model=std::unique_ptr(new memory_model_sct(ns)); else if(mm=="tso") @@ -422,7 +422,7 @@ safety_checkert::resultt bmct::run( // perform symbolic execution symex(goto_functions); - // add a partial ordering, if required + // add a partial ordering, if required if(equation.has_threads()) { memory_model->set_message_handler(get_message_handler()); @@ -505,7 +505,7 @@ safety_checkert::resultt bmct::run( show_vcc(); return safety_checkert::SAFE; // to indicate non-error } - + if(!options.get_list_option("cover").empty()) { const optionst::value_listt criteria= @@ -612,7 +612,7 @@ safety_checkert::resultt bmct::stop_on_fail( error_trace(); } - + report_failure(); return UNSAFE; @@ -620,7 +620,7 @@ safety_checkert::resultt bmct::stop_on_fail( if(options.get_bool_option("dimacs") || options.get_option("outfile")!="") return SAFE; - + error() << "decision procedure failed" << eom; return ERROR; @@ -672,7 +672,7 @@ void bmct::setup_unwind() else symex.set_unwind_loop_limit(id, uw); } - + if(next==std::string::npos) break; idx=next; } diff --git a/src/cbmc/bmc.h b/src/cbmc/bmc.h index 32cb298ffca..7a396fecede 100644 --- a/src/cbmc/bmc.h +++ b/src/cbmc/bmc.h @@ -45,17 +45,17 @@ class bmct:public safety_checkert { symex.constant_propagation=options.get_bool_option("propagation"); } - + virtual resultt run(const goto_functionst &goto_functions); virtual ~bmct() { } - // additional stuff - expr_listt bmc_constraints; - + // additional stuff + expr_listt bmc_constraints; + friend class cbmc_satt; friend class hw_cbmc_satt; friend class counterexample_beautification_greedyt; - + void set_ui(language_uit::uit _ui) { ui=_ui; } // the safety_checkert interface @@ -66,7 +66,7 @@ class bmct:public safety_checkert } protected: - const optionst &options; + const optionst &options; symbol_tablet new_symbol_table; namespacet ns; symex_target_equationt equation; @@ -75,19 +75,19 @@ class bmct:public safety_checkert // use gui format language_uit::uit ui; - + virtual decision_proceduret::resultt run_decision_procedure(prop_convt &prop_conv); - + virtual resultt decide( const goto_functionst &, prop_convt &); - + // unwinding virtual void setup_unwind(); virtual void do_unwind_module(); void do_conversion(); - + virtual void show_vcc(); virtual void show_vcc_plain(std::ostream &out); virtual void show_vcc_json(std::ostream &out); @@ -103,7 +103,7 @@ class bmct:public safety_checkert virtual void report_failure(); virtual void error_trace(); - + bool cover( const goto_functionst &goto_functions, const optionst::value_listt &criteria); diff --git a/src/cbmc/bmc_cover.cpp b/src/cbmc/bmc_cover.cpp index 6c020b4d837..72e45362437 100644 --- a/src/cbmc/bmc_cover.cpp +++ b/src/cbmc/bmc_cover.cpp @@ -47,7 +47,7 @@ class bmc_covert: goto_functions(_goto_functions), solver(_bmc.prop_conv), bmc(_bmc) { } - + bool operator()(); // gets called by prop_covert @@ -61,10 +61,10 @@ class bmc_covert: symex_target_equationt::SSA_stepst::iterator step; literalt condition; }; - + typedef std::vector instancest; instancest instances; - + void add_instance( symex_target_equationt::SSA_stepst::iterator step, literalt condition) @@ -73,13 +73,13 @@ class bmc_covert: instances.back().step=step; instances.back().condition=condition; } - + std::string description; source_locationt source_location; - + // if satisified, we compute a goto_trace bool satisfied; - + goalt( const std::string &_description, const source_locationt &_source_location): @@ -88,12 +88,12 @@ class bmc_covert: satisfied(false) { } - + goalt():source_location(source_locationt::nil()), satisfied(false) { } - + exprt as_expr() const { std::vector tmp; @@ -110,7 +110,7 @@ class bmc_covert: goto_tracet goto_trace; std::vector covered_goals; }; - + inline irep_idt id(goto_programt::const_targett loc) { return loc->source_location.get_property_id(); @@ -120,7 +120,7 @@ class bmc_covert: goal_mapt goal_map; typedef std::vector testst; testst tests; - + std::string get_test(const goto_tracet &goto_trace) const { bool first=true; @@ -169,15 +169,15 @@ void bmc_covert::satisfying_assignment() for(auto &g_it : goal_map) { goalt &g=g_it.second; - + // covered already? if(g.satisfied) continue; - + // check whether satisfied for(const auto &c_it : g.instances) { literalt cond=c_it.condition; - + if(solver.l_get(cond).is_true()) { status() << "Covered " << g.description << messaget::eom; @@ -188,7 +188,7 @@ void bmc_covert::satisfying_assignment() } } - build_goto_trace(bmc.equation, bmc.equation.SSA_steps.end(), + build_goto_trace(bmc.equation, bmc.equation.SSA_steps.end(), solver, bmc.ns, test.goto_trace); goto_tracet &goto_trace=test.goto_trace; @@ -206,7 +206,7 @@ void bmc_covert::satisfying_assignment() s_it2=s_it1; s_it2!=goto_trace.steps.end(); s_it2=goto_trace.steps.erase(s_it2)); - + break; } @@ -252,13 +252,13 @@ bool bmc_covert::operator()() for(auto & it : bmc.equation.SSA_steps) it.cond_literal=literalt(0, 0); - + // Do conversion to next solver layer - + bmc.do_conversion(); - + //bmc.equation.output(std::cout); - + // get the conditions for these goals from formula // collect all 'instances' of the goals for(auto it = bmc.equation.SSA_steps.begin(); @@ -276,24 +276,24 @@ bool bmc_covert::operator()() goal_map[id(it->source.pc)].add_instance(it, l_c); } } - + status() << "Aiming to cover " << goal_map.size() << " goal(s)" << eom; - + cover_goalst cover_goals(solver); - + cover_goals.register_observer(*this); - + for(const auto &it : goal_map) { literalt l=solver.convert(it.second.as_expr()); cover_goals.add(l); } - + assert(cover_goals.size()==goal_map.size()); status() << "Running " << solver.decision_procedure_text() << eom; - cover_goals(); + cover_goals(); // output runtime @@ -302,13 +302,13 @@ bool bmc_covert::operator()() status() << "Runtime decision procedure: " << (sat_stop-sat_start) << "s" << eom; } - + // report unsigned goals_covered=0; - + for(const auto & it : goal_map) if(it.second.satisfied) goals_covered++; - + switch(bmc.ui) { case ui_message_handlert::PLAIN: @@ -381,7 +381,7 @@ bool bmc_covert::operator()() xmlt &xml_goal=xml_result.new_element("goal"); xml_goal.set_attribute("id", id2string(goal_id)); } - + std::cout << xml_result << "\n"; } break; @@ -447,7 +447,7 @@ bool bmc_covert::operator()() << std::fixed << std::setw(1) << std::setprecision(1) << (goal_map.empty()?100.0:100.0*goals_covered/goal_map.size()) << "%)" << eom; - + statistics() << "** Used " << cover_goals.iterations() << " iteration" << (cover_goals.iterations()==1?"":"s") @@ -460,7 +460,7 @@ bool bmc_covert::operator()() for(const auto & test : tests) std::cout << get_test(test.goto_trace) << '\n'; } - + return false; } diff --git a/src/cbmc/cbmc_dimacs.cpp b/src/cbmc/cbmc_dimacs.cpp index 58bb5a74965..e411e733138 100644 --- a/src/cbmc/cbmc_dimacs.cpp +++ b/src/cbmc/cbmc_dimacs.cpp @@ -26,7 +26,7 @@ Function: cbmc_dimacst::write_dimacs \*******************************************************************/ bool cbmc_dimacst::write_dimacs(const std::string &filename) -{ +{ if(filename.empty() || filename=="-") return write_dimacs(std::cout); @@ -95,6 +95,6 @@ bool cbmc_dimacst::write_dimacs(std::ostream &out) out << "\n"; } - + return false; } diff --git a/src/cbmc/cbmc_languages.cpp b/src/cbmc/cbmc_languages.cpp index e9f4e9e9c50..a18d0344833 100644 --- a/src/cbmc/cbmc_languages.cpp +++ b/src/cbmc/cbmc_languages.cpp @@ -41,11 +41,11 @@ void cbmc_parse_optionst::register_languages() { register_language(new_ansi_c_language); register_language(new_cpp_language); - + #ifdef HAVE_SPECC register_language(new_specc_language); #endif - + #ifdef HAVE_JAVA_BYTECODE register_language(new_java_bytecode_language); #endif @@ -54,4 +54,3 @@ void cbmc_parse_optionst::register_languages() register_language(new_jsil_language); #endif } - diff --git a/src/cbmc/cbmc_main.cpp b/src/cbmc/cbmc_main.cpp index 2a379433c29..d09ecc4772e 100644 --- a/src/cbmc/cbmc_main.cpp +++ b/src/cbmc/cbmc_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: CBMC Main Module +Module: CBMC Main Module Author: Daniel Kroening, kroening@kroening.com diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp index 948abda07d1..09f2f17812d 100644 --- a/src/cbmc/cbmc_parse_options.cpp +++ b/src/cbmc/cbmc_parse_options.cpp @@ -75,7 +75,7 @@ cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv): ui_message_handler(cmdline, "CBMC " CBMC_VERSION) { } - + /*******************************************************************\ Function: cbmc_parse_optionst::cbmc_parse_optionst @@ -115,13 +115,13 @@ void cbmc_parse_optionst::eval_verbosity() { // this is our default verbosity unsigned int v=messaget::M_STATISTICS; - + if(cmdline.isset("verbosity")) { v=unsafe_string2unsigned(cmdline.get_value("verbosity")); if(v>10) v=10; } - + ui_message_handler.set_verbosity(v); } @@ -194,7 +194,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) if(cmdline.isset("localize-faults")) options.set_option("localize-faults", true); if(cmdline.isset("localize-faults-method")) - options.set_option("localize-faults-method", + options.set_option("localize-faults-method", cmdline.get_value("localize-faults-method")); if(cmdline.isset("unwind")) @@ -292,7 +292,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) // generate unwinding assumptions otherwise options.set_option("partial-loops", cmdline.isset("partial-loops")); - + if(options.get_bool_option("partial-loops") && options.get_bool_option("unwinding-assertions")) { @@ -448,7 +448,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) else options.set_option("sat-preprocessor", true); - options.set_option("pretty-names", + options.set_option("pretty-names", !cmdline.isset("no-pretty-names")); if(cmdline.isset("outfile")) @@ -477,7 +477,7 @@ int cbmc_parse_optionst::doit() std::cout << CBMC_VERSION << std::endl; return 0; // should contemplate EX_OK from sysexits.h } - + // // command line options // @@ -506,12 +506,12 @@ int cbmc_parse_optionst::doit() " hardware modules. Please use hw-cbmc." << eom; return 1; // should contemplate EX_USAGE from sysexits.h } - + register_languages(); - + if(cmdline.isset("test-preprocessor")) return test_c_preprocessor(ui_message_handler)?8:0; - + if(cmdline.isset("preprocess")) { preprocessing(); @@ -525,12 +525,12 @@ int cbmc_parse_optionst::doit() cbmc_solvers.set_ui(get_ui()); std::unique_ptr cbmc_solver; - + try { cbmc_solver=cbmc_solvers.get_solver(); } - + catch(const char *error_msg) { error() << error_msg << eom; @@ -560,11 +560,11 @@ int cbmc_parse_optionst::doit() if(cmdline.isset("show-reachable-properties")) // may replace --show-properties { const namespacet ns(symbol_table); - + // Entry point will have been set before and function pointers removed status() << "Removing Unused Functions" << eom; remove_unused_functions(goto_functions, ui_message_handler); - + show_properties(ns, get_ui(), goto_functions); return 0; // should contemplate EX_OK from sysexits.h } @@ -610,12 +610,12 @@ bool cbmc_parse_optionst::set_properties(goto_functionst &goto_functions) error() << e << eom; return true; } - + catch(int) { return true; } - + return false; } @@ -630,7 +630,7 @@ Function: cbmc_parse_optionst::get_goto_program Purpose: \*******************************************************************/ - + int cbmc_parse_optionst::get_goto_program( const optionst &options, bmct &bmc, // for get_modules @@ -652,41 +652,41 @@ int cbmc_parse_optionst::get_goto_program( error() << "Please give exactly one source file" << eom; return 6; } - + std::string filename=cmdline.args[0]; - + #ifdef _MSC_VER std::ifstream infile(widen(filename)); #else std::ifstream infile(filename); #endif - + if(!infile) { - error() << "failed to open input file `" + error() << "failed to open input file `" << filename << "'" << eom; return 6; } - + languaget *language=get_language_from_filename(filename); - + if(language==NULL) { - error() << "failed to figure out type of file `" + error() << "failed to figure out type of file `" << filename << "'" << eom; return 6; } - + language->set_message_handler(get_message_handler()); - + status("Parsing", filename); - + if(language->parse(infile, filename)) { error() << "PARSING ERROR" << eom; return 6; } - + language->show_parse(std::cout); return 0; } @@ -728,7 +728,7 @@ int cbmc_parse_optionst::get_goto_program( { status() << "Reading GOTO program from file " << eom; - if(read_object_and_link(*it, symbol_table, goto_functions, + if(read_object_and_link(*it, symbol_table, goto_functions, get_message_handler())) return 6; } @@ -776,18 +776,18 @@ int cbmc_parse_optionst::get_goto_program( error() << e << eom; return 6; } - + catch(int) { return 6; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return 6; } - + return -1; // no error, continue } @@ -802,7 +802,7 @@ Function: cbmc_parse_optionst::preprocessing Purpose: \*******************************************************************/ - + void cbmc_parse_optionst::preprocessing() { try @@ -830,11 +830,11 @@ void cbmc_parse_optionst::preprocessing() error() << "failed to figure out type of file" << eom; return; } - + ptr->set_message_handler(get_message_handler()); std::unique_ptr language(ptr); - + if(language->preprocess(infile, filename, std::cout)) error() << "PREPROCESSING ERROR" << eom; } @@ -848,7 +848,7 @@ void cbmc_parse_optionst::preprocessing() { error() << e << eom; } - + catch(int) { } @@ -870,7 +870,7 @@ Function: cbmc_parse_optionst::process_goto_program Purpose: \*******************************************************************/ - + bool cbmc_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -878,13 +878,13 @@ bool cbmc_parse_optionst::process_goto_program( try { namespacet ns(symbol_table); - + // Remove inline assembler; this needs to happen before // adding the library. remove_asm(symbol_table, goto_functions); // add the library - status() << "Adding CPROVER library (" + status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom; link_to_library(symbol_table, goto_functions, ui_message_handler); @@ -904,20 +904,20 @@ bool cbmc_parse_optionst::process_goto_program( status() << "Performing a full slice" << eom; full_slicer(goto_functions, ns); } - + // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); - + // remove returns, gcc vectors, complex remove_returns(symbol_table, goto_functions); remove_vector(symbol_table, goto_functions); remove_complex(symbol_table, goto_functions); - + // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); - + // ignore default/user-specified initialization // of variables with static lifetime if(cmdline.isset("nondet-static")) @@ -937,24 +937,24 @@ bool cbmc_parse_optionst::process_goto_program( // add failed symbols // needs to be done before pointer analysis add_failed_symbols(symbol_table); - + // recalculate numbers, etc. goto_functions.update(); - + // add loop ids goto_functions.compute_loop_numbers(); - + // instrument cover goals - + if(cmdline.isset("cover")) { std::list criteria_strings= cmdline.get_values("cover"); - + std::set criteria; - + for(const auto & criterion_string : criteria_strings) - { + { coverage_criteriont c; if(criterion_string=="assertion" || criterion_string=="assertions") @@ -967,7 +967,7 @@ bool cbmc_parse_optionst::process_goto_program( c=coverage_criteriont::LOCATION; else if(criterion_string=="decision" || criterion_string=="decisions") c=coverage_criteriont::DECISION; - else if(criterion_string=="condition" || criterion_string=="conditions") + else if(criterion_string=="condition" || criterion_string=="conditions") c=coverage_criteriont::CONDITION; else if(criterion_string=="mcdc") c=coverage_criteriont::MCDC; @@ -978,7 +978,7 @@ bool cbmc_parse_optionst::process_goto_program( error() << "unknown coverage criterion" << eom; return true; } - + criteria.insert(c); } @@ -1006,18 +1006,18 @@ bool cbmc_parse_optionst::process_goto_program( error() << e << eom; return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -1069,11 +1069,11 @@ void cbmc_parse_optionst::help() std::cout << "\n" "* * CBMC " CBMC_VERSION " - Copyright (C) 2001-2016 "; - + std::cout << "(" << (sizeof(void *)*8) << "-bit version)"; - + std::cout << " * *\n"; - + std::cout << "* * Daniel Kroening, Edmund Clarke * *\n" "* * Carnegie Mellon University, Computer Science Department * *\n" diff --git a/src/cbmc/cbmc_parse_options.h b/src/cbmc/cbmc_parse_options.h index 64b870784be..1a4b9477cfd 100644 --- a/src/cbmc/cbmc_parse_options.h +++ b/src/cbmc/cbmc_parse_options.h @@ -87,17 +87,17 @@ class cbmc_parse_optionst: virtual bool process_goto_program( const optionst &options, goto_functionst &goto_functions); - + bool set_properties(goto_functionst &goto_functions); - + void eval_verbosity(); - + // get any additional stuff before finalizing virtual int get_modules(bmct &bmc) { return -1; // continue } - + void preprocessing(); }; diff --git a/src/cbmc/cbmc_solvers.cpp b/src/cbmc/cbmc_solvers.cpp index 30bf9486c39..95d9b35cf38 100644 --- a/src/cbmc/cbmc_solvers.cpp +++ b/src/cbmc/cbmc_solvers.cpp @@ -43,7 +43,7 @@ smt1_dect::solvert cbmc_solverst::get_smt1_solver_type() const assert(options.get_bool_option("smt1")); smt1_dect::solvert s = smt1_dect::GENERIC; - + if(options.get_bool_option("boolector")) s = smt1_dect::BOOLECTOR; else if(options.get_bool_option("mathsat")) @@ -81,7 +81,7 @@ smt2_dect::solvert cbmc_solverst::get_smt2_solver_type() const assert(options.get_bool_option("smt2")); smt2_dect::solvert s = smt2_dect::GENERIC; - + if(options.get_bool_option("boolector")) s = smt2_dect::BOOLECTOR; else if(options.get_bool_option("mathsat")) @@ -122,7 +122,7 @@ class cbmc_solver_with_propt: public cbmc_solverst::solvert { assert(_prop!=NULL); } - + ~cbmc_solver_with_propt() { delete prop; @@ -213,21 +213,21 @@ Function: cbmc_solverst::get_default cbmc_solverst::solvert* cbmc_solverst::get_default() { solvert *solver; - - if(options.get_bool_option("beautify") || + + if(options.get_bool_option("beautify") || !options.get_bool_option("sat-preprocessor")) // no simplifier { // simplifier won't work with beautification propt* prop = new satcheck_no_simplifiert(); prop->set_message_handler(get_message_handler()); - + bv_cbmct* bv_cbmc = new bv_cbmct(ns, *prop); - + if(options.get_option("arrays-uf")=="never") bv_cbmc->unbounded_array=bv_cbmct::U_NONE; else if(options.get_option("arrays-uf")=="always") bv_cbmc->unbounded_array=bv_cbmct::U_ALL; - + solver = new cbmc_solver_with_propt(bv_cbmc, prop); } else // with simplifier @@ -265,7 +265,7 @@ Function: cbmc_solverst::get_dimacs Purpose: \*******************************************************************/ - + cbmc_solverst::solvert* cbmc_solverst::get_dimacs() { no_beautification(); @@ -273,9 +273,9 @@ cbmc_solverst::solvert* cbmc_solverst::get_dimacs() dimacs_cnft *prop=new dimacs_cnft(); prop->set_message_handler(get_message_handler()); - + std::string filename=options.get_option("outfile"); - + return new cbmc_solver_with_propt(new cbmc_dimacst(ns, *prop, filename), prop); } @@ -290,7 +290,7 @@ Function: cbmc_solverst::get_bv_refinement Purpose: \*******************************************************************/ - + cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() { propt *prop; @@ -303,20 +303,20 @@ cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() } else prop=new satcheck_no_simplifiert(); - + prop->set_message_handler(get_message_handler()); bv_refinementt *bv_refinement = new bv_refinementt(ns, *prop); bv_refinement->set_ui(ui); - // we allow setting some parameters + // we allow setting some parameters if(options.get_option("max-node-refinement")!="") - bv_refinement->max_node_refinement = + bv_refinement->max_node_refinement = options.get_unsigned_int_option("max-node-refinement"); - bv_refinement->do_array_refinement = + bv_refinement->do_array_refinement = options.get_bool_option("refine-arrays"); - bv_refinement->do_arithmetic_refinement = + bv_refinement->do_arithmetic_refinement = options.get_bool_option("refine-arithmetic"); return new cbmc_solver_with_propt(bv_refinement, prop); @@ -333,14 +333,14 @@ Function: cbmc_solverst::get_smt1 Purpose: \*******************************************************************/ - + cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) { no_beautification(); no_incremental_check(); const std::string &filename=options.get_option("outfile"); - + if(filename=="") { if(solver==smt1_dect::GENERIC) @@ -379,7 +379,7 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) #else std::ofstream *out=new std::ofstream(filename); #endif - + if(!out) { error() << "failed to open " << filename << eom; @@ -399,7 +399,7 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) return new cbmc_solver_with_filet(smt1_conv, out); } } - + /*******************************************************************\ Function: cbmc_solverst::get_smt2 @@ -411,13 +411,13 @@ Function: cbmc_solverst::get_smt2 Purpose: \*******************************************************************/ - + cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) { no_beautification(); const std::string &filename=options.get_option("outfile"); - + if(filename=="") { if(solver==smt2_dect::GENERIC) @@ -425,7 +425,7 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) error() << "please use --outfile" << eom; throw 0; } - + smt2_dect* smt2_dec = new smt2_dect( ns, "cbmc", @@ -462,7 +462,7 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) #else std::ofstream *out=new std::ofstream(filename); #endif - + if(!*out) { error() << "failed to open " << filename << eom; diff --git a/src/cbmc/cbmc_solvers.h b/src/cbmc/cbmc_solvers.h index e121b8fa2af..765b3bbfd13 100644 --- a/src/cbmc/cbmc_solvers.h +++ b/src/cbmc/cbmc_solvers.h @@ -33,7 +33,7 @@ Author: Daniel Kroening, kroening@kroening.com Solver factory \*******************************************************************/ - + class cbmc_solverst:public messaget { public: @@ -66,7 +66,7 @@ class cbmc_solverst:public messaget //use this to get the prop_conv prop_convt& prop_conv() const - { + { assert(prop_conv_ptr!=NULL); return *prop_conv_ptr; } @@ -82,20 +82,20 @@ class cbmc_solverst:public messaget if(options.get_bool_option("dimacs")) solver = get_dimacs(); - else if(options.get_bool_option("refine")) + else if(options.get_bool_option("refine")) solver = get_bv_refinement(); - else if(options.get_bool_option("smt1")) + else if(options.get_bool_option("smt1")) solver = get_smt1(get_smt1_solver_type()); else if(options.get_bool_option("smt2")) solver = get_smt2(get_smt2_solver_type()); else solver = get_default(); - return std::unique_ptr(solver); + return std::unique_ptr(solver); } virtual ~cbmc_solverst() - { + { } void set_ui(language_uit::uit _ui) { ui=_ui; } diff --git a/src/cbmc/counterexample_beautification.cpp b/src/cbmc/counterexample_beautification.cpp index e431745945f..fe86e313f58 100644 --- a/src/cbmc/counterexample_beautification.cpp +++ b/src/cbmc/counterexample_beautification.cpp @@ -46,7 +46,7 @@ void counterexample_beautificationt::get_minimization_list( if(!prop_conv.l_get(it->guard_literal).is_false()) { const typet &type=it->ssa_lhs.type(); - + if(type!=bool_typet()) { // we minimize the absolute value, if applicable @@ -95,7 +95,7 @@ counterexample_beautificationt::get_failed_property( prop_conv.l_get(it->guard_literal).is_true() && prop_conv.l_get(it->cond_literal).is_false()) return it; - + assert(false); return equation.SSA_steps.end(); } @@ -120,7 +120,7 @@ void counterexample_beautificationt::operator()( // find failed property failed=get_failed_property(bv_cbmc, equation); - + // lock the failed assertion bv_cbmc.set_to(literal_exprt(failed->cond_literal), false); @@ -151,7 +151,7 @@ void counterexample_beautificationt::operator()( // give to propositional minimizer prop_minimizet prop_minimize(bv_cbmc); prop_minimize.set_message_handler(bv_cbmc.get_message_handler()); - + for(guard_countt::const_iterator it=guard_count.begin(); it!=guard_count.end(); @@ -168,9 +168,9 @@ void counterexample_beautificationt::operator()( // get symbols we care about minimization_listt minimization_list; - + get_minimization_list(bv_cbmc, equation, minimization_list); - + // minimize bv_minimizet bv_minimize(bv_cbmc); bv_minimize.set_message_handler(bv_cbmc.get_message_handler()); diff --git a/src/cbmc/counterexample_beautification.h b/src/cbmc/counterexample_beautification.h index f3450af60a9..92da4db8319 100644 --- a/src/cbmc/counterexample_beautification.h +++ b/src/cbmc/counterexample_beautification.h @@ -32,7 +32,7 @@ class counterexample_beautificationt protected: void get_minimization_list( prop_convt &prop_conv, - const symex_target_equationt &equation, + const symex_target_equationt &equation, minimization_listt &minimization_list); void minimize( diff --git a/src/cbmc/fault_localization.cpp b/src/cbmc/fault_localization.cpp index 555924a0520..1554efa4b13 100644 --- a/src/cbmc/fault_localization.cpp +++ b/src/cbmc/fault_localization.cpp @@ -103,7 +103,7 @@ fault_localizationt::get_failed_property() bmc.prop_conv.l_get(it->guard_literal).is_true() && bmc.prop_conv.l_get(it->cond_literal).is_false()) return it; - + assert(false); return bmc.equation.SSA_steps.end(); } @@ -120,7 +120,7 @@ Function: fault_localizationt::check \*******************************************************************/ -bool fault_localizationt::check(const lpointst &lpoints, +bool fault_localizationt::check(const lpointst &lpoints, const lpoints_valuet& value) { assert(value.size()==lpoints.size()); @@ -273,7 +273,7 @@ void fault_localizationt::report(irep_idt goal_id) lpointt &max=lpoints.begin()->second; for(auto &l : lpoints) { - debug() << l.second.target->source_location + debug() << l.second.target->source_location << "\n score: " << l.second.score << eom; if(max.scorecond_literal; - + if(solver.l_get(cond).is_false()) { g.second.status=goalt::statust::FAILURE; symex_target_equationt::SSA_stepst::iterator next=c; next++; // include the assertion - build_goto_trace(bmc.equation, next, solver, bmc.ns, + build_goto_trace(bmc.equation, next, solver, bmc.ns, g.second.goto_trace); //localize faults @@ -468,4 +468,3 @@ void fault_localizationt::report( break; } } - diff --git a/src/cbmc/fault_localization.h b/src/cbmc/fault_localization.h index d57a8a493a1..69251e67d5e 100644 --- a/src/cbmc/fault_localization.h +++ b/src/cbmc/fault_localization.h @@ -29,8 +29,8 @@ class fault_localizationt: const optionst &_options) : bmc_all_propertiest(_goto_functions, _bmc.prop_conv, _bmc), - goto_functions(_goto_functions), - bmc(_bmc), + goto_functions(_goto_functions), + bmc(_bmc), options(_options) { set_message_handler(bmc.get_message_handler()); @@ -90,7 +90,7 @@ class fault_localizationt: virtual void report(const cover_goalst &cover_goals); //override bmc_all_propertiest - virtual void do_before_solving() + virtual void do_before_solving() { freeze_guards(); } diff --git a/src/cbmc/show_vcc.cpp b/src/cbmc/show_vcc.cpp index 54f8c2a1f83..28e460774e5 100644 --- a/src/cbmc/show_vcc.cpp +++ b/src/cbmc/show_vcc.cpp @@ -37,7 +37,7 @@ void bmct::show_vcc_plain(std::ostream &out) out << "\n" << "VERIFICATION CONDITIONS:" << "\n" << "\n"; languagest languages(ns, new_ansi_c_language()); - + bool has_threads=equation.has_threads(); for(symex_target_equationt::SSA_stepst::iterator @@ -46,20 +46,20 @@ void bmct::show_vcc_plain(std::ostream &out) s_it++) { if(!s_it->is_assert()) continue; - + if(s_it->source.pc->source_location.is_not_nil()) out << s_it->source.pc->source_location << "\n"; - + if(s_it->comment!="") out << s_it->comment << "\n"; - + symex_target_equationt::SSA_stepst::const_iterator p_it=equation.SSA_steps.begin(); // we show everything in case there are threads symex_target_equationt::SSA_stepst::const_iterator last_it=has_threads?equation.SSA_steps.end():s_it; - + for(unsigned count=1; p_it!=last_it; p_it++) if(p_it->is_assume() || p_it->is_assignment() || p_it->is_constraint()) if(!p_it->ignore) @@ -73,7 +73,7 @@ void bmct::show_vcc_plain(std::ostream &out) out << "GUARD: " << string_value << "\n"; out << "\n"; #endif - + count++; } @@ -82,7 +82,7 @@ void bmct::show_vcc_plain(std::ostream &out) std::string string_value; languages.from_expr(s_it->cond_expr, string_value); out << "{" << 1 << "} " << string_value << "\n"; - + out << "\n"; } } diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 0c55384dea2..b4ae665079e 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -87,10 +87,10 @@ bool symex_bmct::get_unwind( // and 'infinity' when we have none. unsigned this_loop_limit=std::numeric_limits::max(); - + loop_limitst &this_thread_limits= thread_loop_limits[source.thread_nr]; - + loop_limitst::const_iterator l_it=this_thread_limits.find(id); if(l_it!=this_thread_limits.end()) this_loop_limit=l_it->second; @@ -142,7 +142,7 @@ bool symex_bmct::get_unwind_recursion( loop_limitst &this_thread_limits= thread_loop_limits[thread_nr]; - + loop_limitst::const_iterator l_it=this_thread_limits.find(id); if(l_it!=this_thread_limits.end()) this_loop_limit=l_it->second; @@ -165,7 +165,7 @@ bool symex_bmct::get_unwind_recursion( << " recursion " << symbol.display_name() << " iteration " << unwind; - + if(this_loop_limit!=std::numeric_limits::max()) statistics() << " (" << this_loop_limit << " max)"; diff --git a/src/cbmc/symex_bmc.h b/src/cbmc/symex_bmc.h index 78ee3de0f6e..919cd6f73f8 100644 --- a/src/cbmc/symex_bmc.h +++ b/src/cbmc/symex_bmc.h @@ -28,13 +28,13 @@ class symex_bmct: source_locationt last_source_location; // Control unwinding. - + void set_unwind_limit(unsigned limit) { max_unwind=limit; max_unwind_is_set=true; } - + void set_unwind_thread_loop_limit( unsigned thread_nr, const irep_idt &id, @@ -50,7 +50,7 @@ class symex_bmct: loop_limits[id]=limit; } -protected: +protected: // We have // 1) a global limit (max_unwind) // 2) a limit per loop, all threads @@ -62,7 +62,7 @@ class symex_bmct: typedef hash_map_cont loop_limitst; loop_limitst loop_limits; - + typedef std::map thread_loop_limitst; thread_loop_limitst thread_loop_limits; @@ -82,9 +82,9 @@ class symex_bmct: const irep_idt &identifier, const unsigned thread_nr, unsigned unwind); - + virtual void no_body(const irep_idt &identifier); - + hash_set_cont body_warnings; }; diff --git a/src/cbmc/xml_interface.cpp b/src/cbmc/xml_interface.cpp index 976584d9ec0..45c1d231caa 100644 --- a/src/cbmc/xml_interface.cpp +++ b/src/cbmc/xml_interface.cpp @@ -36,7 +36,7 @@ void xml_interfacet::get_xml_options(cmdlinet &cmdline) parse_xml(std::cin, "", message_handler, xml); get_xml_options(xml, cmdline); - + cmdline.set("xml-ui"); } } @@ -65,7 +65,7 @@ void xml_interfacet::get_xml_options( // recursive call get_xml_options(*e_it, cmdline); } - + if(xml.name=="valueOption") { std::string name=xml.get_attribute("name"); @@ -84,4 +84,3 @@ void xml_interfacet::get_xml_options( } } } - diff --git a/src/cbmc/xml_interface.h b/src/cbmc/xml_interface.h index 6c997db464e..b0307bd4e21 100644 --- a/src/cbmc/xml_interface.h +++ b/src/cbmc/xml_interface.h @@ -18,7 +18,7 @@ class xml_interfacet { get_xml_options(_cmdline); } - + protected: void get_xml_options(cmdlinet &cmdline); void get_xml_options(const class xmlt &xml, cmdlinet &cmdline); diff --git a/src/cegis/Makefile b/src/cegis/Makefile index 8ce0716cfde..d222b8f77e5 100644 --- a/src/cegis/Makefile +++ b/src/cegis/Makefile @@ -81,7 +81,7 @@ SRC = danger/meta/meta_variable_names.cpp danger/facade/danger_runner.cpp danger instrument/cegis_library.cpp instrument/instrument_var_ops.cpp instrument/meta_variables.cpp \ instrument/find_cprover_initialize.cpp \ runner/cegis_parse_options.cpp runner/cegis_main.cpp runner/cegis_languages.cpp - + OBJ += ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ ../java_bytecode/java_bytecode$(LIBEXT) \ @@ -141,4 +141,3 @@ endif cegis$(EXEEXT): $(OBJ) $(LINKBIN) - diff --git a/src/cegis/runner/cegis_languages.cpp b/src/cegis/runner/cegis_languages.cpp index c31d4159cb4..cdf90e27426 100644 --- a/src/cegis/runner/cegis_languages.cpp +++ b/src/cegis/runner/cegis_languages.cpp @@ -33,9 +33,8 @@ void cbmc_parse_optionst::register_languages() { register_language(new_ansi_c_language); register_language(new_cpp_language); - + #ifdef HAVE_JAVA_BYTECODE register_language(new_java_bytecode_language); #endif } - diff --git a/src/cegis/runner/cegis_main.cpp b/src/cegis/runner/cegis_main.cpp index 74b01c15806..1d285529a67 100644 --- a/src/cegis/runner/cegis_main.cpp +++ b/src/cegis/runner/cegis_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: CEGIS Main Module +Module: CEGIS Main Module Author: Daniel Kroening, kroening@kroening.com diff --git a/src/clobber/Makefile b/src/clobber/Makefile index 4b9849630f7..f9c76dda397 100644 --- a/src/clobber/Makefile +++ b/src/clobber/Makefile @@ -57,4 +57,3 @@ clobber$(EXEEXT): $(OBJ) clobber-mac-signed: cbmc$(EXEEXT) strip clobber$(EXEEXT) ; codesign -v -s $(OSX_IDENTITY) clobber$(EXEEXT) - diff --git a/src/clobber/clobber_main.cpp b/src/clobber/clobber_main.cpp index a18c66e7ebf..8255f068c92 100644 --- a/src/clobber/clobber_main.cpp +++ b/src/clobber/clobber_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: Symex Main Module +Module: Symex Main Module Author: Daniel Kroening, kroening@kroening.com diff --git a/src/clobber/clobber_parse_options.cpp b/src/clobber/clobber_parse_options.cpp index 6f134e4b8f0..8c9fb178dad 100644 --- a/src/clobber/clobber_parse_options.cpp +++ b/src/clobber/clobber_parse_options.cpp @@ -56,7 +56,7 @@ clobber_parse_optionst::clobber_parse_optionst(int argc, const char **argv): language_uit("CLOBBER " CBMC_VERSION, cmdline) { } - + /*******************************************************************\ Function: clobber_parse_optionst::eval_verbosity @@ -73,7 +73,7 @@ void clobber_parse_optionst::eval_verbosity() { // this is our default verbosity int v=messaget::M_STATISTICS; - + if(cmdline.isset("verbosity")) { v=unsafe_string2int(cmdline.getval("verbosity")); @@ -82,7 +82,7 @@ void clobber_parse_optionst::eval_verbosity() else if(v>10) v=10; } - + ui_message_handler.set_verbosity(v); } @@ -213,7 +213,7 @@ int clobber_parse_optionst::doit() if(get_goto_program(options, goto_functions)) return 6; - + label_properties(goto_functions); if(cmdline.isset("show-properties")) @@ -225,25 +225,25 @@ int clobber_parse_optionst::doit() if(set_properties(goto_functions)) return 7; - + // do instrumentation try { const namespacet ns(symbol_table); - + std::ofstream out("simulator.c"); - + if(!out) throw std::string("failed to create file simulator.c"); - + dump_c(goto_functions, true, ns, out); - + status() << "instrumentation complete; compile and execute simulator.c" << eom; - + return 0; } - + catch(const std::string error_msg) { error() << error_msg << messaget::eom; @@ -256,7 +256,7 @@ int clobber_parse_optionst::doit() return 8; } - #if 0 + #if 0 // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); @@ -295,12 +295,12 @@ bool clobber_parse_optionst::set_properties(goto_functionst &goto_functions) error(e); return true; } - + catch(int) { return true; } - + return false; } @@ -315,7 +315,7 @@ Function: clobber_parse_optionst::get_goto_program Purpose: \*******************************************************************/ - + bool clobber_parse_optionst::get_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -336,7 +336,7 @@ bool clobber_parse_optionst::get_goto_program( if(read_goto_binary(cmdline.args[0], symbol_table, goto_functions, get_message_handler())) return true; - + config.ansi_c.set_from_symbol_table(symbol_table); if(cmdline.isset("show-symbol-table")) @@ -344,9 +344,9 @@ bool clobber_parse_optionst::get_goto_program( show_symbol_table(); return true; } - + irep_idt entry_point=goto_functions.entry_point(); - + if(symbol_table.symbols.find(entry_point)==symbol_table.symbols.end()) { error() << "The goto binary has no entry point; please complete linking" << eom; @@ -360,45 +360,45 @@ bool clobber_parse_optionst::get_goto_program( error() << "Please give one source file only" << eom; return true; } - + std::string filename=cmdline.args[0]; - + #ifdef _MSC_VER std::ifstream infile(widen(filename)); #else std::ifstream infile(filename); #endif - + if(!infile) { error() << "failed to open input file `" << filename << "'" << eom; return true; } - + languaget *language=get_language_from_filename(filename); - + if(language==NULL) { error() << "failed to figure out type of file `" << filename << "'" << eom; return true; } - + language->set_message_handler(get_message_handler()); - + status("Parsing", filename); - + if(language->parse(infile, filename)) { error() << "PARSING ERROR" << eom; return true; } - + language->show_parse(std::cout); return true; } else { - + if(parse()) return true; if(typecheck()) return true; if(final()) return true; @@ -413,7 +413,7 @@ bool clobber_parse_optionst::get_goto_program( } irep_idt entry_point=goto_functions.entry_point(); - + if(symbol_table.symbols.find(entry_point)==symbol_table.symbols.end()) { error() << "No entry point; please provide a main function" << eom; @@ -446,18 +446,18 @@ bool clobber_parse_optionst::get_goto_program( error(e); return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -472,7 +472,7 @@ Function: clobber_parse_optionst::process_goto_program Purpose: \*******************************************************************/ - + bool clobber_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -484,20 +484,20 @@ bool clobber_parse_optionst::process_goto_program( // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); - + // add generic checks status() << "Generic Property Instrumentation" << eom; goto_check(ns, options, goto_functions); - + // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); - + // if we aim to cover, replace // all assertions by false to prevent simplification - + if(cmdline.isset("cover-assertions")) make_assertions_false(goto_functions); @@ -527,18 +527,18 @@ bool clobber_parse_optionst::process_goto_program( error(e); return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -611,10 +611,10 @@ void clobber_parse_optionst::report_properties( it++) if(it->second.status==path_searcht::FAIL) failed++; - + status() << "** " << failed << " of " << property_map.size() << " failed" - << eom; + << eom; } } #endif @@ -639,7 +639,7 @@ void clobber_parse_optionst::report_success() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -648,7 +648,7 @@ void clobber_parse_optionst::report_success() std::cout << std::endl; } break; - + default: assert(false); } @@ -677,7 +677,7 @@ void clobber_parse_optionst::show_counterexample( std::cout << std::endl << "Counterexample:" << std::endl; show_goto_trace(std::cout, ns, error_trace); break; - + case ui_message_handlert::XML_UI: { xmlt xml; @@ -685,7 +685,7 @@ void clobber_parse_optionst::show_counterexample( std::cout << xml << std::endl; } break; - + default: assert(false); } @@ -711,7 +711,7 @@ void clobber_parse_optionst::report_failure() { case ui_message_handlert::PLAIN: break; - + case ui_message_handlert::XML_UI: { xmlt xml("cprover-status"); @@ -720,7 +720,7 @@ void clobber_parse_optionst::report_failure() std::cout << std::endl; } break; - + default: assert(false); } @@ -743,11 +743,11 @@ void clobber_parse_optionst::help() std::cout << "\n" "* * CLOBBER " CBMC_VERSION " - Copyright (C) 2014 "; - + std::cout << "(" << (sizeof(void *)*8) << "-bit version)"; - + std::cout << " * *\n"; - + std::cout << "* * Daniel Kroening * *\n" "* * University of Oxford * *\n" diff --git a/src/clobber/clobber_parse_options.h b/src/clobber/clobber_parse_options.h index 8d0daf3ca3b..d00db917084 100644 --- a/src/clobber/clobber_parse_options.h +++ b/src/clobber/clobber_parse_options.h @@ -53,13 +53,13 @@ class clobber_parse_optionst: bool process_goto_program( const optionst &options, goto_functionst &goto_functions); - + bool set_properties(goto_functionst &goto_functions); void report_success(); void report_failure(); void show_counterexample(const class goto_tracet &); - + void eval_verbosity(); }; diff --git a/src/config.inc b/src/config.inc index ccd224fedff..440d36082df 100644 --- a/src/config.inc +++ b/src/config.inc @@ -6,7 +6,7 @@ BUILD_ENV = AUTO #CXXFLAGS = -std=c++11 # If GLPK is available; this is used by goto-instrument and musketeer. -#LIB_GLPK = -lglpk +#LIB_GLPK = -lglpk # SAT-solvers we have #PRECOSAT = ../../precosat-576-7e5e66f-120112 diff --git a/src/cpp/cpp_constructor.cpp b/src/cpp/cpp_constructor.cpp index 62f084b6c74..3de7a374e35 100644 --- a/src/cpp/cpp_constructor.cpp +++ b/src/cpp/cpp_constructor.cpp @@ -77,7 +77,7 @@ codet cpp_typecheckt::cpp_constructor( nil.make_nil(); return nil; } - + exprt tmp_size=size_expr; make_constant_index(tmp_size); @@ -182,7 +182,7 @@ codet cpp_typecheckt::cpp_constructor( "but got " << operands.size() << eom; throw 0; } - + return new_code; } else if(tmp_type.id()==ID_union) diff --git a/src/cpp/cpp_convert_type.cpp b/src/cpp/cpp_convert_type.cpp index e247999b141..dbc9effe910 100644 --- a/src/cpp/cpp_convert_type.cpp +++ b/src/cpp/cpp_convert_type.cpp @@ -64,7 +64,7 @@ void cpp_convert_typet::read(const typet &type) ptr32_cnt=ptr64_cnt=float128_cnt=int128_cnt=0; other.clear(); - + #if 0 std::cout << "cpp_convert_typet::read: " << type.pretty() << std::endl; #endif @@ -353,9 +353,9 @@ Function: cpp_convert_typet::write void cpp_convert_typet::write(typet &type) { type.clear(); - + // first, do "other" - + if(!other.empty()) { if(double_cnt || float_cnt || signed_cnt || diff --git a/src/cpp/cpp_declaration.cpp b/src/cpp/cpp_declaration.cpp index 67705310338..1a06fbaa36d 100644 --- a/src/cpp/cpp_declaration.cpp +++ b/src/cpp/cpp_declaration.cpp @@ -61,15 +61,15 @@ void cpp_declarationt::name_anon_struct_union(typet &dest) if(dest.find(ID_tag).is_nil()) { // it's anonymous - + const declaratorst &d=declarators(); - + if(!d.empty() && d.front().name().is_simple_name()) { // Anon struct/unions without declarator are pretty // useless, but still possible. - + irep_idt base_name="anon-"+id2string(d.front().name().get_base_name()); dest.set(ID_tag, cpp_namet(base_name)); dest.set(ID_C_is_anonymous, true); diff --git a/src/cpp/cpp_declaration.h b/src/cpp/cpp_declaration.h index 8384eab677f..f60bfc868b7 100644 --- a/src/cpp/cpp_declaration.h +++ b/src/cpp/cpp_declaration.h @@ -25,7 +25,7 @@ class cpp_declarationt:public exprt inline cpp_declarationt():exprt(ID_cpp_declaration) { } - + inline bool is_empty() const { return type().is_nil() && !has_operands(); @@ -35,29 +35,29 @@ class cpp_declarationt:public exprt { return type().id()==ID_constructor; } - + inline bool is_static_assert() const { return get_bool(ID_is_static_assert); } - + inline bool is_destructor() const { return type().id()==ID_destructor; } - + inline bool is_template() const { return get_bool(ID_is_template); } - + inline bool is_class_template() const { return is_template() && type().id()==ID_struct && declarators().empty(); } - + inline const declaratorst &declarators() const { return (const declaratorst &)operands(); @@ -67,7 +67,7 @@ class cpp_declarationt:public exprt { return (declaratorst &)operands(); } - + inline const cpp_storage_spect &storage_spec() const { return static_cast( @@ -121,12 +121,12 @@ class cpp_declarationt:public exprt { return get("specialization_of"); } - + void set_is_typedef() { set(ID_is_typedef, true); } - + bool is_typedef() const { return get_bool(ID_is_typedef); diff --git a/src/cpp/cpp_declarator.h b/src/cpp/cpp_declarator.h index 2f0a2587908..464fdc9d9d9 100644 --- a/src/cpp/cpp_declarator.h +++ b/src/cpp/cpp_declarator.h @@ -22,20 +22,20 @@ class cpp_declaratort:public exprt name().make_nil(); add_source_location().make_nil(); } - + explicit cpp_declaratort(const typet &type):exprt(ID_cpp_declarator, type) { value().make_nil(); name().make_nil(); add_source_location().make_nil(); } - + cpp_namet &name() { return static_cast(add(ID_name)); } const cpp_namet &name() const { return static_cast(find(ID_name)); } - + exprt &value() { return static_cast(add(ID_value)); } const exprt &value() const { return static_cast(find(ID_value)); } - + // initializers for function arguments exprt &init_args() { return static_cast(add("init_args")); } const exprt &init_args() const { return static_cast(find("init_args")); } @@ -50,7 +50,7 @@ class cpp_declaratort:public exprt const irept &throw_decl() const { return find("throw_decl"); } void output(std::ostream &out) const; - + typet merge_type(const typet &declaration_type) const; }; diff --git a/src/cpp/cpp_declarator_converter.cpp b/src/cpp/cpp_declarator_converter.cpp index 33086c981b2..29826d7b78e 100644 --- a/src/cpp/cpp_declarator_converter.cpp +++ b/src/cpp/cpp_declarator_converter.cpp @@ -73,9 +73,9 @@ symbolt &cpp_declarator_convertert::convert( assert(declarator.id()==ID_cpp_declarator); final_type=declarator.merge_type(declaration_type); assert(final_type.is_not_nil()); - + cpp_template_args_non_tct template_args; - + // run resolver on scope { cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes); @@ -200,7 +200,7 @@ symbolt &cpp_declarator_convertert::convert( else { // no, it's no way a method - + // we won't allow the constructor/destructor type if(final_type.id()==ID_code && to_code_type(final_type).return_type().id()==ID_constructor) @@ -219,7 +219,7 @@ symbolt &cpp_declarator_convertert::convert( return convert_new_symbol(storage_spec, member_spec, declarator); symbolt &symbol=c_it->second; - + if(!storage_spec.is_extern()) symbol.is_extern = false; @@ -274,7 +274,7 @@ void cpp_declarator_convertert::combine_types( // to argument names, default values, and inlined-ness const code_typet &decl_code_type=to_code_type(decl_type); code_typet &symbol_code_type=to_code_type(symbol.type); - + if(decl_code_type.get_inlined()) symbol_code_type.set_inlined(true); @@ -393,7 +393,7 @@ void cpp_declarator_convertert::handle_initializer( // the symbol is really located here symbol.is_extern=false; } - + if(symbol.value.is_nil()) { // no initial value yet @@ -461,7 +461,7 @@ void cpp_declarator_convertert::get_final_identifier() // and the same signature? symbol_tablet::symbolst::const_iterator c_it=cpp_typecheck.symbol_table.symbols.find(identifier); - + if(c_it!=cpp_typecheck.symbol_table.symbols.end() && c_it->second.type.id()==ID_code && cpp_typecheck.function_identifier(final_type)== @@ -513,12 +513,12 @@ symbolt &cpp_declarator_convertert::convert_new_symbol( symbol.is_type=is_typedef; symbol.is_macro=is_typedef && !is_template_parameter; symbol.pretty_name=pretty_name; - + // Constant? These are propagated. if(symbol.type.get_bool(ID_C_constant) && symbol.value.is_not_nil()) symbol.is_macro=true; - + if(member_spec.is_inline()) symbol.type.set(ID_C_inlined, true); @@ -582,10 +582,10 @@ symbolt &cpp_declarator_convertert::convert_new_symbol( if(!is_code) { cpp_scopest::id_sett id_set; - + cpp_typecheck.cpp_scopes.current_scope().lookup( base_name, cpp_scopet::SCOPE_ONLY, id_set); - + for(cpp_scopest::id_sett::const_iterator id_it=id_set.begin(); id_it!=id_set.end(); diff --git a/src/cpp/cpp_destructor.cpp b/src/cpp/cpp_destructor.cpp index 94d14f4c652..a6b3c865a9d 100644 --- a/src/cpp/cpp_destructor.cpp +++ b/src/cpp/cpp_destructor.cpp @@ -57,7 +57,7 @@ codet cpp_typecheckt::cpp_destructor( new_code.make_nil(); return new_code; } - + exprt tmp_size=size_expr; make_constant_index(tmp_size); @@ -160,4 +160,3 @@ codet cpp_typecheckt::cpp_destructor( return new_code; } - diff --git a/src/cpp/cpp_enum_type.cpp b/src/cpp/cpp_enum_type.cpp index 1b0269c623b..ba4bc6ecbae 100644 --- a/src/cpp/cpp_enum_type.cpp +++ b/src/cpp/cpp_enum_type.cpp @@ -42,16 +42,16 @@ irep_idt cpp_enum_typet::generate_anon_tag() const { // This will only clash with anon enums that would have // clashes on the enum constants anyway. - + const irept::subt &b=body().get_sub(); - + std::string result="#anonE"; - + forall_irep(it, b) { result+='#'; result+=id2string(it->get(ID_name)); } - + return result; } diff --git a/src/cpp/cpp_enum_type.h b/src/cpp/cpp_enum_type.h index 70e50ff7b64..0a73d9c3d15 100644 --- a/src/cpp/cpp_enum_type.h +++ b/src/cpp/cpp_enum_type.h @@ -19,22 +19,22 @@ class cpp_enum_typet:public typet { public: cpp_enum_typet(); - + inline const cpp_namet &tag() const { return static_cast(find(ID_tag)); } - + inline bool has_tag() const { return find(ID_tag).is_not_nil(); } - + inline cpp_namet &tag() { return static_cast(add(ID_tag)); } - + const irept &body() const { return find(ID_body); @@ -44,7 +44,7 @@ class cpp_enum_typet:public typet { return add(ID_body); } - + bool has_body() const { return find(ID_body).is_not_nil(); @@ -54,7 +54,7 @@ class cpp_enum_typet:public typet { return get_bool(ID_C_tag_only_declaration); } - + irep_idt generate_anon_tag() const; }; diff --git a/src/cpp/cpp_exception_id.cpp b/src/cpp/cpp_exception_id.cpp index c67184736b1..d661103de3b 100644 --- a/src/cpp/cpp_exception_id.cpp +++ b/src/cpp/cpp_exception_id.cpp @@ -52,10 +52,10 @@ void cpp_exception_list_rec( { // just get tag dest.push_back("struct_"+src.get_string(ID_tag)); - + // now do any bases, recursively const irept::subt &bases=src.find(ID_bases).get_sub(); - + forall_irep(it, bases) { const typet &type=static_cast(it->find(ID_type)); @@ -66,13 +66,13 @@ void cpp_exception_list_rec( { // grab C/C++ type irep_idt c_type=src.get(ID_C_c_type); - + if(c_type!=irep_idt()) { dest.push_back(id2string(c_type)+suffix); return; } - + } } @@ -94,13 +94,13 @@ irept cpp_exception_list( { std::vector ids; irept result(ID_exception_list); - + cpp_exception_list_rec(src, ns, "", ids); result.get_sub().resize(ids.size()); for(unsigned i=0; i(cpp_scopes.id_map[template_symbol.name]); assert(template_scope!=NULL); - + irep_idt identifier= id2string(template_scope->prefix)+ "tag-"+id2string(template_symbol.base_name)+ id2string(suffix); - + // already there? symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(identifier); @@ -189,7 +189,7 @@ const symbolt &cpp_typecheckt::class_template_symbol( new_symbol.mode=template_symbol.mode; new_symbol.base_name=template_symbol.base_name; new_symbol.is_type=true; - + symbolt *s_ptr; symbol_table.move(new_symbol, s_ptr); @@ -203,7 +203,7 @@ const symbolt &cpp_typecheckt::class_template_symbol( id2string(suffix)+"::"; id.class_identifier=s_ptr->name; id.id_class=cpp_idt::CLASS; - + return *s_ptr; } @@ -211,7 +211,7 @@ const symbolt &cpp_typecheckt::class_template_symbol( Function: cpp_typecheckt::elaborate_class_template - Inputs: + Inputs: Outputs: @@ -223,12 +223,12 @@ void cpp_typecheckt::elaborate_class_template( const typet &type) { if(type.id()!=ID_symbol) return; - + const symbolt &symbol=lookup(type); - // Make a copy, as instantiate will destroy the symbol type! + // Make a copy, as instantiate will destroy the symbol type! const typet t_type=symbol.type; - + if(t_type.id()==ID_incomplete_struct && t_type.get_bool(ID_template_class_instance)) { @@ -248,7 +248,7 @@ Function: cpp_typecheckt::instantiate_template the identifier of the template symbol, typechecked template arguments, an (optional) specialization - + Outputs: Purpose: @@ -271,12 +271,12 @@ const symbolt &cpp_typecheckt::instantiate_template( << MAX_DEPTH << ")" << eom; throw 0; } - + instantiation_levelt i_level(instantiation_stack); instantiation_stack.back().source_location=source_location; instantiation_stack.back().identifier=template_symbol.name; instantiation_stack.back().full_template_args=full_template_args; - + #if 0 std::cout << "L: " << source_location << std::endl; std::cout << "I: " << template_symbol.name << std::endl; @@ -313,10 +313,10 @@ const symbolt &cpp_typecheckt::instantiate_template( << eom; throw 0; } - + // produce new symbol name std::string suffix=template_suffix(full_template_args); - + // we need the template scope to see the template parameters cpp_scopet *template_scope= static_cast(cpp_scopes.id_map[template_symbol.name]); @@ -328,13 +328,13 @@ const symbolt &cpp_typecheckt::instantiate_template( << "template instantiation error: scope not found" << eom; throw 0; } - + assert(template_scope!=NULL); // produce new declaration cpp_declarationt new_decl=to_cpp_declaration(template_symbol.type); - // The new one is not a template any longer, but we remember the + // The new one is not a template any longer, but we remember the // template type that was used. template_typet template_type=new_decl.template_type(); new_decl.remove(ID_is_template); @@ -364,7 +364,7 @@ const symbolt &cpp_typecheckt::instantiate_template( // sub-scope for fixing the prefix std::string subscope_name=id2string(template_scope->identifier)+suffix; - + // let's see if we have the instance already cpp_scopest::id_mapt::iterator scope_it= cpp_scopes.id_map.find(subscope_name); @@ -409,7 +409,7 @@ const symbolt &cpp_typecheckt::instantiate_template( cpp_scopes.id_map.insert( cpp_scopest::id_mapt::value_type(subscope_name, &sub_scope)); } - + // store the information that the template has // been instantiated using these arguments { @@ -423,7 +423,7 @@ const symbolt &cpp_typecheckt::instantiate_template( std::cout << "MAP:" << std::endl; template_map.print(std::cout); #endif - + // fix the type { typet declaration_type=new_decl.type(); @@ -456,7 +456,7 @@ const symbolt &cpp_typecheckt::instantiate_template( const exprt &template_methods= static_cast( template_symbol.value.find("template_methods")); - + for(unsigned i=0; i\"" << '\n'; - + // new and delete are in the root namespace! out << "void operator delete(void *);" << '\n'; - out << "void *operator new(__typeof__(sizeof(int)));" << '\n'; + out << "void *operator new(__typeof__(sizeof(int)));" << '\n'; // auxiliaries for new/delete - out << "extern \"C\" void *__new(__typeof__(sizeof(int)));" << '\n'; - out << "extern \"C\" void *__new_array(__typeof__(sizeof(int)), __typeof__(sizeof(int)));" << '\n'; - out << "extern \"C\" void *__placement_new(__typeof__(sizeof(int)), void *);" << '\n'; + out << "extern \"C\" void *__new(__typeof__(sizeof(int)));" << '\n'; + out << "extern \"C\" void *__new_array(__typeof__(sizeof(int)), __typeof__(sizeof(int)));" << '\n'; + out << "extern \"C\" void *__placement_new(__typeof__(sizeof(int)), void *);" << '\n'; out << "extern \"C\" void *__placement_new_array(__typeof__(sizeof(int)), __typeof__(sizeof(int)), void *);" << '\n'; - out << "extern \"C\" void __delete(void *);" << '\n'; - out << "extern \"C\" void __delete_array(void *);" << '\n'; + out << "extern \"C\" void __delete(void *);" << '\n'; + out << "extern \"C\" void __delete_array(void *);" << '\n'; out << "extern \"C\" bool __CPROVER_malloc_is_new_array=0;" << '\n'; - + // __CPROVER namespace out << "namespace __CPROVER { }" << '\n'; - + // types out << "typedef __typeof__(sizeof(int)) __CPROVER::size_t;" << '\n'; out << "typedef __typeof__(sizeof(int)) __CPROVER_size_t;" << '\n'; @@ -109,7 +109,7 @@ void cpp_internal_additions(std::ostream &out) out << "extern \"C\" bool __CPROVER_DYNAMIC_OBJECT(const void *p);" << '\n'; out << "extern \"C\" extern unsigned char __CPROVER_memory[__CPROVER::constant_infinity_uint];" << '\n'; out << "extern \"C\" const void *__CPROVER_dead_object=0;" << '\n'; - + // malloc out << "extern \"C\" void *__CPROVER_malloc(__CPROVER::size_t size);" << '\n'; out << "extern \"C\" const void *__CPROVER_deallocated=0;" << '\n'; @@ -117,13 +117,13 @@ void cpp_internal_additions(std::ostream &out) out << "extern \"C\" __CPROVER::size_t __CPROVER_malloc_size;" << '\n'; // float - out << "extern \"C\" int __CPROVER_rounding_mode;" << '\n'; + out << "extern \"C\" int __CPROVER_rounding_mode;" << '\n'; // arrays out << "bool __CPROVER::array_equal(const void array1[], const void array2[]);" << '\n'; out << "void __CPROVER::array_copy(const void dest[], const void src[]);" << '\n'; out << "void __CPROVER::array_set(const void dest[], ...);" << '\n'; - + // GCC stuff, but also for ARM if(config.ansi_c.mode==configt::ansi_ct::flavourt::GCC || config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE || @@ -134,11 +134,11 @@ void cpp_internal_additions(std::ostream &out) if(config.ansi_c.mode==configt::ansi_ct::flavourt::APPLE) out << "typedef double __float128;\n"; // clang doesn't do __float128 - + out << c2cpp(gcc_builtin_headers_ia32); out << "}" << '\n'; } - + // extensions for Visual C/C++ if(config.ansi_c.os==configt::ansi_ct::ost::OS_WIN) out << "extern \"C\" int __noop(...);\n"; @@ -146,28 +146,27 @@ void cpp_internal_additions(std::ostream &out) // string symbols to identify the architecture we have compiled for std::string architecture_strings; ansi_c_architecture_strings(architecture_strings); - + out << "extern \"C\" {" << '\n'; out << architecture_strings; out << "}" << '\n'; - + // Microsoft stuff if(config.ansi_c.mode==configt::ansi_ct::flavourt::VISUAL_STUDIO) { // type_info infrastructure -- the standard wants this to be in the // std:: namespace, but MS has it in the root namespace out << "class type_info;" << '\n'; - + // this is the return type of __uuidof(...), // in the root namespace out << "struct _GUID;" << '\n'; // MS ATL-related stuff out << "namespace ATL; " << '\n'; - out << "void ATL::AtlThrowImpl(long);" << '\n'; - out << "void __stdcall ATL::AtlThrowLastWin32();" << '\n'; + out << "void ATL::AtlThrowImpl(long);" << '\n'; + out << "void __stdcall ATL::AtlThrowLastWin32();" << '\n'; } - + out << std::flush; } - diff --git a/src/cpp/cpp_is_pod.cpp b/src/cpp/cpp_is_pod.cpp index f96e5b4ca0b..2b5c895611e 100644 --- a/src/cpp/cpp_is_pod.cpp +++ b/src/cpp/cpp_is_pod.cpp @@ -52,7 +52,7 @@ bool cpp_typecheckt::cpp_is_pod(const typet &type) const // * private/protected, unless static // * overloading assignment operator // * Base classes - + const struct_typet &struct_type=to_struct_type(type); if(!type.find(ID_bases).get_sub().empty()) @@ -74,7 +74,7 @@ bool cpp_typecheckt::cpp_is_pod(const typet &type) const if(it->get_bool(ID_is_virtual)) return false; - + const typet &sub_type=it->type(); if(sub_type.id()==ID_code) diff --git a/src/cpp/cpp_item.h b/src/cpp/cpp_item.h index 82138a786f7..3a4a9d5450e 100644 --- a/src/cpp/cpp_item.h +++ b/src/cpp/cpp_item.h @@ -21,30 +21,30 @@ class cpp_itemt:public irept { public: // declaration - + cpp_declarationt &make_declaration() { id(ID_cpp_declaration); return (cpp_declarationt &)*this; } - + cpp_declarationt &get_declaration() { assert(is_declaration()); return (cpp_declarationt &)*this; } - + const cpp_declarationt &get_declaration() const { assert(is_declaration()); return (const cpp_declarationt &)*this; } - + bool is_declaration() const { return id()==ID_cpp_declaration; } - + // linkage spec cpp_linkage_spect &make_linkage_spec() @@ -69,9 +69,9 @@ class cpp_itemt:public irept { return id()==ID_cpp_linkage_spec; } - + // namespace - + cpp_namespace_spect &make_namespace_spec() { id(ID_cpp_namespace_spec); @@ -96,7 +96,7 @@ class cpp_itemt:public irept } // using - + cpp_usingt &make_using() { id(ID_cpp_using); @@ -119,7 +119,7 @@ class cpp_itemt:public irept { return id()==ID_cpp_using; } - + // static assertion cpp_static_assertt &make_static_assert() @@ -138,13 +138,13 @@ class cpp_itemt:public irept { return id()==ID_cpp_static_assert; } - + const source_locationt &source_location() const { return static_cast( - find(ID_C_source_location)); + find(ID_C_source_location)); } - + }; #endif diff --git a/src/cpp/cpp_language.cpp b/src/cpp/cpp_language.cpp index b876a4a025a..cbabe644fa3 100644 --- a/src/cpp/cpp_language.cpp +++ b/src/cpp/cpp_language.cpp @@ -41,14 +41,14 @@ Function: cpp_languaget::extensions std::set cpp_languaget::extensions() const { std::set s; - + s.insert("cpp"); s.insert("CPP"); s.insert("cc"); s.insert("c++"); s.insert("ii"); s.insert("cxx"); - + #ifndef _WIN32 s.insert("C"); #endif diff --git a/src/cpp/cpp_language.h b/src/cpp/cpp_language.h index 2245cbec284..4f041a1ace2 100644 --- a/src/cpp/cpp_language.h +++ b/src/cpp/cpp_language.h @@ -38,7 +38,7 @@ class cpp_languaget:public languaget symbol_tablet &dest, symbol_tablet &src, const std::string &module, - class replace_symbolt &replace_symbol) const; + class replace_symbolt &replace_symbol) const; virtual bool final( symbol_tablet &symbol_table); diff --git a/src/cpp/cpp_linkage_spec.h b/src/cpp/cpp_linkage_spec.h index a4bfc382e7a..3303ec1de4b 100644 --- a/src/cpp/cpp_linkage_spec.h +++ b/src/cpp/cpp_linkage_spec.h @@ -15,7 +15,7 @@ class cpp_linkage_spect:public exprt cpp_linkage_spect():exprt(ID_cpp_linkage_spec) { } - + typedef std::vector itemst; const itemst &items() const @@ -27,7 +27,7 @@ class cpp_linkage_spect:public exprt { return (itemst &)operands(); } - + irept &linkage() { return add(ID_linkage); diff --git a/src/cpp/cpp_member_spec.h b/src/cpp/cpp_member_spec.h index 4c31bd396a6..5824b0e1b6a 100644 --- a/src/cpp/cpp_member_spec.h +++ b/src/cpp/cpp_member_spec.h @@ -28,7 +28,7 @@ class cpp_member_spect:public irept void set_inline(bool value) { set(ID_inline, value); } void set_friend(bool value) { set(ID_friend, value); } void set_explicit(bool value) { set(ID_explicit, value); } - + bool is_empty() const { return !is_virtual() && diff --git a/src/cpp/cpp_name.cpp b/src/cpp/cpp_name.cpp index 2219beabf6d..ae73ba3cbca 100644 --- a/src/cpp/cpp_name.cpp +++ b/src/cpp/cpp_name.cpp @@ -26,7 +26,7 @@ Function: cpp_namet::get_base_name irep_idt cpp_namet::get_base_name() const { const subt &sub=get_sub(); - + // find last "::" unsigned base=0; @@ -44,7 +44,7 @@ irep_idt cpp_namet::get_base_name() const else if(base+1get_string(ID_identifier); } - + return str; } diff --git a/src/cpp/cpp_name.h b/src/cpp/cpp_name.h index d5a9032cd91..c5430b62002 100644 --- a/src/cpp/cpp_name.h +++ b/src/cpp/cpp_name.h @@ -40,7 +40,7 @@ class cpp_namet:public irept set(ID_identifier, _base_name); add_source_location()=_source_location; } - + inline source_locationt &add_source_location() { return static_cast(add(ID_C_source_location)); @@ -55,7 +55,7 @@ class cpp_namet:public irept inline cpp_namet():irept(ID_cpp_name) { } - + inline explicit cpp_namet(const irep_idt &base_name):irept(ID_cpp_name) { get_sub().push_back(namet(base_name)); @@ -78,7 +78,7 @@ class cpp_namet:public irept //void convert(std::string &identifier, std::string &base_name) const; irep_idt get_base_name() const; - + // one of three: // 'identifier' // 'operator X' @@ -109,7 +109,7 @@ class cpp_namet:public irept return true; return false; } - + bool is_destructor() const { return get_sub().size()>=1 && get_sub().front().id()=="~"; @@ -125,7 +125,7 @@ class cpp_namet:public irept } std::string to_string() const; - + const exprt &as_expr() const { return static_cast(static_cast(*this)); diff --git a/src/cpp/cpp_namespace_spec.h b/src/cpp/cpp_namespace_spec.h index b56d3dbd525..821fa526870 100644 --- a/src/cpp/cpp_namespace_spec.h +++ b/src/cpp/cpp_namespace_spec.h @@ -20,7 +20,7 @@ class cpp_namespace_spect:public exprt { add("alias").make_nil(); } - + typedef std::vector itemst; inline const itemst &items() const @@ -32,7 +32,7 @@ class cpp_namespace_spect:public exprt { return (itemst &)operands(); } - + inline const irep_idt &get_namespace() const { return get(ID_namespace); @@ -42,19 +42,19 @@ class cpp_namespace_spect:public exprt { set(ID_namespace, _namespace); } - + inline cpp_namet &alias() { return static_cast(add("alias")); } - + inline const cpp_namet &alias() const { return static_cast(find("alias")); } - + void output(std::ostream &out) const; - + inline void set_is_inline(bool value) { set(ID_is_inline, value); diff --git a/src/cpp/cpp_parse_tree.cpp b/src/cpp/cpp_parse_tree.cpp index f00d85f94b4..33614a83f53 100644 --- a/src/cpp/cpp_parse_tree.cpp +++ b/src/cpp/cpp_parse_tree.cpp @@ -41,4 +41,3 @@ void cpp_parse_treet::clear() { items.clear(); } - diff --git a/src/cpp/cpp_parser.cpp b/src/cpp/cpp_parser.cpp index 93cb160d682..b72c6be6d5e 100644 --- a/src/cpp/cpp_parser.cpp +++ b/src/cpp/cpp_parser.cpp @@ -40,4 +40,3 @@ bool cpp_parsert::parse() return cpp_parse(); } - diff --git a/src/cpp/cpp_parser.h b/src/cpp/cpp_parser.h index e9d6c24c559..4656a0e93c5 100644 --- a/src/cpp/cpp_parser.h +++ b/src/cpp/cpp_parser.h @@ -35,35 +35,35 @@ class cpp_parsert:public parsert token_buffer.clear(); asm_block_following=false; } - + cpp_parsert(): mode(configt::ansi_ct::flavourt::ANSI), recognize_wchar_t(true), - asm_block_following(false) + asm_block_following(false) { } public: // internal state - ansi_c_parsert::modet mode; - + ansi_c_parsert::modet mode; + // We can furthermore twiddle the recognition of various // keywords. This is honored in particular modes. bool recognize_wchar_t; cpp_token_buffert token_buffer; - + cpp_tokent ¤t_token() { return token_buffer.current_token(); } - + void add_location() { token_buffer.current_token().line_no=get_line_no()-1; token_buffer.current_token().filename=source_location.get_file(); } - + // scanner unsigned parenthesis_counter; bool asm_block_following; diff --git a/src/cpp/cpp_scope.cpp b/src/cpp/cpp_scope.cpp index 29d548f0ec5..ee5185ade6e 100644 --- a/src/cpp/cpp_scope.cpp +++ b/src/cpp/cpp_scope.cpp @@ -30,7 +30,7 @@ std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind) case cpp_scopet::RECURSIVE: return out << "RECURSIVE"; default: assert(false); } - + return out; } @@ -66,8 +66,8 @@ void cpp_scopet::lookup( if(this->base_name==base_name) id_set.insert(this); - - if(kind==SCOPE_ONLY) return; // done + + if(kind==SCOPE_ONLY) return; // done // using scopes for(scope_listt::iterator @@ -96,8 +96,8 @@ void cpp_scopet::lookup( // Note the different kind! other_scope.lookup(base_name, QUALIFIED, id_set); } - - if(kind==QUALIFIED) return; // done + + if(kind==QUALIFIED) return; // done if(!id_set.empty()) return; // done // ask parent, recursive call @@ -130,10 +130,10 @@ void cpp_scopet::lookup( std::cout << "B: " << base_name << std::endl; std::cout << "K: " << kind << std::endl; std::cout << "I: " << id_class << std::endl; - std::cout << "THIS: " << this->base_name << " " << this->id_class + std::cout << "THIS: " << this->base_name << " " << this->id_class << " " << this->identifier << std::endl; #endif - + cpp_id_mapt::iterator lower_it=sub.lower_bound(base_name); @@ -154,7 +154,7 @@ void cpp_scopet::lookup( this->id_class == id_class) id_set.insert(this); - if(kind==SCOPE_ONLY) return; // done + if(kind==SCOPE_ONLY) return; // done // using scopes for(scope_listt::iterator @@ -184,8 +184,8 @@ void cpp_scopet::lookup( // Note the different kind! other_scope.lookup(base_name, QUALIFIED, id_class, id_set); } - - if(kind==QUALIFIED) return; // done + + if(kind==QUALIFIED) return; // done if(!id_set.empty() && id_class!=TEMPLATE) return; // done, upwards scopes are hidden diff --git a/src/cpp/cpp_scope.h b/src/cpp/cpp_scope.h index 4baea7cff76..2d84de317e8 100644 --- a/src/cpp/cpp_scope.h +++ b/src/cpp/cpp_scope.h @@ -23,9 +23,9 @@ class cpp_scopet:public cpp_idt } typedef std::set id_sett; - + enum lookup_kindt { SCOPE_ONLY, QUALIFIED, RECURSIVE }; - + void lookup( const irep_idt &base_name, lookup_kindt kind, @@ -87,14 +87,14 @@ class cpp_scopet:public cpp_idt { return static_cast(cpp_idt::get_parent()); } - + cpp_scopet &get_global_scope() { cpp_scopet *p=this; - + while(!p->is_global_scope()) p=&(p->get_parent()); - + return *p; } diff --git a/src/cpp/cpp_scopes.h b/src/cpp/cpp_scopes.h index c0c253cd63f..70247aa8a8e 100644 --- a/src/cpp/cpp_scopes.h +++ b/src/cpp/cpp_scopes.h @@ -110,7 +110,7 @@ class cpp_scopest { current_scope_ptr=&get_global_scope(); } - + cpp_scopet &get_global_scope() { return current_scope().get_global_scope(); diff --git a/src/cpp/cpp_static_assert.h b/src/cpp/cpp_static_assert.h index da22442300e..56198527e8f 100644 --- a/src/cpp/cpp_static_assert.h +++ b/src/cpp/cpp_static_assert.h @@ -18,17 +18,17 @@ class cpp_static_assertt:public exprt { operands().resize(2); } - + exprt &cond() { return op0(); } - const exprt &cond() const + const exprt &cond() const { return op0(); } - + const exprt &description() const { return op1(); diff --git a/src/cpp/cpp_storage_spec.h b/src/cpp/cpp_storage_spec.h index 22095895bee..c59f1834ae9 100644 --- a/src/cpp/cpp_storage_spec.h +++ b/src/cpp/cpp_storage_spec.h @@ -17,7 +17,7 @@ class cpp_storage_spect:public irept cpp_storage_spect():irept(ID_cpp_storage_spec) { } - + source_locationt &location() { return static_cast(add(ID_C_source_location)); diff --git a/src/cpp/cpp_template_args.h b/src/cpp/cpp_template_args.h index e38dff88af2..48b0e330ecf 100644 --- a/src/cpp/cpp_template_args.h +++ b/src/cpp/cpp_template_args.h @@ -68,7 +68,7 @@ class cpp_template_args_tct:public cpp_template_args_baset if(it->id()==ID_unassigned || it->type().id()==ID_unassigned) return true; - + return false; } }; diff --git a/src/cpp/cpp_template_parameter.h b/src/cpp/cpp_template_parameter.h index e760f611c5a..722cc5056bf 100644 --- a/src/cpp/cpp_template_parameter.h +++ b/src/cpp/cpp_template_parameter.h @@ -22,7 +22,7 @@ struct template_parametert:public exprt { } - #if 0 + #if 0 bool get_is_type() const { return get_bool(ID_is_type); @@ -32,12 +32,12 @@ struct template_parametert:public exprt { set(ID_is_type, value); } - + irep_idt get_identifier() const { return get(ID_identifier); } - + void set_identifier(const irep_idt &identifier) { return set(ID_identifier, identifier); @@ -64,7 +64,7 @@ struct template_parametert:public exprt { return static_cast(find(ID_C_default_value)); } - + bool has_default_argument() const { return find(ID_C_default_value).is_not_nil(); diff --git a/src/cpp/cpp_token.h b/src/cpp/cpp_token.h index ac94dec752c..312506a1e65 100644 --- a/src/cpp/cpp_token.h +++ b/src/cpp/cpp_token.h @@ -21,7 +21,7 @@ class cpp_tokent std::string text; unsigned line_no; irep_idt filename; - + void clear() { kind=0; @@ -30,7 +30,7 @@ class cpp_tokent line_no=0; filename=""; } - + void swap(cpp_tokent &token) { std::swap(kind, token.kind); diff --git a/src/cpp/cpp_token_buffer.cpp b/src/cpp/cpp_token_buffer.cpp index 80b9ddb9daa..1dbb0178684 100644 --- a/src/cpp/cpp_token_buffer.cpp +++ b/src/cpp/cpp_token_buffer.cpp @@ -79,7 +79,7 @@ int cpp_token_buffert::get_token() assert(current_pos<=token_vector.size()); if(token_vector.size()==current_pos) read_token(); - + int kind=token_vector[current_pos]->kind; current_pos++; @@ -134,7 +134,7 @@ void cpp_token_buffert::read_token() token_vector.push_back(--tokens.end()); int kind; - + ansi_c_parser.stack.clear(); kind=yyansi_clex(); tokens.back().text=yyansi_ctext; @@ -143,7 +143,7 @@ void cpp_token_buffert::read_token() tokens.back().data=ansi_c_parser.stack.front(); tokens.back().line_no=ansi_c_parser.get_line_no(); tokens.back().filename=ansi_c_parser.get_file(); - } + } //std::cout << "TOKEN: " << kind << " " << tokens.back().text << std::endl; diff --git a/src/cpp/cpp_token_buffer.h b/src/cpp/cpp_token_buffer.h index 9b4ff7584e3..94ae0f041a9 100644 --- a/src/cpp/cpp_token_buffer.h +++ b/src/cpp/cpp_token_buffer.h @@ -17,9 +17,9 @@ class cpp_token_buffert cpp_token_buffert():current_pos(0) { } - + typedef unsigned int post; - + int LookAhead(unsigned offset); int get_token(cpp_tokent &token); int get_token(); @@ -29,7 +29,7 @@ class cpp_token_buffert void Restore(post pos); void Replace(const cpp_tokent &token); void Insert(const cpp_tokent &token); - + void clear() { tokens.clear(); @@ -43,15 +43,15 @@ class cpp_token_buffert assert(!tokens.empty()); return tokens.back(); } - + protected: typedef std::list tokenst; tokenst tokens; - + std::vector token_vector; - + post current_pos; - + // get another token from lexer void read_token(); }; diff --git a/src/cpp/cpp_type2name.cpp b/src/cpp/cpp_type2name.cpp index d8cb7f51244..95c33c778ff 100644 --- a/src/cpp/cpp_type2name.cpp +++ b/src/cpp/cpp_type2name.cpp @@ -48,7 +48,7 @@ Function: irep2name static void irep2name(const irept &irep, std::string &result) { result=""; - + if(is_reference(static_cast(irep))) result+="reference"; @@ -117,13 +117,13 @@ std::string cpp_type2name(const typet &type) if(type.get_bool(ID_C_constant)) result+="const_"; - + if(type.get_bool(ID_C_restricted)) result+="restricted_"; - + if(type.get_bool(ID_C_volatile)) result+="volatile_"; - + if(type.id()==ID_empty || type.id()==ID_void) result+="void"; else if(type.id()==ID_bool) @@ -141,7 +141,7 @@ std::string cpp_type2name(const typet &type) { // we try to use #c_type const irep_idt c_type=type.get(ID_C_c_type); - + if(c_type!=irep_idt()) result+=id2string(c_type); else if(type.id()==ID_unsignedbv) @@ -164,7 +164,7 @@ std::string cpp_type2name(const typet &type) // we do (args)->(return_type) const code_typet::parameterst ¶meters=to_code_type(type).parameters(); const typet &return_type=to_code_type(type).return_type(); - + result+='('; for(code_typet::parameterst::const_iterator @@ -175,7 +175,7 @@ std::string cpp_type2name(const typet &type) if(arg_it!=parameters.begin()) result+=','; result+=cpp_type2name(arg_it->type()); } - + result+=')'; result+="->("; result+=cpp_type2name(return_type); @@ -188,7 +188,7 @@ std::string cpp_type2name(const typet &type) irep2name(type, tmp); return tmp; } - + return result; } @@ -210,4 +210,3 @@ std::string cpp_expr2name(const exprt &expr) irep2name(expr, tmp); return tmp; } - diff --git a/src/cpp/cpp_typecheck.cpp b/src/cpp/cpp_typecheck.cpp index 9785dbfba50..09706ac4795 100644 --- a/src/cpp/cpp_typecheck.cpp +++ b/src/cpp/cpp_typecheck.cpp @@ -70,7 +70,7 @@ void cpp_typecheckt::typecheck() { // default linkage is "automatic" current_linkage_spec=ID_auto; - + for(auto & item : cpp_parse_tree.items) convert(item); @@ -245,8 +245,8 @@ void cpp_typecheckt::static_and_dynamic_initialization() if(symbol.is_extern) continue; - - // PODs are always statically initialized + + // PODs are always statically initialized if(cpp_is_pod(symbol.type)) continue; @@ -280,7 +280,7 @@ void cpp_typecheckt::static_and_dynamic_initialization() init_block.move_to_operands(call); } } - + dynamic_initializations.clear(); //block_sini.move_to_operands(block_dini); @@ -379,7 +379,7 @@ Function: cpp_typecheckt::clean_up void cpp_typecheckt::clean_up() { symbol_tablet::symbolst::iterator it=symbol_table.symbols.begin(); - + while(it!=symbol_table.symbols.end()) { symbol_tablet::symbolst::iterator cur_it = it; @@ -409,7 +409,7 @@ void cpp_typecheckt::clean_up() struct_union_typet::componentst &function_members= (struct_union_typet::componentst &) (struct_union_type.add(ID_methods).get_sub()); - + function_members.reserve(components.size()); for(const auto & compo_it : components) diff --git a/src/cpp/cpp_typecheck.h b/src/cpp/cpp_typecheck.h index 6c3ef182476..c296376dc18 100644 --- a/src/cpp/cpp_typecheck.h +++ b/src/cpp/cpp_typecheck.h @@ -163,7 +163,7 @@ class cpp_typecheckt:public c_typecheck_baset const irep_idt &base_name, const template_typet &template_type, const cpp_template_args_non_tct &partial_specialization_args); - + std::string function_template_identifier( const irep_idt &base_name, const template_typet &template_type, @@ -174,7 +174,7 @@ class cpp_typecheckt:public c_typecheck_baset const symbolt &template_symbol, const cpp_template_args_non_tct &template_args); - // template instantiations + // template instantiations class instantiationt { public: @@ -185,9 +185,9 @@ class cpp_typecheckt:public c_typecheck_baset typedef std::list instantiation_stackt; instantiation_stackt instantiation_stack; - + void show_instantiation_stack(std::ostream &); - + class instantiation_levelt { public: @@ -197,21 +197,21 @@ class cpp_typecheckt:public c_typecheck_baset { instantiation_stack.push_back(instantiationt()); } - + ~instantiation_levelt() { instantiation_stack.pop_back(); } - + private: instantiation_stackt &instantiation_stack; }; - + const symbolt &class_template_symbol( const source_locationt &source_location, const symbolt &template_symbol, const cpp_template_args_tct &specialization_template_args, - const cpp_template_args_tct &full_template_args); + const cpp_template_args_tct &full_template_args); void elaborate_class_template( const typet &type); @@ -335,15 +335,15 @@ class cpp_typecheckt:public c_typecheck_baset instantiation_stack(_instantiation_stack) { } - + symbolt *method_symbol; template_mapt template_map; instantiation_stackt instantiation_stack; }; - + typedef std::list method_bodiest; method_bodiest method_bodies; - + void add_method_body(symbolt *_method_symbol) { method_bodies.push_back(method_bodyt( diff --git a/src/cpp/cpp_typecheck_bases.cpp b/src/cpp/cpp_typecheck_bases.cpp index 2c0b0cafdaa..e8990a3bce7 100644 --- a/src/cpp/cpp_typecheck_bases.cpp +++ b/src/cpp/cpp_typecheck_bases.cpp @@ -29,7 +29,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) irep_idt default_class_access= type.get_bool(ID_C_class)?ID_private:ID_public; - + irept::subt &bases_irep=type.add(ID_bases).get_sub(); Forall_irep(base_it, bases_irep) @@ -49,7 +49,7 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) error() << "expected type as struct/class base" << eom; throw 0; } - + // elaborate any class template instances given as bases elaborate_class_template(base_symbol_expr.type()); @@ -202,7 +202,7 @@ void cpp_typecheckt::add_base_components( // copy the component dest_c.push_back(*it); - + // now twiddle the copy struct_typet::componentt &component=dest_c.back(); component.set(ID_from_base, true); @@ -230,10 +230,8 @@ void cpp_typecheckt::add_base_components( } else assert(false); - + // put into scope - + } } - - diff --git a/src/cpp/cpp_typecheck_code.cpp b/src/cpp/cpp_typecheck_code.cpp index 3a24a3b9d10..c6f97931455 100644 --- a/src/cpp/cpp_typecheck_code.cpp +++ b/src/cpp/cpp_typecheck_code.cpp @@ -66,7 +66,7 @@ Function: cpp_typecheckt::typecheck_try_catch void cpp_typecheckt::typecheck_try_catch(codet &code) { codet::operandst &operands=code.operands(); - + for(codet::operandst::iterator it=operands.begin(); it!=operands.end(); @@ -81,10 +81,10 @@ void cpp_typecheckt::typecheck_try_catch(codet &code) { // This is (one of) the catch clauses. codet &code=to_code_block(to_code(*it)); - + // look at the catch operand assert(!code.operands().empty()); - + if(to_code(code.op0()).get_statement()==ID_ellipsis) { code.operands().erase(code.operands().begin()); @@ -99,19 +99,19 @@ void cpp_typecheckt::typecheck_try_catch(codet &code) assert(to_code(code.op0()).get_statement()==ID_decl); cpp_declarationt &cpp_declaration= to_cpp_declaration(to_code_decl(to_code(code.op0())).symbol()); - + assert(cpp_declaration.declarators().size()==1); cpp_declaratort &declarator=cpp_declaration.declarators().front(); - + if(is_reference(declarator.type())) declarator.type()=declarator.type().subtype(); } // typecheck the body typecheck_code(code); - + // the declaration is now in a decl_block - + assert(!code.operands().empty()); assert(to_code(code.op0()).get_statement()==ID_decl_block); @@ -121,7 +121,7 @@ void cpp_typecheckt::typecheck_try_catch(codet &code) // get the type const typet &type=code_decl.op0().type(); - + // annotate exception ID it->set(ID_exception_id, cpp_exception_id(type, *this)); } @@ -146,7 +146,7 @@ void cpp_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) // In addition to the C syntax, C++ also allows a declaration // as condition. E.g., // if(void *p=...) ... - + if(code.cond().id()==ID_code) { typecheck_code(to_code(code.cond())); @@ -172,7 +172,7 @@ void cpp_typecheckt::typecheck_while(code_whilet &code) // In addition to the C syntax, C++ also allows a declaration // as condition. E.g., // while(void *p=...) ... - + if(code.cond().id()==ID_code) { typecheck_code(to_code(code.cond())); @@ -198,24 +198,24 @@ void cpp_typecheckt::typecheck_switch(code_switcht &code) // In addition to the C syntax, C++ also allows a declaration // as condition. E.g., // switch(int i=...) ... - + if(code.value().id()==ID_code) { // we shall rewrite that into // { int i=....; switch(i) .... } - + codet decl=to_code(code.value()); typecheck_decl(decl); - + assert(decl.get_statement()==ID_decl_block); assert(decl.operands().size()==1); - - // replace declaration by its symbol + + // replace declaration by its symbol assert(decl.op0().op0().id()==ID_symbol); code.value()=decl.op0().op0(); c_typecheck_baset::typecheck_switch(code); - + code_blockt code_block; code_block.move_to_operands(decl.op0(), code); code.swap(code_block); @@ -240,11 +240,11 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) { const cpp_namet &member= to_cpp_name(code.find(ID_member)); - + // Let's first typecheck the operands. Forall_operands(it, code) typecheck_expr(*it); - + // The initializer may be a data member (non-type) // or a parent class (type). // We ask for VAR only, as we get the parent classes via their @@ -263,12 +263,12 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) if(symbol_expr.type().id()==ID_code) { const code_typet &code_type=to_code_type(symbol_expr.type()); - + assert(code_type.parameters().size()>=1); - + // It's a parent. Call the constructor that we got. side_effect_expr_function_callt function_call; - + function_call.function()=symbol_expr; function_call.add_source_location()=code.source_location(); function_call.arguments().reserve(code.operands().size()+1); @@ -276,16 +276,16 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) // we have to add 'this' exprt this_expr = cpp_scopes.current_scope().this_expr; assert(this_expr.is_not_nil()); - + make_ptr_typecast( this_expr, code_type.parameters().front().type()); function_call.arguments().push_back(this_expr); - + forall_operands(it, code) function_call.arguments().push_back(*it); - + // done building the expression, check the argument types typecheck_function_call_arguments(function_call); @@ -308,7 +308,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) #endif } } - + code_expressiont code_expression; code_expression.expression()=function_call; @@ -386,7 +386,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) { // it's a data member already_typechecked(symbol_expr); - + Forall_operands(it, code) already_typechecked(*it); @@ -437,9 +437,9 @@ void cpp_typecheckt::typecheck_decl(codet &code) cpp_declarationt &declaration= to_cpp_declaration(code.op0()); - + typet &type=declaration.type(); - + bool is_typedef=declaration.is_typedef(); typecheck_type(type); @@ -486,7 +486,7 @@ void cpp_typecheckt::typecheck_decl(codet &code) decl_statement.copy_to_operands(symbol.value); assert(follow(decl_statement.op1().type())==follow(symbol.type)); } - + new_code.move_to_operands(decl_statement); // is there a constructor to be called? @@ -501,7 +501,7 @@ void cpp_typecheckt::typecheck_decl(codet &code) exprt object_expr=cpp_symbol_expr(symbol); already_typechecked(object_expr); - + exprt constructor_call= cpp_constructor( symbol.location, diff --git a/src/cpp/cpp_typecheck_compound_type.cpp b/src/cpp/cpp_typecheck_compound_type.cpp index e4a4c88885d..502a0ba3517 100644 --- a/src/cpp/cpp_typecheck_compound_type.cpp +++ b/src/cpp/cpp_typecheck_compound_type.cpp @@ -42,7 +42,7 @@ bool cpp_typecheckt::has_const(const typet &type) { forall_subtypes(it, type) if(has_const(*it)) return true; - + return false; } else @@ -69,7 +69,7 @@ bool cpp_typecheckt::has_volatile(const typet &type) { forall_subtypes(it, type) if(has_volatile(*it)) return true; - + return false; } else @@ -109,7 +109,7 @@ cpp_scopet &cpp_typecheckt::tag_scope( if(has_body || tag_only_declaration) return cpp_scopes.current_scope(); - + // No body. Not a tag-only-declaration. // Check if we have it already. If so, take it. @@ -120,7 +120,7 @@ cpp_scopet &cpp_typecheckt::tag_scope( for(const auto & it : id_set) if(it->is_class()) return static_cast(it->get_parent()); - + // Tags without body that we don't have already // and that are not a tag-only declaration go into // the global scope of the namespace. @@ -175,7 +175,7 @@ void cpp_typecheckt::typecheck_compound_type( if(cpp_name.is_simple_name()) { base_name=cpp_name.get_base_name(); - + // anonymous structs always go into the current scope if(type.get_bool(ID_C_is_anonymous)) dest_scope=&cpp_scopes.current_scope(); @@ -190,7 +190,7 @@ void cpp_typecheckt::typecheck_compound_type( dest_scope=&cpp_typecheck_resolve.resolve_scope(cpp_name, base_name, t_args); } } - + // The identifier 'tag-X' matches what the C front-end does! // The hypen is deliberate to avoid collisions with other // identifiers. @@ -198,7 +198,7 @@ void cpp_typecheckt::typecheck_compound_type( dest_scope->prefix+ "tag-"+id2string(base_name)+ dest_scope->suffix; - + // check if we have it already symbol_tablet::symbolst::iterator previous_symbol= @@ -207,7 +207,7 @@ void cpp_typecheckt::typecheck_compound_type( if(previous_symbol!=symbol_table.symbols.end()) { // we do! - + symbolt &symbol=previous_symbol->second; if(has_body) @@ -255,7 +255,7 @@ void cpp_typecheckt::typecheck_compound_type( // move early, must be visible before doing body symbolt *new_symbol; - + if(symbol_table.move(symbol, new_symbol)) { error().source_location=symbol.location; @@ -274,7 +274,7 @@ void cpp_typecheckt::typecheck_compound_type( cpp_scopes.current_scope().suffix+"::"; id.class_identifier=new_symbol->name; id.id_class=cpp_idt::CLASS; - + if(has_body) typecheck_compound_body(*new_symbol); else @@ -337,12 +337,12 @@ void cpp_typecheckt::typecheck_compound_declarator( elaborate_class_template(final_type); typecheck_type(final_type); - + cpp_namet cpp_name; cpp_name.swap(declarator.name()); - + irep_idt base_name; - + if(cpp_name.is_nil()) { // Yes, there can be members without name. @@ -433,7 +433,7 @@ void cpp_typecheckt::typecheck_compound_declarator( struct_typet::componentt component; irep_idt identifier; - + // the below is a temporary hack //if(is_method || is_static)d if(id2string(cpp_scopes.current_scope().prefix).find("#anon")== @@ -451,7 +451,7 @@ void cpp_typecheckt::typecheck_compound_declarator( // otherwise, we keep them simple identifier=base_name; } - + component.set(ID_name, identifier); component.type()=final_type; component.set(ID_access, access); @@ -499,16 +499,16 @@ void cpp_typecheckt::typecheck_compound_declarator( component.get_string(ID_base_name)+ id2string( function_identifier(static_cast(component.find(ID_type)))); - + if(has_const(method_qualifier)) virtual_name+="$const"; if(has_volatile(method_qualifier)) virtual_name+="$virtual"; - + if(component.type().get(ID_return_type)==ID_destructor) virtual_name="@dtor"; - + // The method may be virtual implicitly. std::set virtual_bases; @@ -580,7 +580,7 @@ void cpp_typecheckt::typecheck_compound_declarator( if(vtit == symbol_table.symbols.end()) { - // first time: create a virtual-table symbol type + // first time: create a virtual-table symbol type symbolt vt_symb_type; vt_symb_type.name= vt_name; vt_symb_type.base_name="virtual_table::"+id2string(symbol.base_name); @@ -596,7 +596,7 @@ void cpp_typecheckt::typecheck_compound_declarator( assert(!failed); vtit = symbol_table.symbols.find(vt_name); - // add a virtual-table pointer + // add a virtual-table pointer struct_typet::componentt compo; compo.type() = pointer_typet(symbol_typet(vt_name)); compo.set_name(id2string(symbol.name) +"::@vtable_pointer"); @@ -607,7 +607,7 @@ void cpp_typecheckt::typecheck_compound_declarator( components.push_back(compo); put_compound_into_scope(compo); } - + assert(vtit->second.type.id()==ID_struct); struct_typet &virtual_table= @@ -677,7 +677,7 @@ void cpp_typecheckt::typecheck_compound_declarator( late_cast.op0()= namespacet(symbol_table).lookup( args[0].get(ID_C_identifier)).symbol_expr(); - + if(code_type.return_type().id()!=ID_empty && code_type.return_type().id()!=ID_destructor) { @@ -716,7 +716,7 @@ void cpp_typecheckt::typecheck_compound_declarator( } // add this new function to the list of components - + struct_typet::componentt new_compo = component; new_compo.type() = func_symb.type; new_compo.set_name(func_symb.name); @@ -733,7 +733,7 @@ void cpp_typecheckt::typecheck_compound_declarator( } } } - + if(is_static && !is_method) // static non-method member { // add as global variable to symbol_table @@ -746,7 +746,7 @@ void cpp_typecheckt::typecheck_compound_declarator( static_symbol.is_static_lifetime=true; static_symbol.location=cpp_name.source_location(); static_symbol.is_extern=true; - + // TODO: not sure about this: should be defined separately! dynamic_initializations.push_back(static_symbol.name); @@ -814,7 +814,7 @@ void cpp_typecheckt::check_fixed_size_array(typet &type) if(type.id()==ID_array) { array_typet &array_type=to_array_type(type); - + if(array_type.size().is_not_nil()) make_constant_index(array_type.size()); @@ -840,11 +840,11 @@ void cpp_typecheckt::put_compound_into_scope( { const irep_idt &base_name=compound.get_base_name(); const irep_idt &name=compound.get_name(); - + // nothing to do if no base_name (e.g., an anonymous bitfield) if(base_name==irep_idt()) return; - + if(compound.type().id()==ID_code) { // put the symbol into scope @@ -877,9 +877,9 @@ void cpp_typecheckt::put_compound_into_scope( { // check if it's already there cpp_scopest::id_sett id_set; - + cpp_scopes.current_scope().lookup(base_name, cpp_scopet::SCOPE_ONLY, id_set); - + for(const auto & id_it : id_set) { const cpp_idt &id=*id_it; @@ -932,7 +932,7 @@ void cpp_typecheckt::typecheck_friend_declaration( error() << "friend template not supported" << eom; throw 0; } - + // we distinguish these whether there is a declarator if(declaration.declarators().empty()) { @@ -945,7 +945,7 @@ void cpp_typecheckt::typecheck_friend_declaration( error() << "unexpected friend" << eom; throw 0; } - + if(ftype.find(ID_body).is_not_nil()) { error().source_location=declaration.type().source_location(); @@ -954,7 +954,7 @@ void cpp_typecheckt::typecheck_friend_declaration( } // typecheck ftype - + // TODO // typecheck_type(ftype); // assert(ftype.id()==ID_symbol); @@ -965,7 +965,7 @@ void cpp_typecheckt::typecheck_friend_declaration( // It should be a friend function. // Do the declarators. - + for(auto & sub_it : declaration.declarators()) { bool has_value = sub_it.value().is_not_nil(); @@ -1036,7 +1036,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) error() << "union types must not have bases" << eom; throw 0; } - + typecheck_compound_bases(to_struct_type(type)); } @@ -1202,14 +1202,14 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) if(!declaration.is_constructor()) continue; - + for(auto & declarator : declaration.declarators()) { #if 0 irep_idt ctor_base_name= declarator.name().get_base_name(); #endif - + if(declarator.value().is_not_nil()) // body? { if(declarator.find(ID_member_initializers).is_nil()) @@ -1232,7 +1232,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) bool is_static=declaration.storage_spec().is_static(); // Shall be false bool is_mutable=declaration.storage_spec().is_mutable(); // Shall be false bool is_typedef=declaration.is_typedef(); // Shall be false - + typecheck_compound_declarator( symbol, declaration, declarator, components, @@ -1256,7 +1256,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) struct_typet::componentt component; if(!find_cpctor(symbol)) - { + { // build declaration cpp_declarationt cpctor; default_cpctor(symbol, cpctor); @@ -1269,7 +1269,7 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) typecheck_compound_declarator( symbol, cpctor, cpctor.declarators()[0], components, - ID_public, false, false, false); + ID_public, false, false, false); } // Add the default assignment operator @@ -1435,7 +1435,7 @@ void cpp_typecheckt::typecheck_member_function( throw 0; } - + // Is this in a class template? // If so, we defer typechecking until used. if(cpp_scopes.current_scope().get_parent().is_template_scope()) @@ -1468,16 +1468,16 @@ void cpp_typecheckt::add_this_to_method_type( parameters.begin(), code_typet::parametert()); code_typet::parametert ¶meter=parameters.front(); - + parameter.set_identifier(ID_this); // check? Not qualified parameter.set_base_name(ID_this); parameter.set_this(); typet subtype=symbol_typet(compound_symbol); - + if(has_const(method_qualifier)) subtype.set(ID_C_constant, true); - + if(has_volatile(method_qualifier)) subtype.set(ID_C_volatile, true); @@ -1536,7 +1536,7 @@ void cpp_typecheckt::add_anonymous_members_to_scope( error() << "`" << base_name << "' already in scope" << eom; throw 0; } - + cpp_idt &id=cpp_scopes.current_scope().insert(base_name); id.id_class=cpp_idt::SYMBOL; id.identifier=it.get(ID_name); @@ -1601,9 +1601,9 @@ void cpp_typecheckt::convert_anon_struct_union_member( component.add_source_location()=declaration.source_location(); components.push_back(component); - + add_anonymous_members_to_scope(struct_union_symbol); - + put_compound_into_scope(component); struct_union_symbol.type.set("#unnamed_object", base_name); @@ -1687,9 +1687,9 @@ bool cpp_typecheckt::get_component( follow(component.type()).find("#unnamed_object").is_not_nil()) { // could be anonymous union or struct - + const typet &component_type=follow(component.type()); - + if(component_type.id()==ID_union || component_type.id()==ID_struct) { @@ -1776,7 +1776,7 @@ bool cpp_typecheckt::check_component_access( // check friendship const irept::subt &friends= struct_union_type.find("#friends").get_sub(); - + forall_irep(f_it, friends) { const irept &friend_symb = *f_it; @@ -1926,4 +1926,3 @@ void cpp_typecheckt::make_ptr_typecast( expr.make_typecast(dest_type); } - diff --git a/src/cpp/cpp_typecheck_constructor.cpp b/src/cpp/cpp_typecheck_constructor.cpp index 377e7409b73..d3ce33b2871 100644 --- a/src/cpp/cpp_typecheck_constructor.cpp +++ b/src/cpp/cpp_typecheck_constructor.cpp @@ -260,7 +260,7 @@ void cpp_typecheckt::default_cpctor( exprt param_name(ID_name); param_name.add_source_location()=source_location; param_name.set(ID_identifier, param_identifier); - + cpp_namet cpp_parameter; cpp_parameter.move_to_sub(param_name); @@ -335,11 +335,11 @@ void cpp_typecheckt::default_cpctor( exprt name(ID_name); name.set(ID_identifier,mem_it->get(ID_base_name)); name.add_source_location()=source_location; - + cpp_namet cppname; cppname.move_to_sub(name); - const symbolt &virtual_table_symbol_type = + const symbolt &virtual_table_symbol_type = namespacet(symbol_table).lookup(mem_it->type().subtype().get(ID_identifier)); const symbolt &virtual_table_symbol_var = @@ -545,7 +545,7 @@ void cpp_typecheckt::default_assignop_value( // throw 0; continue; } - + mp_integer size; bool to_int = to_integer(size_expr, size); assert(!to_int); @@ -827,7 +827,7 @@ void cpp_typecheckt::full_member_initialization( for(struct_typet::componentst::const_iterator c_it = components.begin(); c_it != components.end(); c_it++) { - if(c_it->get(ID_base_name)==base_name && + if(c_it->get(ID_base_name)==base_name && c_it->get(ID_type)!=ID_code && !c_it->get_bool(ID_is_type)) { @@ -909,11 +909,11 @@ void cpp_typecheckt::full_member_initialization( cpp_namet cppname; cppname.move_to_sub(name); - const symbolt& virtual_table_symbol_type = + const symbolt& virtual_table_symbol_type = lookup(mem_it->type().subtype().get(ID_identifier)); const symbolt& virtual_table_symbol_var = - lookup(id2string(virtual_table_symbol_type.name) + "@" + + lookup(id2string(virtual_table_symbol_type.name) + "@" + id2string(struct_union_type.get(ID_name))); exprt var = virtual_table_symbol_var.symbol_expr(); @@ -1117,4 +1117,3 @@ bool cpp_typecheckt::find_assignop(const symbolt& symbol) const return false; } - diff --git a/src/cpp/cpp_typecheck_conversions.cpp b/src/cpp/cpp_typecheck_conversions.cpp index 2324ba5fc08..37017ec41d9 100644 --- a/src/cpp/cpp_typecheck_conversions.cpp +++ b/src/cpp/cpp_typecheck_conversions.cpp @@ -429,7 +429,7 @@ bool cpp_typecheckt::standard_conversion_floating_integral_conversion( if(expr.type().id()==ID_floatbv || expr.type().id()==ID_fixedbv) { - if(type.id()!=ID_signedbv && + if(type.id()!=ID_signedbv && type.id()!=ID_unsignedbv) return false; } @@ -557,7 +557,7 @@ bool cpp_typecheckt::standard_conversion_pointer( if(expr.get_bool(ID_C_lvalue)) return false; - + // integer 0 to NULL pointer conversion? if(simplify_expr(expr, *this).is_zero() && expr.type().id()!=ID_pointer) @@ -570,7 +570,7 @@ bool cpp_typecheckt::standard_conversion_pointer( if(type.find("to-member").is_not_nil()) return false; - + if(expr.type().id() != ID_pointer || expr.type().find("to-member").is_not_nil()) return false; @@ -752,7 +752,7 @@ bool cpp_typecheckt::standard_conversion_boolean( if(expr.type().id()!=ID_signedbv && expr.type().id()!=ID_unsignedbv && - expr.type().id()!=ID_pointer && + expr.type().id()!=ID_pointer && expr.type().id()!=ID_c_enum_tag) return false; @@ -812,10 +812,10 @@ bool cpp_typecheckt::standard_conversion_sequence( if(type.id()==ID_c_bit_field) return standard_conversion_sequence(expr, type.subtype(), new_expr, rank); - // we turn bit fields into their underlying type + // we turn bit fields into their underlying type if(curr_expr.type().id()==ID_c_bit_field) curr_expr.make_typecast(curr_expr.type().subtype()); - + if(curr_expr.type().id()==ID_array) { if(type.id()==ID_pointer) @@ -880,7 +880,7 @@ bool cpp_typecheckt::standard_conversion_sequence( } else if(type.id()==ID_floatbv || type.id()==ID_fixedbv) { - if(!standard_conversion_floating_point_promotion(curr_expr, new_expr) || + if(!standard_conversion_floating_point_promotion(curr_expr, new_expr) || new_expr.type() != type) { if(!standard_conversion_floating_point_conversion(curr_expr, type, new_expr) && @@ -919,7 +919,7 @@ bool cpp_typecheckt::standard_conversion_sequence( } else new_expr = curr_expr; - + curr_expr.swap(new_expr); if(curr_expr.type().id()==ID_pointer) @@ -945,7 +945,7 @@ bool cpp_typecheckt::standard_conversion_sequence( rank+=1; break; } - + } while(sub_from.id()==ID_pointer); @@ -988,11 +988,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence( const typet &to = follow(type); new_expr.make_nil(); - + // special case: // A conversion from a type to the same type is given an exact // match rank even though a user-defined conversion is used - + if(from==to) rank+=0; else @@ -1298,7 +1298,7 @@ bool cpp_typecheckt::reference_related( { assert(is_reference(type)); assert(!is_reference(expr.type())); - + typet from = follow(expr.type()); typet to = follow(type.subtype()); @@ -1309,7 +1309,7 @@ bool cpp_typecheckt::reference_related( if(from==to) return true; - if(from.id()==ID_struct && + if(from.id()==ID_struct && to.id()==ID_struct) return subtype_typecast(to_struct_type(from), to_struct_type(to)); @@ -1627,7 +1627,7 @@ Function: implicit_conversion_sequence The rank of the sequence is stored in 'rank' Purpose: implicit conversion sequence - + \*******************************************************************/ bool cpp_typecheckt::implicit_conversion_sequence( @@ -2167,7 +2167,7 @@ bool cpp_typecheckt::static_typecast( bool check_constantness) { exprt e=expr; - + if(check_constantness && type.id()==ID_pointer) { if(e.id()==ID_dereference && e.get_bool(ID_C_implicit)) @@ -2232,7 +2232,7 @@ bool cpp_typecheckt::static_typecast( new_expr.make_typecast(type); return true; } - + // int/enum to enum if(type.id()==ID_c_enum_tag && ( e.type().id()==ID_signedbv diff --git a/src/cpp/cpp_typecheck_declaration.cpp b/src/cpp/cpp_typecheck_declaration.cpp index f71e9116cf0..1d7fec47c9f 100644 --- a/src/cpp/cpp_typecheck_declaration.cpp +++ b/src/cpp/cpp_typecheck_declaration.cpp @@ -155,15 +155,15 @@ void cpp_typecheckt::convert_non_template_declaration( // the name anonymous tag types declaration.name_anon_struct_union(); - + // do the type of the declaration typecheck_type(declaration_type); - + // Elaborate any class template instance _unless_ we do a typedef. // These are only elaborated on usage! if(!is_typedef) elaborate_class_template(declaration_type); - + // Special treatment for anonymous unions if(declaration.declarators().empty() && follow(declaration.type()).get_bool(ID_C_is_anonymous)) @@ -187,7 +187,7 @@ void cpp_typecheckt::convert_non_template_declaration( { // copy the declarator (we destroy the original) cpp_declaratort declarator=it; - + cpp_declarator_convertert cpp_declarator_converter(*this); cpp_declarator_converter.is_typedef=is_typedef; diff --git a/src/cpp/cpp_typecheck_destructor.cpp b/src/cpp/cpp_typecheck_destructor.cpp index 359ba8bf7b4..39fabd3cf5e 100644 --- a/src/cpp/cpp_typecheck_destructor.cpp +++ b/src/cpp/cpp_typecheck_destructor.cpp @@ -121,7 +121,7 @@ codet cpp_typecheckt::dtor(const symbolt &symbol) cpp_namet cppname; cppname.move_to_sub(name); - const symbolt &virtual_table_symbol_type = + const symbolt &virtual_table_symbol_type = namespacet(symbol_table).lookup( cit->type().subtype().get(ID_identifier)); @@ -179,7 +179,7 @@ codet cpp_typecheckt::dtor(const symbolt &symbol) if(dtor_code.is_not_nil()) block.move_to_operands(dtor_code); } - + const irept::subt &bases=symbol.type.find(ID_bases).get_sub(); // call the base destructors in the reverse order @@ -205,4 +205,3 @@ codet cpp_typecheckt::dtor(const symbolt &symbol) return block; } - diff --git a/src/cpp/cpp_typecheck_enum_type.cpp b/src/cpp/cpp_typecheck_enum_type.cpp index 45b6678ce43..abff4131755 100644 --- a/src/cpp/cpp_typecheck_enum_type.cpp +++ b/src/cpp/cpp_typecheck_enum_type.cpp @@ -30,18 +30,18 @@ Function: cpp_typecheckt::typecheck_enum_body void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) { c_enum_typet &c_enum_type=to_c_enum_type(enum_symbol.type); - + exprt &body=static_cast(c_enum_type.add(ID_body)); irept::subt &components=body.get_sub(); - + c_enum_tag_typet enum_tag_type(enum_symbol.name); - + mp_integer i=0; - + Forall_irep(it, components) { const irep_idt &name=it->get(ID_name); - + if(it->find(ID_value).is_not_nil()) { exprt &value=static_cast(it->add(ID_value)); @@ -55,10 +55,10 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) throw 0; } } - + exprt value_expr=from_integer(i, c_enum_type.subtype()); value_expr.type()=enum_tag_type; // override type - + symbolt symbol; symbol.name=id2string(enum_symbol.name)+"::"+id2string(name); @@ -70,7 +70,7 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) symbol.type=enum_tag_type; symbol.is_type=false; symbol.is_macro=true; - + symbolt *new_symbol; if(symbol_table.move(symbol, new_symbol)) { @@ -82,9 +82,9 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) cpp_idt &scope_identifier= cpp_scopes.put_into_scope(*new_symbol); - + scope_identifier.id_class=cpp_idt::SYMBOL; - + ++i; } } @@ -106,11 +106,11 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) // first save qualifiers c_qualifierst qualifiers; qualifiers.read(type); - + cpp_enum_typet &enum_type=to_cpp_enum_type(type); bool anonymous=!enum_type.has_tag(); irep_idt base_name; - + if(anonymous) { // we fabricate a tag based on the enum constants contained @@ -119,7 +119,7 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) else { const cpp_namet &tag=enum_type.tag(); - + if(tag.is_simple_name()) base_name=tag.get_base_name(); else @@ -140,10 +140,10 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) dest_scope.prefix+"tag-"+id2string(base_name); // check if we have it - + symbol_tablet::symbolst::iterator previous_symbol= symbol_table.symbols.find(symbol_name); - + if(previous_symbol!=symbol_table.symbols.end()) { // we do! @@ -164,7 +164,7 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) { std::string pretty_name= cpp_scopes.current_scope().prefix+id2string(base_name); - + // C++11 enumerations have an underlying type, // which defaults to int. // enums without underlying type may be 'packed'. @@ -197,7 +197,7 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) symbol.is_type=true; symbol.is_macro=false; symbol.pretty_name=pretty_name; - + // move early, must be visible before doing body symbolt *new_symbol; if(symbol_table.move(symbol, new_symbol)) @@ -211,7 +211,7 @@ void cpp_typecheckt::typecheck_enum_type(typet &type) // put into scope cpp_idt &scope_identifier= cpp_scopes.put_into_scope(*new_symbol, dest_scope); - + scope_identifier.id_class=cpp_idt::CLASS; typecheck_enum_body(*new_symbol); diff --git a/src/cpp/cpp_typecheck_expr.cpp b/src/cpp/cpp_typecheck_expr.cpp index f36bdb563de..d057883067d 100644 --- a/src/cpp/cpp_typecheck_expr.cpp +++ b/src/cpp/cpp_typecheck_expr.cpp @@ -112,13 +112,13 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr) { // an MS extension // http://msdn.microsoft.com/en-us/library/ms177194(v=vs.80).aspx - + typet base=static_cast(expr.find("type_arg1")); typet deriv=static_cast(expr.find("type_arg2")); - + typecheck_type(base); typecheck_type(deriv); - + follow_symbol(base); follow_symbol(deriv); @@ -292,7 +292,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) expr.op1().type().subtype() == expr.op2().type().subtype()) { // array-to-pointer conversion - + index_exprt index1; index1.array() = expr.op1(); index1.index() = from_integer(0, index_type()); @@ -305,7 +305,7 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) address_of_exprt addr1(index1); address_of_exprt addr2(index2); - + expr.op1() = addr1; expr.op2() = addr2; expr.type() = addr1.type(); @@ -364,12 +364,12 @@ void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) { // We need to overload, "sizeof-expression" can be mis-parsed // as a type. - + if(expr.operands().empty()) { const typet &type= static_cast(expr.find(ID_type_arg)); - + if(type.id()==ID_cpp_name) { // sizeof(X) may be ambiguous -- X can be either a type or @@ -391,7 +391,7 @@ void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) else if(type.id()==ID_array) { // sizeof(expr[index]) can be parsed as an array type! - + if(type.subtype().id()==ID_cpp_name) { cpp_typecheck_fargst fargs; @@ -411,7 +411,7 @@ void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) } } } - + c_typecheck_baset::typecheck_expr_sizeof(expr); } @@ -487,7 +487,7 @@ void cpp_typecheckt::typecheck_function_expr( exprt tmp("already_typechecked"); tmp.copy_to_operands(function_call); function_call.swap(tmp); - + expr.op0().swap(function_call); typecheck_function_expr(expr, fargs); return; @@ -514,7 +514,7 @@ Function: cpp_typecheckt::overloadable bool cpp_typecheckt::overloadable(const exprt &expr) { // at least one argument must have class or enumerated type - + forall_operands(it, expr) { typet t=follow(it->type()); @@ -580,13 +580,13 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) { // Check argument types first. // At least one struct/enum operand is required. - + if(!overloadable(expr)) return false; else if(expr.id()==ID_dereference && expr.get_bool(ID_C_implicit)) return false; - + assert(expr.operands().size()>=1); if(expr.id()=="explicit-typecast") @@ -682,7 +682,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) assert(!expr.get_bool(ID_C_implicit)); std::string op_name=std::string("operator")+e->op_name; - + // first do function/operator cpp_namet cpp_name; cpp_name.get_sub().push_back(irept(ID_name)); @@ -703,8 +703,8 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) // // We try and fail silently, maybe conversions will work // instead. - - // go into scope of first operand + + // go into scope of first operand if(expr.op0().type().id()==ID_symbol && follow(expr.op0().type()).id()==ID_struct) { @@ -714,17 +714,17 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) // get that scope cpp_save_scopet save_scope(cpp_scopes); cpp_scopes.set_scope(struct_identifier); - + // build fargs for resolver cpp_typecheck_fargst fargs; fargs.operands=expr.operands(); fargs.has_object=true; fargs.in_use=true; - + // should really be a qualified search exprt resolve_result=resolve( cpp_name, cpp_typecheck_resolvet::VAR, fargs, false); - + if(resolve_result.is_not_nil()) { // Found! We turn op(a, b, ...) into a.op(b, ...) @@ -748,12 +748,12 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) it++) function_call.arguments().push_back(*it); } - + typecheck_side_effect_function_call(function_call); - + expr=function_call; - return true; + return true; } } @@ -763,10 +763,10 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) fargs.operands=expr.operands(); fargs.has_object=false; fargs.in_use=true; - + exprt resolve_result=resolve( cpp_name, cpp_typecheck_resolvet::VAR, fargs, false); - + if(resolve_result.is_not_nil()) { // found! @@ -789,7 +789,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) typecheck_expr(expr); return true; } - + expr=function_call; return true; @@ -843,7 +843,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr) expr.op0().swap(address); } - if(expr.op0().id()==ID_address_of && + if(expr.op0().id()==ID_address_of && expr.op0().get_bool(ID_C_implicit)) { // must be the address of a function @@ -898,16 +898,16 @@ void cpp_typecheckt::typecheck_expr_throw(exprt &expr) { // nothing really to do; one can throw _almost_ anything const typet &exception_type=expr.op0().type(); - + if(follow(exception_type).id()==ID_empty) { error().source_location=expr.op0().find_source_location(); error() << "cannot throw void" << eom; throw 0; } - + // annotate the relevant exception IDs - expr.set(ID_exception_list, + expr.set(ID_exception_list, cpp_exception_list(exception_type, *this)); } } @@ -975,7 +975,7 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr) // not yet typechecked-stuff exprt &initializer=static_cast(expr.add(ID_initializer)); - + // arrays must not have an initializer if(!initializer.operands().empty() && expr.get(ID_statement)==ID_cpp_new_array) @@ -992,7 +992,7 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr) initializer.operands()); expr.add(ID_initializer).swap(code); - + // we add the size of the object for convenience of the // runtime library @@ -1025,7 +1025,7 @@ static exprt collect_comma_expression(const exprt &src) } else result.copy_to_operands(src); - + return result; } @@ -1038,7 +1038,7 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr) // Default value, e.g., int() typecheck_type(expr.type()); exprt new_expr=gen_zero(expr.type()); - + if(new_expr.is_nil()) { error().source_location=expr.find_source_location(); @@ -1057,7 +1057,7 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr) // (f)(1), where 'f' is a function symbol and not a type. // This also exists with a "comma expression", e.g., // (f)(1, 2, 3) - + if(expr.type().id()==ID_cpp_name) { // try to resolve as type @@ -1080,16 +1080,16 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr) f_call.add_source_location()=expr.source_location(); f_call.function().swap(expr.type()); f_call.arguments()=collect_comma_expression(expr.op0()).operands(); - + typecheck_side_effect_function_call(f_call); - + expr.swap(f_call); return; } } else typecheck_type(expr.type()); - + exprt new_expr; if(const_typecast(expr.op0(), expr.type(), new_expr) || @@ -1146,7 +1146,7 @@ void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr) typet symb(ID_symbol); symb.set(ID_identifier, expr.type().get(ID_name)); symb.add_source_location()=expr.source_location(); - + exprt e=expr; new_temporary(e.source_location(), symb, e.operands(), expr); } @@ -1203,7 +1203,7 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr) error() << "delete expects one operand" << eom; throw 0; } - + const irep_idt statement=expr.get(ID_statement); if(statement==ID_cpp_delete) @@ -1214,7 +1214,7 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr) } else assert(false); - + typet pointer_type=follow(expr.op0().type()); if(pointer_type.id()!=ID_pointer) @@ -1224,31 +1224,31 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr) << to_string(pointer_type) << "'" << eom; throw 0; } - + // remove any const-ness of the argument // (which would impair the call to the destructor) pointer_type.subtype().remove(ID_C_constant); // delete expressions are always void expr.type()=typet(ID_empty); - + // we provide the right destructor, for the convenience // of later stages exprt new_object(ID_new_object, pointer_type.subtype()); new_object.add_source_location()=expr.source_location(); new_object.set(ID_C_lvalue, true); - + already_typechecked(new_object); codet destructor_code=cpp_destructor( expr.source_location(), pointer_type.subtype(), new_object); - + // this isn't typechecked yet if(destructor_code.is_not_nil()) typecheck_code(destructor_code); - + expr.set(ID_destructor, destructor_code); } @@ -1301,9 +1301,9 @@ void cpp_typecheckt::typecheck_expr_member( // The notation for explicit calls to destructors can be used regardless // of whether the type defines a destructor. This allows you to make such - // explicit calls without knowing if a destructor is defined for the type. + // explicit calls without knowing if a destructor is defined for the type. // An explicit call to a destructor where none is defined has no effect. - + if(expr.find(ID_component_cpp_name).is_not_nil() && to_cpp_name(expr.find(ID_component_cpp_name)).is_destructor() && follow(op0.type()).id()!=ID_struct) @@ -1340,7 +1340,7 @@ void cpp_typecheckt::typecheck_expr_member( const struct_union_typet &type= to_struct_union_type(followed_op0_type); - + irep_idt struct_identifier=type.get(ID_name); if(expr.find(ID_component_cpp_name).is_not_nil()) @@ -1367,7 +1367,7 @@ void cpp_typecheckt::typecheck_expr_member( exprt tmp=symbol_expr.op0(); symbol_expr.swap(tmp); } - + assert(symbol_expr.id()==ID_symbol || symbol_expr.id()==ID_member || symbol_expr.id()==ID_constant); @@ -1566,7 +1566,7 @@ void cpp_typecheckt::typecheck_cast_expr(exprt &expr) } irept &template_arg=template_arguments.get_sub().front(); - + if(template_arg.id()!=ID_type && template_arg.id()!="ambiguous") { @@ -1679,7 +1679,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( { // These are polymorphic, see // http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html - + // adjust return type of function to match pointer subtype if(fargs.operands.size()<1) { @@ -1732,7 +1732,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + symbol_exprt result; result.add_source_location()=source_location; result.set_identifier(identifier); @@ -1766,7 +1766,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + symbol_exprt result; result.add_source_location()=source_location; result.set_identifier(identifier); @@ -1801,7 +1801,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + symbol_exprt result; result.add_source_location()=source_location; result.set_identifier(identifier); @@ -1834,7 +1834,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + if(fargs.operands[1].type().id()!=ID_pointer) { error().source_location=source_location; @@ -1842,7 +1842,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + const exprt &ptr_arg=fargs.operands.front(); symbol_exprt result; @@ -1875,7 +1875,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + if(fargs.operands[1].type().id()!=ID_pointer) { error().source_location=source_location; @@ -1883,7 +1883,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + if(fargs.operands[2].type().id()!=ID_pointer) { error().source_location=source_location; @@ -1891,7 +1891,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + const exprt &ptr_arg=fargs.operands.front(); symbol_exprt result; @@ -1927,7 +1927,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + if(fargs.operands[1].type().id()!=ID_pointer) { error().source_location=source_location; @@ -1953,12 +1953,12 @@ void cpp_typecheckt::typecheck_expr_cpp_name( code_typet t; t.parameters().push_back(code_typet::parametert(ptr_arg.type())); t.parameters().push_back(code_typet::parametert(ptr_arg.type())); - + if(identifier=="__atomic_compare_exchange") t.parameters().push_back(code_typet::parametert(ptr_arg.type())); else t.parameters().push_back(code_typet::parametert(ptr_arg.type().subtype())); - + t.parameters().push_back(code_typet::parametert(c_bool_type())); t.parameters().push_back(code_typet::parametert(signed_int_type())); t.parameters().push_back(code_typet::parametert(signed_int_type())); @@ -1981,7 +1981,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + const exprt &ptr_arg=fargs.operands.front(); if(ptr_arg.type().id()!=ID_pointer) @@ -2017,7 +2017,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( << eom; throw 0; } - + const exprt &ptr_arg=fargs.operands.front(); if(ptr_arg.type().id()!=ID_pointer) @@ -2071,7 +2071,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name( typet name(ID_name); name.set(ID_identifier, tmp); name.add_source_location()=source_location; - + type=name; } } @@ -2211,7 +2211,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( // now do the function -- this has been postponed typecheck_function_expr(expr.function(), cpp_typecheck_fargst(expr)); - + if(expr.function().id()=="pod_constructor") { assert(expr.function().type().id()==ID_code); @@ -2221,7 +2221,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( assert(cpp_is_pod(pod)); // These aren't really function calls, but either conversions or - // initializations. + // initializations. if(expr.arguments().empty()) { // create temporary object @@ -2269,7 +2269,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( // look at type of function follow_symbol(expr.function().type()); - + if(expr.function().type().id()==ID_pointer) { if(expr.function().type().find("to-member").is_not_nil()) @@ -2438,7 +2438,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( exprt new_object("new_object", tmp_object_expr.type()); new_object.set(ID_C_lvalue, true); - + assert(follow(tmp_object_expr.type()).id()==ID_struct); get_component(expr.source_location(), @@ -2482,7 +2482,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call( } expr.function().swap(member); - + typecheck_method_application(expr); typecheck_function_call_arguments(expr); @@ -2601,7 +2601,7 @@ void cpp_typecheckt::typecheck_function_call_arguments( } } - + c_typecheck_baset::typecheck_function_call_arguments(expr); } @@ -2693,7 +2693,7 @@ void cpp_typecheckt::typecheck_method_application( assert(this_type.id()==ID_pointer); this_type.set(ID_C_reference, true); this_type.set("#this", true); - + if(expr.arguments().size()==func_type.parameters().size()) { // this might be set up for base-class initialisation @@ -2744,7 +2744,7 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) << eom; throw 0; } - + typet type0=expr.op0().type(); if(is_reference(type0)) @@ -2758,7 +2758,7 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) expr.op0().set(ID_C_lvalue, true); c_typecheck_baset::typecheck_side_effect_assignment(expr); - + // Note that in C++ (as opposed to C), the assignment yields // an lvalue! expr.set(ID_C_lvalue, true); @@ -2769,7 +2769,7 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) // Turn into an operator call std::string strop="operator"; - + const irep_idt statement=expr.get(ID_statement); if(statement==ID_assign) @@ -2905,7 +2905,7 @@ void cpp_typecheckt::typecheck_side_effect_inc_dec( if(post) new_expr.arguments().push_back( from_integer(mp_integer(0), signed_int_type())); - + typecheck_side_effect_function_call(new_expr); expr.swap(new_expr); } @@ -3075,11 +3075,11 @@ void cpp_typecheckt::typecheck_expr(exprt &expr) { bool override_constantness= expr.get_bool("#override_constantness"); - + // We take care of an ambiguity in the C++ grammar. // Needs to be done before the operands! explicit_typecast_ambiguity(expr); - + // cpp_name uses get_sub, which can get confused with expressions. if(expr.id()==ID_cpp_name) typecheck_expr_cpp_name(expr, cpp_typecheck_fargst()); @@ -3117,11 +3117,11 @@ void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) if(expr.id()!="explicit-typecast") return; - + assert(expr.operands().size()==1); - + irep_idt op0_id=expr.op0().id(); - + if(expr.type().id()==ID_cpp_name && expr.op0().operands().size()==1 && (op0_id==ID_unary_plus || @@ -3140,11 +3140,11 @@ void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) // need to re-write the expression // e.g., (ID) +expr -> ID+expr exprt new_binary_expr; - + new_binary_expr.operands().resize(2); new_binary_expr.op0().swap(expr.type()); new_binary_expr.op1().swap(expr.op0().op0()); - + if(op0_id==ID_unary_plus) new_binary_expr.id(ID_plus); else if(op0_id==ID_unary_minus) @@ -3153,12 +3153,12 @@ void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) new_binary_expr.id(ID_bitand); else if(op0_id==ID_dereference) new_binary_expr.id(ID_mult); - + new_binary_expr.add_source_location()=expr.op0().source_location(); expr.swap(new_binary_expr); } } - + } /*******************************************************************\ @@ -3251,4 +3251,3 @@ void cpp_typecheckt::typecheck_expr_rel(binary_relation_exprt &expr) { c_typecheck_baset::typecheck_expr_rel(expr); } - diff --git a/src/cpp/cpp_typecheck_fargs.cpp b/src/cpp/cpp_typecheck_fargs.cpp index 45e671b7c53..48088cd3e6f 100644 --- a/src/cpp/cpp_typecheck_fargs.cpp +++ b/src/cpp/cpp_typecheck_fargs.cpp @@ -98,7 +98,7 @@ bool cpp_typecheck_fargst::match( if(default_value.is_nil()) return false; - + ops.push_back(default_value); } } @@ -118,14 +118,14 @@ bool cpp_typecheck_fargst::match( // * Standard conversion sequences // * User-defined conversion sequences // * Ellipsis conversion sequences - + if(i>=parameters.size()) { // Ellipsis is the 'worst' of the conversion sequences distance+=1000; continue; } - + exprt parameter=parameters[i]; exprt &operand=ops[i]; diff --git a/src/cpp/cpp_typecheck_fargs.h b/src/cpp/cpp_typecheck_fargs.h index 74d66a6c70f..e1b4a36ba7b 100644 --- a/src/cpp/cpp_typecheck_fargs.h +++ b/src/cpp/cpp_typecheck_fargs.h @@ -18,7 +18,7 @@ class cpp_typecheck_fargst // for function overloading public: bool in_use, has_object; exprt::operandst operands; - + // has_object indicates that the first element of // 'operands' is the 'this' pointer (with the object type, // not pointer to object type) diff --git a/src/cpp/cpp_typecheck_function.cpp b/src/cpp/cpp_typecheck_function.cpp index dae73b334b8..5b3b1c1c917 100644 --- a/src/cpp/cpp_typecheck_function.cpp +++ b/src/cpp/cpp_typecheck_function.cpp @@ -166,11 +166,11 @@ void cpp_typecheckt::convert_function(symbolt &symbol) if(return_type.id()==ID_constructor || return_type.id()==ID_destructor) return_type=empty_typet(); - + typecheck_code(to_code(symbol.value)); symbol.value.type()=symbol.type; - + return_type = old_return_type; } diff --git a/src/cpp/cpp_typecheck_initializer.cpp b/src/cpp/cpp_typecheck_initializer.cpp index 58ec93c0929..a225902d543 100644 --- a/src/cpp/cpp_typecheck_initializer.cpp +++ b/src/cpp/cpp_typecheck_initializer.cpp @@ -116,7 +116,7 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol) if(resolved_expr.id()==ID_symbol) { - symbol.value= + symbol.value= address_of_exprt(resolved_expr); } else if(resolved_expr.id()==ID_member) @@ -129,7 +129,7 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol) } else assert(false); - + if(symbol.type != symbol.value.type()) { error().source_location=symbol.location; @@ -143,12 +143,12 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol) } typecheck_expr(symbol.value); - + if(symbol.value.id()==ID_initializer_list || symbol.value.id()==ID_string_constant) { do_initializer(symbol.value, symbol.type, true); - + if(symbol.type.find(ID_size).is_nil()) symbol.type=symbol.value.type(); } @@ -281,7 +281,7 @@ void cpp_typecheckt::zero_initializer( irept name(ID_name); name.set(ID_identifier, comp.get(ID_base_name)); name.set(ID_C_source_location, source_location); - + cpp_namet cpp_name; cpp_name.move_to_sub(name); diff --git a/src/cpp/cpp_typecheck_linkage_spec.cpp b/src/cpp/cpp_typecheck_linkage_spec.cpp index 24fb27e72ba..39ebc12db29 100644 --- a/src/cpp/cpp_typecheck_linkage_spec.cpp +++ b/src/cpp/cpp_typecheck_linkage_spec.cpp @@ -25,7 +25,7 @@ void cpp_typecheckt::convert(cpp_linkage_spect &linkage_spec) irep_idt old_linkage_spec=current_linkage_spec; current_linkage_spec=linkage_spec.linkage().get(ID_value); - + // there is a linkage spec "C++", which we know as "cpp" if(current_linkage_spec=="C++") current_linkage_spec=ID_cpp; diff --git a/src/cpp/cpp_typecheck_method_bodies.cpp b/src/cpp/cpp_typecheck_method_bodies.cpp index eaf9f1545e9..5635cf5005e 100644 --- a/src/cpp/cpp_typecheck_method_bodies.cpp +++ b/src/cpp/cpp_typecheck_method_bodies.cpp @@ -33,7 +33,7 @@ void cpp_typecheckt::typecheck_method_bodies( symbolt &method_symbol=*b.method_symbol; template_map.swap(b.template_map); instantiation_stack.swap(b.instantiation_stack); - + if(method_symbol.name==ID_main) add_argc_argv(method_symbol); @@ -50,4 +50,3 @@ void cpp_typecheckt::typecheck_method_bodies( old_instantiation_stack.swap(instantiation_stack); } - diff --git a/src/cpp/cpp_typecheck_namespace.cpp b/src/cpp/cpp_typecheck_namespace.cpp index e01ab039608..81fea3a3eae 100644 --- a/src/cpp/cpp_typecheck_namespace.cpp +++ b/src/cpp/cpp_typecheck_namespace.cpp @@ -56,7 +56,7 @@ void cpp_typecheckt::convert(cpp_namespace_spect &namespace_spec) << it->second.location << eom; throw 0; } - + if(it->second.type.id()!=ID_namespace) { error().source_location=namespace_spec.source_location(); diff --git a/src/cpp/cpp_typecheck_resolve.cpp b/src/cpp/cpp_typecheck_resolve.cpp index 8edae1c897b..81867bac864 100644 --- a/src/cpp/cpp_typecheck_resolve.cpp +++ b/src/cpp/cpp_typecheck_resolve.cpp @@ -69,7 +69,7 @@ void cpp_typecheck_resolvet::convert_identifiers( { const cpp_idt &identifier=**it; exprt e=convert_identifier(identifier, want, fargs); - + if(e.is_not_nil()) { if(e.id()==ID_type) @@ -136,7 +136,7 @@ void cpp_typecheck_resolvet::guess_function_template_args( { resolve_identifierst old_identifiers; old_identifiers.swap(identifiers); - + for(resolve_identifierst::const_iterator it=old_identifiers.begin(); it!=old_identifiers.end(); @@ -150,9 +150,9 @@ void cpp_typecheck_resolvet::guess_function_template_args( identifiers.push_back(e); } } - + disambiguate_functions(identifiers, fargs); - + // there should only be one left, or we have failed to disambiguate if(identifiers.size()==1) { @@ -162,7 +162,7 @@ void cpp_typecheck_resolvet::guess_function_template_args( const symbolt &template_symbol= cpp_typecheck.lookup(e.type().get(ID_C_template)); - + const cpp_template_args_tct &template_args= to_cpp_template_args_tc(e.type().find(ID_C_template_arguments)); @@ -174,8 +174,8 @@ void cpp_typecheck_resolvet::guess_function_template_args( template_symbol, template_args, template_args); - - identifiers.clear(); + + identifiers.clear(); identifiers.push_back( symbol_exprt(new_symbol.name, new_symbol.type)); } @@ -226,7 +226,7 @@ void cpp_typecheck_resolvet::remove_duplicates( { resolve_identifierst old_identifiers; old_identifiers.swap(identifiers); - + std::set ids; std::set other; @@ -236,7 +236,7 @@ void cpp_typecheck_resolvet::remove_duplicates( it++) { irep_idt id; - + if(it->id()==ID_symbol) id=it->get(ID_identifier); else if(it->id()==ID_type && it->type().id()==ID_symbol) @@ -272,7 +272,7 @@ exprt cpp_typecheck_resolvet::convert_template_parameter( { // look up the parameter in the template map exprt e=cpp_typecheck.template_map.lookup(identifier.identifier); - + if(e.is_nil() || (e.id()==ID_type && e.type().is_nil())) { @@ -284,7 +284,7 @@ exprt cpp_typecheck_resolvet::convert_template_parameter( } e.add_source_location()=source_location; - + return e; } @@ -315,7 +315,7 @@ exprt cpp_typecheck_resolvet::convert_identifier( !identifier.is_static_member) { // a regular struct or union member - + const symbolt &compound_symbol= cpp_typecheck.lookup(identifier.class_identifier); @@ -351,10 +351,10 @@ exprt cpp_typecheck_resolvet::convert_identifier( << " " << cpp_typecheck.cpp_scopes.current_scope().this_class_identifier << std::endl; #endif - + const exprt &this_expr= original_scope->this_expr; - + if(fargs.has_object) { // the object is given to us in fargs @@ -375,8 +375,8 @@ exprt cpp_typecheck_resolvet::convert_identifier( // check if the member can be applied to the object typet object_type=cpp_typecheck.follow(object.type()); - - if(object_type.id()==ID_struct || + + if(object_type.id()==ID_struct || object_type.id()==ID_union) { if(!has_component_rec( @@ -412,7 +412,7 @@ exprt cpp_typecheck_resolvet::convert_identifier( { const symbolt &symbol= cpp_typecheck.lookup(identifier.identifier); - + if(symbol.is_type) { e=type_exprt(); @@ -461,7 +461,7 @@ exprt cpp_typecheck_resolvet::convert_identifier( } } } - + e.add_source_location()=source_location; return e; @@ -485,14 +485,14 @@ void cpp_typecheck_resolvet::filter( { resolve_identifierst old_identifiers; old_identifiers.swap(identifiers); - + for(resolve_identifierst::const_iterator it=old_identifiers.begin(); it!=old_identifiers.end(); it++) { bool match=false; - + switch(want) { case TYPE: @@ -536,7 +536,7 @@ void cpp_typecheck_resolvet::exact_match_functions( resolve_identifierst old_identifiers; old_identifiers.swap(identifiers); - + identifiers.clear(); // put in the ones that match precisely @@ -570,7 +570,7 @@ void cpp_typecheck_resolvet::disambiguate_functions( { resolve_identifierst old_identifiers; old_identifiers.swap(identifiers); - + // sort according to distance std::multimap distance_map; @@ -580,11 +580,11 @@ void cpp_typecheck_resolvet::disambiguate_functions( it++) { unsigned args_distance; - + if(disambiguate_functions(*it, args_distance, fargs)) { std::size_t template_distance=0; - + if(it->type().get(ID_C_template)!="") template_distance=it->type(). find(ID_C_template_arguments).find(ID_arguments).get_sub().size(); @@ -593,7 +593,7 @@ void cpp_typecheck_resolvet::disambiguate_functions( // fewer template arguments std::size_t total_distance= 1000*template_distance+args_distance; - + distance_map.insert( std::pair(total_distance, *it)); } @@ -612,7 +612,7 @@ void cpp_typecheck_resolvet::disambiguate_functions( it++) identifiers.push_back(it->second); } - + if(identifiers.size()>1 && fargs.in_use) { // try to further disambiguate functions @@ -623,7 +623,7 @@ void cpp_typecheck_resolvet::disambiguate_functions( it1++) { if(it1->type().id()!=ID_code) continue; - + const code_typet &f1= to_code_type(it1->type()); @@ -741,7 +741,7 @@ void cpp_typecheck_resolvet::make_constructors( cpp_typecheck.follow(it->type()); // is it a POD? - + if(cpp_typecheck.cpp_is_pod(symbol_type)) { // there are two pod constructors: @@ -763,7 +763,7 @@ void cpp_typecheck_resolvet::make_constructors( exprt pod_constructor2("pod_constructor", t2); new_identifiers.push_back(pod_constructor2); } - + // enums, in addition, can also be constructed from int if(symbol_type.id()==ID_c_enum_tag) { @@ -1003,7 +1003,7 @@ exprt cpp_typecheck_resolvet::do_builtin( << base_name << messaget::eom; throw 0; } - + return dest; } @@ -1033,7 +1033,7 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope( source_location=cpp_name.source_location(); irept::subt::const_iterator pos=cpp_name.get_sub().begin(); - + bool recursive=true; // check if we need to go to the root scope @@ -1056,7 +1056,7 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope( else if(pos->id()=="::") { cpp_scopest::id_sett id_set; - + if(template_args.is_not_nil()) { cpp_typecheck.cpp_scopes.current_scope().lookup( @@ -1068,15 +1068,15 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope( // std::cout << "S: " << cpp_typecheck.cpp_scopes.current_scope().identifier << std::endl; // cpp_typecheck.cpp_scopes.current_scope().print(std::cout); // std::cout << "X: " << id_set.size() < primary_templates; - + for(cpp_scopest::id_sett::const_iterator it=id_set.begin(); it!=id_set.end(); @@ -1214,7 +1214,7 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( << "' is ambiguous" << messaget::eom; throw 0; } - + assert(primary_templates.size()==1); const symbolt &primary_template_symbol= @@ -1223,13 +1223,13 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( // We typecheck the template arguments in the context // of the original scope! cpp_template_args_tct full_template_args_tc; - + { cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes); cpp_typecheck.cpp_scopes.go_to(*original_scope); - // use template type of 'primary template' + // use template type of 'primary template' full_template_args_tc= cpp_typecheck.typecheck_template_args( source_location, @@ -1239,14 +1239,14 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( } // find any matches - + std::vector matches; // the baseline matches.push_back( matcht(full_template_args_tc, full_template_args_tc, primary_template_symbol.name)); - + for(cpp_scopest::id_sett::const_iterator it=id_set.begin(); it!=id_set.end(); @@ -1260,10 +1260,10 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( const cpp_declarationt &cpp_declaration= to_cpp_declaration(s.type); - + const cpp_template_args_non_tct &partial_specialization_args= cpp_declaration.partial_specialization_args(); - + // alright, set up template arguments as 'unassigned' cpp_saved_template_mapt saved_map(cpp_typecheck.template_map); @@ -1309,11 +1309,11 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( cpp_template_args_tct guessed_template_args= cpp_typecheck.template_map.build_template_args( cpp_declaration.template_type()); - + if(!guessed_template_args.has_unassigned()) { // check: we can now typecheck the partial_specialization_args - + cpp_template_args_tct partial_specialization_args_tc= cpp_typecheck.typecheck_template_args( source_location, @@ -1321,21 +1321,21 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( partial_specialization_args); // if these match the arguments, we have a match - + assert(partial_specialization_args_tc.arguments().size()== full_template_args_tc.arguments().size()); if(partial_specialization_args_tc== full_template_args_tc) - { + { matches.push_back(matcht( guessed_template_args, full_template_args_tc, id)); } } } - + assert(!matches.empty()); - + std::sort(matches.begin(), matches.end()); #if 0 @@ -1347,23 +1347,23 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( std::cout << "M: " << m_it->cost << " " << m_it->id << std::endl; } - + std::cout << std::endl; #endif - + const matcht &match=*matches.begin(); const symbolt &choice= cpp_typecheck.lookup(match.id); - + #if 0 - // build instance + // build instance const symbolt &instance= cpp_typecheck.instantiate_template( source_location, choice, match.specialization_args, - match.full_args); + match.full_args); if(instance.type.id()!=ID_struct && instance.type.id()!=ID_incomplete_struct) @@ -1380,18 +1380,18 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( return result; #else - // build instance + // build instance const symbolt &instance= cpp_typecheck.class_template_symbol( source_location, choice, match.specialization_args, - match.full_args); + match.full_args); symbol_typet result(instance.name); result.add_source_location()=source_location; - return result; + return result; #endif } @@ -1475,7 +1475,7 @@ void cpp_typecheck_resolvet::show_identifiers( it++) { const exprt &id_expr=*it; - + out << " "; if(id_expr.id()==ID_type) @@ -1530,7 +1530,7 @@ void cpp_typecheck_resolvet::show_identifiers( out << cpp_typecheck.to_string(parameter_type); } - + if(code_type.has_ellipsis()) { if(!parameters.empty()) out << ", "; @@ -1582,7 +1582,7 @@ exprt cpp_typecheck_resolvet::resolve( original_scope=&cpp_typecheck.cpp_scopes.current_scope(); cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes); - + // this changes the scope resolve_scope(cpp_name, base_name, template_args); @@ -1609,12 +1609,12 @@ exprt cpp_typecheck_resolvet::resolve( return s; } } - + cpp_scopest::id_sett id_set; - + cpp_scopet::lookup_kindt lookup_kind= qualified?cpp_scopet::QUALIFIED:cpp_scopet::RECURSIVE; - + if(template_args.is_nil()) cpp_typecheck.cpp_scopes.current_scope().lookup(base_name, lookup_kind, id_set); else @@ -1659,9 +1659,9 @@ exprt cpp_typecheck_resolvet::resolve( //cpp_typecheck.cpp_scopes.current_scope().print(std::cout); throw 0; } - + resolve_identifierst identifiers; - + if(template_args.is_not_nil()) { // first figure out if we are doing functions/methods or @@ -1693,7 +1693,7 @@ exprt cpp_typecheck_resolvet::resolve( << base_name << "' is ambiguous" << messaget::eom; throw 0; } - + if(want==TYPE || have_classes) { typet instance= @@ -1727,7 +1727,7 @@ exprt cpp_typecheck_resolvet::resolve( show_identifiers(base_name, identifiers, std::cout); std::cout << "\n"; #endif - + exprt result; // We disambiguate functions @@ -1743,7 +1743,7 @@ exprt cpp_typecheck_resolvet::resolve( // we only want _exact_ matches, without templates! exact_match_functions(new_identifiers, fargs); - + #if 0 std::cout << "P2 " << base_name << " " << new_identifiers.size() << "\n"; show_identifiers(base_name, new_identifiers, std::cout); @@ -1754,11 +1754,11 @@ exprt cpp_typecheck_resolvet::resolve( if(new_identifiers.empty()) { new_identifiers=identifiers; - + if(template_args.is_nil()) { guess_function_template_args(new_identifiers, fargs); - + if(new_identifiers.empty()) new_identifiers=identifiers; } @@ -1771,7 +1771,7 @@ exprt cpp_typecheck_resolvet::resolve( std::cout << "\n"; #endif } - + remove_duplicates(new_identifiers); #if 0 @@ -1779,7 +1779,7 @@ exprt cpp_typecheck_resolvet::resolve( show_identifiers(base_name, new_identifiers, std::cout); std::cout << "\n"; #endif - + if(new_identifiers.size()==1) { result=*new_identifiers.begin(); @@ -1804,7 +1804,7 @@ exprt cpp_typecheck_resolvet::resolve( << "symbol `" << base_name << "' does not uniquely resolve:\n"; show_identifiers(base_name, new_identifiers, cpp_typecheck.error()); - + #if 0 exprt e1=*new_identifiers.begin(); exprt e2=*(++new_identifiers.begin()); @@ -1840,7 +1840,7 @@ exprt cpp_typecheck_resolvet::resolve( cpp_typecheck.error() << messaget::eom; throw 0; } - + // we do some checks before we return if(result.get_bool("#not_accessible")) { @@ -1890,7 +1890,7 @@ exprt cpp_typecheck_resolvet::resolve( default:; } - + return result; } @@ -1918,7 +1918,7 @@ void cpp_typecheck_resolvet::guess_template_args( if(!cpp_name.is_qualified()) { cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes); - + cpp_template_args_non_tct template_args; irep_idt base_name; resolve_scope(cpp_name, base_name, template_args); @@ -1946,7 +1946,7 @@ void cpp_typecheck_resolvet::guess_template_args( e.make_typecast(old_type); } } - } + } } } } @@ -2007,17 +2007,17 @@ void cpp_typecheck_resolvet::guess_template_args( const cpp_namet &cpp_name=to_cpp_name(template_type); cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes); - + if(cpp_name.has_template_args()) { // this could be s.th. like my_template, and we need // to match 'T'. Then 'desired_type' has to be a template instance. - + // TODO } else { - // template parameters aren't qualified + // template parameters aren't qualified if(!cpp_name.is_qualified()) { irep_idt base_name; @@ -2054,7 +2054,7 @@ void cpp_typecheck_resolvet::guess_template_args( #endif } } - } + } } } } @@ -2120,16 +2120,16 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( { typet tmp=expr.type(); cpp_typecheck.follow_symbol(tmp); - + if(!tmp.get_bool(ID_is_template)) return nil_exprt(); // not a template assert(expr.id()==ID_symbol); - - // a template is always a declaration + + // a template is always a declaration const cpp_declarationt &cpp_declaration= to_cpp_declaration(tmp); - + // Class templates require explicit template arguments, // no guessing! if(cpp_declaration.is_class_template()) @@ -2138,17 +2138,17 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( // we need function arguments for guessing if(fargs.operands.empty()) return nil_exprt(); // give up - + // We need to guess in the case of function templates! irep_idt template_identifier= to_symbol_expr(expr).get_identifier(); - + const symbolt &template_symbol= cpp_typecheck.lookup(template_identifier); - + // alright, set up template arguments as 'unassigned' - + cpp_saved_template_mapt saved_map(cpp_typecheck.template_map); cpp_typecheck.template_map.build_unassigned( @@ -2156,11 +2156,11 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( // there should be exactly one declarator assert(cpp_declaration.declarators().size()==1); - + const cpp_declaratort &function_declarator= cpp_declaration.declarators().front(); - - // and that needs to have function type + + // and that needs to have function type if(function_declarator.type().id()!=ID_function_type) { cpp_typecheck.error().source_location=source_location; @@ -2193,7 +2193,7 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( // walk through the function parameters const irept::subt ¶meters= function_declarator.type().find(ID_parameters).get_sub(); - + for(std::size_t i=0; itype().get(ID_identifier)); assert(type_symb.type.id()==ID_struct); @@ -2382,7 +2382,7 @@ bool cpp_typecheck_resolvet::disambiguate_functions( const cpp_typecheck_fargst &fargs) { args_distance=0; - + if(expr.type().id()!=ID_code || !fargs.in_use) return true; @@ -2434,7 +2434,7 @@ bool cpp_typecheck_resolvet::disambiguate_functions( return new_fargs.match(type, args_distance, cpp_typecheck); } - + return fargs.match(type, args_distance, cpp_typecheck); } @@ -2454,7 +2454,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( cpp_scopest::id_sett &id_set) { cpp_scopest::id_sett new_set; - + // std::cout << "FILTER\n"; // We only want scopes! @@ -2487,7 +2487,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( assert(type.id()!=ID_struct); if(type.id()==ID_symbol) identifier=type.get(ID_identifier); - else + else continue; } @@ -2502,7 +2502,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( // this is a scope, too! cpp_idt &class_id= cpp_typecheck.cpp_scopes.get_id(identifier); - + assert(class_id.is_scope); new_set.insert(&class_id); break; @@ -2537,13 +2537,13 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( exprt e=cpp_typecheck.template_map.lookup(id.identifier); #if 0 - cpp_typecheck.template_map.print(std::cout); + cpp_typecheck.template_map.print(std::cout); std::cout << "S: " << cpp_typecheck.cpp_scopes.current_scope().identifier << std::endl; std::cout << "P: " << cpp_typecheck.cpp_scopes.current_scope().get_parent() << std::endl; std::cout << "I: " << id.identifier << std::endl; std::cout << "E: " << e.pretty() << std::endl; #endif - + if(e.id()!=ID_type) continue; // expressions are definitively not a scope @@ -2557,7 +2557,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( const symbolt &symbol=cpp_typecheck.lookup(identifier); assert(symbol.is_type); - + if(symbol.type.id()==ID_symbol) type=to_symbol_type(symbol.type); else if(symbol.type.id()==ID_struct || @@ -2569,7 +2569,7 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( // this is a scope, too! cpp_idt &class_id= cpp_typecheck.cpp_scopes.get_id(identifier); - + assert(class_id.is_scope); new_set.insert(&class_id); break; diff --git a/src/cpp/cpp_typecheck_resolve.h b/src/cpp/cpp_typecheck_resolve.h index afcf66e35aa..3364671dfe0 100644 --- a/src/cpp/cpp_typecheck_resolve.h +++ b/src/cpp/cpp_typecheck_resolve.h @@ -40,7 +40,7 @@ class cpp_typecheck_resolvet cpp_typecheckt &cpp_typecheck; source_locationt source_location; cpp_scopet *original_scope; - + typedef std::vector resolve_identifierst; void convert_identifiers( @@ -48,10 +48,10 @@ class cpp_typecheck_resolvet const wantt want, const cpp_typecheck_fargst &fargs, resolve_identifierst &identifiers); - + exprt convert_template_parameter( const cpp_idt &id); - + exprt convert_identifier( const cpp_idt &id, const wantt want, @@ -100,15 +100,15 @@ class cpp_typecheck_resolvet exprt guess_function_template_args( const exprt &expr, const cpp_typecheck_fargst &fargs); - + void guess_template_args( const typet &template_parameter, const typet &desired_type); - + void guess_template_args( const exprt &template_parameter, const exprt &desired_expr); - + bool disambiguate_functions( const exprt &expr, unsigned &args_distance, @@ -147,12 +147,12 @@ class cpp_typecheck_resolvet { } }; - + inline friend bool operator < (const matcht &m1, const matcht &m2) { return m1.costsecond.type); - + bool previous_has_body= previous_declaration.type().find(ID_body).is_not_nil(); @@ -183,7 +183,7 @@ void cpp_typecheckt::typecheck_class_template( << previous_symbol->second.location << eom; throw 0; } - + if(has_body) { // We replace the template! @@ -191,9 +191,9 @@ void cpp_typecheckt::typecheck_class_template( salvage_default_arguments( previous_declaration.template_type(), declaration.template_type()); - + previous_symbol->second.type.swap(declaration); - + #if 0 std::cout << "*****\n"; std::cout << *cpp_scopes.id_map[symbol_name]; @@ -203,7 +203,7 @@ void cpp_typecheckt::typecheck_class_template( // We also replace the template scope (the old one could be deleted). cpp_scopes.id_map[symbol_name]=&template_scope; - + // We also fix the parent scope in order to see the new // template arguments } @@ -214,7 +214,7 @@ void cpp_typecheckt::typecheck_class_template( declaration.template_type(), previous_declaration.template_type()); } - + assert(cpp_scopes.id_map[symbol_name]->id_class == cpp_idt::TEMPLATE_SCOPE); return; } @@ -290,7 +290,7 @@ void cpp_typecheckt::typecheck_function_template( irep_idt base_name=cpp_name.get_base_name(); template_typet &template_type=declaration.template_type(); - + typet function_type= declarator.merge_type(declaration.type()); @@ -458,15 +458,15 @@ void cpp_typecheckt::typecheck_class_template_member( exprt &template_methods=static_cast( template_symbol.value.add("template_methods")); - + template_methods.copy_to_operands(declaration); // save current scope cpp_save_scopet cpp_saved_scope(cpp_scopes); - const irept &instantiated_with = + const irept &instantiated_with = template_symbol.value.add("instantiated_with"); - + for(std::size_t i=0; iid()==ID_type) identifier+="Type"+i2string(counter); else @@ -533,19 +533,19 @@ std::string cpp_typecheckt::class_template_identifier( } identifier += ">"; - + if(!partial_specialization_args.arguments().empty()) { identifier+="_specialized_to_<"; - + counter=0; for(cpp_template_args_non_tct::argumentst::const_iterator it=partial_specialization_args.arguments().begin(); it!=partial_specialization_args.arguments().end(); it++, counter++) - { + { if(counter!=0) identifier+=','; - + // These are not yet typechecked, as they may depend // on unassigned template parameters. @@ -554,10 +554,10 @@ std::string cpp_typecheckt::class_template_identifier( else identifier+=cpp_expr2name(*it); } - + identifier+='>'; } - + return identifier; } @@ -620,7 +620,7 @@ void cpp_typecheckt::convert_class_template_specialization( error() << "qualifiers not expected here" << eom; throw 0; } - + if(cpp_name.get_sub().size()!=2 || cpp_name.get_sub()[0].id()!=ID_name || cpp_name.get_sub()[1].id()!=ID_template_args) @@ -635,7 +635,7 @@ void cpp_typecheckt::convert_class_template_specialization( irep_idt base_name= cpp_name.get_sub()[0].get(ID_identifier); - // copy the template arguments + // copy the template arguments const cpp_template_args_non_tct template_args_non_tc= to_cpp_template_args_non_tc(cpp_name.get_sub()[1]); @@ -656,11 +656,11 @@ void cpp_typecheckt::convert_class_template_specialization( { cpp_scopest::id_sett::iterator next=it; next++; - + if(lookup((*it)->identifier).type. find("specialization_of").is_not_nil()) id_set.erase(it); - + it=next; } @@ -678,14 +678,14 @@ void cpp_typecheckt::convert_class_template_specialization( << eom; throw 0; } - + symbol_tablet::symbolst::iterator s_it= symbol_table.symbols.find((*id_set.begin())->identifier); - + assert(s_it!=symbol_table.symbols.end()); - + symbolt &template_symbol=s_it->second; - + if(!template_symbol.type.get_bool(ID_is_template)) { error().source_location=type.source_location(); @@ -693,7 +693,7 @@ void cpp_typecheckt::convert_class_template_specialization( } #if 0 - // is this partial specialization? + // is this partial specialization? if(declaration.template_type().parameters().empty()) { // typecheck arguments -- these are for the 'primary' template! @@ -702,7 +702,7 @@ void cpp_typecheckt::convert_class_template_specialization( declaration.source_location(), to_cpp_declaration(template_symbol.type).template_type(), template_args_non_tc); - + // Full specialization, i.e., template<>. // We instantiate. instantiate_template( @@ -713,7 +713,7 @@ void cpp_typecheckt::convert_class_template_specialization( } else #endif - + { // partial specialization -- we typecheck declaration.partial_specialization_args()=template_args_non_tc; @@ -739,7 +739,7 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( cpp_declarationt &declaration) { cpp_save_scopet saved_scope(cpp_scopes); - + if(declaration.declarators().size()!=1 || declaration.declarators().front().type().id()!=ID_function_type) { @@ -758,12 +758,12 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( error() << "qualifiers not expected here" << eom; throw 0; } - + // There is specialization (instantiation with template arguments) // but also function overloading (no template arguments) - + assert(!cpp_name.get_sub().empty()); - + if(cpp_name.get_sub().back().id()==ID_template_args) { // proper specialization with arguments @@ -799,7 +799,7 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( << "' is ambiguous" << eom; throw 0; } - + const symbolt &template_symbol= lookup((*id_set.begin())->identifier); @@ -827,11 +827,11 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( // for disambiguation purposes! // http://www.gotw.ca/publications/mill17.htm cpp_declarationt new_declaration=declaration; - + new_declaration.remove(ID_template_type); new_declaration.remove(ID_is_template); new_declaration.set(ID_C_template, ""); // todo, get identifier - + convert_non_template_declaration(new_declaration); } } @@ -882,7 +882,7 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( cpp_declarationt declaration; declaration.swap(static_cast(parameter)); - + cpp_declarator_convertert cpp_declarator_converter(*this); // there must be _one_ declarator @@ -908,17 +908,17 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( error() << "template parameter must be simple name" << eom; throw 0; } - + cpp_scopet &scope=cpp_scopes.current_scope(); - + irep_idt base_name=declarator.name().get_sub().front().get(ID_identifier); irep_idt identifier=scope.prefix+id2string(base_name); - + // add to scope cpp_idt &id=scope.insert(base_name); id.identifier=identifier; id.id_class=cpp_idt::TEMPLATE_PARAMETER; - + // is it a type or not? if(declaration.get_bool(ID_is_type)) { @@ -939,8 +939,8 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( // because of possible dependencies on earlier parameters! if(declarator.value().is_not_nil()) parameter.add(ID_C_default_value)=declarator.value(); - - #else + + #else // is it a type or not? cpp_declarator_converter.is_typedef=declaration.get_bool(ID_is_type); @@ -964,7 +964,7 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( } else parameter=symbol.symbol_expr(); - + // set (non-typechecked) default value if(default_value.is_not_nil()) parameter.add(ID_C_default_value)=default_value; @@ -1010,10 +1010,10 @@ cpp_template_args_tct cpp_typecheckt::typecheck_template_args( cpp_template_args_tct::argumentst &args= result.arguments(); - + const template_typet::template_parameterst ¶meters= template_type.template_parameters(); - + if(parameters.size()=args.size()) { // Check for default argument for the parameter. @@ -1047,7 +1047,7 @@ cpp_template_args_tct cpp_typecheckt::typecheck_template_args( } args.push_back(parameter.default_argument()); - + // these need to be typechecked in the scope of the template, // not in the current scope! cpp_idt *template_scope=cpp_scopes.id_map[template_symbol.name]; @@ -1056,9 +1056,9 @@ cpp_template_args_tct cpp_typecheckt::typecheck_template_args( } assert(icpp_scopes); @@ -40,7 +40,7 @@ void cpp_typecheckt::convert(cpp_usingt &cpp_using) cpp_scopes.current_scope().lookup( base_name, qualified?cpp_scopet::QUALIFIED:cpp_scopet::RECURSIVE, id_set); - + bool using_directive=cpp_using.get_namespace(); if(id_set.empty()) diff --git a/src/cpp/cpp_typecheck_virtual_table.cpp b/src/cpp/cpp_typecheck_virtual_table.cpp index 6223e7822ae..151ea1034e2 100644 --- a/src/cpp/cpp_typecheck_virtual_table.cpp +++ b/src/cpp/cpp_typecheck_virtual_table.cpp @@ -21,7 +21,7 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol) assert(symbol.type.id()==ID_struct); // builds virtual-table value maps: (class x virtual_name x value) - std::map > vt_value_maps; + std::map > vt_value_maps; const struct_typet &struct_type = to_struct_type(symbol.type); @@ -65,7 +65,7 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol) { const std::map& value_map = cit->second; - const symbolt& late_cast_symb = namespacet(symbol_table).lookup(cit->first); + const symbolt& late_cast_symb = namespacet(symbol_table).lookup(cit->first); const symbolt& vt_symb_type = namespacet(symbol_table).lookup("virtual_table::"+id2string(late_cast_symb.name)); symbolt vt_symb_var; diff --git a/src/cpp/cpp_using.h b/src/cpp/cpp_using.h index d0ca8929373..15693a7d8a9 100644 --- a/src/cpp/cpp_using.h +++ b/src/cpp/cpp_using.h @@ -17,17 +17,17 @@ class cpp_usingt:public irept cpp_usingt():irept(ID_cpp_using) { } - + cpp_namet &name() { return (cpp_namet &)add(ID_name); } - const cpp_namet &name() const + const cpp_namet &name() const { return (cpp_namet &)find(ID_name); } - + bool get_namespace() const { return get_bool(ID_namespace); diff --git a/src/cpp/cpp_util.cpp b/src/cpp/cpp_util.cpp index cdfb001d334..1a3c8dfd773 100644 --- a/src/cpp/cpp_util.cpp +++ b/src/cpp/cpp_util.cpp @@ -33,4 +33,3 @@ exprt cpp_symbol_expr(const symbolt &symbol) return tmp; } - diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index 14487c6daf4..38779ec8581 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -177,10 +177,10 @@ std::string expr2cppt::convert_rec( { c_qualifierst new_qualifiers(qualifiers); new_qualifiers.read(src); - + const std::string d= declarator==""?declarator:(" "+declarator); - + const std::string q= new_qualifiers.as_string(); @@ -242,7 +242,7 @@ std::string expr2cppt::convert_rec( symbol.type.id()==ID_incomplete_struct) { std::string dest=q; - + if(symbol.type.get_bool(ID_C_class)) dest+="class"; else if(symbol.type.get_bool(ID_C_interface)) @@ -380,9 +380,9 @@ std::string expr2cppt::convert_rec( // C doesn't really have syntax for function types, // so we use C++11 trailing return types! - + std::string dest="auto"; - + // qualifiers, declarator? if(d.empty()) dest+=' '; @@ -402,7 +402,7 @@ std::string expr2cppt::convert_rec( dest+=convert(it->type()); } - + if(code_type.has_ellipsis()) { if(!parameters.empty()) dest+=", "; @@ -410,7 +410,7 @@ std::string expr2cppt::convert_rec( } dest+=')'; - + const typet &return_type=code_type.return_type(); dest+=" -> "+convert(return_type); diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index 88bbc8c51b1..e0d1ee023ba 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -53,7 +53,7 @@ class new_scopet TEMPLATE_TEMPLATE_PARAMETER } kindt; kindt kind; irep_idt id; - + bool is_type() const { return kind==TYPEDEF || @@ -61,21 +61,21 @@ class new_scopet kind==TAG || kind==CLASS_TEMPLATE; } - + bool is_template() const { return kind==FUNCTION_TEMPLATE || kind==CLASS_TEMPLATE || kind==MEMBER_TEMPLATE; } - + bool is_named_scope() const { return kind==NAMESPACE || kind==TAG || kind==TYPE_TEMPLATE_PARAMETER; } - + static const char *kind2string(kindt kind) { switch(kind) @@ -98,31 +98,31 @@ class new_scopet default: return ""; } } - + typedef std::map id_mapt; id_mapt id_map; - + unsigned anon_count; - + new_scopet *parent; - + inline void print(std::ostream &out) const { print_rec(out, 0); } - + irep_idt get_anon_id() { ++anon_count; return "#anon"+i2string(anon_count); } - + std::string full_name() const { return (parent==NULL?"":(parent->full_name()+"::"))+ id2string(id); } - + protected: void print_rec(std::ostream &, unsigned indent) const; }; @@ -134,12 +134,12 @@ class save_scopet scope_ptr(_scope), old_scope(_scope) { } - + inline ~save_scopet() { scope_ptr=old_scope; } - + protected: new_scopet *&scope_ptr; new_scopet *old_scope; @@ -188,7 +188,7 @@ class Parser protected: cpp_token_buffert &lex; cpp_parsert &parser; - + // scopes new_scopet root_scope; new_scopet *current_scope; @@ -327,10 +327,10 @@ class Parser bool moreVarName(); bool rString(cpp_tokent &tk); - + // GCC extensions bool rGCCAsmStatement(codet &); - + // MSC extensions bool rMSC_tryStatement(codet &); bool rMSC_leaveStatement(codet &); @@ -358,7 +358,7 @@ class Parser void make_subtype(const typet &src, typet &dest) { typet *p=&dest; - + while(p->id()!=irep_idt() && p->is_not_nil()) { if(p->id()==ID_merged_type) @@ -369,7 +369,7 @@ class Parser else p=&p->subtype(); } - + *p=src; } @@ -416,7 +416,7 @@ Function: Parser::add_id new_scopet &Parser::add_id(const irep_idt &id, new_scopet::kindt kind) { new_scopet &s=current_scope->id_map[id]; - + s.kind=kind; s.id=id; s.parent=current_scope; @@ -706,7 +706,7 @@ bool Parser::rTypedef(cpp_declarationt &declaration) if(!rDeclarators(declaration.declarators(), true)) return false; - + return true; } @@ -1010,7 +1010,7 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec) { case '{': return rLinkageBody(namespace_spec.items()); - + case '=': // namespace alias lex.get_token(tk2); // eat = return rName(namespace_spec.alias()); @@ -1187,10 +1187,10 @@ bool Parser::rLinkageBody(cpp_linkage_spect::itemst &items) bool Parser::rTemplateDecl(cpp_declarationt &decl) { TemplateDeclKind kind=tdk_unknown; - + make_sub_scope("#template", new_scopet::TEMPLATE); current_scope->id_map.clear(); - + typet template_type; if(!rTemplateDecl2(template_type, kind)) return false; @@ -1418,7 +1418,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) set_location(name, tk2); cpp_name.get_sub().push_back(name); declarator.name().swap(cpp_name); - + add_id(declarator.name(), new_scopet::TYPE_TEMPLATE_PARAMETER); if(has_ellipsis) @@ -1675,7 +1675,7 @@ bool Parser::rDeclaration(cpp_declarationt &declaration) #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rDeclaration 4\n"; #endif - + if(!optIntegralTypeOrClassSpec(integral)) return false; @@ -1754,7 +1754,7 @@ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) /* no type-specifier so far -> can't be a declaration */ if(integral.is_nil()) return false; - + merge_types(cv_q, integral); declaration.type().swap(integral); @@ -1762,7 +1762,7 @@ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) cpp_declaratort declarator; if(!rDeclarator(declarator, kDeclarator, false, true, true)) return false; - + // there really _has_ to be an initializer! if(lex.LookAhead(0)!='=') @@ -1773,7 +1773,7 @@ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) if(!rExpression(declarator.value(), false)) return false; - + declaration.declarators().push_back(declarator); return true; @@ -1961,7 +1961,7 @@ bool Parser::rOtherDeclaration( if(!rName(type_name)) return false; - + merge_types(cv_q, type_name); #ifdef DEBUG @@ -2008,7 +2008,7 @@ bool Parser::rOtherDeclaration( #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rOtherDeclaration 5\n"; #endif - + // it's a conversion operator typet type = type_name; type.get_sub().erase(type.get_sub().begin()); @@ -2048,7 +2048,7 @@ bool Parser::rOtherDeclaration( type_name=trailing_return_type; else type_name=typet(is_destructor?ID_destructor:ID_constructor); - + declaration.declarators().push_back(constructor_declarator); } else if(!member_spec.is_empty() && lex.LookAhead(0)==';') @@ -2620,7 +2620,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) case TOK_CPROVER_BOOL: type_id=ID_proper_bool; break; default: type_id=irep_idt(); } - + if(type_id!=irep_idt()) { cpp_tokent tk; @@ -2670,7 +2670,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) cpp_tokent tk; if(lex.get_token(tk)!='(') return false; - + // the argument can be a type or an expression { @@ -2718,7 +2718,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) cpp_tokent tk; if(lex.get_token(tk)!='(') return false; - + // the argument is always an expression exprt expr; @@ -2742,9 +2742,9 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) cpp_tokent tk; if(lex.get_token(tk)!='(') return false; - + // the argument is always a type - + typet tname; if(!rTypeName(tname)) @@ -2789,7 +2789,7 @@ bool Parser::rConstructorDecl( indenter _i; std::cout << std::string(__indent, ' ') << "Parser::rConstructorDecl 0\n"; #endif - + trailing_return_type.make_nil(); constructor=cpp_declaratort(typet(ID_function_type)); @@ -2832,7 +2832,7 @@ bool Parser::rConstructorDecl( // C++11 trailing return type cpp_tokent arrow; lex.get_token(arrow); - + if(!rTypeSpecifier(trailing_return_type, false)) return false; } @@ -2859,7 +2859,7 @@ bool Parser::rConstructorDecl( { cpp_tokent eq, value; lex.get_token(eq); - + switch(lex.get_token(value)) { case TOK_INTEGER: @@ -2868,21 +2868,21 @@ bool Parser::rConstructorDecl( set_location(constructor.value(), value); } break; - + case TOK_DEFAULT: // C++0x { constructor.value()=codet(ID_default); set_location(constructor.value(), value); } break; - + case TOK_DELETE: // C++0x { constructor.value()=codet(ID_cpp_delete); set_location(constructor.value(), value); } break; - + default: return false; } @@ -3028,8 +3028,8 @@ bool Parser::rDeclarators( /* declarator.with.init : ':' expression - | declarator - {'=' initialize.expr | + | declarator + {'=' initialize.expr | ':' expression} */ bool Parser::rDeclaratorWithInit( @@ -3051,7 +3051,7 @@ bool Parser::rDeclaratorWithInit( bit_field_type.set(ID_size, e); bit_field_type.subtype().make_nil(); set_location(bit_field_type, tk); - + //merge_types(bit_field_type, declarator.type()); return true; @@ -3063,7 +3063,7 @@ bool Parser::rDeclaratorWithInit( if(!rDeclarator(declarator, kDeclarator, false, should_be_declarator, is_statement)) return false; - + // asm post-declarator if(lex.LookAhead(0)==TOK_GCC_ASM) { @@ -3076,14 +3076,14 @@ bool Parser::rDeclaratorWithInit( if(!rString(tk)) return false; if(lex.get_token(tk)!=')') return false; } - + int t=lex.LookAhead(0); if(t=='=') { // initializer cpp_tokent tk; lex.get_token(tk); - + if(lex.LookAhead(0)==TOK_DEFAULT) // C++0x { lex.get_token(tk); @@ -3122,12 +3122,12 @@ bool Parser::rDeclaratorWithInit( exprt e; if(!rExpression(e, false)) return false; - + typet bit_field_type(ID_c_bit_field); bit_field_type.set(ID_size, e); bit_field_type.subtype().make_nil(); set_location(bit_field_type, tk); - + merge_types(bit_field_type, declarator.type()); } @@ -3148,10 +3148,10 @@ bool Parser::rDeclaratorWithInit( \*******************************************************************/ -/* __stdcall, __fastcall, __clrcall, __cdecl +/* __stdcall, __fastcall, __clrcall, __cdecl These are Visual-Studio specific. - + */ bool Parser::rDeclaratorQualifier() @@ -3212,7 +3212,7 @@ bool Parser::rDeclarator( indenter _i; std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 1\n"; #endif - + // we can have one or more declatator qualifiers if(!rDeclaratorQualifier()) return false; @@ -3223,7 +3223,7 @@ bool Parser::rDeclarator( name.make_nil(); d_outer.make_nil(); d_inner.make_nil(); - + if(!optPtrOperator(d_outer)) return false; @@ -3245,7 +3245,7 @@ bool Parser::rDeclarator( cpp_tokent op; lex.get_token(op); - + cpp_declaratort declarator2; if(!rDeclarator(declarator2, kind, true, true, false)) return false; @@ -3280,7 +3280,7 @@ bool Parser::rDeclarator( #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rDeclarator2 6\n"; #endif - + // if this is an argument declarator, "int (*)()" is valid. if(!rName(name)) return false; @@ -3341,7 +3341,7 @@ bool Parser::rDeclarator( irept throw_decl; optThrowDecl(throw_decl); // ignore in this version - + if(lex.LookAhead(0)==TOK_ARROW) { #ifdef DEBUG @@ -3352,7 +3352,7 @@ bool Parser::rDeclarator( // a return type. We should report this as an error. cpp_tokent arrow; lex.get_token(arrow); - + typet return_type; if(!rTypeSpecifier(return_type, false)) return false; @@ -3529,7 +3529,7 @@ bool Parser::optPtrOperator(typet &ptrs) { int t=lex.LookAhead(0); - + if(t=='&') { cpp_tokent tk; @@ -3651,7 +3651,7 @@ bool Parser::rMemberInit(exprt &init) init=codet(ID_member_initializer); init.add(ID_member).swap(name); - + cpp_tokent tk1, tk2; lex.get_token(tk1); set_location(init, tk1); @@ -3883,9 +3883,9 @@ bool Parser::rOperatorName(irept &name) cpp_tokent tk; int t=lex.LookAhead(0); - + irep_idt operator_id; - + switch(t) { case '+': @@ -3928,7 +3928,7 @@ bool Parser::rOperatorName(irept &name) case TOK_DOTPM: operator_id=".*"; break; case TOK_ARROWPM: operator_id="->*"; break; case TOK_ARROW: operator_id="->"; break; - + case TOK_NEW: case TOK_DELETE: { @@ -3949,7 +3949,7 @@ bool Parser::rOperatorName(irept &name) if(lex.get_token(tk)!=']') return false; } - + } return true; @@ -3968,12 +3968,12 @@ bool Parser::rOperatorName(irept &name) default: return rCastOperatorName(name); } - + assert(operator_id!=irep_idt()); lex.get_token(tk); name=irept(operator_id); set_location(name, tk); - + return true; } @@ -4023,7 +4023,7 @@ bool Parser::rCastOperatorName(irept &name) if(!optPtrOperator(ptr)) return false; - + make_subtype(type_name, ptr); merge_types(cv2, ptr); name = ptr; @@ -4485,7 +4485,7 @@ bool Parser::rArgDeclaration(cpp_declarationt &declaration) | '{' initialize.expr (',' initialize.expr)* {','} '}' */ bool Parser::rInitializeExpr(exprt &expr) -{ +{ if(lex.LookAhead(0)!='{') return rExpression(expr, false); @@ -4520,7 +4520,7 @@ bool Parser::rInitializeExpr(exprt &expr) if(lex.LookAhead(0)==',') lex.get_token(tk); if(lex.get_token(tk)!='}') return false; } - + if(!rInitializeExpr(tmp)) { if(!SyntaxError()) @@ -4648,7 +4648,7 @@ bool Parser::rEnumSpec(typet &spec) spec.subtype().make_nil(); - // C++11 enum classes + // C++11 enum classes if(lex.LookAhead(0)==TOK_CLASS) { lex.get_token(tk); @@ -4667,7 +4667,7 @@ bool Parser::rEnumSpec(typet &spec) spec.add(ID_tag).swap(name); } - + #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rEnumSpec 2\n"; #endif @@ -4803,7 +4803,7 @@ bool Parser::rClassSpec(typet &spec) #endif int t=lex.get_token(tk); - if(t!=TOK_CLASS && t!=TOK_STRUCT && + if(t!=TOK_CLASS && t!=TOK_STRUCT && t!=TOK_UNION && t!=TOK_INTERFACE) return false; @@ -5250,7 +5250,7 @@ bool Parser::rExpression(exprt &exp, bool template_args) int t=lex.LookAhead(0); - if(t=='=' || + if(t=='=' || t==TOK_MULTASSIGN || t==TOK_DIVASSIGN || t==TOK_MODASSIGN || t==TOK_PLUSASSIGN || t==TOK_MINUSASSIGN || t==TOK_SHLASSIGN || t==TOK_SHRASSIGN || t==TOK_ANDASSIGN || @@ -5721,7 +5721,7 @@ bool Parser::rRelationalExpr(exprt &exp, bool template_args) exprt left; left.swap(exp); - + irep_idt id; switch(t) @@ -5835,7 +5835,7 @@ bool Parser::rAdditiveExpr(exprt &exp) exprt left; left.swap(exp); - + irep_idt id; switch(t) { @@ -5894,7 +5894,7 @@ bool Parser::rMultiplyExpr(exprt &exp) exprt left; left.swap(exp); - + irep_idt id; switch(t) { @@ -5902,7 +5902,7 @@ bool Parser::rMultiplyExpr(exprt &exp) case '/': id=ID_div; break; case '%': id=ID_mod; break; } - + exp=exprt(id); exp.move_to_operands(left, right); set_location(exp, tk); @@ -6004,7 +6004,7 @@ bool Parser::rCastExpr(exprt &exp) // (TYPENAME) + expr (typecast of unary plus) vs. // (expr) + expr (sum of two expressions) // Same issue with the operators & and - and * - + cpp_tokent tk1, tk2; typet tname; @@ -6034,7 +6034,7 @@ bool Parser::rCastExpr(exprt &exp) exp.type().swap(tname); exp.move_to_operands(op); set_location(exp, tk1); - + return true; } } @@ -6069,7 +6069,7 @@ bool Parser::rTypeName(typet &tname) #endif typet type_name; - + if(!rTypeSpecifier(type_name, true)) return false; @@ -6202,7 +6202,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) for(;;) { // function type parameters - + #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rTypeNameOrFunctionType 5\n"; #endif @@ -6217,7 +6217,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) type.make_ellipsis(); } else - { + { cpp_declarationt parameter_declaration; if(!rArgDeclaration(parameter_declaration)) return false; @@ -6225,7 +6225,7 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) code_typet::parametert parameter; parameter.swap(parameter_declaration); type.parameters().push_back(parameter); - + t=lex.LookAhead(0); if(t==',') { @@ -6263,13 +6263,13 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) // not sure where this one belongs if(!optPtrOperator(type)) return false; - + tname.swap(type); #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rTypeNameOrFunctionType 8\n"; #endif - + return true; } @@ -6438,7 +6438,7 @@ bool Parser::rThrowExpr(exprt &exp) else { exprt e; - + if(!rExpression(e, false)) return false; @@ -6632,7 +6632,7 @@ bool Parser::rAlignofExpr(exprt &exp) if(!rTypeName(tname)) return false; - + if(lex.get_token(cp)!=')') return false; @@ -6792,7 +6792,7 @@ bool Parser::rAllocateExpr(exprt &exp) #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rAllocateExpr 4\n"; #endif - + exp.add(ID_initializer).swap(initializer); exp.operands().swap(arguments.operands()); return true; @@ -6842,7 +6842,7 @@ bool Parser::rAllocateType( if(lex.get_token()==')') { // we have "( type.name )" - + if(lex.LookAhead(0)!='(') { if(!isTypeSpecifier()) @@ -7193,7 +7193,7 @@ bool Parser::rPostfixExpr(exprt &exp) __uuidof( expression ) __uuidof( type ) This is a Visual Studio Extension. -*/ +*/ bool Parser::rMSCuuidof(exprt &expr) { @@ -7254,18 +7254,18 @@ bool Parser::rMSCuuidof(exprt &expr) /* __if_exists ( identifier ) { token stream } __if_not_exists ( identifier ) { token stream } -*/ +*/ bool Parser::rMSC_if_existsExpr(exprt &expr) { cpp_tokent tk1; lex.get_token(tk1); - + if(tk1.kind!=TOK_MSC_IF_EXISTS && tk1.kind!=TOK_MSC_IF_NOT_EXISTS) return false; - + cpp_tokent tk2; if(lex.get_token(tk2)!='(') @@ -7295,7 +7295,7 @@ bool Parser::rMSC_if_existsExpr(exprt &expr) ID_msc_if_not_exists); expr.move_to_operands(name, op); - + set_location(expr, tk1); return true; @@ -7318,11 +7318,11 @@ bool Parser::rMSC_if_existsStatement(codet &code) cpp_tokent tk1; lex.get_token(tk1); - + if(tk1.kind!=TOK_MSC_IF_EXISTS && tk1.kind!=TOK_MSC_IF_NOT_EXISTS) return false; - + cpp_tokent tk2; if(lex.get_token(tk2)!='(') @@ -7359,7 +7359,7 @@ bool Parser::rMSC_if_existsStatement(codet &code) ID_msc_if_not_exists); code.move_to_operands(name, block); - + set_location(code, tk1); return true; @@ -7391,10 +7391,10 @@ bool Parser::rTypePredicate(exprt &expr) lex.get_token(tk); expr.id(irep_idt(tk.text)); - set_location(expr, tk); + set_location(expr, tk); typet tname1, tname2; - + switch(tk.kind) { case TOK_UNARY_TYPE_PREDICATE: @@ -7403,7 +7403,7 @@ bool Parser::rTypePredicate(exprt &expr) if(lex.get_token(tk)!=')') return false; expr.add(ID_type_arg).swap(tname1); break; - + case TOK_BINARY_TYPE_PREDICATE: if(lex.get_token(tk)!='(') return false; if(!rTypeName(tname1)) return false; @@ -7413,7 +7413,7 @@ bool Parser::rTypePredicate(exprt &expr) expr.add("type_arg1").swap(tname1); expr.add("type_arg2").swap(tname2); break; - + default: assert(false); } @@ -7568,7 +7568,7 @@ bool Parser::rPrimaryExpr(exprt &exp) case TOK_TYPEID: return rTypeidExpr(exp); - + case TOK_UNARY_TYPE_PREDICATE: case TOK_BINARY_TYPE_PREDICATE: #ifdef DEBUG @@ -7620,7 +7620,7 @@ bool Parser::rPrimaryExpr(exprt &exp) if(lex.LookAhead(0)=='{') { lex.LookAhead(0, tk); - + exprt exp2; if(!rInitializeExpr(exp2)) return false; @@ -7766,7 +7766,7 @@ bool Parser::rVarNameCore(exprt &name) // Skip template token, next will be identifier if(lex.LookAhead(0)!=TOK_IDENTIFIER) return false; break; - + case TOK_IDENTIFIER: #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rVarNameCore 3\n"; @@ -8003,13 +8003,13 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) { // The following is an extension in GCC, // ARMCC, CodeWarrior... - + if(lex.LookAhead(0)=='{' && lex.LookAhead(1)==TOK_ASM_STRING) { cpp_tokent ob, tk, cb; lex.get_token(ob); - + codet body=code_blockt(); set_location(body, ob); @@ -8018,7 +8018,7 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) if(lex.get_token(cb)!='}') return false; - declarator.value()=body; + declarator.value()=body; return true; } else @@ -8026,7 +8026,7 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) // this is for the benefit of set_location const cpp_namet &cpp_name=declarator.name(); current_function=cpp_name.get_base_name(); - + codet body; if(!rCompoundStatement(body)) { @@ -8035,9 +8035,9 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) } declarator.value()=body; - + current_function.clear(); - + return true; } } @@ -8174,7 +8174,7 @@ bool Parser::rStatement(codet &statement) case TOK_MSC_LEAVE: return rMSC_leaveStatement(statement); - + case TOK_BREAK: case TOK_CONTINUE: lex.get_token(tk1); @@ -8254,13 +8254,13 @@ bool Parser::rStatement(codet &statement) exprt case_expr; if(!rExpression(case_expr, false)) return false; - + if(lex.LookAhead(0)==TOK_ELLIPSIS) { // This is a gcc extension for case ranges. // Should really refuse in non-GCC modes. lex.get_token(tk2); - + exprt range_end; if(!rExpression(range_end, false)) return false; @@ -8285,7 +8285,7 @@ bool Parser::rStatement(codet &statement) statement=code_switch_caset(); set_location(statement, tk1); statement.op0()=case_expr; - + if(lex.get_token(tk2)!=':') return false; @@ -8347,7 +8347,7 @@ bool Parser::rStatement(codet &statement) } return rExprStatement(statement); - + case TOK_USING: { if(lex.LookAhead(1)==TOK_IDENTIFIER && @@ -8362,23 +8362,23 @@ bool Parser::rStatement(codet &statement) if(!rUsing(cpp_using)) return false; - + // TODO - - return true; + + return true; } - + case TOK_STATIC_ASSERT: { cpp_static_assertt cpp_static_assert; - + if(!rStaticAssert(cpp_static_assert)) return false; - + statement.set_statement(ID_static_assert); statement.add_source_location()=cpp_static_assert.source_location(); statement.operands().swap(cpp_static_assert.operands()); - + return true; } @@ -8705,7 +8705,7 @@ bool Parser::rTryStatement(codet &statement) do { cpp_tokent catch_token, op_token, cp_token; - + if(lex.get_token(catch_token)!=TOK_CATCH) return false; @@ -8728,10 +8728,10 @@ bool Parser::rTryStatement(codet &statement) if(!rArgDeclaration(declaration)) return false; - + // No name in the declarator? Make one. assert(declaration.declarators().size()==1); - + if(declaration.declarators().front().name().is_nil()) { irept name(ID_name); @@ -8739,25 +8739,25 @@ bool Parser::rTryStatement(codet &statement) declaration.declarators().front().name()=cpp_namet(); declaration.declarators().front().name().get_sub().push_back(name); } - + codet code_decl; code_decl.set_statement(ID_decl); code_decl.move_to_operands(declaration); set_location(code_decl, catch_token); - + catch_op=code_decl; } if(lex.get_token(cp_token)!=')') return false; - + codet body; - + if(!rCompoundStatement(body)) return false; - + assert(body.get_statement()==ID_block); - + body.operands().insert(body.operands().begin(), catch_op); statement.move_to_operands(body); @@ -8783,26 +8783,26 @@ bool Parser::rMSC_tryStatement(codet &statement) { // These are for 'structured exception handling', // and are a relic from Visual C. - + cpp_tokent tk, tk2, tk3; if(lex.get_token(tk)!=TOK_MSC_TRY) return false; set_location(statement, tk); - + codet body1, body2; if(!rCompoundStatement(body1)) return false; - + if(lex.LookAhead(0)==TOK_MSC_EXCEPT) { lex.get_token(tk); statement.set_statement(ID_msc_try_except); - + // get '(' comma.expression ')' - + if(lex.get_token(tk2)!='(') return false; @@ -8812,10 +8812,10 @@ bool Parser::rMSC_tryStatement(codet &statement) if(lex.get_token(tk3)!=')') return false; - + if(!rCompoundStatement(body2)) return false; - + statement.move_to_operands(body1, exp, body2); } else if(lex.LookAhead(0)==TOK_MSC_FINALLY) @@ -8850,7 +8850,7 @@ bool Parser::rMSC_leaveStatement(codet &statement) { // These are for 'structured exception handling', // and are a relic from Visual C. - + cpp_tokent tk; if(lex.get_token(tk)!=TOK_MSC_LEAVE) @@ -9000,14 +9000,14 @@ bool Parser::rMSCAsmStatement(codet &statement) if(lex.LookAhead(0)=='{') { lex.get_token(tk); // eat the '{' - + #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rMSCAsmStatement 3\n"; #endif // DEBUG - + if(lex.LookAhead(0)!=TOK_ASM_STRING) return true; - + lex.get_token(tk); statement.move_to_operands(tk.data); @@ -9025,7 +9025,7 @@ bool Parser::rMSCAsmStatement(codet &statement) if(lex.LookAhead(0)!=TOK_ASM_STRING) return true; - + lex.get_token(tk); statement.move_to_operands(tk.data); @@ -9033,7 +9033,7 @@ bool Parser::rMSCAsmStatement(codet &statement) std::cout << std::string(__indent, ' ') << "Parser::rMSCAsmStatement 6\n"; #endif // DEBUG } - + #ifdef DEBUG std::cout << std::string(__indent, ' ') << "Parser::rMSCAsmStatement 7\n"; #endif // DEBUG @@ -9147,7 +9147,7 @@ bool Parser::rExprStatement(codet &statement) bool Parser::rCondition(exprt &statement) { cpp_token_buffert::post pos=lex.Save(); - + // C++ conditions can be a declaration! cpp_declarationt declaration; @@ -9449,7 +9449,7 @@ bool Parser::operator()() parser.parse_tree.items.push_back(item); item.clear(); } - + #if 0 root_scope.print(std::cout); #endif diff --git a/src/cpp/recursion_counter.h b/src/cpp/recursion_counter.h index 9113fd2712d..1359da73849 100644 --- a/src/cpp/recursion_counter.h +++ b/src/cpp/recursion_counter.h @@ -13,7 +13,7 @@ class recursion_countert { cnt++; } - + ~recursion_countert() { cnt--; diff --git a/src/cpp/template_map.cpp b/src/cpp/template_map.cpp index d29ba3d1b2f..62d5b026207 100644 --- a/src/cpp/template_map.cpp +++ b/src/cpp/template_map.cpp @@ -293,13 +293,13 @@ void template_mapt::set( else { // must be non-type - + if(value.id()==ID_type) assert(false); // typechecked before! irep_idt identifier=parameter.get(ID_identifier); expr_map[identifier]=value; - } + } } /*******************************************************************\ @@ -326,7 +326,7 @@ void template_mapt::build_unassigned( t_it++) { const template_parametert &t=*t_it; - + if(t.id()==ID_type) { typet tmp(ID_unassigned); @@ -340,7 +340,7 @@ void template_mapt::build_unassigned( tmp.set(ID_identifier, t.get(ID_identifier)); tmp.add_source_location()=t.source_location(); expr_map[t.get(ID_identifier)]=tmp; - } + } } } @@ -364,11 +364,11 @@ cpp_template_args_tct template_mapt::build_template_args( cpp_template_args_tct template_args; template_args.arguments().resize(template_parameters.size()); - + for(std::size_t i=0; i10) v=10; } - + ui_message_handler.set_verbosity(v); } @@ -239,7 +239,7 @@ int goto_analyzer_parse_optionst::doit() std::cout << CBMC_VERSION << std::endl; return 0; } - + // // command line options // @@ -257,12 +257,12 @@ int goto_analyzer_parse_optionst::doit() << config.this_operating_system() << eom; register_languages(); - + goto_model.set_message_handler(get_message_handler()); if(goto_model(cmdline.args)) return 6; - + if(process_goto_program(options)) return 6; @@ -311,7 +311,7 @@ int goto_analyzer_parse_optionst::doit() if(cmdline.isset("show-local-may-alias")) { namespacet ns(goto_model.symbol_table); - + forall_goto_functions(it, goto_model.goto_functions) { std::cout << ">>>>\n"; @@ -335,7 +335,7 @@ int goto_analyzer_parse_optionst::doit() if(set_properties()) return 7; - + if(cmdline.isset("show-intervals")) { show_intervals(goto_model, std::cout); @@ -389,12 +389,12 @@ bool goto_analyzer_parse_optionst::set_properties() error() << e << eom; return true; } - + catch(int) { return true; } - + return false; } @@ -409,7 +409,7 @@ Function: goto_analyzer_parse_optionst::process_goto_program Purpose: \*******************************************************************/ - + bool goto_analyzer_parse_optionst::process_goto_program( const optionst &options) { @@ -421,7 +421,7 @@ bool goto_analyzer_parse_optionst::process_goto_program( remove_asm(goto_model); // add the library - status() << "Adding CPROVER library (" + status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom; link_to_library(goto_model, ui_message_handler); #endif @@ -434,7 +434,7 @@ bool goto_analyzer_parse_optionst::process_goto_program( // do partial inlining status() << "Partial Inlining" << eom; goto_partial_inline(goto_model, ui_message_handler); - + // remove returns, gcc vectors, complex remove_returns(goto_model); remove_vector(goto_model); @@ -445,13 +445,13 @@ bool goto_analyzer_parse_optionst::process_goto_program( status() << "Generic Property Instrumentation" << eom; goto_check(options, goto_model); #endif - + // recalculate numbers, etc. goto_model.goto_functions.update(); // add loop ids goto_model.goto_functions.compute_loop_numbers(); - + // show it? if(cmdline.isset("show-goto-functions")) { @@ -480,18 +480,18 @@ bool goto_analyzer_parse_optionst::process_goto_program( error() << e << eom; return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; } @@ -512,11 +512,11 @@ void goto_analyzer_parse_optionst::help() std::cout << "\n" "* * GOTO-ANALYSER " CBMC_VERSION " - Copyright (C) 2016 "; - + std::cout << "(" << (sizeof(void *)*8) << "-bit version)"; - + std::cout << " * *\n"; - + std::cout << "* * Daniel Kroening, DiffBlue * *\n" "* * kroening@kroening.com * *\n" diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 7eba4c7b247..eecf0930c76 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -58,9 +58,9 @@ class goto_analyzer_parse_optionst: virtual bool process_goto_program(const optionst &options); bool set_properties(); - + void eval_verbosity(); - + bool has_entry_point; }; diff --git a/src/goto-analyzer/static_analyzer.cpp b/src/goto-analyzer/static_analyzer.cpp index 89e511288af..f4f6c5cff33 100644 --- a/src/goto-analyzer/static_analyzer.cpp +++ b/src/goto-analyzer/static_analyzer.cpp @@ -29,7 +29,7 @@ class static_analyzert:public messaget options(_options) { } - + bool operator()(); protected: @@ -41,9 +41,9 @@ class static_analyzert:public messaget ait interval_analysis; void plain_text_report(); - void json_report(const std::string &); - void xml_report(const std::string &); - + void json_report(const std::string &); + void xml_report(const std::string &); + tvt eval(goto_programt::const_targett); }; @@ -55,7 +55,7 @@ Function: static_analyzert::operator() Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -73,7 +73,7 @@ bool static_analyzert::operator()() return false; } - + /*******************************************************************\ Function: static_analyzert::eval @@ -82,7 +82,7 @@ Function: static_analyzert::eval Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -92,7 +92,7 @@ tvt static_analyzert::eval(goto_programt::const_targett t) interval_domaint d=interval_analysis[t]; d.assume(not_exprt(guard), ns); if(d.is_bottom()) return tvt(true); - return tvt::unknown(); + return tvt::unknown(); } /*******************************************************************\ @@ -103,18 +103,18 @@ Function: static_analyzert::plain_text_report Outputs: - Purpose: + Purpose: \*******************************************************************/ void static_analyzert::plain_text_report() { unsigned pass=0, fail=0, unknown=0; - + forall_goto_functions(f_it, goto_functions) { if(!f_it->second.body.has_assertion()) continue; - + if(f_it->first=="__actual_thread_spawn") continue; @@ -123,9 +123,9 @@ void static_analyzert::plain_text_report() forall_goto_program_instructions(i_it, f_it->second.body) { if(!i_it->is_assert()) continue; - + tvt r=eval(i_it); - + result() << '[' << i_it->source_location.get_property_id() << ']' << ' '; @@ -151,7 +151,7 @@ void static_analyzert::plain_text_report() status() << '\n'; } - + status() << "SUMMARY: " << pass << " pass, " << fail << " fail, " << unknown << " unknown\n"; } @@ -164,25 +164,25 @@ Function: static_analyzert::json_report Outputs: - Purpose: + Purpose: \*******************************************************************/ void static_analyzert::json_report(const std::string &file_name) { json_arrayt json_result; - + forall_goto_functions(f_it, goto_functions) { if(!f_it->second.body.has_assertion()) continue; - + if(f_it->first=="__actual_thread_spawn") continue; forall_goto_program_instructions(i_it, f_it->second.body) { if(!i_it->is_assert()) continue; - + tvt r=eval(i_it); json_objectt &j=json_result.push_back().make_object(); @@ -191,11 +191,11 @@ void static_analyzert::json_report(const std::string &file_name) j["status"]=json_stringt("SUCCESS"); else if(r.is_false()) j["status"]=json_stringt("FAILURE"); - else + else j["status"]=json_stringt("UNKNOWN"); j["file"]=json_stringt(id2string(i_it->source_location.get_file())); - j["line"]=json_numbert(id2string(i_it->source_location.get_line())); + j["line"]=json_numbert(id2string(i_it->source_location.get_line())); j["description"]=json_stringt(id2string( i_it->source_location.get_comment())); } @@ -208,7 +208,7 @@ void static_analyzert::json_report(const std::string &file_name) << file_name << "'" << eom; return; } - + status() << "Writing report to `" << file_name << "'" << eom; out << json_result; } @@ -221,25 +221,25 @@ Function: static_analyzert::xml_report Outputs: - Purpose: + Purpose: \*******************************************************************/ void static_analyzert::xml_report(const std::string &file_name) { xmlt xml_result; - + forall_goto_functions(f_it, goto_functions) { if(!f_it->second.body.has_assertion()) continue; - + if(f_it->first=="__actual_thread_spawn") continue; forall_goto_program_instructions(i_it, f_it->second.body) { if(!i_it->is_assert()) continue; - + tvt r=eval(i_it); xmlt &x=xml_result.new_element("result"); @@ -248,11 +248,11 @@ void static_analyzert::xml_report(const std::string &file_name) x.set_attribute("status", "SUCCESS"); else if(r.is_false()) x.set_attribute("status", "FAILURE"); - else + else x.set_attribute("status", "UNKNOWN"); x.set_attribute("file", id2string(i_it->source_location.get_file())); - x.set_attribute("line", id2string(i_it->source_location.get_line())); + x.set_attribute("line", id2string(i_it->source_location.get_line())); x.set_attribute("description", id2string(i_it->source_location.get_comment())); } } @@ -264,7 +264,7 @@ void static_analyzert::xml_report(const std::string &file_name) << file_name << "'" << eom; return; } - + status() << "Writing report to `" << file_name << "'" << eom; out << xml_result; } @@ -277,7 +277,7 @@ Function: static_analyzer Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -298,7 +298,7 @@ Function: show_intervals Outputs: - Purpose: + Purpose: \*******************************************************************/ diff --git a/src/goto-analyzer/static_analyzer.h b/src/goto-analyzer/static_analyzer.h index 02fa064ab11..eab55a9a9fa 100644 --- a/src/goto-analyzer/static_analyzer.h +++ b/src/goto-analyzer/static_analyzer.h @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: +Module: Author: Daniel Kroening, kroening@kroening.com diff --git a/src/goto-analyzer/taint_analysis.cpp b/src/goto-analyzer/taint_analysis.cpp index 26b9bee1826..a6413bbdfb3 100644 --- a/src/goto-analyzer/taint_analysis.cpp +++ b/src/goto-analyzer/taint_analysis.cpp @@ -47,7 +47,7 @@ class taint_analysist:public messaget protected: taint_parse_treet taint; class_hierarchyt class_hierarchy; - + void instrument(const namespacet &, goto_functionst &); void instrument(const namespacet &, goto_functionst::goto_functiont &); }; @@ -94,9 +94,9 @@ void taint_analysist::instrument( it++) { const goto_programt::instructiont &instruction=*it; - + goto_programt tmp; - + switch(instruction.type) { case FUNCTION_CALL: @@ -104,32 +104,32 @@ void taint_analysist::instrument( const code_function_callt &function_call= to_code_function_call(instruction.code); const exprt &function=function_call.function(); - + if(function.id()==ID_symbol) { const irep_idt &identifier= to_symbol_expr(function).get_identifier(); - + std::set identifiers; - + identifiers.insert(identifier); irep_idt class_id=function.get(ID_C_class); if(class_id.empty()) { - + } else { std::string suffix= std::string(id2string(identifier), class_id.size(), std::string::npos); - + class_hierarchyt::idst parents= class_hierarchy.get_parents_trans(class_id); for(const auto & p : parents) identifiers.insert(id2string(p)+suffix); } - + for(const auto & rule : taint.rules) { bool match=false; @@ -140,19 +140,19 @@ void taint_analysist::instrument( match=true; break; } - + if(match) { debug() << "MATCH " << rule.id << " on " << identifier << eom; - + exprt where=nil_exprt(); - + const code_typet &code_type=to_code_type(function.type()); - + bool have_this= !code_type.parameters().empty() && code_type.parameters().front().get_bool(ID_C_this); - + switch(rule.where) { case taint_parse_treet::rulet::RETURN_VALUE: @@ -179,7 +179,7 @@ void taint_analysist::instrument( } break; } - + switch(rule.kind) { case taint_parse_treet::rulet::SOURCE: @@ -193,7 +193,7 @@ void taint_analysist::instrument( t->source_location=instruction.source_location; } break; - + case taint_parse_treet::rulet::SINK: { goto_programt::targett t=tmp.add_instruction(); @@ -206,7 +206,7 @@ void taint_analysist::instrument( t->source_location.set_comment(rule.message); } break; - + case taint_parse_treet::rulet::SANITIZER: { codet code_clear_may("clear_may"); @@ -219,16 +219,16 @@ void taint_analysist::instrument( } break; } - + } } } } break; - + default:; } - + if(!tmp.empty()) { goto_programt::targett next=it; @@ -261,7 +261,7 @@ bool taint_analysist::operator()( { json_arrayt json_result; bool use_json=!json_file_name.empty(); - + status() << "Reading taint file `" << taint_file_name << "'" << eom; @@ -284,7 +284,7 @@ bool taint_analysist::operator()( const namespacet ns(symbol_table); instrument(ns, goto_functions); goto_functions.update(); - + bool have_entry_point= goto_functions.function_map.find(goto_functionst::entry_point())!= goto_functions.function_map.end(); @@ -300,7 +300,7 @@ bool taint_analysist::operator()( "we will consider the heads of all functions as reachable" << eom; goto_programt end, gotos, calls; - + end.add_instruction(END_FUNCTION); forall_goto_functions(f_it, goto_functions) @@ -315,7 +315,7 @@ bool taint_analysist::operator()( goto_programt::targett g=gotos.add_instruction(); g->make_goto(t, side_effect_expr_nondett(bool_typet())); } - + goto_functionst::goto_functiont &entry= goto_functions.function_map[goto_functionst::entry_point()]; @@ -324,7 +324,7 @@ bool taint_analysist::operator()( body.destructive_append(gotos); body.destructive_append(calls); body.destructive_append(end); - + goto_functions.update(); } @@ -332,24 +332,24 @@ bool taint_analysist::operator()( custom_bitvector_analysist custom_bitvector_analysis; custom_bitvector_analysis(goto_functions, ns); - + if(show_full) { custom_bitvector_analysis.output(ns, goto_functions, std::cout); return false; } - + forall_goto_functions(f_it, goto_functions) { if(!f_it->second.body.has_assertion()) continue; - + const symbolt &symbol=ns.lookup(f_it->first); if(f_it->first=="__actual_thread_spawn") continue; - + bool first=true; - + forall_goto_program_instructions(i_it, f_it->second.body) { if(!i_it->is_assert()) continue; @@ -384,7 +384,7 @@ bool taint_analysist::operator()( std::cout << i_it->source_location; if(!i_it->source_location.get_comment().empty()) std::cout << ": " << i_it->source_location.get_comment(); - + if(!i_it->source_location.get_property_class().empty()) std::cout << " (" << i_it->source_location.get_property_class() << ")"; @@ -392,7 +392,7 @@ bool taint_analysist::operator()( } } } - + if(use_json) { std::ofstream json_out(json_file_name); @@ -403,13 +403,13 @@ bool taint_analysist::operator()( << json_file_name << "'" << eom; return true; } - + status() << "Analysis result is written to `" << json_file_name << "'" << eom; - + json_out << json_result << '\n'; } - + return false; } catch(const char *error_msg) @@ -452,4 +452,3 @@ bool taint_analysis( return taint_analysis( taint_file_name, goto_model.symbol_table, goto_model.goto_functions, show_full, json_file_name); } - diff --git a/src/goto-analyzer/taint_parser.cpp b/src/goto-analyzer/taint_parser.cpp index 563ac02f64e..3e2e10de6f8 100644 --- a/src/goto-analyzer/taint_parser.cpp +++ b/src/goto-analyzer/taint_parser.cpp @@ -48,7 +48,7 @@ bool taint_parser( << json << messaget::eom; return true; } - + for(jsont::arrayt::const_iterator it=json.array.begin(); it!=json.array.end(); @@ -61,16 +61,16 @@ bool taint_parser( << *it << messaget::eom; return true; } - + taint_parse_treet::rulet rule; - + const std::string kind=(*it)["kind"].value; const std::string function=(*it)["function"].value; const std::string where=(*it)["where"].value; const std::string taint=(*it)["taint"].value; const std::string message=(*it)["message"].value; const std::string id=(*it)["id"].value; - + if(kind=="source") rule.kind=taint_parse_treet::rulet::SOURCE; else if(kind=="sink") @@ -85,7 +85,7 @@ bool taint_parser( << messaget::eom; return true; } - + if(function.empty()) { messaget message(message_handler); @@ -118,14 +118,14 @@ bool taint_parser( << messaget::eom; return true; } - + rule.taint=taint; rule.message=message; rule.id=id; - + dest.rules.push_back(rule); } - + return false; } @@ -151,16 +151,16 @@ void taint_parse_treet::rulet::output(std::ostream &out) const case SINK: out << "SINK "; break; case SANITIZER: out << "SANITIZER "; break; } - + out << taint << " on "; - + switch(where) { case THIS: out << "this in " << function_identifier; break; case PARAMETER: out << "parameter " << parameter_number << " of " << function_identifier; break; case RETURN_VALUE: out << "return value of " << function_identifier; break; } - + out << '\n'; } @@ -181,4 +181,3 @@ void taint_parse_treet::output(std::ostream &out) const for(const auto & rule : rules) rule.output(out); } - diff --git a/src/goto-analyzer/taint_parser.h b/src/goto-analyzer/taint_parser.h index dbf4a9df0ee..8ebcf55eabe 100644 --- a/src/goto-analyzer/taint_parser.h +++ b/src/goto-analyzer/taint_parser.h @@ -24,7 +24,7 @@ class taint_parse_treet public: enum { SOURCE, SINK, SANITIZER } kind; enum { THIS, PARAMETER, RETURN_VALUE } where; - + inline bool is_source() const { return kind==SOURCE; @@ -45,9 +45,9 @@ class taint_parse_treet irep_idt taint; unsigned parameter_number; // the frist one is '1' std::string message; - + void output(std::ostream &) const; - + inline rulet():parameter_number(0) { } @@ -55,7 +55,7 @@ class taint_parse_treet typedef std::list rulest; rulest rules; - + void output(std::ostream &) const; }; diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index b63e5eb0081..9af2aec210c 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -186,7 +186,7 @@ void unreachable_instructions( std::set called; compute_called_functions(goto_model, called); - + const namespacet ns(goto_model.symbol_table); forall_goto_functions(f_it, goto_model.goto_functions) @@ -213,4 +213,3 @@ void unreachable_instructions( if(json && !json_result.array.empty()) os << json_result << std::endl; } - diff --git a/src/goto-cc/Makefile b/src/goto-cc/Makefile index ac8e908a7d5..c7bf41ad9b6 100644 --- a/src/goto-cc/Makefile +++ b/src/goto-cc/Makefile @@ -52,4 +52,3 @@ goto-cl$(EXEEXT): $(OBJ) goto-cc-mac-signed: goto-cc$(EXEEXT) codesign -v -s $(OSX_IDENTITY) goto-cc$(EXEEXT) - diff --git a/src/goto-cc/armcc_cmdline.cpp b/src/goto-cc/armcc_cmdline.cpp index 3093ab9acf2..4b58f765f17 100644 --- a/src/goto-cc/armcc_cmdline.cpp +++ b/src/goto-cc/armcc_cmdline.cpp @@ -12,15 +12,15 @@ Author: Daniel Kroening #include "armcc_cmdline.h" /*******************************************************************\ - + Function: armcc_cmdlinet::parse - + Inputs: argument count, argument strings - + Outputs: none - + Purpose: parses the commandline options into a cmdlinet - + \*******************************************************************/ // see @@ -44,7 +44,7 @@ static const char *options_no_arg[]= "--no-arch", "--no-library", "--string-abstraction", - + // armcc "--help", "--show_cmdline", @@ -280,8 +280,8 @@ bool armcc_cmdlinet::parse(int argc, const char **argv) { args.push_back(argv[i]); continue; - } - + } + // it starts with - and it isn't "-" std::string prefix; @@ -307,7 +307,7 @@ bool armcc_cmdlinet::parse(int argc, const char **argv) else set(prefix, ""); } - } + } else if(prefix_in_list(argv[i], options_with_prefix, prefix)) { // options that have a concatenated argument @@ -315,7 +315,7 @@ bool armcc_cmdlinet::parse(int argc, const char **argv) } else { // unrecognized option - std::cout << "Warning: uninterpreted armcc option '" + std::cout << "Warning: uninterpreted armcc option '" << argv[i] << "'" << std::endl; } } diff --git a/src/goto-cc/armcc_cmdline.h b/src/goto-cc/armcc_cmdline.h index 0a2f1ade6e5..b9e1cdd4758 100644 --- a/src/goto-cc/armcc_cmdline.h +++ b/src/goto-cc/armcc_cmdline.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: A special command line object to mimick ARM's armcc - + Author: Daniel Kroening - + Date: June 2006 - + \*******************************************************************/ #ifndef GOTO_CC_ARMCC_CMDLINE_H diff --git a/src/goto-cc/armcc_mode.cpp b/src/goto-cc/armcc_mode.cpp index 13c1be3e20d..fbe8db16d94 100644 --- a/src/goto-cc/armcc_mode.cpp +++ b/src/goto-cc/armcc_mode.cpp @@ -63,15 +63,15 @@ int armcc_modet::doit() ui_message_handler.set_verbosity(verbosity); debug() << "ARM mode" << eom; - + // get configuration config.set(cmdline); config.ansi_c.mode=configt::ansi_ct::flavourt::ARM; config.ansi_c.arch="arm"; - + // determine actions to be taken - + if(cmdline.isset('E')) compiler.mode=compilet::PREPROCESS_ONLY; else if(cmdline.isset('c') || cmdline.isset('S')) @@ -111,13 +111,13 @@ int armcc_modet::doit() config.ansi_c.preprocessor_options.push_back("--preinclude="+*it); } - // armcc's default is .o + // armcc's default is .o if(cmdline.isset("default_extension=")) compiler.object_file_extension= cmdline.get_value("default_extension="); else compiler.object_file_extension="o"; - + // note that ARM's default is "unsigned_chars", // in contrast to gcc's default! if(cmdline.isset("signed_chars")) @@ -211,5 +211,3 @@ void armcc_modet::help_mode() { std::cout << "goto-armcc understands the options of armcc plus the following.\n\n"; } - - diff --git a/src/goto-cc/armcc_mode.h b/src/goto-cc/armcc_mode.h index ff63026d15f..fe0e7e2edc7 100644 --- a/src/goto-cc/armcc_mode.h +++ b/src/goto-cc/armcc_mode.h @@ -25,7 +25,7 @@ class armcc_modet:public goto_cc_modet cmdline(_armcc_cmdline) { } - + protected: armcc_cmdlinet &cmdline; }; diff --git a/src/goto-cc/compile.cpp b/src/goto-cc/compile.cpp index 4d06f05c90a..a2999ec20ce 100644 --- a/src/goto-cc/compile.cpp +++ b/src/goto-cc/compile.cpp @@ -130,7 +130,7 @@ bool compilet::doit() { if(link()) return true; } - + return false; } @@ -168,7 +168,7 @@ bool compilet::add_input_file(const std::string &file_name) << "' has no extension, not considered" << eom; return false; } - + std::string ext = file_name.substr(r+1, file_name.length()); if(ext=="c" || @@ -212,15 +212,15 @@ bool compilet::add_input_file(const std::string &file_name) // unpack now cmd << "ar x " << concat_dir_file(working_directory, file_name); - + FILE *stream; stream=popen(cmd.str().c_str(), "r"); pclose(stream); - + cmd.clear(); cmd.str(""); - + // add the files from "ar t" #ifdef _WIN32 if(file_name[0]!='/' && file_name[1]!=':') @@ -331,7 +331,7 @@ bool compilet::find_library(const std::string &name) } } } - + return false; } @@ -396,7 +396,7 @@ bool compilet::link() } // produce entry point? - + if(mode==COMPILE_LINK_EXECUTABLE) { // new symbols may have been added to a previously linked file @@ -439,7 +439,7 @@ bool compilet::compile() { std::string file_name=source_files.front(); source_files.pop_front(); - + // Visual Studio always prints the name of the file it's doing if(echo_file_name) status() << file_name << eom; @@ -456,7 +456,7 @@ bool compilet::compile() convert_symbols(compiled_functions); std::string cfn; - + if(output_file_object=="") cfn=get_base_name(file_name, true)+"."+object_file_extension; else @@ -469,7 +469,7 @@ bool compilet::compile() compiled_functions.clear(); } } - + return false; } @@ -502,10 +502,10 @@ bool compilet::parse(const std::string &file_name) } languaget *languagep; - + // Using '-x', the type of a file can be overridden; // otherwise, it's guessed from the extension. - + if(override_language!="") { if(override_language=="c++" || override_language=="c++-header") @@ -524,7 +524,7 @@ bool compilet::parse(const std::string &file_name) languaget &language=*languagep; language.set_message_handler(get_message_handler()); - + language_filet language_file; std::pair @@ -549,7 +549,7 @@ bool compilet::parse(const std::string &file_name) if(!ofs.is_open()) { - error() << "failed to open output file `" + error() << "failed to open output file `" << cmdline.get_value('o') << "'" << eom; return true; } @@ -588,7 +588,7 @@ Function: compilet::parse_stdin bool compilet::parse_stdin() { ansi_c_languaget language; - + language.set_message_handler(get_message_handler()); print(8, "Parsing: (stdin)"); @@ -665,7 +665,7 @@ bool compilet::write_bin_object_file( const symbol_tablet &lsymbol_table, goto_functionst &functions) { - statistics() << "Writing binary format object `" + statistics() << "Writing binary format object `" << file_name << "'" << eom; // symbols @@ -709,10 +709,10 @@ bool compilet::parse_source(const std::string &file_name) { if(parse(file_name)) return true; - + if(typecheck()) // we just want to typecheck this one file here return true; - + if((has_suffix(file_name, ".class") || has_suffix(file_name, ".jar")) && final()) @@ -830,14 +830,14 @@ void compilet::convert_symbols(goto_functionst &dest) // the compilation may add symbols! symbol_tablet::symbolst::size_type before=0; - + while(before!=symbol_table.symbols.size()) { before=symbol_table.symbols.size(); typedef std::set symbols_sett; symbols_sett symbols; - + Forall_symbols(it, symbol_table.symbols) symbols.insert(it->first); diff --git a/src/goto-cc/compile.h b/src/goto-cc/compile.h index 24d6ff41744..f56bd2d2323 100644 --- a/src/goto-cc/compile.h +++ b/src/goto-cc/compile.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Compile and link source and object files. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef GOTO_CC_COMPILE_H @@ -26,7 +26,7 @@ class compilet:public language_uit bool echo_file_name; std::string working_directory; std::string override_language; - + enum { PREPROCESS_ONLY, // gcc -E COMPILE_ONLY, // gcc -c ASSEMBLE_ONLY, // gcc -S @@ -46,9 +46,9 @@ class compilet:public language_uit std::string output_file_object, output_file_executable; compilet(cmdlinet &_cmdline); - + ~compilet(); - + bool add_input_file(const std::string &); bool find_library(const std::string &); bool is_elf_file(const std::string &); @@ -61,16 +61,16 @@ class compilet:public language_uit bool parse_source(const std::string &); - bool write_object_file( const std::string &, const symbol_tablet &, + bool write_object_file( const std::string &, const symbol_tablet &, goto_functionst &); - bool write_bin_object_file( const std::string&, const symbol_tablet &, - goto_functionst& ); + bool write_bin_object_file( const std::string&, const symbol_tablet &, + goto_functionst& ); protected: cmdlinet &cmdline; - + unsigned function_body_count(const goto_functionst &); - + void add_compiler_specific_defines(class configt &config) const; void convert_symbols(goto_functionst &dest); diff --git a/src/goto-cc/cw_mode.cpp b/src/goto-cc/cw_mode.cpp index 7e7550bddf9..a3a085d843c 100644 --- a/src/goto-cc/cw_mode.cpp +++ b/src/goto-cc/cw_mode.cpp @@ -63,7 +63,7 @@ int cw_modet::doit() ui_message_handler.set_verbosity(verbosity); debug() << "CodeWarrior mode" << eom; - + // get configuration config.set(cmdline); @@ -107,7 +107,7 @@ int cw_modet::doit() compiler.output_file_object=""; compiler.output_file_executable="a.out"; } - + if(cmdline.isset("Wp,")) { const std::list &values= @@ -200,4 +200,3 @@ void cw_modet::help_mode() { std::cout << "goto-cw understands the options of gcc (mwcc mode) plus the following.\n\n"; } - diff --git a/src/goto-cc/cw_mode.h b/src/goto-cc/cw_mode.h index 6a1e1c97068..1d18174dc16 100644 --- a/src/goto-cc/cw_mode.h +++ b/src/goto-cc/cw_mode.h @@ -25,7 +25,7 @@ class cw_modet:public goto_cc_modet cmdline(_gcc_cmdline) { } - + protected: gcc_cmdlinet &cmdline; }; diff --git a/src/goto-cc/gcc_cmdline.cpp b/src/goto-cc/gcc_cmdline.cpp index 21b95bb4f49..87a9a10f66f 100644 --- a/src/goto-cc/gcc_cmdline.cpp +++ b/src/goto-cc/gcc_cmdline.cpp @@ -15,13 +15,13 @@ Author: CM Wintersteiger, 2006 #include "gcc_cmdline.h" /*******************************************************************\ - + Function: gcc_cmdlinet::parse - + Inputs: argument count, argument strings - + Outputs: none - + Purpose: parses the commandline options into a cmdlinet \*******************************************************************/ @@ -104,88 +104,88 @@ const char *gcc_options_without_argument[]= "--64", // NON-GCC "--little-endian", // NON-GCC "--big-endian", // NON-GCC - "--no-arch", // NON-GCC + "--no-arch", // NON-GCC "--partial-inlining", // NON-GCC - "-h", + "-h", "--help", // NON-GCC "-?", // NON-GCC "-r", // for ld mimicking "-dylib", // for ld mimicking on MacOS - "-c", + "-c", "-S", - "-E", + "-E", "-combine", - "-pipe", + "-pipe", "-pass-exit-codes", - "-v", + "-v", "-###", - "-help", + "-help", "-target-help", - "--version", + "--version", "-ansi", "-trigraphs", "-no-integrated-cpp", "-traditional", "-traditional-cpp", - "-nostdinc++", + "-nostdinc++", "-gen-decls", "-pedantic", "-pedantic-errors", - "-w", + "-w", "-dumpspecs", "-dumpmachine", - "-dumpversion", + "-dumpversion", "-g", - "-gcoff", + "-gcoff", "-gdwarf-2", - "-ggdb", + "-ggdb", "-gstabs", - "-gstabs+", + "-gstabs+", "-gvms", - "-gxcoff", + "-gxcoff", "-gxcoff+", - "-p", + "-p", "-pg", "-print-libgcc-file-name", "-print-multi-directory", "-print-multi-lib", - "-print-search-dirs", + "-print-search-dirs", "-Q", "-Qn", "-Qy", "-pthread", - "-save-temps", + "-save-temps", "-time", - "-O", - "-O0", - "-O1", + "-O", + "-O0", + "-O1", "-O2", - "-O3", + "-O3", "-Os", "-Oz", // Apple only - "-C", + "-C", "-E", - "-H", + "-H", "-M", - "-MM", - "-MG", + "-MM", + "-MG", "-MP", - "-MD", + "-MD", "-MMD", - "-nostdinc", + "-nostdinc", "-P", - "-remap", + "-remap", "-undef", - "-nostdinc", + "-nostdinc", "-nostartfiles", "-nodefaultlibs", - "-nostdlib", + "-nostdlib", "-pie", - "-rdynamic", + "-rdynamic", "-s", - "-static", - "-static-libgcc", - "--static", + "-static", + "-static-libgcc", + "--static", "-shared", "--shared", "-shared-libgcc", @@ -211,15 +211,15 @@ bool gcc_cmdlinet::parse(int argc, const char **argv) // TODO continue; } - + // file? if(argv_i=="-" || !has_prefix(argv_i, "-")) { add_infile_arg(argv_i); continue; - } - - // add to new_argv + } + + // add to new_argv add_arg(argv_i); // also store in cmdlinet @@ -243,9 +243,9 @@ bool gcc_cmdlinet::parse(int argc, const char **argv) else if(has_prefix(argv_i, "-m")) // m-options { // these sometimes come with a value separated by '=', e.g., -march=cpu_type - + std::size_t equal_pos=argv_i.find('='); - + if(equal_pos==std::string::npos) set(argv_i); // no value else @@ -315,7 +315,7 @@ bool gcc_cmdlinet::parse(int argc, const char **argv) } if(!found) - { + { // unrecognized option std::cerr << "Warning: uninterpreted gcc option '" << argv[i] << "'" << std::endl; } diff --git a/src/goto-cc/gcc_cmdline.h b/src/goto-cc/gcc_cmdline.h index 41f82b7173b..6ec68e2ce64 100644 --- a/src/goto-cc/gcc_cmdline.h +++ b/src/goto-cc/gcc_cmdline.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: A special command line object for the gcc-like options - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef GOTO_CC_GCC_CMDLINE_H diff --git a/src/goto-cc/gcc_mode.cpp b/src/goto-cc/gcc_mode.cpp index ebbb2958261..6038bddb93f 100644 --- a/src/goto-cc/gcc_mode.cpp +++ b/src/goto-cc/gcc_mode.cpp @@ -87,7 +87,7 @@ int gcc_modet::doit() { // This a) prints the version and b) increases verbosity. // Compilation continues, don't exit! - + if(act_as_ld) std::cout << "GNU ld version 2.16.91 20050610 (goto-cc " CBMC_VERSION ")\n"; else @@ -101,7 +101,7 @@ int gcc_modet::doit() else std::cout << "gcc (GCC) 3.4.4 (goto-cc " CBMC_VERSION ")\n\n"; - std::cout << + std::cout << "Copyright (C) 2006-2014 Daniel Kroening, Christoph Wintersteiger\n" << "CBMC version: " CBMC_VERSION << '\n' << "Architecture: " << config.this_architecture() << '\n' << @@ -144,21 +144,21 @@ int gcc_modet::doit() // * assembly (-S) // * preprocessing (-E). // * no input files given - + if(act_as_ld) { } - else if(cmdline.isset('M') || + else if(cmdline.isset('M') || cmdline.isset("MM") || cmdline.isset('S') || cmdline.isset('E') || !cmdline.have_infile_arg()) return run_gcc(); // exit! - + // get configuration config.set(cmdline); - // Intel-specific + // Intel-specific // in GCC, m16 is 32-bit (!), as documented here: // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672 if(cmdline.isset("m16") || @@ -172,33 +172,33 @@ int gcc_modet::doit() config.ansi_c.arch="x86_64"; config.ansi_c.set_arch_spec_x86_64(); } - + // ARM-specific if(cmdline.isset("mbig-endian") || cmdline.isset("mbig")) config.ansi_c.endianness=configt::ansi_ct::endiannesst::IS_BIG_ENDIAN; else if(cmdline.isset("little-endian") || cmdline.isset("mlittle")) config.ansi_c.endianness=configt::ansi_ct::endiannesst::IS_LITTLE_ENDIAN; - + // -fshort-wchar makes wchar_t "short unsigned int" if(cmdline.isset("fshort-wchar")) { config.ansi_c.wchar_t_width=config.ansi_c.short_int_width; config.ansi_c.wchar_t_is_unsigned=true; } - + // -fsingle-precision-constant makes floating-point constants "float" // instead of double if(cmdline.isset("-fsingle-precision-constant")) config.ansi_c.single_precision_constant=true; - + // -fshort-double makes double the same as float if(cmdline.isset("fshort-double")) config.ansi_c.double_width=config.ansi_c.single_width; // determine actions to be undertaken - compilet compiler(cmdline); + compilet compiler(cmdline); compiler.ui_message_handler.set_verbosity(verbosity); - + if(act_as_ld) compiler.mode=compilet::LINK_LIBRARY; else if(cmdline.isset('c')) @@ -246,11 +246,11 @@ int gcc_modet::doit() compiler.object_file_extension="s"; else compiler.object_file_extension="o"; - + if(cmdline.isset("std")) { std::string std_string=cmdline.get_value("std"); - + if(std_string=="gnu89" || std_string=="c89") config.ansi_c.set_c89(); @@ -263,7 +263,7 @@ int gcc_modet::doit() config.ansi_c.set_c11(); if(std_string=="c++11" || std_string=="c++1x" || - std_string=="gnu++11" || std_string=="gnu++1x" || + std_string=="gnu++11" || std_string=="gnu++1x" || std_string=="c++1y" || std_string=="gnu++1y") config.cpp.set_cpp11(); @@ -279,7 +279,7 @@ int gcc_modet::doit() // gcc's default is 64 bits for double if(cmdline.isset("short-double")) config.ansi_c.double_width=32; - + // gcc's default is signed chars on most architectures if(cmdline.isset("funsigned-char")) config.ansi_c.char_is_unsigned=true; @@ -321,14 +321,14 @@ int gcc_modet::doit() compiler.output_file_object=""; compiler.output_file_executable="a.out"; } - + // We now iterate over any input files - + temp_dirt temp_dir("goto-cc-XXXXXX"); - + { std::string language; - + for(goto_cc_cmdlinet::parsed_argvt::iterator arg_it=cmdline.parsed_argv.begin(); arg_it!=cmdline.parsed_argv.end(); @@ -365,7 +365,7 @@ int gcc_modet::doit() error() << "preprocessing has failed" << eom; return exit_code; } - + compiler.add_input_file(dest); } else @@ -387,7 +387,7 @@ int gcc_modet::doit() } } } - + // Revert to gcc in case there is no source to compile // and no binary to link. @@ -403,7 +403,7 @@ int gcc_modet::doit() // containing both executable machine code and the goto-binary. if(produce_hybrid_binary) return gcc_hybrid_binary(); - + return EX_OK; } @@ -426,11 +426,11 @@ int gcc_modet::preprocess( { // build new argv std::vector new_argv; - + new_argv.reserve(cmdline.parsed_argv.size()); bool skip_next=false; - + for(gcc_cmdlinet::parsed_argvt::const_iterator it=cmdline.parsed_argv.begin(); it!=cmdline.parsed_argv.end(); @@ -472,30 +472,30 @@ int gcc_modet::preprocess( // destination file new_argv.push_back("-o"); new_argv.push_back(dest); - + // language, if given if(language!="") { new_argv.push_back("-x"); new_argv.push_back(language); } - - // source file + + // source file new_argv.push_back(src); - + const char *compiler=compiler_name(); // overwrite argv[0] assert(new_argv.size()>=1); new_argv[0]=compiler; - + #if 0 std::cout << "RUN:"; for(std::size_t i=0; i new_argv; - + new_argv.reserve(cmdline.parsed_argv.size()); for(gcc_cmdlinet::parsed_argvt::const_iterator @@ -525,7 +525,7 @@ int gcc_modet::run_gcc() { new_argv.push_back(it->arg); } - + // overwrite argv[0] assert(new_argv.size()>=1); @@ -533,14 +533,14 @@ int gcc_modet::run_gcc() new_argv[0]=linker_name(); else new_argv[0]=compiler_name(); - + #if 0 std::cout << "RUN:"; for(std::size_t i=0; i output_files; - + if(cmdline.isset('c')) { if(cmdline.isset('o')) @@ -598,7 +598,7 @@ int gcc_modet::gcc_hybrid_binary() if(cmdline.isset('o')) output_files.push_back(cmdline.get_value('o')); else - output_files.push_back("a.out"); + output_files.push_back("a.out"); } if(output_files.empty() || @@ -610,7 +610,7 @@ int gcc_modet::gcc_hybrid_binary() debug() << "Running ld to generate hybrid binary" << eom; else debug() << "Running gcc to generate hybrid binary" << eom; - + // save the goto-cc output files for(std::list::const_iterator it=output_files.begin(); @@ -622,9 +622,9 @@ int gcc_modet::gcc_hybrid_binary() // build new argv std::vector new_argv; - + new_argv.reserve(cmdline.parsed_argv.size()); - + bool skip_next=false; for(gcc_cmdlinet::parsed_argvt::const_iterator @@ -648,21 +648,21 @@ int gcc_modet::gcc_hybrid_binary() // overwrite argv[0] assert(new_argv.size()>=1); - + if(act_as_ld) new_argv[0]=linker_name(); else new_argv[0]=compiler_name(); - + #if 0 std::cout << "RUN:"; for(std::size_t i=0; i::const_iterator @@ -678,17 +678,17 @@ int gcc_modet::gcc_hybrid_binary() { // remove any existing goto-cc section std::vector objcopy_argv; - + objcopy_argv.push_back("objcopy"); objcopy_argv.push_back("--remove-section=goto-cc"); objcopy_argv.push_back(*it); - + result=run(objcopy_argv[0], objcopy_argv, ""); } if(result==0) { - // now add goto-binary as goto-cc section + // now add goto-binary as goto-cc section std::vector objcopy_argv; objcopy_argv.push_back("objcopy"); @@ -706,7 +706,7 @@ int gcc_modet::gcc_hybrid_binary() { std::vector lipo_argv; - // now add goto-binary as hppa7100LC section + // now add goto-binary as hppa7100LC section lipo_argv.push_back("lipo"); lipo_argv.push_back(*it); lipo_argv.push_back("-create"); @@ -726,7 +726,7 @@ int gcc_modet::gcc_hybrid_binary() return 1; #endif } - + return result; } @@ -749,4 +749,3 @@ void gcc_modet::help_mode() else std::cout << "goto-cc understands the options of gcc plus the following.\n\n"; } - diff --git a/src/goto-cc/gcc_mode.h b/src/goto-cc/gcc_mode.h index c879ba35dd8..2fbc30a437d 100644 --- a/src/goto-cc/gcc_mode.h +++ b/src/goto-cc/gcc_mode.h @@ -28,22 +28,22 @@ class gcc_modet:public goto_cc_modet } bool produce_hybrid_binary; - + protected: bool act_as_ld; std::string native_compiler_name; - + int preprocess( const std::string &language, const std::string &src, const std::string &dest); int run_gcc(); // call gcc with original command line - + int gcc_hybrid_binary(); - + static bool needs_preprocessing(const std::string &); - + inline const char *compiler_name() { if(native_compiler_name.empty()) diff --git a/src/goto-cc/goto_cc_cmdline.cpp b/src/goto-cc/goto_cc_cmdline.cpp index 7d170d00b3d..8fa543754e9 100644 --- a/src/goto-cc/goto_cc_cmdline.cpp +++ b/src/goto-cc/goto_cc_cmdline.cpp @@ -54,7 +54,7 @@ bool goto_cc_cmdlinet::in_list(const char *option, const char **list) if(strcmp(option, list[i])==0) return true; } - + return false; } @@ -83,7 +83,7 @@ bool goto_cc_cmdlinet::prefix_in_list( return true; } } - + return false; } @@ -103,7 +103,7 @@ std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) { int optnr; cmdlinet::optiont option; - + if(has_prefix(opt_string, "--")) // starts with -- ? { if(opt_string.size()==3) // still "short" @@ -148,7 +148,7 @@ std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) options.push_back(option); return options.size()-1; } - + return optnr; } diff --git a/src/goto-cc/goto_cc_cmdline.h b/src/goto-cc/goto_cc_cmdline.h index 3115ee4c99c..5ced5de0c6d 100644 --- a/src/goto-cc/goto_cc_cmdline.h +++ b/src/goto-cc/goto_cc_cmdline.h @@ -20,7 +20,7 @@ class goto_cc_cmdlinet:public cmdlinet using cmdlinet::parse; virtual bool parse(int argc, const char **argv)=0; - + static bool in_list(const char *option, const char **list); static bool prefix_in_list( @@ -37,7 +37,7 @@ class goto_cc_cmdlinet:public cmdlinet options[nr].isset=true; options[nr].values.push_back(value); } - + void set(const std::string &opt) { options[get_optnr(opt)].isset=true; @@ -46,7 +46,7 @@ class goto_cc_cmdlinet:public cmdlinet // This lets you distinguish input file name arguments // from others, but is otherwise identical to the // original command line. - + struct argt { public: @@ -55,10 +55,10 @@ class goto_cc_cmdlinet:public cmdlinet bool is_infile_name; std::string arg; }; - + typedef std::list parsed_argvt; parsed_argvt parsed_argv; - + bool have_infile_arg() const { for(parsed_argvt::const_iterator @@ -69,7 +69,7 @@ class goto_cc_cmdlinet:public cmdlinet std::string stdin_file; -protected: +protected: void add_arg(const std::string &arg) { parsed_argv.push_back(argt(arg)); diff --git a/src/goto-cc/goto_cc_main.cpp b/src/goto-cc/goto_cc_main.cpp index 4e20b24165e..3442b80da57 100644 --- a/src/goto-cc/goto_cc_main.cpp +++ b/src/goto-cc/goto_cc_main.cpp @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: GOTO-CC Main Module - + Authors: Daniel Kroening, kroening@kroening.com - + Date: May 2006 - + \*******************************************************************/ #include @@ -26,15 +26,15 @@ Date: May 2006 #include "ld_mode.h" /*******************************************************************\ - + Function: to_lower_string - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ std::string to_lower_string(const std::string &s) @@ -45,15 +45,15 @@ std::string to_lower_string(const std::string &s) } /*******************************************************************\ - + Function: main - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ #ifdef _MSC_VER @@ -61,7 +61,7 @@ int wmain(int argc, const wchar_t **argv_wide) #else int main(int argc, const char **argv) #endif -{ +{ #ifdef _MSC_VER const char **argv=narrow_argv(argc, argv_wide); #endif @@ -71,7 +71,7 @@ int main(int argc, const char **argv) std::cerr << "failed to determine base name" << std::endl; return 1; } - + #ifdef _MSC_VER // we do 'to_lower_string' because of Windows std::string base_name= @@ -79,7 +79,7 @@ int main(int argc, const char **argv) #else std::string base_name=get_base_name(argv[0], false); #endif - + if(base_name=="goto-link" || base_name=="link" || base_name=="goto-cl" || base_name=="cl") { diff --git a/src/goto-cc/goto_cc_mode.cpp b/src/goto-cc/goto_cc_mode.cpp index 76032870b61..3d02f19111f 100644 --- a/src/goto-cc/goto_cc_mode.cpp +++ b/src/goto-cc/goto_cc_mode.cpp @@ -25,9 +25,9 @@ Author: CM Wintersteiger, 2006 Function: goto_cc_modet::goto_cc_modet - Inputs: + Inputs: - Outputs: + Outputs: Purpose: constructor @@ -45,9 +45,9 @@ goto_cc_modet::goto_cc_modet(goto_cc_cmdlinet &_cmdline): Function: goto_cc_modet::~goto_cc_modet - Inputs: + Inputs: - Outputs: + Outputs: Purpose: constructor @@ -128,7 +128,7 @@ int goto_cc_modet::main(int argc, const char **argv) { return EX_SOFTWARE; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; diff --git a/src/goto-cc/goto_cc_mode.h b/src/goto-cc/goto_cc_mode.h index 740e27cd8ac..854f5297db5 100644 --- a/src/goto-cc/goto_cc_mode.h +++ b/src/goto-cc/goto_cc_mode.h @@ -28,7 +28,7 @@ class goto_cc_modet:public language_uit explicit goto_cc_modet(goto_cc_cmdlinet &_cmdline); ~goto_cc_modet(); - + protected: ui_message_handlert ui_message_handler; void register_languages(); diff --git a/src/goto-cc/ld_cmdline.cpp b/src/goto-cc/ld_cmdline.cpp index da1fccc474e..0173b1e7774 100644 --- a/src/goto-cc/ld_cmdline.cpp +++ b/src/goto-cc/ld_cmdline.cpp @@ -14,13 +14,13 @@ Author: Daniel Kroening, 2013 #include "ld_cmdline.h" /*******************************************************************\ - + Function: ld_cmdlinet::parse - + Inputs: argument count, argument strings - + Outputs: none - + Purpose: parses the commandline options into a cmdlinet \*******************************************************************/ @@ -250,15 +250,15 @@ bool ld_cmdlinet::parse(int argc, const char **argv) // TODO continue; } - + // file? if(argv_i=="-" || !has_prefix(argv_i, "-")) { add_infile_arg(argv_i); continue; - } - - // add to new_argv + } + + // add to new_argv add_arg(argv_i); // also store in cmdlinet @@ -276,7 +276,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) set(os); // record as long } } - + // arguments to options can be given as follows: // 1) concatenated for short options // 2) concatenated with '=' for long options @@ -285,7 +285,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) for(const char **o=ld_options_with_argument; *o!=NULL && !found; o++) { std::string os(*o); - + // separated? if(argv_i==os || (os.size()>=3 && os[0]=='-' && os[1]=='-' && "-"+argv_i==os)) @@ -321,7 +321,7 @@ bool ld_cmdlinet::parse(int argc, const char **argv) } if(!found) - { + { // unrecognized option std::cerr << "Warning: uninterpreted ld option '" << argv_i << "'" << std::endl; } diff --git a/src/goto-cc/ld_cmdline.h b/src/goto-cc/ld_cmdline.h index 4daa3bf113a..d16adcd7271 100644 --- a/src/goto-cc/ld_cmdline.h +++ b/src/goto-cc/ld_cmdline.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: A special command line object for the ld-like options - + Author: Daniel Kroening - + Date: Feb 2013 - + \*******************************************************************/ #ifndef GOTO_CC_LD_CMDLINE_H diff --git a/src/goto-cc/ld_mode.cpp b/src/goto-cc/ld_mode.cpp index 6b7d1e01e13..f7e6ee09c57 100644 --- a/src/goto-cc/ld_mode.cpp +++ b/src/goto-cc/ld_mode.cpp @@ -47,14 +47,14 @@ int ld_modet::doit() unsigned int verbosity=1; compilet compiler(cmdline); - + if(cmdline.isset('v') || cmdline.isset('V')) { // This a) prints the version and b) increases verbosity. // Linking continues, don't exit! - + std::cout << "GNU ld version 2.16.91 20050610 (goto-cc " CBMC_VERSION ")\n"; - + // 'V' should also print some supported "emulations". } @@ -75,10 +75,10 @@ int ld_modet::doit() debug() << "LD mode (hybrid)" << eom; else debug() << "LD mode" << eom; - + // get configuration config.set(cmdline); - + // determine actions to be undertaken compiler.mode=compilet::LINK_LIBRARY; @@ -118,7 +118,7 @@ int ld_modet::doit() compiler.output_file_object=""; compiler.output_file_executable="a.out"; } - + // do all the rest if(compiler.doit()) return 1; // ld uses exit code 1 for all sorts of errors @@ -130,7 +130,7 @@ int ld_modet::doit() result=true; } #endif - + return EX_OK; } @@ -153,7 +153,7 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) return 0; std::list output_files; - + if(cmdline.isset('c')) { if(cmdline.isset('o')) @@ -179,13 +179,13 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) if(cmdline.isset('o')) output_files.push_back(cmdline.get_value('o')); else - output_files.push_back("a.out"); + output_files.push_back("a.out"); } if(output_files.empty()) return 0; debug("Running gcc to generate hybrid binary"); - + // save the goto-cc output files for(std::list::const_iterator it=output_files.begin(); @@ -197,9 +197,9 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) // build new argv std::vector new_argv; - + new_argv.reserve(cmdline.parsed_argv.size()); - + bool skip_next=false; for(ld_cmdlinet::parsed_argvt::const_iterator @@ -224,16 +224,16 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) // overwrite argv[0] assert(new_argv.size()>=1); new_argv[0]="gcc"; - + #if 0 std::cout << "RUN:"; for(std::size_t i=0; i::const_iterator @@ -248,27 +248,27 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) { // remove any existing goto-cc section std::vector objcopy_argv; - + objcopy_argv.push_back("objcopy"); objcopy_argv.push_back("--remove-section=goto-cc"); objcopy_argv.push_back(*it); - + run(objcopy_argv[0], objcopy_argv); } - // now add goto-binary as goto-cc section + // now add goto-binary as goto-cc section std::string saved=*it+".goto-cc-saved"; std::vector objcopy_argv; - + objcopy_argv.push_back("objcopy"); objcopy_argv.push_back("--add-section"); objcopy_argv.push_back("goto-cc="+saved); objcopy_argv.push_back(*it); - + run(objcopy_argv[0], objcopy_argv); - remove(saved.c_str()); + remove(saved.c_str()); #elif defined(__APPLE__) // Mac @@ -281,8 +281,8 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) debug("merging "+*it); std::vector lipo_argv; - - // now add goto-binary as hppa7100LC section + + // now add goto-binary as hppa7100LC section std::string saved=*it+".goto-cc-saved"; lipo_argv.push_back("lipo"); @@ -293,22 +293,22 @@ int ld_modet::gcc_hybrid_binary(const cmdlinet::argst &input_files) lipo_argv.push_back(saved); lipo_argv.push_back("-output"); lipo_argv.push_back(*it); - + run(lipo_argv[0], lipo_argv); - remove(saved.c_str()); + remove(saved.c_str()); } - + return 0; - + #else - + error() << "binary merging not implemented for this architecture" << eom; return 1; #endif } - + return result!=0; } #endif @@ -329,4 +329,3 @@ void ld_modet::help_mode() { std::cout << "goto-ld understands the options of ld plus the following.\n\n"; } - diff --git a/src/goto-cc/ld_mode.h b/src/goto-cc/ld_mode.h index e0dc42f1760..9369bdbbe22 100644 --- a/src/goto-cc/ld_mode.h +++ b/src/goto-cc/ld_mode.h @@ -28,10 +28,10 @@ class ld_modet:public goto_cc_modet } bool produce_hybrid_binary; - + protected: ld_cmdlinet &cmdline; - + //int gcc_hybrid_binary(const cmdlinet::argst &input_files); //static bool is_supported_source_file(const std::string &); }; diff --git a/src/goto-cc/ms_cl_cmdline.cpp b/src/goto-cc/ms_cl_cmdline.cpp index dfa546f337e..29669514bfa 100644 --- a/src/goto-cc/ms_cl_cmdline.cpp +++ b/src/goto-cc/ms_cl_cmdline.cpp @@ -17,15 +17,15 @@ Author: Daniel Kroening #include "ms_cl_cmdline.h" /*******************************************************************\ - + Function: ms_cl_cmdlinet::parse - + Inputs: argument count, argument strings - + Outputs: none - + Purpose: parses the commandline options into a cmdlinet - + \*******************************************************************/ const char *non_ms_cl_options[]= @@ -44,7 +44,7 @@ const char *non_ms_cl_options[]= "--little-endian", "--big-endian", "--unsigned-char", - "--no-arch", + "--no-arch", "--help", "--xml", "--partial-inlining", @@ -99,21 +99,21 @@ bool ms_cl_cmdlinet::parse(const std::vector &options) } /*******************************************************************\ - + Function: ms_cl_cmdlinet::parse_env - + Inputs: - + Outputs: none - + Purpose: - + \*******************************************************************/ void ms_cl_cmdlinet::parse_env() { // first do environment - + #ifdef _WIN32 const wchar_t *CL_env=_wgetenv(L"CL"); @@ -128,19 +128,19 @@ void ms_cl_cmdlinet::parse_env() if(CL_env!=NULL) process_response_file_line(CL_env); - #endif + #endif } /*******************************************************************\ - + Function: ms_cl_cmdlinet::parse - + Inputs: argument count, argument strings - + Outputs: none - + Purpose: parses the commandline options into a cmdlinet - + \*******************************************************************/ bool ms_cl_cmdlinet::parse(int argc, const char **argv) @@ -152,20 +152,20 @@ bool ms_cl_cmdlinet::parse(int argc, const char **argv) // skip argv[0] for(int i=1; i=3 && @@ -262,7 +262,7 @@ void ms_cl_cmdlinet::process_response_file(const std::string &file) // This is the UTF-8 BOM. We can proceed as usual, since // we use UTF-8 internally. infile.seekg(3); - + while(getline(infile, line)) process_response_file_line(line); } @@ -276,15 +276,15 @@ void ms_cl_cmdlinet::process_response_file(const std::string &file) } /*******************************************************************\ - + Function: ms_cl_cmdlinet::process_response_file_line - - Inputs: - + + Inputs: + Outputs: none - - Purpose: - + + Purpose: + \*******************************************************************/ void ms_cl_cmdlinet::process_response_file_line(const std::string &line) @@ -303,7 +303,7 @@ void ms_cl_cmdlinet::process_response_file_line(const std::string &line) for(std::size_t i=0; i @@ -23,16 +23,16 @@ Date: June 2006 #include "xml_symbol_hashing.h" /*******************************************************************\ - + Function: read_goto_object - + Inputs: input stream, symbol_table, functions - + Outputs: true on error, false otherwise - - Purpose: reads a goto object xml file back into a symbol and a + + Purpose: reads a goto object xml file back into a symbol and a function table - + \*******************************************************************/ bool read_goto_object( @@ -41,7 +41,7 @@ bool read_goto_object( symbol_tablet &symbol_table, goto_functionst &functions, message_handlert &message_handler) -{ +{ messaget message(message_handler); xml_parser.clear(); @@ -53,29 +53,29 @@ bool read_goto_object( return true; xmlt &top = xml_parser.parse_tree.element; - - if (top.get_attribute("version")!=XML_VERSION) + + if (top.get_attribute("version")!=XML_VERSION) { message.error() << "The input was compiled with a different version of " "goto-cc, please recompile." << messaget::eom; return true; } - + xml_irep_convertt::ireps_containert ic; xml_irep_convertt irepconverter(ic); xml_symbol_convertt symbolconverter(ic); xml_goto_function_convertt gfconverter(ic); - + if(top.name.substr(0, 11)=="goto-object") - { + { for(xmlt::elementst::const_iterator sec_it=top.elements.begin(); sec_it != top.elements.end(); sec_it++) { - xmlt sec = *sec_it; - if (sec.name=="irep_hash_map") + xmlt sec = *sec_it; + if (sec.name=="irep_hash_map") { for(xmlt::elementst::const_iterator irep_it = sec.elements.begin(); @@ -88,7 +88,7 @@ bool read_goto_object( } } else if (sec.name=="symbols") - { + { for(xmlt::elementst::const_iterator sym_it = sec.elements.begin(); sym_it != sec.elements.end(); @@ -106,18 +106,18 @@ bool read_goto_object( functions.function_map[symbol.name].type= to_code_type(symbol.type); } - symbol_table.add(symbol); + symbol_table.add(symbol); } } else if (sec.name=="functions") - { + { for(xmlt::elementst::const_iterator fun_it = sec.elements.begin(); fun_it != sec.elements.end(); fun_it++) { std::string fname = fun_it->get_attribute("name"); - //std::cout << "Adding function body: " << fname << std::endl; + //std::cout << "Adding function body: " << fname << std::endl; goto_functionst::goto_functiont &f = functions.function_map[fname]; gfconverter.convert(*fun_it, f); } @@ -135,8 +135,8 @@ bool read_goto_object( { message.error() << "no goto-object" << messaget::eom; return true; - } - + } + xml_parser.clear(); return false; } diff --git a/src/goto-cc/xml_binaries/read_goto_object.h b/src/goto-cc/xml_binaries/read_goto_object.h index 7095f768efe..7b1f67d9252 100644 --- a/src/goto-cc/xml_binaries/read_goto_object.h +++ b/src/goto-cc/xml_binaries/read_goto_object.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Read goto object files. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef CPROVER_READ_GOTO_OBJECT_H diff --git a/src/goto-cc/xml_binaries/xml_goto_function.cpp b/src/goto-cc/xml_binaries/xml_goto_function.cpp index b3cd267bbc8..a50006eb8a1 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function.cpp @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Convert goto functions to xml structures and back. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #include @@ -14,15 +14,15 @@ Date: June 2006 #include "xml_goto_program.h" /*******************************************************************\ - + Function: convert - - Inputs: goto_function and an xml node - + + Inputs: goto_function and an xml node + Outputs: none - - Purpose: takes a goto_function and creates an according xml structure - + + Purpose: takes a goto_function and creates an according xml structure + \*******************************************************************/ void convert( const goto_functionst::goto_functiont& function, xmlt& xml) @@ -32,16 +32,16 @@ void convert( const goto_functionst::goto_functiont& function, xmlt& xml) } /*******************************************************************\ - + Function: convert - + Inputs: xml structure and a goto_function to fill - + Outputs: none - - Purpose: constructs the goto_function according to the information + + Purpose: constructs the goto_function according to the information in the xml structure. - + \*******************************************************************/ void convert( const xmlt& xml, goto_functionst::goto_functiont& function) diff --git a/src/goto-cc/xml_binaries/xml_goto_function.h b/src/goto-cc/xml_binaries/xml_goto_function.h index 995f63c82ce..b9abaae4f32 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.h +++ b/src/goto-cc/xml_binaries/xml_goto_function.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Convert goto functions into xml structures and back - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef XML_GOTO_FUNCTION_H_ diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp index 1315e8b4b80..1fbb85c76ec 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp @@ -1,30 +1,30 @@ /*******************************************************************\ - + Module: Convert goto functions to xml structures and back (with irep hashing) - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #include "xml_goto_function_hashing.h" #include "xml_goto_program_hashing.h" /*******************************************************************\ - + Function: xml_goto_function_convertt::convert - - Inputs: goto_function and an xml node - + + Inputs: goto_function and an xml node + Outputs: none - - Purpose: takes a goto_function and creates an according xml structure - + + Purpose: takes a goto_function and creates an according xml structure + \*******************************************************************/ -void +void xml_goto_function_convertt::convert( const goto_functionst::goto_functiont& function, xmlt& xml) { xml_goto_program_convertt gpconverter(ireps_container); @@ -33,19 +33,19 @@ xml_goto_function_convertt::convert( const goto_functionst::goto_functiont& func } /*******************************************************************\ - + Function: xml_goto_function_convertt::convert - + Inputs: xml structure and a goto_function to fill - + Outputs: none - - Purpose: constructs the goto_function according to the information + + Purpose: constructs the goto_function according to the information in the xml structure. - + \*******************************************************************/ -void +void xml_goto_function_convertt::convert( const xmlt& xml, goto_functionst::goto_functiont& function) { xml_goto_program_convertt gpconverter(ireps_container); diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h index 868be9f14e1..88919a82c67 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h @@ -1,12 +1,12 @@ /*******************************************************************\ - + Module: Convert goto functions into xml structures and back (with irep hashing). - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #ifndef XML_GOTO_FUNCTION_H_ @@ -21,9 +21,9 @@ class xml_goto_function_convertt { private: xml_irep_convertt::ireps_containert &ireps_container; public: - xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic) : + xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic) : ireps_container(ic) {}; - + void convert( const xmlt&, goto_functionst::goto_functiont& ); void convert( const goto_functionst::goto_functiont&, xmlt& ); }; diff --git a/src/goto-cc/xml_binaries/xml_goto_program.cpp b/src/goto-cc/xml_binaries/xml_goto_program.cpp index 64e9e7c4296..b8ab9a1c8b4 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program.cpp @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Convert goto programs to xml structures and back. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #include @@ -16,16 +16,16 @@ Date: June 2006 #include "xml_goto_program.h" /*******************************************************************\ - + Function: convert - + Inputs: goto program, namespace and an xml structure to fill - + Outputs: none - + Purpose: constructs the xml structure according to the goto program and the namespace into the given xml object. - + \*******************************************************************/ void convert(const goto_programt &goto_program, @@ -44,7 +44,7 @@ void convert(const goto_programt &goto_program, if (!ins_it->location.is_nil()) { - convert(ins_it->location, ins.new_element("location")); + convert(ins_it->location, ins.new_element("location")); } if(!ins_it->labels.empty()) @@ -149,7 +149,7 @@ void convert(const goto_programt &goto_program, convert(ins_it->code, c); break; } - + case OTHER: { ins.name = "instruction"; @@ -157,15 +157,15 @@ void convert(const goto_programt &goto_program, convert(ins_it->code, c); break; } - - case ASSIGN: + + case ASSIGN: { ins.name = "assign"; xmlt &c = ins.new_element("code"); convert(ins_it->code, c); break; } - + case FUNCTION_CALL: { ins.name = "functioncall"; @@ -195,7 +195,7 @@ void convert(const goto_programt &goto_program, ins.name = "unknown"; break; } - + if (ins_it->function!="") { xmlt &fnc = ins.new_element("function"); @@ -205,17 +205,17 @@ void convert(const goto_programt &goto_program, } /*******************************************************************\ - + Function: convert - + Inputs: an xml structure, namespace, function symbol and a goto program to fill - + Outputs: none - + Purpose: constructs the goto program according to the xml structure and the namespace into the given goto program object. - + \*******************************************************************/ void convert( const xmlt& xml, goto_programt& goto_program) @@ -399,16 +399,16 @@ void convert( const xmlt& xml, } /*******************************************************************\ - + Function: find_instruction - + Inputs: a target label string, the instructions list and an xml program - + Outputs: iterator to the found instruction or .end() - - Purpose: finds the index of the instruction labelled with the given + + Purpose: finds the index of the instruction labelled with the given target label in the given xml-program - + \*******************************************************************/ goto_programt::targett @@ -430,4 +430,3 @@ find_instruction( return instructions.end(); } - diff --git a/src/goto-cc/xml_binaries/xml_goto_program.h b/src/goto-cc/xml_binaries/xml_goto_program.h index 607e82863a2..1819bef843c 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.h +++ b/src/goto-cc/xml_binaries/xml_goto_program.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Convert goto programs into xml structures and back - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef XML_GOTO_PROGRAM_H_ @@ -17,14 +17,14 @@ Date: June 2006 void convert( const goto_programt&, xmlt&); - + void convert( const xmlt&, goto_programt&); goto_programt::targett find_instruction( - const xmlt &, - goto_programt::instructionst &, + const xmlt &, + goto_programt::instructionst &, const irep_idt &); #endif /*XML_GOTO_PROGRAM_H_*/ diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp index e7a5be873b1..3f624306c3b 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp @@ -1,12 +1,12 @@ /*******************************************************************\ - + Module: Convert goto programs to xml structures and back (with irep hashing) - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #include @@ -16,16 +16,16 @@ Date: July 2006 #include "xml_goto_program_hashing.h" /*******************************************************************\ - + Function: xml_goto_program_convertt::convert - + Inputs: goto program and an xml structure to fill - + Outputs: none - + Purpose: constructs the xml structure according to the goto program and the namespace into the given xml object. - + \*******************************************************************/ void xml_goto_program_convertt::convert(const goto_programt &goto_program, @@ -43,7 +43,7 @@ void xml_goto_program_convertt::convert(const goto_programt &goto_program, xmlt &ins = xml.new_element("instruction"); if (!ins_it->location.is_nil()) { - irepconverter.reference_convert(ins_it->location, ins.new_element("location")); + irepconverter.reference_convert(ins_it->location, ins.new_element("location")); } if(!ins_it->labels.empty()) @@ -189,7 +189,7 @@ void xml_goto_program_convertt::convert(const goto_programt &goto_program, ins.name = "unknown"; break; } - + if(ins_it->function!="") { xmlt &fnc=ins.new_element("function"); @@ -199,23 +199,23 @@ void xml_goto_program_convertt::convert(const goto_programt &goto_program, } /*******************************************************************\ - + Function: xml_goto_program_convertt::convert - + Inputs: an xml structure and a goto program to fill - + Outputs: none - + Purpose: constructs the goto program according to the xml structure and the namespace into the given goto program object. - + \*******************************************************************/ void xml_goto_program_convertt::convert( const xmlt& xml, goto_programt& goto_program) { goto_program.clear(); goto_programt::instructionst &instructions = goto_program.instructions; - + xmlt::elementst::const_iterator it = xml.elements.begin(); for (; it != xml.elements.end(); it++) { @@ -395,16 +395,16 @@ void xml_goto_program_convertt::convert( const xmlt& xml, } /*******************************************************************\ - + Function: xml_goto_program_convertt::find_instruction - + Inputs: a target label string, the instructions list and an xml program - + Outputs: iterator to the found instruction or .end() - - Purpose: finds the index of the instruction labelled with the given + + Purpose: finds the index of the instruction labelled with the given target label in the given xml-program - + \*******************************************************************/ goto_programt::targett xml_goto_program_convertt::find_instruction( const xmlt &xml, @@ -421,4 +421,3 @@ xml_goto_program_convertt::find_instruction( const xmlt &xml, } return instructions.end(); } - diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h index 5ff33229494..b8a8a72494c 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h @@ -1,12 +1,12 @@ /*******************************************************************\ - -Module: Convert goto programs into xml structures and back (with + +Module: Convert goto programs into xml structures and back (with irep hashing) - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #ifndef XML_GOTO_PROGRAM_H_ @@ -21,15 +21,15 @@ class xml_goto_program_convertt { private: xml_irep_convertt irepconverter; public: - xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic) : + xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic) : irepconverter(ic) {}; - + void convert(const goto_programt&, xmlt&); void convert(const xmlt&, goto_programt&); - + goto_programt::targett - find_instruction( const xmlt &, - goto_programt::instructionst &, + find_instruction( const xmlt &, + goto_programt::instructionst &, const std::string &); }; diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp index 75b7055387a..80c71ab6939 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp @@ -1,51 +1,51 @@ /*******************************************************************\ - + Module: XML-irep conversions with hashing - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #include #include -#include "xml_irep_hashing.h" +#include "xml_irep_hashing.h" #include "string_hash.h" /*******************************************************************\ - + Function: xml_irep_convertt::convert - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void xml_irep_convertt::convert( const irept &irep, xmlt &xml) -{ +{ if(irep.id()!="nil") xml.new_element("id").data=irep.id_string(); - + forall_irep(it, irep.get_sub()) - { + { xmlt &x_sub=xml.new_element("s"); reference_convert(*it, x_sub); } - + forall_named_irep(it, irep.get_named_sub()) { xmlt &x_nsub=xml.new_element("ns"); x_nsub.set_attribute("n", name2string(it->first)); reference_convert(it->second, x_nsub); } - + forall_named_irep(it, irep.get_comments()) { xmlt &x_com = xml.new_element("c"); @@ -55,15 +55,15 @@ void xml_irep_convertt::convert( } /*******************************************************************\ - + Function: xml_irep_convertt::convert - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void xml_irep_convertt::convert( @@ -71,13 +71,13 @@ void xml_irep_convertt::convert( irept &irep) { irep.id("nil"); - xmlt::elementst::const_iterator it = xml.elements.begin(); + xmlt::elementst::const_iterator it = xml.elements.begin(); for (; it != xml.elements.end(); it++) { - if (it->name=="R") { + if (it->name=="R") { irep.id("__REFERENCE__"); irep.set("REF", it->data); - } + } else if (it->name=="id") { irep.id(it->data); @@ -112,15 +112,15 @@ void xml_irep_convertt::convert( } /*******************************************************************\ - + Function: xml_irep_convertt::reference_convert - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void xml_irep_convertt::reference_convert( @@ -128,11 +128,11 @@ void xml_irep_convertt::reference_convert( xmlt &xml) { xmlt &ir = xml.new_element("R"); - - ireps_containert::content_containert::const_iterator fi = + + ireps_containert::content_containert::const_iterator fi = find_irep_by_content(irep); - if (fi==ireps_container.content_container.end()) - { + if (fi==ireps_container.content_container.end()) + { unsigned id = ireps_container.id_replace_map[add_with_childs(irep)]; ir.data = long_to_string(id); } else { @@ -142,48 +142,48 @@ void xml_irep_convertt::reference_convert( } /*******************************************************************\ - + Function: xml_irep_convertt::add_with_childs - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ unsigned long xml_irep_convertt::add_with_childs(const irept &iwi) { unsigned long id = insert((unsigned long)&iwi, iwi); if (id!=(unsigned long)&iwi) return id; - + forall_irep(it, iwi.get_sub()) - { - ireps_containert::content_containert::const_iterator fi = + { + ireps_containert::content_containert::const_iterator fi = find_irep_by_content(*it); - if (fi==ireps_container.content_container.end()) - { + if (fi==ireps_container.content_container.end()) + { add_with_childs(*it); } } forall_named_irep(it, iwi.get_named_sub()) - { - ireps_containert::content_containert::const_iterator fi = + { + ireps_containert::content_containert::const_iterator fi = find_irep_by_content(it->second); - if (fi==ireps_container.content_container.end()) - { + if (fi==ireps_container.content_container.end()) + { add_with_childs(it->second); } } forall_named_irep(it, iwi.get_comments()) - { - ireps_containert::content_containert::const_iterator fi = + { + ireps_containert::content_containert::const_iterator fi = find_irep_by_content(it->second); - if (fi==ireps_container.content_container.end()) - { + if (fi==ireps_container.content_container.end()) + { add_with_childs(it->second); } - } + } return id; } @@ -195,7 +195,7 @@ Function: xml_irep_convertt::resolve_references Outputs: none - Purpose: resolves references to ireps from an irep after reading + Purpose: resolves references to ireps from an irep after reading an irep hash map into memory. \*******************************************************************/ @@ -205,40 +205,40 @@ void xml_irep_convertt::resolve_references( const irept &cur ) if (cur.id() == "__REFERENCE__") { unsigned long id = string_to_long(cur.get_string("REF")); - ireps_containert::id_containert::const_iterator itr = find_irep_by_id(id); - if (itr==ireps_container.id_container.end()) + ireps_containert::id_containert::const_iterator itr = find_irep_by_id(id); + if (itr==ireps_container.id_container.end()) { - std::cout << "Warning: can't resolve irep reference (sub " + std::cout << "Warning: can't resolve irep reference (sub " << cur.get("REF") << ")" << std::endl; - } - else - { - irept &curX = const_cast(cur); + } + else + { + irept &curX = const_cast(cur); curX = itr->second; } } - + forall_irep(iti, cur.get_sub()) resolve_references(*iti); - + forall_named_irep(iti, cur.get_named_sub()) resolve_references(iti->second); - + forall_named_irep(iti, cur.get_comments()) - resolve_references(iti->second); - + resolve_references(iti->second); + } /*******************************************************************\ - + Function: xml_irep_convertt::long_to_string - + Inputs: an irep pointer - + Outputs: a new string - + Purpose: converts the hash value to a readable string - + \*******************************************************************/ std::string xml_irep_convertt::long_to_string(const unsigned long l) { std::stringstream s; @@ -247,16 +247,16 @@ std::string xml_irep_convertt::long_to_string(const unsigned long l) { } /*******************************************************************\ - + Function: xml_irep_convertt::string_to_long - + Inputs: a string - + Outputs: an unsigned long - - Purpose: converts the string to an unsigned long that used to give + + Purpose: converts the string to an unsigned long that used to give a pointer to an irep in an old compilation - + \*******************************************************************/ unsigned long xml_irep_convertt::string_to_long(const std::string &s) { std::stringstream ss(s); @@ -266,103 +266,103 @@ unsigned long xml_irep_convertt::string_to_long(const std::string &s) { } /*******************************************************************\ - + Function: xml_irep_convertt::find_irep_by_id - + Inputs: an id - + Outputs: an iterator into the ireps hash set - + Purpose: finds an irep in the ireps hash set by its id - + \*******************************************************************/ -xml_irep_convertt::ireps_containert::id_containert::const_iterator +xml_irep_convertt::ireps_containert::id_containert::const_iterator xml_irep_convertt::find_irep_by_id(const unsigned int id) { return ireps_container.id_container.find(id); } /*******************************************************************\ - + Function: xml_irep_convertt::find_irep_by_content - + Inputs: an irep - + Outputs: an iterator into the ireps hash set - + Purpose: finds an irep in the ireps hash set by checking contents - + \*******************************************************************/ -xml_irep_convertt::ireps_containert::content_containert::const_iterator +xml_irep_convertt::ireps_containert::content_containert::const_iterator xml_irep_convertt::find_irep_by_content(const irept &irep) { return ireps_container.content_container.find(irep); } /*******************************************************************\ - + Function: xml_irep_convertt::insert - + Inputs: an unsigned long and an irep - + Outputs: true on success, false otherwise - - Purpose: inserts an irep into the hashtable - + + Purpose: inserts an irep into the hashtable + \*******************************************************************/ unsigned long xml_irep_convertt::insert( - unsigned long id, - const irept& i) + unsigned long id, + const irept& i) { ireps_containert::content_containert::const_iterator sit; sit = find_irep_by_content(i); if (sit==ireps_container.content_container.end()) { ireps_container.content_container.insert( std::pair(i, id)); - + if( ireps_container.id_container.insert( std::pair(id, i) ).second ) { - ireps_container.id_replace_map[id] = + ireps_container.id_replace_map[id] = ireps_container.id_container.size(); } - + return id; } else { return sit->second; - } + } } /*******************************************************************\ - + Function: xml_irep_convertt::insert - + Inputs: a string and an irep - + Outputs: true on success, false otherwise - + Purpose: inserts an irep into the hashtable - + \*******************************************************************/ unsigned long xml_irep_convertt::insert( - const std::string &id, - const irept& i) + const std::string &id, + const irept& i) { return insert(string_to_long(id), i); } /*******************************************************************\ - + Function: xml_irep_convertt::convert_map - + Inputs: an xml node - + Outputs: nothing - + Purpose: converts the current hash map of ireps into the given xml structure - + \*******************************************************************/ void xml_irep_convertt::convert_map(xmlt &xml) { - ireps_containert::id_containert::iterator hit = + ireps_containert::id_containert::iterator hit = ireps_container.id_container.begin(); for (; hit!=ireps_container.id_container.end(); hit++) { xmlt &xmlhe = xml.new_element("irep"); @@ -373,25 +373,25 @@ void xml_irep_convertt::convert_map(xmlt &xml) { } /*******************************************************************\ - + Function: xml_irep_convertt::output_map - + Inputs: an output stream - + Outputs: nothing - + Purpose: converts the current hash map of ireps into xml nodes and outputs them to the stream - + \*******************************************************************/ void xml_irep_convertt::output_map(std::ostream &out, unsigned indent) { - ireps_containert::id_containert::iterator hit = + ireps_containert::id_containert::iterator hit = ireps_container.id_container.begin(); for (; hit!=ireps_container.id_container.end(); hit++) { xmlt xmlhe("irep"); xmlhe.set_attribute("id", long_to_string( ireps_container.id_replace_map[hit->first])); convert(hit->second, xmlhe); - xmlhe.output(out, indent); + xmlhe.output(out, indent); } } diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.h b/src/goto-cc/xml_binaries/xml_irep_hashing.h index abb2da9531d..78d263469cc 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.h +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: XML-irep conversions with hashing - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #ifndef XML_IREP_HASHING_H_ @@ -17,37 +17,37 @@ Date: July 2006 class xml_irep_convertt { private: - + struct ul_hash { - unsigned short operator()(const unsigned long l) const - { - return (l & 0xFFFF); + unsigned short operator()(const unsigned long l) const + { + return (l & 0xFFFF); } }; struct ul_eq { - bool operator()(const unsigned long l, const unsigned long r) const + bool operator()(const unsigned long l, const unsigned long r) const { return (l==r); } }; struct irep_full_hash { - size_t operator()(const irept &i) const - { - return i.full_hash(); + size_t operator()(const irept &i) const + { + return i.full_hash(); } }; struct irep_content_eq { - bool operator()(const irept &l, const irept &r) const + bool operator()(const irept &l, const irept &r) const { return full_eq(l,r); } }; - - public: + + public: class ireps_containert { public: typedef hash_map_cont id_containert; @@ -55,41 +55,41 @@ class xml_irep_convertt { typedef hash_map_cont content_containert; content_containert content_container; typedef std::map id_replace_mapt; - id_replace_mapt id_replace_map; - - void clear( void ) { - id_container.clear(); + id_replace_mapt id_replace_map; + + void clear( void ) { + id_container.clear(); content_container.clear(); id_replace_map.clear(); - } + } }; - + xml_irep_convertt(ireps_containert& ic) : ireps_container(ic) {}; - + unsigned long insert(unsigned long, const irept&); unsigned long insert(const std::string&, const irept&); - - void convert(const irept &irep, xmlt &xml); + + void convert(const irept &irep, xmlt &xml); void convert(const xmlt &xml, irept &irep); void reference_convert(const irept &irep, xmlt &xml); void resolve_references( const irept &cur ); - + void convert_map(xmlt &xml); void output_map(std::ostream &out, unsigned indent); - + void clear( void ) { ireps_container.clear(); } private: - ireps_containert& ireps_container; - - ireps_containert::id_containert::const_iterator + ireps_containert& ireps_container; + + ireps_containert::id_containert::const_iterator find_irep_by_id(const unsigned int); - ireps_containert::content_containert::const_iterator + ireps_containert::content_containert::const_iterator find_irep_by_content(const irept &irep); - + std::string long_to_string(const unsigned long); unsigned long string_to_long(const std::string &); - - unsigned long add_with_childs(const irept&); + + unsigned long add_with_childs(const irept&); }; #endif /*XML_IREP_HASHING_H_*/ diff --git a/src/goto-cc/xml_binaries/xml_symbol.cpp b/src/goto-cc/xml_binaries/xml_symbol.cpp index 50ba32ab646..de15befac84 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol.cpp @@ -1,26 +1,26 @@ /*******************************************************************\ - + Module: Compile and link source and object files. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #include "xml_irep.h" #include "xml_symbol.h" /*******************************************************************\ - + Function: convert - + Inputs: a symbol and an xml node - + Outputs: none - + Purpose: converts a symbol to an xml symbol node - + \*******************************************************************/ void convert(const symbolt& sym, xmlt &root) @@ -69,21 +69,21 @@ void convert(const symbolt& sym, xmlt &root) } /*******************************************************************\ - + Function: convert - + Inputs: an xml node and a symbol - + Outputs: none - + Purpose: converts an xml symbol node to a symbol - + \*******************************************************************/ void convert(const xmlt &xmlsym, symbolt& symbol) { symbol.name=xmlsym.get_attribute("name"); - + for(xmlt::elementst::const_iterator it=xmlsym.elements.begin(); it!=xmlsym.elements.end(); @@ -120,7 +120,7 @@ void convert(const xmlt &xmlsym, symbolt& symbol) //symbol.binding = it->get_attribute_bool("binding"); //symbol.free_var = it->get_attribute_bool("free_var"); symbol.is_state_var = it->get_attribute_bool("statevar"); - + for(xmlt::elementst::const_iterator fit=it->elements.begin(); fit!=it->elements.end(); diff --git a/src/goto-cc/xml_binaries/xml_symbol.h b/src/goto-cc/xml_binaries/xml_symbol.h index 1cd9a39c3a8..b946a05a10c 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.h +++ b/src/goto-cc/xml_binaries/xml_symbol.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Converts symbols to xml structures and back. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #ifndef XML_SYMBOL_H_ diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp index b733957d4c2..49051cac072 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp @@ -1,53 +1,53 @@ /*******************************************************************\ - + Module: XML-symbol conversions with irep hashing - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #include "xml_symbol_hashing.h" #include "xml_irep_hashing.h" /*******************************************************************\ - + Function: xml_symbol_convertt::convert - + Inputs: a symbol and an xml node - + Outputs: none - + Purpose: converts a symbol to an xml symbol node - + \*******************************************************************/ void xml_symbol_convertt::convert(const symbolt& sym, xmlt &root) { xmlt &xmlsym = root.new_element("symbol"); irepcache.push_back(irept()); - sym.to_irep(irepcache.back()); + sym.to_irep(irepcache.back()); irepconverter.reference_convert(irepcache.back(), xmlsym); } /*******************************************************************\ - + Function: xml_symbol_convertt::convert - + Inputs: an xml node and a symbol - + Outputs: none - + Purpose: converts an xml symbol node to a symbol - + \*******************************************************************/ void xml_symbol_convertt::convert(const xmlt &xmlsym, symbolt& symbol) -{ +{ irept t; - + irepconverter.convert(xmlsym, t); irepconverter.resolve_references(t); - symbol.from_irep(t); + symbol.from_irep(t); } diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.h b/src/goto-cc/xml_binaries/xml_symbol_hashing.h index 9d3d96dc91d..606bb14d9da 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.h +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: XML-symbol conversions with irep hashing - + Author: CM Wintersteiger - + Date: July 2006 - + \*******************************************************************/ #ifndef XML_SYMBOL_HASHING_H_ @@ -20,11 +20,11 @@ class xml_symbol_convertt { private: xml_irep_convertt irepconverter; std::list irepcache; - + public: - xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic) : + xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic) : irepconverter(ic) {}; - + void convert(const symbolt &, xmlt &); void convert(const xmlt &, symbolt &); }; diff --git a/src/goto-diff/Makefile b/src/goto-diff/Makefile index f30027ac66a..6f9dd1a893a 100644 --- a/src/goto-diff/Makefile +++ b/src/goto-diff/Makefile @@ -53,4 +53,3 @@ goto-diff$(EXEEXT): $(OBJ) cbmc-mac-signed: goto-diff$(EXEEXT) strip goto-diff$(EXEEXT) ; codesign -v -s $(OSX_IDENTITY) goto-diff$(EXEEXT) - diff --git a/src/goto-diff/goto_diff.h b/src/goto-diff/goto_diff.h index bb4c5f4c219..94c013b386e 100644 --- a/src/goto-diff/goto_diff.h +++ b/src/goto-diff/goto_diff.h @@ -31,22 +31,22 @@ class goto_difft : public messaget ui(ui_message_handlert::PLAIN), total_functions_count(0) {} - + virtual bool operator()()=0; - + void set_ui(language_uit::uit _ui) { ui=_ui; } - + virtual std::ostream &output_functions(std::ostream &out) const; - + protected: const goto_modelt &goto_model1; const goto_modelt &goto_model2; language_uit::uit ui; - + unsigned total_functions_count; typedef std::set irep_id_sett; - irep_id_sett new_functions, modified_functions, deleted_functions; - + irep_id_sett new_functions, modified_functions, deleted_functions; + void convert_function_group( json_arrayt &result, const irep_id_sett &function_group) const; diff --git a/src/goto-diff/goto_diff_base.cpp b/src/goto-diff/goto_diff_base.cpp index 1eeedc155f2..a8f1ff4f9ea 100644 --- a/src/goto-diff/goto_diff_base.cpp +++ b/src/goto-diff/goto_diff_base.cpp @@ -67,7 +67,7 @@ std::ostream &goto_difft::output_functions(std::ostream &out) const case ui_message_handlert::JSON_UI: { json_objectt json_result; - json_result["totalNumberOfFunctions"]= + json_result["totalNumberOfFunctions"]= json_stringt(i2string(total_functions_count)); convert_function_group (json_result["newFunctions"].make_array(), new_functions); diff --git a/src/goto-diff/goto_diff_languages.cpp b/src/goto-diff/goto_diff_languages.cpp index 14897c9a53d..c467ab92cd3 100644 --- a/src/goto-diff/goto_diff_languages.cpp +++ b/src/goto-diff/goto_diff_languages.cpp @@ -37,13 +37,12 @@ void goto_diff_languagest::register_languages() { register_language(new_ansi_c_language); register_language(new_cpp_language); - + #ifdef HAVE_SPECC register_language(new_specc_language); #endif - + #ifdef HAVE_JAVA_BYTECODE register_language(new_java_bytecode_language); #endif } - diff --git a/src/goto-diff/goto_diff_main.cpp b/src/goto-diff/goto_diff_main.cpp index 4b1a932911d..96655ea5455 100644 --- a/src/goto-diff/goto_diff_main.cpp +++ b/src/goto-diff/goto_diff_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: GOTO-DIFF Main Module +Module: GOTO-DIFF Main Module Author: Peter Schrammel diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index 14430758a83..317da4bf32b 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -419,7 +419,7 @@ int goto_diff_parse_optionst::get_goto_program( } else { - // This is a a workaround to make parse() think that there is only + // This is a a workaround to make parse() think that there is only // one source file. std::string arg2(""); if(cmdline.args.size()==2) diff --git a/src/goto-diff/goto_diff_parse_options.h b/src/goto-diff/goto_diff_parse_options.h index 1b979f744b4..5dd10f54b5a 100644 --- a/src/goto-diff/goto_diff_parse_options.h +++ b/src/goto-diff/goto_diff_parse_options.h @@ -56,9 +56,9 @@ class goto_diff_parse_optionst: virtual bool process_goto_program( const optionst &options, goto_modelt &goto_model); - + void eval_verbosity(); - + void preprocessing(); }; diff --git a/src/goto-diff/syntactic_diff.cpp b/src/goto-diff/syntactic_diff.cpp index a56150907c8..af1e910fd66 100644 --- a/src/goto-diff/syntactic_diff.cpp +++ b/src/goto-diff/syntactic_diff.cpp @@ -81,4 +81,3 @@ bool syntactic_difft::operator()() modified_functions.empty() && deleted_functions.empty()); } - diff --git a/src/goto-instrument/Makefile b/src/goto-instrument/Makefile index fd44907bb11..0d1e4d6f741 100644 --- a/src/goto-instrument/Makefile +++ b/src/goto-instrument/Makefile @@ -41,7 +41,7 @@ OBJ += ../ansi-c/ansi-c$(LIBEXT) \ INCLUDES= -I .. -LIBS = +LIBS = CLEANFILES = goto-instrument$(EXEEXT) @@ -72,4 +72,3 @@ goto-instrument$(EXEEXT): $(OBJ) goto-instrument-mac-signed: goto-instrument$(EXEEXT) codesign -v -s $(OSX_IDENTITY) goto-instrument$(EXEEXT) - diff --git a/src/goto-instrument/accelerate/accelerate.cpp b/src/goto-instrument/accelerate/accelerate.cpp index 40b3370a03e..e59b5273666 100644 --- a/src/goto-instrument/accelerate/accelerate.cpp +++ b/src/goto-instrument/accelerate/accelerate.cpp @@ -393,7 +393,7 @@ symbolt acceleratet::make_symbol(std::string name, typet type) { ret.base_name = name; ret.pretty_name = name; ret.type = type; - + symbol_table.add(ret); return ret; diff --git a/src/goto-instrument/accelerate/acceleration_utils.cpp b/src/goto-instrument/accelerate/acceleration_utils.cpp index ec7f670ab61..384ff5db56e 100644 --- a/src/goto-instrument/accelerate/acceleration_utils.cpp +++ b/src/goto-instrument/accelerate/acceleration_utils.cpp @@ -113,7 +113,7 @@ bool acceleration_utilst::check_inductive( substitutiont substitution; stash_polynomials(program, polynomials, substitution, path); - + for (std::map::iterator it = polynomials.begin(); it != polynomials.end(); ++it) { @@ -322,7 +322,7 @@ bool acceleration_utilst::do_assumptions( // assert(!precondition); exprt condition = precondition(path); - scratch_programt program(symbol_table); + scratch_programt program(symbol_table); substitutiont substitution; stash_polynomials(program, polynomials, substitution, path); @@ -482,7 +482,7 @@ bool acceleration_utilst::do_arrays( expr_sett arrays_written; expr_pairst array_assignments; - + array_assignments = gather_array_assignments(loop_body, arrays_written); #ifdef DEBUG @@ -1129,4 +1129,3 @@ symbolt acceleration_utilst::fresh_symbol(std::string base, typet type) return ret; } - diff --git a/src/goto-instrument/accelerate/accelerator.h b/src/goto-instrument/accelerate/accelerator.h index 37e7e9fa460..6263edc9f70 100644 --- a/src/goto-instrument/accelerate/accelerator.h +++ b/src/goto-instrument/accelerate/accelerator.h @@ -32,7 +32,7 @@ class path_acceleratort { path_acceleratort(const path_acceleratort &that) : path(that.path), changed_vars(that.changed_vars), - dirty_vars(that.dirty_vars) + dirty_vars(that.dirty_vars) { pure_accelerator.copy_from(that.pure_accelerator); overflow_path.copy_from(that.overflow_path); diff --git a/src/goto-instrument/accelerate/cone_of_influence.cpp b/src/goto-instrument/accelerate/cone_of_influence.cpp index 25f10288f6a..c55c4021488 100644 --- a/src/goto-instrument/accelerate/cone_of_influence.cpp +++ b/src/goto-instrument/accelerate/cone_of_influence.cpp @@ -32,7 +32,7 @@ void cone_of_influencet::cone_of_influence(const expr_sett &targets, #ifdef DEBUG std::cout << "Previous cone: " << std::endl; - + for (expr_sett::iterator it = curr.begin(); it != curr.end(); ++it) { @@ -40,7 +40,7 @@ void cone_of_influencet::cone_of_influence(const expr_sett &targets, } std::cout << std::endl << "Current cone: " << std::endl; - + for (expr_sett::iterator it = next.begin(); it != next.end(); ++it) { @@ -91,7 +91,7 @@ void cone_of_influencet::get_succs( return; } } - + unsigned int loc = next->location_number; expr_sett &s = cone_map[loc]; targets.insert(s.begin(), s.end()); diff --git a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp index d7acccd04da..c22ae123fc7 100644 --- a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp +++ b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp @@ -212,7 +212,7 @@ bool disjunctive_polynomial_accelerationt::accelerate( exprt guard; bool path_is_monotone; - + try { path_is_monotone = utils.do_assumptions(polynomials, path, guard); } catch (std::string s) { @@ -512,7 +512,7 @@ bool disjunctive_polynomial_accelerationt::fit_polynomial( assert_for_values(program, values, coefficients, 0, fixed, var); assert_for_values(program, values, coefficients, 1, fixed, var); assert_for_values(program, values, coefficients, 2, fixed, var); - + // Let's make sure that we get a path we have not seen before. for (std::list::iterator it = accelerated_paths.begin(); it != accelerated_paths.end(); @@ -811,7 +811,7 @@ void disjunctive_polynomial_accelerationt::build_fixed() { fixedt->make_skip(); continue; } - + if (d != distinguishing_points.end()) { // We've hit a distinguishing point. Set the relevant shadow // distinguisher to true. diff --git a/src/goto-instrument/accelerate/path.h b/src/goto-instrument/accelerate/path.h index 963c9fae795..890252de218 100644 --- a/src/goto-instrument/accelerate/path.h +++ b/src/goto-instrument/accelerate/path.h @@ -32,7 +32,7 @@ class path_nodet }; typedef std::list patht; -typedef std::list pathst; +typedef std::list pathst; void output_path(patht &path, goto_programt &program, namespacet &ns, std::ostream &str); diff --git a/src/goto-instrument/accelerate/polynomial_accelerator.cpp b/src/goto-instrument/accelerate/polynomial_accelerator.cpp index 4747b9e1bc1..a13eb34a9c4 100644 --- a/src/goto-instrument/accelerate/polynomial_accelerator.cpp +++ b/src/goto-instrument/accelerate/polynomial_accelerator.cpp @@ -149,7 +149,7 @@ bool polynomial_acceleratort::accelerate(patht &loop, exprt guard_last; bool path_is_monotone; - + try { path_is_monotone = utils.do_assumptions(polynomials, loop, guard); } catch (std::string s) { @@ -584,7 +584,7 @@ bool polynomial_acceleratort::check_inductive( substitutiont substitution; stash_polynomials(program, polynomials, substitution, body); - + for (std::map::iterator it = polynomials.begin(); it != polynomials.end(); ++it) { diff --git a/src/goto-instrument/accelerate/sat_path_enumerator.cpp b/src/goto-instrument/accelerate/sat_path_enumerator.cpp index 336e687134d..3ce3eaf1888 100644 --- a/src/goto-instrument/accelerate/sat_path_enumerator.cpp +++ b/src/goto-instrument/accelerate/sat_path_enumerator.cpp @@ -244,7 +244,7 @@ void sat_path_enumeratort::build_fixed() { fixedt->make_skip(); continue; } - + if (d != distinguishing_points.end()) { // We've hit a distinguishing point. Set the relevant shadow // distinguisher to true. diff --git a/src/goto-instrument/accelerate/trace_automaton.cpp b/src/goto-instrument/accelerate/trace_automaton.cpp index 9da5dbdd051..98718be2124 100644 --- a/src/goto-instrument/accelerate/trace_automaton.cpp +++ b/src/goto-instrument/accelerate/trace_automaton.cpp @@ -101,7 +101,7 @@ void trace_automatont::add_path(patht &path) { void trace_automatont::determinise() { #ifdef DEBUG std::cout << "Determinising automaton with " << nta.num_states << - " states and " << nta.accept_states.size() << " accept states and " + " states and " << nta.accept_states.size() << " accept states and " << nta.count_transitions() << " transitions" << endl; #endif diff --git a/src/goto-instrument/alignment_checks.cpp b/src/goto-instrument/alignment_checks.cpp index 7380a29eaa2..1418982cd8d 100644 --- a/src/goto-instrument/alignment_checks.cpp +++ b/src/goto-instrument/alignment_checks.cpp @@ -103,7 +103,7 @@ void print_struct_alignment_problems( if(2*integer2long(size)<=config.ansi_c.memory_operand_size) { - out << std::endl << "WARNING: " + out << std::endl << "WARNING: " << "declaration of an array at " << it->second.location << std::endl << "might be concurrently accessed" << std::endl; diff --git a/src/goto-instrument/branch.cpp b/src/goto-instrument/branch.cpp index f9ae811e3b1..6bd6c64c72a 100644 --- a/src/goto-instrument/branch.cpp +++ b/src/goto-instrument/branch.cpp @@ -34,15 +34,15 @@ void branch( // don't instrument our internal functions if(has_prefix(id2string(f_it->first), CPROVER_PREFIX)) continue; - + // don't instrument the function to be called, // or otherwise this will be recursive if(f_it->first==id) continue; - + // patch in a call to `id' at the branch points goto_programt &body=f_it->second.body; - + Forall_goto_program_instructions(i_it, body) { // if C goto T is transformed into: @@ -52,29 +52,29 @@ void branch( // goto T t2 // T': id("not-taken"); t3 // ... - + if(i_it->is_goto() && !i_it->guard.is_constant()) { // negate condition i_it->guard.make_not(); - + goto_programt::targett t1=body.insert_after(i_it); t1->make_function_call( function_to_call(symbol_table, id, "taken")); t1->function=f_it->first; - + goto_programt::targett t2=body.insert_after(t1); t2->make_goto(); t2->targets=i_it->targets; - + goto_programt::targett t3=body.insert_after(t2); t3->make_function_call( function_to_call(symbol_table, id, "not-taken")); t3->function=f_it->first; i_it->targets.clear(); i_it->targets.push_back(t3); - } + } } } } diff --git a/src/goto-instrument/call_sequences.cpp b/src/goto-instrument/call_sequences.cpp index 6c5a5783f36..c39119972af 100644 --- a/src/goto-instrument/call_sequences.cpp +++ b/src/goto-instrument/call_sequences.cpp @@ -33,10 +33,10 @@ void show_call_sequences( const goto_programt::const_targett start) { std::cout << "# From " << function << std::endl; - + std::stack stack; std::set seen; - + if(start!=goto_program.instructions.end()) stack.push(start); @@ -44,10 +44,10 @@ void show_call_sequences( { goto_programt::const_targett t=stack.top(); stack.pop(); - + if(!seen.insert(t).second) continue; // seen it already - + if(t->is_function_call()) { const exprt &function2=to_code_function_call(t->code).function(); @@ -63,7 +63,7 @@ void show_call_sequences( // get successors goto_programt::const_targetst s; goto_program.get_successors(t, s); - + // add to stack for(goto_programt::const_targetst::const_iterator it=s.begin(); it!=s.end(); it++) @@ -88,24 +88,24 @@ void show_call_sequences( const goto_programt &goto_program) { // this is quadratic - + std::cout << "# " << function << std::endl; - + show_call_sequences( function, goto_program, goto_program.instructions.begin()); - + forall_goto_program_instructions(i_it, goto_program) { if(!i_it->is_function_call()) continue; - + const exprt &f1=to_code_function_call(i_it->code).function(); - + if(f1.id()!=ID_symbol) continue; - + // find any calls reachable from this one goto_programt::const_targett next=i_it; next++; @@ -115,7 +115,7 @@ void show_call_sequences( goto_program, next); } - + std::cout << std::endl; } @@ -160,10 +160,10 @@ class check_call_sequencet goto_functions(_goto_functions), sequence(_sequence) { - } + } void operator()(); - + protected: const goto_functionst &goto_functions; const std::vector &sequence; @@ -173,14 +173,14 @@ class check_call_sequencet goto_functionst::function_mapt::const_iterator f; goto_programt::const_targett return_address; }; - + friend bool operator==(const call_stack_entryt &e1, const call_stack_entryt &e2) { return e1.f->first==e2.f->first && e1.return_address==e2.return_address; } - + struct statet { goto_functionst::function_mapt::const_iterator f; @@ -196,7 +196,7 @@ class check_call_sequencet s1.index==s2.index; } }; - + class state_hash { public: @@ -205,13 +205,13 @@ class check_call_sequencet size_t pc_hash= s.pc==s.f->second.body.instructions.end()?0: (size_t)&*s.pc; - + return hash_string(s.f->first)^ pc_hash^ s.index^s.call_stack.size(); } }; - + typedef hash_set_cont statest; statest states; }; @@ -225,7 +225,7 @@ void check_call_sequencet::operator()() std::cout << "empty sequence given\n"; return; } - + irep_idt entry=sequence.front(); goto_functionst::function_mapt::const_iterator f_it= @@ -238,11 +238,11 @@ void check_call_sequencet::operator()() queue.top().pc=f_it->second.body.instructions.begin(); queue.top().index=1; } - + while(!queue.empty()) { statet &e=queue.top(); - + // seen already? if(states.find(e)!=states.end()) { @@ -250,10 +250,10 @@ void check_call_sequencet::operator()() queue.pop(); continue; } - + // insert states.insert(e); - + // satisfies sequence? if(e.index==sequence.size()) { @@ -280,14 +280,14 @@ void check_call_sequencet::operator()() if(function.id()==ID_symbol) { irep_idt identifier=to_symbol_expr(function).get_identifier(); - + if(sequence[e.index]==identifier) { e.index++; // yes, we have seen it - + goto_functionst::function_mapt::const_iterator f_call_it= goto_functions.function_map.find(identifier); - + if(f_call_it==goto_functions.function_map.end()) e.pc++; else @@ -341,19 +341,18 @@ Function: check_call_sequence void check_call_sequence(const goto_functionst &goto_functions) { // read the sequence from stdin - + std::vector sequence; - + std::string line; while(std::getline(std::cin, line)) { if(line!="" && line[line.size()-1]=='\r') line.resize(line.size()-1); - + if(line!="") sequence.push_back(line); } check_call_sequencet(goto_functions, sequence)(); } - diff --git a/src/goto-instrument/code_contracts.cpp b/src/goto-instrument/code_contracts.cpp index c0de91c1582..d05c7bdbcf8 100644 --- a/src/goto-instrument/code_contracts.cpp +++ b/src/goto-instrument/code_contracts.cpp @@ -101,13 +101,13 @@ static void check_apply_invariants( // H: assert(invariant); // havoc; // assume(invariant); - // if(guard) goto E: + // if(guard) goto E: // loop; // assert(invariant); // assume(false); // E: ... - // find out what can get changed in the loop + // find out what can get changed in the loop modifiest modifies; get_modifies(local_may_alias, loop, modifies); @@ -489,4 +489,3 @@ void code_contracts( { code_contractst(symbol_table, goto_functions)(); } - diff --git a/src/goto-instrument/concurrency.cpp b/src/goto-instrument/concurrency.cpp index 827bcda8817..2bfdf95a5a2 100644 --- a/src/goto-instrument/concurrency.cpp +++ b/src/goto-instrument/concurrency.cpp @@ -20,13 +20,13 @@ class concurrency_instrumentationt { public: concurrency_instrumentationt( - value_setst &_value_sets, + value_setst &_value_sets, symbol_tablet &_symbol_table): value_sets(_value_sets), symbol_table(_symbol_table) { } - + void operator()(goto_functionst &goto_functions) { instrument(goto_functions); @@ -91,8 +91,8 @@ void concurrency_instrumentationt::instrument(exprt &expr) find_symbols(expr, symbols); - replace_symbolt replace_symbol; - + replace_symbolt replace_symbol; + for(std::set::const_iterator s_it=symbols.begin(); s_it!=symbols.end(); @@ -105,13 +105,13 @@ void concurrency_instrumentationt::instrument(exprt &expr) shared_varst::const_iterator v_it=shared_vars.find(identifier); - + if(v_it!=shared_vars.end()) { index_exprt new_expr; //new_expr.array()=symbol_expr(); //new_expr.index()=symbol_expr(); - + replace_symbol.insert(identifier, new_expr); } } @@ -188,10 +188,10 @@ void concurrency_instrumentationt::collect(const exprt &expr) namespacet ns(symbol_table); const symbolt &symbol=ns.lookup(identifier); - + if(!symbol.is_state_var) continue; - + if(symbol.is_thread_local) { if(thread_local_vars.find(identifier)!=thread_local_vars.end()) @@ -277,11 +277,11 @@ void concurrency_instrumentationt::instrument( { namespacet ns(symbol_table); is_threadedt is_threaded(goto_functions); - + // this first collects all shared and thread-local variables forall_goto_functions(f_it, goto_functions) collect(f_it->second.body, is_threaded); - + // add array symbols add_array_symbols(); diff --git a/src/goto-instrument/cover.cpp b/src/goto-instrument/cover.cpp index b7e6f687d8e..fba2f5fe4dc 100644 --- a/src/goto-instrument/cover.cpp +++ b/src/goto-instrument/cover.cpp @@ -29,31 +29,31 @@ class basic_blockst { if(next_is_target || it->is_target()) block_count++; - + block_map[it]=block_count; - + if(!it->source_location.is_nil() && source_location_map.find(block_count)==source_location_map.end()) source_location_map[block_count]=it->source_location; - + next_is_target= it->is_goto() || it->is_function_call() || it->is_assume(); } } - // map program locations to block numbers + // map program locations to block numbers typedef std::map block_mapt; block_mapt block_map; - + // map block numbers to source code locations typedef std::map source_location_mapt; source_location_mapt source_location_map; - + inline unsigned operator[](goto_programt::const_targett t) { return block_map[t]; } - + void output(std::ostream &out) { for(block_mapt::const_iterator @@ -114,7 +114,7 @@ bool is_condition(const exprt &src) if(src.id()==ID_and || src.id()==ID_or || src.id()==ID_not || src.id()==ID_implies) return false; - + return true; } @@ -141,7 +141,7 @@ void collect_conditions_rec(const exprt &src, std::set &dest) collect_conditions_rec(op, dest); if(is_condition(src) && !src.is_constant()) - dest.insert(src); + dest.insert(src); } /*******************************************************************\ @@ -182,14 +182,14 @@ std::set collect_conditions(const goto_programt::const_targett t) case GOTO: case ASSERT: return collect_conditions(t->guard); - + case ASSIGN: case FUNCTION_CALL: return collect_conditions(t->code); - + default:; } - + return std::set(); } @@ -251,7 +251,7 @@ void collect_mcdc_controlling_rec( for(std::size_t i=0; i o=operands; - + // 'o[i]' needs to be true and false std::vector new_conditions=conditions; new_conditions.push_back(conjunction(o)); @@ -301,7 +301,7 @@ void collect_mcdc_controlling_rec( else others.push_back(operands[j]); } - + exprt c=conjunction(others); std::vector new_conditions=conditions; new_conditions.push_back(c); @@ -355,7 +355,7 @@ std::set collect_mcdc_controlling( const std::set &decisions) { std::set result; - + for(const auto &d : decisions) collect_mcdc_controlling_rec(d, { }, result); @@ -394,7 +394,7 @@ std::set replacement_conjunction( } return result; } - + /*******************************************************************\ Function: collect_mcdc_controlling_nested @@ -403,7 +403,7 @@ Function: collect_mcdc_controlling_nested Outputs: - Purpose: This nested method iteratively applies + Purpose: This nested method iteratively applies ''collect_mcdc_controlling'' to every non-atomic expr within a decision @@ -427,10 +427,10 @@ std::set collect_mcdc_controlling_nested( * temporary expansion. **/ s1.insert(src); - - // dual-loop structure to eliminate complex + + // dual-loop structure to eliminate complex // non-atomic-conditional terms - while(true) + while(true) { bool changed=false; // the 2nd loop @@ -453,7 +453,7 @@ std::set collect_mcdc_controlling_nested( std::set res; /** * To expand an operand if it is not atomic, - * and label the ''changed'' flag; the resulted + * and label the ''changed'' flag; the resulted * expansion of such an operand is stored in ''res''. **/ if(operands[i].id()==ID_not) @@ -495,7 +495,7 @@ std::set collect_mcdc_controlling_nested( // the ''result'' result.insert(s1.begin(), s1.end()); } - + return result; } @@ -517,7 +517,7 @@ std::set sign_of_expr(const exprt &e, const exprt &E) { std::set signs; - // At fist, we pre-screen the case such that ''E'' + // At fist, we pre-screen the case such that ''E'' // is an atomic condition if(is_condition(E)) { @@ -648,7 +648,7 @@ void remove_repetition(std::set &exprs) * expr in ''new_conditions, we label it * and break. **/ - if(iden) + if(iden) { red=true; break; @@ -676,7 +676,7 @@ Function: eval_expr \*******************************************************************/ bool eval_expr( - const std::map &atomic_exprs, + const std::map &atomic_exprs, const exprt &src) { std::vector operands; @@ -725,7 +725,7 @@ bool eval_expr( Function: values_of_atomic_exprs - Inputs: + Inputs: Outputs: @@ -760,14 +760,14 @@ std::map values_of_atomic_exprs( Function: is_mcdc_pair - Inputs: + Inputs: Outputs: Purpose: To check if the two input controlling exprs are mcdc pairs regarding an atomic expr ''c''. A mcdc pair of (e1, e2) regarding ''c'' means that ''e1'' and ''e2'' - result in different ''decision'' values, and this is + result in different ''decision'' values, and this is caused by the different choice of ''c'' value. \*******************************************************************/ @@ -781,8 +781,8 @@ bool is_mcdc_pair( { // An controlling expr cannot be mcdc pair of itself if(e1==e2) return false; - - // To obtain values of each atomic condition within ''e1'' + + // To obtain values of each atomic condition within ''e1'' // and ''e2'' std::map atomic_exprs_e1= values_of_atomic_exprs(e1, conditions); @@ -795,7 +795,7 @@ bool is_mcdc_pair( // a mcdc pair should both contain ''c'', i.e., sign=+1 or -1 if(cs1==0||cs2==0) return false; - + // A mcdc pair regarding an atomic expr ''c'' // should have different values of ''c'' if(cs1==cs2) @@ -832,11 +832,11 @@ bool is_mcdc_pair( Function: has_mcdc_pair - Inputs: + Inputs: Outputs: - Purpose: To check if we can find the mcdc pair of the + Purpose: To check if we can find the mcdc pair of the input ''expr_set'' regarding the atomic expr ''c'' \*******************************************************************/ @@ -896,18 +896,18 @@ void minimize_mcdc_controlling( bool ctrl_update=false; /** * Iteratively, we test that after removing an item ''x'' - * from the ''controlling'', can a complete mcdc coverage + * from the ''controlling'', can a complete mcdc coverage * over ''decision'' still be reserved? * - * If yes, we update ''controlling'' with the - * ''new_controlling'' without ''x''; otherwise, we should + * If yes, we update ''controlling'' with the + * ''new_controlling'' without ''x''; otherwise, we should * keep ''x'' within ''controlling''. * - * If in the end all elements ''x'' in ''controlling'' are - * reserved, this means that current ''controlling'' set is + * If in the end all elements ''x'' in ''controlling'' are + * reserved, this means that current ''controlling'' set is * minimum and the ''while'' loop should be breaked. * - * Note: implementaion here for the above procedure is + * Note: implementaion here for the above procedure is * not (meant to be) optimal. **/ for(auto &x : controlling) @@ -926,7 +926,7 @@ void minimize_mcdc_controlling( has_mcdc_pair(c, new_controlling, conditions, decision); /** * If there is no mcdc pair for an atomic condition ''c'', - * then ''x'' should not be removed from the original + * then ''x'' should not be removed from the original * ''controlling'' set **/ if(!cOK) @@ -936,7 +936,7 @@ void minimize_mcdc_controlling( } } - // If ''removing_x'' is valid, it is safe to remove ''x'' + // If ''removing_x'' is valid, it is safe to remove ''x'' // from the original ''controlling'' if(removing_x) { @@ -984,7 +984,7 @@ void collect_decisions_rec(const exprt &src, std::set &dest) } else { - dest.insert(src); + dest.insert(src); } } else @@ -1032,14 +1032,14 @@ std::set collect_decisions(const goto_programt::const_targett t) case GOTO: case ASSERT: return collect_decisions(t->guard); - + case ASSIGN: case FUNCTION_CALL: return collect_decisions(t->code); - + default:; } - + return std::set(); } @@ -1063,16 +1063,16 @@ void instrument_cover_goals( const namespacet ns(symbol_table); basic_blockst basic_blocks(goto_program); std::set blocks_done; - + // ignore if built-in library if(!goto_program.instructions.empty() && has_prefix(id2string(goto_program.instructions.front().source_location.get_file()), "source_location.set_property_class(property_class); } break; - + case coverage_criteriont::COVER: // turn __CPROVER_cover(x) into 'assert(!x)' if(i_it->is_function_call()) @@ -1111,7 +1111,7 @@ void instrument_cover_goals( else if(i_it->is_assert()) i_it->make_skip(); break; - + case coverage_criteriont::LOCATION: if(i_it->is_assert()) i_it->make_skip(); @@ -1124,7 +1124,7 @@ void instrument_cover_goals( std::string id=id2string(i_it->function)+"#"+b; source_locationt source_location= basic_blocks.source_location_map[block_nr]; - + if(!source_location.get_file().empty() && source_location.get_file()[0]!='<') { @@ -1135,13 +1135,13 @@ void instrument_cover_goals( i_it->source_location.set_comment(comment); i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); - + i_it++; } } } break; - + case coverage_criteriont::BRANCH: if(i_it->is_assert()) i_it->make_skip(); @@ -1162,7 +1162,7 @@ void instrument_cover_goals( t->source_location.set(ID_coverage_criterion, coverage_criterion); t->source_location.set_property_class(property_class); } - + if(i_it->is_goto() && !i_it->guard.is_true()) { std::string b=i2string(basic_blocks[i_it]); @@ -1187,12 +1187,12 @@ void instrument_cover_goals( i_it->source_location.set_comment(false_comment); i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); - + i_it++; i_it++; } break; - + case coverage_criteriont::CONDITION: if(i_it->is_assert()) i_it->make_skip(); @@ -1206,7 +1206,7 @@ void instrument_cover_goals( for(const auto & c : conditions) { const std::string c_string=from_expr(ns, "", c); - + const std::string comment_t="condition `"+c_string+"' true"; goto_program.insert_before_swap(i_it); i_it->make_assertion(c); @@ -1223,12 +1223,12 @@ void instrument_cover_goals( i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); } - + for(std::size_t i=0; iis_assert()) i_it->make_skip(); @@ -1242,7 +1242,7 @@ void instrument_cover_goals( for(const auto & d : decisions) { const std::string d_string=from_expr(ns, "", d); - + const std::string comment_t="decision `"+d_string+"' true"; goto_program.insert_before_swap(i_it); i_it->make_assertion(d); @@ -1259,12 +1259,12 @@ void instrument_cover_goals( i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); } - + for(std::size_t i=0; iis_assert()) i_it->make_skip(); @@ -1277,7 +1277,7 @@ void instrument_cover_goals( { const std::set conditions=collect_conditions(i_it); const std::set decisions=collect_decisions(i_it); - + std::set both; std::set_union(conditions.begin(), conditions.end(), decisions.begin(), decisions.end(), @@ -1289,13 +1289,13 @@ void instrument_cover_goals( { bool is_decision=decisions.find(p)!=decisions.end(); bool is_condition=conditions.find(p)!=conditions.end(); - + std::string description= (is_decision && is_condition)?"decision/condition": is_decision?"decision":"condition"; - + std::string p_string=from_expr(ns, "", p); - + std::string comment_t=description+" `"+p_string+"' true"; goto_program.insert_before_swap(i_it); //i_it->make_assertion(p); @@ -1314,7 +1314,7 @@ void instrument_cover_goals( i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); } - + std::set controlling; //controlling=collect_mcdc_controlling(decisions); controlling=collect_mcdc_controlling_nested(decisions); @@ -1329,7 +1329,7 @@ void instrument_cover_goals( std::string description= "MC/DC independence condition `"+p_string+"'"; - + goto_program.insert_before_swap(i_it); i_it->make_assertion(not_exprt(p)); //i_it->make_assertion(p); @@ -1338,7 +1338,7 @@ void instrument_cover_goals( i_it->source_location.set(ID_coverage_criterion, coverage_criterion); i_it->source_location.set_property_class(property_class); } - + for(std::size_t i=0; iis_assert()) i_it->make_skip(); break; - + default:; } } @@ -1377,7 +1377,7 @@ void instrument_cover_goals( if(f_it->first==ID__start || f_it->first=="__CPROVER_initialize") continue; - + instrument_cover_goals(symbol_table, f_it->second.body, criterion); } } diff --git a/src/goto-instrument/document_properties.cpp b/src/goto-instrument/document_properties.cpp index 0111a231035..77e1df0a2cb 100644 --- a/src/goto-instrument/document_properties.cpp +++ b/src/goto-instrument/document_properties.cpp @@ -27,7 +27,7 @@ class document_propertiest out(_out) { } - + void html() { format=HTML; @@ -43,7 +43,7 @@ class document_propertiest private: const goto_functionst &goto_functions; std::ostream &out; - + struct linet { std::string text; @@ -55,14 +55,14 @@ class document_propertiest void get_code( const source_locationt &source_location, std::string &dest); - + struct doc_claimt { std::set comment_set; }; enum { HTML, LATEX } format; - + void doit(); }; @@ -128,7 +128,7 @@ std::string escape_latex(const std::string &s, bool alltt) if(s[i]=='\\' || s[i]=='{' || s[i]=='}') dest+="\\"; - if(!alltt && + if(!alltt && (s[i]=='_' || s[i]=='$' || s[i]=='~' || s[i]=='^' || s[i]=='%' || s[i]=='#' || s[i]=='&')) @@ -265,7 +265,7 @@ void document_propertiest::get_code( it=lines.erase(it); else break; - } + } for(std::list::iterator it=lines.end(); it!=lines.begin();) @@ -295,27 +295,27 @@ void document_propertiest::get_code( case LATEX: while(line_no.size()<4) line_no=" "+line_no; - + line_no+" "; - + tmp+=escape_latex(it->text, true); if(it->line_number==line_int) tmp="{\\ttb{}"+tmp+"}"; - + break; - + case HTML: while(line_no.size()<4) line_no=" "+line_no; - + line_no+"  "; - + tmp+=escape_html(it->text); if(it->line_number==line_int) tmp=""+tmp+""; - + break; } @@ -395,7 +395,7 @@ void document_propertiest::doit() out << std::endl; out << std::endl; break; - + case HTML: out << "
" << std::endl << "
File " @@ -464,4 +464,3 @@ void document_properties_latex( { document_propertiest(goto_functions, out).latex(); } - diff --git a/src/goto-instrument/dot.cpp b/src/goto-instrument/dot.cpp index d77687345d2..f6a587274fa 100644 --- a/src/goto-instrument/dot.cpp +++ b/src/goto-instrument/dot.cpp @@ -30,9 +30,9 @@ class dott subgraphscount(0) { } - + void output(std::ostream &out); - + protected: const namespacet &ns; const goto_functionst &goto_functions; @@ -43,10 +43,10 @@ class dott std::list clusters; void write_dot_subgraph( - std::ostream &, - const std::string &, + std::ostream &, + const std::string &, const goto_programt &); - + void do_dot_function_calls(std::ostream &); std::string &escape(std::string &str); @@ -88,8 +88,8 @@ void dott::write_dot_subgraph( out << "label=\"" << name << "\";" << std::endl; const goto_programt::instructionst& instructions = - goto_program.instructions; - + goto_program.instructions; + if(instructions.empty()) { out << "Node_" << subgraphscount << "_0 " << @@ -100,15 +100,15 @@ void dott::write_dot_subgraph( std::set seen; goto_programt::const_targetst worklist; worklist.push_back(instructions.begin()); - + while(!worklist.empty()) { goto_programt::const_targett it=worklist.front(); worklist.pop_front(); - + if(it==instructions.end() || seen.find(it)!=seen.end()) continue; - + std::stringstream tmp(""); if(it->is_goto()) { @@ -138,8 +138,8 @@ void dott::write_dot_subgraph( } else if(it->is_skip()) tmp.str("Skip"); - else if(it->is_end_function()) - tmp.str("End of Function"); + else if(it->is_end_function()) + tmp.str("End of Function"); else if(it->is_location()) tmp.str("Location"); else if(it->is_dead()) @@ -154,18 +154,18 @@ void dott::write_dot_subgraph( while (t[ t.size()-1 ]=='\n') t = t.substr(0,t.size()-1); tmp.str(escape(t)); - + exprt fc; std::stringstream ss; ss << "Node_" << subgraphscount << "_" << it->location_number; fc.operands().push_back(exprt(ss.str())); - fc.operands().push_back(it->code.op1()); + fc.operands().push_back(it->code.op1()); function_calls.push_back(fc); } else if(it->is_assign() || it->is_decl() || it->is_return() || - it->is_other()) + it->is_other()) { std::string t = from_expr(ns, "", it->code); while (t[ t.size()-1 ]=='\n') @@ -184,7 +184,7 @@ void dott::write_dot_subgraph( tmp.str("UNKNOWN"); out << "Node_" << subgraphscount << "_" << it->location_number; - out << " [shape="; + out << " [shape="; if(it->is_goto() && !it->guard.is_true() && !it->guard.is_false()) out << "diamond"; else @@ -194,7 +194,7 @@ void dott::write_dot_subgraph( out << "\"];" << std::endl; std::set tres; - std::set fres; + std::set fres; find_next(instructions, it, tres, fres); std::string tlabel="true"; @@ -204,9 +204,9 @@ void dott::write_dot_subgraph( tlabel=""; flabel=""; } - - typedef std::set t; - + + typedef std::set t; + for (t::iterator trit=tres.begin(); trit!=tres.end(); trit++) @@ -215,14 +215,14 @@ void dott::write_dot_subgraph( frit!=fres.end(); frit++) write_edge(out, *it, **frit, flabel); - + seen.insert(it); goto_programt::const_targetst temp; goto_program.get_successors(it, temp); worklist.insert(worklist.end(), temp.begin(), temp.end()); } } - + out << "}" << std::endl; subgraphscount++; } @@ -380,7 +380,7 @@ void dott::find_next( if(it->is_goto() && it->guard.is_true()) return; - + goto_programt::const_targett next = it; next++; if(next!=instructions.end()) fres.insert(next); @@ -437,6 +437,5 @@ void dot( std::ostream &out) { dott dot(src, ns); - dot.output(out); + dot.output(out); } - diff --git a/src/goto-instrument/dump_c.cpp b/src/goto-instrument/dump_c.cpp index 737855b4d54..1d6d7cc712e 100644 --- a/src/goto-instrument/dump_c.cpp +++ b/src/goto-instrument/dump_c.cpp @@ -1514,4 +1514,3 @@ void dump_cpp( dump_ct goto2cpp(src, use_system_headers, ns, new_cpp_language); out << goto2cpp; } - diff --git a/src/goto-instrument/dump_c_class.h b/src/goto-instrument/dump_c_class.h index 59752a7874f..b3681ef3f94 100644 --- a/src/goto-instrument/dump_c_class.h +++ b/src/goto-instrument/dump_c_class.h @@ -131,4 +131,3 @@ class dump_ct std::list &local_static, std::list &local_type_decls); }; - diff --git a/src/goto-instrument/full_slicer.cpp b/src/goto-instrument/full_slicer.cpp index e0741bc24cd..ede5bfb2676 100644 --- a/src/goto-instrument/full_slicer.cpp +++ b/src/goto-instrument/full_slicer.cpp @@ -507,4 +507,3 @@ Function: slicing_criteriont::~slicing_criteriont slicing_criteriont::~slicing_criteriont() { } - diff --git a/src/goto-instrument/function.cpp b/src/goto-instrument/function.cpp index 3daa926d10a..e7a08a5c1c2 100644 --- a/src/goto-instrument/function.cpp +++ b/src/goto-instrument/function.cpp @@ -34,16 +34,16 @@ code_function_callt function_to_call( const irep_idt &argument) { // already there? - + symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(id); - + if(s_it==symbol_table.symbols.end()) { // not there pointer_typet p(char_type()); p.subtype().set(ID_C_constant, true); - + code_typet function_type; function_type.return_type()=empty_typet(); function_type.parameters().push_back( @@ -53,7 +53,7 @@ code_function_callt function_to_call( new_symbol.name=id; new_symbol.base_name=id; new_symbol.type=function_type; - + symbol_table.move(new_symbol); s_it=symbol_table.symbols.find(id); @@ -69,7 +69,7 @@ code_function_callt function_to_call( std::string error="function `"+id2string(id)+"' has wrong signature"; throw error; } - + string_constantt function_id_string(argument); code_function_callt call; @@ -108,15 +108,15 @@ void function_enter( // don't instrument our internal functions if(has_prefix(id2string(f_it->first), CPROVER_PREFIX)) continue; - + // don't instrument the function to be called, // or otherwise this will be recursive if(f_it->first==id) continue; - + // patch in a call to `id' at the entry point goto_programt &body=f_it->second.body; - + goto_programt::targett t= body.insert_before(body.instructions.begin()); t->make_function_call( @@ -147,15 +147,15 @@ void function_exit( // don't instrument our internal functions if(has_prefix(id2string(f_it->first), CPROVER_PREFIX)) continue; - + // don't instrument the function to be called, // or otherwise this will be recursive if(f_it->first==id) continue; - + // patch in a call to `id' at the exit points goto_programt &body=f_it->second.body; - + // make sure we have END_OF_FUNCTION if(body.instructions.empty() || !body.instructions.back().is_end_function()) @@ -173,9 +173,9 @@ void function_exit( // move on i_it++; - } + } } - + // exiting without return goto_programt::targett last=body.instructions.end(); last--; @@ -183,7 +183,7 @@ void function_exit( // is there already a return? bool has_return=false; - + if(last!=body.instructions.begin()) { goto_programt::targett before_last=last; @@ -191,7 +191,7 @@ void function_exit( if(before_last->is_return()) has_return=true; } - + if(!has_return) { goto_programt::instructiont call; @@ -202,4 +202,3 @@ void function_exit( } } } - diff --git a/src/goto-instrument/function_modifies.cpp b/src/goto-instrument/function_modifies.cpp index 85f6093fb63..f050fa9ece4 100644 --- a/src/goto-instrument/function_modifies.cpp +++ b/src/goto-instrument/function_modifies.cpp @@ -79,11 +79,11 @@ void function_modifiest::get_modifies( const code_function_callt &code_function_call= to_code_function_call(instruction.code); const exprt &lhs=code_function_call.lhs(); - + // return value assignment if(lhs.is_not_nil()) get_modifies_lhs(local_may_alias, i_it, lhs, modifies); - + get_modifies_function( code_function_call.function(), modifies); } @@ -108,7 +108,7 @@ void function_modifiest::get_modifies_function( if(function.id()==ID_symbol) { const irep_idt &identifier=to_symbol_expr(function).get_identifier(); - + function_mapt::const_iterator fm_it= function_map.find(identifier); @@ -118,17 +118,17 @@ void function_modifiest::get_modifies_function( modifies.insert(fm_it->second.begin(), fm_it->second.end()); return; } - + goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.find(identifier); - + if(f_it==goto_functions.function_map.end()) return; - + local_may_aliast local_may_alias(f_it->second); - + const goto_programt &goto_program=f_it->second.body; - + forall_goto_program_instructions(i_it, goto_program) get_modifies(local_may_alias, i_it, modifies); } diff --git a/src/goto-instrument/function_modifies.h b/src/goto-instrument/function_modifies.h index d2b9912eaa6..95e17109856 100644 --- a/src/goto-instrument/function_modifies.h +++ b/src/goto-instrument/function_modifies.h @@ -32,11 +32,11 @@ class function_modifiest const goto_programt::const_targett, const exprt &lhs, modifiest &); - + void get_modifies_function( const exprt &, - modifiest &); - + modifiest &); + inline void operator()(const exprt &function, modifiest &modifies) { get_modifies_function(function, modifies); diff --git a/src/goto-instrument/goto_instrument_languages.cpp b/src/goto-instrument/goto_instrument_languages.cpp index 114a51722db..4cc03bca860 100644 --- a/src/goto-instrument/goto_instrument_languages.cpp +++ b/src/goto-instrument/goto_instrument_languages.cpp @@ -32,4 +32,3 @@ void goto_instrument_parse_optionst::register_languages() register_language(new_cpp_language); register_language(new_java_bytecode_language); } - diff --git a/src/goto-instrument/goto_instrument_main.cpp b/src/goto-instrument/goto_instrument_main.cpp index 28d9954040f..f25cbbcf9d8 100644 --- a/src/goto-instrument/goto_instrument_main.cpp +++ b/src/goto-instrument/goto_instrument_main.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: Main Module +Module: Main Module Author: Daniel Kroening, kroening@kroening.com diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 6eee2e3d58f..8fd60ad0fb3 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: Main Module +Module: Main Module Author: Daniel Kroening, kroening@kroening.com @@ -102,13 +102,13 @@ Function: goto_instrument_parse_optionst::eval_verbosity void goto_instrument_parse_optionst::eval_verbosity() { unsigned int v=8; - + if(cmdline.isset("verbosity")) { v=unsafe_string2unsigned(cmdline.get_value("verbosity")); if(v>10) v=10; } - + ui_message_handler.set_verbosity(v); } @@ -131,13 +131,13 @@ int goto_instrument_parse_optionst::doit() std::cout << CBMC_VERSION << std::endl; return 0; } - + if(cmdline.args.size()!=1 && cmdline.args.size()!=2) { help(); return 0; } - + eval_verbosity(); try @@ -162,7 +162,7 @@ int goto_instrument_parse_optionst::doit() { do_function_pointer_removal(); do_partial_inlining(); - + // recalculate numbers, etc. goto_functions.update(); @@ -184,7 +184,7 @@ int goto_instrument_parse_optionst::doit() // recalculate numbers, etc. goto_functions.update(); - + namespacet ns(symbol_table); global_may_alias_analysist global_may_alias_analysis; global_may_alias_analysis(goto_functions, ns); @@ -198,7 +198,7 @@ int goto_instrument_parse_optionst::doit() do_function_pointer_removal(); do_partial_inlining(); parameter_assignments(symbol_table, goto_functions); - + // recalculate numbers, etc. goto_functions.update(); @@ -216,16 +216,16 @@ int goto_instrument_parse_optionst::doit() return 0; } - + if(cmdline.isset("show-custom-bitvector-analysis")) { do_function_pointer_removal(); do_partial_inlining(); do_remove_returns(); parameter_assignments(symbol_table, goto_functions); - + remove_unused_functions(goto_functions, get_message_handler()); - + if(!cmdline.isset("inline")) { thread_exit_instrumentation(goto_functions); @@ -234,7 +234,7 @@ int goto_instrument_parse_optionst::doit() // recalculate numbers, etc. goto_functions.update(); - + namespacet ns(symbol_table); custom_bitvector_analysist custom_bitvector_analysis; custom_bitvector_analysis(goto_functions, ns); @@ -271,7 +271,7 @@ int goto_instrument_parse_optionst::doit() parameter_assignments(symbol_table, goto_functions); remove_unused_functions(goto_functions, get_message_handler()); - + if(!cmdline.isset("inline")) { thread_exit_instrumentation(goto_functions); @@ -306,7 +306,7 @@ int goto_instrument_parse_optionst::doit() points_to.output(std::cout); return 0; } - + if(cmdline.isset("show-intervals")) { do_function_pointer_removal(); @@ -319,11 +319,11 @@ int goto_instrument_parse_optionst::doit() namespacet ns(symbol_table); ait interval_analysis; interval_analysis(goto_functions, ns); - + interval_analysis.output(ns, goto_functions, std::cout); return 0; } - + if(cmdline.isset("show-call-sequences")) { show_call_sequences(goto_functions); @@ -349,14 +349,14 @@ int goto_instrument_parse_optionst::doit() // recalculate numbers, etc. goto_functions.update(); } - + status() << "Pointer Analysis" << eom; value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); - + const symbolt &symbol=ns.lookup(ID_main); symbol_exprt main(symbol.name, symbol.type); - + std::cout << rw_set_functiont(value_set_analysis, ns, goto_functions, main); return 0; } @@ -521,7 +521,7 @@ int goto_instrument_parse_optionst::doit() // restore RETURN instructions in case remove_returns had been // applied restore_returns(symbol_table, goto_functions); - + if(cmdline.args.size()==2) { #ifdef _MSC_VER @@ -538,14 +538,14 @@ int goto_instrument_parse_optionst::doit() } else (is_cpp ? dump_cpp : dump_c)(goto_functions, h, ns, std::cout); - + return 0; } - + if(cmdline.isset("call-graph")) { call_grapht call_graph(goto_functions); - + if(cmdline.isset("xml")) call_graph.output_xml(std::cout); else if(cmdline.isset("dot")) @@ -555,11 +555,11 @@ int goto_instrument_parse_optionst::doit() return 0; } - + if(cmdline.isset("dot")) { namespacet ns(symbol_table); - + if(cmdline.args.size()==2) { #ifdef _MSC_VER @@ -577,14 +577,14 @@ int goto_instrument_parse_optionst::doit() } else dot(goto_functions, ns, std::cout); - + return 0; } if(cmdline.isset("accelerate")) { do_function_pointer_removal(); - + namespacet ns(symbol_table); status() << "Performing full inlining" << eom; @@ -595,12 +595,12 @@ int goto_instrument_parse_optionst::doit() remove_skip(goto_functions); goto_functions.update(); } - + if(cmdline.isset("horn-encoding")) { status() << "Horn-clause encoding" << eom; namespacet ns(symbol_table); - + if(cmdline.args.size()==2) { #ifdef _MSC_VER @@ -608,27 +608,27 @@ int goto_instrument_parse_optionst::doit() #else std::ofstream out(cmdline.args[1]); #endif - + if(!out) { error() << "Failed to open output file " << cmdline.args[1] << eom; return 1; } - + horn_encoding(goto_functions, ns, out); } else horn_encoding(goto_functions, ns, std::cout); - + return 0; } - + // write new binary? if(cmdline.args.size()==2) { status() << "Writing GOTO program to `" << cmdline.args[1] << "'" << eom; - + if(write_goto_binary( cmdline.args[1], symbol_table, goto_functions, get_message_handler())) return 1; @@ -651,12 +651,12 @@ int goto_instrument_parse_optionst::doit() error() << e << eom; return 11; } - + catch(int) { return 11; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; @@ -675,7 +675,7 @@ Function: goto_instrument_parse_optionst::do_function_pointer_removal Purpose: \*******************************************************************/ - + void goto_instrument_parse_optionst::do_function_pointer_removal() { if(function_pointer_removal_done) return; @@ -696,7 +696,7 @@ Function: goto_instrument_parse_optionst::do_partial_inlining Purpose: \*******************************************************************/ - + void goto_instrument_parse_optionst::do_partial_inlining() { if(partial_inlining_done) return; @@ -721,7 +721,7 @@ Function: goto_instrument_parse_optionst::do_remove_returns Purpose: \*******************************************************************/ - + void goto_instrument_parse_optionst::do_remove_returns() { if(remove_returns_done) return; @@ -742,7 +742,7 @@ Function: goto_instrument_parse_optionst::get_goto_program Purpose: \*******************************************************************/ - + void goto_instrument_parse_optionst::get_goto_program() { status() << "Reading GOTO program from `" << cmdline.args[0] << "'" << eom; @@ -766,7 +766,7 @@ Function: goto_instrument_parse_optionst::instrument_goto_program Purpose: \*******************************************************************/ - + void goto_instrument_parse_optionst::instrument_goto_program() { optionst options; @@ -853,7 +853,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() if(cmdline.isset("error-label")) options.set_option("error-label", cmdline.get_value("error-label")); - // unwind loops + // unwind loops if(cmdline.isset("unwind")) { status() << "Unwinding loops" << eom; @@ -879,7 +879,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() if(cmdline.isset("show-custom-bitvector-analysis") || cmdline.isset("custom-bitvector-analysis")) config.ansi_c.defines.push_back("__CPROVER_CUSTOM_BITVECTOR_ANALYSIS"); - + status() << "Adding CPROVER library" << eom; link_to_library(symbol_table, goto_functions, ui_message_handler); } @@ -921,7 +921,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() // recalculate numbers, etc. goto_functions.update(); } - + // verify and set invariants and pre/post-condition pairs if(cmdline.isset("apply-code-contracts")) { @@ -957,20 +957,20 @@ void goto_instrument_parse_optionst::instrument_goto_program() status() << "Propagating Constants" << eom; constant_propagator_ait constant_propagator_ai(goto_functions, ns); - + remove_skip(goto_functions); } // add generic checks, if needed goto_check(ns, options, goto_functions); - + // check for uninitalized local varibles if(cmdline.isset("uninitialized-check")) { status() << "Adding checks for uninitialized local variables" << eom; add_uninitialized_locals_assertions(symbol_table, goto_functions); } - + // check for maximum call stack size if(cmdline.isset("stack-depth")) { @@ -993,7 +993,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() string_abstraction(symbol_table, get_message_handler(), goto_functions); } - + // some analyses require function pointer removal and partial inlining if(cmdline.isset("remove-pointers") || @@ -1011,7 +1011,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() status() << "Partial Inlining" << eom; goto_partial_inline(goto_functions, ns, ui_message_handler); } - + status() << "Pointer Analysis" << eom; value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); @@ -1036,7 +1036,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() if(cmdline.isset("mm")) { // TODO: move to wmm/weak_mem, and copy goto_functions AFTER some of the - // modifications. Do the analysis on the copy, after remove_asm, and + // modifications. Do the analysis on the copy, after remove_asm, and // instrument the original (without remove_asm) remove_asm(symbol_table, goto_functions); goto_functions.update(); @@ -1059,8 +1059,8 @@ void goto_instrument_parse_optionst::instrument_goto_program() else /* default: instruments all unsafe pairs */ inst_strategy=all; - - const unsigned unwind_loops = + + const unsigned unwind_loops = ( cmdline.isset("unwind")?unsafe_string2unsigned(cmdline.get_value("unwind")):0 ); const unsigned max_var = ( cmdline.isset("max-var")?unsafe_string2unsigned(cmdline.get_value("max-var")):0 ); @@ -1152,7 +1152,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() symbol_table, goto_functions); } - } + } if(cmdline.isset("interval-analysis")) { @@ -1177,13 +1177,13 @@ void goto_instrument_parse_optionst::instrument_goto_program() throw "please specify one of --step-case and --base-case"; unsigned k=unsafe_string2unsigned(cmdline.get_value("k-induction")); - + if(k==0) throw "please give k>=1"; status() << "Instrumenting k-induction for k=" << k << ", " << (base_case?"base case":"step case") << eom; - + k_induction(goto_functions, base_case, step_case, k); } @@ -1216,13 +1216,13 @@ void goto_instrument_parse_optionst::instrument_goto_program() // add failed symbols add_failed_symbols(symbol_table); - + // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); - + // label the assertions label_properties(goto_functions); @@ -1253,7 +1253,7 @@ void goto_instrument_parse_optionst::instrument_goto_program() else full_slicer(goto_functions, ns); } - + // label the assertions label_properties(goto_functions); diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index fdfce8b1a46..1123a1ec6e9 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -80,24 +80,24 @@ class goto_instrument_parse_optionst: remove_returns_done(false) { } - + protected: ui_message_handlert ui_message_handler; virtual void register_languages(); void get_goto_program(); void instrument_goto_program(); - + void eval_verbosity(); - + void do_function_pointer_removal(); void do_partial_inlining(); void do_remove_returns(); - + bool function_pointer_removal_done; bool partial_inlining_done; bool remove_returns_done; - + goto_functionst goto_functions; }; diff --git a/src/goto-instrument/goto_program2code.cpp b/src/goto-instrument/goto_program2code.cpp index 1206d437bcb..edcc18a3792 100644 --- a/src/goto-instrument/goto_program2code.cpp +++ b/src/goto-instrument/goto_program2code.cpp @@ -1114,7 +1114,7 @@ goto_programt::const_targett goto_program2codet::convert_goto_switch( const cfg_dominatorst &dominators=loops.get_dominator_info(); // always use convert_goto_if for dead code as the construction below relies - // on effective dominator information + // on effective dominator information cfg_dominatorst::cfgt::entry_mapt::const_iterator t_entry= dominators.cfg.entry_map.find(target); assert(t_entry!=dominators.cfg.entry_map.end()); @@ -2225,7 +2225,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) cleanup_expr(*it, no_typecast); } - // work around transparent union argument + // work around transparent union argument if(expr.id()==ID_union && ns.follow(expr.type()).id()!=ID_union) { @@ -2269,9 +2269,9 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) { // Replace by a function call to nondet_... // We first search for a suitable one in the symbol table. - + irep_idt id=""; - + for(symbol_tablet::symbolst::const_iterator it=symbol_table.symbols.begin(); it!=symbol_table.symbols.end(); @@ -2285,13 +2285,13 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) id=it->second.name; break; } - + // none found? make one - + if(id=="") { irep_idt base_name=""; - + if(expr.type().get(ID_C_c_type)!="") { irep_idt suffix; @@ -2301,7 +2301,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) symbol_table.symbols.end()) base_name="nondet_"+id2string(suffix); } - + if(base_name=="") { unsigned count; @@ -2311,29 +2311,29 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) count++); base_name="nondet_"+i2string(count); } - + code_typet code_type; code_type.return_type()=expr.type(); - + symbolt symbol; symbol.base_name=base_name; symbol.name=base_name; symbol.type=code_type; id=symbol.name; - + symbol_table.move(symbol); } - + const symbolt &symbol=ns.lookup(id); - + symbol_exprt symbol_expr(symbol.name, symbol.type); symbol_expr.add_source_location()=expr.source_location(); - + side_effect_expr_function_callt call; call.add_source_location()=expr.source_location(); call.function()=symbol_expr; call.type()=expr.type(); - + expr.swap(call); } } @@ -2400,4 +2400,3 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) } } } - diff --git a/src/goto-instrument/goto_program2code.h b/src/goto-instrument/goto_program2code.h index f252fdca152..e852a1598ce 100644 --- a/src/goto-instrument/goto_program2code.h +++ b/src/goto-instrument/goto_program2code.h @@ -209,4 +209,3 @@ class goto_program2codet goto_programt::const_targett upper_bound, codet &dest); }; - diff --git a/src/goto-instrument/havoc_loops.cpp b/src/goto-instrument/havoc_loops.cpp index 71cff064da2..600cfa3c977 100644 --- a/src/goto-instrument/havoc_loops.cpp +++ b/src/goto-instrument/havoc_loops.cpp @@ -20,7 +20,7 @@ class havoc_loopst { public: typedef goto_functionst::goto_functiont goto_functiont; - + havoc_loopst( function_modifiest &_function_modifies, goto_functiont &_goto_function): @@ -31,13 +31,13 @@ class havoc_loopst { havoc_loops(); } - + protected: goto_functiont &goto_function; local_may_aliast local_may_alias; function_modifiest &function_modifies; natural_loops_mutablet natural_loops; - + typedef std::set modifiest; typedef const natural_loops_mutablet::natural_loopt loopt; @@ -51,7 +51,7 @@ class havoc_loopst const goto_programt::targett loop_head, const modifiest &modifies, goto_programt &dest); - + void get_modifies( const loopt &, modifiest &); @@ -77,7 +77,7 @@ goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) // find the last instruction in the loop std::map loop_map; - + for(loopt::const_iterator l_it=loop.begin(); l_it!=loop.end(); l_it++) @@ -85,7 +85,7 @@ goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) // get the one with the highest number goto_programt::targett last=(--loop_map.end())->second; - + return ++last; } @@ -113,7 +113,7 @@ void havoc_loopst::build_havoc_code( { exprt lhs=*m_it; exprt rhs=side_effect_expr_nondett(lhs.type()); - + goto_programt::targett t=dest.add_instruction(ASSIGN); t->function=loop_head->function; t->source_location=loop_head->source_location; @@ -140,18 +140,18 @@ void havoc_loopst::havoc_loop( { assert(!loop.empty()); - // first find out what can get changed in the loop + // first find out what can get changed in the loop modifiest modifies; get_modifies(loop, modifies); - + // build the havoc-ing code goto_programt havoc_code; build_havoc_code(loop_head, modifies, havoc_code); - + // Now havoc at the loop head. Use insert_swap to // preserve jumps to loop head. goto_function.body.insert_before_swap(loop_head, havoc_code); - + // compute the loop exit goto_programt::targett loop_exit= get_loop_exit(loop); @@ -209,11 +209,11 @@ void havoc_loopst::get_modifies( const code_function_callt &code_function_call= to_code_function_call(instruction.code); const exprt &lhs=code_function_call.lhs(); - + // return value assignment if(lhs.is_not_nil()) function_modifies.get_modifies_lhs(local_may_alias, *i_it, lhs, modifies); - + function_modifies(code_function_call.function(), modifies); } } @@ -234,7 +234,7 @@ Function: havoc_loopst::havoc_loops void havoc_loopst::havoc_loops() { // iterate over the (natural) loops in the function - + for(natural_loops_mutablet::loop_mapt::const_iterator l_it=natural_loops.loop_map.begin(); l_it!=natural_loops.loop_map.end(); diff --git a/src/goto-instrument/interrupt.cpp b/src/goto-instrument/interrupt.cpp index 0d9e35032ed..7517f83867e 100644 --- a/src/goto-instrument/interrupt.cpp +++ b/src/goto-instrument/interrupt.cpp @@ -45,7 +45,7 @@ bool potential_race_on_read( if(isr_rw_set.has_w_entry(e_it->first)) return true; } - + return false; } @@ -74,7 +74,7 @@ bool potential_race_on_write( if(isr_rw_set.has_w_entry(e_it->first)) return true; } - + return false; } @@ -101,7 +101,7 @@ void interrupt( const rw_set_baset &isr_rw_set) { namespacet ns(symbol_table); - + Forall_goto_program_instructions(i_it, goto_program) { goto_programt::instructiont &instruction=*i_it; @@ -118,27 +118,27 @@ void interrupt( // potential race? bool race_on_read=potential_race_on_read(rw_set, isr_rw_set); bool race_on_write=potential_race_on_write(rw_set, isr_rw_set); - + if(!race_on_read && !race_on_write) continue; - + // Insert the call to the ISR. // We do before for races on Read, and before and after // for races on Write. if(race_on_read || race_on_write) - { + { goto_programt::instructiont original_instruction; original_instruction.swap(instruction); const source_locationt &source_location= original_instruction.source_location; - + code_function_callt isr_call; isr_call.add_source_location()=source_location; isr_call.function()=interrupt_handler; - - goto_programt::targett t_goto=i_it; + + goto_programt::targett t_goto=i_it; goto_programt::targett t_call=goto_program.insert_after(t_goto); goto_programt::targett t_orig=goto_program.insert_after(t_call); @@ -152,25 +152,25 @@ void interrupt( t_call->function=original_instruction.function; t_orig->swap(original_instruction); - + i_it=t_orig; // the for loop already counts us up } - + if(race_on_write) { // insert _after_ the instruction with race goto_programt::targett t_orig=i_it; t_orig++; - + goto_programt::targett t_goto=goto_program.insert_after(i_it); goto_programt::targett t_call=goto_program.insert_after(t_goto); - + const source_locationt &source_location=i_it->source_location; - + code_function_callt isr_call; isr_call.add_source_location()=source_location; isr_call.function()=interrupt_handler; - + t_goto->make_goto(t_orig); t_goto->source_location=source_location; t_goto->guard=side_effect_expr_nondett(bool_typet()); @@ -180,7 +180,7 @@ void interrupt( t_call->source_location=source_location; t_call->function=i_it->function; - i_it=t_call; // the for loop already counts us up + i_it=t_call; // the for loop already counts us up } } } @@ -208,13 +208,13 @@ symbol_exprt get_isr( // look it up symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(m_it->second); - + if(s_it==symbol_table.symbols.end()) continue; - + if(s_it->second.type.id()==ID_code) matches.push_back(s_it->second.symbol_expr()); } - + if(matches.empty()) throw "interrupt handler `"+id2string(interrupt_handler)+"' not found"; @@ -222,7 +222,7 @@ symbol_exprt get_isr( throw "interrupt handler `"+id2string(interrupt_handler)+"' is ambiguous"; symbol_exprt isr=matches.front(); - + if(!to_code_type(isr.type()).parameters().empty()) throw "interrupt handler `"+id2string(interrupt_handler)+ "' must not have parameters"; @@ -263,7 +263,7 @@ void interrupt( f_it->first!=goto_functionst::entry_point() && f_it->first!=isr.get_identifier()) interrupt( - value_sets, symbol_table, + value_sets, symbol_table, #ifdef LOCAL_MAY f_it->second, #endif @@ -271,4 +271,3 @@ void interrupt( goto_functions.update(); } - diff --git a/src/goto-instrument/interrupt.h b/src/goto-instrument/interrupt.h index 99039f1baff..a5a81670064 100644 --- a/src/goto-instrument/interrupt.h +++ b/src/goto-instrument/interrupt.h @@ -15,7 +15,7 @@ class symbol_tablet; class goto_functionst; #include "rw_set.h" - + void interrupt( value_setst &value_sets, const class symbol_tablet &symbol_table, diff --git a/src/goto-instrument/k_induction.cpp b/src/goto-instrument/k_induction.cpp index e67067d5178..a2f7d7d0d7c 100644 --- a/src/goto-instrument/k_induction.cpp +++ b/src/goto-instrument/k_induction.cpp @@ -21,7 +21,7 @@ class k_inductiont { public: typedef goto_functionst::goto_functiont goto_functiont; - + k_inductiont( goto_functiont &_goto_function, bool _base_case, bool _step_case, @@ -38,7 +38,7 @@ class k_inductiont goto_functiont &goto_function; local_may_aliast local_may_alias; natural_loops_mutablet natural_loops; - + const bool base_case, step_case; const unsigned k; @@ -89,25 +89,25 @@ void k_inductiont::process_loop( { // step case - // find out what can get changed in the loop + // find out what can get changed in the loop modifiest modifies; get_modifies(local_may_alias, loop, modifies); - + // build the havoc-ing code goto_programt havoc_code; build_havoc_code(loop_head, modifies, havoc_code); - + // unwind to get k+1 copies std::vector iteration_points; unwind(goto_function.body, loop_head, loop_exit, k+1, iteration_points); - + // we can remove everything up to the first assertion for(goto_programt::targett t=loop_head; t!=loop_exit; t++) { if(t->is_assert()) break; t->make_skip(); } - + // now turn any assertions in iterations 0..k-1 into assumptions assert(iteration_points.size()==k+1); @@ -127,7 +127,7 @@ void k_inductiont::process_loop( // Now havoc at the loop head. Use insert_swap to // preserve jumps to loop head. - goto_function.body.insert_before_swap(loop_head, havoc_code); + goto_function.body.insert_before_swap(loop_head, havoc_code); } // remove skips @@ -149,7 +149,7 @@ Function: k_inductiont::k_induction void k_inductiont::k_induction() { // iterate over the (natural) loops in the function - + for(natural_loops_mutablet::loop_mapt::const_iterator l_it=natural_loops.loop_map.begin(); l_it!=natural_loops.loop_map.end(); diff --git a/src/goto-instrument/loop_utils.cpp b/src/goto-instrument/loop_utils.cpp index 7a8b701eedf..90981198321 100644 --- a/src/goto-instrument/loop_utils.cpp +++ b/src/goto-instrument/loop_utils.cpp @@ -152,4 +152,3 @@ void get_modifies( } } } - diff --git a/src/goto-instrument/mmio.cpp b/src/goto-instrument/mmio.cpp index ecae3333203..78ab7648cd2 100644 --- a/src/goto-instrument/mmio.cpp +++ b/src/goto-instrument/mmio.cpp @@ -59,7 +59,7 @@ void mmio( Forall_goto_program_instructions(i_it, goto_program) { goto_programt::instructiont &instruction=*i_it; - + if(instruction.is_assign()) { rw_set_loct rw_set(ns, value_sets, i_it @@ -67,18 +67,18 @@ void mmio( , local_may #endif ); - + if(rw_set.empty()) continue; - - #if 0 + + #if 0 goto_programt::instructiont original_instruction; original_instruction.swap(instruction); const locationt &location=original_instruction.location; - + instruction.make_atomic_begin(); instruction.location=location; i_it++; - + // we first perform (non-deterministically) up to 2 writes for // stuff that is potentially read forall_rw_set_entries(e_it, rw_set) @@ -87,34 +87,34 @@ void mmio( const shared_bufferst::varst &vars=shared_buffers(e_it->second.object); irep_idt choice0=shared_buffers.choice("0"); irep_idt choice1=shared_buffers.choice("1"); - + symbol_exprt choice0_expr=symbol_exprt(choice0, bool_typet()); symbol_exprt choice1_expr=symbol_exprt(choice1, bool_typet()); - + symbol_exprt w_buff0_expr=symbol_exprt(vars.w_buff0, vars.type); symbol_exprt w_buff1_expr=symbol_exprt(vars.w_buff1, vars.type); - + symbol_exprt w_used0_expr=symbol_exprt(vars.w_used0, bool_typet()); symbol_exprt w_used1_expr=symbol_exprt(vars.w_used1, bool_typet()); - + exprt nondet_bool_expr=side_effect_nondet_exprt(bool_typet()); - + exprt choice0_rhs=and_exprt(nondet_bool_expr, w_used0_expr); exprt choice1_rhs=and_exprt(nondet_bool_expr, w_used1_expr); - + // throw 2 Boolean dice shared_buffers.assignment(goto_program, i_it, location, choice0, choice0_rhs); shared_buffers.assignment(goto_program, i_it, location, choice1, choice1_rhs); - + exprt lhs=symbol_exprt(e_it->second.object, vars.type); - + exprt value= if_exprt(choice0_expr, w_buff0_expr, if_exprt(choice1_expr, w_buff1_expr, lhs)); // write one of the buffer entries shared_buffers.assignment(goto_program, i_it, location, e_it->second.object, value); - + // update 'used' flags exprt w_used0_rhs=if_exprt(choice0_expr, false_exprt(), w_used0_expr); exprt w_used1_rhs=and_exprt(if_exprt(choice1_expr, false_exprt(), w_used1_expr), w_used0_expr); @@ -128,7 +128,7 @@ void mmio( if(e_it->second.w) { const shared_bufferst::varst &vars=shared_buffers(e_it->second.object); - + // w_used1=w_used0; w_used0=true; shared_buffers.assignment(goto_program, i_it, location, vars.w_used1, vars.w_used0); shared_buffers.assignment(goto_program, i_it, location, vars.w_used0, true_exprt()); @@ -143,7 +143,7 @@ void mmio( i_it->make_atomic_end(); i_it->location=location; i_it++; - + i_it--; // the for loop already counts us up #endif } @@ -176,7 +176,7 @@ void mmio( Forall_goto_functions(f_it, goto_functions) if(f_it->first!=CPROVER_PREFIX "initialize" && f_it->first!=goto_functionst::entry_point()) - mmio(value_sets, symbol_table, + mmio(value_sets, symbol_table, #ifdef LOCAL_MAY f_it->second, #endif @@ -184,4 +184,3 @@ void mmio( goto_functions.update(); } - diff --git a/src/goto-instrument/nondet_static.cpp b/src/goto-instrument/nondet_static.cpp index 71455374d27..90eb8ab3c08 100644 --- a/src/goto-instrument/nondet_static.cpp +++ b/src/goto-instrument/nondet_static.cpp @@ -53,7 +53,7 @@ void nondet_static( // is it a __CPROVER_* variable? if(has_prefix(id2string(sym.get_identifier()), CPROVER_PREFIX)) continue; - + // static lifetime? if(!ns.lookup(sym.get_identifier()).is_static_lifetime) continue; @@ -101,4 +101,3 @@ void nondet_static( // update counters etc. goto_functions.update(); } - diff --git a/src/goto-instrument/nondet_volatile.cpp b/src/goto-instrument/nondet_volatile.cpp index 1cada06c1fe..9a7d6574a14 100644 --- a/src/goto-instrument/nondet_volatile.cpp +++ b/src/goto-instrument/nondet_volatile.cpp @@ -38,7 +38,7 @@ bool is_volatile( assert(s_it!=symbol_table.symbols.end()); return is_volatile(symbol_table, s_it->second.type); } - + return false; } @@ -58,7 +58,7 @@ void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) { Forall_operands(it, expr) nondet_volatile_rhs(symbol_table, *it); - + if(expr.id()==ID_symbol || expr.id()==ID_dereference) { @@ -66,7 +66,7 @@ void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) { typet t=expr.type(); t.remove(ID_C_volatile); - + // replace by nondet side_effect_expr_nondett nondet_expr(t); expr.swap(nondet_expr); @@ -130,7 +130,7 @@ void nondet_volatile( Forall_goto_program_instructions(i_it, goto_program) { goto_programt::instructiont &instruction=*i_it; - + if(instruction.is_assign()) { nondet_volatile_rhs(symbol_table, to_code_assign(instruction.code).rhs()); @@ -139,7 +139,7 @@ void nondet_volatile( else if(instruction.is_function_call()) { // these have arguments and a return LHS - + code_function_callt &code_function_call= to_code_function_call(instruction.code); @@ -149,7 +149,7 @@ void nondet_volatile( it!=code_function_call.arguments().end(); it++) nondet_volatile_rhs(symbol_table, *it); - + // do return value nondet_volatile_lhs(symbol_table, code_function_call.lhs()); } diff --git a/src/goto-instrument/object_id.cpp b/src/goto-instrument/object_id.cpp index e39a517a57b..f8fa7de4ca0 100644 --- a/src/goto-instrument/object_id.cpp +++ b/src/goto-instrument/object_id.cpp @@ -43,7 +43,7 @@ void get_objects_rec( if(mode==LHS_R) get_objects_rec(READ, index_expr.array(), dest, "[]"+suffix); else - get_objects_rec(mode, index_expr.array(), dest, "[]"+suffix); + get_objects_rec(mode, index_expr.array(), dest, "[]"+suffix); } else if(expr.id()==ID_if) { @@ -66,7 +66,7 @@ void get_objects_rec( { const dereference_exprt &dereference_expr= to_dereference_expr(expr); - + if(mode==LHS_R || mode==READ) get_objects_rec(READ, dereference_expr.pointer(), dest, ""); } @@ -163,4 +163,3 @@ void get_objects_r_lhs(const exprt &lhs, object_id_sett &dest) { get_objects_rec(LHS_R, lhs, dest, ""); } - diff --git a/src/goto-instrument/object_id.h b/src/goto-instrument/object_id.h index 881c33178ee..a83baf84e79 100644 --- a/src/goto-instrument/object_id.h +++ b/src/goto-instrument/object_id.h @@ -24,12 +24,12 @@ class object_idt { id=symbol_expr.get_identifier(); } - + explicit object_idt(const irep_idt &identifier) { id=identifier; } - + friend std::ostream &operator << (std::ostream &out, const object_idt &x) { return out << x.id; @@ -39,7 +39,7 @@ class object_idt { return a.id < b.id; } - + protected: irep_idt id; }; diff --git a/src/goto-instrument/points_to.cpp b/src/goto-instrument/points_to.cpp index 4cc9941cae7..aef33d57ed0 100644 --- a/src/goto-instrument/points_to.cpp +++ b/src/goto-instrument/points_to.cpp @@ -29,7 +29,7 @@ void points_tot::fixedpoint() do { added=false; - + for(cfgt::entry_mapt::iterator e_it=cfg.entry_map.begin(); e_it!=cfg.entry_map.end(); @@ -70,7 +70,7 @@ void points_tot::output(std::ostream &out) const { out << " " << *o_it; } - + out << std::endl; } } @@ -97,20 +97,20 @@ bool points_tot::transform(const cfgt::nodet &e) case RETURN: // TODO break; - + case ASSIGN: { // const code_assignt &code_assign=to_code_assign(instruction.code); - - } + + } break; - + case FUNCTION_CALL: // these are like assignments for the arguments break; - + default:; } - + return result; } diff --git a/src/goto-instrument/points_to.h b/src/goto-instrument/points_to.h index 39ecbcfc987..b8995645162 100644 --- a/src/goto-instrument/points_to.h +++ b/src/goto-instrument/points_to.h @@ -35,7 +35,7 @@ class points_tot { // build the CFG data structure cfg(goto_functions); - + // iterate fixedpoint(); } @@ -48,24 +48,24 @@ class points_tot } void output(std::ostream &out) const; - + inline friend std::ostream &operator << ( std::ostream &out, const points_tot &points_to) { points_to.output(out); return out; } - + protected: typedef cfg_baset cfgt; cfgt cfg; typedef std::map value_mapt; value_mapt value_map; - + void fixedpoint(); bool transform(const cfgt::nodet&); - + const object_id_sett empty_set; }; diff --git a/src/goto-instrument/race_check.cpp b/src/goto-instrument/race_check.cpp index 3a794749388..6c15573ec27 100644 --- a/src/goto-instrument/race_check.cpp +++ b/src/goto-instrument/race_check.cpp @@ -34,28 +34,28 @@ class w_guardst w_guardst(symbol_tablet &_symbol_table):symbol_table(_symbol_table) { } - + std::list w_guards; const symbolt &get_guard_symbol(const irep_idt &object); - + const exprt get_guard_symbol_expr(const irep_idt &object) { return get_guard_symbol(object).symbol_expr(); } - + const exprt get_w_guard_expr(const rw_set_baset::entryt &entry) { return get_guard_symbol_expr(entry.object); } - + const exprt get_assertion(const rw_set_baset::entryt &entry) { return not_exprt(get_guard_symbol_expr(entry.object)); } - + void add_initialization(goto_programt &goto_program) const; - + protected: symbol_tablet &symbol_table; }; @@ -81,7 +81,7 @@ const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) if(it!=symbol_table.symbols.end()) return it->second; - + w_guards.push_back(identifier); symbolt new_symbol; @@ -90,7 +90,7 @@ const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) new_symbol.type=bool_typet(); new_symbol.is_static_lifetime=true; new_symbol.value=false_exprt(); - + symbolt *symbol_ptr; symbol_table.move(new_symbol, symbol_ptr); return *symbol_ptr; @@ -119,11 +119,11 @@ void w_guardst::add_initialization(goto_programt &goto_program) const it++) { exprt symbol=ns.lookup(*it).symbol_expr(); - + t=goto_program.insert_before(t); t->type=ASSIGN; t->code=code_assignt(symbol, false_exprt()); - + t++; } } @@ -248,7 +248,7 @@ void race_check( Forall_goto_program_instructions(i_it, goto_program) { goto_programt::instructiont &instruction=*i_it; - + if(instruction.is_assign()) { rw_set_loct rw_set(ns, value_sets, i_it @@ -256,21 +256,21 @@ void race_check( , local_may #endif ); - + if(!has_shared_entries(ns, rw_set)) continue; - + goto_programt::instructiont original_instruction; original_instruction.swap(instruction); - + instruction.make_skip(); i_it++; // now add assignments for what is written -- set forall_rw_set_w_entries(e_it, rw_set) - { + { if(!is_shared(ns, e_it->second.symbol_expr)) continue; - + goto_programt::targett t=goto_program.insert_before(i_it); t->type=ASSIGN; @@ -291,7 +291,7 @@ void race_check( // now add assignments for what is written -- reset forall_rw_set_w_entries(e_it, rw_set) - { + { if(!is_shared(ns, e_it->second.symbol_expr)) continue; goto_programt::targett t=goto_program.insert_before(i_it); @@ -330,11 +330,11 @@ void race_check( i_it=++t; } - i_it--; // the for loop already counts us up + i_it--; // the for loop already counts us up } } - - remove_skip(goto_program); + + remove_skip(goto_program); } /*******************************************************************\ @@ -359,9 +359,9 @@ void race_check( { w_guardst w_guards(symbol_table); - race_check(value_sets, symbol_table, + race_check(value_sets, symbol_table, #ifdef LOCAL_MAY - goto_function, + goto_function, #endif goto_program, w_guards); @@ -391,9 +391,9 @@ void race_check( Forall_goto_functions(f_it, goto_functions) if(f_it->first!=goto_functionst::entry_point() && f_it->first!=CPROVER_PREFIX "initialize") - race_check(value_sets, symbol_table, + race_check(value_sets, symbol_table, #ifdef LOCAL_MAY - f_it->second, + f_it->second, #endif f_it->second.body, w_guards); diff --git a/src/goto-instrument/reachability_slicer.cpp b/src/goto-instrument/reachability_slicer.cpp index c1de4fa1759..9f30f74b2d2 100644 --- a/src/goto-instrument/reachability_slicer.cpp +++ b/src/goto-instrument/reachability_slicer.cpp @@ -51,7 +51,7 @@ void reachability_slicert::fixedpoint_assertions( if(node.reaches_assertion) continue; node.reaches_assertion=true; - + for(cfgt::edgest::const_iterator p_it=node.in.begin(); p_it!=node.in.end(); @@ -93,7 +93,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions) // replace unreachable code by skip remove_unreachable(f_it->second.body); } - + // remove the skips remove_skip(goto_functions); goto_functions.update(); diff --git a/src/goto-instrument/rw_set.cpp b/src/goto-instrument/rw_set.cpp index e891971b99b..0a3408f4df7 100644 --- a/src/goto-instrument/rw_set.cpp +++ b/src/goto-instrument/rw_set.cpp @@ -40,7 +40,7 @@ void rw_set_baset::output(std::ostream &out) const out << it->second.object << " if " << from_expr(ns, "", it->second.guard) << std::endl; } - + out << std::endl; out << "WRITE:" << std::endl; @@ -84,14 +84,14 @@ void _rw_set_loct::compute() to_code_function_call(target->code); read(code_function_call.function()); - + // do operands for(code_function_callt::argumentst::const_iterator it=code_function_call.arguments().begin(); it!=code_function_call.arguments().end(); it++) read(*it); - + if(code_function_call.lhs().is_not_nil()) write(code_function_call.lhs()); } @@ -148,7 +148,7 @@ void _rw_set_loct::read_write_rec( track_deref(entry, true); } - + if(w) { entryt &entry=w_entries[object]; @@ -205,9 +205,9 @@ void _rw_set_loct::read_write_rec( } #else dereference(target, tmp, ns, value_sets); - + read_write_rec(tmp, r, w, suffix, guard); - #endif + #endif reset_track_deref(); } @@ -219,17 +219,17 @@ void _rw_set_loct::read_write_rec( else if(expr.id()==ID_address_of) { assert(expr.operands().size()==1); - + } else if(expr.id()==ID_if) { assert(expr.operands().size()==3); read(expr.op0(), guard); - + guardt true_guard(guard); true_guard.add(expr.op0()); read_write_rec(expr.op1(), r, w, suffix, true_guard); - + guardt false_guard(guard); false_guard.add(not_exprt(expr.op0())); read_write_rec(expr.op2(), r, w, suffix, false_guard); @@ -290,4 +290,4 @@ void rw_set_functiont::compute_rec(const exprt &function) compute_rec(to_if_expr(function).true_case()); compute_rec(to_if_expr(function).false_case()); } -} +} diff --git a/src/goto-instrument/rw_set.h b/src/goto-instrument/rw_set.h index 7edad0df6b5..34df614d3db 100644 --- a/src/goto-instrument/rw_set.h +++ b/src/goto-instrument/rw_set.h @@ -39,51 +39,51 @@ class rw_set_baset } ~rw_set_baset() {} - + struct entryt { symbol_exprt symbol_expr; irep_idt object; exprt guard; - + entryt():guard(true_exprt()) { } }; - + typedef hash_map_cont entriest; entriest r_entries, w_entries; - + void swap(rw_set_baset &other) { std::swap(other.r_entries, r_entries); std::swap(other.w_entries, w_entries); } - + inline rw_set_baset &operator += (const rw_set_baset &other) { r_entries.insert(other.r_entries.begin(), other.r_entries.end()); w_entries.insert(other.w_entries.begin(), other.w_entries.end()); return *this; } - + inline bool empty() const { return r_entries.empty() && w_entries.empty(); } - + inline bool has_w_entry(irep_idt object) const { return w_entries.find(object)!=w_entries.end(); } - + inline bool has_r_entry(irep_idt object) const { return r_entries.find(object)!=r_entries.end(); } - + void output(std::ostream &out) const; - + protected: virtual void track_deref(const entryt& entry, bool read) {} virtual void set_track_deref() {} @@ -102,11 +102,11 @@ extern inline std::ostream & operator << ( #define forall_rw_set_r_entries(it, rw_set) \ for(rw_set_baset::entriest::const_iterator it=(rw_set).r_entries.begin(); \ it!=(rw_set).r_entries.end(); it++) - + #define forall_rw_set_w_entries(it, rw_set) \ for(rw_set_baset::entriest::const_iterator it=(rw_set).w_entries.begin(); \ it!=(rw_set).w_entries.end(); it++) - + // a producer of read/write sets class _rw_set_loct:public rw_set_baset @@ -129,7 +129,7 @@ class _rw_set_loct:public rw_set_baset } ~_rw_set_loct() {} - + protected: value_setst &value_sets; const goto_programt::const_targett target; @@ -142,19 +142,19 @@ class _rw_set_loct:public rw_set_baset { read_write_rec(expr, true, false, "", guardt()); } - + inline void read(const exprt &expr, const guardt &guard) { read_write_rec(expr, true, false, "", guard); } - + inline void write(const exprt &expr) { read_write_rec(expr, false, true, "", guardt()); } - + void compute(); - + void assign(const exprt &lhs, const exprt &rhs); void read_write_rec( @@ -204,7 +204,7 @@ class rw_set_functiont:public rw_set_baset } ~rw_set_functiont() {} - + protected: value_setst &value_sets; const goto_functionst &goto_functions; @@ -218,9 +218,9 @@ class rw_set_with_trackt:public _rw_set_loct { public: // NOTE: combine this with entriest to avoid double copy - /* keeps track of who is dereferenced from who. + /* keeps track of who is dereferenced from who. E.g., y=&z; x=*y; - reads(x=*y;)={y,z} + reads(x=*y;)={y,z} dereferenced_from={z|->y} */ std::map dereferenced_from; @@ -265,7 +265,7 @@ class rw_set_with_trackt:public _rw_set_loct void set_track_deref() { dereferencing=true; } - + void reset_track_deref() { dereferencing=false; dereferenced.clear(); diff --git a/src/goto-instrument/show_locations.cpp b/src/goto-instrument/show_locations.cpp index 78d3b7b5ced..35ec08d9766 100644 --- a/src/goto-instrument/show_locations.cpp +++ b/src/goto-instrument/show_locations.cpp @@ -39,7 +39,7 @@ void show_locations( it++) { const source_locationt &source_location=it->source_location; - + switch(ui) { case ui_message_handlert::XML_UI: @@ -47,18 +47,18 @@ void show_locations( xmlt xml("program_location"); xml.new_element("function").data=id2string(function_id); xml.new_element("id").data=i2string(it->location_number); - + xmlt &l=xml.new_element(); l.name="location"; - + l.new_element("line").data=id2string(source_location.get_line()); l.new_element("file").data=id2string(source_location.get_file()); l.new_element("function").data=id2string(source_location.get_function()); - + std::cout << xml << std::endl; } break; - + case ui_message_handlert::PLAIN: std::cout << function_id << " " << it->location_number << " " diff --git a/src/goto-instrument/skip_loops.cpp b/src/goto-instrument/skip_loops.cpp index 437a31a4796..1658b5890d3 100644 --- a/src/goto-instrument/skip_loops.cpp +++ b/src/goto-instrument/skip_loops.cpp @@ -155,4 +155,3 @@ bool skip_loops( return false; } - diff --git a/src/goto-instrument/stack_depth.cpp b/src/goto-instrument/stack_depth.cpp index bf2fb883ad3..d281f72210f 100644 --- a/src/goto-instrument/stack_depth.cpp +++ b/src/goto-instrument/stack_depth.cpp @@ -145,4 +145,3 @@ void stack_depth( // update counters etc. goto_functions.update(); } - diff --git a/src/goto-instrument/thread_instrumentation.cpp b/src/goto-instrument/thread_instrumentation.cpp index 45afd16c038..602796db094 100644 --- a/src/goto-instrument/thread_instrumentation.cpp +++ b/src/goto-instrument/thread_instrumentation.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: +Module: Author: Daniel Kroening, kroening@kroening.com @@ -55,7 +55,7 @@ void thread_exit_instrumentation(goto_programt &goto_program) end--; assert(end->is_end_function()); - + source_locationt source_location=end->source_location; irep_idt function=end->function; @@ -63,13 +63,13 @@ void thread_exit_instrumentation(goto_programt &goto_program) exprt mutex_locked_string= string_constantt("mutex-locked"); - + binary_exprt get_may("get_may"); - + // NULL is any get_may.op0()=constant_exprt(ID_NULL, pointer_typet(empty_typet())); get_may.op1()=address_of_exprt(mutex_locked_string); - + end->make_assertion(not_exprt(get_may)); end->source_location=source_location; @@ -93,7 +93,7 @@ void thread_exit_instrumentation(goto_functionst &goto_functions) { // we'll look for START THREAD std::set thread_fkts; - + forall_goto_functions(f_it, goto_functions) { if(has_start_thread(f_it->second.body)) @@ -146,18 +146,18 @@ void mutex_init_instrumentation( { const code_assignt &code_assign= to_code_assign(it->code); - + if(code_assign.lhs().type()==lock_type) { goto_programt::targett t=goto_program.insert_after(it); code_function_callt call; - + call.function()=f_it->second.symbol_expr(); call.arguments().resize(2); call.arguments()[0]=address_of_exprt(code_assign.lhs()); call.arguments()[1]=address_of_exprt(string_constantt("mutex-init")); - + t->make_function_call(call); t->source_location=it->source_location; } @@ -182,7 +182,7 @@ void mutex_init_instrumentation( goto_functionst &goto_functions) { // get pthread_mutex_lock - + symbol_tablet::symbolst::const_iterator f_it= symbol_table.symbols.find("pthread_mutex_lock"); @@ -193,9 +193,9 @@ void mutex_init_instrumentation( code_typet code_type=to_code_type(to_code_type(f_it->second.type)); if(code_type.parameters().size()!=1) return; - + typet lock_type=code_type.parameters()[0].type(); - + if(lock_type.id()!=ID_pointer) return; diff --git a/src/goto-instrument/thread_instrumentation.h b/src/goto-instrument/thread_instrumentation.h index cf90fe07f63..c4ca11dcb3d 100644 --- a/src/goto-instrument/thread_instrumentation.h +++ b/src/goto-instrument/thread_instrumentation.h @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: +Module: Author: Daniel Kroening, kroening@kroening.com diff --git a/src/goto-instrument/uninitialized.cpp b/src/goto-instrument/uninitialized.cpp index 9b24feead0f..75a1eb10a08 100644 --- a/src/goto-instrument/uninitialized.cpp +++ b/src/goto-instrument/uninitialized.cpp @@ -18,7 +18,7 @@ Date: January 2010 Class: uninitializedt - Purpose: + Purpose: \*******************************************************************/ @@ -41,7 +41,7 @@ class uninitializedt // The variables that need tracking, // i.e., are uninitialized and may be read? std::set tracking; - + void get_tracking(goto_programt::const_targett i_it); }; @@ -93,13 +93,13 @@ Function: uninitializedt::add_assertions void uninitializedt::add_assertions(goto_programt &goto_program) { uninitialized_analysis(goto_program, ns); - + // find out which variables need tracking tracking.clear(); forall_goto_program_instructions(i_it, goto_program) get_tracking(i_it); - + // add tracking symbols to symbol table for(std::set::const_iterator it=tracking.begin(); @@ -119,7 +119,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) new_symbol.is_static_lifetime=false; new_symbol.is_file_local=true; new_symbol.is_lvalue=true; - + symbol_table.move(new_symbol); } @@ -140,7 +140,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) goto_programt::targett i1=goto_program.insert_after(i_it); goto_programt::targett i2=goto_program.insert_after(i1); i_it++, i_it++; - + const irep_idt new_identifier= id2string(identifier)+"#initialized"; @@ -153,7 +153,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) i2->type=ASSIGN; i2->source_location=instruction.source_location; - i2->code=code_assignt(symbol_expr, false_exprt()); + i2->code=code_assignt(symbol_expr, false_exprt()); } } else @@ -179,7 +179,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) { assert(tracking.find(identifier)!=tracking.end()); const irep_idt new_identifier=id2string(identifier)+"#initialized"; - + // insert assertion goto_programt::instructiont assertion; assertion.type=ASSERT; @@ -187,7 +187,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) assertion.source_location=instruction.source_location; assertion.source_location.set_comment("use of uninitialized local variable"); assertion.source_location.set_property_class("uninitialized local"); - + goto_program.insert_before_swap(i_it, assertion); i_it++; } @@ -204,20 +204,20 @@ void uninitializedt::add_assertions(goto_programt &goto_program) if(tracking.find(identifier)!=tracking.end()) { const irep_idt new_identifier=id2string(identifier)+"#initialized"; - + goto_programt::instructiont assignment; assignment.type=ASSIGN; assignment.code=code_assignt( symbol_exprt(new_identifier, bool_typet()), true_exprt()); assignment.source_location=instruction.source_location; - + goto_program.insert_before_swap(i_it, assignment); i_it++; } } } } - } + } } /*******************************************************************\ diff --git a/src/goto-instrument/unwind.cpp b/src/goto-instrument/unwind.cpp index 8720d0af788..3a9e44e4a17 100644 --- a/src/goto-instrument/unwind.cpp +++ b/src/goto-instrument/unwind.cpp @@ -53,21 +53,21 @@ void unwind( std::vector &iteration_points) { assert(k!=0); - + iteration_points.resize(k); // loop_exit: where to go after the loop ends // loop_iter: where to go for the next iteration - + // Add a 'goto' and a 'skip' _before_ loop_exit. // The goto is to take care of 'fall-out' loop exit, and is // not needed if there is an unconditional goto before loop_exit. if(loop_exit!=goto_program.instructions.begin()) - { + { goto_programt::targett t_before=loop_exit; t_before--; - + if(t_before->is_goto() && t_before->guard.is_true()) { // no 'fall-out' @@ -76,28 +76,28 @@ void unwind( { // guard against 'fall-out' goto_programt::targett t_goto=goto_program.insert_before(loop_exit); - + t_goto->make_goto(loop_exit); t_goto->source_location=loop_exit->source_location; t_goto->function=loop_exit->function; t_goto->guard=true_exprt(); } } - + goto_programt::targett t_skip=goto_program.insert_before(loop_exit); goto_programt::targett loop_iter=t_skip; - + t_skip->make_skip(); t_skip->source_location=loop_head->source_location; t_skip->function=loop_head->function; - + // record the exit point of first iteration iteration_points[0]=loop_iter; - + // build a map for branch targets inside the loop std::map target_map; - { + { unsigned count=0; for(goto_programt::targett t=loop_head; t!=loop_exit; t++, count++) @@ -108,7 +108,7 @@ void unwind( } // re-direct any branches that go to loop_head to loop_iter - + for(goto_programt::targett t=loop_head; t!=loop_iter; t++) { @@ -119,7 +119,7 @@ void unwind( t_it++) if(*t_it==loop_head) *t_it=loop_iter; } - + // we make k-1 copies, to be inserted before loop_exit goto_programt copies; @@ -140,7 +140,7 @@ void unwind( // record exit point of this copy iteration_points[i]=target_vector.back(); - + // adjust the intra-loop branches for(std::size_t i=0; isecond; @@ -228,4 +228,3 @@ void goto_unwind( } } } - diff --git a/src/goto-instrument/wmm/abstract_event.cpp b/src/goto-instrument/wmm/abstract_event.cpp index 7c2907367e1..9e4df2668fa 100644 --- a/src/goto-instrument/wmm/abstract_event.cpp +++ b/src/goto-instrument/wmm/abstract_event.cpp @@ -22,7 +22,7 @@ Function: abstract_eventt::unsafe_pair_lwfence_param \*******************************************************************/ -bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt& next, +bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt& next, memory_modelt model, bool lwsync_met) const { @@ -109,7 +109,7 @@ bool abstract_eventt::unsafe_pair_asm(const abstract_eventt& next, switch(model) { case TSO: - return (thread==next.thread && operation==Write && next.operation==Read + return (thread==next.thread && operation==Write && next.operation==Read && (met&1)==0); case PSO: return (thread==next.thread && operation==Write @@ -136,4 +136,3 @@ bool abstract_eventt::unsafe_pair_asm(const abstract_eventt& next, /* unknown memory model */ return true; } - diff --git a/src/goto-instrument/wmm/abstract_event.h b/src/goto-instrument/wmm/abstract_event.h index 8726c087505..6d0a5e0f6e0 100644 --- a/src/goto-instrument/wmm/abstract_event.h +++ b/src/goto-instrument/wmm/abstract_event.h @@ -153,4 +153,3 @@ class abstract_eventt:public graph_nodet } }; #endif - diff --git a/src/goto-instrument/wmm/cycle_collection.cpp b/src/goto-instrument/wmm/cycle_collection.cpp index 850bb80dce2..5d2d34148ec 100644 --- a/src/goto-instrument/wmm/cycle_collection.cpp +++ b/src/goto-instrument/wmm/cycle_collection.cpp @@ -20,7 +20,7 @@ Function: event_grapht::graph_explorert::filter_thin_air Outputs: - Purpose: after the collection, eliminates the executions forbidden + Purpose: after the collection, eliminates the executions forbidden by an indirect thin-air \*******************************************************************/ @@ -67,7 +67,7 @@ Function: event_grapht::graph_explorert::collect_cycles \*******************************************************************/ void event_grapht::graph_explorert::collect_cycles( - std::set& set_of_cycles, + std::set& set_of_cycles, memory_modelt model) { /* all the events initially unmarked */ @@ -100,12 +100,12 @@ void event_grapht::graph_explorert::collect_cycles( if(order->empty()) return; - for(std::list::const_iterator st_it=order->begin(); + for(std::list::const_iterator st_it=order->begin(); st_it!=order->end(); ++st_it) { unsigned source=*st_it; egraph.message.debug() << "explore " << egraph[source].id << messaget::eom; - backtrack(set_of_cycles, source, source, + backtrack(set_of_cycles, source, source, false, max_po_trans, false, false, false, "", model); while(!marked_stack.empty()) @@ -136,7 +136,7 @@ Function: event_grapht::graph_explorert::extract_cycle \*******************************************************************/ event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( - unsigned vertex, + unsigned vertex, unsigned source, unsigned number) { @@ -149,8 +149,8 @@ event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( unsigned current_vertex=stack.top(); stack.pop(); - egraph.message.debug() << "extract: " << egraph[current_vertex].get_operation() - << egraph[current_vertex].variable << "@" + egraph.message.debug() << "extract: " << egraph[current_vertex].get_operation() + << egraph[current_vertex].variable << "@" << egraph[current_vertex].thread << "~" << egraph[current_vertex].local << messaget::eom; @@ -185,8 +185,8 @@ Function: event_grapht::graph_explorert::backtrack \*******************************************************************/ bool event_grapht::graph_explorert::backtrack( - std::set &set_of_cycles, - unsigned source, + std::set &set_of_cycles, + unsigned source, unsigned vertex, bool unsafe_met, /* unsafe pair for the model met in the visited path */ unsigned po_trans, /* po-transition skips still allowed */ @@ -199,7 +199,7 @@ bool event_grapht::graph_explorert::backtrack( #ifdef DEBUG for(unsigned i=0; i<80; egraph.message.debug() << "-", ++i); egraph.message.debug() << messaget::eom; - egraph.message.debug() << "marked size:" << marked_stack.size() + egraph.message.debug() << "marked size:" << marked_stack.size() << messaget::eom; std::stack tmp; while(!point_stack.empty()) @@ -210,7 +210,7 @@ bool event_grapht::graph_explorert::backtrack( } egraph.message.debug() << messaget::eom; while(!tmp.empty()) - { + { point_stack.push(tmp.top()); tmp.pop(); } @@ -263,10 +263,10 @@ bool event_grapht::graph_explorert::backtrack( return false; //{no_comm=true;get_com_only=false;}//return false; bool has_to_be_unsafe_updated=false; - // TODO: propagate this constraint within the optimisation + // TODO: propagate this constraint within the optimisation // -- no optimisation can strongly affect performances /* tab[] can appear several times */ - if(egraph.ignore_arrays || id2string(this_vertex.variable).find("[]")==std::string::npos) + if(egraph.ignore_arrays || id2string(this_vertex.variable).find("[]")==std::string::npos) { /* no more than 4 events per thread */ if(this_vertex.operation!=abstract_eventt::Fence @@ -279,10 +279,10 @@ bool event_grapht::graph_explorert::backtrack( events_per_thread[this_vertex.thread]++; } - /* Multiple re-orderings constraint: if the thread on this cycles contains - more than one, ensure that an unsafe pair is not protected by another - relation in the thread. E.g., in Wx Rx Wy, under TSO, the rfi cannot be - delayed, since the only way to make this transformation matter is to + /* Multiple re-orderings constraint: if the thread on this cycles contains + more than one, ensure that an unsafe pair is not protected by another + relation in the thread. E.g., in Wx Rx Wy, under TSO, the rfi cannot be + delayed, since the only way to make this transformation matter is to re-order also the two writes, which is not permitted on TSO. */ if(has_to_be_unsafe && point_stack.size() >= 2) { @@ -315,8 +315,8 @@ bool event_grapht::graph_explorert::backtrack( && this_vertex.operation!=abstract_eventt::ASMfence && this_vertex.variable==egraph[point_stack.top()].variable) { - if(same_var_pair || - (this_vertex.operation==abstract_eventt::Read + if(same_var_pair || + (this_vertex.operation==abstract_eventt::Read && egraph[point_stack.top()].operation==abstract_eventt::Read)) { events_per_thread[this_vertex.thread]--; @@ -341,7 +341,7 @@ bool event_grapht::graph_explorert::backtrack( } /* constraint 2: per variable, either W W, R W, W R, or R W R */ - if(this_vertex.operation!=abstract_eventt::Fence + if(this_vertex.operation!=abstract_eventt::Fence && this_vertex.operation!=abstract_eventt::Lwfence && this_vertex.operation!=abstract_eventt::ASMfence) { @@ -381,7 +381,7 @@ bool event_grapht::graph_explorert::backtrack( unsafe_met_updated |= (prev_vertex.unsafe_pair(this_vertex,model) && !(prev_vertex.thread==this_vertex.thread && egraph.map_data_dp[this_vertex.thread].dp(prev_vertex,this_vertex))); - if (unsafe_met_updated && !unsafe_met + if (unsafe_met_updated && !unsafe_met && egraph.are_po_ordered(point_stack.top(), vertex)) has_to_be_unsafe_updated=true; } @@ -393,8 +393,8 @@ bool event_grapht::graph_explorert::backtrack( if(!get_com_only) { /* we first visit via po transition, if existing */ - for(graph::edgest::const_iterator - w_it=egraph.po_out(vertex).begin(); + for(graph::edgest::const_iterator + w_it=egraph.po_out(vertex).begin(); w_it!=egraph.po_out(vertex).end(); w_it++) { const unsigned w = w_it->first; @@ -411,12 +411,12 @@ bool event_grapht::graph_explorert::backtrack( ++e_it) thin_air_events.insert(*e_it); } - if((!egraph.filter_uniproc || new_cycle.is_not_uniproc(model)) && not_thin_air + if((!egraph.filter_uniproc || new_cycle.is_not_uniproc(model)) && not_thin_air && new_cycle.is_cycle() && new_cycle.is_unsafe(model) /*&& new_cycle.is_unsafe_asm(model)*/) { - egraph.message.debug() << new_cycle.print_name(model,false) + egraph.message.debug() << new_cycle.print_name(model,false) << messaget::eom; set_of_cycles.insert(new_cycle); #if 0 @@ -428,7 +428,7 @@ bool event_grapht::graph_explorert::backtrack( f = true; } else if(!mark[w]) - f |= backtrack(set_of_cycles, source, w, unsafe_met_updated, + f |= backtrack(set_of_cycles, source, w, unsafe_met_updated, po_trans, same_var_pair_updated, false, has_to_be_unsafe_updated, avoid_at_the_end, model); } @@ -436,7 +436,7 @@ bool event_grapht::graph_explorert::backtrack( if(!no_comm) /* we then visit via com transitions, if existing */ - for(graph::edgest::const_iterator + for(graph::edgest::const_iterator w_it=egraph.com_out(vertex).begin(); w_it!=egraph.com_out(vertex).end(); w_it++) { @@ -444,7 +444,7 @@ bool event_grapht::graph_explorert::backtrack( if(w < source) egraph.remove_com_edge(vertex,w); else if(w == source && point_stack.size()>=4 - && (unsafe_met_updated + && (unsafe_met_updated || this_vertex.unsafe_pair(egraph[source],model)) ) { critical_cyclet new_cycle = extract_cycle(vertex, source, cycle_nb++); @@ -456,12 +456,12 @@ bool event_grapht::graph_explorert::backtrack( ++e_it) thin_air_events.insert(*e_it); } - if((!egraph.filter_uniproc || new_cycle.is_not_uniproc(model)) && not_thin_air + if((!egraph.filter_uniproc || new_cycle.is_not_uniproc(model)) && not_thin_air && new_cycle.is_cycle() && new_cycle.is_unsafe(model) /*&& new_cycle.is_unsafe_asm(model)*/) { - egraph.message.debug() << new_cycle.print_name(model,false) + egraph.message.debug() << new_cycle.print_name(model,false) << messaget::eom; set_of_cycles.insert(new_cycle); #if 0 @@ -473,7 +473,7 @@ bool event_grapht::graph_explorert::backtrack( f = true; } else if(!mark[w]) - f |= backtrack(set_of_cycles, source, w, + f |= backtrack(set_of_cycles, source, w, unsafe_met_updated, po_trans, false, false, false, "", model); } @@ -495,7 +495,7 @@ bool event_grapht::graph_explorert::backtrack( point_stack.pop(); /* removes variable access */ - if(this_vertex.operation!=abstract_eventt::Fence + if(this_vertex.operation!=abstract_eventt::Fence && this_vertex.operation!=abstract_eventt::Lwfence && this_vertex.operation!=abstract_eventt::ASMfence) { @@ -508,7 +508,7 @@ bool event_grapht::graph_explorert::backtrack( } } - /* transitivity of po: do the same, but skip this event + /* transitivity of po: do the same, but skip this event (except if it is a fence or no more po-transition skips allowed); if the cycle explored so far has a thin-air subcycle, this cycle is not valid: stop this exploration here */ @@ -520,7 +520,7 @@ bool event_grapht::graph_explorert::backtrack( && ( this_vertex.operation!=abstract_eventt::Lwfence || egraph[point_stack.top()].operation==abstract_eventt::Write) && ( this_vertex.operation!=abstract_eventt::ASMfence - || !this_vertex.WRfence + || !this_vertex.WRfence || egraph[point_stack.top()].operation==abstract_eventt::Write) ) { @@ -555,7 +555,7 @@ bool event_grapht::graph_explorert::backtrack( if(!egraph[point_stack.top()].unsafe_pair(this_vertex, model)) { /* tab[] should never be avoided */ - if(egraph.ignore_arrays + if(egraph.ignore_arrays || id2string(this_vertex.variable).find("[]")==std::string::npos) avoid_at_the_end = this_vertex.variable; } @@ -565,7 +565,7 @@ bool event_grapht::graph_explorert::backtrack( const bool is_lwfence = (this_vertex.operation==abstract_eventt::Lwfence && egraph[point_stack.top()].operation==abstract_eventt::Write) || (this_vertex.operation==abstract_eventt::ASMfence && - (!this_vertex.WRfence + (!this_vertex.WRfence && egraph[point_stack.top()].operation==abstract_eventt::Write)); for(graph::edgest::const_iterator w_it= @@ -574,7 +574,7 @@ bool event_grapht::graph_explorert::backtrack( { const unsigned w = w_it->first; f |= backtrack(set_of_cycles, source, w, - unsafe_met/*_updated*/, (po_trans==0?0:po_trans-1), + unsafe_met/*_updated*/, (po_trans==0?0:po_trans-1), same_var_pair/*_updated*/, is_lwfence, has_to_be_unsafe, avoid_at_the_end, model); } @@ -598,4 +598,3 @@ bool event_grapht::graph_explorert::backtrack( return f; } - diff --git a/src/goto-instrument/wmm/data_dp.cpp b/src/goto-instrument/wmm/data_dp.cpp index bf92adc3136..983955127f2 100644 --- a/src/goto-instrument/wmm/data_dp.cpp +++ b/src/goto-instrument/wmm/data_dp.cpp @@ -26,9 +26,9 @@ Function: data_dpt::dp_analysis \*******************************************************************/ void data_dpt::dp_analysis( - const datat& read, - bool local_read, - const datat& write, + const datat& read, + bool local_read, + const datat& write, bool local_write) { const_iterator it; @@ -68,7 +68,7 @@ Function: data_dpt::dp_analysis \*******************************************************************/ -void data_dpt::dp_analysis(const abstract_eventt& read, +void data_dpt::dp_analysis(const abstract_eventt& read, const abstract_eventt& write) { datat d_read(read.variable,read.source_location); @@ -227,4 +227,3 @@ void data_dpt::print(messaget& message) } #endif } - diff --git a/src/goto-instrument/wmm/event_graph.cpp b/src/goto-instrument/wmm/event_graph.cpp index 219e08cb32e..79ed0b6a13f 100644 --- a/src/goto-instrument/wmm/event_graph.cpp +++ b/src/goto-instrument/wmm/event_graph.cpp @@ -34,11 +34,11 @@ Function: event_grapht::print_rec_graph \*******************************************************************/ -void event_grapht::print_rec_graph(std::ofstream& file, unsigned node_id, - std::set& visited) +void event_grapht::print_rec_graph(std::ofstream& file, unsigned node_id, + std::set& visited) { const abstract_eventt& node=operator[](node_id); - file << node_id << "[label=\"" << node << ", " << node.source_location << + file << node_id << "[label=\"" << node << ", " << node.source_location << "\"];" << std::endl; visited.insert(node_id); @@ -99,7 +99,7 @@ Function: event_grapht::copy_segment \*******************************************************************/ -void event_grapht::explore_copy_segment(std::set& explored, +void event_grapht::explore_copy_segment(std::set& explored, unsigned begin, unsigned end) const { //std::cout << "explores " << begin << " against " << end << std::endl; @@ -111,7 +111,7 @@ void event_grapht::explore_copy_segment(std::set& explored, if(begin==end) return; - for(graph::edgest::const_iterator it=po_out(begin).begin(); + for(graph::edgest::const_iterator it=po_out(begin).begin(); it!=po_out(begin).end(); ++it) explore_copy_segment(explored, it->first, end); @@ -144,7 +144,7 @@ unsigned event_grapht::copy_segment(unsigned begin, unsigned end) if(covered.size()==0) return end; - + // for(std::set::const_iterator it=covered.begin(); it!=covered.end(); ++it) // std::cout << "covered: " << *it << std::endl; @@ -224,8 +224,8 @@ Function: event_grapht::critical_cyclet::check_AC \*******************************************************************/ bool event_grapht::critical_cyclet::check_AC( - const_iterator s_it, - const abstract_eventt& first, + const_iterator s_it, + const abstract_eventt& first, const abstract_eventt& second) const { bool AC=false; @@ -276,7 +276,7 @@ Function: event_grapht::critical_cyclet::check_BC bool event_grapht::critical_cyclet::check_BC( const_iterator it, - const abstract_eventt& first, + const abstract_eventt& first, const abstract_eventt& second) const { bool BC=false; @@ -351,7 +351,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) /* critical cycles contain at least 2 threads */ unsigned thread=egraph[*begin()].thread; const_iterator th_it; - for(th_it=begin(); + for(th_it=begin(); th_it!=end() && thread==egraph[*th_it].thread; ++th_it) thread = egraph[*th_it].thread; if(th_it==end()) @@ -380,7 +380,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) /* selects the next event which is not a weak fence */ const_iterator s_it=next; - for(; s_it!=end() && egraph[*s_it].operation==abstract_eventt::Lwfence; + for(; s_it!=end() && egraph[*s_it].operation==abstract_eventt::Lwfence; ++s_it); if(s_it==end()) @@ -418,7 +418,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) if(s_it==n_it) { /* there is no lwfence between the pair */ - if(first.unsafe_pair(second,model) + if(first.unsafe_pair(second,model) && (first.thread!=second.thread || egraph.are_po_ordered(*it,*s_it))) { const_iterator before_first; @@ -437,7 +437,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) else after_second=s_it; - if(first.variable == second.variable + if(first.variable == second.variable && first.thread == second.thread && egraph[*before_first].thread != first.thread && egraph[*after_second].thread != second.thread) @@ -512,7 +512,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) /* selects the next event which is not a weak fence */ const_iterator s_it; - for(s_it=begin(); + for(s_it=begin(); s_it!=end() && egraph[*s_it].operation==abstract_eventt::Lwfence; s_it++); /* if the whole cycle has been explored */ @@ -544,7 +544,7 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) if(s_it==begin()) { /* no lwfence between the pair */ - if(first.unsafe_pair(second,model) + if(first.unsafe_pair(second,model) && (first.thread!=second.thread || egraph.are_po_ordered(back(),*s_it))) { std::list::const_iterator before_first; @@ -583,14 +583,14 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) { std::list::const_iterator before_first; std::list::const_iterator after_second; - + before_first = end(); --before_first; --before_first; after_second = s_it; ++after_second; - + if(first.variable == second.variable && first.thread == second.thread && egraph[*before_first].thread != first.thread @@ -625,7 +625,7 @@ Function: event_grapht::critical_cyclet::is_unsafe_asm \*******************************************************************/ -bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, +bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, bool fast) { egraph.message.debug() << "cycle is safe?" << messaget::eom; @@ -639,7 +639,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, /* critical cycles contain at least 2 threads */ unsigned thread = egraph[*begin()].thread; const_iterator th_it; - for(th_it=begin(); + for(th_it=begin(); th_it!=end() && thread==egraph[*th_it].thread; ++th_it) thread = egraph[*th_it].thread; if(th_it==end()) @@ -667,8 +667,8 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, const_iterator s_it = ++it; --it; - for(; - s_it!=end() && egraph[*s_it].operation==abstract_eventt::ASMfence; + for(; + s_it!=end() && egraph[*s_it].operation==abstract_eventt::ASMfence; s_it++) fences_met |= egraph[*s_it].fence_value(); @@ -704,7 +704,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, AC_it!=end() && egraph[*AC_it].thread==second.thread; AC_it++) if(egraph[*AC_it].operation==abstract_eventt::ASMfence - && egraph[*AC_it].is_cumul() + && egraph[*AC_it].is_cumul() && egraph[*AC_it].is_corresponding_fence(egraph[*it],egraph[*s_it])) { AC = true; @@ -778,7 +778,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, --it; /* no lwfence between the pair */ - if(first.unsafe_pair(second,model) + if(first.unsafe_pair(second,model) && (first.thread!=second.thread || egraph.are_po_ordered(*it,*s_it))) { if(fast) @@ -820,7 +820,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, /* selects the next event which is not a weak fence */ const_iterator s_it; - for(s_it=begin(); + for(s_it=begin(); s_it!=end() && egraph[*s_it].operation==abstract_eventt::ASMfence; s_it++) fences_met |= egraph[*s_it].fence_value(); @@ -881,7 +881,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, /* no fence before the first element? (BC) */ const_iterator BC_it = end(); --BC_it; - + for(; BC_it!=begin() && egraph[*BC_it].thread==first.thread; BC_it--) @@ -919,7 +919,7 @@ bool event_grapht::critical_cyclet::is_unsafe_asm(memory_modelt model, if(s_it==begin()) { /* no lwfence between the pair */ - if(first.unsafe_pair(second,model) + if(first.unsafe_pair(second,model) && (first.thread!=second.thread || egraph.are_po_ordered(back(),*s_it))) { if(!fast) @@ -1204,7 +1204,7 @@ std::string event_grapht::critical_cyclet::print_events() const for(const_iterator it=begin(); it!=end(); ++it) { const abstract_eventt& it_evt=egraph[*it]; - cycle += it_evt.get_operation() + id2string(it_evt.variable) + cycle += it_evt.get_operation() + id2string(it_evt.variable) + "; "; } return cycle+" End of cycle."; @@ -1228,7 +1228,7 @@ std::string event_grapht::critical_cyclet::print_output() const for(const_iterator it=begin(); it!=end(); ++it) { const abstract_eventt& it_evt=egraph[*it]; - cycle += id2string(it_evt.variable) + " ("; + cycle += id2string(it_evt.variable) + " ("; cycle += it_evt.source_location.as_string(); cycle += " thread " + i2string(it_evt.thread) + ") "; } @@ -1469,7 +1469,7 @@ std::string event_grapht::critical_cyclet::print_name( const abstract_eventt& succ=egraph[*n_it]; assert(succ.operation == abstract_eventt::Read || succ.operation == abstract_eventt::Write); - name += (model==Power?" Sync":" MFence"); + name += (model==Power?" Sync":" MFence"); name += (prev.variable==succ.variable?"s":"d") + prev.get_operation() + succ.get_operation(); } @@ -1498,7 +1498,7 @@ std::string event_grapht::critical_cyclet::print_name( else if(cand.operation == abstract_eventt::Fence || (cand.operation == abstract_eventt::ASMfence && cand.fence_value()&1)) - cand_name = (model==Power?" Sync":" MFence"); + cand_name = (model==Power?" Sync":" MFence"); if(!wraparound) ++cur_it; if(!wraparound) ++extra_fence_count; } @@ -1514,7 +1514,7 @@ std::string event_grapht::critical_cyclet::print_name( { std::string cand_name; if(cur.fence_value()&1) - cand_name = (model==Power?" Sync":" MFence"); + cand_name = (model==Power?" Sync":" MFence"); else cand_name = " LwSync"; const_iterator n_it=cur_it; @@ -1538,7 +1538,7 @@ std::string event_grapht::critical_cyclet::print_name( else if(cand.operation == abstract_eventt::Fence || (cand.operation == abstract_eventt::ASMfence && cand.fence_value()&1)) - cand_name = (model==Power?" Sync":" MFence"); + cand_name = (model==Power?" Sync":" MFence"); if(!wraparound) ++cur_it; if(!wraparound) ++extra_fence_count; } @@ -1594,11 +1594,11 @@ std::string event_grapht::critical_cyclet::print_name( else { name += " Po"; - name += (prev.variable==cur.variable?"s":"d") + prev.get_operation() + name += (prev.variable==cur.variable?"s":"d") + prev.get_operation() + cur.get_operation(); } } - + else if(cur.variable!=ID_unknown && prev.variable!=ID_unknown) assert(false); } @@ -1695,7 +1695,7 @@ std::string event_grapht::critical_cyclet::print_name( else { name += " Po"; - name += (last.variable==first.variable?"s":"d") + last.get_operation() + name += (last.variable==first.variable?"s":"d") + last.get_operation() + first.get_operation(); } } @@ -1769,7 +1769,7 @@ void event_grapht::critical_cyclet::print_dot( const abstract_eventt& succ=( n_it!=end() ? egraph[*n_it] : egraph[front()] ); str << succ.id << "[label=\""; - str << (model==Power?"Sync":"MFence"); + str << (model==Power?"Sync":"MFence"); str << (prev.variable==cur.variable?"s":"d"); str << prev.get_operation() << succ.get_operation(); } @@ -1814,7 +1814,7 @@ void event_grapht::critical_cyclet::print_dot( && prev.operation != abstract_eventt::Fence) { str << cur.id << "[label=\""; - str << "Po" << (prev.variable==cur.variable?"s":"d") + str << "Po" << (prev.variable==cur.variable?"s":"d") + prev.get_operation() + cur.get_operation(); } diff --git a/src/goto-instrument/wmm/event_graph.h b/src/goto-instrument/wmm/event_graph.h index a115e3a01be..c4e9a98a966 100644 --- a/src/goto-instrument/wmm/event_graph.h +++ b/src/goto-instrument/wmm/event_graph.h @@ -41,16 +41,16 @@ class event_grapht bool is_not_uniproc() const; bool is_not_weak_uniproc() const; - std::string print_detail(const critical_cyclet& reduced, + std::string print_detail(const critical_cyclet& reduced, std::map& map_id2var, std::map& map_var2id, memory_modelt model) const; - std::string print_name(const critical_cyclet& redyced, + std::string print_name(const critical_cyclet& redyced, memory_modelt model) const; - bool check_AC(const_iterator s_it, const abstract_eventt& first, + bool check_AC(const_iterator s_it, const abstract_eventt& first, const abstract_eventt& second) const; - bool check_BC(const_iterator it, const abstract_eventt& first, + bool check_BC(const_iterator it, const abstract_eventt& first, const abstract_eventt& second) const; public: @@ -70,7 +70,7 @@ class event_grapht push_back(*it); has_user_defined_fence=cyc.has_user_defined_fence; } - + bool is_cycle() { /* size check */ @@ -83,7 +83,7 @@ class event_grapht ++n_it; for(; it!=end() && n_it!=end(); ++it, ++n_it) { - if(egraph[*it].thread==egraph[*n_it].thread + if(egraph[*it].thread==egraph[*n_it].thread && !egraph.are_po_ordered(*it,*n_it)) return false; } @@ -91,11 +91,11 @@ class event_grapht return true; } - /* removes internal events (e.g. podWW Rfi gives podWR) + /* removes internal events (e.g. podWW Rfi gives podWR) from.hide_internals(&target) */ void hide_internals(critical_cyclet& reduced) const; - /* checks whether there is at leat one pair which is unsafe + /* checks whether there is at leat one pair which is unsafe (takes fences and dependencies into account), and adds the unsafe pairs in the set */ bool is_unsafe(memory_modelt model, bool fast=false); @@ -160,7 +160,7 @@ class event_grapht std::set unsafe_pairs; - /* print events or ids in the cycles*/ + /* print events or ids in the cycles*/ std::string print() const; std::string print_events() const; @@ -184,12 +184,12 @@ class event_grapht std::string print_unsafes() const; std::string print_output() const; - std::string print_all(memory_modelt model, + std::string print_all(memory_modelt model, std::map& map_id2var, std::map& map_var2id, bool hide_internals) const; - void print_dot(std::ostream &str, + void print_dot(std::ostream &str, unsigned colour, memory_modelt model) const; inline bool operator<(const critical_cyclet& other) const @@ -244,7 +244,7 @@ class event_grapht unsigned cycle_nb; /* events in thin-air executions met so far */ - /* any execution blocked by thin-air is guaranteed + /* any execution blocked by thin-air is guaranteed to have all its events in this set */ std::set thin_air_events; @@ -253,7 +253,7 @@ class event_grapht void filter_thin_air(std::set& set_of_cycles); public: - graph_explorert(event_grapht& _egraph, unsigned _max_var, + graph_explorert(event_grapht& _egraph, unsigned _max_var, unsigned _max_po_trans) :egraph(_egraph), max_var(_max_var), max_po_trans(_max_po_trans), cycle_nb(0) { @@ -266,7 +266,7 @@ class event_grapht std::set skip_tracked; - critical_cyclet extract_cycle(unsigned vertex, + critical_cyclet extract_cycle(unsigned vertex, unsigned source, unsigned number_of_cycles); bool backtrack(std::set& set_of_cycles, @@ -329,7 +329,7 @@ class event_grapht public: graph_pensieve_explorert(event_grapht& _egraph, unsigned _max_var, unsigned _max_po_trans) - :graph_explorert(_egraph,_max_var,_max_po_trans), naive(false) + :graph_explorert(_egraph,_max_var,_max_po_trans), naive(false) {} void set_naive() {naive=true;} @@ -368,7 +368,7 @@ class event_grapht inline graph::nodet &operator[](unsigned n) { return po_graph[n]; - } + } bool has_po_edge(unsigned i, unsigned j) const { @@ -457,7 +457,7 @@ class event_grapht /* copies the sub-graph G between begin and end into G', connects G.end with G'.begin, and returns G'.end */ - void explore_copy_segment(std::set& explored, unsigned begin, + void explore_copy_segment(std::set& explored, unsigned begin, unsigned end) const; unsigned copy_segment(unsigned begin, unsigned end); @@ -503,7 +503,7 @@ class event_grapht std::set& visited); /* Tarjan 1972 adapted and modified for events + po-transitivity */ - void collect_cycles(std::set& set_of_cycles, + void collect_cycles(std::set& set_of_cycles, memory_modelt model, const std::set& filter) { @@ -519,7 +519,7 @@ class event_grapht } void set_parameters_collection( - unsigned _max_var=0, + unsigned _max_var=0, unsigned _max_po_trans=0, bool _ignore_arrays=false) { @@ -528,7 +528,7 @@ class event_grapht ignore_arrays = _ignore_arrays; } - /* collects all the pairs of events with respectively at least one cmp, + /* collects all the pairs of events with respectively at least one cmp, regardless of the architecture (Pensieve'05 strategy) */ void collect_pairs(namespacet& ns) { diff --git a/src/goto-instrument/wmm/goto2graph.cpp b/src/goto-instrument/wmm/goto2graph.cpp index 33396df148f..59e7f97f903 100644 --- a/src/goto-instrument/wmm/goto2graph.cpp +++ b/src/goto-instrument/wmm/goto2graph.cpp @@ -35,9 +35,9 @@ Date: 2012 Function: instrumentert::local Inputs: - + Outputs: - + Purpose: is local variable? \*******************************************************************/ @@ -61,7 +61,7 @@ bool inline instrumentert::local(const irep_idt& id) identifier=="sys_nerr" || has_prefix(identifier, "__unbuffered_")) return true; - + const size_t pos = identifier.find("[]"); if(pos!=std::string::npos) @@ -97,15 +97,15 @@ bool inline instrumentert::cfg_visitort::local(const irep_idt& i) /*******************************************************************\ Function: instrumentert::goto2graph_cfg - + Inputs: - + Outputs: - + Purpose: goes through CFG and build a static abstract event graph overapproximating the read/write relations for any executions - + \*******************************************************************/ unsigned instrumentert::goto2graph_cfg( @@ -119,7 +119,7 @@ unsigned instrumentert::goto2graph_cfg( /* builds the graph following the CFG */ cfg_visitort visitor(ns, *this); - visitor.visit_cfg(value_sets, model, no_dependencies, duplicate_body, + visitor.visit_cfg(value_sets, model, no_dependencies, duplicate_body, goto_functions.entry_point()); std::vector subgraph_index; @@ -162,13 +162,13 @@ unsigned instrumentert::goto2graph_cfg( /*******************************************************************\ Function: instrumentert::cfg_visitort::visit_cfg_function - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_function( @@ -199,7 +199,7 @@ void instrumentert::cfg_visitort::visit_cfg_function( #endif /* goes through the function */ - Forall_goto_program_instructions(i_it, + Forall_goto_program_instructions(i_it, instrumenter.goto_functions.function_map[function].body) { goto_programt::instructiont& instruction=*i_it; @@ -234,7 +234,7 @@ void instrumentert::cfg_visitort::visit_cfg_function( #else /* propagates */ visit_cfg_propagate(i_it); - #endif + #endif } /* a:=b -o-> Rb -po-> Wa */ @@ -264,7 +264,7 @@ void instrumentert::cfg_visitort::visit_cfg_function( visit_cfg_skip(i_it); } - else if(instruction.is_other() + else if(instruction.is_other() && instruction.code.get_statement()==ID_fence) { visit_cfg_asm_fence(i_it); @@ -272,7 +272,7 @@ void instrumentert::cfg_visitort::visit_cfg_function( else if(instruction.is_function_call()) { - visit_cfg_function_call(value_sets, i_it, model, + visit_cfg_function_call(value_sets, i_it, model, no_dependencies, replicate_body); } @@ -289,7 +289,7 @@ void instrumentert::cfg_visitort::visit_cfg_function( else if(instruction.is_return()) { visit_cfg_propagate(i_it); - add_all_pos(it, out_nodes[function], in_pos[i_it]); + add_all_pos(it, out_nodes[function], in_pos[i_it]); } #endif @@ -315,19 +315,19 @@ void instrumentert::cfg_visitort::visit_cfg_function( .goto_functions.function_map[function].body.instructions.end(); --it; ending_vertex=in_pos[it]; - } + } } /*******************************************************************\ Function: instrumentert::visit_cfg_propagate - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::cfg_visitort::visit_cfg_propagate( @@ -349,13 +349,13 @@ void inline instrumentert::cfg_visitort::visit_cfg_propagate( /*******************************************************************\ Function: instrumentert::visit_cfg_thread - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_thread() const @@ -365,18 +365,18 @@ void instrumentert::cfg_visitort::visit_cfg_thread() const /*******************************************************************\ Function: instrumentert::visit_cfg_reference_function - + Inputs: - + Outputs: - + Purpose: references the first and last edges of the function - + \*******************************************************************/ /* OBSOLETE */ /* Note: can be merged with visit_cfg_body */ -/* Warning: we iterate here over the successive instructions of the +/* Warning: we iterate here over the successive instructions of the regardless of the gotos. This function has to be called *AFTER* an exploration of the function constructing the graph. */ void inline instrumentert::cfg_visitort::visit_cfg_reference_function ( @@ -467,19 +467,19 @@ void inline instrumentert::cfg_visitort::visit_cfg_reference_function ( /*******************************************************************\ Function: alt_copy_segment - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ -unsigned alt_copy_segment(graph& alt_egraph, +unsigned alt_copy_segment(graph& alt_egraph, unsigned begin, unsigned end) { - /* no need to duplicate the loop nodes for the SCC-detection graph -- a + /* no need to duplicate the loop nodes for the SCC-detection graph -- a single back-edge will ensure the same connectivity */ alt_egraph.add_edge(end, begin); return end; @@ -488,17 +488,17 @@ unsigned alt_copy_segment(graph& alt_egraph, /*******************************************************************\ Function: instrumentert::visit_cfg_visitort::contains_shared_array - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ bool instrumentert::cfg_visitort::contains_shared_array( - goto_programt::const_targett targ, + goto_programt::const_targett targ, goto_programt::const_targett i_it, value_setst& value_sets #ifdef LOCAL_MAY @@ -506,11 +506,11 @@ bool instrumentert::cfg_visitort::contains_shared_array( #endif ) const { - instrumenter.message.debug() << "contains_shared_array called for " - << targ->source_location.get_line() << " and " + instrumenter.message.debug() << "contains_shared_array called for " + << targ->source_location.get_line() << " and " << i_it->source_location.get_line() << messaget::eom; for(goto_programt::const_targett cur=targ; cur!=i_it; ++cur) - { + { instrumenter.message.debug() << "Do we have an array at line " <source_location.get_line()<<"?" << messaget::eom; rw_set_loct rw_set(ns, value_sets, cur @@ -524,18 +524,18 @@ bool instrumentert::cfg_visitort::contains_shared_array( forall_rw_set_r_entries(r_it, rw_set) { const irep_idt var=r_it->second.object; - instrumenter.message.debug() << "Is "<second.object; instrumenter.message.debug()<<"Is "<function]; - + bool found_pos=false; goto_programt::instructiont::targett new_targ=targ; if(in_pos[targ].empty()) { /* tries to find the next node after the back edge */ - for(; new_targ!=fun.body.instructions.end(); + for(; new_targ!=fun.body.instructions.end(); ++new_targ) { if(in_pos.find(new_targ)!=in_pos.end() && !in_pos[new_targ].empty()) @@ -639,7 +639,7 @@ void inline instrumentert::cfg_visitort::visit_cfg_duplicate( } } - if(!found_pos + if(!found_pos || new_targ->source_location.get_function() !=targ->source_location.get_function() || new_targ->source_location.get_file() @@ -674,23 +674,23 @@ void inline instrumentert::cfg_visitort::visit_cfg_duplicate( #endif } } -} +} /*******************************************************************\ Function: instrumentert::visit_cfg_visitort::visit_cfg_backedge - + Inputs: - + Outputs: - + Purpose: strategy: fwd/bwd alternation - + \*******************************************************************/ void inline instrumentert::cfg_visitort::visit_cfg_backedge( goto_programt::targett targ, goto_programt::targett i_it) -{ +{ /* if in_pos was updated at this program point */ if(updated.find(targ)!=updated.end()) { @@ -717,11 +717,11 @@ void inline instrumentert::cfg_visitort::visit_cfg_backedge( for(goto_programt::instructionst::iterator cur=i_it; cur!=targ; --cur) { - for(std::set::const_iterator + for(std::set::const_iterator t=cur->incoming_edges.begin(); t!=cur->incoming_edges.end(); ++t) { - if(in_pos.find(*t)!=in_pos.end() + if(in_pos.find(*t)!=in_pos.end() && updated.find(*t)!=updated.end()) { /* out_pos[*t].insert(in_pos[*t])*/ @@ -756,13 +756,13 @@ void inline instrumentert::cfg_visitort::visit_cfg_backedge( /*******************************************************************\ Function: instrumentert::visit_cfg_goto - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_goto( @@ -780,12 +780,12 @@ void instrumentert::cfg_visitort::visit_cfg_goto( visit_cfg_propagate(i_it); /* if back-edges, constructs them too: - if goto to event, connects previously propagated events to it; + if goto to event, connects previously propagated events to it; if not, we need to find which events AFTER the target are to be connected. We do a backward analysis. */ if(instruction.is_backwards_goto()) { - instrumenter.message.debug() << "backward goto" << messaget::eom; + instrumenter.message.debug() << "backward goto" << messaget::eom; visit_cfg_body(i_it, replicate_body, value_sets #ifdef LOCAL_MAY , local_may @@ -799,15 +799,15 @@ void instrumentert::cfg_visitort::visit_cfg_goto( Function: intrumentert::visit_cfg_function_call Inputs: - + Outputs: - - Purpose: + + Purpose: \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_function_call( - value_setst& value_sets, + value_setst& value_sets, goto_programt::instructionst::iterator i_it, memory_modelt model, bool no_dependencies, @@ -833,9 +833,9 @@ void instrumentert::cfg_visitort::visit_cfg_function_call( #endif #if 0 - if(!inline_function_cond(fun_id)) + if(!inline_function_cond(fun_id)) { - /* do not inline it, connect to an existing subgraph or create a new + /* do not inline it, connect to an existing subgraph or create a new one */ if(instrumenter.map_function_graph.find(fun_id)!=instrumenter.map_function_graph.end()) { @@ -850,11 +850,11 @@ void instrumentert::cfg_visitort::visit_cfg_function_call( updated.insert(i_it); } } - else + else #endif { /* normal inlining strategy */ - visit_cfg_function(value_sets, model, no_dependencies, replicate_body, + visit_cfg_function(value_sets, model, no_dependencies, replicate_body, fun_id, s, in_pos[i_it]); updated.insert(i_it); } @@ -873,13 +873,13 @@ void instrumentert::cfg_visitort::visit_cfg_function_call( /*******************************************************************\ Function: instrumentert::visit_cfg_lwfence - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_lwfence( @@ -917,13 +917,13 @@ void instrumentert::cfg_visitort::visit_cfg_lwfence( /*******************************************************************\ Function: instrumentert::visit_cfg_lwfence - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_asm_fence( @@ -969,13 +969,13 @@ void instrumentert::cfg_visitort::visit_cfg_asm_fence( /*******************************************************************\ Function: instrumentert::visit_cfg_assign - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_assign( @@ -1001,7 +1001,7 @@ void instrumentert::cfg_visitort::visit_cfg_assign( unsigned previous_gnode=(unsigned)-1; #if 0 - /* for the moment, use labels ASSERT in front of the assertions + /* for the moment, use labels ASSERT in front of the assertions to prevent them from being instrumented */ if(instruction.is_assert()) continue; // return; @@ -1090,7 +1090,7 @@ void instrumentert::cfg_visitort::visit_cfg_assign( /* for unknown writes */ for(std::set::const_iterator id_it= unknown_write_nodes.begin(); - id_it!=unknown_write_nodes.end(); + id_it!=unknown_write_nodes.end(); ++id_it) if(egraph[*id_it].thread != new_read_event.thread) { @@ -1179,7 +1179,7 @@ void instrumentert::cfg_visitort::visit_cfg_assign( idr_it!=r_with_same_var.second; idr_it++) if(egraph[idr_it->second].thread != new_write_event.thread) { - instrumenter.message.debug() <second<<"<-com->" + instrumenter.message.debug() <second<<"<-com->" <::const_iterator entry= instrumenter.map_vertex_gnode.find(idr_it->second); @@ -1300,13 +1300,13 @@ void instrumentert::cfg_visitort::visit_cfg_assign( /*******************************************************************\ Function: instrumentert::visit_cfg_fence - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_fence( @@ -1351,15 +1351,15 @@ void instrumentert::cfg_visitort::visit_cfg_fence( Function: intrumentert::visit_cfg_skip Inputs: - + Outputs: - - Purpose: + + Purpose: \*******************************************************************/ void instrumentert::cfg_visitort::visit_cfg_skip( - goto_programt::instructionst::iterator i_it) + goto_programt::instructionst::iterator i_it) { visit_cfg_propagate(i_it); } @@ -1369,10 +1369,10 @@ void instrumentert::cfg_visitort::visit_cfg_skip( Function: intrumentert::add_instr_to_interleaving Inputs: - + Outputs: - - Purpose: + + Purpose: \*******************************************************************/ @@ -1415,13 +1415,13 @@ void inline instrumentert::add_instr_to_interleaving ( /*******************************************************************\ Function: instrumentert::is_cfg_spurious - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) @@ -1429,7 +1429,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) message.debug() << "spurious by CFG? " << messaget::eom; goto_programt interleaving; - for(event_grapht::critical_cyclet::const_iterator e_it=cyc.begin(); + for(event_grapht::critical_cyclet::const_iterator e_it=cyc.begin(); e_it!=cyc.end() && ++e_it!=cyc.end(); ++e_it) { --e_it; @@ -1483,7 +1483,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) { /* add all the instructions of this line */ for(goto_programt::instructionst::iterator same_loc=i_it; - same_loc!=current_po->instructions.end() + same_loc!=current_po->instructions.end() && same_loc->source_location==i_it->source_location; same_loc++) add_instr_to_interleaving(same_loc, interleaving); @@ -1504,7 +1504,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) if(it->source_location==current_location) in_cycle = true; - /* do not add the last instruction now -- will be done at + /* do not add the last instruction now -- will be done at the next iteration */ if(it->source_location==next_location) break; @@ -1515,7 +1515,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) } } - /* if a goto points to a label outside from this interleaving, replace it + /* if a goto points to a label outside from this interleaving, replace it by an assert 0 */ Forall_goto_program_instructions(int_it, interleaving) if(int_it->is_goto()) @@ -1558,16 +1558,16 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc) this_interleaving.function_map = map; optionst no_option; null_message_handlert no_message; - + #if 0 bmct bmc(no_option, symbol_table, no_message); bool is_spurious = bmc.run(this_interleaving); - + message.debug() << "CFG:"<::iterator + for(std::set::iterator it=set_of_cycles.begin(); it!=set_of_cycles.end(); ) @@ -1634,13 +1634,13 @@ void instrumentert::cfg_cycles_filter() /*******************************************************************\ Function: instrumentert::print_outputs - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::print_outputs_local( @@ -1674,7 +1674,7 @@ void inline instrumentert::print_outputs_local( it->print_dot(dot,colour++,model); ref << it->print_name(model, hide_internals) << std::endl; output << it->print_output() << std::endl; - all << it->print_all(model, map_id2var, map_var2id, hide_internals) + all << it->print_all(model, map_id2var, map_var2id, hide_internals) << std::endl; /* emphasises instrumented events */ @@ -1707,9 +1707,9 @@ void inline instrumentert::print_outputs_local( for(unsigned i=0; i<=max_thread; i++) if(!same_po[i].empty()) { - dot << "{rank=same; thread_" << i + dot << "{rank=same; thread_" << i << "[shape=plaintext, label=\"thread " << i << "\"];"; - for(std::set::iterator it=same_po[i].begin(); + for(std::set::iterator it=same_po[i].begin(); it!=same_po[i].end(); it++) dot << egraph[*it].id << ";"; dot << "};" << std::endl; @@ -1799,13 +1799,13 @@ void instrumentert::print_outputs(memory_modelt model, bool hide_internals) /*******************************************************************\ Function: instrumentert::collect_cycles_by_SCCs - + Inputs: - + Outputs: - + Purpose: Note: can be distributed (#define DISTRIBUTED) - + \*******************************************************************/ #if 1 @@ -1830,7 +1830,7 @@ class pthread_argumentt std::set& cycles; pthread_argumentt(instrumentert& _instr, - memory_modelt _mem, + memory_modelt _mem, const std::set& _filter, std::set& _cycles) :instr(_instr),mem(_mem),filter(_filter),cycles(_cycles) @@ -1845,7 +1845,7 @@ void* collect_cycles_in_thread(void* arg) instrumentert& this_instrumenter = ((pthread_argumentt*) arg)->instr; memory_modelt model = ((pthread_argumentt*) arg)->mem; const std::set& filter = ((pthread_argumentt*) arg)->filter; - std::set& cycles = + std::set& cycles = ((pthread_argumentt*) arg)->cycles; this_instrumenter.egraph.collect_cycles(cycles, model, filter); diff --git a/src/goto-instrument/wmm/goto2graph.h b/src/goto-instrument/wmm/goto2graph.h index a1c4211037f..8eea136dcc5 100644 --- a/src/goto-instrument/wmm/goto2graph.h +++ b/src/goto-instrument/wmm/goto2graph.h @@ -34,7 +34,7 @@ class instrumentert namespacet ns; protected: - goto_functionst &goto_functions; + goto_functionst &goto_functions; /* alternative representation of graph (SCC) */ std::map map_vertex_gnode; @@ -84,16 +84,16 @@ class instrumentert typedef std::set target_sett; - class cfg_visitort + class cfg_visitort { - protected: + protected: namespacet& ns; instrumentert& instrumenter; /* pointer to the egraph(s) that we construct */ event_grapht& egraph; - std::vector >& egraph_SCCs; - graph& egraph_alt; + std::vector >& egraph_SCCs; + graph& egraph_alt; /* for thread marking (dynamic) */ unsigned current_thread; @@ -112,16 +112,16 @@ class instrumentert void visit_cfg_thread() const; void visit_cfg_propagate(goto_programt::instructionst::iterator i_it); void visit_cfg_body( - goto_programt::instructionst::iterator i_it, + goto_programt::instructionst::iterator i_it, loop_strategyt replicate_body, value_setst& value_sets #ifdef LOCAL_MAY , local_may_aliast& local_may #endif ); // deprecated - void inline visit_cfg_backedge(goto_programt::targett targ, + void inline visit_cfg_backedge(goto_programt::targett targ, goto_programt::targett i_it); - void inline visit_cfg_duplicate(goto_programt::targett targ, + void inline visit_cfg_duplicate(goto_programt::targett targ, goto_programt::targett i_it); void visit_cfg_assign(value_setst& value_sets, namespacet& ns, goto_programt::instructionst::iterator& i_it, bool no_dependencies @@ -133,8 +133,8 @@ class instrumentert void visit_cfg_skip(goto_programt::instructionst::iterator i_it); void visit_cfg_lwfence(goto_programt::instructionst::iterator i_it); void visit_cfg_asm_fence(goto_programt::instructionst::iterator i_it); - void visit_cfg_function_call(value_setst& value_sets, - goto_programt::instructionst::iterator i_it, + void visit_cfg_function_call(value_setst& value_sets, + goto_programt::instructionst::iterator i_it, memory_modelt model, bool no_dependenciess, loop_strategyt duplicate_body); @@ -169,14 +169,14 @@ class instrumentert /* previous nodes (fwd analysis) */ typedef std::pair nodet; - typedef std::map > + typedef std::map > incoming_post; incoming_post in_pos; std::set updated; /* "next nodes" (bwd steps in fwd/bck analysis) */ - incoming_post out_pos; + incoming_post out_pos; #define add_all_pos(it, target, source) \ for(std::set::const_iterator \ @@ -206,7 +206,7 @@ class instrumentert cfg_visitort(namespacet& _ns, instrumentert& _instrumenter) :ns(_ns), instrumenter(_instrumenter), egraph(_instrumenter.egraph), - egraph_SCCs(_instrumenter.egraph_SCCs), + egraph_SCCs(_instrumenter.egraph_SCCs), egraph_alt(_instrumenter.egraph_alt) { write_counter = 0; @@ -287,7 +287,7 @@ class instrumentert std::vector > set_of_cycles_per_SCC; unsigned num_sccs; - /* map from function to begin and end of the corresponding part of the + /* map from function to begin and end of the corresponding part of the graph */ typedef std::map, std::set > > map_function_nodest; @@ -314,17 +314,17 @@ class instrumentert } } - /* variables to instrument, locations of variables to instrument on + /* variables to instrument, locations of variables to instrument on the cycles, and locations of all the variables on the critical cycles */ - /* TODO: those maps are here to interface easily with weak_mem.cpp, + /* TODO: those maps are here to interface easily with weak_mem.cpp, but a rewriting of weak_mem can eliminate them */ std::set var_to_instr; std::multimap id2loc; std::multimap id2cycloc; - instrumentert(symbol_tablet& _symbol_table, goto_functionst& _goto_f, + instrumentert(symbol_tablet& _symbol_table, goto_functionst& _goto_f, messaget& _message) - :ns(_symbol_table), goto_functions(_goto_f), render_po_aligned(true), + :ns(_symbol_table), goto_functions(_goto_f), render_po_aligned(true), render_by_file(false), render_by_function(false), message(_message), egraph(_message) { @@ -382,9 +382,9 @@ class instrumentert } /* prints outputs: - - cycles.dot: graph of the instrumented cycles + - cycles.dot: graph of the instrumented cycles - ref.txt: names of the instrumented cycles - - output.txt: names of the instructions in the code + - output.txt: names of the instructions in the code - all.txt: all */ void print_outputs(memory_modelt model, bool hide_internals); }; diff --git a/src/goto-instrument/wmm/instrumenter_pensieve.h b/src/goto-instrument/wmm/instrumenter_pensieve.h index e97fe036597..e655f5037b9 100644 --- a/src/goto-instrument/wmm/instrumenter_pensieve.h +++ b/src/goto-instrument/wmm/instrumenter_pensieve.h @@ -19,7 +19,7 @@ class namespacet; class instrumenter_pensievet:public instrumentert { public: - instrumenter_pensievet(symbol_tablet& _symbol_table, + instrumenter_pensievet(symbol_tablet& _symbol_table, goto_functionst& _goto_f, messaget& message) : instrumentert(_symbol_table, _goto_f, message) { diff --git a/src/goto-instrument/wmm/instrumenter_strategies.cpp b/src/goto-instrument/wmm/instrumenter_strategies.cpp index 6f39f589d33..f2e98d5d8f0 100644 --- a/src/goto-instrument/wmm/instrumenter_strategies.cpp +++ b/src/goto-instrument/wmm/instrumenter_strategies.cpp @@ -23,13 +23,13 @@ Date: 2012 /*******************************************************************\ Function: instrumentert::instrument_with_strategy - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) @@ -94,13 +94,13 @@ void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) /*******************************************************************\ Function: instrumentert::instrument_all_inserter - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_all_inserter( @@ -132,13 +132,13 @@ void inline instrumentert::instrument_all_inserter( /*******************************************************************\ Function: instrumentert::instrument_one_event_per_cycle - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_one_event_per_cycle_inserter( @@ -166,7 +166,7 @@ void inline instrumentert::instrument_one_event_per_cycle_inserter( } if(next) - continue; + continue; /* instruments the first pair */ for(std::set::iterator @@ -193,13 +193,13 @@ void inline instrumentert::instrument_one_event_per_cycle_inserter( /*******************************************************************\ Function: instrumentert::instrument_one_read_per_cycle - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_one_read_per_cycle_inserter( @@ -212,13 +212,13 @@ void inline instrumentert::instrument_one_read_per_cycle_inserter( /*******************************************************************\ Function: instrumentert::instrument_one_write_per_cycle - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_one_write_per_cycle_inserter( @@ -231,19 +231,19 @@ void inline instrumentert::instrument_one_write_per_cycle_inserter( /*******************************************************************\ Function: instrumentert::cost - + Inputs: - + Outputs: - + Purpose: cost function - + \*******************************************************************/ unsigned inline instrumentert::cost( - const event_grapht::critical_cyclet::delayt& e) + const event_grapht::critical_cyclet::delayt& e) { - /* cost(poW*)=1 + /* cost(poW*)=1 cost(poRW)=cost(rfe)=2 cost(poRR)=3 */ if(egraph[e.first].operation==abstract_eventt::Write) @@ -258,26 +258,26 @@ unsigned inline instrumentert::cost( /*******************************************************************\ Function: instrumentert::instrument_minimum_interference - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_minimum_interference_inserter( const std::set& set_of_cycles) { /* Idea: - We solve this by a linear programming approach, + We solve this by a linear programming approach, using for instance glpk lib. Input: the edges to instrument E, the cycles C_j Pb: min sum_{e_i in E} d(e_i).x_i s.t. for all j, sum_{e_i in C_j} >= 1, - where e_i is a pair to potentially instrument, + where e_i is a pair to potentially instrument, x_i is a Boolean stating whether we instrument e_i, and d() is the cost of an instrumentation. Output: the x_i, saying which pairs to instrument @@ -287,15 +287,15 @@ void inline instrumentert::instrument_minimum_interference_inserter( d(poRW)=d(rfe)=2 d(poRR)=3 - This function can be refined with the actual times - we get in experimenting the different pairs in a + This function can be refined with the actual times + we get in experimenting the different pairs in a single IRIW. */ - + #ifdef HAVE_GLPK /* first, identify all the unsafe pairs */ std::set edges; - for(std::set::iterator + for(std::set::iterator C_j=set_of_cycles.begin(); C_j!=set_of_cycles.end(); ++C_j) @@ -314,14 +314,14 @@ void inline instrumentert::instrument_minimum_interference_inserter( lp=glp_create_prob(); glp_set_prob_name(lp, "instrumentation optimisation"); glp_set_obj_dir(lp, GLP_MIN); - + message.debug() << "edges: "<::iterator + for(std::set::iterator e_i=edges.begin(); e_i!=edges.end(); ++e_i) @@ -354,7 +354,7 @@ void inline instrumentert::instrument_minimum_interference_inserter( int* imat=(int*)malloc(sizeof(int)*(mat_size+1)); int* jmat=(int*)malloc(sizeof(int)*(mat_size+1)); double* vmat=(double*)malloc(sizeof(double)*(mat_size+1)); - + /* fills the constraints coeff */ /* tables read from 1 in glpk -- first row/column ignored */ unsigned col=1; @@ -394,7 +394,7 @@ void inline instrumentert::instrument_minimum_interference_inserter( glp_intopt(lp, &parm); /* loads results (x_i) */ - message.statistics() << "minimal cost: " << glp_mip_obj_val(lp) + message.statistics() << "minimal cost: " << glp_mip_obj_val(lp) << messaget::eom; i=0; for(std::set::iterator @@ -432,13 +432,13 @@ void inline instrumentert::instrument_minimum_interference_inserter( /*******************************************************************\ Function: instrumentert::instrument_my_events_inserter - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void inline instrumentert::instrument_my_events_inserter( @@ -475,13 +475,13 @@ void inline instrumentert::instrument_my_events_inserter( /*******************************************************************\ Function: instrumentert::instrument_my_events - + Inputs: - + Outputs: - + Purpose: - + \*******************************************************************/ void instrumentert::instrument_my_events(const std::set& my_events) diff --git a/src/goto-instrument/wmm/pair_collection.cpp b/src/goto-instrument/wmm/pair_collection.cpp index 87e53ed797d..475e094c550 100644 --- a/src/goto-instrument/wmm/pair_collection.cpp +++ b/src/goto-instrument/wmm/pair_collection.cpp @@ -1,6 +1,6 @@ /*******************************************************************\ -Module: collection of pairs (for Pensieve's static delay-set +Module: collection of pairs (for Pensieve's static delay-set analysis) in graph of abstract events Author: @@ -50,18 +50,18 @@ void event_grapht::graph_pensieve_explorert::collect_pairs(namespacet& ns) continue; /* find Y s.t. X --po-- Y and Y --cmp-- B, by rules (2) + (4) */ - if(find_second_event(first)) + if(find_second_event(first)) { const abstract_eventt& first_event=egraph[first]; - + try { /* directly outputs */ - OUTPUT(res, "fence", first_event.source_location.get_file(), - first_event.source_location.get_line(), first_event.variable, + OUTPUT(res, "fence", first_event.source_location.get_file(), + first_event.source_location.get_line(), first_event.variable, first_event.operation); - } catch (std::string s) { + } catch (std::string s) { egraph.message.warning() << "failed to find" << s << messaget::eom; - continue; + continue; } } } @@ -82,7 +82,7 @@ Function: event_grapht::graph_explorert::find_second_event \*******************************************************************/ bool event_grapht::graph_pensieve_explorert::find_second_event( - unsigned current) + unsigned current) { if(visited_nodes.find(current)!=visited_nodes.end()) return false; @@ -102,4 +102,3 @@ bool event_grapht::graph_pensieve_explorert::find_second_event( return false; } - diff --git a/src/goto-instrument/wmm/shared_buffers.cpp b/src/goto-instrument/wmm/shared_buffers.cpp index 6f0b4933517..4bc6236768a 100644 --- a/src/goto-instrument/wmm/shared_buffers.cpp +++ b/src/goto-instrument/wmm/shared_buffers.cpp @@ -10,7 +10,7 @@ Function: shared_buffert::unique Inputs: - + Outputs: Purpose: returns a unique id (for fresh variables) @@ -39,9 +39,9 @@ const shared_bufferst::varst &shared_bufferst::operator()(const irep_idt &object { var_mapt::const_iterator it=var_map.find(object); if(it!=var_map.end()) return it->second; - + varst &vars=var_map[object]; - + namespacet ns(symbol_table); const symbolt &symbol=ns.lookup(object); @@ -50,18 +50,18 @@ const shared_bufferst::varst &shared_bufferst::operator()(const irep_idt &object vars.w_buff0=add(object, symbol.base_name, "$w_buff0", symbol.type); vars.w_buff1=add(object, symbol.base_name, "$w_buff1", symbol.type); - vars.w_buff0_used=add(object, symbol.base_name, "$w_buff0_used", + vars.w_buff0_used=add(object, symbol.base_name, "$w_buff0_used", bool_typet()); - vars.w_buff1_used=add(object, symbol.base_name, "$w_buff1_used", + vars.w_buff1_used=add(object, symbol.base_name, "$w_buff1_used", bool_typet()); vars.mem_tmp=add(object, symbol.base_name, "$mem_tmp", symbol.type); - vars.flush_delayed=add(object, symbol.base_name, "$flush_delayed", + vars.flush_delayed=add(object, symbol.base_name, "$flush_delayed", bool_typet()); - vars.read_delayed=add(object, symbol.base_name, "$read_delayed", + vars.read_delayed=add(object, symbol.base_name, "$read_delayed", bool_typet()); - vars.read_delayed_var=add(object, symbol.base_name, "$read_delayed_var", + vars.read_delayed_var=add(object, symbol.base_name, "$read_delayed_var", pointer_typet(symbol.type)); unsigned cnt; @@ -140,17 +140,17 @@ void shared_bufferst::add_initialization(goto_programt &goto_program) source_locationt source_location; source_location.make_nil(); - assignment(goto_program, t, source_location, it->second.w_buff0_used, + assignment(goto_program, t, source_location, it->second.w_buff0_used, false_exprt()); - assignment(goto_program, t, source_location, it->second.w_buff1_used, + assignment(goto_program, t, source_location, it->second.w_buff1_used, false_exprt()); - assignment(goto_program, t, source_location, it->second.flush_delayed, + assignment(goto_program, t, source_location, it->second.flush_delayed, false_exprt()); - assignment(goto_program, t, source_location, it->second.read_delayed, + assignment(goto_program, t, source_location, it->second.read_delayed, false_exprt()); - assignment(goto_program, t, source_location, it->second.read_delayed_var, + assignment(goto_program, t, source_location, it->second.read_delayed_var, null_pointer_exprt(pointer_typet(it->second.type))); - + for( std::vector::const_iterator l_it= it->second.r_buff0_thds.begin(); @@ -235,9 +235,9 @@ void shared_bufferst::assignment( t->code=code_assignt(symbol, value); t->code.add_source_location()=source_location; t->source_location=source_location; - + //instrumentations.insert((const irep_idt) (t->code.id())); - + t++; } catch(std::string s) @@ -271,7 +271,7 @@ void shared_bufferst::delay_read( #if 0 assignment(goto_program, target, source_location, vars.read_delayed, true_exprt()); - assignment(goto_program, target, source_location, vars.read_delayed_var, + assignment(goto_program, target, source_location, vars.read_delayed_var, read_object); const irep_idt& new_var=add_fresh_var(write_object,unique(),vars.type); @@ -293,7 +293,7 @@ void shared_bufferst::delay_read( const symbol_exprt read_object_expr = symbol_exprt(read_object, vars.type); assignment(goto_program, target, source_location, vars.read_delayed, true_exprt()); - assignment(goto_program, target, source_location, vars.read_delayed_var, + assignment(goto_program, target, source_location, vars.read_delayed_var, address_of_exprt( read_object_expr )); } @@ -306,7 +306,7 @@ Function: shared_bufferst::flush_read Outputs: Purpose: flushes read (POWER) - + \*******************************************************************/ void shared_bufferst::flush_read( @@ -324,7 +324,7 @@ void shared_bufferst::flush_read( const symbol_exprt var_expr=symbol_exprt(vars.read_delayed_var, vars.type); const exprt eq_expr=equal_exprt(var_expr, fresh_var_expr); - const symbol_exprt cond_delayed_expr=symbol_exprt(vars.read_delayed, + const symbol_exprt cond_delayed_expr=symbol_exprt(vars.read_delayed, bool_typet()); const exprt if_expr=if_exprt(cond_delayed_expr, eq_expr, true_exprt()); @@ -372,14 +372,14 @@ void shared_bufferst::write( // We rotate the write buffers for anything that is written. assignment(goto_program, target, source_location, vars.w_buff1, vars.w_buff0); assignment( - goto_program, target, source_location, vars.w_buff0, + goto_program, target, source_location, vars.w_buff0, original_instruction.code.op1()); // We update the used flags assignment(goto_program, target, source_location, vars.w_buff1_used, vars.w_buff0_used); assignment(goto_program, target, source_location, vars.w_buff0_used, true_exprt()); - // We should not exceed the buffer size -- inserts assertion for dynamically + // We should not exceed the buffer size -- inserts assertion for dynamically // checking this const exprt buff0_used_expr=symbol_exprt(vars.w_buff0_used, bool_typet()); const exprt buff1_used_expr=symbol_exprt(vars.w_buff1_used, bool_typet()); @@ -395,7 +395,7 @@ void shared_bufferst::write( // We update writers ownership of the values in the buffer for(unsigned cnt=0; cnt ); if not, if buff1 from this thread, uses + // if buff0 from this thread, uses it to update the memory (the most recent + // value, or last write by -ws-> ); if not, if buff1 from this thread, uses // it; if not, keeps the current memory value const exprt buff0_expr = symbol_exprt(vars.w_buff0, vars.type); const exprt buff1_expr = symbol_exprt(vars.w_buff1, vars.type); @@ -441,14 +441,14 @@ void shared_bufferst::det_flush( const exprt buff0_used_expr = symbol_exprt(vars.w_buff0_used, bool_typet()); const exprt buff1_used_expr = symbol_exprt(vars.w_buff1_used, bool_typet()); - const exprt buff0_mine_expr = symbol_exprt(vars.r_buff0_thds[current_thread], + const exprt buff0_mine_expr = symbol_exprt(vars.r_buff0_thds[current_thread], bool_typet()); - const exprt buff1_mine_expr = symbol_exprt(vars.r_buff1_thds[current_thread], + const exprt buff1_mine_expr = symbol_exprt(vars.r_buff1_thds[current_thread], bool_typet()); - const exprt buff0_used_and_mine_expr = and_exprt(buff0_used_expr, + const exprt buff0_used_and_mine_expr = and_exprt(buff0_used_expr, buff0_mine_expr); - const exprt buff1_used_and_mine_expr = and_exprt(buff1_used_expr, + const exprt buff1_used_and_mine_expr = and_exprt(buff1_used_expr, buff1_mine_expr); const exprt new_value_expr = if_exprt( @@ -460,12 +460,12 @@ void shared_bufferst::det_flush( lhs ) ); - + // We update (or not) the value in the memory assignment(goto_program, target, source_location, object, new_value_expr); // We udpate the flags of the buffer - // if buff0 used and mine, then it is no more used, as we flushed the last + // if buff0 used and mine, then it is no more used, as we flushed the last // write and -ws-> imposes not to have other writes in the buffer assignment(goto_program, target, source_location, vars.w_buff0_used, if_exprt( @@ -480,7 +480,7 @@ void shared_bufferst::det_flush( // otherwise, remains as it is const exprt buff0_or_buff1_used_and_mine_expr = or_exprt( buff0_used_and_mine_expr, - buff1_used_and_mine_expr + buff1_used_and_mine_expr ); assignment(goto_program, target, source_location, vars.w_buff1_used, @@ -489,14 +489,14 @@ void shared_bufferst::det_flush( false_exprt(), buff1_used_expr ) - ); + ); // We update the ownerships // if buff0 mine and used, flushed, so belongs to nobody - const exprt buff0_thd_expr = symbol_exprt(vars.r_buff0_thds[current_thread], + const exprt buff0_thd_expr = symbol_exprt(vars.r_buff0_thds[current_thread], bool_typet()); - assignment(goto_program, target, source_location, vars.r_buff0_thds[current_thread], + assignment(goto_program, target, source_location, vars.r_buff0_thds[current_thread], if_exprt( buff0_used_and_mine_expr, false_exprt(), @@ -504,9 +504,9 @@ void shared_bufferst::det_flush( ) ); - // if buff1 used and mine, or if buff0 used and mine, then buff1 flushed and + // if buff1 used and mine, or if buff0 used and mine, then buff1 flushed and // doesn't belong to anybody - const exprt buff1_thd_expr = symbol_exprt(vars.r_buff1_thds[current_thread], + const exprt buff1_thd_expr = symbol_exprt(vars.r_buff1_thds[current_thread], bool_typet()); assignment(goto_program, target, source_location, vars.r_buff1_thds[current_thread], @@ -516,7 +516,7 @@ void shared_bufferst::det_flush( buff1_thd_expr ) ); -} +} /*******************************************************************\ @@ -550,7 +550,7 @@ void shared_bufferst::nondet_flush( irep_idt choice0=choice(target->function, "0"); irep_idt choice2=choice(target->function, "2"); //delays the write flush - const symbol_exprt choice0_expr=symbol_exprt(choice0, bool_typet()); + const symbol_exprt choice0_expr=symbol_exprt(choice0, bool_typet()); const symbol_exprt delay_expr=symbol_exprt(choice2, bool_typet()); const exprt nondet_bool_expr=side_effect_expr_nondett(bool_typet()); @@ -564,9 +564,9 @@ void shared_bufferst::nondet_flush( const exprt lhs=symbol_exprt(object, vars.type); // Buffer uses - const symbol_exprt buff0_used_expr=symbol_exprt(vars.w_buff0_used, + const symbol_exprt buff0_used_expr=symbol_exprt(vars.w_buff0_used, bool_typet()); - const symbol_exprt buff1_used_expr=symbol_exprt(vars.w_buff1_used, + const symbol_exprt buff1_used_expr=symbol_exprt(vars.w_buff1_used, bool_typet()); // Buffer ownerships @@ -580,7 +580,7 @@ void shared_bufferst::nondet_flush( assignment(goto_program, target, source_location, vars.flush_delayed, delay_expr); assignment(goto_program, target, source_location, vars.mem_tmp, lhs); - // for POWER, only instrumented reads can read from the buffers of other + // for POWER, only instrumented reads can read from the buffers of other // threads bool instrumented=false; @@ -603,7 +603,7 @@ void shared_bufferst::nondet_flush( // 7 cases // (1) (3) (4) - // if buff0 unused + // if buff0 unused // or buff0 not mine and buff1 unused // or buff0 not mine and buff1 not mine // -> read from memory (and does not modify the buffer in any aspect) @@ -665,7 +665,7 @@ void shared_bufferst::nondet_flush( const exprt buff1_5_expr = buff1_expr; const exprt buff0_thd_5_expr = buff0_thd_expr; const exprt buff1_thd_5_expr = false_exprt(); - + // Updates // memory assignment(goto_program, target, source_location, object, if_exprt( @@ -734,7 +734,7 @@ void shared_bufferst::nondet_flush( ) )); // buff0_thd - assignment(goto_program, target, source_location, + assignment(goto_program, target, source_location, vars.r_buff0_thds[current_thread], if_exprt( delay_expr, buff0_thd_expr, @@ -750,7 +750,7 @@ void shared_bufferst::nondet_flush( ) ); // buff1_thd - assignment(goto_program, target, source_location, + assignment(goto_program, target, source_location, vars.r_buff1_thds[current_thread], if_exprt( delay_expr, buff1_thd_expr, @@ -774,14 +774,14 @@ void shared_bufferst::nondet_flush( // One extra non-deterministic choice needed irep_idt choice1=choice(target->function, "1"); const symbol_exprt choice1_expr=symbol_exprt(choice1, bool_typet()); - + // throw Boolean dice assignment(goto_program, target, source_location, choice1, nondet_bool_expr); // 7 cases // (1) - // if buff0 unused + // if buff0 unused // -> read from memory (and does not modify the buffer in any aspect) const exprt cond_1_expr = not_exprt( buff0_used_expr ); const exprt val_1_expr = lhs; @@ -888,7 +888,7 @@ void shared_bufferst::nondet_flush( const exprt buff1_5_expr = buff1_expr; const exprt buff0_thd_5_expr = false_exprt(); const exprt buff1_thd_5_expr = false_exprt(); - + // Updates // memory assignment(goto_program, target, source_location, object, if_exprt( @@ -997,7 +997,7 @@ void shared_bufferst::nondet_flush( ) )); // buff0_thd - assignment(goto_program, target, source_location, + assignment(goto_program, target, source_location, vars.r_buff0_thds[current_thread], if_exprt( delay_expr, buff0_thd_expr, @@ -1021,7 +1021,7 @@ void shared_bufferst::nondet_flush( ) ); // buff1_thd - assignment(goto_program, target, source_location, + assignment(goto_program, target, source_location, vars.r_buff1_thds[current_thread], if_exprt( delay_expr, buff1_thd_expr, @@ -1067,8 +1067,8 @@ Function: is_buffered bool shared_bufferst::is_buffered( const namespacet &ns, const symbol_exprt &symbol_expr, - bool is_write - // are we asking for the variable (false), or for the variable and + bool is_write + // are we asking for the variable (false), or for the variable and // the source_location in the code (true) ) { @@ -1088,7 +1088,7 @@ bool shared_bufferst::is_buffered( if(!symbol.is_static_lifetime) return false; // these are local - + if(symbol.is_thread_local) return false; // these are local @@ -1101,12 +1101,12 @@ bool shared_bufferst::is_buffered( bool shared_bufferst::is_buffered_in_general( const namespacet &ns, const symbol_exprt &symbol_expr, - bool is_write - // are we asking for the variable (false), or for the variable and the + bool is_write + // are we asking for the variable (false), or for the variable and the // source_location in the code? (true) ) { - if(cav11) + if(cav11) return true; const irep_idt &identifier=symbol_expr.get_identifier(); @@ -1117,7 +1117,7 @@ bool shared_bufferst::is_buffered_in_general( if(!is_write) { - // to be uncommented only when we are sure all the cycles + // to be uncommented only when we are sure all the cycles // are detected (before detection of the pairs -- no hack) // WARNING: on the FULL cycle, not reduced by PO /*typedef std::multimap::iterator m_itt; @@ -1146,7 +1146,7 @@ Function: affected_by_delay Outputs: - Purpose: analysis over the goto-program which computes in + Purpose: analysis over the goto-program which computes in affected_by_delay_set the variables (non necessarily shared themselves) whose value could be changed as effect of a read delay @@ -1179,7 +1179,7 @@ void shared_bufferst::affected_by_delay( message.debug() <<"debug: "<second.object) <<" reads from "<second.object) <second.symbol_expr,true)) + if(is_buffered_in_general(ns, r_it->second.symbol_expr,true)) //shouldn't it be true? false => overapprox affected_by_delay_set.insert(w_it->second.object); } @@ -1244,23 +1244,23 @@ void shared_bufferst::cfg_visitort::weak_memory( ); if(rw_set.empty()) continue; - + // add all the written values (which are not instrumentations) // in a set forall_rw_set_w_entries(w_it, rw_set) if(shared_buffers.is_buffered(ns, w_it->second.symbol_expr,false)) past_writes.insert(w_it->second.object); - + goto_programt::instructiont original_instruction; original_instruction.swap(instruction); const source_locationt &source_location= original_instruction.source_location; - // ATOMIC_BEGIN: we make the whole thing atomic + // ATOMIC_BEGIN: we make the whole thing atomic instruction.make_atomic_begin(); instruction.source_location=source_location; i_it++; - + // we first perform (non-deterministically) up to 2 writes for // stuff that is potentially read forall_rw_set_r_entries(e_it, rw_set) @@ -1272,7 +1272,7 @@ void shared_bufferst::cfg_visitort::weak_memory( if(shared_buffers.is_buffered(ns, e_it->second.symbol_expr,false)) shared_buffers.nondet_flush( goto_program, i_it, source_location, e_it->second.object, - current_thread, + current_thread, (model==TSO || model==PSO || model==RMO)); } @@ -1285,14 +1285,14 @@ void shared_bufferst::cfg_visitort::weak_memory( if(shared_buffers.is_buffered(ns, r_it->second.symbol_expr,true)) { shared_buffers.delay_read( - goto_program, i_it, source_location, r_it->second.object, + goto_program, i_it, source_location, r_it->second.object, e_it->second.object); } if(shared_buffers.is_buffered(ns, e_it->second.symbol_expr,true)) { shared_buffers.write( - goto_program, i_it, source_location, + goto_program, i_it, source_location, e_it->second.object,original_instruction, current_thread); } @@ -1304,46 +1304,46 @@ void shared_bufferst::cfg_visitort::weak_memory( if(shared_buffers.affected_by_delay_set.find(r_it->second.object) !=shared_buffers.affected_by_delay_set.end()) { - shared_buffers.message.debug() << "second: " + shared_buffers.message.debug() << "second: " << r_it->second.object << messaget::eom; - const varst &vars=(shared_buffers)(r_it->second.object); + const varst &vars=(shared_buffers)(r_it->second.object); shared_buffers.message.debug() << "writer " <second.object <<" reads "<second.object<< messaget::eom; // TO FIX: how to deal with rhs including calls? - // if a read is delayed, use its alias instead of itself + // if a read is delayed, use its alias instead of itself // -- or not - symbol_exprt to_replace_expr = symbol_exprt( + symbol_exprt to_replace_expr = symbol_exprt( r_it->second.object, vars.type); - symbol_exprt new_read_expr = symbol_exprt( + symbol_exprt new_read_expr = symbol_exprt( vars.read_delayed_var, pointer_typet(vars.type)); - symbol_exprt read_delayed_expr = symbol_exprt( + symbol_exprt read_delayed_expr = symbol_exprt( vars.read_delayed, bool_typet()); // One extra non-deterministic choice needed irep_idt choice1=shared_buffers.choice( instruction.function, "1"); - const symbol_exprt choice1_expr=symbol_exprt(choice1, + const symbol_exprt choice1_expr=symbol_exprt(choice1, bool_typet()); const exprt nondet_bool_expr=side_effect_expr_nondett( bool_typet()); // throw Boolean dice - shared_buffers.assignment(goto_program, i_it, source_location, - choice1, + shared_buffers.assignment(goto_program, i_it, source_location, + choice1, nondet_bool_expr); - exprt rhs = if_exprt( - read_delayed_expr, + exprt rhs = if_exprt( + read_delayed_expr, if_exprt( choice1_expr, dereference_exprt(new_read_expr,vars.type), to_replace_expr), to_replace_expr);//original_instruction.code.op1()); - + shared_buffers.assignment( goto_program, i_it, source_location, r_it->second.object, rhs); @@ -1351,23 +1351,23 @@ void shared_bufferst::cfg_visitort::weak_memory( // normal assignment shared_buffers.assignment( - goto_program, i_it, source_location, + goto_program, i_it, source_location, e_it->second.object, original_instruction.code.op1()); } } - // if last writes was flushed to make the lhs reads the buffer but - // without affecting the memory, restore the previous memory value + // if last writes was flushed to make the lhs reads the buffer but + // without affecting the memory, restore the previous memory value // (buffer flush delay) forall_rw_set_r_entries(e_it, rw_set) if(shared_buffers.is_buffered(ns, e_it->second.symbol_expr,false)) { - shared_buffers.message.debug() << "flush restore: " + shared_buffers.message.debug() << "flush restore: " << e_it->second.object << messaget::eom; const varst vars= (shared_buffers)(e_it->second.object); - const exprt delayed_expr=symbol_exprt(vars.flush_delayed, + const exprt delayed_expr=symbol_exprt(vars.flush_delayed, bool_typet()); - const symbol_exprt mem_value_expr=symbol_exprt(vars.mem_tmp, + const symbol_exprt mem_value_expr=symbol_exprt(vars.mem_tmp, vars.type); const exprt cond_expr=if_exprt(delayed_expr, mem_value_expr, e_it->second.symbol_expr); @@ -1385,16 +1385,16 @@ void shared_bufferst::cfg_visitort::weak_memory( i_it->make_atomic_end(); i_it->source_location=source_location; i_it++; - + i_it--; // the for loop already counts us up } catch (...) { - shared_buffers.message.warning() << "Identifier not found" + shared_buffers.message.warning() << "Identifier not found" << messaget::eom; } } - else if(is_fence(instruction, ns) || (instruction.is_other() + else if(is_fence(instruction, ns) || (instruction.is_other() && instruction.code.get_statement()==ID_fence && (instruction.code.get_bool("WRfence") || instruction.code.get_bool("WWfence") @@ -1412,7 +1412,7 @@ void shared_bufferst::cfg_visitort::weak_memory( i_it++; // does it for all the previous statements - for(std::set::iterator s_it=past_writes.begin(); + for(std::set::iterator s_it=past_writes.begin(); s_it!=past_writes.end(); s_it++) { shared_buffers.det_flush( @@ -1425,9 +1425,9 @@ void shared_bufferst::cfg_visitort::weak_memory( i_it->make_atomic_end(); i_it->source_location=source_location; i_it++; - + i_it--; // the for loop already counts us up - } + } else if(is_lwfence(instruction, ns)) { // po -- remove the lwfence @@ -1440,4 +1440,3 @@ void shared_bufferst::cfg_visitort::weak_memory( } } } - diff --git a/src/goto-instrument/wmm/shared_buffers.h b/src/goto-instrument/wmm/shared_buffers.h index 6cc3a87b1d6..347b2c43d06 100644 --- a/src/goto-instrument/wmm/shared_buffers.h +++ b/src/goto-instrument/wmm/shared_buffers.h @@ -16,7 +16,7 @@ class value_setst; class shared_bufferst { public: - shared_bufferst(symbol_tablet &_symbol_table, unsigned _nb_threads, + shared_bufferst(symbol_tablet &_symbol_table, unsigned _nb_threads, messaget& _message): symbol_table(_symbol_table), nb_threads(_nb_threads+1), @@ -44,23 +44,23 @@ class shared_bufferst // Are those places empty? irep_idt w_buff0_used, w_buff1_used; - // Delays write buffer flush: just to make some swaps between mem and buff - // -- this is to model lhs := rhs with rhs reading in the buffer without - // affecting the memory (Note: we model lhs := rhs by rhs := ..., then + // Delays write buffer flush: just to make some swaps between mem and buff + // -- this is to model lhs := rhs with rhs reading in the buffer without + // affecting the memory (Note: we model lhs := rhs by rhs := ..., then // lhs := rhs) irep_idt mem_tmp; irep_idt flush_delayed; // Thread: Was it me who wrote at this place? std::vector r_buff0_thds, r_buff1_thds; - + // for delayed read: irep_idt read_delayed; irep_idt read_delayed_var; - + typet type; }; - + typedef std::map var_mapt; var_mapt var_map; @@ -73,7 +73,7 @@ class shared_bufferst std::multimap cycles_r_loc; const varst &operator()(const irep_idt &object); - + void add_initialization_code(goto_functionst &goto_functions); void delay_read( @@ -129,7 +129,7 @@ class shared_bufferst const irep_idt &id_rhs) { namespacet ns(symbol_table); - assignment(goto_program, t, source_location, id_lhs, + assignment(goto_program, t, source_location, id_lhs, ns.lookup(id_rhs).symbol_expr()); } @@ -150,18 +150,18 @@ class shared_bufferst const std::string function_base_name = (symbol_table.has_symbol(function)? id2string(symbol_table.lookup(function).base_name): "main"); - return add(function_base_name+"_weak_choice", + return add(function_base_name+"_weak_choice", function_base_name+"_weak_choice", suffix, bool_typet()); } bool is_buffered( - const namespacet&, - const symbol_exprt&, + const namespacet&, + const symbol_exprt&, bool is_write); - + bool is_buffered_in_general( - const namespacet&, - const symbol_exprt&, + const namespacet&, + const symbol_exprt&, bool is_write); void weak_memory( @@ -193,9 +193,9 @@ class shared_bufferst std::set past_writes; public: - cfg_visitort(shared_bufferst& _shared, symbol_tablet& _symbol_table, + cfg_visitort(shared_bufferst& _shared, symbol_tablet& _symbol_table, goto_functionst& _goto_functions) - :shared_buffers(_shared), symbol_table(_symbol_table), + :shared_buffers(_shared), symbol_table(_symbol_table), goto_functions(_goto_functions) { current_thread = 0; @@ -208,10 +208,10 @@ class shared_bufferst const irep_idt& function, memory_modelt model); }; - + protected: class symbol_tablet &symbol_table; - + // number of threads interferring unsigned nb_threads; @@ -244,7 +244,7 @@ class shared_bufferst const irep_idt &object, const irep_idt &base_name, const std::string &suffix, - const typet &type) + const typet &type) { return add(object, base_name, suffix, type, true); } @@ -261,4 +261,3 @@ class shared_bufferst void add_initialization(goto_programt &goto_program); }; - diff --git a/src/goto-instrument/wmm/weak_memory.cpp b/src/goto-instrument/wmm/weak_memory.cpp index 96bcadcdb52..8a15cf532b8 100644 --- a/src/goto-instrument/wmm/weak_memory.cpp +++ b/src/goto-instrument/wmm/weak_memory.cpp @@ -76,7 +76,7 @@ void introduce_temporaries( #endif ); if(rw_set.empty()) continue; - + symbolt new_symbol; new_symbol.base_name="$tmp_guard"; new_symbol.name=id2string(function)+"$tmp_guard"+i2string(tmp_counter++); @@ -84,12 +84,12 @@ void introduce_temporaries( new_symbol.is_static_lifetime=true; new_symbol.is_thread_local=true; new_symbol.value.make_nil(); - + symbol_exprt symbol_expr=new_symbol.symbol_expr(); - + symbolt *symbol_ptr; symbol_table.move(new_symbol, symbol_ptr); - + goto_programt::instructiont new_i; new_i.make_assignment(); new_i.code=code_assignt(symbol_expr, instruction.guard); @@ -138,7 +138,7 @@ void weak_memory( bool render_file, bool render_function, bool cav11_option, - bool hide_internals, + bool hide_internals, message_handlert& message_handler, bool ignore_arrays) { @@ -156,8 +156,8 @@ void weak_memory( Forall_goto_functions(f_it, goto_functions) if(f_it->first!=CPROVER_PREFIX "initialize" && f_it->first!=goto_functionst::entry_point()) - introduce_temporaries(value_sets, symbol_table, f_it->first, - f_it->second.body, + introduce_temporaries(value_sets, symbol_table, f_it->first, + f_it->second.body, #ifdef LOCAL_MAY f_it->second, #endif @@ -167,7 +167,7 @@ void weak_memory( unsigned max_thds = 0; instrumentert instrumenter(symbol_table, goto_functions, message); - max_thds=instrumenter.goto2graph_cfg(value_sets, model, no_dependencies, + max_thds=instrumenter.goto2graph_cfg(value_sets, model, no_dependencies, duplicate_body); message.status()<<"abstraction completed"< events_set = instrumentert::extract_my_events(); instrumenter.instrument_my_events(events_set); - } + } else instrumenter.instrument_with_strategy(event_strategy); @@ -246,13 +246,13 @@ void weak_memory( shared_buffers.affected_by_delay(symbol_table,value_sets,goto_functions); for(std::set::iterator it= - shared_buffers.affected_by_delay_set.begin(); + shared_buffers.affected_by_delay_set.begin(); it!=shared_buffers.affected_by_delay_set.end(); it++) message.debug()<::iterator it=shared_buffers.cycles.begin(); + for(std::set::iterator it=shared_buffers.cycles.begin(); it!=shared_buffers.cycles.end(); it++) { typedef std::multimap::iterator m_itt; @@ -262,7 +262,7 @@ void weak_memory( message.result() << ((*it)==""?"fence":*it)<<", "<second<is_other() || it->is_assign()) { - if(it->code.is_nil()) + if(it->code.is_nil()) it++; else { @@ -80,7 +80,7 @@ void basic_blocks(goto_programt &goto_program, while(end_block!=goto_program.instructions.end() && (end_block->is_other() || end_block->is_assign()) && t_it==targets.end()); - + // replace it with the code of the block { @@ -88,10 +88,10 @@ void basic_blocks(goto_programt &goto_program, for(goto_programt::instructionst::iterator stmt = it; stmt != end_block; - stmt++) + stmt++) if(!stmt->code.is_nil()) new_block.move_to_operands(stmt->code); - + it->code.swap(new_block); it++; if(it!=goto_program.instructions.end()) diff --git a/src/goto-programs/builtin_functions.cpp b/src/goto-programs/builtin_functions.cpp index 355aee85e47..2f90b0f8443 100644 --- a/src/goto-programs/builtin_functions.cpp +++ b/src/goto-programs/builtin_functions.cpp @@ -143,14 +143,14 @@ void goto_convertt::do_prob_coin( const irep_idt &identifier=function.get(ID_identifier); // make it a side effect if there is an LHS - if(arguments.size()!=2) + if(arguments.size()!=2) { error().source_location=function.find_source_location(); error() << "`" << identifier << "' expected to have two arguments" << eom; throw 0; } - + if(lhs.is_nil()) { error().source_location=function.find_source_location(); @@ -285,20 +285,20 @@ void goto_convertt::do_scanf( error() << "scanf takes at least one argument" << eom; throw 0; } - + irep_idt format_string; - + if(!get_string_constant(arguments[0], format_string)) { // use our model format_token_listt token_list=parse_format_string(id2string(format_string)); - + std::size_t argument_number=1; - + for(const auto & t : token_list) { typet type=get_type(t); - + if(type.is_not_nil()) { if(argument_number(rhs.find(ID_sizeof)); bool new_array=rhs.get(ID_statement)==ID_cpp_new_array; - + exprt count; if(new_array) @@ -555,7 +555,7 @@ void goto_convertt::do_cpp_new( // call __new or __new_array exprt new_symbol= ns.lookup(new_array?"__new_array":"__new").symbol_expr(); - + const code_typet &code_type= to_code_type(new_symbol.type()); @@ -567,9 +567,9 @@ void goto_convertt::do_cpp_new( const symbolt &tmp_symbol= new_tmp_symbol(return_type, "new", dest, rhs.source_location()); - + tmp_symbol_expr=tmp_symbol.symbol_expr(); - + code_function_callt new_call; new_call.function()=new_symbol; if(new_array) new_call.arguments().push_back(count); @@ -577,7 +577,7 @@ void goto_convertt::do_cpp_new( new_call.set("#type", lhs.type().subtype()); new_call.lhs()=tmp_symbol_expr; new_call.add_source_location()=rhs.source_location(); - + convert(new_call, dest); } else if(rhs.operands().size()==1) @@ -585,12 +585,12 @@ void goto_convertt::do_cpp_new( // call __placement_new exprt new_symbol= ns.lookup(new_array?"__placement_new_array":"__placement_new").symbol_expr(); - + const code_typet &code_type= to_code_type(new_symbol.type()); const typet &return_type=code_type.return_type(); - + assert(code_type.parameters().size()==2 || code_type.parameters().size()==3); @@ -611,7 +611,7 @@ void goto_convertt::do_cpp_new( for(unsigned i=0; icode=code_assignt( lhs, typecast_exprt(tmp_symbol_expr, lhs.type())); t_n->source_location=rhs.find_source_location(); - + // grab initializer goto_programt tmp_initializer; cpp_new_initializer(lhs, rhs, tmp_initializer); @@ -656,7 +656,7 @@ void set_class_identifier( if(components.empty()) return; assert(!expr.operands().empty()); - + if(components.front().get_name()=="@class_identifier") { assert(expr.op0().id()==ID_constant); @@ -692,7 +692,7 @@ void goto_convertt::do_java_new( error() << "do_java_new without lhs is yet to be implemented" << eom; throw 0; } - + source_locationt location=rhs.source_location(); assert(rhs.operands().empty()); @@ -705,10 +705,10 @@ void goto_convertt::do_java_new( } typet object_type=rhs.type().subtype(); - + // build size expression exprt object_size=size_of_expr(object_type, ns); - + if(object_size.is_nil()) { error().source_location=rhs.find_source_location(); @@ -724,7 +724,7 @@ void goto_convertt::do_java_new( goto_programt::targett t_n=dest.add_instruction(ASSIGN); t_n->code=code_assignt(lhs, malloc_expr); t_n->source_location=location; - + // zero-initialize the object dereference_exprt deref(lhs, object_type); exprt zero_object=zero_initializer(object_type, location, ns, get_message_handler()); @@ -758,11 +758,11 @@ void goto_convertt::do_java_new_array( << eom; throw 0; } - + source_locationt location=rhs.source_location(); assert(rhs.operands().size()>=1); // one per dimension - + if(rhs.type().id()!=ID_pointer) { error().source_location=rhs.find_source_location(); @@ -771,10 +771,10 @@ void goto_convertt::do_java_new_array( } typet object_type=rhs.type().subtype(); - + // build size expression exprt object_size=size_of_expr(object_type, ns); - + if(object_size.is_nil()) { error().source_location=rhs.find_source_location(); @@ -790,9 +790,9 @@ void goto_convertt::do_java_new_array( goto_programt::targett t_n=dest.add_instruction(ASSIGN); t_n->code=code_assignt(lhs, malloc_expr); t_n->source_location=location; - + // multi-dimensional? - + assert(ns.follow(object_type).id()==ID_struct); const struct_typet &struct_type=to_struct_type(ns.follow(object_type)); assert(struct_type.components().size()==3); @@ -803,7 +803,7 @@ void goto_convertt::do_java_new_array( goto_programt::targett t_s=dest.add_instruction(ASSIGN); t_s->code=code_assignt(length, rhs.op0()); t_s->source_location=location; - + // we also need to allocate space for the data member_exprt data(deref, struct_type.components()[2].get_name(), struct_type.components()[2].type()); side_effect_exprt data_cpp_new_expr(ID_cpp_new_array, data.type()); @@ -811,7 +811,7 @@ void goto_convertt::do_java_new_array( goto_programt::targett t_p=dest.add_instruction(ASSIGN); t_p->code=code_assignt(data, data_cpp_new_expr); t_p->source_location=location; - + // zero-initialize the data exprt zero_element=gen_zero(data.type().subtype()); codet array_set(ID_array_set); @@ -825,24 +825,24 @@ void goto_convertt::do_java_new_array( // produce // for(int i=0; iguard=arguments.front(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); - + // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); @@ -1230,7 +1230,7 @@ void goto_convertt::do_function_call_symbol( t->guard=false_exprt(); t->source_location=function.source_location(); t->source_location.set("user-provided", true); - t->source_location.set_property_class(ID_assertion); + t->source_location.set_property_class(ID_assertion); t->source_location.set_comment("assertion at "+function.source_location().as_string()); } else if(identifier=="assert" && @@ -1250,7 +1250,7 @@ void goto_convertt::do_function_call_symbol( t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment("assertion "+id2string(from_expr(ns, "", t->guard))); - + // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); @@ -1271,7 +1271,7 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + const irep_idt description= get_string_constant(arguments[1]); @@ -1281,7 +1281,7 @@ void goto_convertt::do_function_call_symbol( t->source_location.set("user-provided", true); t->source_location.set_property_class(ID_assertion); t->source_location.set_comment(description); - + // let's double-check the type of the argument if(t->guard.type().id()!=ID_bool) t->guard.make_typecast(bool_typet()); @@ -1336,9 +1336,9 @@ void goto_convertt::do_function_call_symbol( { // make it a side effect if there is an LHS if(lhs.is_nil()) return; - + exprt rhs; - + // We need to special-case for _Bool, which // can only be 0 or 1. if(lhs.type().id()==ID_c_bool) @@ -1347,7 +1347,7 @@ void goto_convertt::do_function_call_symbol( rhs.add_source_location()=function.source_location(); rhs.set(ID_C_identifier, identifier); rhs=typecast_exprt(rhs, lhs.type()); - } + } else { rhs=side_effect_expr_nondett(lhs.type()); @@ -1428,7 +1428,7 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + const irep_idt description= "assertion "+id2string(get_string_constant(arguments[0])); @@ -1449,9 +1449,9 @@ void goto_convertt::do_function_call_symbol( // __func__, "file.c", line, "expression" // On Solaris 11, it's three arguments: // "expression", "file", line - + irep_idt description; - + if(arguments.size()==4) { description= @@ -1545,9 +1545,9 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + exprt list_arg=make_va_list(arguments[0]); - + { side_effect_exprt rhs(ID_gcc_builtin_va_arg_next, list_arg.type()); rhs.copy_to_operands(list_arg); @@ -1578,7 +1578,7 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + exprt dest_expr=make_va_list(arguments[0]); exprt src_expr=typecast_exprt(arguments[1], dest_expr.type()); @@ -1587,8 +1587,8 @@ void goto_convertt::do_function_call_symbol( error().source_location=dest_expr.find_source_location(); error() << "va_copy argument expected to be lvalue" << eom; throw 0; - } - + } + goto_programt::targett t=dest.add_instruction(ASSIGN); t->source_location=function.source_location(); t->code=code_assignt(dest_expr, src_expr); @@ -1604,7 +1604,7 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + exprt dest_expr=make_va_list(arguments[0]); exprt src_expr=typecast_exprt( address_of_exprt(arguments[1]), dest_expr.type()); @@ -1614,8 +1614,8 @@ void goto_convertt::do_function_call_symbol( error().source_location=dest_expr.find_source_location(); error() << "va_start argument expected to be lvalue" << eom; throw 0; - } - + } + goto_programt::targett t=dest.add_instruction(ASSIGN); t->source_location=function.source_location(); t->code=code_assignt(dest_expr, src_expr); @@ -1630,15 +1630,15 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + exprt dest_expr=make_va_list(arguments[0]); - + if(!is_lvalue(dest_expr)) { error().source_location=dest_expr.find_source_location(); error() << "va_end argument expected to be lvalue" << eom; throw 0; - } + } // our __builtin_va_list is a pointer if(ns.follow(dest_expr.type()).id()==ID_pointer) @@ -1673,7 +1673,7 @@ void goto_convertt::do_function_call_symbol( << eom; throw 0; } - + // build *ptr dereference_exprt deref_ptr(arguments[0], arguments[0].type().subtype()); @@ -1689,7 +1689,7 @@ void goto_convertt::do_function_call_symbol( if(t2->code.op0().type()!=t2->code.op1().type()) t2->code.op1().make_typecast(t2->code.op0().type()); } - + irep_idt op_id= identifier=="__sync_fetch_and_add"?ID_plus: identifier=="__sync_fetch_and_sub"?ID_minus: @@ -1698,7 +1698,7 @@ void goto_convertt::do_function_call_symbol( identifier=="__sync_fetch_and_xor"?ID_bitxor: identifier=="__sync_fetch_and_nand"?ID_bitnand: ID_nil; - + // build *ptr=*ptr OP arguments[1]; binary_exprt op_expr(deref_ptr, op_id, arguments[1], deref_ptr.type()); if(op_expr.op1().type()!=op_expr.type()) @@ -1707,7 +1707,7 @@ void goto_convertt::do_function_call_symbol( goto_programt::targett t3=dest.add_instruction(ASSIGN); t3->source_location=function.source_location(); t3->code=code_assignt(deref_ptr, op_expr); - + // this instruction implies an mfence, i.e., WRfence goto_programt::targett t4=dest.add_instruction(OTHER); t4->source_location=function.source_location(); @@ -1742,7 +1742,7 @@ void goto_convertt::do_function_call_symbol( << "' expected to have pointer argument" << eom; throw 0; } - + // build *ptr dereference_exprt deref_ptr(arguments[0], arguments[0].type().subtype()); @@ -1757,7 +1757,7 @@ void goto_convertt::do_function_call_symbol( identifier=="__sync_xor_and_fetch"?ID_bitxor: identifier=="__sync_nand_and_fetch"?ID_bitnand: ID_nil; - + // build *ptr=*ptr OP arguments[1]; binary_exprt op_expr(deref_ptr, op_id, arguments[1], deref_ptr.type()); if(op_expr.op1().type()!=op_expr.type()) @@ -1766,7 +1766,7 @@ void goto_convertt::do_function_call_symbol( goto_programt::targett t3=dest.add_instruction(ASSIGN); t3->source_location=function.source_location(); t3->code=code_assignt(deref_ptr, op_expr); - + if(lhs.is_not_nil()) { // return *ptr @@ -1782,7 +1782,7 @@ void goto_convertt::do_function_call_symbol( t4->source_location=function.source_location(); t4->code=codet(ID_fence); t4->code.set(ID_WRfence, true); - + goto_programt::targett t5=dest.add_instruction(ATOMIC_END); t5->source_location=function.source_location(); } @@ -1798,7 +1798,7 @@ void goto_convertt::do_function_call_symbol( // them into ansi-c/library. // bool __sync_bool_compare_and_swap (type *ptr, type oldval, type newval, ...) - + if(arguments.size()<3) { error().source_location=function.find_source_location(); @@ -1821,11 +1821,11 @@ void goto_convertt::do_function_call_symbol( goto_programt::targett t1=dest.add_instruction(ATOMIC_BEGIN); t1->source_location=function.source_location(); - // build *ptr==oldval + // build *ptr==oldval equal_exprt equal(deref_ptr, arguments[1]); if(equal.op1().type()!=equal.op0().type()) equal.op1().make_typecast(equal.op0().type()); - + if(lhs.is_not_nil()) { // return *ptr==oldval @@ -1835,8 +1835,8 @@ void goto_convertt::do_function_call_symbol( if(t2->code.op0().type()!=t2->code.op1().type()) t2->code.op1().make_typecast(t2->code.op0().type()); } - - // build (*ptr==oldval)?newval:*ptr + + // build (*ptr==oldval)?newval:*ptr if_exprt if_expr(equal, arguments[2], deref_ptr, deref_ptr.type()); if(if_expr.op1().type()!=if_expr.type()) if_expr.op1().make_typecast(if_expr.type()); @@ -1844,13 +1844,13 @@ void goto_convertt::do_function_call_symbol( goto_programt::targett t3=dest.add_instruction(ASSIGN); t3->source_location=function.source_location(); t3->code=code_assignt(deref_ptr, if_expr); - + // this instruction implies an mfence, i.e., WRfence goto_programt::targett t4=dest.add_instruction(OTHER); t4->source_location=function.source_location(); t4->code=codet(ID_fence); t4->code.set(ID_WRfence, true); - + goto_programt::targett t5=dest.add_instruction(ATOMIC_END); t5->source_location=function.source_location(); } @@ -1888,13 +1888,13 @@ void goto_convertt::do_function_call_symbol( if(t2->code.op0().type()!=t2->code.op1().type()) t2->code.op1().make_typecast(t2->code.op0().type()); } - - // build *ptr==oldval + + // build *ptr==oldval equal_exprt equal(deref_ptr, arguments[1]); if(equal.op1().type()!=equal.op0().type()) equal.op1().make_typecast(equal.op0().type()); - - // build (*ptr==oldval)?newval:*ptr + + // build (*ptr==oldval)?newval:*ptr if_exprt if_expr(equal, arguments[2], deref_ptr, deref_ptr.type()); if(if_expr.op1().type()!=if_expr.type()) if_expr.op1().make_typecast(if_expr.type()); @@ -1902,22 +1902,22 @@ void goto_convertt::do_function_call_symbol( goto_programt::targett t3=dest.add_instruction(ASSIGN); t3->source_location=function.source_location(); t3->code=code_assignt(deref_ptr, if_expr); - + // this instruction implies an mfence, i.e., WRfence goto_programt::targett t4=dest.add_instruction(OTHER); t4->source_location=function.source_location(); t4->code=codet(ID_fence); t4->code.set(ID_WRfence, true); - + goto_programt::targett t5=dest.add_instruction(ATOMIC_END); t5->source_location=function.source_location(); } else if(identifier=="__sync_lock_test_and_set") { // type __sync_lock_test_and_set (type *ptr, type value, ...) - + // This builtin, as described by Intel, is not a traditional - // test-and-set operation, but rather an atomic exchange operation. + // test-and-set operation, but rather an atomic exchange operation. // It writes value into *ptr, and returns the previous contents of // *ptr. Many targets have only minimal support for such locks, and // do not support a full exchange operation. In this case, a target diff --git a/src/goto-programs/cfg.h b/src/goto-programs/cfg.h index 95432896885..f134866b03d 100644 --- a/src/goto-programs/cfg.h +++ b/src/goto-programs/cfg.h @@ -401,7 +401,7 @@ void cfg_baset::compute_edges_function_call( { // empty function this->add_edge(entry, entry_map[next_PC]); - } + } } else if(next_PC!=goto_program.instructions.end()) this->add_edge(entry, entry_map[next_PC]); diff --git a/src/goto-programs/class_hierarchy.cpp b/src/goto-programs/class_hierarchy.cpp index d22782713d3..af6a5ea882d 100644 --- a/src/goto-programs/class_hierarchy.cpp +++ b/src/goto-programs/class_hierarchy.cpp @@ -38,12 +38,12 @@ void class_hierarchyt::operator()(const symbol_tablet &symbol_table) const irept::subt &bases= struct_type.find(ID_bases).get_sub(); - + for(const auto & base : bases) { irep_idt parent=base.find(ID_type).get(ID_identifier); if(parent.empty()) continue; - + class_map[parent].children.push_back(it->first); class_map[it->first].parents.push_back(parent); } @@ -70,7 +70,7 @@ void class_hierarchyt::get_children_trans_rec( class_mapt::const_iterator it=class_map.find(c); if(it==class_map.end()) return; const entryt &entry=it->second; - + for(const auto & child : entry.children) dest.push_back(child); @@ -98,7 +98,7 @@ void class_hierarchyt::get_parents_trans_rec( class_mapt::const_iterator it=class_map.find(c); if(it==class_map.end()) return; const entryt &entry=it->second; - + for(const auto & child : entry.parents) dest.push_back(child); diff --git a/src/goto-programs/class_hierarchy.h b/src/goto-programs/class_hierarchy.h index 03dfd076071..d64d361f84e 100644 --- a/src/goto-programs/class_hierarchy.h +++ b/src/goto-programs/class_hierarchy.h @@ -29,7 +29,7 @@ class class_hierarchyt typedef std::map class_mapt; class_mapt class_map; - + void operator()(const symbol_tablet &); // transitively gets all children @@ -39,7 +39,7 @@ class class_hierarchyt get_children_trans_rec(id, result); return result; } - + // transitively gets all parents idst get_parents_trans(const irep_idt &id) const { @@ -47,7 +47,7 @@ class class_hierarchyt get_parents_trans_rec(id, result); return result; } - + void output(std::ostream &) const; protected: diff --git a/src/goto-programs/compute_called_functions.cpp b/src/goto-programs/compute_called_functions.cpp index d85a29802b2..0f6940de9a1 100644 --- a/src/goto-programs/compute_called_functions.cpp +++ b/src/goto-programs/compute_called_functions.cpp @@ -28,7 +28,7 @@ void compute_address_taken_functions( { forall_operands(it, src) compute_address_taken_functions(*it, address_taken); - + if(src.id()==ID_address_of && src.type().id()==ID_pointer && src.type().subtype().id()==ID_code) @@ -58,7 +58,7 @@ void compute_functions( { forall_operands(it, src) compute_functions(*it, address_taken); - + if(src.type().id()==ID_code && src.id()==ID_symbol) address_taken.insert(to_symbol_expr(src).get_identifier()); @@ -125,30 +125,30 @@ void compute_called_functions( { std::set working_queue; std::set done; - + // start from entry point working_queue.insert(goto_functions.entry_point()); - + while(!working_queue.empty()) { irep_idt id=*working_queue.begin(); working_queue.erase(working_queue.begin()); - + if(done.find(id)!=done.end()) continue; - + functions.insert(id); done.insert(id); - + const goto_functionst::function_mapt::const_iterator f_it= goto_functions.function_map.find(id); - + if(f_it==goto_functions.function_map.end()) continue; - + const goto_programt &program= f_it->second.body; - + compute_address_taken_functions(program, working_queue); forall_goto_program_instructions(i_it, program) @@ -161,7 +161,7 @@ void compute_called_functions( } } } - + } /*******************************************************************\ @@ -182,4 +182,3 @@ void compute_called_functions( { compute_called_functions(goto_model.goto_functions, functions); } - diff --git a/src/goto-programs/destructor.cpp b/src/goto-programs/destructor.cpp index 350cf95ceb2..ba1fe127a5f 100644 --- a/src/goto-programs/destructor.cpp +++ b/src/goto-programs/destructor.cpp @@ -40,21 +40,21 @@ code_function_callt get_destructor( if(it->type().id()==ID_code) { const code_typet &code_type=to_code_type(it->type()); - + if(code_type.return_type().id()==ID_destructor && code_type.parameters().size()==1) { const typet &arg_type=code_type.parameters().front().type(); - + if(arg_type.id()==ID_pointer && ns.follow(arg_type.subtype())==type) { exprt symbol_expr(ID_symbol, it->type()); - symbol_expr.set(ID_identifier, it->get(ID_name)); + symbol_expr.set(ID_identifier, it->get(ID_name)); code_function_callt function_call; function_call.function()=symbol_expr; - + return function_call; } } diff --git a/src/goto-programs/elf_reader.cpp b/src/goto-programs/elf_reader.cpp index c304aa1c063..bbb71ea442b 100644 --- a/src/goto-programs/elf_reader.cpp +++ b/src/goto-programs/elf_reader.cpp @@ -37,11 +37,11 @@ elf_readert::elf_readert(std::istream &_in):in(_in) throw "ELF header malformed (magic)"; elf_class=(elf_classt)elf32_header.e_ident[4]; - + if(elf_class==ELF32) { char ei_data=elf32_header.e_ident[5]; - + if(ei_data==1) little_endian=true; else if(ei_data==2) @@ -51,7 +51,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in) if(elf32_header.e_version!=1) throw "unknown ELF32 version"; - + // get offset for section header if(elf32_header.e_shoff==0 || elf32_header.e_shnum==0) @@ -69,7 +69,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in) // read section header in.read((char *)&elf32_section_header_table[i], sizeof(Elf32_Shdr)); } - + // string table unsigned string_table_nr=elf32_header.e_shstrndx; if(string_table_nr>=elf32_section_header_table.size()) @@ -84,7 +84,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in) in.read((char *)&elf64_header, sizeof(elf64_header)); char ei_data=elf64_header.e_ident[5]; - + if(ei_data==1) little_endian=true; else if(ei_data==2) @@ -94,7 +94,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in) if(elf64_header.e_version!=1) throw "unknown ELF64 version"; - + // get offset for section header if(elf64_header.e_shoff==0 || elf64_header.e_shnum==0) @@ -112,7 +112,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in) // read section header in.read((char *)&elf64_section_header_table[i], sizeof(Elf64_Shdr)); } - + // string table unsigned string_table_nr=elf64_header.e_shstrndx; if(string_table_nr>=elf64_section_header_table.size()) @@ -147,7 +147,7 @@ std::string elf_readert::get_string(std::streampos index) const if(ch==0) break; result+=ch; } - + return result; } @@ -167,6 +167,6 @@ bool elf_readert::has_section(const std::string &name) const { for(unsigned i=0; i elf32_section_header_tablet; elf32_section_header_tablet elf32_section_header_table; @@ -128,23 +128,23 @@ class elf_readert { return get_string(elf64_section_header_table[index].sh_name); } - + unsigned number_of_sections; std::string section_name(unsigned index) const { - return + return elf_class==ELF32?elf32_section_name(index): elf64_section_name(index); } - + std::streampos section_offset(unsigned index) const { return elf_class==ELF32?elf32_section_header_table[index].sh_offset: elf64_section_header_table[index].sh_offset; } - + bool has_section(const std::string &name) const; protected: diff --git a/src/goto-programs/format_strings.h b/src/goto-programs/format_strings.h index 48d968a932f..e04d5be0bc0 100644 --- a/src/goto-programs/format_strings.h +++ b/src/goto-programs/format_strings.h @@ -15,7 +15,7 @@ Author: CM Wintersteiger #include #include -class format_tokent +class format_tokent { public: typedef enum { UNKNOWN, @@ -26,19 +26,19 @@ class format_tokent STRING, // s POINTER // p } token_typet; - - typedef enum { ALTERNATE, ZERO_PAD, LEFT_ADJUST, + + typedef enum { ALTERNATE, ZERO_PAD, LEFT_ADJUST, SIGNED_SPACE, SIGN, ASTERISK } flag_typet; - + typedef enum { LEN_h, LEN_hh, LEN_l, LEN_ll, LEN_L, LEN_j, LEN_t } length_modifierst; - + typedef enum { SIGNED_DEC, UNSIGNED_DEC, UNSIGNED_OCT, UNSIGNED_HEX } representationt; - + explicit format_tokent(token_typet _type) : type(_type) { } format_tokent(): type(UNKNOWN) { } - - token_typet type; - std::list flags; + + token_typet type; + std::list flags; mp_integer field_width; mp_integer precision; length_modifierst length_modifier; diff --git a/src/goto-programs/get_goto_model.cpp b/src/goto-programs/get_goto_model.cpp index 02cf10f3d80..fd47031a1f3 100644 --- a/src/goto-programs/get_goto_model.cpp +++ b/src/goto-programs/get_goto_model.cpp @@ -57,7 +57,7 @@ bool get_goto_modelt::operator()(const std::vector &files) if(!sources.empty()) { language_filest language_files; - + language_files.set_message_handler(get_message_handler()); for(const auto & filename : sources) @@ -74,7 +74,7 @@ bool get_goto_modelt::operator()(const std::vector &files) << '\'' << eom; return true; } - + std::pair result=language_files.filemap.insert( std::pair(filename, language_filet())); @@ -89,7 +89,7 @@ bool get_goto_modelt::operator()(const std::vector &files) error("failed to figure out type of file", filename); return true; } - + languaget &language=*lf.language; language.set_message_handler(get_message_handler()); @@ -101,11 +101,11 @@ bool get_goto_modelt::operator()(const std::vector &files) return true; } - lf.get_modules(); + lf.get_modules(); } status() << "Converting" << eom; - + if(language_files.typecheck(symbol_table)) { error() << "CONVERSION ERROR" << eom; @@ -151,17 +151,17 @@ bool get_goto_modelt::operator()(const std::vector &files) error() << e << eom; return true; } - + catch(int) { return true; } - + catch(std::bad_alloc) { error() << "Out of memory" << eom; return true; } - + return false; // no error } diff --git a/src/goto-programs/goto_asm.cpp b/src/goto-programs/goto_asm.cpp index d42d11825bb..782d601a29e 100644 --- a/src/goto-programs/goto_asm.cpp +++ b/src/goto-programs/goto_asm.cpp @@ -25,5 +25,5 @@ void goto_convertt::convert_asm( goto_programt &dest) { // copy as OTHER - copy(code, OTHER, dest); + copy(code, OTHER, dest); } diff --git a/src/goto-programs/goto_clean_expr.cpp b/src/goto-programs/goto_clean_expr.cpp index 0d233fb2ccd..c97a11f3f8f 100644 --- a/src/goto-programs/goto_clean_expr.cpp +++ b/src/goto-programs/goto_clean_expr.cpp @@ -34,10 +34,10 @@ symbol_exprt goto_convertt::make_compound_literal( goto_programt &dest) { const source_locationt source_location=expr.find_source_location(); - + auxiliary_symbolt new_symbol; symbolt *symbol_ptr; - + do { new_symbol.base_name="literal$"+i2string(++temporary_counter); @@ -47,7 +47,7 @@ symbol_exprt goto_convertt::make_compound_literal( new_symbol.type=expr.type(); new_symbol.location=source_location; } - while(symbol_table.move(new_symbol, symbol_ptr)); + while(symbol_table.move(new_symbol, symbol_ptr)); // The value might depend on a variable, thus // generate code for this. @@ -58,7 +58,7 @@ symbol_exprt goto_convertt::make_compound_literal( // The lifetime of compound literals is really that of // the block they are in. copy(code_declt(result), DECL, dest); - + code_assignt code_assign(result, expr); code_assign.add_source_location()=source_location; convert(code_assign, dest); @@ -101,7 +101,7 @@ bool goto_convertt::needs_cleaning(const exprt &expr) if(to_index_expr(expr).array().id()==ID_string_constant && to_index_expr(expr).index().is_zero()) return false; - + return true; } @@ -121,11 +121,11 @@ bool goto_convertt::needs_cleaning(const exprt &expr) // forall (i : int) (g1 || g2) if(expr.id()==ID_forall || expr.id()==ID_exists) return false; - + forall_operands(it, expr) if(needs_cleaning(*it)) return true; - + return false; } @@ -144,7 +144,7 @@ Function: goto_convertt::rewrite_boolean void goto_convertt::rewrite_boolean(exprt &expr) { assert(expr.id()==ID_and || expr.id()==ID_or); - + if(!expr.is_boolean()) { error().source_location=expr.find_source_location(); @@ -157,12 +157,12 @@ void goto_convertt::rewrite_boolean(exprt &expr) // re-write "a || b" into nested a?1:b exprt tmp; - + if(expr.id()==ID_and) tmp=true_exprt(); else // ID_or tmp=false_exprt(); - + exprt::operandst &ops=expr.operands(); // start with last one @@ -224,7 +224,7 @@ void goto_convertt::clean_expr( { // rewrite into ?: rewrite_boolean(expr); - + // recursive call clean_expr(expr, dest, result_is_used); return; @@ -241,7 +241,7 @@ void goto_convertt::clean_expr( // copy expression if_exprt if_expr=to_if_expr(expr); - + if(!if_expr.cond().is_boolean()) { error().source_location=if_expr.find_source_location(); @@ -251,7 +251,7 @@ void goto_convertt::clean_expr( } const source_locationt source_location=expr.find_source_location(); - + #if 0 // We do some constant-folding here, to mimic // what typical compilers do. @@ -278,7 +278,7 @@ void goto_convertt::clean_expr( goto_programt tmp_false; clean_expr(if_expr.false_case(), tmp_false, result_is_used); - + if(result_is_used) { symbolt &new_symbol= @@ -307,17 +307,17 @@ void goto_convertt::clean_expr( code_expressiont code_expression(if_expr.true_case()); convert(code_expression, tmp_true); } - + if(if_expr.false_case().is_not_nil()) { code_expressiont code_expression(if_expr.false_case()); convert(code_expression, tmp_false); } - + expr=nil_exprt(); } - // generate guard for argument side-effects + // generate guard for argument side-effects generate_ifthenelse( if_expr.cond(), tmp_true, tmp_false, source_location, dest); @@ -329,11 +329,11 @@ void goto_convertt::clean_expr( if(result_is_used) { exprt result; - + Forall_operands(it, expr) { bool last=(it==--expr.operands().end()); - + // special treatment for last one if(last) { @@ -362,10 +362,10 @@ void goto_convertt::clean_expr( if(it->is_not_nil()) convert(code_expressiont(*it), dest); } - + expr=nil_exprt(); } - + return; } else if(expr.id()==ID_typecast) @@ -379,17 +379,17 @@ void goto_convertt::clean_expr( // preserve 'result_is_used' clean_expr(expr.op0(), dest, result_is_used); - + if(expr.op0().is_nil()) expr.make_nil(); - + return; } else if(expr.id()==ID_side_effect) { // some of the side-effects need special treatment! const irep_idt statement=to_side_effect_expr(expr).get_statement(); - + if(statement==ID_gcc_conditional_expression) { // need to do separately @@ -525,11 +525,11 @@ void goto_convertt::clean_expr_address_of( // Treatment is similar to clean_expr() above. exprt result; - + Forall_operands(it, expr) { bool last=(it==--expr.operands().end()); - + // special treatment for last one if(last) result.swap(*it); @@ -544,7 +544,7 @@ void goto_convertt::clean_expr_address_of( } expr.swap(result); - + // do again clean_expr_address_of(expr, dest); } @@ -590,9 +590,9 @@ void goto_convertt::remove_gcc_conditional_expression( if(if_expr.cond().type()!=bool_typet()) if_expr.cond().make_typecast(bool_typet()); - + expr.swap(if_expr); - // there might still be junk in expr.op2() + // there might still be junk in expr.op2() clean_expr(expr, dest); } diff --git a/src/goto-programs/goto_convert.cpp b/src/goto-programs/goto_convert.cpp index d5cffddd62d..78b5cc9067f 100644 --- a/src/goto-programs/goto_convert.cpp +++ b/src/goto-programs/goto_convert.cpp @@ -63,13 +63,13 @@ void goto_convertt::finish_gotos() for(const auto & it : targets.gotos) { goto_programt::instructiont &i=*it; - + if(i.code.get_statement()=="non-deterministic-goto") { const irept &destinations=i.code.find("destinations"); i.make_goto(); - + forall_irep(it, destinations.get_sub()) { labelst::const_iterator l_it= @@ -81,7 +81,7 @@ void goto_convertt::finish_gotos() error() << "goto label `" << it->id() << "' not found" << eom; throw 0; } - + i.targets.push_back(l_it->second); } } @@ -124,7 +124,7 @@ void goto_convertt::finish_gotos() throw 0; } } - + targets.gotos.clear(); } @@ -146,16 +146,16 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) { goto_programt::instructiont &i=*g_it; exprt destination=i.code.op0(); - + assert(destination.id()==ID_dereference); assert(destination.operands().size()==1); - + exprt pointer=destination.op0(); // remember the expression for later checks i.type=OTHER; i.code=code_expressiont(pointer); - + // insert huge case-split for(labelst::const_iterator l_it=targets.labels.begin(); @@ -166,10 +166,10 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) label_expr.set(ID_identifier, l_it->first); equal_exprt guard; - + guard.lhs()=pointer; guard.rhs()=address_of_exprt(label_expr); - + goto_programt::targett t= goto_program.insert_after(g_it); @@ -178,7 +178,7 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) t->guard=guard; } } - + targets.computed_gotos.clear(); } @@ -265,10 +265,10 @@ void goto_convertt::convert_label( error() << "label statement expected to have one operand" << eom; throw 0; } - + // grab the label const irep_idt &label=code.get_label(); - + goto_programt tmp; // magic thread creation label? @@ -282,7 +282,7 @@ void goto_convertt::convert_label( } else convert(to_code(code.op0()), tmp); - + goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -333,10 +333,10 @@ void goto_convertt::convert_switch_case( << eom; throw 0; } - + goto_programt tmp; convert(code.code(), tmp); - + goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -384,10 +384,10 @@ void goto_convertt::convert_gcc_switch_case_range( << "three operands" << eom; throw 0; } - + goto_programt tmp; convert(to_code(code.op2()), tmp); - + //goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -423,7 +423,7 @@ void goto_convertt::convert( goto_programt &dest) { const irep_idt &statement=code.get_statement(); - + if(statement==ID_block) convert_block(to_code_block(code), dest); else if(statement==ID_decl) @@ -571,8 +571,8 @@ void goto_convertt::convert_block( // this saves the size of the destructor stack std::size_t old_stack_size=targets.destructor_stack.size(); - - // now convert block + + // now convert block forall_operands(it, code) { const codet &b_code=to_code(*it); @@ -616,9 +616,9 @@ void goto_convertt::convert_expression( error() << "expression statement takes one operand" << eom; throw 0; } - + exprt expr=code.op0(); - + if(expr.id()==ID_if) { // We do a special treatment for c?t:f @@ -637,7 +637,7 @@ void goto_convertt::convert_expression( { clean_expr(expr, dest, false); // result _not_ used - // Any residual expression? + // Any residual expression? // We keep it to add checks later. if(expr.is_not_nil()) { @@ -666,7 +666,7 @@ void goto_convertt::convert_decl( goto_programt &dest) { const exprt &op0=code.op0(); - + if(op0.id()!=ID_symbol) { error().source_location=op0.find_source_location(); @@ -675,9 +675,9 @@ void goto_convertt::convert_decl( } const irep_idt &identifier=op0.get(ID_identifier); - + const symbolt &symbol=lookup(identifier); - + if(symbol.is_static_lifetime || symbol.type.id()==ID_code) return; // this is a SKIP! @@ -690,11 +690,11 @@ void goto_convertt::convert_decl( { // this is expected to go away exprt initializer; - + codet tmp=code; initializer=code.op1(); tmp.operands().resize(1); - + // Break up into decl and assignment. // Decl must be visible before initializer. copy(tmp, DECL, dest); @@ -779,7 +779,7 @@ void goto_convertt::convert_assign( error() << "function_call sideeffect takes two operands" << eom; throw 0; } - + Forall_operands(it, rhs) clean_expr(*it, dest); @@ -826,7 +826,7 @@ void goto_convertt::convert_assign( else { clean_expr(rhs, dest); - + if(lhs.id()==ID_typecast) { assert(lhs.operands().size()==1); @@ -835,9 +835,9 @@ void goto_convertt::convert_assign( exprt new_rhs=rhs; rhs.make_typecast(lhs.op0().type()); - // remove typecast from lhs + // remove typecast from lhs exprt tmp=lhs.op0(); - lhs.swap(tmp); + lhs.swap(tmp); } code_assignt new_assign(code); @@ -870,7 +870,7 @@ void goto_convertt::convert_init( error() <<"init statement takes two operands" << eom; throw 0; } - + // make it an assignment codet assignment=code; assignment.set_statement(ID_assign); @@ -900,24 +900,24 @@ void goto_convertt::convert_cpp_delete( error() << "cpp_delete statement takes one operand" << eom; throw 0; } - + exprt tmp_op=code.op0(); - + clean_expr(tmp_op, dest); - + // we call the destructor, and then free const exprt &destructor= static_cast(code.find(ID_destructor)); - + irep_idt delete_identifier; - + if(code.get_statement()==ID_cpp_delete_array) delete_identifier="__delete_array"; else if(code.get_statement()==ID_cpp_delete) delete_identifier="__delete"; else assert(false); - + if(destructor.is_not_nil()) { if(code.get_statement()==ID_cpp_delete_array) @@ -930,7 +930,7 @@ void goto_convertt::convert_cpp_delete( // just one object exprt deref_op(ID_dereference, tmp_op.type().subtype()); deref_op.copy_to_operands(tmp_op); - + codet tmp_code=to_code(destructor); replace_new_object(deref_op, tmp_code); convert(tmp_code, dest); @@ -938,22 +938,22 @@ void goto_convertt::convert_cpp_delete( else assert(false); } - + // now do "free" exprt delete_symbol=ns.lookup(delete_identifier).symbol_expr(); - + assert(to_code_type(delete_symbol.type()).parameters().size()==1); typet arg_type= to_code_type(delete_symbol.type()).parameters().front().type(); - + code_function_callt delete_call; delete_call.function()=delete_symbol; delete_call.arguments().push_back(typecast_exprt(tmp_op, arg_type)); delete_call.lhs().make_nil(); delete_call.add_source_location()=code.source_location(); - - convert(delete_call, dest); + + convert(delete_call, dest); } /*******************************************************************\ @@ -975,7 +975,7 @@ void goto_convertt::convert_assert( exprt cond=code.assertion(); clean_expr(cond, dest); - + goto_programt::targett t=dest.add_instruction(ASSERT); t->guard.swap(cond); t->source_location=code.source_location(); @@ -1084,7 +1084,7 @@ void goto_convertt::convert_for( // A; while(c) { P; B; } //----------------------------- // A; - // u: sideeffects in c + // u: sideeffects in c // v: if(!c) goto z; // w: P; // x: B; <-- continue target @@ -1094,7 +1094,7 @@ void goto_convertt::convert_for( // A; if(code.init().is_not_nil()) convert(to_code(code.init()), dest); - + exprt cond=code.cond(); goto_programt sideeffects; @@ -1109,7 +1109,7 @@ void goto_convertt::convert_for( // do the v label goto_programt tmp_v; goto_programt::targett v=tmp_v.add_instruction(); - + // do the z label goto_programt tmp_z; goto_programt::targett z=tmp_z.add_instruction(SKIP); @@ -1117,7 +1117,7 @@ void goto_convertt::convert_for( // do the x label goto_programt tmp_x; - + if(code.op2().is_nil()) { tmp_x.add_instruction(SKIP); @@ -1135,7 +1135,7 @@ void goto_convertt::convert_for( tmp_x.instructions.back().source_location=code.source_location(); } } - + // optimize the v label if(sideeffects.instructions.empty()) u=v; @@ -1153,7 +1153,7 @@ void goto_convertt::convert_for( // do the w label goto_programt tmp_w; convert(code.body(), tmp_w); - + // y: goto u; goto_programt tmp_y; goto_programt::targett y=tmp_y.add_instruction(); @@ -1269,13 +1269,13 @@ void goto_convertt::convert_dowhile( throw 0; } - // save source location + // save source location source_locationt condition_location=code.op0().find_source_location(); exprt cond=code.op0(); goto_programt sideeffects; - clean_expr(cond, sideeffects); + clean_expr(cond, sideeffects); // do P while(c); //-------------------- @@ -1365,7 +1365,7 @@ exprt goto_convertt::case_guard( tmp.swap(dest.op0()); dest.swap(tmp); } - + return dest; } @@ -1406,7 +1406,7 @@ void goto_convertt::convert_switch( error() << "switch takes at least two operands" << eom; throw 0; } - + exprt argument=code.value(); goto_programt sideeffects; @@ -1438,9 +1438,9 @@ void goto_convertt::convert_switch( for(auto & it : targets.cases) { const caset &case_ops=it.second; - - assert(!case_ops.empty()); - + + assert(!case_ops.empty()); + exprt guard_expr=case_guard(argument, case_ops); goto_programt::targett x=tmp_cases.add_instruction(); @@ -1526,21 +1526,21 @@ void goto_convertt::convert_return( error() << "return takes none or one operand" << eom; throw 0; } - + code_returnt new_code(code); - + if(new_code.has_return_value()) { bool result_is_used= new_code.return_value().type().id()!=ID_empty; - + goto_programt sideeffects; clean_expr(new_code.return_value(), sideeffects, result_is_used); dest.destructive_append(sideeffects); // remove void-typed return value if(!result_is_used) - new_code.operands().resize(0); + new_code.operands().resize(0); } if(targets.has_return_value) @@ -1568,7 +1568,7 @@ void goto_convertt::convert_return( throw 0; } } - + // Need to process _entire_ destructor stack. unwind_destructor_stack(code.source_location(), 0, dest); @@ -1764,7 +1764,7 @@ void goto_convertt::convert_specc_wait( { #if 0 goto_programt::targett t=dest.add_instruction(WAIT); - + if(code.operands().size()!=1) { error().source_location=code.find_source_location(); @@ -1832,14 +1832,14 @@ void goto_convertt::convert_start_thread( dest.add_instruction(START_THREAD); start_thread->source_location=code.source_location(); - + { // start_thread label; // goto tmp; // label: op0-code // end_thread // tmp: skip - + goto_programt::targett goto_instruction=dest.add_instruction(GOTO); goto_instruction->guard=true_exprt(); goto_instruction->source_location=code.source_location(); @@ -1848,7 +1848,7 @@ void goto_convertt::convert_start_thread( convert(to_code(code.op0()), tmp); goto_programt::targett end_thread=tmp.add_instruction(END_THREAD); end_thread->source_location=code.source_location(); - + start_thread->targets.push_back(tmp.instructions.begin()); dest.destructive_append(tmp); goto_instruction->targets.push_back(dest.add_instruction(SKIP)); @@ -1956,7 +1956,7 @@ void goto_convertt::convert_bp_enforce( error() << "bp_enfroce expects two arguments" << eom; throw 0; } - + // do an assume exprt op=code.op0(); @@ -1967,15 +1967,15 @@ void goto_convertt::convert_bp_enforce( t->source_location=code.source_location(); // change the assignments - + goto_programt tmp; convert(to_code(code.op1()), tmp); - + if(!op.is_true()) { exprt constraint(op); make_next_state(constraint); - + Forall_goto_program_instructions(it, tmp) { if(it->is_assign()) @@ -2001,7 +2001,7 @@ void goto_convertt::convert_bp_enforce( } } } - + dest.destructive_append(tmp); } @@ -2027,12 +2027,12 @@ void goto_convertt::convert_bp_abortif( error() << "bp_abortif expects one argument" << eom; throw 0; } - + // do an assert exprt op=code.op0(); clean_expr(op, dest); - + op.make_not(); goto_programt::targett t=dest.add_instruction(ASSERT); @@ -2062,9 +2062,9 @@ void goto_convertt::convert_ifthenelse( error() << "ifthenelse takes three operands" << eom; throw 0; } - + assert(code.then_case().is_not_nil()); - + bool has_else= !code.else_case().is_nil(); @@ -2180,7 +2180,7 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(true_case); return; } - + // similarly, do guarded assertions directly if(true_case.instructions.size()==1 && true_case.instructions.back().is_assert() && @@ -2293,7 +2293,7 @@ static bool has_and_or(const exprt &expr) if(expr.id()==ID_and || expr.id()==ID_or) return true; - + return false; } @@ -2314,10 +2314,10 @@ void goto_convertt::generate_conditional_branch( goto_programt::targett target_false=tmp.add_instruction(); target_false->make_skip(); target_false->source_location=source_location; - + generate_conditional_branch( guard, target_true, target_false, source_location, dest); - + dest.destructive_append(tmp); } else @@ -2325,7 +2325,7 @@ void goto_convertt::generate_conditional_branch( // simple branch exprt cond=guard; clean_expr(cond, dest); - + goto_programt tmp; goto_programt::targett g=tmp.add_instruction(); g->make_goto(target_true); @@ -2371,10 +2371,10 @@ void goto_convertt::generate_conditional_branch( // if(!a) goto target_false; // if(!b) goto target_false; // goto target_true; - + std::list op; collect_operands(guard, guard.id(), op); - + forall_expr_list(it, op) generate_conditional_branch( boolean_negate(*it), target_false, source_location, dest); @@ -2383,7 +2383,7 @@ void goto_convertt::generate_conditional_branch( t_true->make_goto(target_true); t_true->guard=true_exprt(); t_true->source_location=source_location; - + return; } else if(guard.id()==ID_or) @@ -2397,7 +2397,7 @@ void goto_convertt::generate_conditional_branch( std::list op; collect_operands(guard, guard.id(), op); - + forall_expr_list(it, op) generate_conditional_branch( *it, target_true, source_location, dest); @@ -2406,13 +2406,13 @@ void goto_convertt::generate_conditional_branch( t_false->make_goto(target_false); t_false->guard=true_exprt(); t_false->source_location=guard.source_location(); - + return; } exprt cond=guard; clean_expr(cond, dest); - + goto_programt::targett t_true=dest.add_instruction(); t_true->make_goto(target_true); t_true->guard=cond; @@ -2451,7 +2451,7 @@ bool goto_convertt::get_string_constant( { exprt index_op=get_constant(expr.op0().op0()); simplify(index_op, ns); - + if(index_op.id()==ID_string_constant) return value=index_op.get(ID_value), false; else if(index_op.id()==ID_array) @@ -2501,7 +2501,7 @@ irep_idt goto_convertt::get_string_constant(const exprt &expr) throw 0; } - + return result; } @@ -2563,21 +2563,21 @@ symbolt &goto_convertt::new_tmp_symbol( { auxiliary_symbolt new_symbol; symbolt *symbol_ptr; - + do { new_symbol.base_name="tmp_"+suffix+"$"+i2string(++temporary_counter); new_symbol.name=tmp_symbol_prefix+id2string(new_symbol.base_name); - new_symbol.type=type; + new_symbol.type=type; new_symbol.location=source_location; - } while(symbol_table.move(new_symbol, symbol_ptr)); - + } while(symbol_table.move(new_symbol, symbol_ptr)); + code_declt decl; decl.symbol()=symbol_ptr->symbol_expr(); decl.add_source_location()=source_location; convert_decl(decl, dest); - return *symbol_ptr; + return *symbol_ptr; } /*******************************************************************\ @@ -2598,7 +2598,7 @@ void goto_convertt::make_temp_symbol( goto_programt &dest) { const source_locationt source_location=expr.find_source_location(); - + symbolt &new_symbol= new_tmp_symbol(expr.type(), suffix, dest, source_location); @@ -2680,7 +2680,7 @@ void goto_convert( { goto_convert.goto_convert(code, dest); } - + catch(int) { goto_convert.error(); @@ -2720,11 +2720,11 @@ void goto_convert( // find main symbol const symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find("main"); - + if(s_it==symbol_table.symbols.end()) throw "failed to find main symbol"; - + const symbolt &symbol=s_it->second; - + ::goto_convert(to_code(symbol.value), symbol_table, dest, message_handler); } diff --git a/src/goto-programs/goto_convert_class.h b/src/goto-programs/goto_convert_class.h index 68401889e3e..db6d0c54bd0 100644 --- a/src/goto-programs/goto_convert_class.h +++ b/src/goto-programs/goto_convert_class.h @@ -35,11 +35,11 @@ class goto_convertt:public messaget tmp_symbol_prefix("goto_convertt::") { } - + virtual ~goto_convertt() { } - + protected: symbol_tablet &symbol_table; namespacet ns; @@ -50,16 +50,16 @@ class goto_convertt:public messaget // // tools for symbols - // + // void new_name(symbolt &symbol); const symbolt &lookup(const irep_idt &identifier); - + symbolt &new_tmp_symbol( const typet &type, const std::string &suffix, goto_programt &dest, const source_locationt &); - + symbol_exprt make_compound_literal( const exprt &expr, goto_programt &dest); @@ -68,7 +68,7 @@ class goto_convertt:public messaget // translation of C expressions (with side effects) // into the program logic // - + void clean_expr( exprt &expr, goto_programt &dest, @@ -79,7 +79,7 @@ class goto_convertt:public messaget goto_programt &dest); static bool needs_cleaning(const exprt &expr); - + void make_temp_symbol( exprt &expr, const std::string &suffix, @@ -89,7 +89,7 @@ class goto_convertt:public messaget static bool has_sideeffect(const exprt &expr); static bool has_function_call(const exprt &expr); - + void remove_side_effect(side_effect_exprt &expr, goto_programt &dest, bool result_is_used); void remove_assignment(side_effect_exprt &expr, goto_programt &dest, bool result_is_used); void remove_pre(side_effect_exprt &expr, goto_programt &dest, bool result_is_used); @@ -127,9 +127,9 @@ class goto_convertt:public messaget goto_programt &dest); // - // function calls + // function calls // - + virtual void do_function_call( const exprt &lhs, const exprt &function, @@ -157,7 +157,7 @@ class goto_convertt:public messaget const exprt &function, const exprt::operandst &arguments, goto_programt &dest); - + // // conversion // @@ -211,11 +211,11 @@ class goto_convertt:public messaget void convert(const codet &code, goto_programt &dest); void copy(const codet &code, goto_program_instruction_typet type, goto_programt &dest); - + // // exceptions // - + symbol_exprt exception_flag(); void unwind_destructor_stack( const source_locationt &, @@ -236,7 +236,7 @@ class goto_convertt:public messaget typedef exprt::operandst caset; typedef std::list > casest; typedef std::map cases_mapt; - + struct targetst { bool return_set, has_return_value, break_set, continue_set, @@ -252,7 +252,7 @@ class goto_convertt:public messaget goto_programt::targett return_target, break_target, continue_target, default_target, throw_target, leave_target; - + std::size_t break_stack_size, continue_stack_size, throw_stack_size, leave_stack_size; @@ -308,11 +308,11 @@ class goto_convertt:public messaget } } targets; - + struct break_continue_targetst { // for 'while', 'for', 'dowhile' - + explicit break_continue_targetst(const targetst &targets) { break_set=targets.break_set; @@ -331,13 +331,13 @@ class goto_convertt:public messaget goto_programt::targett break_target; goto_programt::targett continue_target; - bool break_set, continue_set; + bool break_set, continue_set; }; - + struct break_switch_targetst { // for 'switch' - + explicit break_switch_targetst(const targetst &targets) { break_set=targets.break_set; @@ -348,7 +348,7 @@ class goto_convertt:public messaget cases=targets.cases; cases_map=targets.cases_map; } - + void restore(targetst &targets) { targets.break_set=break_set; @@ -361,13 +361,13 @@ class goto_convertt:public messaget goto_programt::targett break_target; goto_programt::targett default_target; - bool break_set, default_set; + bool break_set, default_set; std::size_t break_stack_size; casest cases; cases_mapt cases_map; }; - + struct throw_targett { // for 'try...catch' and the like @@ -389,7 +389,7 @@ class goto_convertt:public messaget bool throw_set; std::size_t throw_stack_size; }; - + struct leave_targett { // for 'try...leave...finally' @@ -411,7 +411,7 @@ class goto_convertt:public messaget bool leave_set; std::size_t leave_stack_size; }; - + exprt case_guard( const exprt &value, const caset &case_op); @@ -438,7 +438,7 @@ class goto_convertt:public messaget goto_programt::targett target_true, const source_locationt &, goto_programt &dest); - + // turn a OP b OP c into a list a, b, c static void collect_operands( const exprt &expr, @@ -452,7 +452,7 @@ class goto_convertt:public messaget bool get_string_constant(const exprt &expr, irep_idt &); exprt get_constant(const exprt &expr); - // some built-in functions + // some built-in functions void do_atomic_begin (const exprt &lhs, const exprt &rhs, const exprt::operandst &arguments, goto_programt &dest); void do_atomic_end (const exprt &lhs, const exprt &rhs, const exprt::operandst &arguments, goto_programt &dest); void do_create_thread (const exprt &lhs, const exprt &rhs, const exprt::operandst &arguments, goto_programt &dest); diff --git a/src/goto-programs/goto_convert_exceptions.cpp b/src/goto-programs/goto_convert_exceptions.cpp index bc5439b6d20..75dcffe1552 100644 --- a/src/goto-programs/goto_convert_exceptions.cpp +++ b/src/goto-programs/goto_convert_exceptions.cpp @@ -32,30 +32,30 @@ void goto_convertt::convert_msc_try_finally( error() << "msc_try_finally expects two arguments" << eom; throw 0; } - + goto_programt tmp; tmp.add_instruction(SKIP)->source_location=code.source_location(); - { + { // save 'leave' target leave_targett leave_target(targets); targets.set_leave(tmp.instructions.begin()); - + // first put 'finally' code onto destructor stack targets.destructor_stack.push_back(to_code(code.op1())); - + // do 'try' code convert(to_code(code.op0()), dest); // pop 'finally' from destructor stack targets.destructor_stack.pop_back(); - + // 'leave' target gets restored here } // now add 'finally' code convert(to_code(code.op1()), dest); - + // this is the target for 'leave' dest.destructive_append(tmp); } @@ -84,7 +84,7 @@ void goto_convertt::convert_msc_try_except( } convert(to_code(code.op0()), dest); - + // todo: generate exception tracking } @@ -110,7 +110,7 @@ void goto_convertt::convert_msc_leave( error() << "leave without target" << eom; throw 0; } - + // need to process destructor stack for(std::size_t d=targets.destructor_stack.size(); d!=targets.leave_stack_size; @@ -143,13 +143,13 @@ void goto_convertt::convert_try_catch( goto_programt &dest) { assert(code.operands().size()>=2); - + // add the CATCH-push instruction to 'dest' goto_programt::targett catch_push_instruction=dest.add_instruction(); catch_push_instruction->make_catch(); catch_push_instruction->code.set_statement(ID_catch); catch_push_instruction->source_location=code.source_location(); - + // the CATCH-push instruction is annotated with a list of IDs, // one per target irept::subt &exception_list= @@ -159,25 +159,25 @@ void goto_convertt::convert_try_catch( goto_programt end; goto_programt::targett end_target=end.add_instruction(); end_target->make_skip(); - + // the first operand is the 'try' block convert(to_code(code.op0()), dest); - + // add the CATCH-pop to the end of the 'try' block goto_programt::targett catch_pop_instruction=dest.add_instruction(); catch_pop_instruction->make_catch(); catch_pop_instruction->code.set_statement(ID_catch); - + // add a goto to the end of the 'try' block dest.add_instruction()->make_goto(end_target); for(unsigned i=1; itargets.push_back(tmp.instructions.begin()); @@ -187,7 +187,7 @@ void goto_convertt::convert_try_catch( dest.add_instruction()->make_goto(end_target); } - // add the end-target + // add the end-target dest.destructive_append(end); } @@ -221,7 +221,7 @@ void goto_convertt::convert_CPROVER_try_catch( // set 'throw' target throw_targett throw_target(targets); targets.set_throw(tmp.instructions.begin()); - + // now put 'catch' code onto destructor stack code_ifthenelset catch_code; catch_code.cond()=exception_flag(); @@ -235,7 +235,7 @@ void goto_convertt::convert_CPROVER_try_catch( // pop 'catch' code off stack targets.destructor_stack.pop_back(); - + // add 'throw' target dest.destructive_append(tmp); } @@ -310,10 +310,10 @@ void goto_convertt::convert_CPROVER_try_finally( error() << "CPROVER_try_finally expects two arguments" << eom; throw 0; } - + // first put 'finally' code onto destructor stack targets.destructor_stack.push_back(to_code(code.op1())); - + // do 'try' code convert(to_code(code.op0()), dest); @@ -342,7 +342,7 @@ symbol_exprt goto_convertt::exception_flag() symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(id); - + if(s_it==symbol_table.symbols.end()) { symbolt new_symbol; @@ -354,10 +354,10 @@ symbol_exprt goto_convertt::exception_flag() new_symbol.type=bool_typet(); symbol_table.move(new_symbol); } - + return symbol_exprt(id, bool_typet()); } - + /*******************************************************************\ Function: goto_convertt::unwind_destructor_stack @@ -384,13 +384,13 @@ void goto_convertt::unwind_destructor_stack( { codet d_code=targets.destructor_stack.back(); d_code.add_source_location()=source_location; - + // pop now to avoid doing this again targets.destructor_stack.pop_back(); - + convert(d_code, dest); } // Now restore old stack. - old_stack.swap(targets.destructor_stack); + old_stack.swap(targets.destructor_stack); } diff --git a/src/goto-programs/goto_convert_function_call.cpp b/src/goto-programs/goto_convert_function_call.cpp index 910336fc579..78d6d8b762e 100644 --- a/src/goto-programs/goto_convert_function_call.cpp +++ b/src/goto-programs/goto_convert_function_call.cpp @@ -62,17 +62,17 @@ void goto_convertt::do_function_call( goto_programt &dest) { // make it all side effect free - + exprt new_lhs=lhs, new_function=function; - + exprt::operandst new_arguments=arguments; if(!new_lhs.is_nil()) clean_expr(new_lhs, dest); clean_expr(new_function, dest); - + // the arguments of __noop do not get evaluated if(new_function.id()==ID_symbol && to_symbol_expr(new_function).get_identifier()=="__noop") @@ -212,7 +212,7 @@ void goto_convertt::do_function_call_other( function_call.lhs()=lhs; function_call.function()=function; function_call.arguments()=arguments; - + t->source_location=function.source_location(); t->code.swap(function_call); } diff --git a/src/goto-programs/goto_convert_functions.cpp b/src/goto-programs/goto_convert_functions.cpp index 35b46503bfa..c6d7be47258 100644 --- a/src/goto-programs/goto_convert_functions.cpp +++ b/src/goto-programs/goto_convert_functions.cpp @@ -38,7 +38,7 @@ goto_convert_functionst::goto_convert_functionst( functions(_functions) { } - + /*******************************************************************\ Function: goto_convert_functionst::~goto_convert_functionst @@ -85,7 +85,7 @@ void goto_convert_functionst::goto_convert() it->second.mode=="jsil")) symbol_list.push_back(it->first); } - + for(symbol_listt::const_iterator it=symbol_list.begin(); it!=symbol_list.end(); @@ -93,7 +93,7 @@ void goto_convert_functionst::goto_convert() { convert_function(*it); } - + functions.compute_location_numbers(); // this removes the parse tree of the bodies from memory @@ -136,7 +136,7 @@ bool goto_convert_functionst::hide(const goto_programt &goto_program) return true; } } - + return false; } @@ -160,7 +160,7 @@ void goto_convert_functionst::add_return( if(!f.body.instructions.empty() && f.body.instructions.back().is_return()) return; // not needed, we have one already - + // see if we have an unconditional goto at the end if(!f.body.instructions.empty() && f.body.instructions.back().is_goto() && @@ -181,7 +181,7 @@ void goto_convert_functionst::add_return( last_instruction->guard.is_true()) return; - // return? + // return? if(last_instruction->is_return()) return; @@ -194,7 +194,7 @@ void goto_convert_functionst::add_return( break; // give up } } - + #endif goto_programt::targett t=f.body.add_instruction(); @@ -222,18 +222,18 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) { const symbolt &symbol=ns.lookup(identifier); goto_functionst::goto_functiont &f=functions.function_map[identifier]; - + // make tmp variables local to function tmp_symbol_prefix=id2string(symbol.name)+"::$tmp::"; temporary_counter=0; - + f.type=to_code_type(symbol.type); if(f.body_available()) return; // already converted if(symbol.value.is_nil() || symbol.value.id()=="compiled") /* goto_inline may have removed the body */ return; - + if(symbol.value.id()!=ID_code) { error().source_location=symbol.value.find_source_location(); @@ -241,9 +241,9 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) << eom; throw 0; } - + const codet &code=to_code(symbol.value); - + source_locationt end_location; if(code.get_statement()==ID_block) @@ -265,11 +265,11 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) f.type.return_type().id()!=ID_destructor; goto_convert_rec(code, f.body); - + // add non-det return value, if needed if(targets.has_return_value) add_return(f, end_location); - + // handle SV-COMP's __VERIFIER_atomic_ if(!f.body.instructions.empty() && has_prefix(id2string(identifier), "__VERIFIER_atomic_")) @@ -296,7 +296,7 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) // do function tags Forall_goto_program_instructions(i_it, f.body) i_it->function=identifier; - + f.body.update(); if(hide(f.body)) @@ -343,9 +343,9 @@ void goto_convert( { goto_convert_functionst goto_convert_functions( symbol_table, functions, message_handler); - + try - { + { goto_convert_functions.goto_convert(); } @@ -388,9 +388,9 @@ void goto_convert( { goto_convert_functionst goto_convert_functions( symbol_table, functions, message_handler); - + try - { + { goto_convert_functions.convert_function(identifier); } @@ -412,5 +412,3 @@ void goto_convert( throw 0; } } - - diff --git a/src/goto-programs/goto_convert_functions.h b/src/goto-programs/goto_convert_functions.h index ccb5edf6bc0..32072255f57 100644 --- a/src/goto-programs/goto_convert_functions.h +++ b/src/goto-programs/goto_convert_functions.h @@ -19,20 +19,20 @@ void goto_convert( symbol_tablet &symbol_table, goto_functionst &functions, message_handlert &message_handler); - + // convert it all! void goto_convert( symbol_tablet &symbol_table, goto_modelt &dest, message_handlert &message_handler); - + // just convert a specific function void goto_convert( const irep_idt &identifier, symbol_tablet &symbol_table, goto_functionst &functions, message_handlert &message_handler); - + class goto_convert_functionst:public goto_convertt { public: @@ -43,16 +43,16 @@ class goto_convert_functionst:public goto_convertt symbol_tablet &_symbol_table, goto_functionst &_functions, message_handlert &_message_handler); - + virtual ~goto_convert_functionst(); protected: goto_functionst &functions; - + static bool hide(const goto_programt &goto_program); // - // function calls + // function calls // void add_return( goto_functionst::goto_functiont &, diff --git a/src/goto-programs/goto_convert_new_switch_case.cpp b/src/goto-programs/goto_convert_new_switch_case.cpp index a9f1103f1aa..7f0b0007e6e 100644 --- a/src/goto-programs/goto_convert_new_switch_case.cpp +++ b/src/goto-programs/goto_convert_new_switch_case.cpp @@ -65,13 +65,13 @@ void goto_convertt::finish_gotos() it++) { goto_programt::instructiont &i=**it; - + if(i.code.get_statement()=="non-deterministic-goto") { const irept &destinations=i.code.find("destinations"); i.make_goto(); - + forall_irep(it, destinations.get_sub()) { labelst::const_iterator l_it= @@ -84,7 +84,7 @@ void goto_convertt::finish_gotos() error_msg(); throw 0; } - + i.targets.push_back(l_it->second); } } @@ -129,7 +129,7 @@ void goto_convertt::finish_gotos() throw 0; } } - + targets.gotos.clear(); } @@ -154,16 +154,16 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) { goto_programt::instructiont &i=**g_it; exprt destination=i.code.op0(); - + assert(destination.id()==ID_dereference); assert(destination.operands().size()==1); - + exprt pointer=destination.op0(); // remember the expression for later checks i.type=OTHER; i.code=code_expressiont(pointer); - + // insert huge case-split for(labelst::const_iterator l_it=targets.labels.begin(); @@ -174,10 +174,10 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) label_expr.set(ID_identifier, l_it->first); equal_exprt guard; - + guard.lhs()=pointer; guard.rhs()=address_of_exprt(label_expr); - + goto_programt::targett t= goto_program.insert_after(*g_it); @@ -186,7 +186,7 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) t->guard=guard; } } - + targets.computed_gotos.clear(); } @@ -273,10 +273,10 @@ void goto_convertt::convert_label( error() << "label statement expected to have one operand" << eom; throw 0; } - + // grab the label const irep_idt &label=code.get_label(); - + goto_programt tmp; // magic thread creation label? @@ -290,7 +290,7 @@ void goto_convertt::convert_label( } else convert(to_code(code.op0()), tmp); - + goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -340,10 +340,10 @@ void goto_convertt::convert_switch_case( error() << "switch-case statement expected to have two operands" << eom; throw 0; } - + goto_programt tmp; convert(code.code(), tmp); - + goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -363,7 +363,7 @@ void goto_convertt::convert_switch_case( dest.add_instruction(GOTO); g->source_location=code.source_location(); - + targets.cases.push_back(std::make_pair(g, caset())); cases_entry=targets.cases_map.insert(std::make_pair( @@ -397,10 +397,10 @@ void goto_convertt::convert_gcc_switch_case_range( error() << "GCC's switch-case-range statement expected to have three operands" << eom; throw 0; } - + goto_programt tmp; convert(to_code(code.op2()), tmp); - + //goto_programt::targett target=tmp.instructions.begin(); dest.destructive_append(tmp); @@ -436,7 +436,7 @@ void goto_convertt::convert( goto_programt &dest) { const irep_idt &statement=code.get_statement(); - + if(statement==ID_block) convert_block(to_code_block(code), dest); else if(statement==ID_decl) @@ -585,8 +585,8 @@ void goto_convertt::convert_block( // this saves the size of the destructor stack std::size_t old_stack_size=targets.destructor_stack.size(); - - // now convert block + + // now convert block forall_operands(it, code) { const codet &b_code=to_code(*it); @@ -622,9 +622,9 @@ void goto_convertt::convert_expression( error() << "expression statement takes one operand" << eom; throw 0; } - + exprt expr=code.op0(); - + if(expr.id()==ID_if) { // We do a special treatment for c?t:f @@ -643,7 +643,7 @@ void goto_convertt::convert_expression( { clean_expr(expr, dest, false); // result _not_ used - // Any residual expression? + // Any residual expression? // We keep it to add checks later. if(expr.is_not_nil()) { @@ -672,7 +672,7 @@ void goto_convertt::convert_decl( goto_programt &dest) { const exprt &op0=code.op0(); - + if(op0.id()!=ID_symbol) { err_location(op0); @@ -681,9 +681,9 @@ void goto_convertt::convert_decl( } const irep_idt &identifier=op0.get(ID_identifier); - + const symbolt &symbol=lookup(identifier); - + if(symbol.is_static_lifetime || symbol.type.id()==ID_code) return; // this is a SKIP! @@ -696,11 +696,11 @@ void goto_convertt::convert_decl( { // this is expected to go away exprt initializer; - + codet tmp=code; initializer=code.op1(); tmp.operands().resize(1); - + // Break up into decl and assignment. // Decl must be visible before initializer. copy(tmp, DECL, dest); @@ -785,7 +785,7 @@ void goto_convertt::convert_assign( error() << "function_call sideeffect takes two operands" << eom; throw 0; } - + Forall_operands(it, rhs) clean_expr(*it, dest); @@ -832,7 +832,7 @@ void goto_convertt::convert_assign( else { clean_expr(rhs, dest); - + if(lhs.id()==ID_typecast) { assert(lhs.operands().size()==1); @@ -841,9 +841,9 @@ void goto_convertt::convert_assign( exprt new_rhs=rhs; rhs.make_typecast(lhs.op0().type()); - // remove typecast from lhs + // remove typecast from lhs exprt tmp=lhs.op0(); - lhs.swap(tmp); + lhs.swap(tmp); } code_assignt new_assign(code); @@ -876,7 +876,7 @@ void goto_convertt::convert_init( error() << "init statement takes two operands" << eom; throw 0; } - + // make it an assignment codet assignment=code; assignment.set_statement(ID_assign); @@ -906,24 +906,24 @@ void goto_convertt::convert_cpp_delete( error() << "cpp_delete statement takes one operand" << eom; throw 0; } - + exprt tmp_op=code.op0(); - + clean_expr(tmp_op, dest); - + // we call the destructor, and then free const exprt &destructor= static_cast(code.find(ID_destructor)); - + irep_idt delete_identifier; - + if(code.get_statement()==ID_cpp_delete_array) delete_identifier="__delete_array"; else if(code.get_statement()==ID_cpp_delete) delete_identifier="__delete"; else assert(false); - + if(destructor.is_not_nil()) { if(code.get_statement()==ID_cpp_delete_array) @@ -936,7 +936,7 @@ void goto_convertt::convert_cpp_delete( // just one object exprt deref_op(ID_dereference, tmp_op.type().subtype()); deref_op.copy_to_operands(tmp_op); - + codet tmp_code=to_code(destructor); replace_new_object(deref_op, tmp_code); convert(tmp_code, dest); @@ -944,22 +944,22 @@ void goto_convertt::convert_cpp_delete( else assert(false); } - + // now do "free" exprt delete_symbol=ns.lookup(delete_identifier).symbol_expr(); - + assert(to_code_type(delete_symbol.type()).parameters().size()==1); typet arg_type= to_code_type(delete_symbol.type()).parameters().front().type(); - + code_function_callt delete_call; delete_call.function()=delete_symbol; delete_call.arguments().push_back(typecast_exprt(tmp_op, arg_type)); delete_call.lhs().make_nil(); delete_call.add_source_location()=code.source_location(); - - convert(delete_call, dest); + + convert(delete_call, dest); } /*******************************************************************\ @@ -981,7 +981,7 @@ void goto_convertt::convert_assert( exprt cond=code.assertion(); clean_expr(cond, dest); - + goto_programt::targett t=dest.add_instruction(ASSERT); t->guard.swap(cond); t->source_location=code.source_location(); @@ -1055,7 +1055,7 @@ void goto_convertt::convert_for( // A; while(c) { P; B; } //----------------------------- // A; - // u: sideeffects in c + // u: sideeffects in c // v: if(!c) goto z; // w: P; // x: B; <-- continue target @@ -1065,7 +1065,7 @@ void goto_convertt::convert_for( // A; if(code.init().is_not_nil()) convert(to_code(code.init()), dest); - + exprt cond=code.cond(); goto_programt sideeffects; @@ -1080,7 +1080,7 @@ void goto_convertt::convert_for( // do the v label goto_programt tmp_v; goto_programt::targett v=tmp_v.add_instruction(); - + // do the z label goto_programt tmp_z; goto_programt::targett z=tmp_z.add_instruction(SKIP); @@ -1088,7 +1088,7 @@ void goto_convertt::convert_for( // do the x label goto_programt tmp_x; - + if(code.op2().is_nil()) { tmp_x.add_instruction(SKIP); @@ -1106,7 +1106,7 @@ void goto_convertt::convert_for( tmp_x.instructions.back().source_location=code.source_location(); } } - + // optimize the v label if(sideeffects.instructions.empty()) u=v; @@ -1124,7 +1124,7 @@ void goto_convertt::convert_for( // do the w label goto_programt tmp_w; convert(code.body(), tmp_w); - + // y: goto u; goto_programt tmp_y; goto_programt::targett y=tmp_y.add_instruction(); @@ -1234,13 +1234,13 @@ void goto_convertt::convert_dowhile( throw 0; } - // save source location + // save source location source_locationt condition_location=code.op0().find_source_location(); exprt cond=code.op0(); goto_programt sideeffects; - clean_expr(cond, sideeffects); + clean_expr(cond, sideeffects); // do P while(c); //-------------------- @@ -1327,7 +1327,7 @@ exprt goto_convertt::case_guard( tmp.swap(dest.op0()); dest.swap(tmp); } - + return dest; } @@ -1369,7 +1369,7 @@ void goto_convertt::convert_switch( error() << "switch takes at least two operands" << eom; throw 0; } - + exprt argument=code.value(); goto_programt sideeffects; @@ -1403,7 +1403,7 @@ void goto_convertt::convert_switch( convert(to_code(*it), tmp); goto_programt tmp_cases; - + goto_programt::targett previous=a; for(casest::iterator it=targets.cases.begin(); @@ -1411,18 +1411,18 @@ void goto_convertt::convert_switch( it++) { const caset &case_ops=it->second; - + // we generate a goto for 'case' assert(it->first->is_goto()); - + assert(!case_ops.empty()); - + exprt guard_expr=case_guard(argument, case_ops); - + // adjust previous case to jump here previous->set_target(it->first); it->first->guard=guard_expr; - + previous=it->first; } @@ -1503,21 +1503,21 @@ void goto_convertt::convert_return( error() << "return takes none or one operand" << eom; throw 0; } - + code_returnt new_code(code); - + if(new_code.has_return_value()) { bool result_is_used= new_code.return_value().type().id()!=ID_empty; - + goto_programt sideeffects; clean_expr(new_code.return_value(), sideeffects, result_is_used); dest.destructive_append(sideeffects); // remove void-typed return value if(!result_is_used) - new_code.operands().resize(0); + new_code.operands().resize(0); } if(targets.has_return_value) @@ -1545,10 +1545,10 @@ void goto_convertt::convert_return( throw 0; } } - + // Need to process _entire_ destructor stack. unwind_destructor_stack(code.source_location(), 0, dest); - + // add goto to end-of-function goto_programt::targett t=dest.add_instruction(); t->make_goto(targets.return_target, true_exprt()); @@ -1741,7 +1741,7 @@ void goto_convertt::convert_specc_wait( { #if 0 goto_programt::targett t=dest.add_instruction(WAIT); - + if(code.operands().size()!=1) { err_location(code); @@ -1809,14 +1809,14 @@ void goto_convertt::convert_start_thread( dest.add_instruction(START_THREAD); start_thread->source_location=code.source_location(); - + { // start_thread label; // goto tmp; // label: op0-code // end_thread // tmp: skip - + goto_programt::targett goto_instruction=dest.add_instruction(GOTO); goto_instruction->guard=true_exprt(); goto_instruction->source_location=code.source_location(); @@ -1825,7 +1825,7 @@ void goto_convertt::convert_start_thread( convert(to_code(code.op0()), tmp); goto_programt::targett end_thread=tmp.add_instruction(END_THREAD); end_thread->source_location=code.source_location(); - + start_thread->targets.push_back(tmp.instructions.begin()); dest.destructive_append(tmp); goto_instruction->targets.push_back(dest.add_instruction(SKIP)); @@ -1934,7 +1934,7 @@ void goto_convertt::convert_bp_enforce( error_msg(); throw 0; } - + // do an assume exprt op=code.op0(); @@ -1945,15 +1945,15 @@ void goto_convertt::convert_bp_enforce( t->source_location=code.source_location(); // change the assignments - + goto_programt tmp; convert(to_code(code.op1()), tmp); - + if(!op.is_true()) { exprt constraint(op); make_next_state(constraint); - + Forall_goto_program_instructions(it, tmp) { if(it->is_assign()) @@ -1979,7 +1979,7 @@ void goto_convertt::convert_bp_enforce( } } } - + dest.destructive_append(tmp); } @@ -2005,12 +2005,12 @@ void goto_convertt::convert_bp_abortif( error() << "bp_abortif expects one argument" << eom; throw 0; } - + // do an assert exprt op=code.op0(); clean_expr(op, dest); - + op.make_not(); goto_programt::targett t=dest.add_instruction(ASSERT); @@ -2040,9 +2040,9 @@ void goto_convertt::convert_ifthenelse( error() << "ifthenelse takes three operands" << eom; throw 0; } - + assert(code.then_case().is_not_nil()); - + bool has_else= !code.else_case().is_nil(); @@ -2148,7 +2148,7 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(true_case); return; } - + // similarly, do guarded assertions directly if(true_case.instructions.size()==1 && true_case.instructions.back().is_assert() && @@ -2260,7 +2260,7 @@ static bool has_and_or(const exprt &expr) if(expr.id()==ID_and || expr.id()==ID_or) return true; - + return false; } @@ -2281,10 +2281,10 @@ void goto_convertt::generate_conditional_branch( goto_programt::targett target_false=tmp.add_instruction(); target_false->make_skip(); target_false->source_location=source_location; - + generate_conditional_branch( guard, target_true, target_false, source_location, dest); - + dest.destructive_append(tmp); } else @@ -2292,7 +2292,7 @@ void goto_convertt::generate_conditional_branch( // simple branch exprt cond=guard; clean_expr(cond, dest); - + goto_programt tmp; goto_programt::targett g=tmp.add_instruction(); g->make_goto(target_true); @@ -2338,10 +2338,10 @@ void goto_convertt::generate_conditional_branch( // if(!a) goto target_false; // if(!b) goto target_false; // goto target_true; - + std::list op; collect_operands(guard, guard.id(), op); - + forall_expr_list(it, op) generate_conditional_branch( boolean_negate(*it), target_false, source_location, dest); @@ -2350,7 +2350,7 @@ void goto_convertt::generate_conditional_branch( t_true->make_goto(target_true); t_true->guard=true_exprt(); t_true->source_location=source_location; - + return; } else if(guard.id()==ID_or) @@ -2364,7 +2364,7 @@ void goto_convertt::generate_conditional_branch( std::list op; collect_operands(guard, guard.id(), op); - + forall_expr_list(it, op) generate_conditional_branch( *it, target_true, source_location, dest); @@ -2373,13 +2373,13 @@ void goto_convertt::generate_conditional_branch( t_false->make_goto(target_false); t_false->guard=true_exprt(); t_false->source_location=guard.source_location(); - + return; } exprt cond=guard; clean_expr(cond, dest); - + goto_programt::targett t_true=dest.add_instruction(); t_true->make_goto(target_true); t_true->guard=cond; @@ -2417,7 +2417,7 @@ const irep_idt goto_convertt::get_string_constant( { exprt index_op=get_constant(expr.op0().op0()); simplify(index_op, ns); - + if(index_op.id()==ID_string_constant) return index_op.get(ID_value); else if(index_op.id()==ID_array) @@ -2432,7 +2432,7 @@ const irep_idt goto_convertt::get_string_constant( if(i!=0) // to skip terminating 0 result+=char(i); } - + return result; } } @@ -2506,22 +2506,22 @@ symbolt &goto_convertt::new_tmp_symbol( { auxiliary_symbolt new_symbol; symbolt *symbol_ptr; - + do { new_symbol.base_name="tmp_"+suffix+"$"+i2string(++temporary_counter); new_symbol.name=tmp_symbol_prefix+id2string(new_symbol.base_name); - new_symbol.type=type; + new_symbol.type=type; new_symbol.location=source_location; - } while(symbol_table.move(new_symbol, symbol_ptr)); - + } while(symbol_table.move(new_symbol, symbol_ptr)); + tmp_symbols.push_back(symbol_ptr->name); - + goto_programt::targett t=dest.add_instruction(DECL); t->code=code_declt(symbol_ptr->symbol_expr()); t->source_location=source_location; - return *symbol_ptr; + return *symbol_ptr; } /*******************************************************************\ @@ -2542,7 +2542,7 @@ void goto_convertt::make_temp_symbol( goto_programt &dest) { const source_locationt source_location=expr.find_source_location(); - + symbolt &new_symbol= new_tmp_symbol(expr.type(), suffix, dest, source_location); @@ -2624,7 +2624,7 @@ void goto_convert( { goto_convert.goto_convert(code, dest); } - + catch(int) { goto_convert.error_msg(); @@ -2666,14 +2666,14 @@ void goto_convert( // find main symbol const symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find("main"); - + if(s_it==symbol_table.symbols.end()) { error() << "failed to find main symbol" << eom; throw 0; } - + const symbolt &symbol=s_it->second; - + ::goto_convert(to_code(symbol.value), symbol_table, dest, message_handler); } diff --git a/src/goto-programs/goto_convert_side_effect.cpp b/src/goto-programs/goto_convert_side_effect.cpp index e8a7a852fd3..4e51390026b 100644 --- a/src/goto-programs/goto_convert_side_effect.cpp +++ b/src/goto-programs/goto_convert_side_effect.cpp @@ -60,7 +60,7 @@ void goto_convertt::remove_assignment( bool result_is_used) { const irep_idt statement=expr.get_statement(); - + if(statement==ID_assign) { exprt tmp=expr; @@ -120,7 +120,7 @@ void goto_convertt::remove_assignment( } exprt rhs; - + const typet &op0_type=ns.follow(expr.op0().type()); // C/C++ Booleans get very special treatment. @@ -130,17 +130,17 @@ void goto_convertt::remove_assignment( tmp.op0().make_typecast(expr.op1().type()); rhs=typecast_exprt(is_not_zero(tmp, ns), expr.op0().type()); } - else + else { rhs.id(new_id); rhs.copy_to_operands(expr.op0(), expr.op1()); rhs.type()=expr.op0().type(); rhs.add_source_location()=expr.source_location(); } - + code_assignt assignment(expr.op0(), rhs); assignment.add_source_location()=expr.source_location(); - + convert(assignment, dest); } else @@ -193,9 +193,9 @@ void goto_convertt::remove_pre( rhs.id(ID_plus); else rhs.id(ID_minus); - + const typet &op_type=ns.follow(expr.op0().type()); - + if(op_type.id()==ID_bool) { rhs.copy_to_operands(expr.op0(), gen_one(signed_int_type())); @@ -243,7 +243,7 @@ void goto_convertt::remove_pre( code_assignt assignment(expr.op0(), rhs); assignment.add_source_location()=expr.find_source_location(); - + convert(assignment, dest); if(result_is_used) @@ -297,9 +297,9 @@ void goto_convertt::remove_post( rhs.id(ID_plus); else rhs.id(ID_minus); - + const typet &op_type=ns.follow(expr.op0().type()); - + if(op_type.id()==ID_bool) { rhs.copy_to_operands(expr.op0(), gen_one(signed_int_type())); @@ -347,7 +347,7 @@ void goto_convertt::remove_post( code_assignt assignment(expr.op0(), rhs); assignment.add_source_location()=expr.find_source_location(); - + convert(assignment, tmp2); // fix up the expression, if needed @@ -422,13 +422,13 @@ void goto_convertt::remove_function_call( { const irep_idt &identifier=expr.op0().get(ID_identifier); const symbolt &symbol=lookup(identifier); - + std::string new_base_name=id2string(new_symbol.base_name); - + new_base_name+='_'; new_base_name+=id2string(symbol.base_name); new_base_name+="$"+i2string(++temporary_counter); - + new_symbol.base_name=new_base_name; new_symbol.mode=symbol.mode; } @@ -436,7 +436,7 @@ void goto_convertt::remove_function_call( new_symbol.name=tmp_symbol_prefix+id2string(new_symbol.base_name); new_name(new_symbol); - + { code_declt decl; decl.symbol()=new_symbol.symbol_expr(); @@ -542,15 +542,15 @@ void goto_convertt::remove_cpp_delete( assert(expr.operands().size()==1); codet tmp; - + tmp.set_statement(expr.get_statement()); tmp.add_source_location()=expr.source_location(); tmp.copy_to_operands(expr.op0()); tmp.set(ID_destructor, expr.find(ID_destructor)); convert_cpp_delete(tmp, dest); - - expr.make_nil(); + + expr.make_nil(); } /*******************************************************************\ @@ -590,7 +590,7 @@ void goto_convertt::remove_malloc( call=code_assignt(new_symbol.symbol_expr(), expr); call.add_source_location()=expr.source_location(); - + static_cast(expr)=new_symbol.symbol_expr(); } else @@ -631,7 +631,7 @@ void goto_convertt::remove_temporary_object( new_tmp_symbol(expr.type(), "obj", dest, expr.find_source_location()); new_symbol.mode=expr.get(ID_mode); - + if(expr.operands().size()==1) { codet assignment(ID_assign); @@ -691,21 +691,21 @@ void goto_convertt::remove_statement_expression( } codet &code=to_code(expr.op0()); - + if(!result_is_used) { convert(code, dest); expr.make_nil(); return; } - + if(code.get_statement()!=ID_block) { error().source_location=code.find_source_location(); error() << "statement_expression takes block as operand" << eom; throw 0; } - + if(code.operands().empty()) { error().source_location=expr.find_source_location(); @@ -713,7 +713,7 @@ void goto_convertt::remove_statement_expression( << eom; throw 0; } - + // get last statement from block, following labels codet &last=to_code_block(code).find_last_statement(); @@ -721,7 +721,7 @@ void goto_convertt::remove_statement_expression( symbolt &new_symbol= new_tmp_symbol(expr.type(), "statement_expression", dest, source_location); - + symbol_exprt tmp_symbol_expr(new_symbol.name, new_symbol.type); tmp_symbol_expr.add_source_location()=source_location; @@ -748,7 +748,7 @@ void goto_convertt::remove_statement_expression( } { - goto_programt tmp; + goto_programt tmp; convert(code, tmp); dest.destructive_append(tmp); } @@ -774,7 +774,7 @@ void goto_convertt::remove_side_effect( bool result_is_used) { const irep_idt &statement=expr.get_statement(); - + if(statement==ID_function_call) remove_function_call(expr, dest, result_is_used); else if(statement==ID_assign || @@ -823,7 +823,7 @@ void goto_convertt::remove_side_effect( t->code.op0().operands().swap(expr.operands()); t->code.add_source_location()=expr.source_location(); t->source_location=expr.source_location(); - + // the result can't be used, these are void expr.make_nil(); } @@ -834,4 +834,3 @@ void goto_convertt::remove_side_effect( throw 0; } } - diff --git a/src/goto-programs/goto_functions.cpp b/src/goto-programs/goto_functions.cpp index a6c12027b87..ceec1cf97f0 100644 --- a/src/goto-programs/goto_functions.cpp +++ b/src/goto-programs/goto_functions.cpp @@ -27,10 +27,10 @@ void get_local_identifiers( std::set &dest) { goto_function.body.get_decl_identifiers(dest); - + const code_typet::parameterst ¶meters= goto_function.type.parameters(); - + // add parameters for(code_typet::parameterst::const_iterator a_it=parameters.begin(); @@ -40,4 +40,4 @@ void get_local_identifiers( const irep_idt &identifier=a_it->get_identifier(); if(identifier!="") dest.insert(identifier); } -} +} diff --git a/src/goto-programs/goto_functions.h b/src/goto-programs/goto_functions.h index 866bd296e7b..c2c95e7f85e 100644 --- a/src/goto-programs/goto_functions.h +++ b/src/goto-programs/goto_functions.h @@ -22,7 +22,7 @@ class goto_functionst:public goto_functions_templatet #define Forall_goto_functions(it, functions) \ for(goto_functionst::function_mapt::iterator it=(functions).function_map.begin(); \ it!=(functions).function_map.end(); it++) - + #define forall_goto_functions(it, functions) \ for(goto_functionst::function_mapt::const_iterator it=(functions).function_map.begin(); \ it!=(functions).function_map.end(); it++) diff --git a/src/goto-programs/goto_functions_template.h b/src/goto-programs/goto_functions_template.h index 116610fb6f5..73876c607b5 100644 --- a/src/goto-programs/goto_functions_template.h +++ b/src/goto-programs/goto_functions_template.h @@ -23,7 +23,7 @@ class goto_function_templatet public: bodyT body; code_typet type; - + typedef std::vector parameter_identifierst; parameter_identifierst parameter_identifiers; @@ -36,12 +36,12 @@ class goto_function_templatet { return type.get_bool(ID_C_inlined); } - + inline bool is_hidden() const { return type.get_bool(ID_C_hide); } - + inline void make_hidden() { type.set(ID_C_hide, true); @@ -50,7 +50,7 @@ class goto_function_templatet goto_function_templatet() { } - + void clear() { body.clear(); @@ -87,7 +87,7 @@ class goto_functions_templatet typedef goto_function_templatet goto_functiont; typedef std::map function_mapt; function_mapt function_map; - + inline goto_functions_templatet() { } @@ -97,16 +97,16 @@ class goto_functions_templatet { assert(src.function_map.empty()); } - + inline void clear() { function_map.clear(); } - + void output( const namespacet &ns, std::ostream &out) const; - + void compute_location_numbers(); void compute_loop_numbers(); void compute_target_numbers(); @@ -124,12 +124,12 @@ class goto_functions_templatet // do not confuse with C's "int main()" return ID__start; } - + inline void swap(goto_functions_templatet &other) { function_map.swap(other.function_map); } - + void copy_from(const goto_functions_templatet &other) { for(typename function_mapt::const_iterator @@ -166,11 +166,11 @@ void goto_functions_templatet::output( if(it->second.body_available()) { out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"; - + const symbolt &symbol=ns.lookup(it->first); out << symbol.display_name() << " /* " << symbol.name << " */\n"; it->second.body.output(ns, symbol.name, out); - + out << std::flush; } } @@ -265,5 +265,5 @@ void goto_functions_templatet::compute_loop_numbers() it++) it->second.body.compute_loop_numbers(); } - + #endif diff --git a/src/goto-programs/goto_inline.cpp b/src/goto-programs/goto_inline.cpp index f7dcd2b202b..21fd341d538 100644 --- a/src/goto-programs/goto_inline.cpp +++ b/src/goto-programs/goto_inline.cpp @@ -43,7 +43,7 @@ void goto_inlinet::parameter_assignments( const code_typet::parameterst ¶meter_types= code_type.parameters(); - + // iterates over the types of the parameters for(code_typet::parameterst::const_iterator it2=parameter_types.begin(); @@ -72,7 +72,7 @@ void goto_inlinet::parameter_assignments( decl->code=code_declt(symbol.symbol_expr()); decl->code.add_source_location()=source_location; decl->source_location=source_location; - decl->function=function_name; + decl->function=function_name; } // this is the actual parameter @@ -93,7 +93,7 @@ void goto_inlinet::parameter_assignments( // nil means "don't assign" if(actual.is_nil()) - { + { } else { @@ -103,7 +103,7 @@ void goto_inlinet::parameter_assignments( { const typet &f_partype = ns.follow(par_type); const typet &f_acttype = ns.follow(actual.type()); - + // we are willing to do some conversion if((f_partype.id()==ID_pointer && f_acttype.id()==ID_pointer) || @@ -118,7 +118,7 @@ void goto_inlinet::parameter_assignments( f_partype.id()==ID_bool) && (f_acttype.id()==ID_signedbv || f_acttype.id()==ID_unsignedbv || - f_acttype.id()==ID_bool)) + f_acttype.id()==ID_bool)) { actual.make_typecast(par_type); } @@ -144,7 +144,7 @@ void goto_inlinet::parameter_assignments( dest.add_instruction(ASSIGN); dest.instructions.back().source_location=source_location; dest.instructions.back().code.swap(assignment); - dest.instructions.back().function=function_name; + dest.instructions.back().function=function_name; } if(it1!=arguments.end()) @@ -177,7 +177,7 @@ void goto_inlinet::parameter_destruction( { const code_typet::parameterst ¶meter_types= code_type.parameters(); - + // iterates over the types of the parameters for(code_typet::parameterst::const_iterator it=parameter_types.begin(); @@ -203,7 +203,7 @@ void goto_inlinet::parameter_destruction( dead->code=code_deadt(symbol.symbol_expr()); dead->code.add_source_location()=source_location; dead->source_location=source_location; - dead->function=function_name; + dead->function=function_name; } } } @@ -242,10 +242,10 @@ void goto_inlinet::replace_return( warning_msg(); continue; } - + goto_programt tmp; goto_programt::targett assignment=tmp.add_instruction(ASSIGN); - + code_assignt code_assign(lhs, it->code.op0()); // this may happen if the declared return type at the call site @@ -257,7 +257,7 @@ void goto_inlinet::replace_return( assignment->code=code_assign; assignment->source_location=it->source_location; assignment->function=it->function; - + if(constrain.is_not_nil() && !constrain.is_true()) { codet constrain(ID_bp_constrain); @@ -265,7 +265,7 @@ void goto_inlinet::replace_return( constrain.move_to_operands(assignment->code); constrain.copy_to_operands(constrain); } - + dest.insert_before_swap(it, *assignment); it++; } @@ -273,12 +273,12 @@ void goto_inlinet::replace_return( { goto_programt tmp; goto_programt::targett expression=tmp.add_instruction(OTHER); - + expression->code=codet(ID_expression); expression->code.move_to_operands(it->code.op0()); expression->source_location=it->source_location; expression->function=it->function; - + dest.insert_before_swap(it, *expression); it++; } @@ -294,7 +294,7 @@ void goto_inlinet::replace_return( << it->code.pretty() << eom; continue; } - + code_assignt code_assign(lhs, it->code.op0()); // this may happen if the declared return type at the call site @@ -357,7 +357,7 @@ void replace_location( irep_idt property_id=dest.get_property_id(); dest=new_location; - + if(comment!=irep_idt()) dest.set_comment(comment); if(property_class!=irep_idt()) dest.set_property_class(property_class); if(property_id!=irep_idt()) dest.set_property_id(property_id); @@ -409,7 +409,7 @@ void goto_inlinet::expand_function_call( { // look it up const irep_idt identifier=function.get_identifier(); - + // we ignore certain calls if(identifier=="__CPROVER_cleanup" || identifier=="__CPROVER_set_must" || @@ -421,7 +421,7 @@ void goto_inlinet::expand_function_call( target++; return; // ignore } - + // see if we are already expanding it if(recursion_set.find(identifier)!=recursion_set.end()) { @@ -436,7 +436,7 @@ void goto_inlinet::expand_function_call( warning().source_location=function.find_source_location(); warning() << "recursion is ignored" << eom; target->make_skip(); - + target++; return; } @@ -456,10 +456,10 @@ void goto_inlinet::expand_function_call( error() << "failed to find function `" << identifier << "'" << eom; throw 0; } - + const goto_functionst::goto_functiont &f=m_it->second; - // see if we need to inline this + // see if we need to inline this if(!full) { if(!f.body_available() || @@ -479,10 +479,10 @@ void goto_inlinet::expand_function_call( goto_programt tmp2; tmp2.copy_from(f.body); - + assert(tmp2.instructions.back().is_end_function()); tmp2.instructions.back().type=LOCATION; - + replace_return(tmp2, lhs, constrain); goto_programt tmp; @@ -494,11 +494,11 @@ void goto_inlinet::expand_function_call( { source_locationt new_source_location= function.find_source_location(); - + if(new_source_location.is_not_nil()) { new_source_location.set_hide(); - + Forall_goto_program_instructions(it, tmp) { if(it->function==identifier) @@ -520,10 +520,10 @@ void goto_inlinet::expand_function_call( } } - // set up location instruction for function call + // set up location instruction for function call target->type=LOCATION; target->code.clear(); - + goto_programt::targett next_target(target); next_target++; @@ -551,7 +551,7 @@ void goto_inlinet::expand_function_call( t->source_location=target->source_location; t->function=target->function; } - + // return value if(lhs.is_not_nil()) { @@ -560,7 +560,7 @@ void goto_inlinet::expand_function_call( code_assignt code(lhs, rhs); code.add_source_location()=target->source_location; - + goto_programt::targett t=tmp.add_instruction(ASSIGN); t->source_location=target->source_location; t->function=target->function; @@ -592,7 +592,7 @@ Function: goto_inlinet::goto_inline void goto_inlinet::goto_inline(goto_programt &dest) { goto_inline_rec(dest, true); - replace_return(dest, + replace_return(dest, static_cast(get_nil_irep()), static_cast(get_nil_irep())); } @@ -614,18 +614,18 @@ void goto_inlinet::goto_inline_rec( bool full) { // already done? - + if(finished_inlining_set.find(f_it->first)!= finished_inlining_set.end()) return; // yes - + // do it - + goto_inline_rec(f_it->second.body, full); - + // remember we did it - - finished_inlining_set.insert(f_it->first); + + finished_inlining_set.insert(f_it->first); } /*******************************************************************\ @@ -655,7 +655,7 @@ void goto_inlinet::goto_inline_rec(goto_programt &dest, bool full) if(changed) { - remove_skip(dest); + remove_skip(dest); dest.update(); } } @@ -711,10 +711,10 @@ bool goto_inlinet::inline_instruction( } } - // advance iterator + // advance iterator it++; - return false; + return false; } /*******************************************************************\ @@ -735,16 +735,16 @@ void goto_inline( message_handlert &message_handler) { goto_inlinet goto_inline(goto_functions, ns, message_handler); - + try { // find entry point goto_functionst::function_mapt::iterator it= goto_functions.function_map.find(goto_functionst::entry_point()); - + if(it==goto_functions.function_map.end()) return; - + goto_inline.goto_inline(it->second.body); } @@ -765,7 +765,7 @@ void goto_inline( goto_inline.error() << e << messaget::eom; throw 0; } - + // clean up for(goto_functionst::function_mapt::iterator it=goto_functions.function_map.begin(); @@ -817,9 +817,9 @@ void goto_partial_inline( goto_functions, ns, message_handler); - + goto_inline.smallfunc_limit=_smallfunc_limit; - + try { for(goto_functionst::function_mapt::iterator diff --git a/src/goto-programs/goto_inline_class.h b/src/goto-programs/goto_inline_class.h index e67f3588174..1006d6fb66c 100644 --- a/src/goto-programs/goto_inline_class.h +++ b/src/goto-programs/goto_inline_class.h @@ -26,7 +26,7 @@ class goto_inlinet:public messaget ns(_ns) { } - + void goto_inline(goto_programt &dest); void goto_inline_rec( @@ -34,7 +34,7 @@ class goto_inlinet:public messaget bool full); void goto_inline_rec(goto_programt &dest, bool full); - + // inline single instruction at 'target' // returns true in case a change was done // set 'full' to perform this recursively @@ -43,12 +43,12 @@ class goto_inlinet:public messaget bool full, goto_programt::targett &target); - unsigned smallfunc_limit; + unsigned smallfunc_limit; protected: goto_functionst &goto_functions; const namespacet &ns; - + void expand_function_call( goto_programt &dest, goto_programt::targett &target, @@ -57,12 +57,12 @@ class goto_inlinet:public messaget const exprt::operandst &arguments, const exprt &constrain, bool recursive); - + void replace_return( goto_programt &body, const exprt &lhs, const exprt &constrain); - + void parameter_assignments( const source_locationt &source_location, const irep_idt &function_name, @@ -78,7 +78,7 @@ class goto_inlinet:public messaget typedef hash_set_cont recursion_sett; recursion_sett recursion_set; - + typedef hash_set_cont no_body_sett; no_body_sett no_body_set; diff --git a/src/goto-programs/goto_model.h b/src/goto-programs/goto_model.h index 89af1df1291..96261aeb2cb 100644 --- a/src/goto-programs/goto_model.h +++ b/src/goto-programs/goto_model.h @@ -21,29 +21,29 @@ class goto_modelt public: symbol_tablet symbol_table; goto_functionst goto_functions; - + inline void clear() { symbol_table.clear(); goto_functions.clear(); } - + void output(std::ostream &out) { namespacet ns(symbol_table); goto_functions.output(ns, out); } - + inline goto_modelt() { } - + inline goto_modelt(goto_modelt &&other) { symbol_table.swap(other.symbol_table); goto_functions.swap(other.goto_functions); } - + // copying is likely too expensive goto_modelt(const goto_modelt &) = delete; }; diff --git a/src/goto-programs/goto_program.cpp b/src/goto-programs/goto_program.cpp index 82d1d3e91f8..b83c1a10efd 100644 --- a/src/goto-programs/goto_program.cpp +++ b/src/goto-programs/goto_program.cpp @@ -52,7 +52,7 @@ std::ostream& goto_programt::output_instruction( { out << " " << *l_it; } - + out << '\n'; } @@ -66,7 +66,7 @@ std::ostream& goto_programt::output_instruction( case NO_INSTRUCTION_TYPE: out << "NO INSTRUCTION TYPE SET" << '\n'; break; - + case GOTO: if(!it->guard.is_true()) { @@ -76,7 +76,7 @@ std::ostream& goto_programt::output_instruction( } out << "GOTO "; - + for(instructiont::targetst::const_iterator gt_it=it->targets.begin(); gt_it!=it->targets.end(); @@ -85,10 +85,10 @@ std::ostream& goto_programt::output_instruction( if(gt_it!=it->targets.begin()) out << ", "; out << (*gt_it)->target_number; } - + out << '\n'; break; - + case RETURN: case OTHER: case DECL: @@ -97,61 +97,61 @@ std::ostream& goto_programt::output_instruction( case ASSIGN: out << from_expr(ns, identifier, it->code) << '\n'; break; - + case ASSUME: case ASSERT: if(it->is_assume()) out << "ASSUME "; else out << "ASSERT "; - + { out << from_expr(ns, identifier, it->guard); - + const irep_idt &comment=it->source_location.get_comment(); if(comment!="") out << " // " << comment; } - + out << '\n'; break; case SKIP: out << "SKIP" << '\n'; break; - + case END_FUNCTION: out << "END_FUNCTION" << '\n'; break; - + case LOCATION: out << "LOCATION" << '\n'; break; - + case THROW: out << "THROW"; { const irept::subt &exception_list= it->code.find(ID_exception_list).get_sub(); - + for(irept::subt::const_iterator it=exception_list.begin(); it!=exception_list.end(); it++) out << " " << it->id(); } - + if(it->code.operands().size()==1) out << ": " << from_expr(ns, identifier, it->code.op0()); - + out << '\n'; break; - + case CATCH: if(!it->targets.empty()) { out << "CATCH-PUSH "; - + unsigned i=0; const irept::subt &exception_list= it->code.find(ID_exception_list).get_sub(); @@ -169,36 +169,36 @@ std::ostream& goto_programt::output_instruction( } else out << "CATCH-POP"; - + out << '\n'; break; - + case ATOMIC_BEGIN: out << "ATOMIC_BEGIN" << '\n'; break; - + case ATOMIC_END: out << "ATOMIC_END" << '\n'; break; - + case START_THREAD: out << "START THREAD "; if(it->targets.size()==1) out << it->targets.front()->target_number; - + out << '\n'; break; - + case END_THREAD: out << "END THREAD" << '\n'; break; - + default: throw "unknown statement"; } - return out; + return out; } /*******************************************************************\ @@ -226,7 +226,7 @@ void goto_programt::get_decl_identifiers( decl_identifiers.insert(symbol_expr.get_identifier()); } } -} +} /*******************************************************************\ @@ -291,12 +291,12 @@ std::list expressions_read( case GOTO: dest.push_back(instruction.guard); break; - + case RETURN: if(to_code_return(instruction.code).return_value().is_not_nil()) dest.push_back(to_code_return(instruction.code).return_value()); break; - + case FUNCTION_CALL: { const code_function_callt &function_call= @@ -307,7 +307,7 @@ std::list expressions_read( parse_lhs_read(function_call.lhs(), dest); } break; - + case ASSIGN: { const code_assignt &assignment=to_code_assign(instruction.code); @@ -315,10 +315,10 @@ std::list expressions_read( parse_lhs_read(assignment.lhs(), dest); } break; - + default:; } - + return dest; } @@ -349,14 +349,14 @@ std::list expressions_written( dest.push_back(function_call.lhs()); } break; - + case ASSIGN: dest.push_back(to_code_assign(instruction.code).lhs()); break; - + default:; } - + return dest; } @@ -374,7 +374,7 @@ Function: get_objects_read void objects_read( const exprt &src, - std::list &dest) + std::list &dest) { if(src.id()==ID_symbol) dest.push_back(src); @@ -414,10 +414,10 @@ std::list objects_read( std::list expressions=expressions_read(instruction); std::list dest; - + forall_expr_list(it, expressions) objects_read(*it, dest); - + return dest; } @@ -465,10 +465,10 @@ std::list objects_written( std::list expressions=expressions_written(instruction); std::list dest; - + forall_expr_list(it, expressions) objects_written(*it, dest); - + return dest; } @@ -494,7 +494,7 @@ std::string as_string( { case NO_INSTRUCTION_TYPE: return "(NO INSTRUCTION TYPE)"; - + case GOTO: if(!i.guard.is_true()) { @@ -504,7 +504,7 @@ std::string as_string( } result+="GOTO "; - + for(goto_programt::instructiont::targetst::const_iterator gt_it=i.targets.begin(); gt_it!=i.targets.end(); @@ -514,7 +514,7 @@ std::string as_string( result+=i2string((*gt_it)->target_number); } return result; - + case RETURN: case OTHER: case DECL: @@ -522,14 +522,14 @@ std::string as_string( case FUNCTION_CALL: case ASSIGN: return from_expr(ns, i.function, i.code); - + case ASSUME: case ASSERT: if(i.is_assume()) result+="ASSUME "; else result+="ASSERT "; - + result+=from_expr(ns, i.function, i.guard); { @@ -540,39 +540,38 @@ std::string as_string( case SKIP: return "SKIP"; - + case END_FUNCTION: return "END_FUNCTION"; - + case LOCATION: return "LOCATION"; - + case THROW: return "THROW"; - + case CATCH: return "CATCH"; - + case ATOMIC_BEGIN: return "ATOMIC_BEGIN"; - + case ATOMIC_END: return "ATOMIC_END"; - + case START_THREAD: result+="START THREAD "; if(i.targets.size()==1) result+=i2string(i.targets.front()->target_number); return result; - + case END_THREAD: return "END THREAD"; - + default: throw "unknown statement"; } return ""; } - diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index 9b186ff3f68..c7f859545c4 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -29,7 +29,7 @@ class goto_programt:public goto_program_templatet instructionst::const_iterator it) const; goto_programt() { } - + // get the variables in decl statements typedef std::set decl_identifierst; void get_decl_identifiers(decl_identifierst &decl_identifiers) const; @@ -44,7 +44,7 @@ class goto_programt:public goto_program_templatet for(goto_programt::instructionst::iterator \ it=(program).instructions.begin(); \ it!=(program).instructions.end(); it++) - + extern inline bool operator<(const goto_programt::const_targett i1, const goto_programt::const_targett i2) { diff --git a/src/goto-programs/goto_program_irep.cpp b/src/goto-programs/goto_program_irep.cpp index 6ec61240254..cbf78acd295 100644 --- a/src/goto-programs/goto_program_irep.cpp +++ b/src/goto-programs/goto_program_irep.cpp @@ -19,41 +19,41 @@ Date: May 2007 Function: convert - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ -void convert(const goto_programt::instructiont &instruction, irept &irep) -{ +void convert(const goto_programt::instructiont &instruction, irept &irep) +{ irep.set(ID_code, instruction.code); - + if(instruction.function!="") irep.set(ID_function, instruction.function); - + if(instruction.source_location.is_not_nil()) irep.set(ID_location, instruction.source_location); - - irep.set(ID_type, (long) instruction.type); + + irep.set(ID_type, (long) instruction.type); irep.set(ID_guard, instruction.guard); - + if(!instruction.targets.empty()) { - irept &tgts=irep.add(ID_targets); + irept &tgts=irep.add(ID_targets); for(goto_programt::targetst::const_iterator it= instruction.targets.begin(); it!=instruction.targets.end(); it++) { irept t(i2string((*it)->location_number)); - tgts.move_to_sub(t); + tgts.move_to_sub(t); } - } - + } + if(!instruction.labels.empty()) { irept &lbls = irep.add(ID_labels); @@ -73,11 +73,11 @@ void convert(const goto_programt::instructiont &instruction, irept &irep) Function: convert - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -91,11 +91,11 @@ void convert( instruction.type = static_cast( unsafe_string2unsigned(irep.find(ID_type).id_string())); instruction.guard = static_cast(irep.find(ID_guard)); - + // don't touch the targets, the goto_programt conversion does that - + const irept &lbls=irep.find(ID_labels); - const irept::subt &lsubs=lbls.get_sub(); + const irept::subt &lsubs=lbls.get_sub(); for (irept::subt::const_iterator it=lsubs.begin(); it!=lsubs.end(); it++) @@ -108,11 +108,11 @@ void convert( Function: convert - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -127,52 +127,52 @@ void convert( const goto_programt &program, irept &irep ) { irep.get_sub().push_back(irept()); convert(*it, irep.get_sub().back()); - } + } } /*******************************************************************\ Function: convert - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ void convert( const irept &irep, goto_programt &program ) { assert(irep.id()=="goto-program"); - + program.instructions.clear(); - + std::list< std::list > number_targets_list; - + // convert instructions back - const irept::subt &subs = irep.get_sub(); + const irept::subt &subs = irep.get_sub(); for (irept::subt::const_iterator it=subs.begin(); it!=subs.end(); it++) { program.instructions.push_back(goto_programt::instructiont()); convert(*it, program.instructions.back()); - + number_targets_list.push_back(std::list()); const irept &targets=it->find(ID_targets); const irept::subt &tsubs=targets.get_sub(); for (irept::subt::const_iterator tit=tsubs.begin(); tit!=tsubs.end(); tit++) - { + { number_targets_list.back().push_back( unsafe_string2unsigned(tit->id_string())); } } - + program.compute_location_numbers(); - + // resolve targets std::list< std::list >::iterator nit= number_targets_list.begin(); @@ -190,19 +190,19 @@ void convert( const irept &irep, goto_programt &program ) { if (fit->location_number==*tit) { - lit->targets.push_back(fit); + lit->targets.push_back(fit); break; } } - + if (fit==program.instructions.end()) - { + { std::cout << "Warning: could not resolve target link " << "during irep->goto_program translation." << std::endl; throw 0; } } } - + program.update(); } diff --git a/src/goto-programs/goto_program_template.cpp b/src/goto-programs/goto_program_template.cpp index 1d97653a681..80fc9089c74 100644 --- a/src/goto-programs/goto_program_template.cpp +++ b/src/goto-programs/goto_program_template.cpp @@ -18,8 +18,8 @@ Function: operator<< Outputs: - Purpose: - + Purpose: + \*******************************************************************/ std::ostream &operator<<(std::ostream &out, goto_program_instruction_typet t) @@ -46,6 +46,6 @@ std::ostream &operator<<(std::ostream &out, goto_program_instruction_typet t) default: out << "?"; } - + return out; } diff --git a/src/goto-programs/goto_program_template.h b/src/goto-programs/goto_program_template.h index aaf9cd275b9..4de571933f7 100644 --- a/src/goto-programs/goto_program_template.h +++ b/src/goto-programs/goto_program_template.h @@ -81,28 +81,28 @@ class goto_program_templatet { public: codeT code; - + //! function this belongs to irep_idt function; - + //! the location of the instruction in the source file source_locationt source_location; - + //! what kind of instruction? goto_program_instruction_typet type; //! guard for gotos, assume, assert guardT guard; - + // The below will eventually become a single target only. //! the target for gotos and for start_thread nodes typedef typename std::list::iterator targett; typedef typename std::list::const_iterator const_targett; typedef std::list targetst; typedef std::list const_targetst; - + targetst targets; - + // for the usual case of a single target inline targett get_target() const { @@ -117,7 +117,7 @@ class goto_program_templatet targets.push_back(t); } - //! goto target labels + //! goto target labels typedef std::list labelst; labelst labels; @@ -128,7 +128,7 @@ class goto_program_templatet inline bool is_target() const { return target_number!=unsigned(-1); } - //! clear the node + //! clear the node inline void clear(goto_program_instruction_typet _type) { type=_type; @@ -136,7 +136,7 @@ class goto_program_templatet guard=true_exprt(); code.make_nil(); } - + inline void make_goto() { clear(GOTO); } inline void make_return() { clear(RETURN); } inline void make_function_call(const codeT &_code) { clear(FUNCTION_CALL); code=_code; } @@ -157,7 +157,7 @@ class goto_program_templatet make_goto(); targets.push_back(_target); } - + inline void make_goto(targett _target, const guardT &g) { make_goto(_target); @@ -201,7 +201,7 @@ class goto_program_templatet { } - //! swap two instructions + //! swap two instructions void swap(instructiont &instruction) { instruction.code.swap(code); @@ -211,15 +211,15 @@ class goto_program_templatet instruction.targets.swap(targets); instruction.function.swap(function); } - + //! A globally unique number to identify a program location. //! It's guaranteed to be ordered in program order within //! one goto_program. unsigned location_number; - + //! Number unique per function to identify loops unsigned loop_number; - + //! A number to identify branch targets. //! This is -1 if it's not a target. unsigned target_number; @@ -232,13 +232,13 @@ class goto_program_templatet for(const auto & t : targets) if(t->location_number<=location_number) return true; - + return false; - } + } }; typedef std::list instructionst; - + typedef typename instructionst::iterator targett; typedef typename instructionst::const_iterator const_targett; typedef typename std::list targetst; @@ -246,7 +246,7 @@ class goto_program_templatet //! The list of instructions in the goto program instructionst instructions; - + void get_successors( targett target, targetst &successors); @@ -265,7 +265,7 @@ class goto_program_templatet next++; instructions.insert(next, instructiont())->swap(*target); } - + //! Insertion that preserves jumps to "target". //! The instruction is destroyed. void insert_before_swap(targett target, instructiont &instruction) @@ -273,7 +273,7 @@ class goto_program_templatet insert_before_swap(target); target->swap(instruction); } - + //! Insertion that preserves jumps to "target". //! The program p is destroyed. void insert_before_swap(targett target, goto_program_templatet &p) @@ -286,14 +286,14 @@ class goto_program_templatet p.instructions.erase(p.instructions.begin()); instructions.splice(next, p.instructions); } - + //! Insertion before the given target //! \return newly inserted location inline targett insert_before(targett target) { return instructions.insert(target, instructiont()); } - + //! Insertion after the given target //! \return newly inserted location inline targett insert_after(targett target) @@ -302,7 +302,7 @@ class goto_program_templatet t++; return instructions.insert(t, instructiont()); } - + //! Appends the given program, which is destroyed inline void destructive_append(goto_program_templatet &p) { @@ -344,13 +344,13 @@ class goto_program_templatet const irep_idt &identifier, std::ostream &out) const; - //! Output goto-program to given stream + //! Output goto-program to given stream inline std::ostream &output(std::ostream &out) const { return output(namespacet(symbol_tablet()), "", out); } - //! Output a single instruction + //! Output a single instruction virtual std::ostream &output_instruction( const namespacet &ns, const irep_idt &identifier, @@ -366,18 +366,18 @@ class goto_program_templatet for(auto & i : instructions) i.location_number=nr++; } - + //! Compute location numbers inline void compute_location_numbers() { unsigned nr=0; compute_location_numbers(nr); } - + //! Compute loop numbers void compute_loop_numbers(); - //! Update all indices + //! Update all indices void update(); //! Human-readable loop name @@ -386,7 +386,7 @@ class goto_program_templatet return id2string(target->function)+"."+ i2string(target->loop_number); } - + //! Is the program empty? inline bool empty() const { @@ -402,24 +402,24 @@ class goto_program_templatet { } - //! Swap the goto program + //! Swap the goto program inline void swap(goto_program_templatet &program) { program.instructions.swap(instructions); } - //! Clear the goto program + //! Clear the goto program inline void clear() { instructions.clear(); } - //! Copy a full goto program, preserving targets + //! Copy a full goto program, preserving targets void copy_from(const goto_program_templatet &src); - //! Does the goto program have an assertion? + //! Does the goto program have an assertion? bool has_assertion() const; -}; +}; template void goto_program_templatet::compute_loop_numbers() @@ -440,7 +440,7 @@ void goto_program_templatet::get_successors( targett next=target; next++; - + const instructiont &i=*target; if(i.is_goto()) @@ -489,7 +489,7 @@ void goto_program_templatet::get_successors( const_targett next=target; next++; - + const instructiont &i=*target; if(i.is_goto()) @@ -549,17 +549,17 @@ std::ostream& goto_program_templatet::output( it++) output_instruction(ns, identifier, out, it); - return out; + return out; } template void goto_program_templatet::compute_target_numbers() { // reset marking - + for(auto & i : instructions) i.target_number=-1; - + // mark the goto targets for(const auto & i : instructions) @@ -570,10 +570,10 @@ void goto_program_templatet::compute_target_numbers() t->target_number=0; } } - + // number the targets properly unsigned cnt=0; - + for(auto & i : instructions) { if(i.is_target()) @@ -597,7 +597,7 @@ void goto_program_templatet::compute_target_numbers() } } } - + } template @@ -623,7 +623,7 @@ void goto_program_templatet::copy_from( } // Loop over program - 2nd time updates targets - + for(auto & i : instructions) { for(auto & t : i.targets) @@ -667,9 +667,9 @@ void goto_program_templatet::compute_incoming_edges() it++) { targetst successors; - + get_successors(it, successors); - + for(const auto & s : successors) { if(s!=instructions.end()) diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp index 8370e4b48f3..c27607129a2 100644 --- a/src/goto-programs/goto_trace.cpp +++ b/src/goto-programs/goto_trace.cpp @@ -124,14 +124,14 @@ void goto_trace_stept::output( out << "Violated property:" << "\n"; if(pc->source_location.is_nil()) out << " " << pc->source_location << "\n"; - + if(comment!="") out << " " << comment << "\n"; out << " " << from_expr(ns, "", pc->guard) << "\n"; out << "\n"; } } - + out << "\n"; } @@ -152,7 +152,7 @@ std::string trace_value_binary( const namespacet &ns) { const typet &type=ns.follow(expr.type()); - + if(expr.id()==ID_constant) { if(type.id()==ID_unsignedbv || @@ -176,29 +176,29 @@ std::string trace_value_binary( else if(expr.id()==ID_array) { std::string result; - + forall_operands(it, expr) { if(result=="") result="{ "; else result+=", "; result+=trace_value_binary(*it, ns); } - + return result+" }"; } else if(expr.id()==ID_struct) { std::string result="{ "; - + forall_operands(it, expr) { if(it!=expr.operands().begin()) result+=", "; result+=trace_value_binary(*it, ns); } - + return result+" }"; } else if(expr.id()==ID_union) - { + { assert(expr.operands().size()==1); return trace_value_binary(expr.op0(), ns); } @@ -231,7 +231,7 @@ void trace_value( identifier=lhs_object.get_object_name(); std::string value_string; - + if(value.is_nil()) value_string="(assignment removed)"; else @@ -267,12 +267,12 @@ void show_state_header( unsigned step_nr) { out << "\n"; - + if(step_nr==0) out << "Initial State"; else out << "State " << step_nr; - + out << " " << source_location << " thread " << state.thread_nr << "\n"; out << "----------------------------------------------------" << "\n"; @@ -330,7 +330,7 @@ void show_goto_trace( // hide the hidden ones if(it->hidden) continue; - + switch(it->type) { case goto_trace_stept::ASSERT: @@ -344,11 +344,11 @@ void show_goto_trace( if(it->pc->is_assert()) out << " " << from_expr(ns, "", it->pc->guard) << "\n"; - + out << "\n"; } break; - + case goto_trace_stept::ASSUME: if(!it->cond_value) { @@ -359,14 +359,14 @@ void show_goto_trace( if(it->pc->is_assume()) out << " " << from_expr(ns, "", it->pc->guard) << "\n"; - + out << "\n"; } break; - + case goto_trace_stept::LOCATION: break; - + case goto_trace_stept::GOTO: break; @@ -382,7 +382,7 @@ void show_goto_trace( prev_step_nr=it->step_nr; show_state_header(out, *it, it->pc->source_location, it->step_nr); } - + // see if the full lhs is something clean if(is_index_member_symbol(it->full_lhs)) trace_value(out, ns, it->lhs_object, it->full_lhs, it->full_lhs_value); @@ -426,7 +426,7 @@ void show_goto_trace( // the binary representation out << " (" << trace_value_binary(*l_it, ns) << ")"; } - + out << "\n"; } break; @@ -446,10 +446,10 @@ void show_goto_trace( // the binary representation out << " (" << trace_value_binary(*l_it, ns) << ")"; } - + out << "\n"; break; - + case goto_trace_stept::FUNCTION_CALL: case goto_trace_stept::FUNCTION_RETURN: case goto_trace_stept::SPAWN: @@ -458,16 +458,16 @@ void show_goto_trace( case goto_trace_stept::ATOMIC_END: case goto_trace_stept::DEAD: break; - + case goto_trace_stept::CONSTRAINT: assert(false); break; - + case goto_trace_stept::SHARED_READ: case goto_trace_stept::SHARED_WRITE: assert(false); break; - + default: assert(false); } diff --git a/src/goto-programs/goto_trace.h b/src/goto-programs/goto_trace.h index b1629a5a6f5..04b50b77dab 100644 --- a/src/goto-programs/goto_trace.h +++ b/src/goto-programs/goto_trace.h @@ -28,11 +28,11 @@ Date: July 2005 /*! \brief TO_BE_DOCUMENTED * \ingroup gr_goto_symex */ -class goto_trace_stept +class goto_trace_stept { public: unsigned step_nr; - + bool is_assignment() const { return type==ASSIGNMENT; } bool is_assume() const { return type==ASSUME; } bool is_assert() const { return type==ASSERT; } @@ -59,41 +59,41 @@ class goto_trace_stept SHARED_READ, SHARED_WRITE, SPAWN, MEMORY_BARRIER, ATOMIC_BEGIN, ATOMIC_END } typet; typet type; - + // we may choose to hide a step bool hidden; - + // we categorize typedef enum { STATE, ACTUAL_PARAMETER } assignment_typet; assignment_typet assignment_type; - + goto_programt::const_targett pc; // this transition done by given thread number unsigned thread_nr; - + // for assume, assert, goto bool cond_value; exprt cond_expr; - + // for assert std::string comment; // the object being assigned ssa_exprt lhs_object; - + // the full, original lhs expression exprt full_lhs; // A constant with the new value exprt lhs_object_value, full_lhs_value; - + // for INPUT/OUTPUT irep_idt format_string, io_id; typedef std::list io_argst; io_argst io_args; bool formatted; - + // for function call/return irep_idt identifier; @@ -102,7 +102,7 @@ class goto_trace_stept void output( const class namespacet &ns, std::ostream &out) const; - + goto_trace_stept(): step_nr(0), type(NONE), @@ -128,15 +128,15 @@ class goto_tracet public: typedef std::list stepst; stepst steps; - + irep_idt mode; - + inline void clear() { mode.clear(); steps.clear(); } - + /*! \brief outputs the trace in ASCII to a given stream */ void output( @@ -148,19 +148,19 @@ class goto_tracet other.steps.swap(steps); other.mode.swap(mode); } - + inline void add_step(const goto_trace_stept &step) { steps.push_back(step); } - // delete all steps after (not including) s + // delete all steps after (not including) s void trim_after(stepst::iterator s) { assert(s!=steps.end()); s++; for(; - s!=steps.end(); + s!=steps.end(); s=steps.erase(s)); } }; diff --git a/src/goto-programs/interpreter.cpp b/src/goto-programs/interpreter.cpp index 9bc13619754..d4cfef09b85 100644 --- a/src/goto-programs/interpreter.cpp +++ b/src/goto-programs/interpreter.cpp @@ -32,23 +32,23 @@ Function: interpretert::operator() void interpretert::operator()() { build_memory_map(); - + const goto_functionst::function_mapt::const_iterator main_it=goto_functions.function_map.find(goto_functionst::entry_point()); if(main_it==goto_functions.function_map.end()) throw "main not found"; - + const goto_functionst::goto_functiont &goto_function=main_it->second; - + if(!goto_function.body_available()) throw "main has no body"; PC=goto_function.body.instructions.begin(); function=main_it; - + done=false; - + while(!done) { show_state(); @@ -82,7 +82,7 @@ void interpretert::show_state() } else function->second.body.output_instruction(ns, function->first, std::cout, PC); - + std::cout << std::endl; } @@ -101,7 +101,7 @@ Function: interpretert::command void interpretert::command() { #define BUFSIZE 100 - char command[BUFSIZE]; + char command[BUFSIZE]; if(fgets(command, BUFSIZE-1, stdin)==NULL) { done=true; @@ -142,37 +142,37 @@ void interpretert::step() return; } - + next_PC=PC; - next_PC++; + next_PC++; switch(PC->type) { case GOTO: execute_goto(); break; - + case ASSUME: execute_assume(); break; - + case ASSERT: execute_assert(); break; - + case OTHER: execute_other(); break; - + case DECL: execute_decl(); break; - + case SKIP: case LOCATION: case END_FUNCTION: break; - + case RETURN: if(call_stack.empty()) throw "RETURN without call"; @@ -187,35 +187,35 @@ void interpretert::step() next_PC=function->second.body.instructions.end(); break; - + case ASSIGN: execute_assign(); break; - + case FUNCTION_CALL: execute_function_call(); break; - + case START_THREAD: throw "START_THREAD not yet implemented"; - + case END_THREAD: throw "END_THREAD not yet implemented"; break; case ATOMIC_BEGIN: throw "ATOMIC_BEGIN not yet implemented"; - + case ATOMIC_END: throw "ATOMIC_END not yet implemented"; - + case DEAD: throw "DEAD not yet implemented"; - + default: throw "encountered instruction with undefined instruction type"; } - + PC=next_PC; } @@ -237,7 +237,7 @@ void interpretert::execute_goto() { if(PC->targets.empty()) throw "taken goto without target"; - + if(PC->targets.size()>=2) throw "non-deterministic goto encountered"; @@ -260,7 +260,7 @@ Function: interpretert::execute_other void interpretert::execute_other() { const irep_idt &statement=PC->code.get_statement(); - + if(statement==ID_expression) { assert(PC->code.operands().size()==1); @@ -307,10 +307,10 @@ void interpretert::execute_assign() std::vector rhs; evaluate(code_assign.rhs(), rhs); - + if(!rhs.empty()) { - mp_integer address=evaluate_address(code_assign.lhs()); + mp_integer address=evaluate_address(code_assign.lhs()); unsigned size=get_size(code_assign.lhs().type()); if(size!=rhs.size()) @@ -419,7 +419,7 @@ void interpretert::execute_function_call() if(f_it==goto_functions.function_map.end()) throw "failed to find function "+id2string(identifier); - + // return value mp_integer return_value_address; @@ -428,40 +428,40 @@ void interpretert::execute_function_call() evaluate_address(function_call.lhs()); else return_value_address=0; - + // values of the arguments std::vector > argument_values; - + argument_values.resize(function_call.arguments().size()); - + for(std::size_t i=0; isecond.body_available()) { call_stack.push(stack_framet()); stack_framet &frame=call_stack.top(); - + frame.return_PC=next_PC; frame.return_function=function; frame.old_stack_pointer=stack_pointer; frame.return_value_address=return_value_address; - + // local variables std::set locals; get_local_identifiers(f_it->second, locals); - + for(std::set::const_iterator it=locals.begin(); it!=locals.end(); it++) { - const irep_idt &id=*it; + const irep_idt &id=*it; const symbolt &symbol=ns.lookup(id); unsigned size=get_size(symbol.type); - + if(size!=0) { frame.local_map[id]=stack_pointer; @@ -474,11 +474,11 @@ void interpretert::execute_function_call() memory[address].identifier=id; memory[address].offset=i; } - + stack_pointer+=size; } } - + // assign the arguments const code_typet::parameterst ¶meters= to_code_type(f_it->second.type).parameters(); @@ -497,7 +497,7 @@ void interpretert::execute_function_call() // set up new PC function=f_it; - next_PC=f_it->second.body.instructions.begin(); + next_PC=f_it->second.body.instructions.begin(); } else throw "no body for "+id2string(identifier); @@ -528,7 +528,7 @@ void interpretert::build_memory_map() it!=symbol_table.symbols.end(); it++) build_memory_map(it->second); - + // for the locals stack_pointer=memory.size(); } @@ -563,7 +563,7 @@ void interpretert::build_memory_map(const symbolt &symbol) unsigned address=memory.size(); memory.resize(address+size); memory_map[symbol.name]=address; - + for(unsigned i=0; i memory_mapt; memory_mapt memory_map; - + class memory_cellt { public: @@ -43,17 +43,17 @@ class interpretert unsigned offset; mp_integer value; }; - + typedef std::vector memoryt; memoryt memory; - + std::size_t stack_pointer; - + void build_memory_map(); void build_memory_map(const symbolt &symbol); unsigned get_size(const typet &type) const; void step(); - + void execute_assert(); void execute_assume(); void execute_assign(); @@ -81,14 +81,14 @@ class interpretert memory_mapt local_map; unsigned old_stack_pointer; }; - + typedef std::stack call_stackt; call_stackt call_stack; - + goto_functionst::function_mapt::const_iterator function; goto_programt::const_targett PC, next_PC; bool done; - + bool evaluate_boolean(const exprt &expr) const { std::vector v; @@ -100,8 +100,8 @@ class interpretert void evaluate( const exprt &expr, std::vector &dest) const; - + mp_integer evaluate_address(const exprt &expr) const; - + void show_state(); }; diff --git a/src/goto-programs/interpreter_evaluate.cpp b/src/goto-programs/interpreter_evaluate.cpp index 97f041fd614..f402d077bfc 100644 --- a/src/goto-programs/interpreter_evaluate.cpp +++ b/src/goto-programs/interpreter_evaluate.cpp @@ -35,12 +35,12 @@ void interpretert::read( for(unsigned i=0; itype()); if(sub_size==0) continue; - + std::vector tmp; evaluate(*it, tmp); @@ -118,10 +118,10 @@ void interpretert::evaluate( else error=true; } - + if(!error) return; - + dest.clear(); } else if(expr.id()==ID_equal || @@ -142,7 +142,7 @@ void interpretert::evaluate( { const mp_integer &op0=tmp0.front(); const mp_integer &op1=tmp1.front(); - + if(expr.id()==ID_equal) dest.push_back(op0==op1); else if(expr.id()==ID_notequal) @@ -163,7 +163,7 @@ void interpretert::evaluate( { if(expr.operands().size()<1) throw id2string(expr.id())+" expects at least one operand"; - + bool result=false; forall_operands(it, expr) @@ -177,7 +177,7 @@ void interpretert::evaluate( break; } } - + dest.push_back(result); return; @@ -186,7 +186,7 @@ void interpretert::evaluate( { if(expr.operands().size()!=3) throw "if expects three operands"; - + std::vector tmp0, tmp1, tmp2; evaluate(expr.op0(), tmp0); evaluate(expr.op1(), tmp1); @@ -198,7 +198,7 @@ void interpretert::evaluate( const mp_integer &op1=tmp1.front(); const mp_integer &op2=tmp2.front(); - dest.push_back(op0!=0?op1:op2); + dest.push_back(op0!=0?op1:op2); } return; @@ -207,7 +207,7 @@ void interpretert::evaluate( { if(expr.operands().size()<1) throw id2string(expr.id())+" expects at least one operand"; - + bool result=true; forall_operands(it, expr) @@ -221,7 +221,7 @@ void interpretert::evaluate( break; } } - + dest.push_back(result); return; @@ -230,7 +230,7 @@ void interpretert::evaluate( { if(expr.operands().size()!=1) throw id2string(expr.id())+" expects one operand"; - + std::vector tmp; evaluate(expr.op0(), tmp); @@ -250,7 +250,7 @@ void interpretert::evaluate( if(tmp.size()==1) result+=tmp.front(); } - + dest.push_back(result); return; } @@ -258,7 +258,7 @@ void interpretert::evaluate( { // type-dependent! mp_integer result; - + if(expr.type().id()==ID_fixedbv) { fixedbvt f; @@ -306,7 +306,7 @@ void interpretert::evaluate( result*=tmp.front(); } } - + dest.push_back(result); return; } @@ -370,7 +370,7 @@ void interpretert::evaluate( { if(expr.operands().size()!=1) throw "typecast expects one operand"; - + std::vector tmp; evaluate(expr.op0(), tmp); @@ -394,7 +394,7 @@ void interpretert::evaluate( { const std::string s= integer2binary(value, to_unsignedbv_type(expr.type()).get_width()); - dest.push_back(binary2integer(s, false)); + dest.push_back(binary2integer(s, false)); return; } else if(expr.type().id()==ID_bool) @@ -441,10 +441,10 @@ mp_integer interpretert::evaluate_address(const exprt &expr) const if(expr.id()==ID_symbol) { const irep_idt &identifier=expr.get(ID_identifier); - + interpretert::memory_mapt::const_iterator m_it1= memory_map.find(identifier); - + if(m_it1!=memory_map.end()) return m_it1->second; @@ -452,7 +452,7 @@ mp_integer interpretert::evaluate_address(const exprt &expr) const { interpretert::memory_mapt::const_iterator m_it2= call_stack.top().local_map.find(identifier); - + if(m_it2!=call_stack.top().local_map.end()) return m_it2->second; } @@ -504,11 +504,11 @@ mp_integer interpretert::evaluate_address(const exprt &expr) const break; offset+=get_size(it->type()); - } + } return evaluate_address(expr.op0())+offset; } - + std::cout << "!! failed to evaluate address: " << from_expr(ns, function->first, expr) << std::endl; diff --git a/src/goto-programs/json_goto_trace.cpp b/src/goto-programs/json_goto_trace.cpp index 66ed0f7c33f..3d2cbf3c352 100644 --- a/src/goto-programs/json_goto_trace.cpp +++ b/src/goto-programs/json_goto_trace.cpp @@ -35,7 +35,7 @@ void convert( jsont &dest) { json_arrayt &dest_array=dest.make_array(); - + source_locationt previous_source_location; for(const auto & it : goto_trace.steps) @@ -48,14 +48,14 @@ void convert( json_location=json(source_location); else json_location=json_nullt(); - + switch(it.type) { case goto_trace_stept::ASSERT: if(!it.cond_value) { irep_idt property_id; - + if(it.pc->is_assert()) property_id=source_location.get_property_id(); else if(it.pc->is_goto()) // unwinding, we suspect @@ -64,9 +64,9 @@ void convert( id2string(it.pc->source_location.get_function())+".unwind."+ i2string(it.pc->loop_number); } - + json_objectt &json_failure=dest_array.push_back().make_object(); - + json_failure["stepType"]=json_stringt("failure"); json_failure["hidden"]=jsont::json_boolean(it.hidden); json_failure["thread"]=json_numbert(i2string(it.thread_nr)); @@ -77,13 +77,13 @@ void convert( json_failure["sourceLocation"]=json_location; } break; - + case goto_trace_stept::ASSIGNMENT: case goto_trace_stept::DECL: { irep_idt identifier=it.lhs_object.get_identifier(); json_objectt &json_assignment=dest_array.push_back().make_object(); - + json_assignment["stepType"]=json_stringt("assignment"); if(!json_location.is_null()) @@ -126,11 +126,11 @@ void convert( "actual-parameter":"variable"); } break; - + case goto_trace_stept::OUTPUT: { json_objectt &json_output=dest_array.push_back().make_object(); - + json_output["stepType"]=json_stringt("output"); json_output["hidden"]=jsont::json_boolean(it.hidden); json_output["thread"]=json_numbert(i2string(it.thread_nr)); @@ -150,16 +150,16 @@ void convert( json_output["sourceLocation"]=json_location; } break; - + case goto_trace_stept::INPUT: { json_objectt &json_input=dest_array.push_back().make_object(); - + json_input["stepType"]=json_stringt("input"); json_input["hidden"]=jsont::json_boolean(it.hidden); json_input["thread"]=json_numbert(i2string(it.thread_nr)); json_input["inputID"]=json_stringt(id2string(it.io_id)); - + json_arrayt &json_values=json_input["values"].make_array(); for(const auto l_it : it.io_args) @@ -174,7 +174,7 @@ void convert( json_input["sourceLocation"]=json_location; } break; - + case goto_trace_stept::FUNCTION_CALL: case goto_trace_stept::FUNCTION_RETURN: { @@ -182,7 +182,7 @@ void convert( (it.type==goto_trace_stept::FUNCTION_CALL)? "function-call":"function-return"; json_objectt &json_call_return=dest_array.push_back().make_object(); - + json_call_return["stepType"]=json_stringt(tag); json_call_return["hidden"]=jsont::json_boolean(it.hidden); json_call_return["thread"]=json_numbert(i2string(it.thread_nr)); @@ -198,7 +198,7 @@ void convert( json_call_return["sourceLocation"]=json_location; } break; - + default: if(source_location!=previous_source_location) { diff --git a/src/goto-programs/link_to_library.cpp b/src/goto-programs/link_to_library.cpp index 57b2e32f98e..edfe507f651 100644 --- a/src/goto-programs/link_to_library.cpp +++ b/src/goto-programs/link_to_library.cpp @@ -60,7 +60,7 @@ void link_to_library( { std::set called_functions; compute_called_functions(goto_functions, called_functions); - + // eliminate those for which we already have a body std::set missing_functions; @@ -72,7 +72,7 @@ void link_to_library( { goto_functionst::function_mapt::const_iterator f_it=goto_functions.function_map.find(*it); - + if(f_it!=goto_functions.function_map.end() && f_it->second.body_available()) { @@ -85,10 +85,10 @@ void link_to_library( else missing_functions.insert(*it); } - + // done? if(missing_functions.empty()) break; - + add_cprover_library(missing_functions, symbol_table, message_handler); // convert to CFG @@ -99,9 +99,9 @@ void link_to_library( { if(symbol_table.symbols.find(*it)!=symbol_table.symbols.end()) goto_convert(*it, symbol_table, goto_functions, message_handler); - + added_functions.insert(*it); } - + } } diff --git a/src/goto-programs/loop_ids.cpp b/src/goto-programs/loop_ids.cpp index 95f25ab6863..93119cecb93 100644 --- a/src/goto-programs/loop_ids.cpp +++ b/src/goto-programs/loop_ids.cpp @@ -82,7 +82,7 @@ void show_loop_ids( { unsigned loop_id=it->loop_number; std::string id=id2string(it->function)+"."+i2string(loop_id); - + xmlt xml_loop("loop"); xml_loop.set_attribute("name", id); xml_loop.new_element("loop-id").data=id; diff --git a/src/goto-programs/osx_fat_reader.cpp b/src/goto-programs/osx_fat_reader.cpp index 6fcc49e5031..da5cecb9ce3 100644 --- a/src/goto-programs/osx_fat_reader.cpp +++ b/src/goto-programs/osx_fat_reader.cpp @@ -112,4 +112,3 @@ bool osx_fat_readert::extract_gb( "lipo -thin hppa7100LC -output \""+dest+"\" \""+source+"\""; return system(command.c_str())!=0; } - diff --git a/src/goto-programs/parameter_assignments.cpp b/src/goto-programs/parameter_assignments.cpp index eee71af8dcb..0cb2332e692 100644 --- a/src/goto-programs/parameter_assignments.cpp +++ b/src/goto-programs/parameter_assignments.cpp @@ -65,15 +65,15 @@ void parameter_assignmentst::do_function_calls( const namespacet ns(symbol_table); const symbolt &function_symbol=ns.lookup(identifier); const code_typet &code_type=to_code_type(function_symbol.type); - + goto_programt tmp; - + for(std::size_t nr=0; nrfunction=i_it->function; } } - + std::size_t count=tmp.instructions.size(); goto_program.insert_before_swap(i_it, tmp); - + for(; count!=0; count--) i_it++; } } @@ -151,4 +151,3 @@ void parameter_assignments(goto_modelt &goto_model) parameter_assignmentst rr(goto_model.symbol_table); rr(goto_model.goto_functions); } - diff --git a/src/goto-programs/pointer_arithmetic.cpp b/src/goto-programs/pointer_arithmetic.cpp index e573b31dee9..c080329cb75 100644 --- a/src/goto-programs/pointer_arithmetic.cpp +++ b/src/goto-programs/pointer_arithmetic.cpp @@ -111,7 +111,7 @@ void pointer_arithmetict::add_to_offset(const exprt &src) if(new_offset.op1().type()!=offset.type()) new_offset.op1().make_typecast(offset.type()); - + offset=new_offset; } } @@ -135,4 +135,3 @@ void pointer_arithmetict::make_pointer(const exprt &src) else add_to_offset(src); } - diff --git a/src/goto-programs/pointer_arithmetic.h b/src/goto-programs/pointer_arithmetic.h index 8cd1a1a3d24..cd18d61ff15 100644 --- a/src/goto-programs/pointer_arithmetic.h +++ b/src/goto-programs/pointer_arithmetic.h @@ -16,7 +16,7 @@ struct pointer_arithmetict exprt pointer, offset; pointer_arithmetict(const exprt &src); - + protected: void read(const exprt &src); void add_to_offset(const exprt &src); diff --git a/src/goto-programs/property_checker.cpp b/src/goto-programs/property_checker.cpp index a4132e98d99..f94d94f4dc5 100644 --- a/src/goto-programs/property_checker.cpp +++ b/src/goto-programs/property_checker.cpp @@ -74,7 +74,7 @@ void property_checkert::initialize_property_map( it->first==goto_functions.entry_point()) { const goto_programt &goto_program=it->second.body; - + for(goto_programt::instructionst::const_iterator it=goto_program.instructions.begin(); it!=goto_program.instructions.end(); @@ -82,11 +82,11 @@ void property_checkert::initialize_property_map( { if(!it->is_assert()) continue; - + const source_locationt &source_location=it->source_location; - + irep_idt property_id=source_location.get_property_id(); - + property_statust &property_status=property_map[property_id]; property_status.result=UNKNOWN; property_status.location=it; diff --git a/src/goto-programs/property_checker.h b/src/goto-programs/property_checker.h index 60c37d95e32..3566e188667 100644 --- a/src/goto-programs/property_checker.h +++ b/src/goto-programs/property_checker.h @@ -27,7 +27,7 @@ class property_checkert:public messaget message_handlert &_message_handler); typedef enum { PASS, FAIL, ERROR, UNKNOWN } resultt; - + static std::string as_string(resultt); // Check whether all properties in goto_functions hold. @@ -35,12 +35,12 @@ class property_checkert:public messaget struct property_statust { - // this is the counterexample + // this is the counterexample goto_tracet error_trace; resultt result; goto_programt::const_targett location; }; - + // the irep_idt is the property id typedef std::map property_mapt; property_mapt property_map; diff --git a/src/goto-programs/read_bin_goto_object.cpp b/src/goto-programs/read_bin_goto_object.cpp index 91e50acfa66..653adadd46d 100644 --- a/src/goto-programs/read_bin_goto_object.cpp +++ b/src/goto-programs/read_bin_goto_object.cpp @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Read goto object files. - + Author: CM Wintersteiger - + Date: June 2006 - + \*******************************************************************/ #include @@ -17,15 +17,15 @@ Date: June 2006 #include "read_bin_goto_object.h" /*******************************************************************\ - + Function: read_goto_object_v3 - + Inputs: input stream, symbol_table, functions - + Outputs: true on error, false otherwise - + Purpose: read goto binary format v3 - + \*******************************************************************/ bool read_bin_goto_object_v3( @@ -35,31 +35,31 @@ bool read_bin_goto_object_v3( goto_functionst &functions, message_handlert &message_handler, irep_serializationt &irepconverter) -{ +{ std::size_t count = irepconverter.read_gb_word(in); // # of symbols for(std::size_t i=0; i > target_mapt; target_mapt target_map; typedef std::map rev_target_mapt; rev_target_mapt rev_target_map; - + bool hidden=false; - + std::size_t ins_count = irepconverter.read_gb_word(in); // # of instructions for(std::size_t i=0; isecond!=itarget) assert(false); - + std::size_t t_count = irepconverter.read_gb_word(in); // # of targets for(std::size_t i=0; ifirst; - + for(std::list::iterator nit = tit->second.begin(); nit!=tit->second.end(); nit++) @@ -154,27 +154,27 @@ bool read_bin_goto_object_v3( ins->targets.push_back(entry->second); } } - + f.body.update(); - + if(hidden) f.make_hidden(); } - + functions.compute_location_numbers(); return false; } /*******************************************************************\ - + Function: read_goto_object - + Inputs: input stream, symbol table, functions - + Outputs: true on error, false otherwise - + Purpose: reads a goto binary file back into a symbol and a function table - + \*******************************************************************/ bool read_bin_goto_object( @@ -183,14 +183,14 @@ bool read_bin_goto_object( symbol_tablet &symbol_table, goto_functionst &functions, message_handlert &message_handler) -{ +{ messaget message(message_handler); { char hdr[4]; hdr[0]=in.get(); hdr[1]=in.get(); - hdr[2]=in.get(); + hdr[2]=in.get(); if(hdr[0]=='G' && hdr[1]=='B' && hdr[2]=='F') ; @@ -204,7 +204,7 @@ bool read_bin_goto_object( else if(hdr[0]==0x7f && hdr[1]=='E' && hdr[2]=='L' && hdr[3]=='F') { if(filename!="") - message.error() << + message.error() << "Sorry, but I can't read ELF binary `" << filename << "'" << messaget::eom; else message.error() << "Sorry, but I can't read ELF binaries" << messaget::eom; @@ -215,17 +215,17 @@ bool read_bin_goto_object( { message.error() << "`" << filename << "' is not a goto-binary" << messaget::eom; return true; - } + } } } - + irep_serializationt::ireps_containert ic; irep_serializationt irepconverter(ic); //symbol_serializationt symbolconverter(ic); - + { std::size_t version=irepconverter.read_gb_word(in); - + switch(version) { case 1: @@ -236,8 +236,8 @@ bool read_bin_goto_object( return true; case 3: - return read_bin_goto_object_v3(in, filename, - symbol_table, functions, + return read_bin_goto_object_v3(in, filename, + symbol_table, functions, message_handler, irepconverter); break; @@ -248,7 +248,7 @@ bool read_bin_goto_object( "goto-cc; please recompile" << messaget::eom; return true; } - } - + } + return false; } diff --git a/src/goto-programs/read_bin_goto_object.h b/src/goto-programs/read_bin_goto_object.h index b0b90f419af..f9864036764 100644 --- a/src/goto-programs/read_bin_goto_object.h +++ b/src/goto-programs/read_bin_goto_object.h @@ -1,11 +1,11 @@ /*******************************************************************\ - + Module: Read goto object files. - + Author: CM Wintersteiger - + Date: May 2007 - + \*******************************************************************/ #ifndef CPROVER_READ_BIN_GOTO_OBJECT_H diff --git a/src/goto-programs/read_goto_binary.cpp b/src/goto-programs/read_goto_binary.cpp index 5e3bb530293..cbc9a9af64d 100644 --- a/src/goto-programs/read_goto_binary.cpp +++ b/src/goto-programs/read_goto_binary.cpp @@ -85,11 +85,11 @@ bool read_goto_binary( << messaget::eom; return true; } - + char hdr[4]; hdr[0]=in.get(); hdr[1]=in.get(); - hdr[2]=in.get(); + hdr[2]=in.get(); hdr[3]=in.get(); in.seekg(0); @@ -105,7 +105,7 @@ bool read_goto_binary( try { elf_readert elf_reader(in); - + for(unsigned i=0; ipretty() << std::endl; } - + std::cout << "B ********************\n"; #endif - + // deal with prefixes irep_idt command; unsigned pos=0; - + if(instruction.front().id()==ID_symbol && instruction.front().get(ID_identifier)=="lock") { x86_32_locked_atomic=true; pos++; } - + // done? if(pos==instruction.size()) continue; - + if(instruction[pos].id()==ID_symbol) { command=instruction[pos].get(ID_identifier); @@ -298,7 +298,7 @@ void remove_asmt::process_instruction( x86_32_locked_atomic=false; } } - + if(unknown) { // we give up; we should perhaps print a warning @@ -330,10 +330,10 @@ void remove_asmt::process_function( goto_programt tmp_dest; process_instruction(*it, tmp_dest); it->make_skip(); - + goto_programt::targett next=it; next++; - + goto_function.body.destructive_insert(next, tmp_dest); } } @@ -394,4 +394,3 @@ void remove_asm(goto_modelt &goto_model) { remove_asmt(goto_model.symbol_table, goto_model.goto_functions)(); } - diff --git a/src/goto-programs/remove_complex.cpp b/src/goto-programs/remove_complex.cpp index 8d54e499e69..553a70dab50 100644 --- a/src/goto-programs/remove_complex.cpp +++ b/src/goto-programs/remove_complex.cpp @@ -23,7 +23,7 @@ Function: complex_member Outputs: -Purpose: +Purpose: \*******************************************************************/ @@ -101,13 +101,13 @@ void remove_complex(exprt &expr) complex_member(expr.op1(), ID_real)); struct_expr.op0().add_source_location()=expr.source_location(); - + struct_expr.op1()= binary_exprt(complex_member(expr.op0(), ID_imag), expr.id(), - complex_member(expr.op1(), ID_imag)); + complex_member(expr.op1(), ID_imag)); struct_expr.op1().add_source_location()=expr.source_location(); - + expr=struct_expr; } else if(expr.id()==ID_unary_minus) @@ -122,12 +122,12 @@ void remove_complex(exprt &expr) unary_minus_exprt(complex_member(expr.op0(), ID_real)); struct_expr.op0().add_source_location()=expr.source_location(); - + struct_expr.op1()= unary_minus_exprt(complex_member(expr.op0(), ID_imag)); struct_expr.op1().add_source_location()=expr.source_location(); - + expr=struct_expr; } else if(expr.id()==ID_complex) @@ -151,13 +151,13 @@ void remove_complex(exprt &expr) typecast_exprt(complex_member(expr.op0(), ID_real), subtype); struct_expr.op0().add_source_location()=expr.source_location(); - + struct_expr.op1()= typecast_exprt(complex_member(expr.op0(), ID_imag), subtype); struct_expr.op1().add_source_location()=expr.source_location(); - - expr=struct_expr; + + expr=struct_expr; } else { @@ -168,7 +168,7 @@ void remove_complex(exprt &expr) struct_expr.op0()=typecast_exprt(expr.op0(), subtype); struct_expr.op1()=gen_zero(subtype); struct_expr.add_source_location()=expr.source_location(); - + expr=struct_expr; } } @@ -223,7 +223,7 @@ void remove_complex(typet &type) else if(type.id()==ID_complex) { remove_complex(type.subtype()); - + // Replace by a struct with two members. // The real part goes first. struct_typet struct_type; @@ -232,8 +232,8 @@ void remove_complex(typet &type) struct_type.components()[0].type()=type.subtype(); struct_type.components()[0].set_name(ID_real); struct_type.components()[1].type()=type.subtype(); - struct_type.components()[1].set_name(ID_imag); - + struct_type.components()[1].set_name(ID_imag); + type=struct_type; } } @@ -351,4 +351,3 @@ void remove_complex(goto_modelt &goto_model) { remove_complex(goto_model.symbol_table, goto_model.goto_functions); } - diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 64c60bc30a1..5054f351a05 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -53,7 +53,7 @@ class remove_function_pointerst goto_programt::targett target); std::set address_taken; - + typedef std::map type_mapt; type_mapt type_map; @@ -135,14 +135,14 @@ symbolt &remove_function_pointerst::new_tmp_symbol() auxiliary_symbolt new_symbol; symbolt *symbol_ptr; - + do { new_symbol.base_name="tmp_return_val$"+i2string(++temporary_counter); new_symbol.name="remove_function_pointers::"+id2string(new_symbol.base_name); - } while(symbol_table.move(new_symbol, symbol_ptr)); - - return *symbol_ptr; + } while(symbol_table.move(new_symbol, symbol_ptr)); + + return *symbol_ptr; } /*******************************************************************\ @@ -162,7 +162,7 @@ bool remove_function_pointerst::arg_is_type_compatible( const typet &function_type) { if(type_eq(call_type, function_type, ns)) return true; - + // any integer-vs-enum-vs-pointer is ok if(call_type.id()==ID_signedbv || call_type.id()==ID_unsigned || @@ -178,14 +178,14 @@ bool remove_function_pointerst::arg_is_type_compatible( function_type.id()==ID_c_enum || function_type.id()==ID_c_enum_tag) return true; - + return false; } - + // structs/unions need to match, // which could be made more generous - - return false; + + return false; } /*******************************************************************\ @@ -240,13 +240,13 @@ bool remove_function_pointerst::is_type_compatible( // we are quite strict here, could be much more generous if(call_parameters.size()!=function_parameters.size()) return false; - + for(unsigned i=0; imake_assignment(); t_assign->code=code_assignt( old_lhs, typecast_exprt(tmp_symbol_expr, old_lhs.type())); -} +} /*******************************************************************\ @@ -352,7 +352,7 @@ void remove_function_pointerst::remove_function_pointer( to_code_function_call(target->code); const exprt &function=code.function(); - + // this better have the right type code_typet call_type=to_code_type(function.type()); @@ -365,12 +365,12 @@ void remove_function_pointerst::remove_function_pointer( call_type.parameters().push_back( code_typet::parametert(it->type())); } - + assert(function.id()==ID_dereference); assert(function.operands().size()==1); const exprt &pointer=function.op0(); - + // Is this simple? if(pointer.id()==ID_address_of && to_address_of_expr(pointer).object().id()==ID_symbol) @@ -379,12 +379,12 @@ void remove_function_pointerst::remove_function_pointer( to_address_of_expr(pointer).object(); return; } - + typedef std::list functionst; functionst functions; - + bool return_value_used=code.lhs().is_not_nil(); - + // get all type-compatible functions // whose address is ever taken for(type_mapt::const_iterator f_it= @@ -402,19 +402,19 @@ void remove_function_pointerst::remove_function_pointer( if(f_it->first=="pthread_mutex_cleanup") continue; - + symbol_exprt expr; expr.type()=f_it->second; expr.set_identifier(f_it->first); functions.push_back(expr); } - + // the final target is a skip goto_programt final_skip; goto_programt::targett t_final=final_skip.add_instruction(); t_final->make_skip(); - + // build the calls and gotos goto_programt new_code_calls; @@ -429,24 +429,24 @@ void remove_function_pointerst::remove_function_pointer( goto_programt::targett t1=new_code_calls.add_instruction(); t1->make_function_call(code); to_code_function_call(t1->code).function()=*it; - + // the signature of the function might not match precisely fix_argument_types(to_code_function_call(t1->code)); - + fix_return_type(to_code_function_call(t1->code), new_code_calls); // goto final goto_programt::targett t3=new_code_calls.add_instruction(); t3->make_goto(t_final, true_exprt()); - + // goto to call address_of_exprt address_of; address_of.object()=*it; address_of.type()=pointer_typet(); address_of.type().subtype()=it->type(); - + if(address_of.type()!=pointer.type()) address_of.make_typecast(pointer.type()); - + goto_programt::targett t4=new_code_gotos.add_instruction(); t4->make_goto(t1, equal_exprt(pointer, address_of)); } @@ -459,14 +459,14 @@ void remove_function_pointerst::remove_function_pointer( t->source_location.set_property_class("pointer dereference"); t->source_location.set_comment("invalid function pointer"); } - + goto_programt new_code; - + // patch them all together new_code.destructive_append(new_code_gotos); new_code.destructive_append(new_code_calls); new_code.destructive_append(final_skip); - + // set locations Forall_goto_program_instructions(it, new_code) { @@ -477,10 +477,10 @@ void remove_function_pointerst::remove_function_pointer( if(!property_class.empty()) it->source_location.set_property_class(property_class); if(!comment.empty()) it->source_location.set_comment(comment); } - + goto_programt::targett next_target=target; next_target++; - + goto_program.destructive_insert(next_target, new_code); // We preserve the original dereferencing to possibly catch @@ -514,10 +514,10 @@ bool remove_function_pointerst::remove_function_pointers( { const code_function_callt &code= to_code_function_call(target->code); - + if(code.function().id()==ID_dereference) { - remove_function_pointer(goto_program, target); + remove_function_pointer(goto_program, target); did_something=true; } } @@ -546,7 +546,7 @@ Function: remove_function_pointerst::operator() void remove_function_pointerst::operator()(goto_functionst &functions) { bool did_something=false; - + for(goto_functionst::function_mapt::iterator f_it= functions.function_map.begin(); f_it!=functions.function_map.end(); diff --git a/src/goto-programs/remove_returns.cpp b/src/goto-programs/remove_returns.cpp index 57f6d989aff..ce1ced18c37 100644 --- a/src/goto-programs/remove_returns.cpp +++ b/src/goto-programs/remove_returns.cpp @@ -63,7 +63,7 @@ void remove_returnst::replace_returns( typet return_type=f_it->second.type.return_type(); const irep_idt function_id=f_it->first; - + // returns something but void? bool has_return_value=return_type!=empty_typet(); @@ -88,12 +88,12 @@ void remove_returnst::replace_returns( new_symbol.name=id2string(function_symbol.name)+RETURN_VALUE_SUFFIX; new_symbol.mode=function_symbol.mode; new_symbol.type=return_type; - + symbol_table.add(new_symbol); } goto_programt &goto_program=f_it->second.body; - + if(goto_program.empty()) return; @@ -166,7 +166,7 @@ void remove_returnst::do_function_calls( if(function_call.lhs().is_not_nil()) { exprt rhs; - + if(f_it->second.body_available()) { symbol_exprt return_value; @@ -178,7 +178,7 @@ void remove_returnst::do_function_calls( { rhs=side_effect_expr_nondett(function_call.lhs().type()); } - + goto_programt::targett t_a=goto_program.insert_after(i_it); t_a->make_assignment(); t_a->source_location=i_it->source_location; @@ -460,4 +460,3 @@ void restore_returns( remove_returnst rr(symbol_table); rr.restore(goto_functions); } - diff --git a/src/goto-programs/remove_skip.cpp b/src/goto-programs/remove_skip.cpp index 946b48d0a81..b2b05e8305f 100644 --- a/src/goto-programs/remove_skip.cpp +++ b/src/goto-programs/remove_skip.cpp @@ -24,13 +24,13 @@ static bool is_skip(goto_programt::instructionst::iterator it) { // we won't remove labelled statements // (think about error labels or the like) - + if(!it->labels.empty()) return false; if(it->is_skip()) return !it->code.get_bool(ID_explicit); - + if(it->is_goto()) { if(it->guard.is_false()) return true; @@ -46,13 +46,13 @@ static bool is_skip(goto_programt::instructionst::iterator it) return it->guard.is_true() && it->targets.front()==next_it; } - + if(it->is_other()) { if(it->code.is_nil()) return true; - + const irep_idt &statement=it->code.get_statement(); - + if(statement==ID_skip) return true; else if(statement==ID_expression) @@ -67,10 +67,10 @@ static bool is_skip(goto_programt::instructionst::iterator it) return true; } } - + return false; } - + return false; } @@ -91,11 +91,11 @@ void remove_skip(goto_programt &goto_program) // This needs to be a fixed-point, as // removing a skip can turn a goto into a skip. std::size_t old_size; - + do { old_size=goto_program.instructions.size(); - + // maps deleted instructions to their replacement typedef std::map new_targetst; new_targetst new_targets; @@ -107,7 +107,7 @@ void remove_skip(goto_programt &goto_program) it!=goto_program.instructions.end();) { goto_programt::targett old_target=it; - + // for collecting labels std::list labels; @@ -124,7 +124,7 @@ void remove_skip(goto_programt &goto_program) } goto_programt::targett new_target=it; - + // save labels it->labels.splice(it->labels.begin(), labels); @@ -147,7 +147,7 @@ void remove_skip(goto_programt &goto_program) t_it!=i_it->targets.end(); t_it++) { - new_targetst::const_iterator + new_targetst::const_iterator result=new_targets.find(*t_it); if(result!=new_targets.end()) @@ -156,7 +156,7 @@ void remove_skip(goto_programt &goto_program) } // now delete the skips -- we do so after adjusting the - // gotos to avoid dangling targets + // gotos to avoid dangling targets for(new_targetst::const_iterator it=new_targets.begin(); it!=new_targets.end(); it++) goto_program.instructions.erase(it->first); @@ -167,7 +167,7 @@ void remove_skip(goto_programt &goto_program) if(!goto_program.instructions.empty() && is_skip(--goto_program.instructions.end()) && !goto_program.instructions.back().is_target()) - goto_program.instructions.pop_back(); + goto_program.instructions.pop_back(); } while(goto_program.instructions.size()make_skip(); } } - diff --git a/src/goto-programs/remove_unused_functions.cpp b/src/goto-programs/remove_unused_functions.cpp index fa097142e4d..dcb1ec6d667 100644 --- a/src/goto-programs/remove_unused_functions.cpp +++ b/src/goto-programs/remove_unused_functions.cpp @@ -14,11 +14,11 @@ Author: CM Wintersteiger Function: remove_unused_functions - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -29,7 +29,7 @@ void remove_unused_functions( std::set used_functions; std::list unused_functions; find_used_functions(goto_functionst::entry_point(), functions, used_functions); - + for(goto_functionst::function_mapt::iterator it= functions.function_map.begin(); it!=functions.function_map.end(); @@ -38,33 +38,33 @@ void remove_unused_functions( if(used_functions.find(it->first)==used_functions.end()) unused_functions.push_back(it); } - + messaget message(message_handler); - + if(unused_functions.size()>0) { message.statistics() << "Dropping " << unused_functions.size() << " of " << - functions.function_map.size() << " functions (" << + functions.function_map.size() << " functions (" << used_functions.size() << " used)" << messaget::eom; } - for(std::list::const_iterator + for(std::list::const_iterator it=unused_functions.begin(); it!=unused_functions.end(); it++) - functions.function_map.erase(*it); + functions.function_map.erase(*it); } /*******************************************************************\ Function: find_used_functions - Inputs: + Inputs: - Outputs: + Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -75,27 +75,27 @@ void find_used_functions( { std::pair::const_iterator, bool> res = seen.insert(start); - - if(!res.second) + + if(!res.second) return; else { goto_functionst::function_mapt::const_iterator f_it = functions.function_map.find(start); - + if(f_it!=functions.function_map.end()) { - forall_goto_program_instructions(it, f_it->second.body){ + forall_goto_program_instructions(it, f_it->second.body){ if(it->type==FUNCTION_CALL) { - const code_function_callt &call = + const code_function_callt &call = to_code_function_call(to_code(it->code)); - + // check that this is actually a simple call assert(call.function().id()==ID_symbol); - - find_used_functions(call.function().get(ID_identifier), - functions, + + find_used_functions(call.function().get(ID_identifier), + functions, seen); } } diff --git a/src/goto-programs/remove_unused_functions.h b/src/goto-programs/remove_unused_functions.h index fda5426739e..24f5a896d00 100644 --- a/src/goto-programs/remove_unused_functions.h +++ b/src/goto-programs/remove_unused_functions.h @@ -13,7 +13,7 @@ Author: CM Wintersteiger #include -void remove_unused_functions( +void remove_unused_functions( goto_functionst &functions, message_handlert &message_handler); diff --git a/src/goto-programs/remove_vector.cpp b/src/goto-programs/remove_vector.cpp index 89267bf329b..90df83ca43b 100644 --- a/src/goto-programs/remove_vector.cpp +++ b/src/goto-programs/remove_vector.cpp @@ -41,10 +41,10 @@ void remove_vector(exprt &expr) { remove_vector(expr.type()); array_typet array_type=to_array_type(expr.type()); - + mp_integer dimension; to_integer(array_type.size(), dimension); - + assert(expr.operands().size()==2); const typet subtype=array_type.subtype(); // do component-wise: @@ -55,22 +55,22 @@ void remove_vector(exprt &expr) for(unsigned i=0; i functionst; void get_functions(const exprt &, functionst &); exprt get_method(const irep_idt &class_id, const irep_idt &component_name); - + exprt build_class_identifier(const exprt &); }; @@ -92,19 +92,19 @@ exprt remove_virtual_functionst::build_class_identifier( { // the class identifier is in the root class exprt e=src; - + while(1) { const typet &type=ns.follow(e.type()); assert(type.id()==ID_struct); - + const struct_typet &struct_type=to_struct_type(type); const struct_typet::componentst &components=struct_type.components(); assert(!components.empty()); - + member_exprt member_expr( e, components.front().get_name(), components.front().type()); - + if(components.front().get_name()=="@class_identifier") { // found it @@ -139,16 +139,16 @@ void remove_virtual_functionst::remove_virtual_function( const exprt &function=code.function(); assert(function.id()==ID_virtual_function); assert(!code.arguments().empty()); - + functionst functions; get_functions(function, functions); - + if(functions.empty()) { target->make_skip(); return; // give up } - + // only one option? if(functions.size()==1) { @@ -164,7 +164,7 @@ void remove_virtual_functionst::remove_virtual_function( goto_programt::targett t_final=final_skip.add_instruction(); t_final->make_skip(); - + // build the calls and gotos goto_programt new_code_calls; @@ -179,34 +179,34 @@ void remove_virtual_functionst::remove_virtual_function( goto_programt::targett t1=new_code_calls.add_instruction(); t1->make_function_call(code); to_code_function_call(t1->code).function()=it->symbol_expr; - + // goto final goto_programt::targett t3=new_code_calls.add_instruction(); t3->make_goto(t_final, true_exprt()); - exprt this_expr=code.arguments()[0]; + exprt this_expr=code.arguments()[0]; if(this_expr.type().id()!=ID_pointer || this_expr.type().id()!=ID_struct) { symbol_typet symbol_type(it->class_id); this_expr=typecast_exprt(this_expr, pointer_typet(symbol_type)); } - + exprt deref=dereference_exprt(this_expr, this_expr.type().subtype()); exprt c_id1=constant_exprt(it->class_id, string_typet()); exprt c_id2=build_class_identifier(deref); - + goto_programt::targett t4=new_code_gotos.add_instruction(); t4->make_goto(t1, equal_exprt(c_id1, c_id2)); } goto_programt new_code; - + // patch them all together new_code.destructive_append(new_code_gotos); new_code.destructive_append(new_code_calls); new_code.destructive_append(final_skip); - + // set locations Forall_goto_program_instructions(it, new_code) { @@ -217,12 +217,12 @@ void remove_virtual_functionst::remove_virtual_function( if(!property_class.empty()) it->source_location.set_property_class(property_class); if(!comment.empty()) it->source_location.set_comment(comment); } - + goto_programt::targett next_target=target; next_target++; - + goto_program.destructive_insert(next_target, new_code); - + // finally, kill original invocation target->make_skip(); } @@ -246,7 +246,7 @@ void remove_virtual_functionst::get_functions( const irep_idt class_id=function.get(ID_C_class); const irep_idt component_name=function.get(ID_component_name); assert(!class_id.empty()); - + // iterate over all children, transitively std::vector children= class_hierarchy.get_children_trans(class_id); @@ -263,7 +263,7 @@ void remove_virtual_functionst::get_functions( functions.push_back(function); } } - + // Start from current class, go to parents until something // is found. irep_idt c=class_id; @@ -306,11 +306,11 @@ exprt remove_virtual_functionst::get_method( { irep_idt id=id2string(class_id)+"."+ id2string(component_name); - + const symbolt *symbol; if(ns.lookup(id, symbol)) return nil_exprt(); - + return symbol->symbol_expr(); } @@ -336,10 +336,10 @@ bool remove_virtual_functionst::remove_virtual_functions( { const code_function_callt &code= to_code_function_call(target->code); - + if(code.function().id()==ID_virtual_function) { - remove_virtual_function(goto_program, target); + remove_virtual_function(goto_program, target); did_something=true; } } @@ -368,7 +368,7 @@ Function: remove_virtual_functionst::operator() void remove_virtual_functionst::operator()(goto_functionst &functions) { bool did_something=false; - + for(goto_functionst::function_mapt::iterator f_it= functions.function_map.begin(); f_it!=functions.function_map.end(); diff --git a/src/goto-programs/safety_checker.cpp b/src/goto-programs/safety_checker.cpp index 275a9f34719..275cffbbe09 100644 --- a/src/goto-programs/safety_checker.cpp +++ b/src/goto-programs/safety_checker.cpp @@ -44,4 +44,3 @@ safety_checkert::safety_checkert( ns(_ns) { } - diff --git a/src/goto-programs/safety_checker.h b/src/goto-programs/safety_checker.h index 31f1396922d..43b768c9a34 100644 --- a/src/goto-programs/safety_checker.h +++ b/src/goto-programs/safety_checker.h @@ -34,7 +34,7 @@ class safety_checkert:public messaget virtual resultt operator()( const goto_functionst &goto_functions)=0; - // this is the counterexample + // this is the counterexample goto_tracet error_trace; protected: diff --git a/src/goto-programs/set_properties.cpp b/src/goto-programs/set_properties.cpp index accd14aded2..d6949449411 100644 --- a/src/goto-programs/set_properties.cpp +++ b/src/goto-programs/set_properties.cpp @@ -35,12 +35,12 @@ void set_properties( it++) { if(!it->is_assert()) continue; - + irep_idt property_id=it->source_location.get_property_id(); hash_set_cont::iterator c_it=property_set.find(property_id); - + if(c_it==property_set.end()) it->type=SKIP; else @@ -87,9 +87,9 @@ void label_properties( it++) { if(!it->is_assert()) continue; - + irep_idt function=it->source_location.get_function(); - + std::string prefix=id2string(function); if(it->source_location.get_property_class()!="") { @@ -98,20 +98,20 @@ void label_properties( std::string class_infix= id2string(it->source_location.get_property_class()); - // replace the spaces by underscores + // replace the spaces by underscores std::replace(class_infix.begin(), class_infix.end(), ' ', '_'); - + prefix+=class_infix; } if(prefix!="") prefix+="."; - + unsigned &count=property_counters[prefix]; - + count++; - + std::string property_id=prefix+i2string(count); - + it->source_location.set_property_id(property_id); } } @@ -250,7 +250,7 @@ void make_assertions_false( f_it++) { goto_programt &goto_program=f_it->second.body; - + for(goto_programt::instructionst::iterator i_it=goto_program.instructions.begin(); i_it!=goto_program.instructions.end(); @@ -261,4 +261,3 @@ void make_assertions_false( } } } - diff --git a/src/goto-programs/set_properties.h b/src/goto-programs/set_properties.h index 9d6b9bee89a..216a12727fb 100644 --- a/src/goto-programs/set_properties.h +++ b/src/goto-programs/set_properties.h @@ -19,8 +19,8 @@ void set_properties( goto_modelt &goto_model, const std::list &properties); -void make_assertions_false(goto_functionst &); -void make_assertions_false(goto_modelt &); +void make_assertions_false(goto_functionst &); +void make_assertions_false(goto_modelt &); void label_properties(goto_functionst &); void label_properties(goto_programt &); diff --git a/src/goto-programs/show_goto_functions.cpp b/src/goto-programs/show_goto_functions.cpp index 286d298fa82..85733c43dba 100644 --- a/src/goto-programs/show_goto_functions.cpp +++ b/src/goto-programs/show_goto_functions.cpp @@ -50,7 +50,7 @@ void show_goto_functions( it++) { xmlt &xml_function=xml_functions.new_element("function"); - xml_function.set_attribute("name", id2string(it->first)); + xml_function.set_attribute("name", id2string(it->first)); } std::cout << xml_functions << std::endl; @@ -80,7 +80,7 @@ void show_goto_functions( std::cout << ",\n" << json_result; } break; - + case ui_message_handlert::PLAIN: goto_functions.output(ns, std::cout); break; @@ -106,6 +106,3 @@ void show_goto_functions( const namespacet ns(goto_model.symbol_table); show_goto_functions(ns, ui, goto_model.goto_functions); } - - - diff --git a/src/goto-programs/show_properties.cpp b/src/goto-programs/show_properties.cpp index 4ec953e03e5..e8ea32ca682 100644 --- a/src/goto-programs/show_properties.cpp +++ b/src/goto-programs/show_properties.cpp @@ -42,17 +42,17 @@ void show_properties( { if(!it.is_assert()) continue; - + const source_locationt &source_location=it.source_location; - + const irep_idt &comment=source_location.get_comment(); //const irep_idt &function=location.get_function(); const irep_idt &property_class=source_location.get_property_class(); const irep_idt description= (comment==""?"assertion":comment); - + irep_idt property_id=source_location.get_property_id(); - + switch(ui) { case ui_message_handlert::XML_UI: @@ -62,11 +62,11 @@ void show_properties( xml_claim.new_element("number").data=id2string(property_id); // will go away xml_claim.new_element("name").data=id2string(property_id); // will go away xml_claim.set_attribute("name", id2string(property_id)); // use this one - + xmlt &l=xml_claim.new_element(); l=xml(it.source_location); - - xml_claim.new_element("description").data=id2string(description); + + xml_claim.new_element("description").data=id2string(description); xml_claim.new_element("property").data=id2string(property_class); xml_claim.new_element("expression").data=from_expr(ns, identifier, it.guard); xml_claim.new_element("source").data=""; @@ -78,11 +78,11 @@ void show_properties( xmlt xml_property("property"); xml_property.set_attribute("name", id2string(property_id)); // use this one xml_property.set_attribute("class", id2string(property_class)); // use this one - + xmlt &property_l=xml_property.new_element(); property_l=xml(it.source_location); - - xml_property.new_element("description").data=id2string(description); + + xml_property.new_element("description").data=id2string(description); xml_property.new_element("expression").data=from_expr(ns, identifier, it.guard); std::cout << xml_property << std::endl; @@ -92,7 +92,7 @@ void show_properties( case ui_message_handlert::JSON_UI: assert(false); break; - + case ui_message_handlert::PLAIN: std::cout << "Property " << property_id << ":" << std::endl; @@ -230,4 +230,3 @@ void show_properties( else show_properties(ns, ui, goto_model.goto_functions); } - diff --git a/src/goto-programs/show_symbol_table.cpp b/src/goto-programs/show_symbol_table.cpp index 58a40c28be8..2df672e3bdb 100644 --- a/src/goto-programs/show_symbol_table.cpp +++ b/src/goto-programs/show_symbol_table.cpp @@ -48,21 +48,21 @@ void show_symbol_table_plain( std::ostream &out) { out << '\n' << "Symbols:" << '\n' << '\n'; - + // we want to sort alphabetically std::set symbols; forall_symbols(it, goto_model.symbol_table.symbols) symbols.insert(id2string(it->first)); - + const namespacet ns(goto_model.symbol_table); for(const std::string &id : symbols) { const symbolt &symbol=ns.lookup(id); - + languaget *ptr; - + if(symbol.mode=="") ptr=get_default_language(); else @@ -73,13 +73,13 @@ void show_symbol_table_plain( std::unique_ptr p(ptr); std::string type_str, value_str; - + if(symbol.type.is_not_nil()) p->from_type(symbol.type, type_str, ns); - + if(symbol.value.is_not_nil()) p->from_expr(symbol.value, value_str, ns); - + out << "Symbol......: " << symbol.name << '\n' << std::flush; out << "Pretty name.: " << symbol.pretty_name << '\n'; out << "Module......: " << symbol.module << '\n'; @@ -108,7 +108,7 @@ void show_symbol_table_plain( out << '\n'; out << "Location....: " << symbol.location << '\n'; - + out << '\n' << std::flush; } } @@ -143,4 +143,3 @@ void show_symbol_table( break; } } - diff --git a/src/goto-programs/string_abstraction.cpp b/src/goto-programs/string_abstraction.cpp index ca33c509214..229607ffa88 100644 --- a/src/goto-programs/string_abstraction.cpp +++ b/src/goto-programs/string_abstraction.cpp @@ -39,7 +39,7 @@ bool string_abstractiont::build_wrap(const exprt &object, exprt &dest, bool writ if(build(object, dest, write)) return true; // extra consistency check - // use + // use // #define build_wrap(a,b,c) build(a,b,c) // to avoid it const typet &a_t=build_abstraction_type(object.type()); @@ -912,7 +912,7 @@ const typet& string_abstractiont::build_abstraction_type(const typet &type) const typet &eff_type=ns.follow(type); abstraction_types_mapt::const_iterator map_entry= abstraction_types_map.find(eff_type); - if(map_entry!=abstraction_types_map.end()) + if(map_entry!=abstraction_types_map.end()) return map_entry->second; abstraction_types_mapt tmp; @@ -949,7 +949,7 @@ const typet& string_abstractiont::build_abstraction_type_rec(const typet &type, ::std::pair< abstraction_types_mapt::iterator, bool > map_entry( abstraction_types_map.insert(::std::make_pair( eff_type, nil_typet()))); - if(!map_entry.second) + if(!map_entry.second) return map_entry.first->second; if(eff_type.id()==ID_array || eff_type.id()==ID_pointer) @@ -1798,4 +1798,3 @@ exprt string_abstractiont::member(const exprt &a, whatt what) return result; } - diff --git a/src/goto-programs/string_instrumentation.cpp b/src/goto-programs/string_instrumentation.cpp index 2bcade33a7c..21f7e9367ed 100644 --- a/src/goto-programs/string_instrumentation.cpp +++ b/src/goto-programs/string_instrumentation.cpp @@ -107,7 +107,7 @@ class string_instrumentationt:public messaget ns(_symbol_table) { } - + void operator()(goto_programt &dest); void operator()(goto_functionst &dest); @@ -135,7 +135,7 @@ class string_instrumentationt:public messaget void do_strtok (goto_programt &dest, goto_programt::targett it, code_function_callt &call); void do_strerror(goto_programt &dest, goto_programt::targett it, code_function_callt &call); void do_fscanf (goto_programt &dest, goto_programt::targett it, code_function_callt &call); - + void do_format_string_read( goto_programt &dest, goto_programt::const_targett target, @@ -143,7 +143,7 @@ class string_instrumentationt:public messaget unsigned format_string_inx, unsigned argument_start_inx, const std::string &function_name); - + void do_format_string_write( goto_programt &dest, goto_programt::const_targett target, @@ -151,14 +151,14 @@ class string_instrumentationt:public messaget unsigned format_string_inx, unsigned argument_start_inx, const std::string &function_name); - + bool is_string_type(const typet &t) const { - return ((t.id()==ID_pointer || t.id()==ID_array) && + return ((t.id()==ID_pointer || t.id()==ID_array) && (t.subtype().id()==ID_signedbv || t.subtype().id()==ID_unsignedbv) && (to_bitvector_type(t.subtype()).get_width()==config.ansi_c.char_width)); } - + void invalidate_buffer( goto_programt &dest, goto_programt::const_targett target, @@ -270,12 +270,12 @@ void string_instrumentationt::instrument( { case ASSIGN: break; - + case FUNCTION_CALL: do_function_call(dest, it); break; - - default:; + + default:; } } @@ -299,7 +299,7 @@ void string_instrumentationt::do_function_call( to_code_function_call(target->code); exprt &function=call.function(); //const exprt &lhs=call.lhs(); - + if(function.id()==ID_symbol) { const irep_idt &identifier= @@ -338,7 +338,7 @@ void string_instrumentationt::do_function_call( do_snprintf(dest, target, call); else if(identifier=="fscanf") do_fscanf(dest, target, call); - + dest.update(); } } @@ -361,38 +361,38 @@ void string_instrumentationt::do_sprintf( code_function_callt &call) { const code_function_callt::argumentst &arguments=call.arguments(); - + if(arguments.size()<2) { error().source_location=target->source_location; error() << "sprintf expected to have two or more arguments" << eom; throw 0; } - + goto_programt tmp; - - goto_programt::targett assertion=tmp.add_instruction(); + + goto_programt::targett assertion=tmp.add_instruction(); assertion->source_location=target->source_location; - assertion->source_location.set_property_class("string"); + assertion->source_location.set_property_class("string"); assertion->source_location.set_comment("sprintf buffer overflow"); - - // in the abstract model, we have to report a + + // in the abstract model, we have to report a // (possibly false) positive here assertion->make_assertion(false_exprt()); - + do_format_string_read(tmp, target, arguments, 1, 2, "sprintf"); - + if(call.lhs().is_not_nil()) { goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN); return_assignment->source_location=target->source_location; - + exprt rhs=side_effect_expr_nondett(call.lhs().type()); rhs.add_source_location()=target->source_location; - + return_assignment->code=code_assignt(call.lhs(), rhs); } - + target->make_skip(); dest.insert_before_swap(target, tmp); } @@ -415,7 +415,7 @@ void string_instrumentationt::do_snprintf( code_function_callt &call) { const code_function_callt::argumentst &arguments=call.arguments(); - + if(arguments.size()<3) { error().source_location=target->source_location; @@ -423,30 +423,30 @@ void string_instrumentationt::do_snprintf( << eom; throw 0; } - + goto_programt tmp; - - goto_programt::targett assertion=tmp.add_instruction(); + + goto_programt::targett assertion=tmp.add_instruction(); assertion->source_location=target->source_location; - assertion->source_location.set_property_class("string"); + assertion->source_location.set_property_class("string"); assertion->source_location.set_comment("snprintf buffer overflow"); - + exprt bufsize = buffer_size(arguments[0]); assertion->make_assertion(binary_relation_exprt(bufsize, ID_ge, arguments[1])); - + do_format_string_read(tmp, target, arguments, 2, 3, "snprintf"); - + if(call.lhs().is_not_nil()) { goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN); return_assignment->source_location=target->source_location; - + exprt rhs=side_effect_expr_nondett(call.lhs().type()); rhs.add_source_location()=target->source_location; - + return_assignment->code=code_assignt(call.lhs(), rhs); } - + target->make_skip(); dest.insert_before_swap(target, tmp); } @@ -469,29 +469,29 @@ void string_instrumentationt::do_fscanf( code_function_callt &call) { const code_function_callt::argumentst &arguments=call.arguments(); - + if(arguments.size()<2) { error().source_location=target->source_location; error() << "fscanf expected to have two or more arguments" << eom; throw 0; } - + goto_programt tmp; - + do_format_string_write(tmp, target, arguments, 1, 2, "fscanf"); - + if(call.lhs().is_not_nil()) { goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN); return_assignment->source_location=target->source_location; - + exprt rhs=side_effect_expr_nondett(call.lhs().type()); rhs.add_source_location()=target->source_location; - + return_assignment->code=code_assignt(call.lhs(), rhs); } - + target->make_skip(); dest.insert_before_swap(target, tmp); } @@ -517,16 +517,16 @@ void string_instrumentationt::do_format_string_read( const std::string &function_name) { const exprt &format_arg = arguments[format_string_inx]; - + if(format_arg.id()==ID_address_of && format_arg.op0().id()==ID_index && format_arg.op0().op0().id()==ID_string_constant) { format_token_listt token_list= parse_format_string(format_arg.op0().op0().get_string(ID_value)); - + unsigned args=0; - + for(format_token_listt::const_iterator it=token_list.begin(); it!=token_list.end(); it++) @@ -535,7 +535,7 @@ void string_instrumentationt::do_format_string_read( { const exprt &arg = arguments[argument_start_inx+args]; const typet &arg_type = ns.follow(arg.type()); - + if(arg.id()!=ID_string_constant) // we don't need to check constants { goto_programt::targett assertion=dest.add_instruction(); @@ -544,28 +544,28 @@ void string_instrumentationt::do_format_string_read( std::string comment("zero-termination of string argument of "); comment += function_name; assertion->source_location.set_comment(comment); - + exprt temp(arg); - + if(arg_type.id()!=ID_pointer) { index_exprt index; index.array()=temp; index.index()=gen_zero(index_type()); - index.type()=arg_type.subtype(); - temp=address_of_exprt(index); + index.type()=arg_type.subtype(); + temp=address_of_exprt(index); } - + assertion->make_assertion(is_zero_string(temp)); } } - - if(it->type!=format_tokent::TEXT && + + if(it->type!=format_tokent::TEXT && it->type!=format_tokent::UNKNOWN) args++; - + if(find(it->flags.begin(), it->flags.end(), format_tokent::ASTERISK)!= it->flags.end()) - args++; // just eat the additional argument + args++; // just eat the additional argument } } else // non-const format string @@ -577,33 +577,33 @@ void string_instrumentationt::do_format_string_read( std::string comment("zero-termination of format string of "); comment += function_name; format_ass->source_location.set_comment(comment); - + for(unsigned i=2; isource_location=target->source_location; assertion->source_location.set_property_class("string"); std::string comment("zero-termination of string argument of "); comment += function_name; assertion->source_location.set_comment(comment); - + exprt temp(arg); - + if(arg_type.id()!=ID_pointer) { index_exprt index; index.array()=temp; index.index()=gen_zero(index_type()); - index.type()=arg_type.subtype(); - temp=address_of_exprt(index); + index.type()=arg_type.subtype(); + temp=address_of_exprt(index); } - + assertion->make_assertion(is_zero_string(temp)); } } @@ -631,39 +631,39 @@ void string_instrumentationt::do_format_string_write( const std::string &function_name) { const exprt &format_arg = arguments[format_string_inx]; - + if(format_arg.id()==ID_address_of && format_arg.op0().id()==ID_index && format_arg.op0().op0().id()==ID_string_constant) // constant format { format_token_listt token_list= parse_format_string(format_arg.op0().op0().get_string(ID_value)); - + unsigned args=0; - + for(format_token_listt::const_iterator it=token_list.begin(); it!=token_list.end(); it++) { if(find(it->flags.begin(), it->flags.end(), format_tokent::ASTERISK)!= - it->flags.end()) + it->flags.end()) continue; // asterisk means `ignore this' - + switch(it->type) { case format_tokent::STRING: { - + const exprt &argument=arguments[argument_start_inx+args]; const typet &arg_type=ns.follow(argument.type()); - + goto_programt::targett assertion=dest.add_instruction(); assertion->source_location=target->source_location; assertion->source_location.set_property_class("string"); std::string comment("format string buffer overflow in "); comment += function_name; assertion->source_location.set_comment(comment); - + if(it->field_width!=0) { exprt fwidth = from_integer(it->field_width, unsigned_int_type()); @@ -671,9 +671,9 @@ void string_instrumentationt::do_format_string_write( exprt one = gen_one(unsigned_int_type()); fw_1.move_to_operands(fwidth); fw_1.move_to_operands(one); // +1 for 0-char - + exprt fw_lt_bs; - + if(arg_type.id()==ID_pointer) fw_lt_bs=binary_relation_exprt(fw_1, ID_le, buffer_size(argument)); else @@ -684,7 +684,7 @@ void string_instrumentationt::do_format_string_write( address_of_exprt aof(index); fw_lt_bs=binary_relation_exprt(fw_1, ID_le, buffer_size(aof)); } - + assertion->make_assertion(fw_lt_bs); } else @@ -692,16 +692,16 @@ void string_instrumentationt::do_format_string_write( // this is a possible overflow. assertion->make_assertion(false_exprt()); } - + // now kill the contents invalidate_buffer(dest, target, argument, arg_type, it->field_width); - + args++; break; } case format_tokent::TEXT: case format_tokent::UNKNOWN: - { + { // nothing break; } @@ -709,18 +709,18 @@ void string_instrumentationt::do_format_string_write( { const exprt &argument=arguments[argument_start_inx+args]; const typet &arg_type=ns.follow(argument.type()); - + goto_programt::targett assignment=dest.add_instruction(ASSIGN); assignment->source_location=target->source_location; - + exprt lhs(ID_dereference, arg_type.subtype()); lhs.copy_to_operands(argument); - + exprt rhs=side_effect_expr_nondett(lhs.type()); rhs.add_source_location()=target->source_location; - + assignment->code=code_assignt(lhs, rhs); - + args++; break; } @@ -728,11 +728,11 @@ void string_instrumentationt::do_format_string_write( } } else // non-const format string - { + { for(unsigned i=argument_start_inx; isource_location.set_comment(comment); - // as we don't know any field width for the %s that - // should be here during runtime, we just report a + // as we don't know any field width for the %s that + // should be here during runtime, we just report a // possibly false positive assertion->make_assertion(false_exprt()); - + invalidate_buffer(dest, target, arguments[i], arg_type, 0); } else { goto_programt::targett assignment = dest.add_instruction(ASSIGN); assignment->source_location=target->source_location; - + exprt lhs(ID_dereference, arg_type.subtype()); lhs.copy_to_operands(arguments[i]); - + exprt rhs=side_effect_expr_nondett(lhs.type()); rhs.add_source_location()=target->source_location; - + assignment->code=code_assignt(lhs, rhs); } } @@ -772,7 +772,7 @@ void string_instrumentationt::do_format_string_write( /*******************************************************************\ -Function: string_instrumentationt::do_strncmp +Function: string_instrumentationt::do_strncmp Inputs: @@ -791,7 +791,7 @@ void string_instrumentationt::do_strncmp( /*******************************************************************\ -Function: string_instrumentationt::do_strchr +Function: string_instrumentationt::do_strchr Inputs: @@ -814,7 +814,7 @@ void string_instrumentationt::do_strchr( error() << "strchr expected to have two arguments" << eom; throw 0; } - + goto_programt tmp; goto_programt::targett assertion=tmp.add_instruction(); @@ -829,7 +829,7 @@ void string_instrumentationt::do_strchr( /*******************************************************************\ -Function: string_instrumentationt::do_strrchr +Function: string_instrumentationt::do_strrchr Inputs: @@ -852,7 +852,7 @@ void string_instrumentationt::do_strrchr( error() << "strrchr expected to have two arguments" << eom; throw 0; } - + goto_programt tmp; goto_programt::targett assertion=tmp.add_instruction(); @@ -867,7 +867,7 @@ void string_instrumentationt::do_strrchr( /*******************************************************************\ -Function: string_instrumentationt::do_strstr +Function: string_instrumentationt::do_strstr Inputs: @@ -890,7 +890,7 @@ void string_instrumentationt::do_strstr( error() << "strstr expected to have two arguments" << eom; throw 0; } - + goto_programt tmp; goto_programt::targett assertion0=tmp.add_instruction(); @@ -911,7 +911,7 @@ void string_instrumentationt::do_strstr( /*******************************************************************\ -Function: string_instrumentationt::do_strtok +Function: string_instrumentationt::do_strtok Inputs: @@ -934,7 +934,7 @@ void string_instrumentationt::do_strtok( error() << "strtok expected to have two arguments" << eom; throw 0; } - + goto_programt tmp; goto_programt::targett assertion0=tmp.add_instruction(); @@ -1013,13 +1013,13 @@ void string_instrumentationt::do_strerror( goto_programt tmp; - { + { goto_programt::targett assignment1=tmp.add_instruction(ASSIGN); exprt nondet_size=side_effect_expr_nondett(size_type()); assignment1->code=code_assignt(symbol_size.symbol_expr(), nondet_size); assignment1->source_location=it->source_location; - + goto_programt::targett assumption1=tmp.add_instruction(); assumption1->make_assumption(binary_relation_exprt( @@ -1077,7 +1077,7 @@ void string_instrumentationt::invalidate_buffer( const mp_integer &limit) { irep_idt cntr_id="string_instrumentation::$counter"; - + if(symbol_table.symbols.find(cntr_id)==symbol_table.symbols.end()) { symbolt new_symbol; @@ -1089,45 +1089,45 @@ void string_instrumentationt::invalidate_buffer( new_symbol.is_state_var=true; new_symbol.is_lvalue=true; new_symbol.is_static_lifetime=true; - + symbol_table.move(new_symbol); } - + const symbolt &cntr_sym=ns.lookup(cntr_id); - + // create a loop that runs over the buffer // and invalidates every element - + goto_programt::targett init=dest.add_instruction(ASSIGN); - init->source_location=target->source_location; + init->source_location=target->source_location; init->code=code_assignt(cntr_sym.symbol_expr(), gen_zero(cntr_sym.type)); - + goto_programt::targett check=dest.add_instruction(); - check->source_location=target->source_location; - + check->source_location=target->source_location; + goto_programt::targett invalidate=dest.add_instruction(ASSIGN); - invalidate->source_location=target->source_location; - + invalidate->source_location=target->source_location; + goto_programt::targett increment=dest.add_instruction(ASSIGN); - increment->source_location=target->source_location; - + increment->source_location=target->source_location; + exprt plus(ID_plus, unsigned_int_type()); plus.copy_to_operands(cntr_sym.symbol_expr()); plus.copy_to_operands(gen_one(unsigned_int_type())); - + increment->code=code_assignt(cntr_sym.symbol_expr(), plus); - + goto_programt::targett back=dest.add_instruction(); - back->source_location=target->source_location; + back->source_location=target->source_location; back->make_goto(check); back->guard=true_exprt(); - + goto_programt::targett exit=dest.add_instruction(); - exit->source_location=target->source_location; - exit->make_skip(); - + exit->source_location=target->source_location; + exit->make_skip(); + exprt cnt_bs, bufp; - + if(buf_type.id()==ID_pointer) bufp = buffer; else @@ -1138,24 +1138,24 @@ void string_instrumentationt::invalidate_buffer( index.type()=buf_type.subtype(); bufp = address_of_exprt(index); } - + exprt deref(ID_dereference, buf_type.subtype()); exprt b_plus_i(ID_plus, bufp.type()); b_plus_i.copy_to_operands(bufp); b_plus_i.copy_to_operands(cntr_sym.symbol_expr()); deref.copy_to_operands(b_plus_i); - + check->make_goto(exit); - + if(limit==0) check->guard= - binary_relation_exprt(cntr_sym.symbol_expr(), ID_ge, + binary_relation_exprt(cntr_sym.symbol_expr(), ID_ge, buffer_size(bufp)); else check->guard= - binary_relation_exprt(cntr_sym.symbol_expr(), ID_gt, + binary_relation_exprt(cntr_sym.symbol_expr(), ID_gt, from_integer(limit, unsigned_int_type())); - + exprt nondet=side_effect_expr_nondett(buf_type.subtype()); invalidate->code=code_assignt(deref, nondet); } diff --git a/src/goto-programs/vcd_goto_trace.cpp b/src/goto-programs/vcd_goto_trace.cpp index 0aee18d9740..e4f7eec02bd 100644 --- a/src/goto-programs/vcd_goto_trace.cpp +++ b/src/goto-programs/vcd_goto_trace.cpp @@ -35,7 +35,7 @@ std::string as_vcd_binary( const namespacet &ns) { const typet &type=ns.follow(expr.type()); - + if(expr.id()==ID_constant) { if(type.id()==ID_unsignedbv || @@ -52,7 +52,7 @@ std::string as_vcd_binary( forall_operands(it, expr) result+=as_vcd_binary(*it, ns); - + return result; } else if(expr.id()==ID_struct) @@ -61,15 +61,15 @@ std::string as_vcd_binary( forall_operands(it, expr) result+=as_vcd_binary(*it, ns); - + return result; } else if(expr.id()==ID_union) - { + { assert(expr.operands().size()==1); return as_vcd_binary(expr.op0(), ns); } - + // build "xxx" mp_integer width; @@ -93,7 +93,7 @@ std::string as_vcd_binary( return result; } - + return ""; } @@ -117,12 +117,12 @@ void output_vcd( time_t t; time(&t); out << "$date\n " << ctime(&t) << "$end" << "\n"; - + // this is pretty arbitrary out << "$timescale 1 ns $end" << "\n"; // we first collect all variables that are assigned - + numbering n; for(const auto & it : goto_trace.steps) @@ -131,7 +131,7 @@ void output_vcd( { irep_idt identifier=it.lhs_object.get_identifier(); const typet &type=it.lhs_object.type(); - + const auto number=n.number(identifier); mp_integer width; @@ -140,12 +140,12 @@ void output_vcd( width=1; else width=pointer_offset_bits(type, ns); - + if(width>=1) out << "$var reg " << width << " V" << number << " " << identifier << " $end" << "\n"; } - } + } // end of header out << "$enddefinitions $end" << "\n"; @@ -165,7 +165,7 @@ void output_vcd( timestamp++; const auto number=n.number(identifier); - + // booleans are special in VCD if(type.id()==ID_bool) { @@ -185,7 +185,7 @@ void output_vcd( } } break; - + default:; } } diff --git a/src/goto-programs/wp.cpp b/src/goto-programs/wp.cpp index 21756055e9d..a6e2c7d55c6 100644 --- a/src/goto-programs/wp.cpp +++ b/src/goto-programs/wp.cpp @@ -23,7 +23,7 @@ Function: has_nondet Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -37,11 +37,11 @@ bool has_nondet(const exprt &dest) { const side_effect_exprt &side_effect_expr=to_side_effect_expr(dest); const irep_idt &statement=side_effect_expr.get_statement(); - + if(statement==ID_nondet) return true; } - + return false; } @@ -53,7 +53,7 @@ Function: approximate_nondet_rec Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -67,7 +67,7 @@ void approximate_nondet_rec(exprt &dest, unsigned &count) dest.id(ID_nondet_symbol); return; } - + Forall_operands(it, dest) approximate_nondet_rec(*it, count); } @@ -80,7 +80,7 @@ Function: approximate_nondet Outputs: - Purpose: + Purpose: \*******************************************************************/ @@ -114,7 +114,7 @@ aliasingt aliasing( e1.op0().id()==ID_address_of && e1.op0().operands().size()==1) return aliasing(e1.op0().op0(), e2, ns); - + if(e2.id()==ID_dereference && e2.operands().size()==1 && e2.op0().id()==ID_address_of && @@ -124,7 +124,7 @@ aliasingt aliasing( // fairly radical. Ignores struct prefixes and the like. if(!base_type_eq(e1.type(), e2.type(), ns)) return A_MUSTNOT; - + // syntactically the same? if(e1==e2) return A_MUST; @@ -138,10 +138,10 @@ aliasingt aliasing( else return A_MUSTNOT; } - + // an array or struct will never alias with a variable, // nor will a struct alias with an array - + if(e1.id()==ID_index || e1.id()==ID_struct) if(e2.id()!=ID_dereference && e1.id()!=e2.id()) return A_MUSTNOT; @@ -153,7 +153,7 @@ aliasingt aliasing( // we give up, and say it may // (could do much more here) - return A_MAY; + return A_MAY; } /*******************************************************************\ @@ -199,7 +199,7 @@ void substitute_rec( exprt dest_address=address_of_exprt(dest); equal_exprt alias_cond=equal_exprt(what_address, dest_address); - + if_exprt if_expr; if_expr.cond()=alias_cond; @@ -210,10 +210,10 @@ void substitute_rec( dest=if_expr; return; } - + case A_MUSTNOT: // nothing to do - break; + break; } } } @@ -244,10 +244,10 @@ void rewrite_assignment(exprt &lhs, exprt &rhs) new_rhs.where().id(ID_member_name); new_rhs.where().set(ID_component_name, component_name); new_rhs.new_value()=rhs; - + lhs=new_lhs; rhs=new_rhs; - + rewrite_assignment(lhs, rhs); // rec. call } else if(lhs.id()==ID_index) // turn s[i]:=e into s:=(s with [i]=e) @@ -260,10 +260,10 @@ void rewrite_assignment(exprt &lhs, exprt &rhs) new_rhs.old()=new_lhs; new_rhs.where()=index_expr.index(); new_rhs.new_value()=rhs; - + lhs=new_lhs; rhs=new_rhs; - + rewrite_assignment(lhs, rhs); // rec. call } } @@ -286,10 +286,10 @@ exprt wp_assign( const namespacet &ns) { exprt pre=post; - + exprt lhs=code.lhs(), rhs=code.rhs(); - + // take care of non-determinism in the RHS approximate_nondet(rhs); @@ -297,7 +297,7 @@ exprt wp_assign( // replace lhs by rhs in pre substitute_rec(pre, lhs, rhs, ns); - + return pre; } @@ -364,7 +364,7 @@ exprt wp( const namespacet &ns) { const irep_idt &statement=code.get_statement(); - + if(statement==ID_assign) return wp_assign(to_code_assign(code), post, ns); else if(statement==ID_assume) @@ -374,7 +374,7 @@ exprt wp( else if(statement==ID_decl) return wp_decl(to_code_decl(code), post, ns); else if(statement==ID_assert) - return post; + return post; else if(statement==ID_expression) return post; else if(statement==ID_printf) diff --git a/src/goto-programs/wp.h b/src/goto-programs/wp.h index c3e13bcd2e9..4572e79776e 100644 --- a/src/goto-programs/wp.h +++ b/src/goto-programs/wp.h @@ -32,8 +32,8 @@ exprt wp( /*! \brief approximate the non-deterministic choice in a way cheaper than by (proper) quantification * \ingroup gr_wp -*/ - +*/ + void approximate_nondet(exprt &dest); #endif diff --git a/src/goto-programs/write_goto_binary.cpp b/src/goto-programs/write_goto_binary.cpp index 129cde694b4..ff0a98790b3 100644 --- a/src/goto-programs/write_goto_binary.cpp +++ b/src/goto-programs/write_goto_binary.cpp @@ -40,24 +40,24 @@ bool write_goto_binary_v3( { // Since version 2, symbols are not converted to ireps, // instead they are saved in a custom binary format - - const symbolt &sym = it->second; - + + const symbolt &sym = it->second; + irepconverter.reference_convert(sym.type, out); irepconverter.reference_convert(sym.value, out); irepconverter.reference_convert(sym.location, out); - + irepconverter.write_string_ref(out, sym.name); irepconverter.write_string_ref(out, sym.module); irepconverter.write_string_ref(out, sym.base_name); irepconverter.write_string_ref(out, sym.mode); irepconverter.write_string_ref(out, sym.pretty_name); - + write_gb_word(out, 0); // old: sym.ordering - unsigned flags=0; + unsigned flags=0; flags = (flags << 1) | (int)sym.is_weak; - flags = (flags << 1) | (int)sym.is_type; + flags = (flags << 1) | (int)sym.is_type; flags = (flags << 1) | (int)sym.is_property; flags = (flags << 1) | (int)sym.is_macro; flags = (flags << 1) | (int)sym.is_exported; @@ -73,14 +73,14 @@ bool write_goto_binary_v3( flags = (flags << 1) | (int)sym.is_file_local; flags = (flags << 1) | (int)sym.is_extern; flags = (flags << 1) | (int)sym.is_volatile; - + write_gb_word(out, flags); } // now write functions, but only those with body unsigned cnt=0; - forall_goto_functions(it, functions) + forall_goto_functions(it, functions) if(it->second.body_available()) cnt++; @@ -89,30 +89,30 @@ bool write_goto_binary_v3( for(const auto & it : functions.function_map) { if(it.second.body_available()) - { + { // Since version 2, goto functions are not converted to ireps, - // instead they are saved in a custom binary format - - write_gb_string(out, id2string(it.first)); // name + // instead they are saved in a custom binary format + + write_gb_string(out, id2string(it.first)); // name write_gb_word(out, it.second.body.instructions.size()); // # instructions - + forall_goto_program_instructions(i_it, it.second.body) { const goto_programt::instructiont &instruction = *i_it; - + irepconverter.reference_convert(instruction.code, out); irepconverter.write_string_ref(out, instruction.function); irepconverter.reference_convert(instruction.source_location, out); write_gb_word(out, (long)instruction.type); - irepconverter.reference_convert(instruction.guard, out); + irepconverter.reference_convert(instruction.guard, out); irepconverter.write_string_ref(out, irep_idt()); // former event write_gb_word(out, instruction.target_number); - + write_gb_word(out, instruction.targets.size()); for(const auto & t_it : instruction.targets) write_gb_word(out, t_it->target_number); - + write_gb_word(out, instruction.labels.size()); for(const auto & l_it : instruction.labels) @@ -122,7 +122,7 @@ bool write_goto_binary_v3( } //irepconverter.output_map(f); - //irepconverter.output_string_map(f); + //irepconverter.output_string_map(f); return false; } @@ -150,25 +150,25 @@ bool write_goto_binary( write_gb_word(out, version); irep_serializationt::ireps_containert irepc; - irep_serializationt irepconverter(irepc); - + irep_serializationt irepconverter(irepc); + switch(version) { - case 1: + case 1: throw "version 1 no longer supported"; case 2: throw "version 2 no longer supported"; - + case 3: return write_goto_binary_v3( out, lsymbol_table, functions, irepconverter); - default: + default: throw "Unknown goto binary version"; } - + return false; } @@ -195,11 +195,10 @@ bool write_goto_binary( if(!out) { messaget message(message_handler); - message.error() << + message.error() << "Failed to open `" << filename << "'"; return true; } return write_goto_binary(out, symbol_table, goto_functions); } - diff --git a/src/goto-programs/xml_goto_trace.cpp b/src/goto-programs/xml_goto_trace.cpp index 2f34786baad..161bc399cca 100644 --- a/src/goto-programs/xml_goto_trace.cpp +++ b/src/goto-programs/xml_goto_trace.cpp @@ -37,7 +37,7 @@ void convert( xmlt &dest) { dest=xmlt("goto_trace"); - + source_locationt previous_source_location; for(const auto & it : goto_trace.steps) @@ -47,14 +47,14 @@ void convert( xmlt xml_location; if(source_location.is_not_nil() && source_location.get_file()!="") xml_location=xml(source_location); - + switch(it.type) { case goto_trace_stept::ASSERT: if(!it.cond_value) { irep_idt property_id; - + if(it.pc->is_assert()) property_id=source_location.get_property_id(); else if(it.pc->is_goto()) // unwinding, we suspect @@ -63,7 +63,7 @@ void convert( id2string(it.pc->source_location.get_function())+".unwind."+ i2string(it.pc->loop_number); } - + xmlt &xml_failure=dest.new_element("failure"); xml_failure.set_attribute_bool("hidden", it.hidden); @@ -76,7 +76,7 @@ void convert( xml_failure.new_element().swap(xml_location); } break; - + case goto_trace_stept::ASSIGNMENT: case goto_trace_stept::DECL: { @@ -88,7 +88,7 @@ void convert( std::string value_string, binary_string, type_string, full_lhs_string, full_lhs_value_string; - + if(it.lhs_object_value.is_not_nil()) value_string=from_expr(ns, identifier, it.lhs_object_value); @@ -118,7 +118,7 @@ void convert( xml_assignment.new_element("full_lhs").data=full_lhs_string; xml_assignment.new_element("full_lhs_value").data=full_lhs_value_string; xml_assignment.new_element("value").data=value_string; - + xml_assignment.set_attribute_bool("hidden", it.hidden); xml_assignment.set_attribute("thread", i2string(it.thread_nr)); xml_assignment.set_attribute("identifier", id2string(identifier)); @@ -126,7 +126,7 @@ void convert( xml_assignment.set_attribute("display_name", id2string(display_name)); xml_assignment.set_attribute("step_nr", i2string(it.step_nr)); - xml_assignment.set_attribute("assignment_type", + xml_assignment.set_attribute("assignment_type", it.assignment_type==goto_trace_stept::ACTUAL_PARAMETER?"actual_parameter": "state"); @@ -134,14 +134,14 @@ void convert( xml_assignment.new_element("value_expression").new_element(xml(it.lhs_object_value, ns)); } break; - + case goto_trace_stept::OUTPUT: { printf_formattert printf_formatter(ns); printf_formatter(id2string(it.format_string), it.io_args); std::string text=printf_formatter.as_string(); xmlt &xml_output=dest.new_element("output"); - + xml_output.new_element("text").data=text; xml_output.set_attribute_bool("hidden", it.hidden); @@ -159,35 +159,35 @@ void convert( } } break; - + case goto_trace_stept::INPUT: { xmlt &xml_input=dest.new_element("input"); xml_input.new_element("input_id").data=id2string(it.io_id); - + xml_input.set_attribute_bool("hidden", it.hidden); xml_input.set_attribute("thread", i2string(it.thread_nr)); xml_input.set_attribute("step_nr", i2string(it.step_nr)); - + for(const auto & l_it : it.io_args) { xml_input.new_element("value").data=from_expr(ns, "", l_it); xml_input.new_element("value_expression"). new_element(xml(l_it, ns)); } - + if(xml_location.name!="") xml_input.new_element().swap(xml_location); } break; - + case goto_trace_stept::FUNCTION_CALL: case goto_trace_stept::FUNCTION_RETURN: { std::string tag= (it.type==goto_trace_stept::FUNCTION_CALL)?"function_call":"function_return"; xmlt &xml_call_return=dest.new_element(tag); - + xml_call_return.set_attribute_bool("hidden", it.hidden); xml_call_return.set_attribute("thread", i2string(it.thread_nr)); xml_call_return.set_attribute("step_nr", i2string(it.step_nr)); @@ -202,7 +202,7 @@ void convert( xml_call_return.new_element().swap(xml_location); } break; - + default: if(source_location!=previous_source_location) { @@ -210,7 +210,7 @@ void convert( if(xml_location.name!="") { xmlt &xml_location_only=dest.new_element("location-only"); - + xml_location_only.set_attribute_bool("hidden", it.hidden); xml_location_only.set_attribute("thread", i2string(it.thread_nr)); xml_location_only.set_attribute("step_nr", i2string(it.step_nr)); diff --git a/src/goto-symex/Makefile b/src/goto-symex/Makefile index 81b59c7377c..801307df858 100644 --- a/src/goto-symex/Makefile +++ b/src/goto-symex/Makefile @@ -23,4 +23,3 @@ all: goto-symex$(LIBEXT) goto-symex$(LIBEXT): $(OBJ) $(LINKLIB) - diff --git a/src/goto-symex/adjust_float_expressions.cpp b/src/goto-symex/adjust_float_expressions.cpp index aca71e9bae6..94048db8e5f 100644 --- a/src/goto-symex/adjust_float_expressions.cpp +++ b/src/goto-symex/adjust_float_expressions.cpp @@ -43,9 +43,9 @@ void adjust_float_expressions( { symbol_exprt rounding_mode= ns.lookup(CPROVER_PREFIX "rounding_mode").symbol_expr(); - + rounding_mode.add_source_location()=expr.source_location(); - + if(expr.id()==ID_plus || expr.id()==ID_minus || expr.id()==ID_mult || expr.id()==ID_div || expr.id()==ID_rem) @@ -68,19 +68,19 @@ void adjust_float_expressions( expr.op2()=rounding_mode; } } - + if(expr.id()==ID_typecast) { const typecast_exprt &typecast_expr=to_typecast_expr(expr); - + const typet &src_type=typecast_expr.op().type(); const typet &dest_type=typecast_expr.type(); symbol_exprt rounding_mode= ns.lookup(CPROVER_PREFIX "rounding_mode").symbol_expr(); - + rounding_mode.add_source_location()=expr.source_location(); - + if(dest_type.id()==ID_floatbv && src_type.id()==ID_floatbv) { @@ -126,4 +126,3 @@ void adjust_float_expressions( } } } - diff --git a/src/goto-symex/auto_objects.cpp b/src/goto-symex/auto_objects.cpp index ebb8899c52d..b06a86691ec 100644 --- a/src/goto-symex/auto_objects.cpp +++ b/src/goto-symex/auto_objects.cpp @@ -29,7 +29,7 @@ Function: goto_symext::make_auto_object exprt goto_symext::make_auto_object(const typet &type) { dynamic_counter++; - + // produce auto-object symbol symbolt symbol; @@ -61,12 +61,12 @@ void goto_symext::initialize_auto_object( statet &state) { const typet &type=ns.follow(expr.type()); - + if(type.id()==ID_struct) { const struct_typet &struct_type=to_struct_type(type); const struct_typet::componentst &components=struct_type.components(); - + for(struct_typet::componentst::const_iterator it=components.begin(); it!=components.end(); @@ -84,14 +84,14 @@ void goto_symext::initialize_auto_object( { const pointer_typet &pointer_type=to_pointer_type(type); const typet &subtype=ns.follow(type.subtype()); - + // we don't like function pointers and // we don't like void * if(subtype.id()!=ID_code && subtype.id()!=ID_empty) { // could be NULL nondeterministically - + address_of_exprt address_of_expr= address_of_exprt(make_auto_object(type.subtype())); @@ -99,7 +99,7 @@ void goto_symext::initialize_auto_object( side_effect_expr_nondett(bool_typet()), null_pointer_exprt(pointer_type), address_of_expr); - + code_assignt assignment(expr, rhs); symex_assign_rec(state, assignment); } @@ -127,12 +127,12 @@ void goto_symext::trigger_auto_object( { const ssa_exprt &ssa_expr=to_ssa_expr(expr); const irep_idt &obj_identifier=ssa_expr.get_object_name(); - + if(obj_identifier!="goto_symex::\\guard") { const symbolt &symbol= ns.lookup(obj_identifier); - + if(has_prefix(id2string(symbol.base_name), "auto_object")) { // done already? diff --git a/src/goto-symex/build_goto_trace.cpp b/src/goto-symex/build_goto_trace.cpp index 0e501875ba4..4c1a718d846 100644 --- a/src/goto-symex/build_goto_trace.cpp +++ b/src/goto-symex/build_goto_trace.cpp @@ -41,21 +41,21 @@ exprt build_full_lhs_rec( { if(src_ssa.id()!=src_original.id()) return src_original; - + const irep_idt id=src_original.id(); if(id==ID_index) { // get index value from src_ssa exprt index_value=prop_conv.get(to_index_expr(src_ssa).index()); - + if(index_value.is_not_nil()) { simplify(index_value, ns); index_exprt tmp=to_index_expr(src_original); tmp.index()=index_value; tmp.array()= - build_full_lhs_rec(prop_conv, ns, + build_full_lhs_rec(prop_conv, ns, to_index_expr(src_original).array(), to_index_expr(src_ssa).array()); return tmp; @@ -74,8 +74,8 @@ exprt build_full_lhs_rec( else if(id==ID_if) { if_exprt tmp2=to_if_expr(src_original); - - tmp2.false_case()=build_full_lhs_rec(prop_conv, ns, + + tmp2.false_case()=build_full_lhs_rec(prop_conv, ns, tmp2.false_case(), to_if_expr(src_ssa).false_case()); tmp2.true_case()=build_full_lhs_rec(prop_conv, ns, @@ -105,9 +105,9 @@ exprt build_full_lhs_rec( tmp.op0()=build_full_lhs_rec(prop_conv, ns, tmp.op0(), src_ssa.op0()); // re-write into big case-split - + } - + return src_original; } @@ -153,19 +153,19 @@ void build_goto_trace( // We need to re-sort the steps according to their clock. // Furthermore, read-events need to occur before write // events with the same clock. - + typedef std::map time_mapt; time_mapt time_map; - + mp_integer current_time=0; - + for(symex_target_equationt::SSA_stepst::const_iterator it=target.SSA_steps.begin(); it!=end_step; it++) { const symex_target_equationt::SSA_stept &SSA_step=*it; - + if(prop_conv.l_get(SSA_step.guard_literal)!=tvt(true)) continue; @@ -220,9 +220,9 @@ void build_goto_trace( continue; goto_tracet::stepst &steps=time_map[current_time]; - steps.push_back(goto_trace_stept()); + steps.push_back(goto_trace_stept()); goto_trace_stept &goto_trace_step=steps.back(); - + goto_trace_step.thread_nr=SSA_step.source.thread_nr; goto_trace_step.pc=SSA_step.source.pc; goto_trace_step.comment=SSA_step.comment; @@ -243,21 +243,21 @@ void build_goto_trace( SSA_step.assignment_type==symex_targett::HIDDEN_ACTUAL_PARAMETER))? goto_trace_stept::ACTUAL_PARAMETER: goto_trace_stept::STATE; - + if(SSA_step.original_full_lhs.is_not_nil()) goto_trace_step.full_lhs= build_full_lhs_rec( prop_conv, ns, SSA_step.original_full_lhs, SSA_step.ssa_full_lhs); - + if(SSA_step.ssa_lhs.is_not_nil()) goto_trace_step.lhs_object_value=prop_conv.get(SSA_step.ssa_lhs); - + if(SSA_step.ssa_full_lhs.is_not_nil()) { goto_trace_step.full_lhs_value=prop_conv.get(SSA_step.ssa_full_lhs); simplify(goto_trace_step.full_lhs_value, ns); } - + for(const auto & j : SSA_step.converted_io_args) { if(j.is_constant() || @@ -280,7 +280,7 @@ void build_goto_trace( prop_conv.l_get(SSA_step.cond_literal).is_true(); } } - + // Now assemble into a single goto_trace. // This expoits sorted-ness of the map. for(auto & t_it : time_map) @@ -288,7 +288,7 @@ void build_goto_trace( // produce the step numbers unsigned step_nr=0; - + for(auto & s_it : goto_trace.steps) s_it.step_nr=++step_nr; } @@ -327,8 +327,7 @@ void build_goto_trace( s_it2=s_it1; s_it2!=goto_trace.steps.end(); s_it2=goto_trace.steps.erase(s_it2)); - + break; } } - diff --git a/src/goto-symex/goto_symex.h b/src/goto-symex/goto_symex.h index 15f05453921..09efe7cadac 100644 --- a/src/goto-symex/goto_symex.h +++ b/src/goto-symex/goto_symex.h @@ -57,7 +57,7 @@ class goto_symext options.set_option("simplify", true); options.set_option("assertions", true); } - + virtual ~goto_symext() { } @@ -86,7 +86,7 @@ class goto_symext // these bypass the target maps virtual void symex_step_goto(statet &state, bool taken); - + // statistics unsigned total_vccs, remaining_vccs; @@ -97,20 +97,20 @@ class goto_symext protected: const namespacet &ns; - symex_targett ⌖ + symex_targett ⌖ unsigned atomic_section_counter; friend class symex_dereference_statet; - + void new_name(symbolt &symbol); - + // this does the following: // a) rename non-det choices // b) remove pointer dereferencing // c) rewrite array_equal expression into equality void clean_expr( exprt &expr, statet &state, bool write); - + void replace_array_equal(exprt &expr); void trigger_auto_object(const exprt &expr, statet &state); void initialize_auto_object(const exprt &expr, statet &state); @@ -122,75 +122,75 @@ class goto_symext exprt &expr, statet &state, const bool write); - + void dereference_rec( exprt &expr, statet &state, guardt &guard, const bool write); - + void dereference_rec_address_of( exprt &expr, statet &state, guardt &guard); - + static bool is_index_member_symbol_if(const exprt &expr); - + exprt address_arithmetic( const exprt &expr, statet &state, guardt &guard, bool keep_array); - + // guards - + irep_idt guard_identifier; - + // symex virtual void symex_goto(statet &state); virtual void symex_start_thread(statet &state); virtual void symex_atomic_begin(statet &state); - virtual void symex_atomic_end(statet &state); + virtual void symex_atomic_end(statet &state); virtual void symex_decl(statet &state); virtual void symex_decl(statet &state, const symbol_exprt &expr); virtual void symex_dead(statet &state); virtual void symex_other( const goto_functionst &goto_functions, - statet &state); - + statet &state); + virtual void vcc( const exprt &expr, const std::string &msg, statet &state); - + virtual void symex_assume(statet &state, const exprt &cond); - + // gotos void merge_gotos(statet &state); - + void merge_value_sets( const statet::goto_statet &goto_state, statet &dest); - + void phi_function( const statet::goto_statet &goto_state, statet &state); - + // determine whether to unwind a loop -- true indicates abort, // with false we continue. virtual bool get_unwind( const symex_targett::sourcet &source, unsigned unwind); - + virtual void loop_bound_exceeded(statet &state, const exprt &guard); - + // function calls - + void pop_frame(statet &state); void return_assignment(statet &state); - + virtual void no_body(const irep_idt &identifier) { } @@ -211,7 +211,7 @@ class goto_symext const goto_functionst &goto_functions, statet &state, const code_function_callt &call); - + virtual bool get_unwind_recursion( const irep_idt &identifier, const unsigned thread_nr, @@ -231,20 +231,20 @@ class goto_symext void add_end_of_function( exprt &code, const irep_idt &identifier); - + // exceptions - + void symex_throw(statet &state); void symex_catch(statet &state); virtual void do_simplify(exprt &expr); - + //virtual void symex_block(statet &state, const codet &code); void symex_assign_rec(statet &state, const code_assignt &code); virtual void symex_assign(statet &state, const code_assignt &code); typedef symex_targett::assignment_typet assignment_typet; - + void symex_assign_rec(statet &state, const exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); void symex_assign_symbol(statet &state, const ssa_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); void symex_assign_typecast(statet &state, const typecast_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); @@ -252,9 +252,9 @@ class goto_symext void symex_assign_struct_member(statet &state, const member_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); void symex_assign_if(statet &state, const if_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); void symex_assign_byte_extract(statet &state, const byte_extract_exprt &lhs, const exprt &full_lhs, const exprt &rhs, guardt &guard, assignment_typet assignment_type); - + static exprt add_to_lhs(const exprt &lhs, const exprt &what); - + virtual void symex_gcc_builtin_va_arg_next(statet &state, const exprt &lhs, const side_effect_exprt &code); virtual void symex_malloc (statet &state, const exprt &lhs, const side_effect_exprt &code); virtual void symex_cpp_delete (statet &state, const codet &code); @@ -268,7 +268,7 @@ class goto_symext static unsigned nondet_count; static unsigned dynamic_counter; - + void read(exprt &expr); void replace_nondet(exprt &expr); void rewrite_quantifiers(exprt &expr, statet &state); diff --git a/src/goto-symex/goto_symex_state.cpp b/src/goto-symex/goto_symex_state.cpp index 27a79bab974..0e124257b5b 100644 --- a/src/goto-symex/goto_symex_state.cpp +++ b/src/goto-symex/goto_symex_state.cpp @@ -98,13 +98,13 @@ void goto_symex_statet::level0t::operator()( std::cerr << "level0: failed to find " << obj_identifier << std::endl; abort(); } - + // don't rename shared variables or functions if(s->type.id()==ID_code || s->is_shared()) return; - // rename! + // rename! ssa_expr.set_level_0(thread_nr); } @@ -152,7 +152,7 @@ bool goto_symex_statet::constant_propagation(const exprt &expr) const { if(expr.is_constant()) return true; - + if(expr.id()==ID_address_of) { const address_of_exprt &address_of_expr=to_address_of_expr(expr); @@ -187,7 +187,7 @@ bool goto_symex_statet::constant_propagation(const exprt &expr) const forall_operands(it, expr) if(!constant_propagation(*it)) return false; - + return true; } else if(expr.id()==ID_array_of) @@ -398,7 +398,7 @@ void goto_symex_statet::assignment( lhs.update_type(); assert_l1_renaming(lhs); - #if 0 + #if 0 assert(l1_identifier != get_original_name(l1_identifier) || l1_identifier=="goto_symex::\\guard" || ns.lookup(l1_identifier).is_shared() @@ -419,12 +419,12 @@ void goto_symex_statet::assignment( assert_l2_renaming(rhs); // for value propagation -- the RHS is L2 - + if(!is_shared && record_value && constant_propagation(rhs)) propagation.values[l1_identifier]=rhs; else propagation.remove(l1_identifier); - + { // update value sets value_sett::expr_sett rhs_value_set; @@ -437,9 +437,9 @@ void goto_symex_statet::assignment( assert_l1_renaming(l1_lhs); assert_l1_renaming(l1_rhs); - value_set.assign(l1_lhs, l1_rhs, ns, rhs_is_simplified, is_shared); + value_set.assign(l1_lhs, l1_rhs, ns, rhs_is_simplified, is_shared); } - + #if 0 std::cout << "Assigning " << l1_identifier << std::endl; value_set.output(ns, std::cout); @@ -502,21 +502,21 @@ void goto_symex_statet::set_ssa_indices( case L0: level0(ssa_expr, ns, source.thread_nr); break; - + case L1: if(!ssa_expr.get_level_2().empty()) return; if(!ssa_expr.get_level_1().empty()) return; level0(ssa_expr, ns, source.thread_nr); level1(ssa_expr); break; - + case L2: if(!ssa_expr.get_level_2().empty()) return; level0(ssa_expr, ns, source.thread_nr); level1(ssa_expr); ssa_expr.set_level_2(level2.current_count(ssa_expr.get_identifier())); break; - + default: assert(false); } @@ -796,7 +796,7 @@ bool goto_symex_statet::l2_thread_write_encoding( if(obj_identifier=="goto_symex::\\guard" || !ns.lookup(obj_identifier).is_shared()) return false; // not shared - + // see whether we are within an atomic section if(atomic_section_id!=0) { @@ -1005,7 +1005,7 @@ void goto_symex_statet::get_original_name(exprt &expr) const } /*******************************************************************\ - + Function: goto_symex_statet::get_original_name Inputs: @@ -1084,7 +1084,7 @@ void goto_symex_statet::switch_to_thread(unsigned t) { assert(source.thread_nr l1_historyt; - l1_historyt l1_history; - + l1_historyt l1_history; + struct renaming_levelt { virtual ~renaming_levelt() { } typedef std::map > current_namest; current_namest current_names; - + unsigned current_count(const irep_idt &identifier) const { current_namest::const_iterator it= @@ -72,7 +72,7 @@ class goto_symex_statet vars.insert(it->second.first); } }; - + // level 0 -- threads! // renaming built for one particular interleaving struct level0t:public renaming_levelt @@ -88,7 +88,7 @@ class goto_symex_statet // level 1 -- function frames // this is to preserve locality in case of recursion - + struct level1t:public renaming_levelt { void operator()(ssa_exprt &ssa_expr); @@ -117,7 +117,7 @@ class goto_symex_statet level1t() { } virtual ~level1t() { } } level1; - + // level 2 -- SSA struct level2t:public renaming_levelt @@ -125,7 +125,7 @@ class goto_symex_statet level2t() { } virtual ~level2t() { } } level2; - + // this maps L1 names to (L2) constants class propagationt { @@ -138,9 +138,9 @@ class goto_symex_statet { values.erase(identifier); } - + } propagation; - + typedef enum { L0=0, L1=1, L2=2 } levelt; // performs renaming _up to_ the given level @@ -150,7 +150,7 @@ class goto_symex_statet const irep_idt &l1_identifier, const namespacet &ns, levelt level=L2); - + void assignment( ssa_exprt &lhs, // L0/L1 const exprt &rhs, // L2 @@ -175,7 +175,7 @@ class goto_symex_statet // this maps L1 names to (L2) types typedef hash_map_cont l1_typest; l1_typest l1_types; - + public: // uses level 1 names, and is used to // do dereferencing @@ -190,7 +190,7 @@ class goto_symex_statet guardt guard; propagationt propagation; unsigned atomic_section_id; - + explicit goto_statet(const goto_symex_statet &s): depth(s.depth), level2_current_names(s.level2.current_names), @@ -228,7 +228,7 @@ class goto_symex_statet class framet { public: - // function calls + // function calls irep_idt function_identifier; goto_state_mapt goto_state_map; symex_targett::sourcet calling_location; @@ -238,10 +238,10 @@ class goto_symex_statet bool hidden_function; renaming_levelt::current_namest old_level1; - + typedef std::set local_objectst; local_objectst local_objects; - + framet(): return_value(nil_exprt()), hidden_function(false) @@ -276,13 +276,13 @@ class goto_symex_statet assert(source.thread_nr written_in_atomic_sectiont; read_in_atomic_sectiont read_in_atomic_section; written_in_atomic_sectiont written_in_atomic_section; - + class threadt { public: @@ -325,7 +325,7 @@ class goto_symex_statet typedef std::vector threadst; threadst threads; - + bool l2_thread_read_encoding(ssa_exprt &expr, const namespacet &ns); bool l2_thread_write_encoding(const ssa_exprt &expr, const namespacet &ns); diff --git a/src/goto-symex/memory_model.cpp b/src/goto-symex/memory_model.cpp index 8956b861162..702fefe57b6 100644 --- a/src/goto-symex/memory_model.cpp +++ b/src/goto-symex/memory_model.cpp @@ -15,7 +15,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk Function: memory_model_baset::memory_model_baset - Inputs: + Inputs: Outputs: @@ -33,7 +33,7 @@ memory_model_baset::memory_model_baset(const namespacet &_ns): Function: memory_model_baset::~memory_model_baset - Inputs: + Inputs: Outputs: @@ -49,7 +49,7 @@ memory_model_baset::~memory_model_baset() Function: memory_model_baset::nondet_bool_symbol - Inputs: + Inputs: Outputs: @@ -69,7 +69,7 @@ symbol_exprt memory_model_baset::nondet_bool_symbol( Function: memory_model_baset::po - Inputs: + Inputs: Outputs: @@ -93,7 +93,7 @@ bool memory_model_baset::po(event_it e1, event_it e2) Function: memory_model_baset::read_from - Inputs: + Inputs: Outputs: @@ -113,14 +113,14 @@ void memory_model_baset::read_from(symex_target_equationt &equation) a_it++) { const a_rect &a_rec=a_it->second; - + for(event_listt::const_iterator r_it=a_rec.reads.begin(); r_it!=a_rec.reads.end(); r_it++) { const event_it r=*r_it; - + exprt::operandst rf_some_operands; rf_some_operands.reserve(a_rec.writes.size()); @@ -131,7 +131,7 @@ void memory_model_baset::read_from(symex_target_equationt &equation) ++w_it) { const event_it w=*w_it; - + // rf cannot contradict program order if(po(r, w)) continue; // contradicts po @@ -140,7 +140,7 @@ void memory_model_baset::read_from(symex_target_equationt &equation) w->source.thread_nr==r->source.thread_nr; symbol_exprt s=nondet_bool_symbol("rf"); - + // record the symbol choice_symbols[ std::make_pair(r, w)]=s; @@ -166,7 +166,7 @@ void memory_model_baset::read_from(symex_target_equationt &equation) rf_some_operands.push_back(s); } - + // value equals the one of some write exprt rf_some; @@ -189,4 +189,3 @@ void memory_model_baset::read_from(symex_target_equationt &equation) } } } - diff --git a/src/goto-symex/memory_model.h b/src/goto-symex/memory_model.h index bcd44cd9738..86ea7932810 100644 --- a/src/goto-symex/memory_model.h +++ b/src/goto-symex/memory_model.h @@ -18,15 +18,15 @@ class memory_model_baset:public partial_order_concurrencyt virtual ~memory_model_baset(); virtual void operator()(symex_target_equationt &)=0; - + protected: // program order bool po(event_it e1, event_it e2); - // produce fresh symbols + // produce fresh symbols unsigned var_cnt; symbol_exprt nondet_bool_symbol(const std::string &prefix); - + // This gives us the choice symbol for an R-W pair; // built by the method below. typedef std::map< @@ -34,10 +34,9 @@ class memory_model_baset:public partial_order_concurrencyt choice_symbolst choice_symbols; void read_from(symex_target_equationt &equation); - + // maps thread numbers to an event list typedef std::map per_thread_mapt; }; #endif - diff --git a/src/goto-symex/memory_model_pso.cpp b/src/goto-symex/memory_model_pso.cpp index 61e0068b83f..fdb64523010 100644 --- a/src/goto-symex/memory_model_pso.cpp +++ b/src/goto-symex/memory_model_pso.cpp @@ -12,7 +12,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk Function: memory_model_psot::operator() - Inputs: + Inputs: Outputs: @@ -26,7 +26,7 @@ void memory_model_psot::operator()(symex_target_equationt &equation) build_event_lists(equation); build_clock_type(equation); - + read_from(equation); write_serialization_external(equation); program_order(equation); @@ -67,4 +67,3 @@ bool memory_model_psot::program_order_is_relaxed( // only read/read and read/write are maintained return is_shared_write(e1); } - diff --git a/src/goto-symex/memory_model_pso.h b/src/goto-symex/memory_model_pso.h index 7091b2c2ec1..dd26924161d 100644 --- a/src/goto-symex/memory_model_pso.h +++ b/src/goto-symex/memory_model_pso.h @@ -20,7 +20,7 @@ class memory_model_psot:public memory_model_tsot } virtual void operator()(symex_target_equationt &equation); - + protected: virtual bool program_order_is_relaxed( partial_order_concurrencyt::event_it e1, @@ -28,4 +28,3 @@ class memory_model_psot:public memory_model_tsot }; #endif - diff --git a/src/goto-symex/memory_model_sc.cpp b/src/goto-symex/memory_model_sc.cpp index 905b9049ed4..eeeda91e2b6 100644 --- a/src/goto-symex/memory_model_sc.cpp +++ b/src/goto-symex/memory_model_sc.cpp @@ -15,7 +15,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk Function: memory_model_sct::operator() - Inputs: + Inputs: Outputs: @@ -29,7 +29,7 @@ void memory_model_sct::operator()(symex_target_equationt &equation) build_event_lists(equation); build_clock_type(equation); - + read_from(equation); write_serialization_external(equation); program_order(equation); @@ -40,7 +40,7 @@ void memory_model_sct::operator()(symex_target_equationt &equation) Function: memory_model_sct::before - Inputs: + Inputs: Outputs: @@ -93,7 +93,7 @@ void memory_model_sct::build_per_thread_map( per_thread_mapt &dest) const { // this orders the events within a thread - + for(eventst::const_iterator e_it=equation.SSA_steps.begin(); e_it!=equation.SSA_steps.end(); @@ -139,8 +139,8 @@ void memory_model_sct::thread_spawn( per_thread_mapt::const_iterator next_thread= per_thread_map.find(++next_thread_id); if(next_thread==per_thread_map.end()) continue; - - // add a constraint for all events, + + // add a constraint for all events, // considering regression/cbmc-concurrency/pthread_create_tso1 for(event_listt::const_iterator n_it=next_thread->second.begin(); @@ -156,7 +156,7 @@ void memory_model_sct::thread_spawn( } } } -} +} #if 0 void memory_model_sct::thread_spawn( @@ -165,7 +165,7 @@ void memory_model_sct::thread_spawn( { // thread spawn: the spawn precedes the first // instruction of the new thread in program order - + unsigned next_thread_id=0; for(eventst::const_iterator e_it=equation.SSA_steps.begin(); @@ -220,7 +220,7 @@ void memory_model_sct::program_order( build_per_thread_map(equation, per_thread_map); thread_spawn(equation, per_thread_map); - + // iterate over threads for(per_thread_mapt::const_iterator @@ -229,11 +229,11 @@ void memory_model_sct::program_order( t_it++) { const event_listt &events=t_it->second; - + // iterate over relevant events in the thread - + event_it previous=equation.SSA_steps.end(); - + for(event_listt::const_iterator e_it=events.begin(); e_it!=events.end(); @@ -284,7 +284,7 @@ void memory_model_sct::write_serialization_external( // This is quadratic in the number of writes // per address. Perhaps some better encoding - // based on 'places'? + // based on 'places'? for(event_listt::const_iterator w_it1=a_rec.writes.begin(); w_it1!=a_rec.writes.end(); @@ -339,7 +339,7 @@ Function: memory_model_sct::from_read void memory_model_sct::from_read(symex_target_equationt &equation) { // from-read: (w', w) in ws and (w', r) in rf -> (r, w) in fr - + for(address_mapt::const_iterator a_it=address_map.begin(); a_it!=address_map.end(); @@ -361,7 +361,7 @@ void memory_model_sct::from_read(symex_target_equationt &equation) ++w) { exprt ws1, ws2; - + if(po(*w_prime, *w) && !program_order_is_relaxed(*w_prime, *w)) { @@ -390,7 +390,7 @@ void memory_model_sct::from_read(symex_target_equationt &equation) exprt rf=c_it->second; exprt cond; cond.make_nil(); - + if(c_it->first.second==*w_prime && !ws1.is_false()) { exprt fr=before(r, *w); @@ -420,9 +420,8 @@ void memory_model_sct::from_read(symex_target_equationt &equation) add_constraint(equation, cond, "fr", r->source); } - + } } } } - diff --git a/src/goto-symex/memory_model_sc.h b/src/goto-symex/memory_model_sc.h index 378b803bbc0..e0b13f3c9fe 100644 --- a/src/goto-symex/memory_model_sc.h +++ b/src/goto-symex/memory_model_sc.h @@ -20,7 +20,7 @@ class memory_model_sct:public memory_model_baset } virtual void operator()(symex_target_equationt &equation); - + protected: virtual exprt before(event_it e1, event_it e2); virtual bool program_order_is_relaxed( @@ -39,4 +39,3 @@ class memory_model_sct:public memory_model_baset }; #endif - diff --git a/src/goto-symex/memory_model_tso.cpp b/src/goto-symex/memory_model_tso.cpp index e4c4b6abbd8..fee99895c2f 100644 --- a/src/goto-symex/memory_model_tso.cpp +++ b/src/goto-symex/memory_model_tso.cpp @@ -15,7 +15,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk Function: memory_model_tsot::operator() - Inputs: + Inputs: Outputs: @@ -29,7 +29,7 @@ void memory_model_tsot::operator()(symex_target_equationt &equation) build_event_lists(equation); build_clock_type(equation); - + read_from(equation); write_serialization_external(equation); program_order(equation); @@ -42,7 +42,7 @@ void memory_model_tsot::operator()(symex_target_equationt &equation) Function: memory_model_tsot::before - Inputs: + Inputs: Outputs: @@ -103,7 +103,7 @@ void memory_model_tsot::program_order( build_per_thread_map(equation, per_thread_map); thread_spawn(equation, per_thread_map); - + // iterate over threads for(per_thread_mapt::const_iterator @@ -112,9 +112,9 @@ void memory_model_tsot::program_order( t_it++) { const event_listt &events=t_it->second; - + // iterate over relevant events in the thread - + for(event_listt::const_iterator e_it=events.begin(); e_it!=events.end(); @@ -208,4 +208,3 @@ void memory_model_tsot::program_order( } } } - diff --git a/src/goto-symex/memory_model_tso.h b/src/goto-symex/memory_model_tso.h index 1f86a704aa5..216d0d1bddc 100644 --- a/src/goto-symex/memory_model_tso.h +++ b/src/goto-symex/memory_model_tso.h @@ -20,7 +20,7 @@ class memory_model_tsot:public memory_model_sct } virtual void operator()(symex_target_equationt &equation); - + protected: virtual exprt before(event_it e1, event_it e2); virtual bool program_order_is_relaxed( @@ -30,4 +30,3 @@ class memory_model_tsot:public memory_model_sct }; #endif - diff --git a/src/goto-symex/partial_order_concurrency.cpp b/src/goto-symex/partial_order_concurrency.cpp index bc1daa21c7c..e9c1eb72e95 100644 --- a/src/goto-symex/partial_order_concurrency.cpp +++ b/src/goto-symex/partial_order_concurrency.cpp @@ -18,7 +18,7 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk Function: partial_order_concurrencyt::~partial_order_concurrencyt - Inputs: + Inputs: Outputs: @@ -35,7 +35,7 @@ partial_order_concurrencyt::partial_order_concurrencyt( Function: partial_order_concurrencyt::~partial_order_concurrencyt - Inputs: + Inputs: Outputs: @@ -51,7 +51,7 @@ partial_order_concurrencyt::~partial_order_concurrencyt() Function: partial_order_concurrencyt::add_init_writes - Inputs: + Inputs: Outputs: @@ -111,7 +111,7 @@ void partial_order_concurrencyt::add_init_writes( Function: partial_order_concurrencyt::build_event_lists - Inputs: + Inputs: Outputs: @@ -172,7 +172,7 @@ void partial_order_concurrencyt::build_event_lists( Function: partial_order_concurrencyt::rw_clock_id - Inputs: + Inputs: Outputs: @@ -198,7 +198,7 @@ irep_idt partial_order_concurrencyt::rw_clock_id( Function: partial_order_concurrencyt::clock - Inputs: + Inputs: Outputs: @@ -240,7 +240,7 @@ symbol_exprt partial_order_concurrencyt::clock( Function: partial_order_concurrencyt::is_shared_write - Inputs: + Inputs: Outputs: @@ -262,7 +262,7 @@ bool partial_order_concurrencyt::is_shared_write(event_it event) const Function: partial_order_concurrencyt::is_shared_read - Inputs: + Inputs: Outputs: @@ -284,7 +284,7 @@ bool partial_order_concurrencyt::is_shared_read(event_it event) const Function: partial_order_concurrencyt::build_clock_type - Inputs: + Inputs: Outputs: @@ -306,7 +306,7 @@ void partial_order_concurrencyt::build_clock_type( Function: partial_order_concurrencyt::before - Inputs: + Inputs: Outputs: @@ -349,7 +349,7 @@ exprt partial_order_concurrencyt::before( Function: partial_order_concurrencyt::add_constraint - Inputs: + Inputs: Outputs: @@ -368,4 +368,3 @@ void partial_order_concurrencyt::add_constraint( equation.constraint(tmp, msg, source); } - diff --git a/src/goto-symex/partial_order_concurrency.h b/src/goto-symex/partial_order_concurrency.h index 1348664ce39..e50559e8759 100644 --- a/src/goto-symex/partial_order_concurrency.h +++ b/src/goto-symex/partial_order_concurrency.h @@ -34,34 +34,34 @@ class partial_order_concurrencyt:public messaget static irep_idt rw_clock_id( event_it e, axiomt axiom=AX_PROPAGATION); - + protected: const namespacet &ns; typedef std::vector event_listt; - + // lists of reads and writes per address struct a_rect { event_listt reads, writes; }; - + typedef std::map address_mapt; address_mapt address_map; - + void build_event_lists(symex_target_equationt &); void add_init_writes(symex_target_equationt &); - + // a per-thread numbering of the events typedef std::map numberingt; - numberingt numbering; - + numberingt numbering; + // produces the symbol ID for an event static inline irep_idt id(event_it event) { return event->ssa_lhs.get_identifier(); } - + // produces an address ID for an event inline irep_idt address(event_it event) const { @@ -81,7 +81,7 @@ class partial_order_concurrencyt:public messaget const exprt &cond, const std::string &msg, const symex_targett::sourcet &source) const; - + // the partial order constraint for two events exprt before(event_it e1, event_it e2, unsigned axioms); virtual exprt before(event_it e1, event_it e2)=0; @@ -91,7 +91,7 @@ class partial_order_concurrencyt:public messaget // is it a read from a shared variable? bool is_shared_read(event_it e) const; - + // is this a spawn? static inline bool is_spawn(event_it e) { diff --git a/src/goto-symex/postcondition.cpp b/src/goto-symex/postcondition.cpp index cd007a72a88..4be55beaa65 100644 --- a/src/goto-symex/postcondition.cpp +++ b/src/goto-symex/postcondition.cpp @@ -48,7 +48,7 @@ class postconditiont public: void compute(exprt &dest); - + protected: void strengthen(exprt &dest); void weaken(exprt &dest); @@ -124,7 +124,7 @@ bool postconditiont::is_used_address_of( assert(expr.operands().size()==1); return is_used(expr.op0(), identifier); } - + return false; } @@ -144,7 +144,7 @@ void postconditiont::compute(exprt &dest) { // weaken due to assignment weaken(dest); - + // strengthen due to assignment strengthen(dest); } @@ -168,20 +168,20 @@ void postconditiont::weaken(exprt &dest) { Forall_operands(it, dest) weaken(*it); - + return; } // we are lazy: // if lhs is mentioned in dest, we use "true". - + const irep_idt &lhs_identifier=SSA_step.ssa_lhs.get_object_name(); if(is_used(dest, lhs_identifier)) dest=true_exprt(); - + // otherwise, no weakening needed -} +} /*******************************************************************\ @@ -205,7 +205,7 @@ void postconditiont::strengthen(exprt &dest) if(SSA_step.ssa_lhs.type().id()==ID_array || SSA_step.ssa_lhs.type().id()==ID_struct) return; - + equal_exprt equality(SSA_step.ssa_lhs, SSA_step.ssa_rhs); s.get_original_name(equality); @@ -214,7 +214,7 @@ void postconditiont::strengthen(exprt &dest) else dest=and_exprt(dest, equality); } -} +} /*******************************************************************\ @@ -256,7 +256,7 @@ bool postconditiont::is_used( value_setst::valuest expr_set; value_set.get_value_set(expr.op0(), expr_set, ns); hash_set_cont symbols; - + for(value_setst::valuest::const_iterator it=expr_set.begin(); it!=expr_set.end(); @@ -266,13 +266,13 @@ bool postconditiont::is_used( s.get_original_name(tmp); find_symbols(tmp, symbols); } - + return symbols.find(identifier)!=symbols.end(); } else forall_operands(it, expr) if(is_used(*it, identifier)) return true; - + return false; } diff --git a/src/goto-symex/precondition.cpp b/src/goto-symex/precondition.cpp index c90a2d7aa48..d7874b9f3b8 100644 --- a/src/goto-symex/precondition.cpp +++ b/src/goto-symex/precondition.cpp @@ -52,7 +52,7 @@ class preconditiont public: void compute(exprt &dest); - + protected: void compute_address_of(exprt &dest); }; @@ -166,7 +166,7 @@ void preconditiont::compute_rec(exprt &dest) assert(dest.operands().size()==1); const irep_idt &lhs_identifier=SSA_step.ssa_lhs.get_object_name(); - + // aliasing may happen here value_setst::valuest expr_set; @@ -178,7 +178,7 @@ void preconditiont::compute_rec(exprt &dest) it!=expr_set.end(); it++) find_symbols(*it, symbols); - + if(symbols.find(lhs_identifier)!=symbols.end()) { // may alias! diff --git a/src/goto-symex/rewrite_union.cpp b/src/goto-symex/rewrite_union.cpp index 1923017faf4..26b9282dfdf 100644 --- a/src/goto-symex/rewrite_union.cpp +++ b/src/goto-symex/rewrite_union.cpp @@ -39,7 +39,7 @@ void rewrite_union( { const exprt &op=to_member_expr(expr).struct_op(); const typet &op_type=ns.follow(op.type()); - + if(op_type.id()==ID_union) { exprt offset=gen_zero(index_type()); diff --git a/src/goto-symex/slice.cpp b/src/goto-symex/slice.cpp index 9f3ed33f9f6..8421e5f30b2 100644 --- a/src/goto-symex/slice.cpp +++ b/src/goto-symex/slice.cpp @@ -65,7 +65,7 @@ Function: symex_slicet::slice \*******************************************************************/ void symex_slicet::slice( - symex_target_equationt &equation, + symex_target_equationt &equation, const expr_listt &exprs) { // collect dependencies @@ -137,15 +137,15 @@ void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) case goto_trace_stept::DECL: slice_decl(SSA_step); break; - + case goto_trace_stept::OUTPUT: case goto_trace_stept::INPUT: break; - + case goto_trace_stept::DEAD: // ignore for now break; - + case goto_trace_stept::CONSTRAINT: case goto_trace_stept::SHARED_READ: case goto_trace_stept::SHARED_WRITE: @@ -155,14 +155,14 @@ void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) case goto_trace_stept::MEMORY_BARRIER: // ignore for now break; - + case goto_trace_stept::FUNCTION_CALL: case goto_trace_stept::FUNCTION_RETURN: // ignore for now break; - + default: - assert(false); + assert(false); } } @@ -233,7 +233,7 @@ Function: symex_slice_classt::collect_open_variables \*******************************************************************/ void symex_slicet::collect_open_variables( - const symex_target_equationt &equation, + const symex_target_equationt &equation, symbol_sett &open_variables) { symbol_sett lhs; @@ -286,12 +286,12 @@ void symex_slicet::collect_open_variables( break; default: - assert(false); + assert(false); } } - + open_variables=depends; - + // remove the ones that are defined open_variables.erase(lhs.begin(), lhs.end()); } @@ -329,7 +329,7 @@ Function: collect_open_variables \*******************************************************************/ void collect_open_variables( - const symex_target_equationt &equation, + const symex_target_equationt &equation, symbol_sett &open_variables) { symex_slicet symex_slice; @@ -349,7 +349,7 @@ Function: slice \*******************************************************************/ -void slice(symex_target_equationt &equation, +void slice(symex_target_equationt &equation, const expr_listt &expressions) { symex_slicet symex_slice; @@ -373,7 +373,7 @@ void simple_slice(symex_target_equationt &equation) // just find the last assertion symex_target_equationt::SSA_stepst::iterator last_assertion=equation.SSA_steps.end(); - + for(symex_target_equationt::SSA_stepst::iterator it=equation.SSA_steps.begin(); it!=equation.SSA_steps.end(); @@ -392,4 +392,3 @@ void simple_slice(symex_target_equationt &equation) s_it++) s_it->ignore=true; } - diff --git a/src/goto-symex/slice.h b/src/goto-symex/slice.h index c0d3441bb06..11de168a875 100644 --- a/src/goto-symex/slice.h +++ b/src/goto-symex/slice.h @@ -18,7 +18,7 @@ void slice(symex_target_equationt &equation); void simple_slice(symex_target_equationt &equation); // Slice the symex trace with respect to a list of given expressions -void slice(symex_target_equationt &equation, +void slice(symex_target_equationt &equation, const expr_listt &expressions); // Collects "open" variables that are used but not assigned @@ -26,7 +26,7 @@ void slice(symex_target_equationt &equation, typedef hash_set_cont symbol_sett; void collect_open_variables( - const symex_target_equationt &equation, + const symex_target_equationt &equation, symbol_sett &open_variables); #endif diff --git a/src/goto-symex/slice_by_trace.cpp b/src/goto-symex/slice_by_trace.cpp index 5c4b7e4a783..8928b0524d7 100644 --- a/src/goto-symex/slice_by_trace.cpp +++ b/src/goto-symex/slice_by_trace.cpp @@ -51,16 +51,16 @@ void symex_slice_by_tracet::slice_by_trace(std::string trace_files, std::string filename = trace_files.substr(idx, next - idx); read_trace(filename); - + compute_ts_back(equation); - + exprt t_copy (t[0]); trace_conditions.push_back(t_copy); if(next == std::string::npos) break; idx = next; } - + exprt trace_condition; if (trace_conditions.size() == 1) { @@ -77,7 +77,7 @@ void symex_slice_by_tracet::slice_by_trace(std::string trace_files, simplify(trace_condition, ns); std::set implications = implied_guards(trace_condition); - + for(std::set::iterator i = sliced_guards.begin(); i != sliced_guards.end(); i++) { @@ -100,14 +100,14 @@ void symex_slice_by_tracet::slice_by_trace(std::string trace_files, throw "Guards should only be and, symbol, constant, or not."; } } - + slice_SSA_steps(equation, implications); // Slice based on implications guardt t_guard; t_guard.make_true(); symex_targett::sourcet empty_source; equation.SSA_steps.push_front(symex_target_equationt::SSA_stept()); - symex_target_equationt::SSA_stept &SSA_step = equation.SSA_steps.front(); + symex_target_equationt::SSA_stept &SSA_step = equation.SSA_steps.front(); SSA_step.guard=t_guard.as_expr(); SSA_step.ssa_lhs.make_nil(); @@ -116,7 +116,7 @@ void symex_slice_by_tracet::slice_by_trace(std::string trace_files, SSA_step.source=empty_source; assign_merges(equation); // Now add the merge variable assignments to eqn - + std::cout << "Finished slicing by trace..." << std::endl; } @@ -141,15 +141,15 @@ void symex_slice_by_tracet::read_trace(std::string filename) // In case not the first trace read alphabet.clear(); - sigma.clear(); + sigma.clear(); sigma_vals.clear(); t.clear(); - + std::string read_line; bool done = false; bool begin = true; alphabet_parity = true; - + while (!done && !file.eof ()) { std::getline(file, read_line); if (begin && (read_line == "!")) @@ -157,22 +157,22 @@ void symex_slice_by_tracet::read_trace(std::string filename) else done = parse_alphabet(read_line); } - + while (!file.eof ()) { std::getline(file,read_line); parse_events(read_line); } - + for (size_t i = 0; i < sigma.size(); i++) { exprt f_e = static_cast(get_nil_irep()); f_e=false_exprt(); t.push_back(f_e); } - + exprt t_e = static_cast(get_nil_irep()); t_e=true_exprt(); t.push_back(t_e); -} +} /*******************************************************************\ @@ -187,14 +187,14 @@ Function: parse_alphabet \*******************************************************************/ bool symex_slice_by_tracet::parse_alphabet(std::string read_line) { - if ((read_line == ":") || (read_line == ":exact") || + if ((read_line == ":") || (read_line == ":exact") || (read_line == ":suffix") || (read_line == ":exact-suffix") || (read_line == ":prefix")) { semantics = read_line; return true; } else { std::cout << "Alphabet: "; - if (!alphabet_parity) + if (!alphabet_parity) std::cout << "!"; std::cout << read_line << std::endl; alphabet.insert(read_line); @@ -238,7 +238,7 @@ void symex_slice_by_tracet::parse_events(std::string read_line) { sigma_vals.push_back(value_v); if (universe) parity = false; - if (!parity) + if (!parity) read_line = read_line.substr(1,read_line.size()-1); std::set eis; size_t vlength = read_line.length(); @@ -246,7 +246,7 @@ void symex_slice_by_tracet::parse_events(std::string read_line) { const std::string::size_type vnext = read_line.find(",", vidx); std::string event = read_line.substr(vidx, vnext - vidx); eis.insert(event); - if ((!alphabet.empty()) && ((alphabet.count(event) != 0) != + if ((!alphabet.empty()) && ((alphabet.count(event) != 0) != alphabet_parity)) throw ("Trace uses symbol not in alphabet: " + event); if(vnext == std::string::npos) break; @@ -275,7 +275,7 @@ void symex_slice_by_tracet::compute_ts_back( for(symex_target_equationt::SSA_stepst::reverse_iterator i=equation.SSA_steps.rbegin(); - i!=equation.SSA_steps.rend(); + i!=equation.SSA_steps.rend(); i++) { if(i->is_output() && @@ -283,14 +283,14 @@ void symex_slice_by_tracet::compute_ts_back( i->io_args.front().id()=="trace_event") { irep_idt event = i->io_args.front().get("event"); - + if (!alphabet.empty()) { bool present = (alphabet.count(event) != 0); if (alphabet_parity != present) continue; } - + exprt guard = i->guard; #if 0 @@ -304,7 +304,7 @@ void symex_slice_by_tracet::compute_ts_back( bool slice_this = (semantics != ":prefix"); std::vector merge; - + for(size_t j = 0; j < t.size(); j++) { if ((t[j].is_true()) || (t[j].is_false())) { merge.push_back(t[j]); @@ -330,7 +330,7 @@ void symex_slice_by_tracet::compute_ts_back( std::list::iterator pvi = i->io_args.begin(); for (std::vector::iterator k = sigma_vals[j].begin(); k != sigma_vals[j].end(); k++) { - + exprt equal_cond=exprt(ID_equal, bool_typet()); equal_cond.operands().reserve(2); equal_cond.copy_to_operands(*pvi); @@ -343,7 +343,7 @@ void symex_slice_by_tracet::compute_ts_back( exprt val_merge = exprt(ID_and, typet(ID_bool)); val_merge.operands().reserve(eq_conds.size()+1); val_merge.copy_to_operands(merge[j+1]); - for (std::list::iterator k = eq_conds.begin(); + for (std::list::iterator k = eq_conds.begin(); k!= eq_conds.end(); k++) { val_merge.copy_to_operands(*k); } @@ -353,7 +353,7 @@ void symex_slice_by_tracet::compute_ts_back( } simplify(u_lhs, ns); - + if ((!u_lhs.is_false()) && implies_false(u_lhs)) u_lhs=false_exprt(); if (!u_lhs.is_false()) @@ -379,13 +379,13 @@ void symex_slice_by_tracet::compute_ts_back( t[j] = u_j; } - + if (semantics == ":prefix") t[t.size()-1]=true_exprt(); - + if (slice_this) { exprt guard_copy(guard); - + sliced_guards.insert(guard_copy); } } @@ -422,7 +422,7 @@ Function: slice_SSA_steps \*******************************************************************/ void symex_slice_by_tracet::slice_SSA_steps( - symex_target_equationt &equation, + symex_target_equationt &equation, std::set implications) { //Some statistics for our benefit. @@ -457,7 +457,7 @@ void symex_slice_by_tracet::slice_SSA_steps( { guard.make_not(); simplify(guard, ns); - + if (implications.count(guard) != 0) { it->cond_expr=true_exprt(); it->ssa_rhs=true_exprt(); @@ -475,7 +475,7 @@ void symex_slice_by_tracet::slice_SSA_steps( exprt neg_expr=*git; neg_expr.make_not(); simplify(neg_expr, ns); - + if (implications.count(neg_expr) != 0) { it->cond_expr=true_exprt(); it->ssa_rhs=true_exprt(); @@ -498,7 +498,7 @@ void symex_slice_by_tracet::slice_SSA_steps( conds_seen++; exprt cond_copy (it->ssa_rhs.op0()); simplify(cond_copy, ns); - + if (implications.count(cond_copy) != 0) { sliced_conds++; exprt t_copy1 (it->ssa_rhs.op1()); @@ -522,12 +522,12 @@ void symex_slice_by_tracet::slice_SSA_steps( } } - std::cout << "Trace slicing effectively removed " + std::cout << "Trace slicing effectively removed " << (sliced_SSA_steps + sliced_conds) << " out of " << equation.SSA_steps.size() << " SSA_steps." << std::endl; - std::cout << " (" - << ((sliced_SSA_steps + sliced_conds) - trace_loc_sliced) - << " out of " + std::cout << " (" + << ((sliced_SSA_steps + sliced_conds) - trace_loc_sliced) + << " out of " << (equation.SSA_steps.size() - trace_SSA_steps - location_SSA_steps) << " non-trace, non-location SSA_steps)" << std::endl; } @@ -580,13 +580,13 @@ void symex_slice_by_tracet::assign_merges( exprt merge_copy(*i); equation.SSA_steps.push_front(symex_target_equationt::SSA_stept()); - symex_target_equationt::SSA_stept &SSA_step = equation.SSA_steps.front(); - + symex_target_equationt::SSA_stept &SSA_step = equation.SSA_steps.front(); + SSA_step.guard=t_guard.as_expr(); SSA_step.ssa_lhs=merge_sym; SSA_step.ssa_rhs.swap(merge_copy); SSA_step.assignment_type=symex_targett::HIDDEN; - + SSA_step.cond_expr=equal_exprt(SSA_step.ssa_lhs, SSA_step.ssa_rhs); SSA_step.type=goto_trace_stept::ASSIGNMENT; SSA_step.source=empty_source; diff --git a/src/goto-symex/slice_by_trace.h b/src/goto-symex/slice_by_trace.h index 9e1e1a22ed0..4df27cb1708 100644 --- a/src/goto-symex/slice_by_trace.h +++ b/src/goto-symex/slice_by_trace.h @@ -34,11 +34,11 @@ class symex_slice_by_tracet event_tracet sigma; typedef std::vector > value_tracet; - + value_tracet sigma_vals; - + typedef std::vector trace_conditionst; - + trace_conditionst t; std::set sliced_guards; @@ -56,7 +56,7 @@ class symex_slice_by_tracet bool parse_alphabet(std::string read_line); void parse_events(std::string read_line); - + void compute_ts_fd(symex_target_equationt &equation); void compute_ts_back(symex_target_equationt &equation); diff --git a/src/goto-symex/symex_assign.cpp b/src/goto-symex/symex_assign.cpp index c75905f30d1..f251a1884ac 100644 --- a/src/goto-symex/symex_assign.cpp +++ b/src/goto-symex/symex_assign.cpp @@ -62,22 +62,22 @@ void goto_symext::symex_assign( replace_nondet(lhs); replace_nondet(rhs); - + if(rhs.id()==ID_side_effect) { const side_effect_exprt &side_effect_expr=to_side_effect_expr(rhs); const irep_idt &statement=side_effect_expr.get_statement(); - + if(statement==ID_function_call) { assert(!side_effect_expr.operands().empty()); - + if(side_effect_expr.op0().id()!=ID_symbol) throw "symex_assign: expected symbol as function"; const irep_idt &identifier= to_symbol_expr(side_effect_expr.op0()).get_identifier(); - + throw "symex_assign: unexpected function call: "+id2string(identifier); } else if(statement==ID_cpp_new || @@ -150,7 +150,7 @@ exprt goto_symext::add_to_lhs( assert(p->operands().size()>=1); p=&p->op0(); } - + assert(p->is_nil()); *p=tmp_what; @@ -218,10 +218,10 @@ void goto_symext::symex_assign_rec( { // this is stuff like __real__ x = 1; assert(lhs.operands().size()==1); - + exprt new_rhs=exprt(ID_complex, lhs.op0().type()); new_rhs.operands().resize(2); - + if(lhs.id()==ID_complex_real) { new_rhs.op0()=rhs; @@ -232,7 +232,7 @@ void goto_symext::symex_assign_rec( new_rhs.op0()=unary_exprt(ID_complex_real, lhs.op0(), lhs.type()); new_rhs.op1()=rhs; } - + symex_assign_rec(state, lhs.op0(), full_lhs, new_rhs, guard, assignment_type); } else @@ -260,7 +260,7 @@ void goto_symext::symex_assign_symbol( assignment_typet assignment_type) { exprt ssa_rhs=rhs; - + // put assignment guard into the rhs if(!guard.is_true()) { @@ -271,13 +271,13 @@ void goto_symext::symex_assign_symbol( tmp_ssa_rhs.false_case()=lhs; tmp_ssa_rhs.swap(ssa_rhs); } - + state.rename(ssa_rhs, ns); do_simplify(ssa_rhs); - + ssa_exprt ssa_lhs=lhs; state.assignment(ssa_lhs, ssa_rhs, ns, options.get_bool_option("simplify"), constant_propagation); - + exprt ssa_full_lhs=full_lhs; ssa_full_lhs=add_to_lhs(ssa_full_lhs, ssa_lhs); const bool record_events=state.record_events; @@ -287,16 +287,16 @@ void goto_symext::symex_assign_symbol( guardt tmp_guard(state.guard); tmp_guard.append(guard); - + // do the assignment const symbolt &symbol=ns.lookup(ssa_lhs.get_original_expr()); if(symbol.is_auxiliary) assignment_type=symex_targett::HIDDEN; - + target.assignment( tmp_guard.as_expr(), ssa_lhs, ssa_full_lhs, add_to_lhs(full_lhs, ssa_lhs.get_original_expr()), - ssa_rhs, + ssa_rhs, state.source, assignment_type); } @@ -322,14 +322,14 @@ void goto_symext::symex_assign_typecast( assignment_typet assignment_type) { // these may come from dereferencing on the lhs - + assert(lhs.operands().size()==1); - + exprt rhs_typecasted=rhs; rhs_typecasted.make_typecast(lhs.op0().type()); - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); - + symex_assign_rec( state, lhs.op0(), new_full_lhs, rhs_typecasted, guard, assignment_type); } @@ -370,7 +370,7 @@ void goto_symext::symex_assign_array( lhs_type.id_string()+"'"; #ifdef USE_UPDATE - + // turn // a[i]=e // into @@ -380,12 +380,12 @@ void goto_symext::symex_assign_array( new_rhs.old()=lhs_array; new_rhs.designator().push_back(index_designatort(lhs_index)); new_rhs.new_value()=rhs; - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); symex_assign_rec( state, lhs_array, new_full_lhs, new_rhs, guard, assignment_type); - + #else // turn // a[i]=e @@ -394,7 +394,7 @@ void goto_symext::symex_assign_array( exprt new_rhs(ID_with, lhs_type); new_rhs.copy_to_operands(lhs_array, lhs_index, rhs); - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); symex_assign_rec( @@ -433,7 +433,7 @@ void goto_symext::symex_assign_struct_member( if(lhs_struct.id()==ID_typecast) { assert(lhs_struct.operands().size()==1); - + if(lhs_struct.op0().id()=="NULL-object") { // ignore, and give up @@ -455,7 +455,7 @@ void goto_symext::symex_assign_struct_member( const irep_idt &component_name=lhs.get_component_name(); #ifdef USE_UPDATE - + // turn // a.c=e // into @@ -465,12 +465,12 @@ void goto_symext::symex_assign_struct_member( new_rhs.old()=lhs_struct; new_rhs.designator().push_back(member_designatort(component_name)); new_rhs.new_value()=rhs; - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); symex_assign_rec( state, lhs_struct, new_full_lhs, new_rhs, guard, assignment_type); - + #else // turn // a.c=e @@ -480,7 +480,7 @@ void goto_symext::symex_assign_struct_member( exprt new_rhs(ID_with, lhs_struct.type()); new_rhs.copy_to_operands(lhs_struct, exprt(ID_member_name), rhs); new_rhs.op1().set(ID_component_name, component_name); - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); symex_assign_rec( @@ -511,20 +511,20 @@ void goto_symext::symex_assign_if( // we have (c?a:b)=e; guardt old_guard=guard; - + exprt renamed_guard=lhs.cond(); state.rename(renamed_guard, ns); do_simplify(renamed_guard); - if(!renamed_guard.is_false()) + if(!renamed_guard.is_false()) { guard.add(renamed_guard); symex_assign_rec(state, lhs.true_case(), full_lhs, rhs, guard, assignment_type); guard.swap(old_guard); } - + if(!renamed_guard.is_true()) - { + { guard.add(not_exprt(renamed_guard)); symex_assign_rec(state, lhs.false_case(), full_lhs, rhs, guard, assignment_type); guard.swap(old_guard); @@ -565,10 +565,9 @@ void goto_symext::symex_assign_byte_extract( new_rhs.copy_to_operands(lhs.op(), lhs.offset(), rhs); new_rhs.type()=lhs.op().type(); - + exprt new_full_lhs=add_to_lhs(full_lhs, lhs); symex_assign_rec( state, lhs.op(), new_full_lhs, new_rhs, guard, assignment_type); } - diff --git a/src/goto-symex/symex_atomic_section.cpp b/src/goto-symex/symex_atomic_section.cpp index 6e65f312bf3..40a47dcfb87 100644 --- a/src/goto-symex/symex_atomic_section.cpp +++ b/src/goto-symex/symex_atomic_section.cpp @@ -28,7 +28,7 @@ void goto_symext::symex_atomic_begin(statet &state) if(state.atomic_section_id!=0) throw "nested atomic section detected at "+ state.source.pc->source_location.as_string(); - + state.atomic_section_id=++atomic_section_counter; state.read_in_atomic_section.clear(); state.written_in_atomic_section.clear(); @@ -54,10 +54,10 @@ Function: goto_symext::symex_atomic_end void goto_symext::symex_atomic_end(statet &state) { if(state.guard.is_false()) return; - + if(state.atomic_section_id==0) throw "ATOMIC_END unmatched"; - + const unsigned atomic_section_id=state.atomic_section_id; state.atomic_section_id=0; diff --git a/src/goto-symex/symex_builtin_functions.cpp b/src/goto-symex/symex_builtin_functions.cpp index 76275b9e4d4..0a1fbbf8505 100644 --- a/src/goto-symex/symex_builtin_functions.cpp +++ b/src/goto-symex/symex_builtin_functions.cpp @@ -54,7 +54,7 @@ inline static typet c_sizeof_type_rec(const exprt &expr) if(t.is_not_nil()) return t; } } - + return nil_typet(); } @@ -65,15 +65,15 @@ void goto_symext::symex_malloc( { if(code.operands().size()!=1) throw "malloc expected to have one operand"; - + if(lhs.is_nil()) return; // ignore dynamic_counter++; - + exprt size=code.op0(); typet object_type=nil_typet(); - + // is the type given? if(code.type().id()==ID_pointer && code.type().subtype().id()!=ID_empty) { @@ -84,11 +84,11 @@ void goto_symext::symex_malloc( exprt tmp_size=size; state.rename(tmp_size, ns); // to allow constant propagation simplify(tmp_size, ns); - + // special treatment for sizeof(T)*x { typet tmp_type=c_sizeof_type_rec(tmp_size); - + if(tmp_type.is_not_nil()) { // Did the size get multiplied? @@ -122,25 +122,25 @@ void goto_symext::symex_malloc( else { mp_integer elements=alloc_size/elem_size; - + if(elements*elem_size==alloc_size) object_type=array_typet(tmp_type, from_integer(elements, tmp_size.type())); } } } } - + if(object_type.is_nil()) object_type=array_typet(unsigned_char_type(), tmp_size); // we introduce a fresh symbol for the size // to prevent any issues of the size getting ever changed - + if(object_type.id()==ID_array && !to_array_type(object_type).size().is_constant()) { exprt &size=to_array_type(object_type).size(); - + symbolt size_symbol; size_symbol.base_name="dynamic_object_size"+i2string(dynamic_counter); @@ -157,7 +157,7 @@ void goto_symext::symex_malloc( symex_assign_rec(state, assignment); } } - + // value symbolt value_symbol; @@ -169,9 +169,9 @@ void goto_symext::symex_malloc( value_symbol.mode=ID_C; new_symbol_table.add(value_symbol); - + address_of_exprt rhs; - + if(object_type.id()==ID_array) { rhs.type()=pointer_typet(value_symbol.type.subtype()); @@ -185,7 +185,7 @@ void goto_symext::symex_malloc( rhs.op0()=value_symbol.symbol_expr(); rhs.type()=pointer_typet(value_symbol.type); } - + if(rhs.type()!=lhs.type()) rhs.make_typecast(lhs.type()); @@ -228,7 +228,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next( { if(code.operands().size()!=1) throw "va_arg_next expected to have one operand"; - + if(lhs.is_nil()) return; // ignore @@ -238,7 +238,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next( irep_idt id=get_symbol(tmp); exprt rhs=gen_zero(lhs.type()); - + if(id!=irep_idt()) { // strip last name off id to get function name @@ -293,7 +293,7 @@ irep_idt get_string_argument_rec(const exprt &src) if(src.op0().id()==ID_index) { assert(src.op0().operands().size()==2); - + if(src.op0().op0().id()==ID_string_constant && src.op0().op1().is_zero()) { @@ -302,7 +302,7 @@ irep_idt get_string_argument_rec(const exprt &src) } } } - + return ""; } @@ -354,7 +354,7 @@ void goto_symext::symex_printf( for(unsigned i=1; i args; - + for(unsigned i=1; i args; - + for(unsigned i=1; i=debug_lvl) { std::list vars; - + irep_idt event=code.arguments()[1].op0().get(ID_value); for(unsigned j=2; j