Reviewed By: jberdine Differential Revision: D3803636 fbshipit-source-id: 5cc201dmaster
parent
ab70143e1b
commit
0b7ea202db
@ -0,0 +1,58 @@
|
|||||||
|
# Copyright (c) 2016 - 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.
|
||||||
|
|
||||||
|
ROOT_DIR = ../../../../..
|
||||||
|
include $(ROOT_DIR)/Makefile.config
|
||||||
|
|
||||||
|
OPTIONS = -x c++ -std=c++11 -isystem$(CLANG_INCLUDES)/c++/v1/ -c
|
||||||
|
|
||||||
|
default: compile
|
||||||
|
|
||||||
|
print: analyze
|
||||||
|
$(INFERPRINT_BIN) -q -a $(ANALYZER) --issues-tests issues.exp.test
|
||||||
|
LC_ALL=C sort -o issues.exp.test issues.exp.test
|
||||||
|
|
||||||
|
test: analyze print
|
||||||
|
make clean
|
||||||
|
diff -u issues.exp issues.exp.test
|
||||||
|
rm issues.exp.test
|
||||||
|
|
||||||
|
ANALYZER = infer
|
||||||
|
|
||||||
|
FILES = \
|
||||||
|
attributes/*.cpp \
|
||||||
|
conditional/*.cpp \
|
||||||
|
constructors/*.cpp \
|
||||||
|
c_tests/*.cpp \
|
||||||
|
exceptions/*.cpp \
|
||||||
|
include_header/header.h \
|
||||||
|
include_header/include_templ.cpp \
|
||||||
|
lambda/*.cpp \
|
||||||
|
memory_leaks/*.cpp \
|
||||||
|
methods/*.cpp \
|
||||||
|
models/*.cpp \
|
||||||
|
namespace/*.cpp \
|
||||||
|
nestedoperators/*.cpp \
|
||||||
|
npe/*.cpp \
|
||||||
|
numeric/*.cpp \
|
||||||
|
reference/*.cpp \
|
||||||
|
resource_leaks/*.cpp \
|
||||||
|
smart_ptr/*.cpp \
|
||||||
|
subtyping/*.cpp \
|
||||||
|
templates/*.cpp \
|
||||||
|
types/*.cpp \
|
||||||
|
vector/*.cpp \
|
||||||
|
|
||||||
|
compile:
|
||||||
|
clang $(OPTIONS) $(FILES)
|
||||||
|
|
||||||
|
analyze:
|
||||||
|
$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt
|
||||||
|
grep "DUPLICATE_SYMBOLS" duplicates.txt; true
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o infer-out duplicates.txt
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/attributes/deprecated_hack.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/conditional/lvalue_conditional.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/constructors/constructor_init.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/constructors/constructor_new.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/constructors/constructor_with_body.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/constructors/copy_move_constructor.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/constructors/temp_object.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/exceptions/Exceptions.cpp
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 - 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace header {
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int div0() { return 1 / 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct B {
|
||||||
|
int div0() { return 1 / 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
int div0_fun() { return 1 / 0; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
int div0_templ() {
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 - 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace header2 {
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int div0() { return 1 / 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct B {
|
||||||
|
int div0() { return 1 / 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
int div0_fun() { return 1 / 0; }
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
int div0_templ() {
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 - 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 "header2.h"
|
||||||
|
|
||||||
|
// instantiate templates to produce bug reports for them
|
||||||
|
void div0_B_int() {
|
||||||
|
B<int> b;
|
||||||
|
b.div0();
|
||||||
|
}
|
||||||
|
|
||||||
|
void div0_B_A() {
|
||||||
|
B<A> b;
|
||||||
|
b.div0();
|
||||||
|
}
|
||||||
|
|
||||||
|
void div0_templ_int() { div0_templ<int>(); }
|
||||||
|
|
||||||
|
int div0_templ_A() { div0_templ<A>(); }
|
@ -0,0 +1,272 @@
|
|||||||
|
attributes/deprecated_hack.cpp, derefFirstArg2_null_deref, 2, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, derefFirstArg3_null_deref, 2, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, derefFirstArg_null_deref, 2, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, getPtr_null_deref1, 3, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, getPtr_null_deref2, 3, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, getRef_null_deref1, 3, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, getRef_null_deref2, 3, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, operator_star_null_deref1, 3, NULL_DEREFERENCE
|
||||||
|
attributes/deprecated_hack.cpp, operator_star_null_deref2, 3, NULL_DEREFERENCE
|
||||||
|
c_tests/c_bugs.cpp, crash_fgetc, 4, NULL_DEREFERENCE
|
||||||
|
c_tests/c_bugs.cpp, crash_getc, 4, NULL_DEREFERENCE
|
||||||
|
c_tests/c_bugs.cpp, malloc_fail_gets_reported, 2, NULL_DEREFERENCE
|
||||||
|
c_tests/c_bugs.cpp, malloc_memory_leak_is_reported, 0, MEMORY_LEAK
|
||||||
|
c_tests/c_bugs.cpp, memcpy_spec_is_found, 3, NULL_DEREFERENCE
|
||||||
|
c_tests/c_bugs.cpp, resource_leak_is_reported, 0, RESOURCE_LEAK
|
||||||
|
c_tests/c_bugs.cpp, resource_leak_is_reported, 0, RETURN_VALUE_IGNORED
|
||||||
|
conditional/lvalue_conditional.cpp, div0_assign_conditional, 0, DIVIDE_BY_ZERO
|
||||||
|
conditional/lvalue_conditional.cpp, div0_choose_lvalue, 0, DIVIDE_BY_ZERO
|
||||||
|
conditional/lvalue_conditional.cpp, div0_choose_rvalue, 0, DIVIDE_BY_ZERO
|
||||||
|
conditional/lvalue_conditional.cpp, div0_temp_lvalue, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_init.cpp, delegate_constr_f2_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_init.cpp, delegate_constr_f_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_init.cpp, f2_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_init.cpp, f_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_init.cpp, t_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::array_of_class_with_not_constant_size, 1, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::array_of_person_with_constant_size, 0, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_1_arg_new_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_1_arg_new_div0, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_3_args_new_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_3_args_new_div0, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_nodes, 3, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::constructor_nodes, 3, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::float_init_number, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::float_init_number, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_array, 4, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_array, 4, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_array_init, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_array_init, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_empty, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_empty, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_empty_list, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_empty_list_new, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_empty_list_new, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_nodes, 3, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_nodes, 4, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_nodes, 4, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_number, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_new.cpp, constructor_new::int_init_number, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_new.cpp, constructor_new::matrix_of_person, 2, MEMORY_LEAK
|
||||||
|
constructors/constructor_with_body.cpp, constructor_with_body::test_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/constructor_with_body.cpp, constructor_with_body::test_div0_default_constructor, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/copy_move_constructor.cpp, copy_move_constructor::copyX_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
constructors/copy_move_constructor.cpp, copy_move_constructor::copyY_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
constructors/copy_move_constructor.cpp, copy_move_constructor::moveX_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/copy_move_constructor.cpp, copy_move_constructor::moveY_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/copy_move_constructor.cpp, copy_move_constructor::moveY_moveY_copyY_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::assign_temp_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::getX_field_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::getX_method_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::temp_field2_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::temp_field_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
constructors/temp_object.cpp, temp_object::temp_method_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
exceptions/Exceptions.cpp, call_deref_with_null, 0, NULL_DEREFERENCE
|
||||||
|
include_header/header.h, header::A_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
include_header/header.h, header::div0_fun, 0, DIVIDE_BY_ZERO
|
||||||
|
include_header/header2.h, header2::B<A>_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
include_header/header2.h, header2::B<int>_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
include_header/header2.h, header2::div0_templ<A>, 1, DIVIDE_BY_ZERO
|
||||||
|
include_header/header2.h, header2::div0_templ<int>, 1, DIVIDE_BY_ZERO
|
||||||
|
lambda/lambda1.cpp, bar, 5, DIVIDE_BY_ZERO
|
||||||
|
lambda/lambda1.cpp, foo, 3, DIVIDE_BY_ZERO
|
||||||
|
lambda/lambda1.cpp, foo::lambda_lambda_lambda1.cpp:19:17_operator(), 0, DIVIDE_BY_ZERO
|
||||||
|
memory_leaks/array_leak.cpp, leak, 4, MEMORY_LEAK
|
||||||
|
memory_leaks/object_leak.cpp, object_leak, 0, MEMORY_LEAK
|
||||||
|
memory_leaks/raii_malloc.cpp, memory_leak, 0, MEMORY_LEAK
|
||||||
|
methods/conversion_operator.cpp, conversion_operator::branch_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
methods/conversion_operator.cpp, conversion_operator::y_branch_div0, 6, DIVIDE_BY_ZERO
|
||||||
|
methods/static.cpp, div0_class, 0, DIVIDE_BY_ZERO
|
||||||
|
methods/static.cpp, div0_instance, 2, DIVIDE_BY_ZERO
|
||||||
|
methods/virtual_methods.cpp, poly_area, 3, DIVIDE_BY_ZERO
|
||||||
|
methods/virtual_methods.cpp, rect_area, 4, DIVIDE_BY_ZERO
|
||||||
|
methods/virtual_methods.cpp, tri_area, 5, DIVIDE_BY_ZERO
|
||||||
|
methods/virtual_methods.cpp, tri_not_virtual_area, 5, DIVIDE_BY_ZERO
|
||||||
|
models/move.cpp, move::div0_moved_from, 3, DIVIDE_BY_ZERO
|
||||||
|
models/move.cpp, move::div0_moved_to, 3, DIVIDE_BY_ZERO
|
||||||
|
namespace/function.cpp, div0_namespace_resolution, 0, DIVIDE_BY_ZERO
|
||||||
|
namespace/function.cpp, div0_using, 2, DIVIDE_BY_ZERO
|
||||||
|
namespace/global_variable.cpp, div0_namepace_res, 3, DIVIDE_BY_ZERO
|
||||||
|
namespace/global_variable.cpp, div0_static_field, 3, DIVIDE_BY_ZERO
|
||||||
|
namespace/global_variable.cpp, div0_static_field_member_access, 3, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, conditional_init_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, function_call_init_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, reference_init_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, simple_inif_elseif_div0, 6, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, simple_init_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
nestedoperators/var_decl_inside_if.cpp, simple_init_null_deref, 4, NULL_DEREFERENCE
|
||||||
|
npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_field_deref, 2, NULL_DEREFERENCE
|
||||||
|
npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref, 2, NULL_DEREFERENCE
|
||||||
|
npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref2, 2, NULL_DEREFERENCE
|
||||||
|
npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_result_method_null_deref, 4, NULL_DEREFERENCE
|
||||||
|
npe/method_call.cpp, npe_call, 2, NULL_DEREFERENCE
|
||||||
|
npe/method_call.cpp, npe_call_after_call, 0, NULL_DEREFERENCE
|
||||||
|
npe/method_call.cpp, npe_call_with_forward_declaration, 1, NULL_DEREFERENCE
|
||||||
|
npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe, 2, NULL_DEREFERENCE
|
||||||
|
npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe_person, 2, NULL_DEREFERENCE
|
||||||
|
npe/null_returned_by_method.cpp, testNullDeref, 3, NULL_DEREFERENCE
|
||||||
|
npe/object_deref.cpp, object_deref::derefNullField, 2, NULL_DEREFERENCE
|
||||||
|
npe/skip_function_with_const_formals.cpp, const_skip2_then_split_case, 5, MEMORY_LEAK
|
||||||
|
npe/skip_function_with_const_formals.cpp, const_skip_then_split_case, 6, MEMORY_LEAK
|
||||||
|
npe/skip_function_with_const_formals.cpp, skip_then_split_case, 2, MEMORY_LEAK
|
||||||
|
npe/skip_function_with_const_formals.cpp, skip_then_split_case, 5, NULL_DEREFERENCE
|
||||||
|
npe/skip_function_with_const_formals.cpp, typedef_skip_then_split_case, 2, MEMORY_LEAK
|
||||||
|
npe/skip_function_with_const_formals.cpp, typedef_skip_then_split_case, 4, NULL_DEREFERENCE
|
||||||
|
numeric/min_max.cpp, max_X_inv_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
numeric/min_max.cpp, max_int_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
numeric/min_max.cpp, min_X_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
numeric/min_max.cpp, min_int_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ptr_F_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ptr_I_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ptr_getF_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ptr_getI_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ref_F_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ref_I_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ref_getF_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::ref_getI_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::val_F_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::val_I_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::val_getF_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_field.cpp, reference_field::val_getI_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, field_div0_ptr, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, field_div0_ref, 2, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, get_global_ptr_div0_field, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, get_global_ptr_div0_method, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, get_global_ref_div0_field, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, get_global_ref_div0_method, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, method_div0_ptr, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_struct_e2e.cpp, method_div0_ref, 2, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ptr_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ptr_div0_function, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ptr_div0_function_temp_var, 4, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ref_div0, 4, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ref_div0_function, 3, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ref_div0_function_temp_var, 4, DIVIDE_BY_ZERO
|
||||||
|
reference/reference_type_e2e.cpp, ref_div0_nested_assignment, 6, DIVIDE_BY_ZERO
|
||||||
|
reference/temporary_lvalue.cpp, div0_function_param_cast, 0, DIVIDE_BY_ZERO
|
||||||
|
reference/temporary_lvalue.cpp, div0_init_expr, 2, DIVIDE_BY_ZERO
|
||||||
|
reference/temporary_lvalue.cpp, div0_no_const_ref, 2, DIVIDE_BY_ZERO
|
||||||
|
resource_leaks/raii.cpp, resource_leak, 7, RESOURCE_LEAK
|
||||||
|
smart_ptr/deref_after_move_example.cpp, deref_after_mode_example::deref_after_move_crash, 4, NULL_DEREFERENCE
|
||||||
|
smart_ptr/deref_after_move_example.cpp, deref_after_mode_example::deref_after_move_ok, 4, MEMORY_LEAK
|
||||||
|
smart_ptr/deref_after_move_example.cpp, deref_after_mode_example::deref_ok, 3, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_base1_null_f1_deref, 6, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_base1_nullptr_deref, 0, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_base2_null_f1_deref, 6, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_base2_nullptr_deref, 0, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived1_null_f1_deref, 6, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived1_nullptr_deref, 0, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived2_null_f1_deref, 6, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived2_nullptr_deref, 0, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived3_null_f1_deref, 6, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_constructors.cpp, shared_ptr_constructors::get_from_derived3_nullptr_deref, 0, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::empty_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::empty_ptr_field_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::empty_ptr_field_deref2, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::empty_ptr_method_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::nullptr_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_null_deref, 2, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_null_deref2, 2, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_null_deref2, 3, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_null_deref2, 4, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_ok_deref, 4, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::reset_ptr_ok_deref2, 5, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_assign_null_deref, 3, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_assign_null_deref, 4, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_assign_ok_deref, 6, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_copy_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_copy_ok_deref, 4, MEMORY_LEAK
|
||||||
|
smart_ptr/shared_ptr_deref.cpp, shared_ptr::shared_ptr_move_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::empty_array_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::empty_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::empty_ptr_field_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::empty_ptr_field_deref2, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::empty_ptr_method_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::nullptr_array_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::nullptr_ptr_deref, 2, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_null_deref, 2, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_null_deref2, 2, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_null_deref2, 3, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_null_deref2, 4, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_ok_deref, 4, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::reset_ptr_ok_deref2, 5, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_assign_null_deref, 3, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_assign_null_deref, 4, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_assign_ok_deref, 6, MEMORY_LEAK
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_copy_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_null_deref, 3, NULL_DEREFERENCE
|
||||||
|
smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_ok_deref, 4, MEMORY_LEAK
|
||||||
|
subtyping/cast_with_enforce.cpp, cast_with_enforce::cast_with_npe, 3, NULL_DEREFERENCE
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::rightPointerCast, 4, DIVIDE_BY_ZERO
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::rightPointerCast, 4, MEMORY_LEAK
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::rightReferenceCast, 2, MEMORY_LEAK
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongCastOfArgumentPointer, 2, DIVIDE_BY_ZERO
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongCastOfArgumentReference, 2, CLASS_CAST_EXCEPTION
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongPointerCast, 2, MEMORY_LEAK
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongPointerCast, 6, DIVIDE_BY_ZERO
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongReferenceCast, 3, CLASS_CAST_EXCEPTION
|
||||||
|
subtyping/dynamic_cast.cpp, dynamic__cast::wrongReferenceCastNotAssigned, 3, CLASS_CAST_EXCEPTION
|
||||||
|
subtyping/subtyping_check.cpp, B_setFG, 4, DIVIDE_BY_ZERO
|
||||||
|
templates/class_template_instantiate.cpp, ExecStore<Choose2>_call_div, 2, DIVIDE_BY_ZERO
|
||||||
|
templates/class_template_instantiate.cpp, choose1_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/class_template_instantiate.cpp, choose2_div0_extra, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function.cpp, function::createAndDiv<X3>, 1, DIVIDE_BY_ZERO
|
||||||
|
templates/function.cpp, function::div0_create_and_get_val, 1, DIVIDE_BY_ZERO
|
||||||
|
templates/function.cpp, function::div0_get_val, 3, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_10args, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_1arg, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_3args1, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_3args2, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_3args3, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/function_pack.cpp, div0_3args4, 0, DIVIDE_BY_ZERO
|
||||||
|
templates/method.cpp, method::div0_getter, 3, DIVIDE_BY_ZERO
|
||||||
|
templates/method.cpp, method::div0_getter_templ, 4, DIVIDE_BY_ZERO
|
||||||
|
templates/method.cpp, method::div0_getter_templ2, 4, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_b1, 2, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_b1_s, 3, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_b2, 2, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_cast, 3, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_cast_ref, 3, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_s, 2, DIVIDE_BY_ZERO
|
||||||
|
types/inheritance_field.cpp, div0_s_b1, 3, DIVIDE_BY_ZERO
|
||||||
|
types/operator_overload.cpp, div0_function_op, 3, DIVIDE_BY_ZERO
|
||||||
|
types/operator_overload.cpp, div0_inheritted_op, 2, DIVIDE_BY_ZERO
|
||||||
|
types/operator_overload.cpp, div0_method, 3, DIVIDE_BY_ZERO
|
||||||
|
types/operator_overload.cpp, div0_method_op, 3, DIVIDE_BY_ZERO
|
||||||
|
types/operator_overload.cpp, div0_method_op_ptr, 0, DIVIDE_BY_ZERO
|
||||||
|
types/return_struct.cpp, return_struct::get_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
types/return_struct.cpp, return_struct::get_field_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
types/return_struct.cpp, return_struct::get_method_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
types/struct_forward_declare.cpp, struct_forward_declare::X_Y_div0, 7, DIVIDE_BY_ZERO
|
||||||
|
types/struct_forward_declare.cpp, struct_forward_declare::X_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
types/struct_forward_declare.cpp, struct_forward_declare::X_ptr_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
types/struct_forward_declare.cpp, struct_forward_declare::Z_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
types/struct_forward_declare.cpp, struct_forward_declare::Z_ptr_div0, 5, DIVIDE_BY_ZERO
|
||||||
|
types/struct_pass_by_value.cpp, struct_pass_by_value::field_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
types/struct_pass_by_value.cpp, struct_pass_by_value::param_get_copied_div0, 3, DIVIDE_BY_ZERO
|
||||||
|
types/struct_pass_by_value.cpp, struct_pass_by_value::temp_div0, 0, DIVIDE_BY_ZERO
|
||||||
|
types/struct_pass_by_value.cpp, struct_pass_by_value::var_div0, 2, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, employee_typeid, 3, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, employee_typeid, 4, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, person_ptr_typeid, 2, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, person_ptr_typeid, 3, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, person_typeid, 3, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, person_typeid, 6, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, person_typeid_name, 3, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, person_typeid_name, 4, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, person_typeid_name, 8, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, template_type_id_person, 2, MEMORY_LEAK
|
||||||
|
types/typeid_expr.cpp, template_type_id_person, 5, DIVIDE_BY_ZERO
|
||||||
|
types/typeid_expr.cpp, template_typeid<Person>, 2, MEMORY_LEAK
|
||||||
|
vector/empty_access.cpp, access_empty, 2, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, assign_empty, 4, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, clear_empty, 3, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, copy_empty, 3, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, empty_check_access_empty, 2, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, getter_empty, 0, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, size_check0_empty, 2, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, vector_as_param_by_value_empty, 2, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, vector_as_param_clear, 3, EMPTY_VECTOR_ACCESS
|
||||||
|
vector/empty_access.cpp, vector_as_param_empty, 2, EMPTY_VECTOR_ACCESS
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/lambda/lambda1.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/methods/conversion_operator.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/methods/static.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/methods/virtual_methods.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/namespace/function.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/namespace/global_variable.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/nestedoperators/var_decl_inside_if.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/reference/reference_field.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/reference/reference_struct_e2e.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/reference/reference_type_e2e.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/reference/temporary_lvalue.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/templates/class_template_instantiate.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/templates/function.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/templates/function_pack.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/templates/method.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/inheritance_field.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/operator_overload.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/return_struct.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/struct_forward_declare.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/struct_pass_by_value.cpp
|
@ -0,0 +1 @@
|
|||||||
|
../../frontend/types/typeid_expr.cpp
|
@ -1,35 +0,0 @@
|
|||||||
tests_dependencies = [
|
|
||||||
'//infer/lib/java/android:android',
|
|
||||||
'//dependencies/java/guava:guava',
|
|
||||||
'//dependencies/java/junit:hamcrest',
|
|
||||||
'//dependencies/java/jackson:jackson',
|
|
||||||
'//dependencies/java/jsr-305:jsr-305',
|
|
||||||
'//dependencies/java/junit:junit',
|
|
||||||
'//dependencies/java/opencsv:opencsv',
|
|
||||||
'//infer/tests/utils:utils',
|
|
||||||
]
|
|
||||||
|
|
||||||
cpp_infer_test_sources = glob(['*.java'])
|
|
||||||
cpp_infer_test_deps = []
|
|
||||||
for test_source in cpp_infer_test_sources:
|
|
||||||
target_name = test_source.replace("/", "_")[:-len(".java")]
|
|
||||||
cpp_infer_test_deps.append(target_name)
|
|
||||||
|
|
||||||
java_test(
|
|
||||||
name=target_name,
|
|
||||||
srcs=[test_source],
|
|
||||||
deps=tests_dependencies,
|
|
||||||
visibility=[
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
source='7',
|
|
||||||
target='7',
|
|
||||||
)
|
|
||||||
|
|
||||||
java_test(
|
|
||||||
name='infer',
|
|
||||||
deps=[':' + x for x in cpp_infer_test_deps],
|
|
||||||
visibility=[
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
)
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class BoxedPtrTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/errors/npe/boxed_ptr.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsNullDerefFunctionsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
String[] procedures = {
|
|
||||||
"smart_ptr_null_field_deref",
|
|
||||||
"smart_ptr_null_method_deref",
|
|
||||||
"smart_ptr_null_method_deref2",
|
|
||||||
"smart_ptr_result_method_null_deref",
|
|
||||||
};
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by 0 error",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NULL_DEREFERENCE,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class CBugsTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/errors/c_tests/c_bugs.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String MEMORY_LEAK = "MEMORY_LEAK";
|
|
||||||
|
|
||||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
|
||||||
|
|
||||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnMallocMemoryLeakThenMemoryLeakIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Using malloc without free should report memory leak",
|
|
||||||
inferResults,
|
|
||||||
contains(MEMORY_LEAK, FILE, "malloc_memory_leak_is_reported"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnMallocFreeWorksThenMemoryLeakIsNotFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Using malloc with free should not report memory leak",
|
|
||||||
inferResults,
|
|
||||||
doesNotContain(MEMORY_LEAK, FILE, "malloc_free_works"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnMallocFailGetsReportedThenNullDereferenceIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Not checking malloc result should report null dereference",
|
|
||||||
inferResults,
|
|
||||||
contains(NULL_DEREFERENCE, FILE, "malloc_fail_gets_reported"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnResourceLeakIsReportedThenResourceLeakIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain resource leak",
|
|
||||||
inferResults,
|
|
||||||
contains(RESOURCE_LEAK, FILE, "resource_leak_is_reported"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsFopenFcloseWorksThenResourceLeakIsNotFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should not contain resource leak",
|
|
||||||
inferResults,
|
|
||||||
doesNotContain(RESOURCE_LEAK, FILE, "fopen_fclose_works"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsMemcpySpecIsFoundThenDivBy0IsNotFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"when spec for memcpy is found, analysis should fail before div by 0",
|
|
||||||
inferResults,
|
|
||||||
doesNotContain(DIVIDE_BY_ZERO, FILE, "memcpy_spec_is_found"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnGetcCrashThenNullDereferenceIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Not checking malloc result should report null dereference",
|
|
||||||
inferResults,
|
|
||||||
contains(NULL_DEREFERENCE, FILE, "crash_getc"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnFgetcCrashThenNullDereferenceIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Not checking malloc result should report null dereference",
|
|
||||||
inferResults,
|
|
||||||
contains(NULL_DEREFERENCE, FILE, "crash_fgetc"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ClassTemplateTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0FunctionsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
String[] procedures = {
|
|
||||||
"choose1_div0",
|
|
||||||
"choose2_div0_extra",
|
|
||||||
"ExecStore<Choose2>_call_div",
|
|
||||||
};
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by 0 error",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ConstructorInitTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"f2_div0",
|
|
||||||
"f_div0",
|
|
||||||
"t_div0",
|
|
||||||
"delegate_constr_f_div0",
|
|
||||||
"delegate_constr_f2_div0",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ConstructorNewTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"constructor_1_arg_new_div0",
|
|
||||||
"constructor_3_args_new_div0",
|
|
||||||
"int_init_number",
|
|
||||||
"float_init_number",
|
|
||||||
"int_init_empty",
|
|
||||||
"int_init_empty_list",
|
|
||||||
"int_init_empty_list_new",
|
|
||||||
"int_init_nodes",
|
|
||||||
"constructor_nodes",
|
|
||||||
"int_array",
|
|
||||||
"int_array_init"
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
|
||||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ConstructorWithBodyTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnConstructorWithBodyDiv0ErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"test_div0",
|
|
||||||
"test_div0_default_constructor",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain null pointer dereference error",
|
|
||||||
inferResults,
|
|
||||||
contains(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
"test_div0"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain null pointer dereference error",
|
|
||||||
inferResults,
|
|
||||||
contains(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
"test_div0_default_constructor"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnConstructorWithBodyDiv1ErrorIsNotFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should not contain null pointer dereference error",
|
|
||||||
inferResults,
|
|
||||||
doesNotContain(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
"test_div1"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ConversionOperatorTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"branch_div0",
|
|
||||||
"y_branch_div0",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class CopyMoveConstructorTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"copyX_div0",
|
|
||||||
"moveX_div0",
|
|
||||||
"copyY_div0",
|
|
||||||
"moveY_div0",
|
|
||||||
"moveY_moveY_copyY_div0",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class DeprecatedHackTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/attributes/deprecated_hack.cpp";
|
|
||||||
|
|
||||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnNullDerefThenNullDereferenceIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferC(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"derefFirstArg_null_deref",
|
|
||||||
"derefFirstArg2_null_deref",
|
|
||||||
"derefFirstArg3_null_deref",
|
|
||||||
"getPtr_null_deref1",
|
|
||||||
"getPtr_null_deref2",
|
|
||||||
"operator_star_null_deref1",
|
|
||||||
"operator_star_null_deref2",
|
|
||||||
"getRef_null_deref1",
|
|
||||||
"getRef_null_deref2",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by zero error",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NULL_DEREFERENCE,
|
|
||||||
SOURCE_FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class DerefAfterMoveTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/errors/smart_ptr/deref_after_move_example.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOngetPersonAgeNPEIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferC(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"deref_after_move_crash",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected npe",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NULL_DEREFERENCE,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class DynamicCastTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
public static final String CLASS_CAST_EXCEPTION = "CLASS_CAST_EXCEPTION";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnWrongCastOfArgumentPointerThenDivideByZeroIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by zero, it shows a wrong cast to pointer to class",
|
|
||||||
inferResults,
|
|
||||||
contains(DIVIDE_BY_ZERO, FILE, "wrongCastOfArgumentPointer"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnWrongPointerCastThenDivideByZeroIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by zero, it shows a wrong cast to pointer to class",
|
|
||||||
inferResults,
|
|
||||||
contains(DIVIDE_BY_ZERO, FILE, "wrongPointerCast"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnRightPointerCastThenDivideByZeroIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by zero, it shows a correct cast to pointer to class",
|
|
||||||
inferResults,
|
|
||||||
contains(DIVIDE_BY_ZERO, FILE, "rightPointerCast"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnRightReferenceCastThenClassCastExceptionIsNotFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should not contain class cast exception",
|
|
||||||
inferResults,
|
|
||||||
doesNotContain(CLASS_CAST_EXCEPTION, FILE, "rightReferenceCast"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnWrongReferenceCastThenClassCastExceptionIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain class cast exception",
|
|
||||||
inferResults,
|
|
||||||
contains(CLASS_CAST_EXCEPTION, FILE, "wrongReferenceCast"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnWrongReferenceCastNotAssignedThenClassCastExceptionIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain class cast exception",
|
|
||||||
inferResults,
|
|
||||||
contains(CLASS_CAST_EXCEPTION, FILE, "wrongReferenceCastNotAssigned"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnWrongCastOfArgumentReferenceThenClassCastExceptionIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain class cast exception",
|
|
||||||
inferResults,
|
|
||||||
contains(CLASS_CAST_EXCEPTION, FILE, "wrongCastOfArgumentReference"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class ExceptionsTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/exceptions/Exceptions.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0FunctionsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
String[] procedures = { "call_deref_with_null" };
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should not contain " + NULL_DEREFERENCE,
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
NULL_DEREFERENCE,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2013 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class FallthroughTest {
|
|
||||||
|
|
||||||
public static final String SOURCE_FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/attributes/clang_fallthrough.cpp";
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, SOURCE_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDivideByZeroThenDivideByZeroIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferC(inferCmd);
|
|
||||||
String[] procedures = {"test_fallthrough"};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by zero error",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
SOURCE_FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class FunctionTemplateTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0FunctionsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
String[] procedures = {
|
|
||||||
"div0_get_val",
|
|
||||||
"div0_create_and_get_val",
|
|
||||||
"createAndDiv<X3>",
|
|
||||||
};
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
assertThat(
|
|
||||||
"Results should contain divide by 0 error",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class IncludeHeaderNoTemplTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/include_header/include_only.cpp";
|
|
||||||
public static final String HEADER =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/include_header/header.h";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommandIncludeHeaders(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"A_div0",
|
|
||||||
"div0_fun",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
HEADER,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class IncludeHeaderTemplTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp";
|
|
||||||
public static final String HEADER =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/include_header/header.h";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommandIncludeHeaders(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"A_div0",
|
|
||||||
"B<int>_div0",
|
|
||||||
"B<A>_div0",
|
|
||||||
"div0_fun",
|
|
||||||
"div0_templ<int>",
|
|
||||||
"div0_templ<A>",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
HEADER,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 - 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endtoend.cpp.infer;
|
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import utils.DebuggableTemporaryFolder;
|
|
||||||
import utils.InferException;
|
|
||||||
import utils.InferResults;
|
|
||||||
import utils.InferRunner;
|
|
||||||
|
|
||||||
public class InheritanceFieldTest {
|
|
||||||
|
|
||||||
public static final String FILE =
|
|
||||||
"infer/tests/codetoanalyze/cpp/frontend/types/inheritance_field.cpp";
|
|
||||||
|
|
||||||
private static ImmutableList<String> inferCmd;
|
|
||||||
|
|
||||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static DebuggableTemporaryFolder folder =
|
|
||||||
new DebuggableTemporaryFolder();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void runInfer() throws InterruptedException, IOException {
|
|
||||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
|
||||||
throws InterruptedException, IOException, InferException {
|
|
||||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
|
||||||
String[] procedures = {
|
|
||||||
"div0_b1",
|
|
||||||
"div0_b2",
|
|
||||||
"div0_s",
|
|
||||||
"div0_cast",
|
|
||||||
"div0_cast_ref",
|
|
||||||
"div0_b1_s",
|
|
||||||
"div0_s_b1",
|
|
||||||
};
|
|
||||||
assertThat(
|
|
||||||
"Results should contain the expected divide by zero",
|
|
||||||
inferResults,
|
|
||||||
containsExactly(
|
|
||||||
DIVIDE_BY_ZERO,
|
|
||||||
FILE,
|
|
||||||
procedures
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue