Summary: Warnings for conditions always true/false Errors for other unreachable statements (should help debugging inferbo) Reviewed By: sblackshear Differential Revision: D5047883 fbshipit-source-id: 65a78camaster
parent
7be1bfa89f
commit
ec7b096ff6
@ -1,20 +1,56 @@
|
||||
codetoanalyze/c/bufferoverrun/array_dynlength.c, init_variable_array, 3, BUFFER_OVERRUN, [Offset: [3xs$0 + 1, 3xs$1 + 1] Size: [3xs$0 + 1, 3xs$1 + 1]]
|
||||
codetoanalyze/c/bufferoverrun/break_continue_return.c, break_continue_return, 4, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/break_continue_return.c, break_continue_return, 13, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/break_continue_return.c, break_continue_return, 16, BUFFER_OVERRUN, [Offset: [0, 10] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/do_while.c, do_while, 2, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ]
|
||||
codetoanalyze/c/bufferoverrun/do_while.c, do_while, 3, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/do_while.c:18:5 by call `do_while_sub()` ]
|
||||
codetoanalyze/c/bufferoverrun/for_loop.c, for_loop, 10, BUFFER_OVERRUN, [Offset: [0, 9] Size: [5, 10]]
|
||||
codetoanalyze/c/bufferoverrun/for_loop.c, safealloc, 10, UNREACHABLE_CODE, []
|
||||
codetoanalyze/c/bufferoverrun/function_call.c, call_by_ptr_good_FP, 4, BUFFER_OVERRUN, [Offset: [99, 99] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset: [20, 20] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:18:3 by call `arr_access()` ]
|
||||
codetoanalyze/c/bufferoverrun/function_call.c, function_call, 4, BUFFER_OVERRUN, [Offset: [100, 100] Size: [10, 10] @ codetoanalyze/c/bufferoverrun/function_call.c:17:3 by call `arr_access()` ]
|
||||
codetoanalyze/c/bufferoverrun/global.c, compare_global_variable_bad, 3, BUFFER_OVERRUN, [Offset: [10, 10] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/goto_loop.c, goto_loop, 11, BUFFER_OVERRUN, [Offset: [10, +oo] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/inf_loop.c, inf_loop, 4, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/models.c, exit_bo_good_unreachable_bad, 2, UNREACHABLE_CODE, []
|
||||
codetoanalyze/c/bufferoverrun/models.c, fgetc_255_bad, 4, BUFFER_OVERRUN, [Offset: [0, 255] Size: [255, 255]]
|
||||
codetoanalyze/c/bufferoverrun/models.c, fgetc_m1_bad, 3, BUFFER_OVERRUN, [Offset: [-1, 255] Size: [10000, 10000]]
|
||||
codetoanalyze/c/bufferoverrun/nested_loop.c, nested_loop, 7, BUFFER_OVERRUN, [Offset: [0, 10] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/nested_loop_with_label.c, nested_loop_with_label, 6, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/pointer_arith.c, pointer_arith_bad, 4, BUFFER_OVERRUN, [Offset: [10, 10] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, FP_prune_alias_exp_Ok, 4, BUFFER_OVERRUN, [Offset: [1, 1] Size: [1, 1]]
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_and_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_and_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_eq_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_exp_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_ge_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_gt_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_le_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_lt_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_ne_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 7, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 7, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 11, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_not_Ok, 11, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_or_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_alias.c, prune_alias_or_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_constant.c, prune_constant_false_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_constant.c, prune_constant_true_Ok, 3, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/prune_constant.c, prune_constant_value_Ok, 3, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/sizeof.c, eval_sizeof_bad, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/sizeof.c, eval_sizeof_bad, 4, BUFFER_OVERRUN, [Offset: [1, 1] Size: [0, 0]]
|
||||
codetoanalyze/c/bufferoverrun/sizeof.c, static_stride_bad, 7, BUFFER_OVERRUN, [Offset: [1, 1] Size: [0, 0]]
|
||||
codetoanalyze/c/bufferoverrun/trivial.c, trivial, 2, BUFFER_OVERRUN, [Offset: [10, 10] Size: [10, 10]]
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, FP_loop_with_break_good, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, FP_loop_with_exit_good, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, FP_loop_with_return_good, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, FP_loop_with_unreachable_good, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, condition_always_false_bad, 1, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, condition_always_true_bad, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, condition_always_true_with_else_bad, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, infinite_loop_bad, 1, CONDITION_ALWAYS_TRUE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, never_loops_bad, 1, CONDITION_ALWAYS_FALSE, []
|
||||
codetoanalyze/c/bufferoverrun/unreachable.c, unreachable_statement_exit_bad, 1, UNREACHABLE_CODE, []
|
||||
codetoanalyze/c/bufferoverrun/while_loop.c, while_loop, 3, BUFFER_OVERRUN, [Offset: [0, +oo] Size: [10, 10]]
|
||||
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
int __infer_nondet_int() {
|
||||
int ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nop() {}
|
||||
|
||||
void condition_always_true_bad() {
|
||||
if (1) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void condition_always_false_bad() {
|
||||
if (0) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void condition_always_true_with_else_bad() {
|
||||
if (1) {
|
||||
nop();
|
||||
} else {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void exit_at_end_of_if_good() {
|
||||
if (__infer_nondet_int()) {
|
||||
exit(4);
|
||||
}
|
||||
}
|
||||
|
||||
void FN_useless_else_bad() {
|
||||
if (__infer_nondet_int()) {
|
||||
exit(0);
|
||||
} else {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void never_loops_bad() {
|
||||
while (0) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void infinite_loop_bad() {
|
||||
while (1) {
|
||||
nop();
|
||||
}
|
||||
}
|
||||
|
||||
void FP_loop_with_break_good() {
|
||||
while (1) {
|
||||
if (__infer_nondet_int()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FP_loop_with_return_good() {
|
||||
while (1) {
|
||||
if (__infer_nondet_int()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FP_loop_with_exit_good() {
|
||||
while (1) {
|
||||
if (__infer_nondet_int()) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FP_loop_with_unreachable_good() {
|
||||
while (1) {
|
||||
if (__infer_nondet_int()) {
|
||||
infinite_loop_bad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FN_loop_once_break_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FN_loop_once_return_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void FN_loop_once_exit_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
void FN_loop_once_unreachable_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
infinite_loop_bad();
|
||||
}
|
||||
}
|
||||
|
||||
void FN_unreachable_statement_call_bad() {
|
||||
infinite_loop_bad();
|
||||
nop();
|
||||
}
|
||||
|
||||
void unreachable_statement_exit_bad() {
|
||||
exit(2);
|
||||
nop();
|
||||
}
|
||||
|
||||
void FN_unreachable_statement_return_bad() {
|
||||
return;
|
||||
nop();
|
||||
}
|
||||
|
||||
void FN_unreachable_statement_break_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
if (__infer_nondet_int()) {
|
||||
break;
|
||||
nop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FN_unreachable_statement_continue_bad() {
|
||||
while (__infer_nondet_int()) {
|
||||
continue;
|
||||
nop();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue