synthetic: reduce controlflow testcases

This commit is contained in:
Daniel Marjamäki 2016-12-06 21:45:51 +01:00
parent 718fcfda46
commit 7fc9fbc746
1 changed files with 11 additions and 62 deletions

View File

@ -1,52 +1,39 @@
////////////////////////////// //////////////////////////////
// path sensitive analysis // control flow analysis
////////////////////////////// //////////////////////////////
int buf[2]; int buf[2];
int getValue(void); // unknown int value
// arg void in_if(int a) {
// -------------------------------------
void arg_in_if(int a) {
if (a==100) if (a==100)
buf[a] = 0; // BUG buf[a] = 0; // BUG
} }
void arg_before_if(int a) { void before_if(int a) {
buf[a] = 0; // WARNING buf[a] = 0; // WARNING
if (a==100) {} if (a==100) {}
} }
void arg_after_if(int a) { void after_if(int a) {
if (a==100) {} if (a==100) {}
buf[a] = 0; // WARNING buf[a] = 0; // WARNING
} }
// var void in_for(void) {
// -------------------------------------
void var(void) {
int x = 100;
buf[x] = 0; // BUG
}
void var_in_for(void) {
int x; int x;
for (x = 0; x<100; x++) { for (x = 0; x<100; x++) {
buf[x] = 0; // BUG buf[x] = 0; // BUG
} }
} }
void var_after_for(void) { void after_for(void) {
int x; int x;
for (x = 0; x<100; x++) {} for (x = 0; x<100; x++) {}
buf[x] = 0; // BUG buf[x] = 0; // BUG
} }
void var_in_switch(void) { void in_switch(int x) {
int x = getValue();
switch (x) { switch (x) {
case 100: case 100:
buf[x] = 0; // BUG buf[x] = 0; // BUG
@ -54,8 +41,7 @@ void var_in_switch(void) {
} }
} }
void var_before_switch(void) { void before_switch(int x) {
int x = getValue();
buf[x] = 0; // WARNING buf[x] = 0; // WARNING
switch (x) { switch (x) {
case 100: case 100:
@ -63,8 +49,7 @@ void var_before_switch(void) {
} }
} }
void var_after_switch(void) { void after_switch(int x) {
int x = getValue();
switch (x) { switch (x) {
case 100: case 100:
break; break;
@ -72,7 +57,7 @@ void var_after_switch(void) {
buf[x] = 0; // WARNING buf[x] = 0; // WARNING
} }
void var_in_while(void) { void in_while(void) {
int x = 0; int x = 0;
while (x<100) { while (x<100) {
buf[x] = 0; // BUG buf[x] = 0; // BUG
@ -80,45 +65,9 @@ void var_in_while(void) {
} }
} }
void var_after_while(void) { void after_while(void) {
int x = 0; int x = 0;
while (x<100) while (x<100)
x++; x++;
buf[x] = 0; // BUG buf[x] = 0; // BUG
} }
// arg+var
// -------------------------------------
void arg_var_assign_in_if(int a) {
int x = 0;
if (a==0)
x = 100;
buf[x] = 0; // WARNING
}
void arg_var_in_while_1(int a) {
int x = 0;
if (a == 100) {}
while (x<a) {
buf[x] = 0; // WARNING
x++;
}
}
void arg_var_in_while_2(int a) {
int x = 0;
while (x<a) {
buf[x] = 0; // WARNING
x++;
}
if (a == 100) {}
}
void arg_var_after_while(int a) {
int x = 0;
if (a == 100) {}
while (x<a)
x++;
buf[x] = 0; // WARNING
}