Skip to content

[depends: #708] Adding tests that check that simplify removes statements generated by FP removal #915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
3d59183
Make evaluation and/or simplification of conditions/expressions an ai…
Sep 8, 2016
1daaaed
Implement domain_simplify for intervals.
Dec 16, 2016
0060747
Refactor goto-analyzer so that task, analysis, domain and output can …
Dec 16, 2016
d412b41
Remove the special case handling of --show-intervals.
Sep 9, 2016
b25bbde
Implement domain_simplify for the constant domain.
Sep 9, 2016
a3875f3
Add output_json to the dependence_graph abstract domain.
Nov 1, 2016
768cc67
Add utility function for remove_unreachable.
Dec 16, 2016
6153fe6
Catch exceptions thrown in doit() in goto analyzer.
Dec 19, 2016
62c7dd2
Fix merging issues in goto analyzer
danpoe Jan 22, 2017
df7e417
Fix whitespace to match coding guidelines
danpoe Jan 25, 2017
86f1731
Fix constant propagator
danpoe Jan 25, 2017
860f465
disable two-way propagation for now
danpoe Jan 30, 2017
03045fd
regression test changes
danpoe Feb 3, 2017
7651ca2
Addressing goto analyzer review comments
danpoe Feb 3, 2017
b20448c
option to ignore unresolved functions in the constant propagator
danpoe Feb 10, 2017
5ae66c0
use ai function output in goto-instrument
danpoe Feb 10, 2017
250dda2
more status output
danpoe Feb 15, 2017
81ed6f6
constant propagator fix
danpoe Feb 15, 2017
bf78fe7
add is_bottom() and is_top() to ai_domain_baset
danpoe Feb 17, 2017
36b72fd
enable failed tests printer for goto-analyzer regression tests
danpoe Feb 22, 2017
4e29ef7
enable assertions in is_threadedt
danpoe Feb 24, 2017
9a91f83
fixed compilation error in debug mode
danpoe Apr 5, 2017
aae6e6e
Check in of basic variable sensitivity framework.
Feb 14, 2017
d7fcaff
Added constant_abstract_value implementation
Feb 17, 2017
cc56a35
Use variable in the constant_propogation checks
Feb 17, 2017
c7c5dcf
Adding debug guarded output to the variable sensitivity domain
Feb 21, 2017
54f195d
Better stub for assigning to non-trivial symbol
Feb 21, 2017
dd98c8c
Created skeleton classes for the array, pointer, struct
Feb 21, 2017
e4a01df
Adding a 2 element implemention of sturct abstract object
Feb 21, 2017
0d1a91a
Modifications to struct_abstract_object
Feb 22, 2017
44e4f9a
Readded broken protected
Feb 22, 2017
6a4a4dd
Implementation of simplify
Feb 22, 2017
d3082d9
Don't use static for the map as means wrong this is captured
Feb 22, 2017
25d231f
Added handler for logical == expression
Feb 22, 2017
28ef4e3
Cleaned up the variable sensitivity framework
Feb 23, 2017
41aa910
Corrected the logic for non-trivial assigns
Feb 23, 2017
50aefad
Fixied potential dangling pointer in the struct abstract oject
Feb 23, 2017
9153942
Basic implementations for abstract pointer and abstract array
Feb 23, 2017
2f7a0fd
Moved the logic for resolving logical expressions into abstract_value
Feb 23, 2017
e42e26e
Fixed bug that would have occured for struct/pointer/array assigns
Feb 24, 2017
0fcaec4
Removed the requirement on two operands
Feb 24, 2017
2a27b35
Simplify the expression before storing
Feb 24, 2017
88a1de2
Fixed issue where writing to a top value
Feb 27, 2017
d6539df
Add previously written design documentation to the relevant parts of …
Feb 28, 2017
c19db6f
Improve the documentation of various methods.
Feb 28, 2017
5291b75
Give a generic implementation of assume.
Feb 28, 2017
3c088e9
Enable the use of assume for branches.
Feb 28, 2017
526cd87
Basic implementation of the sensitive pointer
Feb 27, 2017
6707388
Fixing comments in pointer_abstract_object
Feb 27, 2017
333a38f
Adding merge state
Feb 28, 2017
68c45af
Supporting stack when writing
Feb 28, 2017
f405f53
Changed the pointer abstract object to store an expression
Feb 28, 2017
c3c1c79
Implementing a configurable abstract object factory
Feb 28, 2017
9cab8ce
Fixed crash bug in writing to dereference of pointer to pointer
Feb 28, 2017
6b25f9b
Improved exception message for unreasonable write
Feb 28, 2017
a133870
Checking in a demo script containg the things that currently work
Feb 28, 2017
21c2fcf
Added writing to pointer to demo
Feb 28, 2017
faffd81
Added flags so the factory reads the flags correctly
Feb 28, 2017
2f0e429
Enable pointer sensitivity in the factory
Feb 28, 2017
54a670c
Added documentation to the demo script
Feb 28, 2017
03a5516
Fixing up formatting
Mar 2, 2017
fb86f2b
Add simplification of the left hand side of assignments.
Feb 28, 2017
127699e
Remove incorrect comment.
Feb 28, 2017
f4d1840
Review comments and TODOs.
Feb 28, 2017
2938709
Mark unreachable assertions as satisfied.
Mar 1, 2017
fbd2e52
Document various of the key ideas behind how goto-analyze works.
Mar 2, 2017
b8aa460
Renamed methods to provide a more consistent interface
Mar 6, 2017
a191670
Protect top and bottom as much as possible.
Mar 6, 2017
714a9f7
Output should be const-clean.
Mar 6, 2017
9c33e9a
Implementing sensitive struct abstract object
danpoe Feb 27, 2017
8e44147
If anything is assigned the value bottom, the whole domain should be …
Mar 6, 2017
754f418
A missing case in the factory code means that constant assertions wer…
Mar 6, 2017
5f2407c
Fix overwrite for CLONE and MERGE
Mar 8, 2017
8f8af13
In abstract objects the state should be private and merge_state prote…
Mar 9, 2017
9c1a3a5
Enforced const interface for abstract objects
Mar 9, 2017
7e7218a
Fix crash
Mar 9, 2017
9c272cc
Minimal reproducer for struct problem
Mar 9, 2017
723ae80
Use the correct abstract object when performing a transform
Mar 17, 2017
fae976d
Corrected merge action in the abstract enviroment
Mar 17, 2017
c8e3d7d
Correct struct write for unknown component
Mar 17, 2017
e047346
Correcting type check in struct abstract object
Mar 17, 2017
f9a3cbb
Fix for crash
Mar 7, 2017
1d57f80
Basic implementation of the constant_array_abstract_object
Mar 10, 2017
4aef235
Array initialization now works with the abstract object
Mar 15, 2017
2fc020d
Added merge_state to constant_array_abstract_object
Mar 16, 2017
d944c92
Adding function header comments
Mar 16, 2017
514c92c
Removed unnecessary copies
Mar 17, 2017
07cd3b3
Updating the demo script
Mar 17, 2017
77bbcb0
Adding output function to struct
Mar 23, 2017
9b8655a
Made verify stricter
Mar 23, 2017
ed1dfce
Fixed bug where top wasn't being cleared
Mar 23, 2017
34ce529
Bug fixes for the array abstract object
Mar 23, 2017
d3de879
Corrected and simplified constructor for the pointer abstract object
Mar 23, 2017
9cd204a
Corrected implementation of flow sensitivity
Mar 24, 2017
1d4c393
Tidy up includes
Mar 27, 2017
fa17c4e
Correcting implemenations of the write methods for pointer and struct
Mar 28, 2017
776b24f
Refactor the ai_simplify into a lhs function
Mar 28, 2017
2628f99
Corrected constructing object for failed evaluation
Mar 28, 2017
8818f01
Fixing constant propogation test
Mar 28, 2017
fae0baa
Linting fixes
Mar 28, 2017
2b49093
Modified lambda to compile under Windows compiler.
Mar 29, 2017
9211406
Improved the removing top elements in map merge
Apr 19, 2017
25bb2e5
Modified code to not crash when writing to an pointer arithmetic on lhs
Apr 5, 2017
ba4b2f2
Adding tests for reading and writing to/from ararys through points
Apr 7, 2017
f233cec
Fixed bug when doing a merge write to a pointer
Apr 11, 2017
65e4dd1
Reworked the double dispatch of the merge
Apr 21, 2017
12433b8
Removing default copy constructors
Apr 21, 2017
f8a1f01
Replacing map based switch statments with chained if/elses
Apr 24, 2017
3fa2bf4
Explained why top must be used as the else clause in eval
Apr 24, 2017
8118bef
Don't make copies unnecessarily when merging
Apr 25, 2017
4c761d2
Using enable_shared_from_this to eliminate naked pointers
Apr 25, 2017
009de7e
Adding unit tests for merging of abstract objects
Apr 25, 2017
6c8cfbb
Fixed bugs revealed by unit tests
Apr 25, 2017
a6fdf8f
Adding unit tests for constant abstract object.
Apr 25, 2017
760cbd8
Adding tests for constant array
Apr 27, 2017
c0fcd70
Adding unit tests for the struct abstract object
Apr 28, 2017
d5d3466
Corrected merge methods for pointer and struct
Apr 28, 2017
7788d11
Rewriting the constant_abstract_value::merge using behaviour driven d…
Apr 28, 2017
3cb9ebd
Replaced assert with __CPROVER_assert
May 2, 2017
28481c9
Use Behaviour Driven Design testing for abstract object merge
May 5, 2017
7c8912c
Struct and array AO unit tests using behaviour driven design
May 5, 2017
9ff56b0
Corrected guard on specialised merge
May 5, 2017
67da5aa
Made pointer to array name consistent
May 5, 2017
d10989e
Constant array reading from top handled correctly
May 5, 2017
2f56609
Completed test suite for full struct and constant array AOs
May 5, 2017
c1736c4
Correctly set up the enviroment before running tests
May 9, 2017
92a84dc
Extracted out logic for when to use a 2 value merge
May 11, 2017
79a8b9f
Adding tests for simplify function pointer removal
May 10, 2017
211cd21
Simplify fp tests now checking the simplified GOTO
May 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions regression/goto-analyze-show-goto-functions/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

default: tests.log

test:
@if ! ../test.pl -c ../chain.sh ; then \
../failed-tests-printer.pl ; \
exit 1; \
fi

tests.log:
@if ! ../test.pl -c ../chain.sh ; then \
../failed-tests-printer.pl ; \
exit 1; \
fi

show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.c" "$$dir/*.out"; \
fi; \
done;

clean:
@for dir in *; do \
rm -f tests.log; \
if [ -d "$$dir" ]; then \
cd "$$dir"; \
rm -f *.out *.gb; \
cd ..; \
fi \
done
13 changes: 13 additions & 0 deletions regression/goto-analyze-show-goto-functions/chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

SRC=../../../src
GA=$SRC/goto-analyzer/goto-analyzer

if [ -a $1_simplified.gb ]
then
rm $1_simplified.gb
fi
$GA $1 --simplify $1_simplified.gb --variable --arrays --structs --pointers
$GA $1_simplified.gb --show-goto-functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func()
{
const void_fp fp = f2;

// Warning: this loses const-ness of f2
void_fp * p2fp = (void_fp*)&fp;
*p2fp = &f4;

fp();
}

int main()
{
func();

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CORE
main.c

^\s*f4\(\);$
^SIGNAL=0$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f2\(\);$
^\s*\d+: f3\(\);$
^\s*\d+: f5\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the simplified goto program doesn't call any of the other functions (i.e
it has simplified all the unused cases generated by function pointer removal)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdio.h>
#include <stdlib.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func()
{
void_fp * const fp_tbl= malloc(sizeof(void_fp) * 3);
fp_tbl[0]=f2;
fp_tbl[1]=f3;
fp_tbl[2]=f4;

const void_fp fp = fp_tbl[1];
fp();
}

int main()
{
func();

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FUTURE
main.c

^\s*f3\(\);$
^SIGNAL=0$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f2\(\);$
^\s*\d+: f4\(\);$
^\s*\d+: f5\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the GOTOs generated by the function pointer removal are removed by the
simplify step. This requires supporting tracking arrays assigned dynamically
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func(void_fp fp)
{
fp();
}

int main(int argc, char** argv)
{

func(&f2);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CORE
main.c

^SIGNAL=0$
^\s*f2\(\);$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f3\(\);$
^\s*\d+: f4\(\);$
^\s*\d+: f5\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the GOTOs generated by the function pointer removal are removed by the
simplify step.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <stdio.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func()
{
const void_fp start_fp = f2;
const void_fp * const fp_tbl[] = { &start_fp, &start_fp, &start_fp };

// warning: loses const
void_fp * arr_ptr=fp_tbl[0];
(*arr_ptr) = f5;
arr_ptr++;
(*arr_ptr) = f5;

const void_fp * const fp = fp_tbl[1];


(*fp)();
}

int main()
{
func();

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FUTURE
main.c

^SIGNAL=0$
^\s*f5\(\);$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f2\(\);$
^\s*\d+: f3\(\);$
^\s*\d+: f4\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the GOTOs generated by the function pointer removal are removed by the
simplify step
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <stdio.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func()
{
const void_fp fp_tbl[] = {f2, f3 ,f4};

// warning: loses const
void_fp * arr_ptr=&fp_tbl[0];
(*arr_ptr) = f5;
arr_ptr++;
(*arr_ptr) = f5;

const void_fp fp = &fp_tbl[1];

fp();
}

int main()
{
func();

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FUTURE
main.c

^SIGNAL=0$
^\s*f5\(\);$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f2\(\);$
^\s*\d+: f3\(\);$
^\s*\d+: f4\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the GOTOs generated by the function pointer removal are removed by the
simplify step
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdio.h>

void f1 (void) { printf("%i\n", 1); }
void f2 (void) { printf("%i\n", 2); }
void f3 (void) { printf("%i\n", 3); }
void f4 (void) { printf("%i\n", 4); }
void f5 (void) { printf("%i\n", 5); }
void f6 (void) { printf("%i\n", 6); }
void f7 (void) { printf("%i\n", 7); }
void f8 (void) { printf("%i\n", 8); }
void f9 (void) { printf("%i\n", 9); }

typedef void(*void_fp)(void);

// There is a basic check that excludes all functions that aren't used anywhere
// This ensures that check can't work in this example
const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9};

void func()
{
void_fp fp = f2;
fp = f3;
fp();
}

int main()
{
func();

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CORE
main.c

^SIGNAL=0$
^\s*f3\(\);$
--
^warning: ignoring
^\s*\d+: f1\(\);$
^\s*\d+: f2\(\);$
^\s*\d+: f4\(\);$
^\s*\d+: f5\(\);$
^\s*\d+: f6\(\);$
^\s*\d+: f7\(\);$
^\s*\d+: f8\(\);$
^\s*\d+: f9\(\);$
--
Check the GOTOs generated by the function pointer removal are removed by the
simplify step
Loading