From 0b7ea202db2f2fdf4add78eb7c462505edcc3455 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Wed, 7 Sep 2016 01:47:27 -0700 Subject: [PATCH] Convert infer c++ tests to new format Reviewed By: jberdine Differential Revision: D3803636 fbshipit-source-id: 5cc201d --- Makefile | 4 + infer/src/IR/AttributesTable.re | 18 ++ infer/src/IR/AttributesTable.rei | 4 + infer/src/IR/Cg.re | 8 + infer/src/IR/Cg.rei | 4 + infer/src/backend/InferAnalyze.re | 2 +- infer/src/backend/config.ml | 11 +- infer/src/backend/config.mli | 2 +- infer/src/backend/exe_env.ml | 37 +-- infer/src/backend/exe_env.mli | 2 +- infer/src/backend/printer.ml | 11 +- infer/tests/BUCK | 1 - infer/tests/codetoanalyze/cpp/errors/Makefile | 58 ++++ .../cpp/errors/attributes/deprecated_hack.cpp | 1 + .../errors/conditional/lvalue_conditional.cpp | 1 + .../errors/constructors/constructor_init.cpp | 1 + .../errors/constructors/constructor_new.cpp | 1 + .../constructors/constructor_with_body.cpp | 1 + .../constructors/copy_move_constructor.cpp | 1 + .../cpp/errors/constructors/temp_object.cpp | 1 + .../cpp/errors/exceptions/Exceptions.cpp | 1 + .../cpp/errors/include_header/header.h | 27 ++ .../cpp/errors/include_header/header2.h | 27 ++ .../errors/include_header/include_templ.cpp | 25 ++ .../tests/codetoanalyze/cpp/errors/issues.exp | 272 ++++++++++++++++++ .../cpp/errors/lambda/lambda1.cpp | 1 + .../cpp/errors/memory_leaks/object_leak.cpp | 5 +- .../errors/methods/conversion_operator.cpp | 1 + .../cpp/errors/methods/static.cpp | 1 + .../cpp/errors/methods/virtual_methods.cpp | 1 + .../codetoanalyze/cpp/errors/models/move.cpp | 3 + .../cpp/errors/namespace/function.cpp | 1 + .../cpp/errors/namespace/global_variable.cpp | 1 + .../nestedoperators/var_decl_inside_if.cpp | 1 + .../cpp/errors/npe/boxed_ptr.cpp | 3 + .../cpp/errors/npe/npe_added_to_b1.cpp | 3 + .../cpp/errors/npe/object_deref.cpp | 3 + .../cpp/errors/reference/reference_field.cpp | 1 + .../errors/reference/reference_struct_e2e.cpp | 1 + .../errors/reference/reference_type_e2e.cpp | 1 + .../cpp/errors/reference/temporary_lvalue.cpp | 1 + .../cpp/errors/resource_leaks/raii.cpp | 2 - .../smart_ptr/deref_after_move_example.cpp | 3 + .../smart_ptr/shared_ptr_constructors.cpp | 3 + .../cpp/errors/smart_ptr/shared_ptr_deref.cpp | 3 + .../cpp/errors/smart_ptr/unique_ptr_deref.cpp | 3 + .../errors/subtyping/cast_with_enforce.cpp | 3 + .../subtyping/cast_with_enforce.cpp.dot | 72 ++--- .../cpp/errors/subtyping/dynamic_cast.cpp | 3 + .../templates/class_template_instantiate.cpp | 1 + .../cpp/errors/templates/function.cpp | 1 + .../cpp/errors/templates/function_pack.cpp | 1 + .../cpp/errors/templates/method.cpp | 1 + .../cpp/errors/types/inheritance_field.cpp | 1 + .../cpp/errors/types/operator_overload.cpp | 1 + .../cpp/errors/types/return_struct.cpp | 1 + .../errors/types/struct_forward_declare.cpp | 1 + .../cpp/errors/types/struct_pass_by_value.cpp | 1 + .../cpp/errors/types/typeid_expr.cpp | 1 + .../frontend/constructors/constructor_new.cpp | 3 + .../constructors/constructor_new.cpp.dot | 186 ++++++------ .../constructors/constructor_with_body.cpp | 3 + .../constructor_with_body.cpp.dot | 52 ++-- .../constructors/copy_move_constructor.cpp | 3 + .../copy_move_constructor.cpp.dot | 130 ++++----- .../cpp/frontend/constructors/temp_object.cpp | 3 + .../frontend/constructors/temp_object.cpp.dot | 86 +++--- .../frontend/methods/conversion_operator.cpp | 3 + .../methods/conversion_operator.cpp.dot | 114 ++++---- .../frontend/reference/reference_field.cpp | 3 + .../reference/reference_field.cpp.dot | 238 +++++++-------- .../cpp/frontend/templates/function.cpp | 3 + .../cpp/frontend/templates/function.cpp.dot | 98 +++---- .../cpp/frontend/templates/method.cpp | 3 + .../cpp/frontend/templates/method.cpp.dot | 150 +++++----- .../cpp/frontend/types/return_struct.cpp | 3 + .../cpp/frontend/types/return_struct.cpp.dot | 70 ++--- .../frontend/types/struct_forward_declare.cpp | 3 + .../types/struct_forward_declare.cpp.dot | 80 +++--- .../frontend/types/struct_pass_by_value.cpp | 3 + .../types/struct_pass_by_value.cpp.dot | 94 +++--- infer/tests/endtoend/BUCK | 11 - infer/tests/endtoend/cpp/infer/BUCK | 35 --- .../endtoend/cpp/infer/BoxedPtrTest.java | 67 ----- infer/tests/endtoend/cpp/infer/CBugsTest.java | 134 --------- .../endtoend/cpp/infer/ClassTemplateTest.java | 66 ----- .../cpp/infer/ConstructorInitTest.java | 67 ----- .../cpp/infer/ConstructorNewTest.java | 73 ----- .../cpp/infer/ConstructorWithBodyTest.java | 89 ------ .../cpp/infer/ConversionOperatorTest.java | 64 ----- .../cpp/infer/CopyMoveConstructorTest.java | 67 ----- .../cpp/infer/DeprecatedHackTest.java | 72 ----- .../cpp/infer/DerefAfterMoveTest.java | 63 ---- .../endtoend/cpp/infer/DynamicCastTest.java | 120 -------- .../endtoend/cpp/infer/ExceptionsTest.java | 61 ---- .../endtoend/cpp/infer/FallthroughTest.java | 62 ---- .../cpp/infer/FunctionTemplateTest.java | 66 ----- .../cpp/infer/IncludeHeaderNoTemplTest.java | 66 ----- .../cpp/infer/IncludeHeaderTemplTest.java | 70 ----- .../cpp/infer/InheritanceFieldTest.java | 69 ----- .../cpp/infer/LValueConditionalTest.java | 66 ----- .../tests/endtoend/cpp/infer/LambdaTest.java | 67 ----- .../cpp/infer/MemoryLeakArrayTest.java | 62 ---- .../cpp/infer/MemoryLeakCppBucketTest.java | 62 ---- .../cpp/infer/MemoryLeakRaiiTest.java | 62 ---- .../endtoend/cpp/infer/MemoryLeakTest.java | 62 ---- .../cpp/infer/MethodTemplateTest.java | 66 ----- .../endtoend/cpp/infer/MinMaxNumericTest.java | 66 ----- .../endtoend/cpp/infer/MoveModelTest.java | 65 ----- .../endtoend/cpp/infer/NPEAddedToB1Test.java | 66 ----- .../cpp/infer/NPEWhenMethodCallTest.java | 63 ---- .../cpp/infer/NamespaceFunctionTest.java | 64 ----- .../infer/NamespaceGlobalVariableTest.java | 65 ----- .../cpp/infer/NestedCPPOperatorsTest.java | 81 ------ .../cpp/infer/NoNPEAfterDynamicCastTest.java | 63 ---- .../cpp/infer/NullReturnedByMethodTest.java | 77 ----- .../cpp/infer/ObjectDereferenceTest.java | 77 ----- .../cpp/infer/OperatorOverloadTest.java | 67 ----- .../cpp/infer/ReferenceFieldTest.java | 74 ----- .../cpp/infer/ReferenceStructTest.java | 70 ----- .../endtoend/cpp/infer/ReferenceTypeTest.java | 69 ----- .../cpp/infer/ResourceLeakRaiiTest.java | 62 ---- .../endtoend/cpp/infer/ReturnStructTest.java | 65 ----- .../cpp/infer/SharedPtrConstructorsTest.java | 73 ----- .../cpp/infer/SharedPtrDerefTest.java | 73 ----- .../SkipFunctionWithConstFormalsTest.java | 68 ----- .../endtoend/cpp/infer/StaticMethodTest.java | 64 ----- .../cpp/infer/StructForwardDeclareTest.java | 67 ----- .../cpp/infer/StructPassByValueTest.java | 66 ----- .../cpp/infer/SubtypingCheckTest.java | 63 ---- .../endtoend/cpp/infer/TempObjectTest.java | 68 ----- .../cpp/infer/TemplateFunctionPackTest.java | 68 ----- .../cpp/infer/TemporaryLValueTest.java | 65 ----- .../endtoend/cpp/infer/ThisNotNullTest.java | 63 ---- .../endtoend/cpp/infer/ThrowAsAssertTest.java | 63 ---- .../endtoend/cpp/infer/TypeIdExprTest.java | 67 ----- .../cpp/infer/UniquePtrDerefTest.java | 75 ----- .../cpp/infer/VectorEmptyAccessTest.java | 74 ----- .../cpp/infer/VirtualMethodsTest.java | 63 ---- 139 files changed, 1257 insertions(+), 4668 deletions(-) create mode 100644 infer/tests/codetoanalyze/cpp/errors/Makefile create mode 120000 infer/tests/codetoanalyze/cpp/errors/attributes/deprecated_hack.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/conditional/lvalue_conditional.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/constructors/constructor_init.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/constructors/constructor_new.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/constructors/constructor_with_body.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/constructors/copy_move_constructor.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/constructors/temp_object.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/exceptions/Exceptions.cpp create mode 100644 infer/tests/codetoanalyze/cpp/errors/include_header/header.h create mode 100644 infer/tests/codetoanalyze/cpp/errors/include_header/header2.h create mode 100644 infer/tests/codetoanalyze/cpp/errors/include_header/include_templ.cpp create mode 100644 infer/tests/codetoanalyze/cpp/errors/issues.exp create mode 120000 infer/tests/codetoanalyze/cpp/errors/lambda/lambda1.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/methods/conversion_operator.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/methods/static.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/methods/virtual_methods.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/namespace/function.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/namespace/global_variable.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/nestedoperators/var_decl_inside_if.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/reference/reference_field.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/reference/reference_struct_e2e.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/reference/reference_type_e2e.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/reference/temporary_lvalue.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/templates/class_template_instantiate.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/templates/function.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/templates/function_pack.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/templates/method.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/inheritance_field.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/operator_overload.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/return_struct.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/struct_forward_declare.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/struct_pass_by_value.cpp create mode 120000 infer/tests/codetoanalyze/cpp/errors/types/typeid_expr.cpp delete mode 100644 infer/tests/endtoend/cpp/infer/BUCK delete mode 100644 infer/tests/endtoend/cpp/infer/BoxedPtrTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/CBugsTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ClassTemplateTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ConstructorInitTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ConstructorNewTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ConstructorWithBodyTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ConversionOperatorTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/CopyMoveConstructorTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/DeprecatedHackTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/DerefAfterMoveTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/DynamicCastTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ExceptionsTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/FallthroughTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/FunctionTemplateTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/IncludeHeaderNoTemplTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/IncludeHeaderTemplTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/InheritanceFieldTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/LValueConditionalTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/LambdaTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MemoryLeakArrayTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MemoryLeakCppBucketTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MemoryLeakRaiiTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MemoryLeakTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MethodTemplateTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MinMaxNumericTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/MoveModelTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NPEAddedToB1Test.java delete mode 100644 infer/tests/endtoend/cpp/infer/NPEWhenMethodCallTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NamespaceFunctionTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NamespaceGlobalVariableTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NestedCPPOperatorsTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NoNPEAfterDynamicCastTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/NullReturnedByMethodTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ObjectDereferenceTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/OperatorOverloadTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ReferenceFieldTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ReferenceStructTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ReferenceTypeTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ResourceLeakRaiiTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ReturnStructTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/SharedPtrConstructorsTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/SharedPtrDerefTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/SkipFunctionWithConstFormalsTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/StaticMethodTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/StructForwardDeclareTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/StructPassByValueTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/SubtypingCheckTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/TempObjectTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/TemplateFunctionPackTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/TemporaryLValueTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ThisNotNullTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/ThrowAsAssertTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/TypeIdExprTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/UniquePtrDerefTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/VectorEmptyAccessTest.java delete mode 100644 infer/tests/endtoend/cpp/infer/VirtualMethodsTest.java diff --git a/Makefile b/Makefile index 2d9f198b0..c8d579c87 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ DIRECT_TESTS= TARGETS_TO_TEST= ifeq ($(BUILD_C_ANALYZERS),yes) TARGETS_TO_TEST += c cpp +DIRECT_TESTS += cpp_infer_test endif ifeq ($(BUILD_JAVA_ANALYZERS),yes) TARGETS_TO_TEST += java @@ -97,6 +98,9 @@ endif ocaml_unit_test: test_this_build $(TEST_BUILD_DIR)/unit/inferunit.byte +cpp_infer_test: + make -C ./infer/tests/codetoanalyze/cpp/errors test + java_checkers_test: make -C ./infer/tests/codetoanalyze/java/checkers test diff --git a/infer/src/IR/AttributesTable.re b/infer/src/IR/AttributesTable.re index c97966f59..50c599433 100644 --- a/infer/src/IR/AttributesTable.re +++ b/infer/src/IR/AttributesTable.re @@ -191,3 +191,21 @@ let stats () => { Config.developer_mode ? Some (Marshal.data_size (Marshal.to_bytes attr_tbl []) 0 / 1024) : None; {num_bindings, num_buckets, max_bucket_length, serialized_size_kb} }; + +/* Find the file where the procedure is defined according to the attributes, + if a cfg for that file exist. */ +let file_defining_procedure pname => + switch (load_attributes pname) { + | None => None + | Some proc_attributes => + let loc = proc_attributes.ProcAttributes.loc; + let source_file = loc.file; + let source_dir = DB.source_dir_from_source_file source_file; + let cfg_fname = DB.source_dir_get_internal_file source_dir ".cfg"; + let cfg_fname_exists = Sys.file_exists (DB.filename_to_string cfg_fname); + if cfg_fname_exists { + Some source_file + } else { + None + } + }; diff --git a/infer/src/IR/AttributesTable.rei b/infer/src/IR/AttributesTable.rei index 4f5bac397..5b13a45bc 100644 --- a/infer/src/IR/AttributesTable.rei +++ b/infer/src/IR/AttributesTable.rei @@ -41,6 +41,10 @@ let get_correct_type_from_objc_class_name: Typename.t => option Typ.t; /** Returns true if the method is defined as a C++ model */ let pname_is_cpp_model: Procname.t => bool; +/* Find the file where the procedure is defined according to the attributes, + if a cfg for that file exist. */ +let file_defining_procedure: Procname.t => option DB.source_file; + let is_whitelisted_cpp_method: string => bool; type t; diff --git a/infer/src/IR/Cg.re b/infer/src/IR/Cg.re index b20f7fc84..dcd1efcf8 100644 --- a/infer/src/IR/Cg.re +++ b/infer/src/IR/Cg.re @@ -73,6 +73,14 @@ let add_node g n defined::defined => Procname.Hash.add g.node_map n info }; +let remove_node_defined g n => + try { + let info = Procname.Hash.find g.node_map n; + info.defined = false + } { + | Not_found => () + }; + let add_defined_node g n => add_node g n defined::true; diff --git a/infer/src/IR/Cg.rei b/infer/src/IR/Cg.rei index fd79c1e24..84f494ca2 100644 --- a/infer/src/IR/Cg.rei +++ b/infer/src/IR/Cg.rei @@ -119,6 +119,10 @@ let load_from_file: DB.filename => option t; let node_defined: t => Procname.t => bool; +/** Remove the defined flag from a node, if it exists. */ +let remove_node_defined: t => Procname.t => unit; + + /** Print the current call graph as a dotty file. If the filename is [None], use the current file dir inside the DB dir. */ let save_call_graph_dotty: option DB.filename => (Procname.t => list 'a) => t => unit; diff --git a/infer/src/backend/InferAnalyze.re b/infer/src/backend/InferAnalyze.re index 6a76494a7..8b3f1e2be 100644 --- a/infer/src/backend/InferAnalyze.re +++ b/infer/src/backend/InferAnalyze.re @@ -54,7 +54,7 @@ let analyze_exe_env exe_env => { /** Create an exe_env from a cluster. */ let exe_env_from_cluster cluster => { let _exe_env = Exe_env.create (); - ignore (Exe_env.add_cg _exe_env cluster); + Exe_env.add_cg _exe_env cluster; Exe_env.freeze _exe_env }; diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 4eb163f97..a5f6994c7 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -619,6 +619,11 @@ and changed_files_index = CLOpt.mk_string_opt ~long:"changed-files-index" ~exes:CLOpt.[Toplevel] ~meta:"file" "Specify the file containing the list of files from which reactive analysis should start" +and check_duplicate_symbols = + CLOpt.mk_bool ~long:"check-duplicate-symbols" + ~exes:CLOpt.[Analyze] + "Check if a symbol with the same name is defined in more than one file." + and clang_include_to_override = CLOpt.mk_string_opt ~long:"clang-include-to-override" ~meta:"dir" "Use this option in the uncommon case where the normal compilation process overrides the \ @@ -639,10 +644,6 @@ and cluster = CLOpt.mk_string_opt ~deprecated:["cluster"] ~long:"cluster" ~meta:"file" "Specify a .cluster file to be analyzed" -and code_query = - CLOpt.mk_string_opt ~deprecated:["codequery"] ~long:"code-query" - ~meta:"query" "Execute the code query" - (** Continue the capture for reactive mode: If a procedure was changed beforehand, keep the changed marking. *) and continue = @@ -1360,6 +1361,7 @@ and bugs_txt = !bugs_txt and bugs_xml = !bugs_xml and changed_files_index = !changed_files_index and calls_csv = !calls_csv +and check_duplicate_symbols = !check_duplicate_symbols and checkers = !checkers (** should the checkers be run? *) @@ -1367,7 +1369,6 @@ and checkers_enabled = not (!eradicate || !crashcontext || !quandary) and clang_include_to_override = !clang_include_to_override and clang_lang = !clang_lang and cluster_cmdline = !cluster -and code_query = !code_query and continue_capture = !continue and copy_propagation = !copy_propagation and crashcontext = !crashcontext diff --git a/infer/src/backend/config.mli b/infer/src/backend/config.mli index 17bfa105a..939850e91 100644 --- a/infer/src/backend/config.mli +++ b/infer/src/backend/config.mli @@ -164,12 +164,12 @@ val bugs_txt : outfile option val bugs_xml : outfile option val changed_files_index : string option val calls_csv : outfile option +val check_duplicate_symbols : bool val checkers : bool val checkers_enabled : bool val clang_include_to_override : string option val clang_lang : clang_lang val cluster_cmdline : string option -val code_query : string option val continue_capture : bool val copy_propagation : bool val crashcontext : bool diff --git a/infer/src/backend/exe_env.ml b/infer/src/backend/exe_env.ml index 1474c2cef..0481fe420 100644 --- a/infer/src/backend/exe_env.ml +++ b/infer/src/backend/exe_env.ml @@ -73,38 +73,31 @@ let add_cg (exe_env: t) (source_dir : DB.source_dir) = let cg_fname = DB.source_dir_get_internal_file source_dir ".cg" in match Cg.load_from_file cg_fname with | None -> - L.stderr "cannot load %s@." (DB.filename_to_string cg_fname); - None + L.stderr "cannot load %s@." (DB.filename_to_string cg_fname) | Some cg -> let source = Cg.get_source cg in exe_env.source_files <- DB.SourceFileSet.add source exe_env.source_files; let nLOC = Cg.get_nLOC cg in - Cg.extend exe_env.cg cg; let file_data = new_file_data source nLOC cg_fname in let defined_procs = Cg.get_defined_nodes cg in - (* Find the file where `pname` is defined according to the attributes, - if a cfg for that file exist. *) - let defined_in_according_to_attributes pname = - match AttributesTable.load_attributes pname with - | None -> - None - | Some proc_attributes -> - let loc = proc_attributes.ProcAttributes.loc in - let source_file = loc.Location.file in - let source_dir = DB.source_dir_from_source_file source_file in - let cfg_fname = DB.source_dir_get_internal_file source_dir ".cfg" in - let cfg_fname_exists = Sys.file_exists (DB.filename_to_string cfg_fname) in - if cfg_fname_exists - then Some source_file - else None in - IList.iter (fun pname -> - if (defined_in_according_to_attributes pname = None) - then Procname.Hash.replace exe_env.proc_map pname file_data) + (match AttributesTable.file_defining_procedure pname with + | None -> + Procname.Hash.replace exe_env.proc_map pname file_data + | Some source_defined -> + let multiply_defined = DB.source_file_compare source source_defined <> 0 in + if multiply_defined then Cg.remove_node_defined cg pname; + if Config.check_duplicate_symbols && + multiply_defined then + L.stderr "@.DUPLICATE_SYMBOLS source: %s source_defined:%s pname:%a@." + (DB.source_file_to_string source) + (DB.source_file_to_string source_defined) + Procname.pp pname + )) defined_procs; - Some cg + Cg.extend exe_env.cg cg (** get the global call graph *) let get_cg exe_env = diff --git a/infer/src/backend/exe_env.mli b/infer/src/backend/exe_env.mli index 7e2a1d553..6dd7a3ef6 100644 --- a/infer/src/backend/exe_env.mli +++ b/infer/src/backend/exe_env.mli @@ -26,7 +26,7 @@ val create : unit -> initial (** add call graph from the source dir in the spec db, with relative tenv and cfg, to the execution environment *) -val add_cg : initial -> DB.source_dir -> Cg.t option +val add_cg : initial -> DB.source_dir -> unit (** get the global call graph *) val get_cg : t -> Cg.t diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 604bb8d5d..a5bc9f22f 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -458,10 +458,15 @@ let write_html_file linereader filename cfg = let (fd, fmt) = Io_infer.Html.create DB.Results_dir.Abs_source_dir [".."; fname_encoding] in let do_proc proof_cover table_nodes_at_linenum global_err_log proc_name proc_desc = - (* add the err_log of this proc to [global_err_log] *) let proc_loc = (Cfg.Procdesc.get_loc proc_desc) in - if Cfg.Procdesc.is_defined proc_desc && - (DB.source_file_equal proc_loc.Location.file !DB.current_source) then + let process_proc = + Cfg.Procdesc.is_defined proc_desc && + DB.source_file_equal proc_loc.Location.file !DB.current_source && + match AttributesTable.file_defining_procedure proc_name with + | None -> true + | Some source_file -> + DB.source_file_equal source_file (Cfg.Procdesc.get_loc proc_desc).file in + if process_proc then begin IList.iter (process_node table_nodes_at_linenum) (Cfg.Procdesc.get_nodes proc_desc); match Specs.get_summary proc_name with diff --git a/infer/tests/BUCK b/infer/tests/BUCK index 054f4b751..e0b2ccf0c 100644 --- a/infer/tests/BUCK +++ b/infer/tests/BUCK @@ -9,7 +9,6 @@ java_test( java_test( name='cpp_tests', deps=[ - '//infer/tests/endtoend:cpp_endtoend_tests', '//infer/tests/frontend:cpp_frontend_tests', ], ) diff --git a/infer/tests/codetoanalyze/cpp/errors/Makefile b/infer/tests/codetoanalyze/cpp/errors/Makefile new file mode 100644 index 000000000..be7c92e84 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/Makefile @@ -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 diff --git a/infer/tests/codetoanalyze/cpp/errors/attributes/deprecated_hack.cpp b/infer/tests/codetoanalyze/cpp/errors/attributes/deprecated_hack.cpp new file mode 120000 index 000000000..e4acff852 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/attributes/deprecated_hack.cpp @@ -0,0 +1 @@ +../../frontend/attributes/deprecated_hack.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/conditional/lvalue_conditional.cpp b/infer/tests/codetoanalyze/cpp/errors/conditional/lvalue_conditional.cpp new file mode 120000 index 000000000..55e14d880 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/conditional/lvalue_conditional.cpp @@ -0,0 +1 @@ +../../frontend/conditional/lvalue_conditional.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_init.cpp b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_init.cpp new file mode 120000 index 000000000..22e5c28a0 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_init.cpp @@ -0,0 +1 @@ +../../frontend/constructors/constructor_init.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_new.cpp b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_new.cpp new file mode 120000 index 000000000..7240be4cb --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_new.cpp @@ -0,0 +1 @@ +../../frontend/constructors/constructor_new.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_with_body.cpp b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_with_body.cpp new file mode 120000 index 000000000..a2009c75e --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/constructors/constructor_with_body.cpp @@ -0,0 +1 @@ +../../frontend/constructors/constructor_with_body.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/constructors/copy_move_constructor.cpp b/infer/tests/codetoanalyze/cpp/errors/constructors/copy_move_constructor.cpp new file mode 120000 index 000000000..2ff1b5e24 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/constructors/copy_move_constructor.cpp @@ -0,0 +1 @@ +../../frontend/constructors/copy_move_constructor.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/constructors/temp_object.cpp b/infer/tests/codetoanalyze/cpp/errors/constructors/temp_object.cpp new file mode 120000 index 000000000..2efc53a49 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/constructors/temp_object.cpp @@ -0,0 +1 @@ +../../frontend/constructors/temp_object.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/exceptions/Exceptions.cpp b/infer/tests/codetoanalyze/cpp/errors/exceptions/Exceptions.cpp new file mode 120000 index 000000000..e0717eb9b --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/exceptions/Exceptions.cpp @@ -0,0 +1 @@ +../../frontend/exceptions/Exceptions.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/include_header/header.h b/infer/tests/codetoanalyze/cpp/errors/include_header/header.h new file mode 100644 index 000000000..8fab8fa54 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/include_header/header.h @@ -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 +struct B { + int div0() { return 1 / 0; } +}; + +int div0_fun() { return 1 / 0; } + +template +int div0_templ() { + return 1 / 0; +} +} diff --git a/infer/tests/codetoanalyze/cpp/errors/include_header/header2.h b/infer/tests/codetoanalyze/cpp/errors/include_header/header2.h new file mode 100644 index 000000000..c07b7eb8e --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/include_header/header2.h @@ -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 +struct B { + int div0() { return 1 / 0; } +}; + +int div0_fun() { return 1 / 0; } + +template +int div0_templ() { + return 1 / 0; +} +} diff --git a/infer/tests/codetoanalyze/cpp/errors/include_header/include_templ.cpp b/infer/tests/codetoanalyze/cpp/errors/include_header/include_templ.cpp new file mode 100644 index 000000000..29cf6b6c6 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/include_header/include_templ.cpp @@ -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 b; + b.div0(); +} + +void div0_B_A() { + B b; + b.div0(); +} + +void div0_templ_int() { div0_templ(); } + +int div0_templ_A() { div0_templ(); } diff --git a/infer/tests/codetoanalyze/cpp/errors/issues.exp b/infer/tests/codetoanalyze/cpp/errors/issues.exp new file mode 100644 index 000000000..d0354be09 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/issues.exp @@ -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_div0, 0, DIVIDE_BY_ZERO +include_header/header2.h, header2::B_div0, 0, DIVIDE_BY_ZERO +include_header/header2.h, header2::div0_templ, 1, DIVIDE_BY_ZERO +include_header/header2.h, header2::div0_templ, 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_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, 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, 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 diff --git a/infer/tests/codetoanalyze/cpp/errors/lambda/lambda1.cpp b/infer/tests/codetoanalyze/cpp/errors/lambda/lambda1.cpp new file mode 120000 index 000000000..9fc2d94a0 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/lambda/lambda1.cpp @@ -0,0 +1 @@ +../../frontend/lambda/lambda1.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp b/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp index bdd11fb81..c505a603a 100644 --- a/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp @@ -15,7 +15,4 @@ class Rectangle { int area(void) { return width * height; } }; -int main() { - Rectangle* bar = new Rectangle(5, 6); - return 0; -} +void object_leak() { Rectangle* bar = new Rectangle(5, 6); } diff --git a/infer/tests/codetoanalyze/cpp/errors/methods/conversion_operator.cpp b/infer/tests/codetoanalyze/cpp/errors/methods/conversion_operator.cpp new file mode 120000 index 000000000..554401a75 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/methods/conversion_operator.cpp @@ -0,0 +1 @@ +../../frontend/methods/conversion_operator.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/methods/static.cpp b/infer/tests/codetoanalyze/cpp/errors/methods/static.cpp new file mode 120000 index 000000000..399618add --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/methods/static.cpp @@ -0,0 +1 @@ +../../frontend/methods/static.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/methods/virtual_methods.cpp b/infer/tests/codetoanalyze/cpp/errors/methods/virtual_methods.cpp new file mode 120000 index 000000000..fd2f309ca --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/methods/virtual_methods.cpp @@ -0,0 +1 @@ +../../frontend/methods/virtual_methods.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/models/move.cpp b/infer/tests/codetoanalyze/cpp/errors/models/move.cpp index 4f7900d6f..23d1dc926 100644 --- a/infer/tests/codetoanalyze/cpp/errors/models/move.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/models/move.cpp @@ -9,6 +9,8 @@ #include +namespace move { + struct X { X() : f(1) {} X(X&& x) { @@ -41,3 +43,4 @@ int div0_moved_to() { X x2 = std::move(x1); return 1 / (x2.f - 1); } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/namespace/function.cpp b/infer/tests/codetoanalyze/cpp/errors/namespace/function.cpp new file mode 120000 index 000000000..0ab82d9d7 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/namespace/function.cpp @@ -0,0 +1 @@ +../../frontend/namespace/function.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/namespace/global_variable.cpp b/infer/tests/codetoanalyze/cpp/errors/namespace/global_variable.cpp new file mode 120000 index 000000000..07858ddfc --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/namespace/global_variable.cpp @@ -0,0 +1 @@ +../../frontend/namespace/global_variable.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/nestedoperators/var_decl_inside_if.cpp b/infer/tests/codetoanalyze/cpp/errors/nestedoperators/var_decl_inside_if.cpp new file mode 120000 index 000000000..85910270c --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/nestedoperators/var_decl_inside_if.cpp @@ -0,0 +1 @@ +../../frontend/nestedoperators/var_decl_inside_if.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/npe/boxed_ptr.cpp b/infer/tests/codetoanalyze/cpp/errors/npe/boxed_ptr.cpp index 77bcedba9..94822a618 100644 --- a/infer/tests/codetoanalyze/cpp/errors/npe/boxed_ptr.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/npe/boxed_ptr.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace boxed_ptr { + struct X { int field; int* getPtr() { return &field; } @@ -62,3 +64,4 @@ void smart_ptr_result_method_ok_deref() { p.data = &x; int f = *(p.get()->getPtr()); } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp b/infer/tests/codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp index 3e327d9e7..47bf81067 100644 --- a/infer/tests/codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp @@ -9,6 +9,8 @@ #include +namespace npe_added_to_b1 { + int deref_ref(std::shared_ptr& p) { return *p; } int causes_npe() { @@ -28,3 +30,4 @@ int causes_npe_person() { Person p; return deref_person(p); } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp b/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp index 4861ef1af..153de0086 100644 --- a/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace object_deref { + class X { public: int field; @@ -26,3 +28,4 @@ void derefNonNullField() { X* x = getNonNull(); int c = x->field; } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/reference/reference_field.cpp b/infer/tests/codetoanalyze/cpp/errors/reference/reference_field.cpp new file mode 120000 index 000000000..98eadf454 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/reference/reference_field.cpp @@ -0,0 +1 @@ +../../frontend/reference/reference_field.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/reference/reference_struct_e2e.cpp b/infer/tests/codetoanalyze/cpp/errors/reference/reference_struct_e2e.cpp new file mode 120000 index 000000000..9ef5b5e12 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/reference/reference_struct_e2e.cpp @@ -0,0 +1 @@ +../../frontend/reference/reference_struct_e2e.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/reference/reference_type_e2e.cpp b/infer/tests/codetoanalyze/cpp/errors/reference/reference_type_e2e.cpp new file mode 120000 index 000000000..236239ee6 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/reference/reference_type_e2e.cpp @@ -0,0 +1 @@ +../../frontend/reference/reference_type_e2e.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/reference/temporary_lvalue.cpp b/infer/tests/codetoanalyze/cpp/errors/reference/temporary_lvalue.cpp new file mode 120000 index 000000000..85788e5aa --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/reference/temporary_lvalue.cpp @@ -0,0 +1 @@ +../../frontend/reference/temporary_lvalue.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/resource_leaks/raii.cpp b/infer/tests/codetoanalyze/cpp/errors/resource_leaks/raii.cpp index f56191cd8..47f368215 100644 --- a/infer/tests/codetoanalyze/cpp/errors/resource_leaks/raii.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/resource_leaks/raii.cpp @@ -35,5 +35,3 @@ void no_resource_leak(const char* filename) { OpenFile f(filename); return; } - -int main() {} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/deref_after_move_example.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/deref_after_move_example.cpp index d2a91bba5..551f82b7c 100644 --- a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/deref_after_move_example.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/deref_after_move_example.cpp @@ -9,6 +9,8 @@ #include +namespace deref_after_mode_example { + struct Person { std::unique_ptr age{new int(35)}; std::unique_ptr move_age() { return std::move(age); } @@ -32,3 +34,4 @@ int deref_after_move_ok() { auto x = p.move_age(); return *x; } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_constructors.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_constructors.cpp index a7cdcb189..c173b5712 100644 --- a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_constructors.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_constructors.cpp @@ -9,6 +9,8 @@ #include +namespace shared_ptr_constructors { + struct Base { int* f1; }; @@ -95,3 +97,4 @@ void get_from_derived3_null_f1_deref() { b.f1 = nullptr; int r = *(p->f1); } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_deref.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_deref.cpp index 228c8a2ad..be99608e0 100644 --- a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_deref.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_deref.cpp @@ -9,6 +9,8 @@ #include +namespace shared_ptr { + struct X { int field; int get() { return field; } @@ -127,3 +129,4 @@ int shared_ptr_check_null2(std::shared_ptr p) { return 1; return *p; } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp index 18d9e49ff..745a78a67 100644 --- a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp @@ -9,6 +9,8 @@ #include +namespace unique_ptr { + struct X { int field; int get() { return field; } @@ -117,3 +119,4 @@ int unique_ptr_move_null_deref() { std::unique_ptr p2 = std::move(p1); return *p1; } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp b/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp index 6f522ce20..f1ad6f212 100644 --- a/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp @@ -9,6 +9,8 @@ #include +namespace cast_with_enforce { + class WrongParameterException : public std::runtime_error { public: WrongParameterException(bool e, const char* msg) : std::runtime_error(msg){}; @@ -53,3 +55,4 @@ int cast_with_npe() { auto derived = dynamic_cast(&base); return derived->a; // npe } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp.dot b/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp.dot index b1feda546..ba102f4b6 100644 --- a/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp.dot @@ -1,50 +1,50 @@ /* @generated */ digraph iCFG { -38 [label="38: DeclStmt \n _fun_Base_Base(&base:class Base *) [line 52]\n " shape="box"] +38 [label="38: DeclStmt \n _fun_cast_with_enforce::Base_Base(&base:class cast_with_enforce::Base *) [line 54]\n " shape="box"] 38 -> 37 ; -37 [label="37: DeclStmt \n n$2=_fun___cast(&base:class Base *,sizeof(class Derived ( sub )(cast)):void ) [line 53]\n *&derived:class Derived *=n$2 [line 53]\n " shape="box"] +37 [label="37: DeclStmt \n n$2=_fun___cast(&base:class cast_with_enforce::Base *,sizeof(class cast_with_enforce::Derived ( sub )(cast)):void ) [line 55]\n *&derived:class cast_with_enforce::Derived *=n$2 [line 55]\n " shape="box"] 37 -> 36 ; -36 [label="36: Return Stmt \n n$0=*&derived:class Derived * [line 54]\n n$1=*n$0.a:int [line 54]\n *&return:int =n$1 [line 54]\n " shape="box"] +36 [label="36: Return Stmt \n n$0=*&derived:class cast_with_enforce::Derived * [line 56]\n n$1=*n$0.a:int [line 56]\n *&return:int =n$1 [line 56]\n " shape="box"] 36 -> 35 ; -35 [label="35: Exit cast_with_npe \n " color=yellow style=filled] +35 [label="35: Exit cast_with_enforce::cast_with_npe \n " color=yellow style=filled] -34 [label="34: Start cast_with_npe\nFormals: \nLocals: derived:class Derived * base:class Base \n DECLARE_LOCALS(&return,&derived,&base); [line 51]\n " color=yellow style=filled] +34 [label="34: Start cast_with_enforce::cast_with_npe\nFormals: \nLocals: derived:class cast_with_enforce::Derived * base:class cast_with_enforce::Base \n DECLARE_LOCALS(&return,&derived,&base); [line 53]\n " color=yellow style=filled] 34 -> 38 ; -33 [label="33: DeclStmt \n _fun_Base_Base(&base:class Base *) [line 44]\n " shape="box"] +33 [label="33: DeclStmt \n _fun_cast_with_enforce::Base_Base(&base:class cast_with_enforce::Base *) [line 46]\n " shape="box"] 33 -> 32 ; -32 [label="32: DeclStmt \n n$10=_fun___cast(&base:class Base *,sizeof(class Derived ( sub )(cast)):void ) [line 45]\n *&derived:class Derived *=n$10 [line 45]\n " shape="box"] +32 [label="32: DeclStmt \n n$10=_fun___cast(&base:class cast_with_enforce::Base *,sizeof(class cast_with_enforce::Derived ( sub )(cast)):void ) [line 47]\n *&derived:class cast_with_enforce::Derived *=n$10 [line 47]\n " shape="box"] 32 -> 31 ; -31 [label="31: DeclStmt \n *&_tmp:class Derived *&=&derived [line 46]\n " shape="box"] +31 [label="31: DeclStmt \n *&_tmp:class cast_with_enforce::Derived *&=&derived [line 48]\n " shape="box"] 31 -> 27 ; 31 -> 28 ; -30 [label="30: ConditinalStmt Branch \n _fun_WrongParameterException_WrongParameterException(&0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException *,\"derived\":_Bool ,\"Base is not Derived\":char *) [line 46]\n _fun_WrongParameterException_WrongParameterException(&0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException *,&0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException &) [line 46]\n _fun___infer_objc_cpp_throw(&0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException ) [line 46]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *&=-1 [line 46]\n " shape="box"] +30 [label="30: ConditinalStmt Branch \n _fun_cast_with_enforce::WrongParameterException_WrongParameterException(&0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException *,\"derived\":_Bool ,\"Base is not Derived\":char *) [line 48]\n _fun_cast_with_enforce::WrongParameterException_WrongParameterException(&0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException *,&0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException &) [line 48]\n _fun___infer_objc_cpp_throw(&0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException ) [line 48]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *&=-1 [line 48]\n " shape="box"] 30 -> 26 ; -29 [label="29: ConditinalStmt Branch \n n$5=*&_tmp:class Derived *& [line 46]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *&=n$5 [line 46]\n " shape="box"] +29 [label="29: ConditinalStmt Branch \n n$5=*&_tmp:class cast_with_enforce::Derived *& [line 48]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *&=n$5 [line 48]\n " shape="box"] 29 -> 26 ; -28 [label="28: Prune (false branch) \n n$3=*&_tmp:class Derived *& [line 46]\n n$4=*n$3:class Derived * [line 46]\n PRUNE((n$4 == 0), false); [line 46]\n " shape="invhouse"] +28 [label="28: Prune (false branch) \n n$3=*&_tmp:class cast_with_enforce::Derived *& [line 48]\n n$4=*n$3:class cast_with_enforce::Derived * [line 48]\n PRUNE((n$4 == 0), false); [line 48]\n " shape="invhouse"] 28 -> 30 ; -27 [label="27: Prune (true branch) \n n$3=*&_tmp:class Derived *& [line 46]\n n$4=*n$3:class Derived * [line 46]\n PRUNE((n$4 != 0), true); [line 46]\n " shape="invhouse"] +27 [label="27: Prune (true branch) \n n$3=*&_tmp:class cast_with_enforce::Derived *& [line 48]\n n$4=*n$3:class cast_with_enforce::Derived * [line 48]\n PRUNE((n$4 != 0), true); [line 48]\n " shape="invhouse"] 27 -> 29 ; @@ -52,39 +52,39 @@ digraph iCFG { 26 -> 25 ; -25 [label="25: Return Stmt \n n$0=*&derived:class Derived * [line 47]\n n$1=*n$0.a:int [line 47]\n *&return:int =n$1 [line 47]\n " shape="box"] +25 [label="25: Return Stmt \n n$0=*&derived:class cast_with_enforce::Derived * [line 49]\n n$1=*n$0.a:int [line 49]\n *&return:int =n$1 [line 49]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit cast_with_npe_avoided_by_enforce \n " color=yellow style=filled] +24 [label="24: Exit cast_with_enforce::cast_with_npe_avoided_by_enforce \n " color=yellow style=filled] -23 [label="23: Start cast_with_npe_avoided_by_enforce\nFormals: \nLocals: 0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *& 0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException 0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException _tmp:class Derived *& derived:class Derived * base:class Base \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_temp_conditional___n$2,&0$?%__sil_tmp__temp_construct_n$6,&0$?%__sil_tmpSIL_materialize_temp__n$7,&_tmp,&derived,&base); [line 43]\n " color=yellow style=filled] +23 [label="23: Start cast_with_enforce::cast_with_npe_avoided_by_enforce\nFormals: \nLocals: 0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *& 0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException 0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException _tmp:class cast_with_enforce::Derived *& derived:class cast_with_enforce::Derived * base:class cast_with_enforce::Base \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_temp_conditional___n$2,&0$?%__sil_tmp__temp_construct_n$6,&0$?%__sil_tmpSIL_materialize_temp__n$7,&_tmp,&derived,&base); [line 45]\n " color=yellow style=filled] 23 -> 33 ; -22 [label="22: DeclStmt \n n$10=*&certificate:class Base & [line 38]\n n$11=_fun___cast(n$10:class Base *,sizeof(class Derived ( sub )(cast)):void ) [line 38]\n *&cert:class Derived *=n$11 [line 38]\n " shape="box"] +22 [label="22: DeclStmt \n n$10=*&certificate:class cast_with_enforce::Base & [line 40]\n n$11=_fun___cast(n$10:class cast_with_enforce::Base *,sizeof(class cast_with_enforce::Derived ( sub )(cast)):void ) [line 40]\n *&cert:class cast_with_enforce::Derived *=n$11 [line 40]\n " shape="box"] 22 -> 21 ; -21 [label="21: DeclStmt \n *&_tmp:class Derived *&=&cert [line 39]\n " shape="box"] +21 [label="21: DeclStmt \n *&_tmp:class cast_with_enforce::Derived *&=&cert [line 41]\n " shape="box"] 21 -> 17 ; 21 -> 18 ; -20 [label="20: ConditinalStmt Branch \n _fun_WrongParameterException_WrongParameterException(&0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException *,\"cert\":_Bool ,\"Base is not Derived\":char *) [line 39]\n _fun_WrongParameterException_WrongParameterException(&0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException *,&0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException &) [line 39]\n _fun___infer_objc_cpp_throw(&0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException ) [line 39]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *&=-1 [line 39]\n " shape="box"] +20 [label="20: ConditinalStmt Branch \n _fun_cast_with_enforce::WrongParameterException_WrongParameterException(&0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException *,\"cert\":_Bool ,\"Base is not Derived\":char *) [line 41]\n _fun_cast_with_enforce::WrongParameterException_WrongParameterException(&0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException *,&0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException &) [line 41]\n _fun___infer_objc_cpp_throw(&0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException ) [line 41]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *&=-1 [line 41]\n " shape="box"] 20 -> 16 ; -19 [label="19: ConditinalStmt Branch \n n$5=*&_tmp:class Derived *& [line 39]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *&=n$5 [line 39]\n " shape="box"] +19 [label="19: ConditinalStmt Branch \n n$5=*&_tmp:class cast_with_enforce::Derived *& [line 41]\n *&0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *&=n$5 [line 41]\n " shape="box"] 19 -> 16 ; -18 [label="18: Prune (false branch) \n n$3=*&_tmp:class Derived *& [line 39]\n n$4=*n$3:class Derived * [line 39]\n PRUNE((n$4 == 0), false); [line 39]\n " shape="invhouse"] +18 [label="18: Prune (false branch) \n n$3=*&_tmp:class cast_with_enforce::Derived *& [line 41]\n n$4=*n$3:class cast_with_enforce::Derived * [line 41]\n PRUNE((n$4 == 0), false); [line 41]\n " shape="invhouse"] 18 -> 20 ; -17 [label="17: Prune (true branch) \n n$3=*&_tmp:class Derived *& [line 39]\n n$4=*n$3:class Derived * [line 39]\n PRUNE((n$4 != 0), true); [line 39]\n " shape="invhouse"] +17 [label="17: Prune (true branch) \n n$3=*&_tmp:class cast_with_enforce::Derived *& [line 41]\n n$4=*n$3:class cast_with_enforce::Derived * [line 41]\n PRUNE((n$4 != 0), true); [line 41]\n " shape="invhouse"] 17 -> 19 ; @@ -92,57 +92,57 @@ digraph iCFG { 16 -> 15 ; -15 [label="15: Return Stmt \n n$0=*&cert:class Derived * [line 40]\n n$1=*n$0.a:int [line 40]\n *&return:int =n$1 [line 40]\n " shape="box"] +15 [label="15: Return Stmt \n n$0=*&cert:class cast_with_enforce::Derived * [line 42]\n n$1=*n$0.a:int [line 42]\n *&return:int =n$1 [line 42]\n " shape="box"] 15 -> 14 ; -14 [label="14: Exit cast_with_no_npe \n " color=yellow style=filled] +14 [label="14: Exit cast_with_enforce::cast_with_no_npe \n " color=yellow style=filled] -13 [label="13: Start cast_with_no_npe\nFormals: certificate:class Base &\nLocals: 0$?%__sil_tmpSIL_temp_conditional___n$2:class Derived *& 0$?%__sil_tmp__temp_construct_n$6:class WrongParameterException 0$?%__sil_tmpSIL_materialize_temp__n$7:class WrongParameterException _tmp:class Derived *& cert:class Derived * \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_temp_conditional___n$2,&0$?%__sil_tmp__temp_construct_n$6,&0$?%__sil_tmpSIL_materialize_temp__n$7,&_tmp,&cert); [line 37]\n " color=yellow style=filled] +13 [label="13: Start cast_with_enforce::cast_with_no_npe\nFormals: certificate:class cast_with_enforce::Base &\nLocals: 0$?%__sil_tmpSIL_temp_conditional___n$2:class cast_with_enforce::Derived *& 0$?%__sil_tmp__temp_construct_n$6:class cast_with_enforce::WrongParameterException 0$?%__sil_tmpSIL_materialize_temp__n$7:class cast_with_enforce::WrongParameterException _tmp:class cast_with_enforce::Derived *& cert:class cast_with_enforce::Derived * \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_temp_conditional___n$2,&0$?%__sil_tmp__temp_construct_n$6,&0$?%__sil_tmpSIL_materialize_temp__n$7,&_tmp,&cert); [line 39]\n " color=yellow style=filled] 13 -> 22 ; -12 [label="12: Exit Base_Base \n " color=yellow style=filled] +12 [label="12: Exit cast_with_enforce::Base_Base \n " color=yellow style=filled] -11 [label="11: Start Base_Base\nFormals: this:class Base *\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] +11 [label="11: Start cast_with_enforce::Base_Base\nFormals: this:class cast_with_enforce::Base *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 11 -> 12 ; -10 [label="10: Exit Base_dummy \n " color=yellow style=filled] +10 [label="10: Exit cast_with_enforce::Base_dummy \n " color=yellow style=filled] -9 [label="9: Start Base_dummy\nFormals: this:class Base *\nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] +9 [label="9: Start cast_with_enforce::Base_dummy\nFormals: this:class cast_with_enforce::Base *\nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] 9 -> 10 ; -8 [label="8: Exit WrongParameterException_~WrongParameterException \n " color=yellow style=filled] +8 [label="8: Exit cast_with_enforce::WrongParameterException_~WrongParameterException \n " color=yellow style=filled] -7 [label="7: Start WrongParameterException_~WrongParameterException\nFormals: this:class WrongParameterException *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +7 [label="7: Start cast_with_enforce::WrongParameterException_~WrongParameterException\nFormals: this:class cast_with_enforce::WrongParameterException *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 7 -> 8 ; -6 [label="6: Constructor Init \n n$0=*&this:class WrongParameterException * [line 12]\n n$1=*&__param_0:class WrongParameterException & [line 12]\n _fun_std::runtime_error_runtime_error(n$0:class WrongParameterException *,n$1:class std::runtime_error &) [line 12]\n " shape="box"] +6 [label="6: Constructor Init \n n$0=*&this:class cast_with_enforce::WrongParameterException * [line 14]\n n$1=*&__param_0:class cast_with_enforce::WrongParameterException & [line 14]\n _fun_std::runtime_error_runtime_error(n$0:class cast_with_enforce::WrongParameterException *,n$1:class std::runtime_error &) [line 14]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit WrongParameterException_WrongParameterException \n " color=yellow style=filled] +5 [label="5: Exit cast_with_enforce::WrongParameterException_WrongParameterException \n " color=yellow style=filled] -4 [label="4: Start WrongParameterException_WrongParameterException\nFormals: this:class WrongParameterException * __param_0:class WrongParameterException &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +4 [label="4: Start cast_with_enforce::WrongParameterException_WrongParameterException\nFormals: this:class cast_with_enforce::WrongParameterException * __param_0:class cast_with_enforce::WrongParameterException &\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Constructor Init \n n$0=*&this:class WrongParameterException * [line 14]\n n$1=*&msg:char * [line 14]\n _fun_std::runtime_error_runtime_error(n$0:class WrongParameterException *,n$1:char *) [line 14]\n " shape="box"] +3 [label="3: Constructor Init \n n$0=*&this:class cast_with_enforce::WrongParameterException * [line 16]\n n$1=*&msg:char * [line 16]\n _fun_std::runtime_error_runtime_error(n$0:class cast_with_enforce::WrongParameterException *,n$1:char *) [line 16]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit WrongParameterException_WrongParameterException \n " color=yellow style=filled] +2 [label="2: Exit cast_with_enforce::WrongParameterException_WrongParameterException \n " color=yellow style=filled] -1 [label="1: Start WrongParameterException_WrongParameterException\nFormals: this:class WrongParameterException * e:_Bool msg:char *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +1 [label="1: Start cast_with_enforce::WrongParameterException_WrongParameterException\nFormals: this:class cast_with_enforce::WrongParameterException * e:_Bool msg:char *\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp b/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp index aeb9a54d1..04cf34a34 100644 --- a/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace dynamic__cast { + class Base { virtual void dummy() {} @@ -73,3 +75,4 @@ void wrongReferenceCastNotAssigned() { Base& pdd = *pbb; dynamic_cast(pdd); } +} diff --git a/infer/tests/codetoanalyze/cpp/errors/templates/class_template_instantiate.cpp b/infer/tests/codetoanalyze/cpp/errors/templates/class_template_instantiate.cpp new file mode 120000 index 000000000..a99a05f7e --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/templates/class_template_instantiate.cpp @@ -0,0 +1 @@ +../../frontend/templates/class_template_instantiate.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/templates/function.cpp b/infer/tests/codetoanalyze/cpp/errors/templates/function.cpp new file mode 120000 index 000000000..f5d3d2f66 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/templates/function.cpp @@ -0,0 +1 @@ +../../frontend/templates/function.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/templates/function_pack.cpp b/infer/tests/codetoanalyze/cpp/errors/templates/function_pack.cpp new file mode 120000 index 000000000..36126b6c9 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/templates/function_pack.cpp @@ -0,0 +1 @@ +../../frontend/templates/function_pack.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/templates/method.cpp b/infer/tests/codetoanalyze/cpp/errors/templates/method.cpp new file mode 120000 index 000000000..585b36f4d --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/templates/method.cpp @@ -0,0 +1 @@ +../../frontend/templates/method.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/inheritance_field.cpp b/infer/tests/codetoanalyze/cpp/errors/types/inheritance_field.cpp new file mode 120000 index 000000000..5b286f1c4 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/inheritance_field.cpp @@ -0,0 +1 @@ +../../frontend/types/inheritance_field.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/operator_overload.cpp b/infer/tests/codetoanalyze/cpp/errors/types/operator_overload.cpp new file mode 120000 index 000000000..feddc6bac --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/operator_overload.cpp @@ -0,0 +1 @@ +../../frontend/types/operator_overload.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/return_struct.cpp b/infer/tests/codetoanalyze/cpp/errors/types/return_struct.cpp new file mode 120000 index 000000000..9d47e5286 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/return_struct.cpp @@ -0,0 +1 @@ +../../frontend/types/return_struct.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/struct_forward_declare.cpp b/infer/tests/codetoanalyze/cpp/errors/types/struct_forward_declare.cpp new file mode 120000 index 000000000..53cf2183b --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/struct_forward_declare.cpp @@ -0,0 +1 @@ +../../frontend/types/struct_forward_declare.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/struct_pass_by_value.cpp b/infer/tests/codetoanalyze/cpp/errors/types/struct_pass_by_value.cpp new file mode 120000 index 000000000..af024f199 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/struct_pass_by_value.cpp @@ -0,0 +1 @@ +../../frontend/types/struct_pass_by_value.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/errors/types/typeid_expr.cpp b/infer/tests/codetoanalyze/cpp/errors/types/typeid_expr.cpp new file mode 120000 index 000000000..4f7b5cfe8 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/errors/types/typeid_expr.cpp @@ -0,0 +1 @@ +../../frontend/types/typeid_expr.cpp \ No newline at end of file diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp index 3514cc40f..7a209f705 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace constructor_new { + class Person { public: Person() { x = 0; } @@ -97,3 +99,4 @@ void matrix_of_person() { Person** tarray = new Person*[10]; tarray[0] = new Person[10]; } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp.dot index 257fda6ed..c85245d63 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_new.cpp.dot @@ -1,52 +1,52 @@ /* @generated */ digraph iCFG { -97 [label="97: DeclStmt \n n$2=_fun___new_array((sizeof(class Person *) * 10):unsigned long ) [line 97]\n *&tarray:class Person **=n$2 [line 97]\n " shape="box"] +97 [label="97: DeclStmt \n n$2=_fun___new_array((sizeof(class constructor_new::Person *) * 10):unsigned long ) [line 99]\n *&tarray:class constructor_new::Person **=n$2 [line 99]\n " shape="box"] 97 -> 96 ; -96 [label="96: BinaryOperatorStmt: Assign \n n$0=*&tarray:class Person ** [line 98]\n n$1=_fun___new_array((sizeof(class Person ) * 10):unsigned long ) [line 98]\n _fun_Person_Person(n$1[0]:class Person *) [line 98]\n _fun_Person_Person(n$1[1]:class Person *) [line 98]\n _fun_Person_Person(n$1[2]:class Person *) [line 98]\n _fun_Person_Person(n$1[3]:class Person *) [line 98]\n _fun_Person_Person(n$1[4]:class Person *) [line 98]\n _fun_Person_Person(n$1[5]:class Person *) [line 98]\n _fun_Person_Person(n$1[6]:class Person *) [line 98]\n _fun_Person_Person(n$1[7]:class Person *) [line 98]\n _fun_Person_Person(n$1[8]:class Person *) [line 98]\n _fun_Person_Person(n$1[9]:class Person *) [line 98]\n *n$0[0]:class Person *=n$1 [line 98]\n " shape="box"] +96 [label="96: BinaryOperatorStmt: Assign \n n$0=*&tarray:class constructor_new::Person ** [line 100]\n n$1=_fun___new_array((sizeof(class constructor_new::Person ) * 10):unsigned long ) [line 100]\n _fun_constructor_new::Person_Person(n$1[0]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[1]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[2]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[3]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[4]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[5]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[6]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[7]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[8]:class constructor_new::Person *) [line 100]\n _fun_constructor_new::Person_Person(n$1[9]:class constructor_new::Person *) [line 100]\n *n$0[0]:class constructor_new::Person *=n$1 [line 100]\n " shape="box"] 96 -> 95 ; -95 [label="95: Exit matrix_of_person \n " color=yellow style=filled] +95 [label="95: Exit constructor_new::matrix_of_person \n " color=yellow style=filled] -94 [label="94: Start matrix_of_person\nFormals: \nLocals: tarray:class Person ** \n DECLARE_LOCALS(&return,&tarray); [line 96]\n " color=yellow style=filled] +94 [label="94: Start constructor_new::matrix_of_person\nFormals: \nLocals: tarray:class constructor_new::Person ** \n DECLARE_LOCALS(&return,&tarray); [line 98]\n " color=yellow style=filled] 94 -> 97 ; -93 [label="93: DeclStmt \n n$0=_fun___new_array((sizeof(class Person ) * 10):unsigned long ) [line 93]\n _fun_Person_Person(n$0[0]:class Person *) [line 93]\n _fun_Person_Person(n$0[1]:class Person *) [line 93]\n _fun_Person_Person(n$0[2]:class Person *) [line 93]\n _fun_Person_Person(n$0[3]:class Person *) [line 93]\n _fun_Person_Person(n$0[4]:class Person *) [line 93]\n _fun_Person_Person(n$0[5]:class Person *) [line 93]\n _fun_Person_Person(n$0[6]:class Person *) [line 93]\n _fun_Person_Person(n$0[7]:class Person *) [line 93]\n _fun_Person_Person(n$0[8]:class Person *) [line 93]\n _fun_Person_Person(n$0[9]:class Person *) [line 93]\n *&tarray:class Person *=n$0 [line 93]\n " shape="box"] +93 [label="93: DeclStmt \n n$0=_fun___new_array((sizeof(class constructor_new::Person ) * 10):unsigned long ) [line 95]\n _fun_constructor_new::Person_Person(n$0[0]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[1]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[2]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[3]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[4]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[5]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[6]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[7]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[8]:class constructor_new::Person *) [line 95]\n _fun_constructor_new::Person_Person(n$0[9]:class constructor_new::Person *) [line 95]\n *&tarray:class constructor_new::Person *=n$0 [line 95]\n " shape="box"] 93 -> 92 ; -92 [label="92: Exit array_of_person_with_constant_size \n " color=yellow style=filled] +92 [label="92: Exit constructor_new::array_of_person_with_constant_size \n " color=yellow style=filled] -91 [label="91: Start array_of_person_with_constant_size\nFormals: \nLocals: tarray:class Person * \n DECLARE_LOCALS(&return,&tarray); [line 93]\n " color=yellow style=filled] +91 [label="91: Start constructor_new::array_of_person_with_constant_size\nFormals: \nLocals: tarray:class constructor_new::Person * \n DECLARE_LOCALS(&return,&tarray); [line 95]\n " color=yellow style=filled] 91 -> 93 ; -90 [label="90: DeclStmt \n n$2=*&0$?%__sil_tmpSIL_temp_conditional___n$0:int [line 89]\n n$3=_fun___new_array((sizeof(class Person ) * n$2):unsigned long ) [line 89]\n *&tarray:class Person *=n$3 [line 89]\n " shape="box"] +90 [label="90: DeclStmt \n n$2=*&0$?%__sil_tmpSIL_temp_conditional___n$0:int [line 91]\n n$3=_fun___new_array((sizeof(class constructor_new::Person ) * n$2):unsigned long ) [line 91]\n *&tarray:class constructor_new::Person *=n$3 [line 91]\n " shape="box"] 90 -> 83 ; -89 [label="89: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$0:int =3 [line 89]\n " shape="box"] +89 [label="89: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$0:int =3 [line 91]\n " shape="box"] 89 -> 84 ; -88 [label="88: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$0:int =5 [line 89]\n " shape="box"] +88 [label="88: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$0:int =5 [line 91]\n " shape="box"] 88 -> 84 ; -87 [label="87: Prune (false branch) \n PRUNE(((n$1 == 5) == 0), false); [line 89]\n " shape="invhouse"] +87 [label="87: Prune (false branch) \n PRUNE(((n$1 == 5) == 0), false); [line 91]\n " shape="invhouse"] 87 -> 89 ; -86 [label="86: Prune (true branch) \n PRUNE(((n$1 == 5) != 0), true); [line 89]\n " shape="invhouse"] +86 [label="86: Prune (true branch) \n PRUNE(((n$1 == 5) != 0), true); [line 91]\n " shape="invhouse"] 86 -> 88 ; -85 [label="85: BinaryOperatorStmt: EQ \n n$1=_fun_getValue(5:int ) [line 89]\n " shape="box"] +85 [label="85: BinaryOperatorStmt: EQ \n n$1=_fun_constructor_new::getValue(5:int ) [line 91]\n " shape="box"] 85 -> 86 ; @@ -55,49 +55,49 @@ digraph iCFG { 84 -> 90 ; -83 [label="83: Exit array_of_class_with_not_constant_size \n " color=yellow style=filled] +83 [label="83: Exit constructor_new::array_of_class_with_not_constant_size \n " color=yellow style=filled] -82 [label="82: Start array_of_class_with_not_constant_size\nFormals: \nLocals: tarray:class Person * 0$?%__sil_tmpSIL_temp_conditional___n$0:int \n DECLARE_LOCALS(&return,&tarray,&0$?%__sil_tmpSIL_temp_conditional___n$0); [line 88]\n " color=yellow style=filled] +82 [label="82: Start constructor_new::array_of_class_with_not_constant_size\nFormals: \nLocals: tarray:class constructor_new::Person * 0$?%__sil_tmpSIL_temp_conditional___n$0:int \n DECLARE_LOCALS(&return,&tarray,&0$?%__sil_tmpSIL_temp_conditional___n$0); [line 90]\n " color=yellow style=filled] 82 -> 85 ; -81 [label="81: DeclStmt \n n$10=_fun___new_array((sizeof(int ) * 100):unsigned long ) [line 83]\n *n$10[0]:int =1 [line 83]\n *n$10[1]:int =2 [line 83]\n *n$10[2]:int =3 [line 83]\n *n$10[3]:int =4 [line 83]\n *n$10[4]:int =5 [line 83]\n *n$10[5]:int =6 [line 83]\n *n$10[6]:int =7 [line 83]\n *n$10[7]:int =8 [line 83]\n *n$10[8]:int =9 [line 83]\n *n$10[9]:int =10 [line 83]\n *&arr:int *=n$10 [line 83]\n " shape="box"] +81 [label="81: DeclStmt \n n$10=_fun___new_array((sizeof(int ) * 100):unsigned long ) [line 85]\n *n$10[0]:int =1 [line 85]\n *n$10[1]:int =2 [line 85]\n *n$10[2]:int =3 [line 85]\n *n$10[3]:int =4 [line 85]\n *n$10[4]:int =5 [line 85]\n *n$10[5]:int =6 [line 85]\n *n$10[6]:int =7 [line 85]\n *n$10[7]:int =8 [line 85]\n *n$10[8]:int =9 [line 85]\n *n$10[9]:int =10 [line 85]\n *&arr:int *=n$10 [line 85]\n " shape="box"] 81 -> 80 ; -80 [label="80: Return Stmt \n n$0=*&arr:int * [line 84]\n n$1=*n$0[0]:int [line 84]\n n$2=*&arr:int * [line 84]\n n$3=*n$2[1]:int [line 84]\n n$4=*&arr:int * [line 84]\n n$5=*n$4[2]:int [line 84]\n n$6=*&arr:int * [line 84]\n n$7=*n$6[3]:int [line 84]\n n$8=*&arr:int * [line 84]\n n$9=*n$8[4]:int [line 84]\n *&return:int =(1 / (((((n$1 + n$3) + n$5) + n$7) + n$9) - 15)) [line 84]\n " shape="box"] +80 [label="80: Return Stmt \n n$0=*&arr:int * [line 86]\n n$1=*n$0[0]:int [line 86]\n n$2=*&arr:int * [line 86]\n n$3=*n$2[1]:int [line 86]\n n$4=*&arr:int * [line 86]\n n$5=*n$4[2]:int [line 86]\n n$6=*&arr:int * [line 86]\n n$7=*n$6[3]:int [line 86]\n n$8=*&arr:int * [line 86]\n n$9=*n$8[4]:int [line 86]\n *&return:int =(1 / (((((n$1 + n$3) + n$5) + n$7) + n$9) - 15)) [line 86]\n " shape="box"] 80 -> 79 ; -79 [label="79: Exit int_array_init \n " color=yellow style=filled] +79 [label="79: Exit constructor_new::int_array_init \n " color=yellow style=filled] -78 [label="78: Start int_array_init\nFormals: \nLocals: arr:int * \n DECLARE_LOCALS(&return,&arr); [line 82]\n " color=yellow style=filled] +78 [label="78: Start constructor_new::int_array_init\nFormals: \nLocals: arr:int * \n DECLARE_LOCALS(&return,&arr); [line 84]\n " color=yellow style=filled] 78 -> 81 ; -77 [label="77: DeclStmt \n n$9=*&0$?%__sil_tmpSIL_temp_conditional___n$6:int [line 76]\n n$10=_fun___new_array((sizeof(int ) * n$9):unsigned long ) [line 76]\n *&x2:int *=n$10 [line 76]\n " shape="box"] +77 [label="77: DeclStmt \n n$9=*&0$?%__sil_tmpSIL_temp_conditional___n$6:int [line 78]\n n$10=_fun___new_array((sizeof(int ) * n$9):unsigned long ) [line 78]\n *&x2:int *=n$10 [line 78]\n " shape="box"] 77 -> 70 ; -76 [label="76: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$6:int =3 [line 76]\n " shape="box"] +76 [label="76: ConditinalStmt Branch \n *&0$?%__sil_tmpSIL_temp_conditional___n$6:int =3 [line 78]\n " shape="box"] 76 -> 71 ; -75 [label="75: ConditinalStmt Branch \n n$8=_fun_getValue(5:int ) [line 76]\n *&0$?%__sil_tmpSIL_temp_conditional___n$6:int =n$8 [line 76]\n " shape="box"] +75 [label="75: ConditinalStmt Branch \n n$8=_fun_constructor_new::getValue(5:int ) [line 78]\n *&0$?%__sil_tmpSIL_temp_conditional___n$6:int =n$8 [line 78]\n " shape="box"] 75 -> 71 ; -74 [label="74: Prune (false branch) \n PRUNE((n$7 == 0), false); [line 76]\n " shape="invhouse"] +74 [label="74: Prune (false branch) \n PRUNE((n$7 == 0), false); [line 78]\n " shape="invhouse"] 74 -> 76 ; -73 [label="73: Prune (true branch) \n PRUNE((n$7 != 0), true); [line 76]\n " shape="invhouse"] +73 [label="73: Prune (true branch) \n PRUNE((n$7 != 0), true); [line 78]\n " shape="invhouse"] 73 -> 75 ; -72 [label="72: Call _fun_getValue \n n$7=_fun_getValue(5:int ) [line 76]\n " shape="box"] +72 [label="72: Call _fun_constructor_new::getValue \n n$7=_fun_constructor_new::getValue(5:int ) [line 78]\n " shape="box"] 72 -> 73 ; @@ -106,50 +106,50 @@ digraph iCFG { 71 -> 77 ; -70 [label="70: BinaryOperatorStmt: Assign \n n$5=*&x2:int * [line 77]\n *n$5[0]:int =1 [line 77]\n " shape="box"] +70 [label="70: BinaryOperatorStmt: Assign \n n$5=*&x2:int * [line 79]\n *n$5[0]:int =1 [line 79]\n " shape="box"] 70 -> 69 ; -69 [label="69: BinaryOperatorStmt: Assign \n n$4=*&x2:int * [line 78]\n *n$4[1]:int =2 [line 78]\n " shape="box"] +69 [label="69: BinaryOperatorStmt: Assign \n n$4=*&x2:int * [line 80]\n *n$4[1]:int =2 [line 80]\n " shape="box"] 69 -> 68 ; -68 [label="68: Return Stmt \n n$0=*&x2:int * [line 79]\n n$1=*n$0[0]:int [line 79]\n n$2=*&x2:int * [line 79]\n n$3=*n$2[1]:int [line 79]\n *&return:int =(1 / ((n$1 + n$3) - 3)) [line 79]\n " shape="box"] +68 [label="68: Return Stmt \n n$0=*&x2:int * [line 81]\n n$1=*n$0[0]:int [line 81]\n n$2=*&x2:int * [line 81]\n n$3=*n$2[1]:int [line 81]\n *&return:int =(1 / ((n$1 + n$3) - 3)) [line 81]\n " shape="box"] 68 -> 67 ; -67 [label="67: Exit int_array \n " color=yellow style=filled] +67 [label="67: Exit constructor_new::int_array \n " color=yellow style=filled] -66 [label="66: Start int_array\nFormals: \nLocals: x2:int * 0$?%__sil_tmpSIL_temp_conditional___n$6:int \n DECLARE_LOCALS(&return,&x2,&0$?%__sil_tmpSIL_temp_conditional___n$6); [line 75]\n " color=yellow style=filled] +66 [label="66: Start constructor_new::int_array\nFormals: \nLocals: x2:int * 0$?%__sil_tmpSIL_temp_conditional___n$6:int \n DECLARE_LOCALS(&return,&x2,&0$?%__sil_tmpSIL_temp_conditional___n$6); [line 77]\n " color=yellow style=filled] 66 -> 72 ; -65 [label="65: DeclStmt \n *&z:int =6 [line 70]\n " shape="box"] +65 [label="65: DeclStmt \n *&z:int =6 [line 72]\n " shape="box"] 65 -> 59 ; -64 [label="64: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 71]\n n$7=*&0$?%__sil_tmpSIL_temp_conditional___n$3:int [line 71]\n _fun_Person_Person(n$2:class Person *,n$7:int ) [line 71]\n *&p:class Person *=n$2 [line 71]\n " shape="box"] +64 [label="64: DeclStmt \n n$2=_fun___new(sizeof(class constructor_new::Person ):unsigned long ) [line 73]\n n$7=*&0$?%__sil_tmpSIL_temp_conditional___n$3:int [line 73]\n _fun_constructor_new::Person_Person(n$2:class constructor_new::Person *,n$7:int ) [line 73]\n *&p:class constructor_new::Person *=n$2 [line 73]\n " shape="box"] 64 -> 57 ; -63 [label="63: ConditinalStmt Branch \n n$6=*&z:int [line 71]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =(1 + n$6) [line 71]\n " shape="box"] +63 [label="63: ConditinalStmt Branch \n n$6=*&z:int [line 73]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =(1 + n$6) [line 73]\n " shape="box"] 63 -> 58 ; -62 [label="62: ConditinalStmt Branch \n n$5=_fun_getValue(1:int ) [line 71]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =n$5 [line 71]\n " shape="box"] +62 [label="62: ConditinalStmt Branch \n n$5=_fun_constructor_new::getValue(1:int ) [line 73]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =n$5 [line 73]\n " shape="box"] 62 -> 58 ; -61 [label="61: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 71]\n " shape="invhouse"] +61 [label="61: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 73]\n " shape="invhouse"] 61 -> 63 ; -60 [label="60: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 71]\n " shape="invhouse"] +60 [label="60: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 73]\n " shape="invhouse"] 60 -> 62 ; -59 [label="59: Call _fun_getValue \n n$4=_fun_getValue(0:int ) [line 71]\n " shape="box"] +59 [label="59: Call _fun_constructor_new::getValue \n n$4=_fun_constructor_new::getValue(0:int ) [line 73]\n " shape="box"] 59 -> 60 ; @@ -158,46 +158,46 @@ digraph iCFG { 58 -> 64 ; -57 [label="57: Return Stmt \n n$0=*&p:class Person * [line 72]\n n$1=*n$0.x:int [line 72]\n *&return:int =(1 / (n$1 - 7)) [line 72]\n " shape="box"] +57 [label="57: Return Stmt \n n$0=*&p:class constructor_new::Person * [line 74]\n n$1=*n$0.x:int [line 74]\n *&return:int =(1 / (n$1 - 7)) [line 74]\n " shape="box"] 57 -> 56 ; -56 [label="56: Exit constructor_nodes \n " color=yellow style=filled] +56 [label="56: Exit constructor_new::constructor_nodes \n " color=yellow style=filled] -55 [label="55: Start constructor_nodes\nFormals: \nLocals: p:class Person * 0$?%__sil_tmpSIL_temp_conditional___n$3:int z:int \n DECLARE_LOCALS(&return,&p,&0$?%__sil_tmpSIL_temp_conditional___n$3,&z); [line 69]\n " color=yellow style=filled] +55 [label="55: Start constructor_new::constructor_nodes\nFormals: \nLocals: p:class constructor_new::Person * 0$?%__sil_tmpSIL_temp_conditional___n$3:int z:int \n DECLARE_LOCALS(&return,&p,&0$?%__sil_tmpSIL_temp_conditional___n$3,&z); [line 71]\n " color=yellow style=filled] 55 -> 65 ; -54 [label="54: DeclStmt \n *&z:int =6 [line 63]\n " shape="box"] +54 [label="54: DeclStmt \n *&z:int =6 [line 65]\n " shape="box"] 54 -> 53 ; -53 [label="53: DeclStmt \n n$9=_fun___new(sizeof(int ):unsigned long ) [line 64]\n n$10=_fun_getValue(4:int ) [line 64]\n *n$9:int =n$10 [line 64]\n *&y:int *=n$9 [line 64]\n " shape="box"] +53 [label="53: DeclStmt \n n$9=_fun___new(sizeof(int ):unsigned long ) [line 66]\n n$10=_fun_constructor_new::getValue(4:int ) [line 66]\n *n$9:int =n$10 [line 66]\n *&y:int *=n$9 [line 66]\n " shape="box"] 53 -> 47 ; -52 [label="52: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 65]\n n$8=*&0$?%__sil_tmpSIL_temp_conditional___n$3:int [line 65]\n *n$2:int =n$8 [line 65]\n *&x:int *=n$2 [line 65]\n " shape="box"] +52 [label="52: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 67]\n n$8=*&0$?%__sil_tmpSIL_temp_conditional___n$3:int [line 67]\n *n$2:int =n$8 [line 67]\n *&x:int *=n$2 [line 67]\n " shape="box"] 52 -> 45 ; -51 [label="51: ConditinalStmt Branch \n n$6=*&y:int * [line 65]\n n$7=*n$6:int [line 65]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =(1 + n$7) [line 65]\n " shape="box"] +51 [label="51: ConditinalStmt Branch \n n$6=*&y:int * [line 67]\n n$7=*n$6:int [line 67]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =(1 + n$7) [line 67]\n " shape="box"] 51 -> 46 ; -50 [label="50: ConditinalStmt Branch \n n$5=_fun_getValue(1:int ) [line 65]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =n$5 [line 65]\n " shape="box"] +50 [label="50: ConditinalStmt Branch \n n$5=_fun_constructor_new::getValue(1:int ) [line 67]\n *&0$?%__sil_tmpSIL_temp_conditional___n$3:int =n$5 [line 67]\n " shape="box"] 50 -> 46 ; -49 [label="49: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 65]\n " shape="invhouse"] +49 [label="49: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 67]\n " shape="invhouse"] 49 -> 51 ; -48 [label="48: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 65]\n " shape="invhouse"] +48 [label="48: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 67]\n " shape="invhouse"] 48 -> 50 ; -47 [label="47: Call _fun_getValue \n n$4=_fun_getValue(0:int ) [line 65]\n " shape="box"] +47 [label="47: Call _fun_constructor_new::getValue \n n$4=_fun_constructor_new::getValue(0:int ) [line 67]\n " shape="box"] 47 -> 48 ; @@ -206,171 +206,171 @@ digraph iCFG { 46 -> 52 ; -45 [label="45: Return Stmt \n n$0=*&x:int * [line 66]\n n$1=*n$0:int [line 66]\n *&return:int =(1 / (n$1 - 5)) [line 66]\n " shape="box"] +45 [label="45: Return Stmt \n n$0=*&x:int * [line 68]\n n$1=*n$0:int [line 68]\n *&return:int =(1 / (n$1 - 5)) [line 68]\n " shape="box"] 45 -> 44 ; -44 [label="44: Exit int_init_nodes \n " color=yellow style=filled] +44 [label="44: Exit constructor_new::int_init_nodes \n " color=yellow style=filled] -43 [label="43: Start int_init_nodes\nFormals: \nLocals: x:int * 0$?%__sil_tmpSIL_temp_conditional___n$3:int y:int * z:int \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_temp_conditional___n$3,&y,&z); [line 62]\n " color=yellow style=filled] +43 [label="43: Start constructor_new::int_init_nodes\nFormals: \nLocals: x:int * 0$?%__sil_tmpSIL_temp_conditional___n$3:int y:int * z:int \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_temp_conditional___n$3,&y,&z); [line 64]\n " color=yellow style=filled] 43 -> 54 ; -42 [label="42: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 58]\n *n$2:int =0 [line 58]\n *&x1:int *=n$2 [line 58]\n " shape="box"] +42 [label="42: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 60]\n *n$2:int =0 [line 60]\n *&x1:int *=n$2 [line 60]\n " shape="box"] 42 -> 41 ; -41 [label="41: Return Stmt \n n$0=*&x1:int * [line 59]\n n$1=*n$0:int [line 59]\n *&return:int =(1 / n$1) [line 59]\n " shape="box"] +41 [label="41: Return Stmt \n n$0=*&x1:int * [line 61]\n n$1=*n$0:int [line 61]\n *&return:int =(1 / n$1) [line 61]\n " shape="box"] 41 -> 40 ; -40 [label="40: Exit int_init_empty_list_new \n " color=yellow style=filled] +40 [label="40: Exit constructor_new::int_init_empty_list_new \n " color=yellow style=filled] -39 [label="39: Start int_init_empty_list_new\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 57]\n " color=yellow style=filled] +39 [label="39: Start constructor_new::int_init_empty_list_new\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 59]\n " color=yellow style=filled] 39 -> 42 ; -38 [label="38: DeclStmt \n *&x1:int =0 [line 53]\n " shape="box"] +38 [label="38: DeclStmt \n *&x1:int =0 [line 55]\n " shape="box"] 38 -> 37 ; -37 [label="37: Return Stmt \n n$0=*&x1:int [line 54]\n *&return:int =(1 / n$0) [line 54]\n " shape="box"] +37 [label="37: Return Stmt \n n$0=*&x1:int [line 56]\n *&return:int =(1 / n$0) [line 56]\n " shape="box"] 37 -> 36 ; -36 [label="36: Exit int_init_empty_list \n " color=yellow style=filled] +36 [label="36: Exit constructor_new::int_init_empty_list \n " color=yellow style=filled] -35 [label="35: Start int_init_empty_list\nFormals: \nLocals: x1:int \n DECLARE_LOCALS(&return,&x1); [line 52]\n " color=yellow style=filled] +35 [label="35: Start constructor_new::int_init_empty_list\nFormals: \nLocals: x1:int \n DECLARE_LOCALS(&return,&x1); [line 54]\n " color=yellow style=filled] 35 -> 38 ; -34 [label="34: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 48]\n *n$2:int =0 [line 48]\n *&x1:int *=n$2 [line 48]\n " shape="box"] +34 [label="34: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 50]\n *n$2:int =0 [line 50]\n *&x1:int *=n$2 [line 50]\n " shape="box"] 34 -> 33 ; -33 [label="33: Return Stmt \n n$0=*&x1:int * [line 49]\n n$1=*n$0:int [line 49]\n *&return:int =(1 / n$1) [line 49]\n " shape="box"] +33 [label="33: Return Stmt \n n$0=*&x1:int * [line 51]\n n$1=*n$0:int [line 51]\n *&return:int =(1 / n$1) [line 51]\n " shape="box"] 33 -> 32 ; -32 [label="32: Exit int_init_empty \n " color=yellow style=filled] +32 [label="32: Exit constructor_new::int_init_empty \n " color=yellow style=filled] -31 [label="31: Start int_init_empty\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 47]\n " color=yellow style=filled] +31 [label="31: Start constructor_new::int_init_empty\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 49]\n " color=yellow style=filled] 31 -> 34 ; -30 [label="30: DeclStmt \n n$2=_fun___new(sizeof(float ):unsigned long ) [line 43]\n *n$2:float =5.400000 [line 43]\n *&x1:float *=n$2 [line 43]\n " shape="box"] +30 [label="30: DeclStmt \n n$2=_fun___new(sizeof(float ):unsigned long ) [line 45]\n *n$2:float =5.400000 [line 45]\n *&x1:float *=n$2 [line 45]\n " shape="box"] 30 -> 29 ; -29 [label="29: Return Stmt \n n$0=*&x1:float * [line 44]\n n$1=*n$0:float [line 44]\n *&return:float =(1 / (n$1 - 5.400000)) [line 44]\n " shape="box"] +29 [label="29: Return Stmt \n n$0=*&x1:float * [line 46]\n n$1=*n$0:float [line 46]\n *&return:float =(1 / (n$1 - 5.400000)) [line 46]\n " shape="box"] 29 -> 28 ; -28 [label="28: Exit float_init_number \n " color=yellow style=filled] +28 [label="28: Exit constructor_new::float_init_number \n " color=yellow style=filled] -27 [label="27: Start float_init_number\nFormals: \nLocals: x1:float * \n DECLARE_LOCALS(&return,&x1); [line 42]\n " color=yellow style=filled] +27 [label="27: Start constructor_new::float_init_number\nFormals: \nLocals: x1:float * \n DECLARE_LOCALS(&return,&x1); [line 44]\n " color=yellow style=filled] 27 -> 30 ; -26 [label="26: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 38]\n *n$2:int =5 [line 38]\n *&x1:int *=n$2 [line 38]\n " shape="box"] +26 [label="26: DeclStmt \n n$2=_fun___new(sizeof(int ):unsigned long ) [line 40]\n *n$2:int =5 [line 40]\n *&x1:int *=n$2 [line 40]\n " shape="box"] 26 -> 25 ; -25 [label="25: Return Stmt \n n$0=*&x1:int * [line 39]\n n$1=*n$0:int [line 39]\n *&return:int =(1 / (n$1 - 5)) [line 39]\n " shape="box"] +25 [label="25: Return Stmt \n n$0=*&x1:int * [line 41]\n n$1=*n$0:int [line 41]\n *&return:int =(1 / (n$1 - 5)) [line 41]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit int_init_number \n " color=yellow style=filled] +24 [label="24: Exit constructor_new::int_init_number \n " color=yellow style=filled] -23 [label="23: Start int_init_number\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 37]\n " color=yellow style=filled] +23 [label="23: Start constructor_new::int_init_number\nFormals: \nLocals: x1:int * \n DECLARE_LOCALS(&return,&x1); [line 39]\n " color=yellow style=filled] 23 -> 26 ; -22 [label="22: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 33]\n _fun_Person_Person(n$2:class Person *,5:int ,6:int ,7:int ) [line 33]\n *&p:class Person *=n$2 [line 33]\n " shape="box"] +22 [label="22: DeclStmt \n n$2=_fun___new(sizeof(class constructor_new::Person ):unsigned long ) [line 35]\n _fun_constructor_new::Person_Person(n$2:class constructor_new::Person *,5:int ,6:int ,7:int ) [line 35]\n *&p:class constructor_new::Person *=n$2 [line 35]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n n$0=*&p:class Person * [line 34]\n n$1=*n$0.z:int [line 34]\n *&return:int =(1 / (n$1 - 7)) [line 34]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&p:class constructor_new::Person * [line 36]\n n$1=*n$0.z:int [line 36]\n *&return:int =(1 / (n$1 - 7)) [line 36]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit constructor_3_args_new_div0 \n " color=yellow style=filled] +20 [label="20: Exit constructor_new::constructor_3_args_new_div0 \n " color=yellow style=filled] -19 [label="19: Start constructor_3_args_new_div0\nFormals: \nLocals: p:class Person * \n DECLARE_LOCALS(&return,&p); [line 32]\n " color=yellow style=filled] +19 [label="19: Start constructor_new::constructor_3_args_new_div0\nFormals: \nLocals: p:class constructor_new::Person * \n DECLARE_LOCALS(&return,&p); [line 34]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: DeclStmt \n n$2=_fun___new(sizeof(class Person ):unsigned long ) [line 28]\n _fun_Person_Person(n$2:class Person *,5:int ) [line 28]\n *&p:class Person *=n$2 [line 28]\n " shape="box"] +18 [label="18: DeclStmt \n n$2=_fun___new(sizeof(class constructor_new::Person ):unsigned long ) [line 30]\n _fun_constructor_new::Person_Person(n$2:class constructor_new::Person *,5:int ) [line 30]\n *&p:class constructor_new::Person *=n$2 [line 30]\n " shape="box"] 18 -> 17 ; -17 [label="17: Return Stmt \n n$0=*&p:class Person * [line 29]\n n$1=*n$0.x:int [line 29]\n *&return:int =(1 / (n$1 - 5)) [line 29]\n " shape="box"] +17 [label="17: Return Stmt \n n$0=*&p:class constructor_new::Person * [line 31]\n n$1=*n$0.x:int [line 31]\n *&return:int =(1 / (n$1 - 5)) [line 31]\n " shape="box"] 17 -> 16 ; -16 [label="16: Exit constructor_1_arg_new_div0 \n " color=yellow style=filled] +16 [label="16: Exit constructor_new::constructor_1_arg_new_div0 \n " color=yellow style=filled] -15 [label="15: Start constructor_1_arg_new_div0\nFormals: \nLocals: p:class Person * \n DECLARE_LOCALS(&return,&p); [line 27]\n " color=yellow style=filled] +15 [label="15: Start constructor_new::constructor_1_arg_new_div0\nFormals: \nLocals: p:class constructor_new::Person * \n DECLARE_LOCALS(&return,&p); [line 29]\n " color=yellow style=filled] 15 -> 18 ; -14 [label="14: Return Stmt \n n$0=*&x:int [line 25]\n *&return:int =n$0 [line 25]\n " shape="box"] +14 [label="14: Return Stmt \n n$0=*&x:int [line 27]\n *&return:int =n$0 [line 27]\n " shape="box"] 14 -> 13 ; -13 [label="13: Exit getValue \n " color=yellow style=filled] +13 [label="13: Exit constructor_new::getValue \n " color=yellow style=filled] -12 [label="12: Start getValue\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +12 [label="12: Start constructor_new::getValue\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] 12 -> 14 ; -11 [label="11: BinaryOperatorStmt: Assign \n n$4=*&this:class Person * [line 16]\n n$5=*&i:int [line 16]\n *n$4.x:int =n$5 [line 16]\n " shape="box"] +11 [label="11: BinaryOperatorStmt: Assign \n n$4=*&this:class constructor_new::Person * [line 18]\n n$5=*&i:int [line 18]\n *n$4.x:int =n$5 [line 18]\n " shape="box"] 11 -> 10 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$2=*&this:class Person * [line 17]\n n$3=*&j:int [line 17]\n *n$2.y:int =n$3 [line 17]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n n$2=*&this:class constructor_new::Person * [line 19]\n n$3=*&j:int [line 19]\n *n$2.y:int =n$3 [line 19]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class Person * [line 18]\n n$1=*&k:int [line 18]\n *n$0.z:int =n$1 [line 18]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class constructor_new::Person * [line 20]\n n$1=*&k:int [line 20]\n *n$0.z:int =n$1 [line 20]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit Person_Person \n " color=yellow style=filled] +8 [label="8: Exit constructor_new::Person_Person \n " color=yellow style=filled] -7 [label="7: Start Person_Person\nFormals: this:class Person * i:int j:int k:int \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +7 [label="7: Start constructor_new::Person_Person\nFormals: this:class constructor_new::Person * i:int j:int k:int \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 7 -> 11 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class Person * [line 13]\n n$1=*&i:int [line 13]\n *n$0.x:int =n$1 [line 13]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class constructor_new::Person * [line 15]\n n$1=*&i:int [line 15]\n *n$0.x:int =n$1 [line 15]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit Person_Person \n " color=yellow style=filled] +5 [label="5: Exit constructor_new::Person_Person \n " color=yellow style=filled] -4 [label="4: Start Person_Person\nFormals: this:class Person * i:int \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +4 [label="4: Start constructor_new::Person_Person\nFormals: this:class constructor_new::Person * i:int \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class Person * [line 12]\n *n$0.x:int =0 [line 12]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class constructor_new::Person * [line 14]\n *n$0.x:int =0 [line 14]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit Person_Person \n " color=yellow style=filled] +2 [label="2: Exit constructor_new::Person_Person \n " color=yellow style=filled] -1 [label="1: Start Person_Person\nFormals: this:class Person *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +1 [label="1: Start constructor_new::Person_Person\nFormals: this:class constructor_new::Person *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp index 76b0a6c87..87e263bd0 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace constructor_with_body { + class X { int f; void init() { f = 0; } @@ -39,3 +41,4 @@ void test_div1() { X x(0, 1); x.div(); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp.dot index 6bf637b22..d5c0c6b2d 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp.dot @@ -1,99 +1,99 @@ /* @generated */ digraph iCFG { -26 [label="26: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:int ) [line 39]\n " shape="box"] +26 [label="26: DeclStmt \n _fun_constructor_with_body::X_X(&x:class constructor_with_body::X *,0:int ,1:int ) [line 41]\n " shape="box"] 26 -> 25 ; -25 [label="25: Call _fun_X_div \n _=*&x:class X [line 40]\n n$1=_fun_X_div(&x:class X &) [line 40]\n " shape="box"] +25 [label="25: Call _fun_constructor_with_body::X_div \n _=*&x:class constructor_with_body::X [line 42]\n n$1=_fun_constructor_with_body::X_div(&x:class constructor_with_body::X &) [line 42]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit test_div1 \n " color=yellow style=filled] +24 [label="24: Exit constructor_with_body::test_div1 \n " color=yellow style=filled] -23 [label="23: Start test_div1\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 38]\n " color=yellow style=filled] +23 [label="23: Start constructor_with_body::test_div1\nFormals: \nLocals: x:class constructor_with_body::X \n DECLARE_LOCALS(&return,&x); [line 40]\n " color=yellow style=filled] 23 -> 26 ; -22 [label="22: DeclStmt \n _fun_X_X(&x:class X *) [line 34]\n " shape="box"] +22 [label="22: DeclStmt \n _fun_constructor_with_body::X_X(&x:class constructor_with_body::X *) [line 36]\n " shape="box"] 22 -> 21 ; -21 [label="21: Call _fun_X_div \n _=*&x:class X [line 35]\n n$1=_fun_X_div(&x:class X &) [line 35]\n " shape="box"] +21 [label="21: Call _fun_constructor_with_body::X_div \n _=*&x:class constructor_with_body::X [line 37]\n n$1=_fun_constructor_with_body::X_div(&x:class constructor_with_body::X &) [line 37]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit test_div0_default_constructor \n " color=yellow style=filled] +20 [label="20: Exit constructor_with_body::test_div0_default_constructor \n " color=yellow style=filled] -19 [label="19: Start test_div0_default_constructor\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 33]\n " color=yellow style=filled] +19 [label="19: Start constructor_with_body::test_div0_default_constructor\nFormals: \nLocals: x:class constructor_with_body::X \n DECLARE_LOCALS(&return,&x); [line 35]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: DeclStmt \n _fun_X_X(&x:class X *,-2:int ,2:int ) [line 29]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_constructor_with_body::X_X(&x:class constructor_with_body::X *,-2:int ,2:int ) [line 31]\n " shape="box"] 18 -> 17 ; -17 [label="17: Call _fun_X_div \n _=*&x:class X [line 30]\n n$1=_fun_X_div(&x:class X &) [line 30]\n " shape="box"] +17 [label="17: Call _fun_constructor_with_body::X_div \n _=*&x:class constructor_with_body::X [line 32]\n n$1=_fun_constructor_with_body::X_div(&x:class constructor_with_body::X &) [line 32]\n " shape="box"] 17 -> 16 ; -16 [label="16: Exit test_div0 \n " color=yellow style=filled] +16 [label="16: Exit constructor_with_body::test_div0 \n " color=yellow style=filled] -15 [label="15: Start test_div0\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 28]\n " color=yellow style=filled] +15 [label="15: Start constructor_with_body::test_div0\nFormals: \nLocals: x:class constructor_with_body::X \n DECLARE_LOCALS(&return,&x); [line 30]\n " color=yellow style=filled] 15 -> 18 ; -14 [label="14: DeclStmt \n n$4=*&a:int [line 23]\n n$5=*&b:int [line 23]\n *&c:int =(n$4 + n$5) [line 23]\n " shape="box"] +14 [label="14: DeclStmt \n n$4=*&a:int [line 25]\n n$5=*&b:int [line 25]\n *&c:int =(n$4 + n$5) [line 25]\n " shape="box"] 14 -> 13 ; -13 [label="13: Call _fun_X_init \n n$2=*&this:class X * [line 24]\n _=*n$2:class X [line 24]\n _fun_X_init(n$2:class X *) [line 24]\n " shape="box"] +13 [label="13: Call _fun_constructor_with_body::X_init \n n$2=*&this:class constructor_with_body::X * [line 26]\n _=*n$2:class constructor_with_body::X [line 26]\n _fun_constructor_with_body::X_init(n$2:class constructor_with_body::X *) [line 26]\n " shape="box"] 13 -> 12 ; -12 [label="12: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 25]\n n$1=*&c:int [line 25]\n *n$0.f:int =n$1 [line 25]\n " shape="box"] +12 [label="12: BinaryOperatorStmt: Assign \n n$0=*&this:class constructor_with_body::X * [line 27]\n n$1=*&c:int [line 27]\n *n$0.f:int =n$1 [line 27]\n " shape="box"] 12 -> 11 ; -11 [label="11: Exit X_X \n " color=yellow style=filled] +11 [label="11: Exit constructor_with_body::X_X \n " color=yellow style=filled] -10 [label="10: Start X_X\nFormals: this:class X * a:int b:int \nLocals: c:int \n DECLARE_LOCALS(&return,&c); [line 22]\n " color=yellow style=filled] +10 [label="10: Start constructor_with_body::X_X\nFormals: this:class constructor_with_body::X * a:int b:int \nLocals: c:int \n DECLARE_LOCALS(&return,&c); [line 24]\n " color=yellow style=filled] 10 -> 14 ; -9 [label="9: Return Stmt \n n$0=*&this:class X * [line 19]\n n$1=*n$0.f:int [line 19]\n *&return:int =(1 / n$1) [line 19]\n " shape="box"] +9 [label="9: Return Stmt \n n$0=*&this:class constructor_with_body::X * [line 21]\n n$1=*n$0.f:int [line 21]\n *&return:int =(1 / n$1) [line 21]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit X_div \n " color=yellow style=filled] +8 [label="8: Exit constructor_with_body::X_div \n " color=yellow style=filled] -7 [label="7: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +7 [label="7: Start constructor_with_body::X_div\nFormals: this:class constructor_with_body::X *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Call _fun_X_init \n n$0=*&this:class X * [line 15]\n _=*n$0:class X [line 15]\n _fun_X_init(n$0:class X *) [line 15]\n " shape="box"] +6 [label="6: Call _fun_constructor_with_body::X_init \n n$0=*&this:class constructor_with_body::X * [line 17]\n _=*n$0:class constructor_with_body::X [line 17]\n _fun_constructor_with_body::X_init(n$0:class constructor_with_body::X *) [line 17]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit X_X \n " color=yellow style=filled] +5 [label="5: Exit constructor_with_body::X_X \n " color=yellow style=filled] -4 [label="4: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +4 [label="4: Start constructor_with_body::X_X\nFormals: this:class constructor_with_body::X *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 12]\n *n$0.f:int =0 [line 12]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class constructor_with_body::X * [line 14]\n *n$0.f:int =0 [line 14]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_init \n " color=yellow style=filled] +2 [label="2: Exit constructor_with_body::X_init \n " color=yellow style=filled] -1 [label="1: Start X_init\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +1 [label="1: Start constructor_with_body::X_init\nFormals: this:class constructor_with_body::X *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp index c73ee6c36..ae3a922fc 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace copy_move_constructor { + // NOTE: that test will break if we start doing copy elision // will have default copy/move constructors - used to test // whether they get translated correctly @@ -77,3 +79,4 @@ int copyY_moveY_div1() { int d2 = 1 / getY(2).f; return d1 + d2; } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp.dot index 3a6ad8b7f..2bafdf0f6 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp.dot @@ -1,247 +1,247 @@ /* @generated */ digraph iCFG { -65 [label="65: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 73]\n " shape="box"] +65 [label="65: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y1:class copy_move_constructor::Y *) [line 75]\n " shape="box"] 65 -> 64 ; -64 [label="64: BinaryOperatorStmt: Assign \n *&y1.f:int =1 [line 74]\n " shape="box"] +64 [label="64: BinaryOperatorStmt: Assign \n *&y1.f:int =1 [line 76]\n " shape="box"] 64 -> 63 ; -63 [label="63: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 75]\n " shape="box"] +63 [label="63: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y2:class copy_move_constructor::Y *,&y1:class copy_move_constructor::Y &) [line 77]\n " shape="box"] 63 -> 62 ; -62 [label="62: DeclStmt \n n$5=*&y2.f:int [line 76]\n *&d1:int =(1 / n$5) [line 76]\n " shape="box"] +62 [label="62: DeclStmt \n n$5=*&y2.f:int [line 78]\n *&d1:int =(1 / n$5) [line 78]\n " shape="box"] 62 -> 61 ; -61 [label="61: DeclStmt \n _fun_getY(2:int ,&0$?%__sil_tmp__temp_return_n$3:class Y *) [line 77]\n n$4=*&0$?%__sil_tmp__temp_return_n$3.f:int [line 77]\n *&d2:int =(1 / n$4) [line 77]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_copy_move_constructor::getY(2:int ,&0$?%__sil_tmp__temp_return_n$3:class copy_move_constructor::Y *) [line 79]\n n$4=*&0$?%__sil_tmp__temp_return_n$3.f:int [line 79]\n *&d2:int =(1 / n$4) [line 79]\n " shape="box"] 61 -> 60 ; -60 [label="60: Return Stmt \n n$0=*&d1:int [line 78]\n n$1=*&d2:int [line 78]\n *&return:int =(n$0 + n$1) [line 78]\n " shape="box"] +60 [label="60: Return Stmt \n n$0=*&d1:int [line 80]\n n$1=*&d2:int [line 80]\n *&return:int =(n$0 + n$1) [line 80]\n " shape="box"] 60 -> 59 ; -59 [label="59: Exit copyY_moveY_div1 \n " color=yellow style=filled] +59 [label="59: Exit copy_move_constructor::copyY_moveY_div1 \n " color=yellow style=filled] -58 [label="58: Start copyY_moveY_div1\nFormals: \nLocals: d2:int 0$?%__sil_tmp__temp_return_n$3:class Y d1:int y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&d2,&0$?%__sil_tmp__temp_return_n$3,&d1,&y2,&y1); [line 72]\n " color=yellow style=filled] +58 [label="58: Start copy_move_constructor::copyY_moveY_div1\nFormals: \nLocals: d2:int 0$?%__sil_tmp__temp_return_n$3:class copy_move_constructor::Y d1:int y2:class copy_move_constructor::Y y1:class copy_move_constructor::Y \n DECLARE_LOCALS(&return,&d2,&0$?%__sil_tmp__temp_return_n$3,&d1,&y2,&y1); [line 74]\n " color=yellow style=filled] 58 -> 65 ; -57 [label="57: DeclStmt \n _fun_X_X(&x1:class X *) [line 64]\n " shape="box"] +57 [label="57: DeclStmt \n _fun_copy_move_constructor::X_X(&x1:class copy_move_constructor::X *) [line 66]\n " shape="box"] 57 -> 56 ; -56 [label="56: BinaryOperatorStmt: Assign \n *&x1.f:int =1 [line 65]\n " shape="box"] +56 [label="56: BinaryOperatorStmt: Assign \n *&x1.f:int =1 [line 67]\n " shape="box"] 56 -> 55 ; -55 [label="55: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 66]\n " shape="box"] +55 [label="55: DeclStmt \n _fun_copy_move_constructor::X_X(&x2:class copy_move_constructor::X *,&x1:class copy_move_constructor::X &) [line 68]\n " shape="box"] 55 -> 54 ; -54 [label="54: DeclStmt \n n$5=*&x2.f:int [line 67]\n *&d1:int =(1 / n$5) [line 67]\n " shape="box"] +54 [label="54: DeclStmt \n n$5=*&x2.f:int [line 69]\n *&d1:int =(1 / n$5) [line 69]\n " shape="box"] 54 -> 53 ; -53 [label="53: DeclStmt \n _fun_getX(1:int ,&0$?%__sil_tmp__temp_return_n$3:class X *) [line 68]\n n$4=*&0$?%__sil_tmp__temp_return_n$3.f:int [line 68]\n *&d2:int =(1 / n$4) [line 68]\n " shape="box"] +53 [label="53: DeclStmt \n _fun_copy_move_constructor::getX(1:int ,&0$?%__sil_tmp__temp_return_n$3:class copy_move_constructor::X *) [line 70]\n n$4=*&0$?%__sil_tmp__temp_return_n$3.f:int [line 70]\n *&d2:int =(1 / n$4) [line 70]\n " shape="box"] 53 -> 52 ; -52 [label="52: Return Stmt \n n$0=*&d1:int [line 69]\n n$1=*&d2:int [line 69]\n *&return:int =(n$0 + n$1) [line 69]\n " shape="box"] +52 [label="52: Return Stmt \n n$0=*&d1:int [line 71]\n n$1=*&d2:int [line 71]\n *&return:int =(n$0 + n$1) [line 71]\n " shape="box"] 52 -> 51 ; -51 [label="51: Exit copyX_moveX_div1 \n " color=yellow style=filled] +51 [label="51: Exit copy_move_constructor::copyX_moveX_div1 \n " color=yellow style=filled] -50 [label="50: Start copyX_moveX_div1\nFormals: \nLocals: d2:int 0$?%__sil_tmp__temp_return_n$3:class X d1:int x2:class X x1:class X \n DECLARE_LOCALS(&return,&d2,&0$?%__sil_tmp__temp_return_n$3,&d1,&x2,&x1); [line 63]\n " color=yellow style=filled] +50 [label="50: Start copy_move_constructor::copyX_moveX_div1\nFormals: \nLocals: d2:int 0$?%__sil_tmp__temp_return_n$3:class copy_move_constructor::X d1:int x2:class copy_move_constructor::X x1:class copy_move_constructor::X \n DECLARE_LOCALS(&return,&d2,&0$?%__sil_tmp__temp_return_n$3,&d1,&x2,&x1); [line 65]\n " color=yellow style=filled] 50 -> 57 ; -49 [label="49: DeclStmt \n _fun_getY(2:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class Y *) [line 58]\n _fun_Y_Y(&y1:class Y *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class Y &) [line 58]\n " shape="box"] +49 [label="49: DeclStmt \n _fun_copy_move_constructor::getY(2:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class copy_move_constructor::Y *) [line 60]\n _fun_copy_move_constructor::Y_Y(&y1:class copy_move_constructor::Y *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class copy_move_constructor::Y &) [line 60]\n " shape="box"] 49 -> 48 ; -48 [label="48: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 59]\n " shape="box"] +48 [label="48: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y2:class copy_move_constructor::Y *,&y1:class copy_move_constructor::Y &) [line 61]\n " shape="box"] 48 -> 47 ; -47 [label="47: Return Stmt \n n$0=*&y2.f:int [line 60]\n *&return:int =(1 / n$0) [line 60]\n " shape="box"] +47 [label="47: Return Stmt \n n$0=*&y2.f:int [line 62]\n *&return:int =(1 / n$0) [line 62]\n " shape="box"] 47 -> 46 ; -46 [label="46: Exit moveY_moveY_copyY_div0 \n " color=yellow style=filled] +46 [label="46: Exit copy_move_constructor::moveY_moveY_copyY_div0 \n " color=yellow style=filled] -45 [label="45: Start moveY_moveY_copyY_div0\nFormals: \nLocals: y2:class Y y1:class Y 0$?%__sil_tmpSIL_materialize_temp__n$1:class Y \n DECLARE_LOCALS(&return,&y2,&y1,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 57]\n " color=yellow style=filled] +45 [label="45: Start copy_move_constructor::moveY_moveY_copyY_div0\nFormals: \nLocals: y2:class copy_move_constructor::Y y1:class copy_move_constructor::Y 0$?%__sil_tmpSIL_materialize_temp__n$1:class copy_move_constructor::Y \n DECLARE_LOCALS(&return,&y2,&y1,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 59]\n " color=yellow style=filled] 45 -> 49 ; -44 [label="44: Return Stmt \n _fun_getY(1:int ,&0$?%__sil_tmp__temp_return_n$1:class Y *) [line 55]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 55]\n *&return:int =(1 / n$2) [line 55]\n " shape="box"] +44 [label="44: Return Stmt \n _fun_copy_move_constructor::getY(1:int ,&0$?%__sil_tmp__temp_return_n$1:class copy_move_constructor::Y *) [line 57]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 57]\n *&return:int =(1 / n$2) [line 57]\n " shape="box"] 44 -> 43 ; -43 [label="43: Exit moveY_div0 \n " color=yellow style=filled] +43 [label="43: Exit copy_move_constructor::moveY_div0 \n " color=yellow style=filled] -42 [label="42: Start moveY_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class Y \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 55]\n " color=yellow style=filled] +42 [label="42: Start copy_move_constructor::moveY_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class copy_move_constructor::Y \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 57]\n " color=yellow style=filled] 42 -> 44 ; -41 [label="41: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 49]\n " shape="box"] +41 [label="41: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y1:class copy_move_constructor::Y *) [line 51]\n " shape="box"] 41 -> 40 ; -40 [label="40: BinaryOperatorStmt: Assign \n *&y1.f:int =0 [line 50]\n " shape="box"] +40 [label="40: BinaryOperatorStmt: Assign \n *&y1.f:int =0 [line 52]\n " shape="box"] 40 -> 39 ; -39 [label="39: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 51]\n " shape="box"] +39 [label="39: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y2:class copy_move_constructor::Y *,&y1:class copy_move_constructor::Y &) [line 53]\n " shape="box"] 39 -> 38 ; -38 [label="38: Return Stmt \n n$0=*&y2.f:int [line 52]\n *&return:int =(1 / n$0) [line 52]\n " shape="box"] +38 [label="38: Return Stmt \n n$0=*&y2.f:int [line 54]\n *&return:int =(1 / n$0) [line 54]\n " shape="box"] 38 -> 37 ; -37 [label="37: Exit copyY_div0 \n " color=yellow style=filled] +37 [label="37: Exit copy_move_constructor::copyY_div0 \n " color=yellow style=filled] -36 [label="36: Start copyY_div0\nFormals: \nLocals: y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&y2,&y1); [line 48]\n " color=yellow style=filled] +36 [label="36: Start copy_move_constructor::copyY_div0\nFormals: \nLocals: y2:class copy_move_constructor::Y y1:class copy_move_constructor::Y \n DECLARE_LOCALS(&return,&y2,&y1); [line 50]\n " color=yellow style=filled] 36 -> 41 ; -35 [label="35: Return Stmt \n _fun_getX(0:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 46]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 46]\n *&return:int =(1 / n$2) [line 46]\n " shape="box"] +35 [label="35: Return Stmt \n _fun_copy_move_constructor::getX(0:int ,&0$?%__sil_tmp__temp_return_n$1:class copy_move_constructor::X *) [line 48]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 48]\n *&return:int =(1 / n$2) [line 48]\n " shape="box"] 35 -> 34 ; -34 [label="34: Exit moveX_div0 \n " color=yellow style=filled] +34 [label="34: Exit copy_move_constructor::moveX_div0 \n " color=yellow style=filled] -33 [label="33: Start moveX_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 46]\n " color=yellow style=filled] +33 [label="33: Start copy_move_constructor::moveX_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class copy_move_constructor::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 48]\n " color=yellow style=filled] 33 -> 35 ; -32 [label="32: DeclStmt \n _fun_X_X(&x1:class X *) [line 40]\n " shape="box"] +32 [label="32: DeclStmt \n _fun_copy_move_constructor::X_X(&x1:class copy_move_constructor::X *) [line 42]\n " shape="box"] 32 -> 31 ; -31 [label="31: BinaryOperatorStmt: Assign \n *&x1.f:int =0 [line 41]\n " shape="box"] +31 [label="31: BinaryOperatorStmt: Assign \n *&x1.f:int =0 [line 43]\n " shape="box"] 31 -> 30 ; -30 [label="30: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 42]\n " shape="box"] +30 [label="30: DeclStmt \n _fun_copy_move_constructor::X_X(&x2:class copy_move_constructor::X *,&x1:class copy_move_constructor::X &) [line 44]\n " shape="box"] 30 -> 29 ; -29 [label="29: Return Stmt \n n$0=*&x2.f:int [line 43]\n *&return:int =(1 / n$0) [line 43]\n " shape="box"] +29 [label="29: Return Stmt \n n$0=*&x2.f:int [line 45]\n *&return:int =(1 / n$0) [line 45]\n " shape="box"] 29 -> 28 ; -28 [label="28: Exit copyX_div0 \n " color=yellow style=filled] +28 [label="28: Exit copy_move_constructor::copyX_div0 \n " color=yellow style=filled] -27 [label="27: Start copyX_div0\nFormals: \nLocals: x2:class X x1:class X \n DECLARE_LOCALS(&return,&x2,&x1); [line 39]\n " color=yellow style=filled] +27 [label="27: Start copy_move_constructor::copyX_div0\nFormals: \nLocals: x2:class copy_move_constructor::X x1:class copy_move_constructor::X \n DECLARE_LOCALS(&return,&x2,&x1); [line 41]\n " color=yellow style=filled] 27 -> 32 ; -26 [label="26: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 34]\n " shape="box"] +26 [label="26: DeclStmt \n _fun_copy_move_constructor::Y_Y(&y:class copy_move_constructor::Y *) [line 36]\n " shape="box"] 26 -> 25 ; -25 [label="25: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 35]\n *&y.f:int =n$1 [line 35]\n " shape="box"] +25 [label="25: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 37]\n *&y.f:int =n$1 [line 37]\n " shape="box"] 25 -> 24 ; -24 [label="24: Return Stmt \n n$0=*&__return_param:class Y * [line 36]\n _fun_Y_Y(n$0:class Y *,&y:class Y &) [line 36]\n " shape="box"] +24 [label="24: Return Stmt \n n$0=*&__return_param:class copy_move_constructor::Y * [line 38]\n _fun_copy_move_constructor::Y_Y(n$0:class copy_move_constructor::Y *,&y:class copy_move_constructor::Y &) [line 38]\n " shape="box"] 24 -> 23 ; -23 [label="23: Exit getY \n " color=yellow style=filled] +23 [label="23: Exit copy_move_constructor::getY \n " color=yellow style=filled] -22 [label="22: Start getY\nFormals: f:int __return_param:class Y *\nLocals: y:class Y \n DECLARE_LOCALS(&return,&y); [line 33]\n " color=yellow style=filled] +22 [label="22: Start copy_move_constructor::getY\nFormals: f:int __return_param:class copy_move_constructor::Y *\nLocals: y:class copy_move_constructor::Y \n DECLARE_LOCALS(&return,&y); [line 35]\n " color=yellow style=filled] 22 -> 26 ; -21 [label="21: DeclStmt \n _fun_X_X(&x:class X *) [line 28]\n " shape="box"] +21 [label="21: DeclStmt \n _fun_copy_move_constructor::X_X(&x:class copy_move_constructor::X *) [line 30]\n " shape="box"] 21 -> 20 ; -20 [label="20: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 29]\n *&x.f:int =n$1 [line 29]\n " shape="box"] +20 [label="20: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 31]\n *&x.f:int =n$1 [line 31]\n " shape="box"] 20 -> 19 ; -19 [label="19: Return Stmt \n n$0=*&__return_param:class X * [line 30]\n _fun_X_X(n$0:class X *,&x:class X &) [line 30]\n " shape="box"] +19 [label="19: Return Stmt \n n$0=*&__return_param:class copy_move_constructor::X * [line 32]\n _fun_copy_move_constructor::X_X(n$0:class copy_move_constructor::X *,&x:class copy_move_constructor::X &) [line 32]\n " shape="box"] 19 -> 18 ; -18 [label="18: Exit getX \n " color=yellow style=filled] +18 [label="18: Exit copy_move_constructor::getX \n " color=yellow style=filled] -17 [label="17: Start getX\nFormals: f:int __return_param:class X *\nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 27]\n " color=yellow style=filled] +17 [label="17: Start copy_move_constructor::getX\nFormals: f:int __return_param:class copy_move_constructor::X *\nLocals: x:class copy_move_constructor::X \n DECLARE_LOCALS(&return,&x); [line 29]\n " color=yellow style=filled] 17 -> 21 ; -16 [label="16: Constructor Init \n n$0=*&this:class Y * [line 24]\n n$1=*&y:class Y & [line 24]\n n$2=*n$1.f:int [line 24]\n *n$0.f:int =(n$2 - 1) [line 24]\n " shape="box"] +16 [label="16: Constructor Init \n n$0=*&this:class copy_move_constructor::Y * [line 26]\n n$1=*&y:class copy_move_constructor::Y & [line 26]\n n$2=*n$1.f:int [line 26]\n *n$0.f:int =(n$2 - 1) [line 26]\n " shape="box"] 16 -> 15 ; -15 [label="15: Exit Y_Y \n " color=yellow style=filled] +15 [label="15: Exit copy_move_constructor::Y_Y \n " color=yellow style=filled] -14 [label="14: Start Y_Y\nFormals: this:class Y * y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +14 [label="14: Start copy_move_constructor::Y_Y\nFormals: this:class copy_move_constructor::Y * y:class copy_move_constructor::Y &\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 14 -> 16 ; -13 [label="13: Constructor Init \n n$0=*&this:class Y * [line 22]\n n$1=*&y:class Y & [line 22]\n n$2=*n$1.f:int [line 22]\n *n$0.f:int =n$2 [line 22]\n " shape="box"] +13 [label="13: Constructor Init \n n$0=*&this:class copy_move_constructor::Y * [line 24]\n n$1=*&y:class copy_move_constructor::Y & [line 24]\n n$2=*n$1.f:int [line 24]\n *n$0.f:int =n$2 [line 24]\n " shape="box"] 13 -> 12 ; -12 [label="12: Exit Y_Y \n " color=yellow style=filled] +12 [label="12: Exit copy_move_constructor::Y_Y \n " color=yellow style=filled] -11 [label="11: Start Y_Y\nFormals: this:class Y * y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] +11 [label="11: Start copy_move_constructor::Y_Y\nFormals: this:class copy_move_constructor::Y * y:class copy_move_constructor::Y &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: Exit Y_Y \n " color=yellow style=filled] +10 [label="10: Exit copy_move_constructor::Y_Y \n " color=yellow style=filled] -9 [label="9: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +9 [label="9: Start copy_move_constructor::Y_Y\nFormals: this:class copy_move_constructor::Y *\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] 9 -> 10 ; -8 [label="8: Constructor Init \n n$0=*&this:class X * [line 13]\n n$1=*&__param_0:class X & [line 13]\n n$2=*n$1.f:int [line 13]\n *n$0.f:int =n$2 [line 13]\n " shape="box"] +8 [label="8: Constructor Init \n n$0=*&this:class copy_move_constructor::X * [line 15]\n n$1=*&__param_0:class copy_move_constructor::X & [line 15]\n n$2=*n$1.f:int [line 15]\n *n$0.f:int =n$2 [line 15]\n " shape="box"] 8 -> 7 ; -7 [label="7: Exit X_X \n " color=yellow style=filled] +7 [label="7: Exit copy_move_constructor::X_X \n " color=yellow style=filled] -6 [label="6: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +6 [label="6: Start copy_move_constructor::X_X\nFormals: this:class copy_move_constructor::X * __param_0:class copy_move_constructor::X &\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: Constructor Init \n n$0=*&this:class X * [line 13]\n n$1=*&__param_0:class X & [line 13]\n n$2=*n$1.f:int [line 13]\n *n$0.f:int =n$2 [line 13]\n " shape="box"] +5 [label="5: Constructor Init \n n$0=*&this:class copy_move_constructor::X * [line 15]\n n$1=*&__param_0:class copy_move_constructor::X & [line 15]\n n$2=*n$1.f:int [line 15]\n *n$0.f:int =n$2 [line 15]\n " shape="box"] 5 -> 4 ; -4 [label="4: Exit X_X \n " color=yellow style=filled] +4 [label="4: Exit copy_move_constructor::X_X \n " color=yellow style=filled] -3 [label="3: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +3 [label="3: Start copy_move_constructor::X_X\nFormals: this:class copy_move_constructor::X * __param_0:class copy_move_constructor::X &\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 3 -> 5 ; -2 [label="2: Exit X_X \n " color=yellow style=filled] +2 [label="2: Exit copy_move_constructor::X_X \n " color=yellow style=filled] -1 [label="1: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +1 [label="1: Start copy_move_constructor::X_X\nFormals: this:class copy_move_constructor::X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 1 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp index 3fc58761f..af32bef86 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace temp_object { + struct X { X(int a) { f = a; } X(int a, int b) { f = a; } @@ -41,3 +43,4 @@ int getX_method_div0() { return getX(0, 1).div(); } int temp_field_div1() { return div(X(1, 0).f); } int getX_field_div1() { return div(getX(1, 0).f); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot index 30d03e2dc..db1bdc83f 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot @@ -1,160 +1,160 @@ /* @generated */ digraph iCFG { -43 [label="43: Return Stmt \n _fun_getX(1:int ,0:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 43]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 43]\n n$3=_fun_div(n$2:int ) [line 43]\n *&return:int =n$3 [line 43]\n " shape="box"] +43 [label="43: Return Stmt \n _fun_temp_object::getX(1:int ,0:int ,&0$?%__sil_tmp__temp_return_n$1:class temp_object::X *) [line 45]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 45]\n n$3=_fun_temp_object::div(n$2:int ) [line 45]\n *&return:int =n$3 [line 45]\n " shape="box"] 43 -> 42 ; -42 [label="42: Exit getX_field_div1 \n " color=yellow style=filled] +42 [label="42: Exit temp_object::getX_field_div1 \n " color=yellow style=filled] -41 [label="41: Start getX_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 43]\n " color=yellow style=filled] +41 [label="41: Start temp_object::getX_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 45]\n " color=yellow style=filled] 41 -> 43 ; -40 [label="40: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,1:int ,0:int ) [line 41]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 41]\n n$2=_fun_div(n$1:int ) [line 41]\n *&return:int =n$2 [line 41]\n " shape="box"] +40 [label="40: Return Stmt \n _fun_temp_object::X_X(&0$?%__sil_tmp__temp_construct_n$0:class temp_object::X *,1:int ,0:int ) [line 43]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 43]\n n$2=_fun_temp_object::div(n$1:int ) [line 43]\n *&return:int =n$2 [line 43]\n " shape="box"] 40 -> 39 ; -39 [label="39: Exit temp_field_div1 \n " color=yellow style=filled] +39 [label="39: Exit temp_object::temp_field_div1 \n " color=yellow style=filled] -38 [label="38: Start temp_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 41]\n " color=yellow style=filled] +38 [label="38: Start temp_object::temp_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 43]\n " color=yellow style=filled] 38 -> 40 ; -37 [label="37: Return Stmt \n _fun_getX(0:int ,1:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 39]\n n$2=_fun_X_div(&0$?%__sil_tmp__temp_return_n$1:class X &) [line 39]\n *&return:int =n$2 [line 39]\n " shape="box"] +37 [label="37: Return Stmt \n _fun_temp_object::getX(0:int ,1:int ,&0$?%__sil_tmp__temp_return_n$1:class temp_object::X *) [line 41]\n n$2=_fun_temp_object::X_div(&0$?%__sil_tmp__temp_return_n$1:class temp_object::X &) [line 41]\n *&return:int =n$2 [line 41]\n " shape="box"] 37 -> 36 ; -36 [label="36: Exit getX_method_div0 \n " color=yellow style=filled] +36 [label="36: Exit temp_object::getX_method_div0 \n " color=yellow style=filled] -35 [label="35: Start getX_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 39]\n " color=yellow style=filled] +35 [label="35: Start temp_object::getX_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 41]\n " color=yellow style=filled] 35 -> 37 ; -34 [label="34: Return Stmt \n _fun_getX(0:int ,1:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 37]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 37]\n n$3=_fun_div(n$2:int ) [line 37]\n *&return:int =n$3 [line 37]\n " shape="box"] +34 [label="34: Return Stmt \n _fun_temp_object::getX(0:int ,1:int ,&0$?%__sil_tmp__temp_return_n$1:class temp_object::X *) [line 39]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 39]\n n$3=_fun_temp_object::div(n$2:int ) [line 39]\n *&return:int =n$3 [line 39]\n " shape="box"] 34 -> 33 ; -33 [label="33: Exit getX_field_div0 \n " color=yellow style=filled] +33 [label="33: Exit temp_object::getX_field_div0 \n " color=yellow style=filled] -32 [label="32: Start getX_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 37]\n " color=yellow style=filled] +32 [label="32: Start temp_object::getX_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 39]\n " color=yellow style=filled] 32 -> 34 ; -31 [label="31: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,0:int ,1:int ) [line 35]\n n$1=_fun_X_div(&0$?%__sil_tmp__temp_construct_n$0:class X &) [line 35]\n *&return:int =n$1 [line 35]\n " shape="box"] +31 [label="31: Return Stmt \n _fun_temp_object::X_X(&0$?%__sil_tmp__temp_construct_n$0:class temp_object::X *,0:int ,1:int ) [line 37]\n n$1=_fun_temp_object::X_div(&0$?%__sil_tmp__temp_construct_n$0:class temp_object::X &) [line 37]\n *&return:int =n$1 [line 37]\n " shape="box"] 31 -> 30 ; -30 [label="30: Exit temp_method_div0 \n " color=yellow style=filled] +30 [label="30: Exit temp_object::temp_method_div0 \n " color=yellow style=filled] -29 [label="29: Start temp_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 35]\n " color=yellow style=filled] +29 [label="29: Start temp_object::temp_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 37]\n " color=yellow style=filled] 29 -> 31 ; -28 [label="28: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,0:int ) [line 33]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 33]\n n$2=_fun_div(n$1:int ) [line 33]\n *&return:int =n$2 [line 33]\n " shape="box"] +28 [label="28: Return Stmt \n _fun_temp_object::X_X(&0$?%__sil_tmp__temp_construct_n$0:class temp_object::X *,0:int ) [line 35]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 35]\n n$2=_fun_temp_object::div(n$1:int ) [line 35]\n *&return:int =n$2 [line 35]\n " shape="box"] 28 -> 27 ; -27 [label="27: Exit temp_field2_div0 \n " color=yellow style=filled] +27 [label="27: Exit temp_object::temp_field2_div0 \n " color=yellow style=filled] -26 [label="26: Start temp_field2_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 33]\n " color=yellow style=filled] +26 [label="26: Start temp_object::temp_field2_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 35]\n " color=yellow style=filled] 26 -> 28 ; -25 [label="25: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,0:int ,1:int ) [line 31]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 31]\n n$2=_fun_div(n$1:int ) [line 31]\n *&return:int =n$2 [line 31]\n " shape="box"] +25 [label="25: Return Stmt \n _fun_temp_object::X_X(&0$?%__sil_tmp__temp_construct_n$0:class temp_object::X *,0:int ,1:int ) [line 33]\n n$1=*&0$?%__sil_tmp__temp_construct_n$0.f:int [line 33]\n n$2=_fun_temp_object::div(n$1:int ) [line 33]\n *&return:int =n$2 [line 33]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit temp_field_div0 \n " color=yellow style=filled] +24 [label="24: Exit temp_object::temp_field_div0 \n " color=yellow style=filled] -23 [label="23: Start temp_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 31]\n " color=yellow style=filled] +23 [label="23: Start temp_object::temp_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0); [line 33]\n " color=yellow style=filled] 23 -> 25 ; -22 [label="22: DeclStmt \n _fun_X_X(&0$?%__sil_tmpSIL_materialize_temp__n$2:class X *,0:int ,1:int ) [line 27]\n _fun_X_X(&x:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$2:class X &) [line 27]\n " shape="box"] +22 [label="22: DeclStmt \n _fun_temp_object::X_X(&0$?%__sil_tmpSIL_materialize_temp__n$2:class temp_object::X *,0:int ,1:int ) [line 29]\n _fun_temp_object::X_X(&x:class temp_object::X *,&0$?%__sil_tmpSIL_materialize_temp__n$2:class temp_object::X &) [line 29]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n _=*&x:class X [line 28]\n n$1=_fun_X_div(&x:class X &) [line 28]\n *&return:int =n$1 [line 28]\n " shape="box"] +21 [label="21: Return Stmt \n _=*&x:class temp_object::X [line 30]\n n$1=_fun_temp_object::X_div(&x:class temp_object::X &) [line 30]\n *&return:int =n$1 [line 30]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit assign_temp_div0 \n " color=yellow style=filled] +20 [label="20: Exit temp_object::assign_temp_div0 \n " color=yellow style=filled] -19 [label="19: Start assign_temp_div0\nFormals: \nLocals: x:class X 0$?%__sil_tmpSIL_materialize_temp__n$2:class X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$2); [line 26]\n " color=yellow style=filled] +19 [label="19: Start temp_object::assign_temp_div0\nFormals: \nLocals: x:class temp_object::X 0$?%__sil_tmpSIL_materialize_temp__n$2:class temp_object::X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$2); [line 28]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: Return Stmt \n n$0=*&__return_param:class X * [line 24]\n n$2=*&a:int [line 24]\n n$3=*&b:int [line 24]\n _fun_X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *,n$2:int ,n$3:int ) [line 24]\n _fun_X_X(n$0:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 24]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&__return_param:class temp_object::X * [line 26]\n n$2=*&a:int [line 26]\n n$3=*&b:int [line 26]\n _fun_temp_object::X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class temp_object::X *,n$2:int ,n$3:int ) [line 26]\n _fun_temp_object::X_X(n$0:class temp_object::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class temp_object::X &) [line 26]\n " shape="box"] 18 -> 17 ; -17 [label="17: Exit getX \n " color=yellow style=filled] +17 [label="17: Exit temp_object::getX \n " color=yellow style=filled] -16 [label="16: Start getX\nFormals: a:int b:int __return_param:class X *\nLocals: 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 24]\n " color=yellow style=filled] +16 [label="16: Start temp_object::getX\nFormals: a:int b:int __return_param:class temp_object::X *\nLocals: 0$?%__sil_tmpSIL_materialize_temp__n$1:class temp_object::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 26]\n " color=yellow style=filled] 16 -> 18 ; -15 [label="15: Return Stmt \n n$0=*&f:int [line 19]\n *&return:int =(1 / n$0) [line 19]\n " shape="box"] +15 [label="15: Return Stmt \n n$0=*&f:int [line 21]\n *&return:int =(1 / n$0) [line 21]\n " shape="box"] 15 -> 14 ; -14 [label="14: Exit div \n " color=yellow style=filled] +14 [label="14: Exit temp_object::div \n " color=yellow style=filled] -13 [label="13: Start div\nFormals: f:int \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +13 [label="13: Start temp_object::div\nFormals: f:int \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Return Stmt \n n$0=*&this:class X * [line 16]\n n$1=*n$0.f:int [line 16]\n *&return:int =(1 / n$1) [line 16]\n " shape="box"] +12 [label="12: Return Stmt \n n$0=*&this:class temp_object::X * [line 18]\n n$1=*n$0.f:int [line 18]\n *&return:int =(1 / n$1) [line 18]\n " shape="box"] 12 -> 11 ; -11 [label="11: Exit X_div \n " color=yellow style=filled] +11 [label="11: Exit temp_object::X_div \n " color=yellow style=filled] -10 [label="10: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] +10 [label="10: Start temp_object::X_div\nFormals: this:class temp_object::X *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 10 -> 12 ; -9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 14]\n n$1=*&x:class X & [line 14]\n n$2=*n$1.f:int [line 14]\n *n$0.f:int =n$2 [line 14]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class temp_object::X * [line 16]\n n$1=*&x:class temp_object::X & [line 16]\n n$2=*n$1.f:int [line 16]\n *n$0.f:int =n$2 [line 16]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit X_X \n " color=yellow style=filled] +8 [label="8: Exit temp_object::X_X \n " color=yellow style=filled] -7 [label="7: Start X_X\nFormals: this:class X * x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +7 [label="7: Start temp_object::X_X\nFormals: this:class temp_object::X * x:class temp_object::X &\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 12]\n n$1=*&a:int [line 12]\n *n$0.f:int =n$1 [line 12]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class temp_object::X * [line 14]\n n$1=*&a:int [line 14]\n *n$0.f:int =n$1 [line 14]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit X_X \n " color=yellow style=filled] +5 [label="5: Exit temp_object::X_X \n " color=yellow style=filled] -4 [label="4: Start X_X\nFormals: this:class X * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +4 [label="4: Start temp_object::X_X\nFormals: this:class temp_object::X * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 11]\n n$1=*&a:int [line 11]\n *n$0.f:int =n$1 [line 11]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class temp_object::X * [line 13]\n n$1=*&a:int [line 13]\n *n$0.f:int =n$1 [line 13]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_X \n " color=yellow style=filled] +2 [label="2: Exit temp_object::X_X \n " color=yellow style=filled] -1 [label="1: Start X_X\nFormals: this:class X * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] +1 [label="1: Start temp_object::X_X\nFormals: this:class temp_object::X * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp index 1f9bb3c37..4dab72c62 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace conversion_operator { + struct X { operator int() { return f_; } operator bool() { return b_; } @@ -66,3 +68,4 @@ int branch_div1() { } return x; } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot index cdbb10aa8..43b17ca2e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot @@ -1,26 +1,26 @@ /* @generated */ digraph iCFG { -61 [label="61: DeclStmt \n _fun_X_X(&x:class X *,1:int ,1:_Bool ) [line 62]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_conversion_operator::X_X(&x:class conversion_operator::X *,1:int ,1:_Bool ) [line 64]\n " shape="box"] 61 -> 56 ; -60 [label="60: DeclStmt \n _=*&x:class X [line 64]\n n$6=_fun_X_operator_int(&x:class X &) [line 64]\n *&v:int =n$6 [line 64]\n " shape="box"] +60 [label="60: DeclStmt \n _=*&x:class conversion_operator::X [line 66]\n n$6=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 66]\n *&v:int =n$6 [line 66]\n " shape="box"] 60 -> 59 ; -59 [label="59: Return Stmt \n n$4=*&v:int [line 65]\n *&return:int =(1 / n$4) [line 65]\n " shape="box"] +59 [label="59: Return Stmt \n n$4=*&v:int [line 67]\n *&return:int =(1 / n$4) [line 67]\n " shape="box"] 59 -> 53 ; -58 [label="58: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 63]\n " shape="invhouse"] +58 [label="58: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 65]\n " shape="invhouse"] 58 -> 55 ; -57 [label="57: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 63]\n " shape="invhouse"] +57 [label="57: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 65]\n " shape="invhouse"] 57 -> 60 ; -56 [label="56: Call _fun_X_operator_bool \n _=*&x:class X [line 63]\n n$3=_fun_X_operator_bool(&x:class X &) [line 63]\n " shape="box"] +56 [label="56: Call _fun_conversion_operator::X_operator_bool \n _=*&x:class conversion_operator::X [line 65]\n n$3=_fun_conversion_operator::X_operator_bool(&x:class conversion_operator::X &) [line 65]\n " shape="box"] 56 -> 57 ; @@ -29,38 +29,38 @@ digraph iCFG { 55 -> 54 ; -54 [label="54: Return Stmt \n _=*&x:class X [line 67]\n n$1=_fun_X_operator_int(&x:class X &) [line 67]\n *&return:int =n$1 [line 67]\n " shape="box"] +54 [label="54: Return Stmt \n _=*&x:class conversion_operator::X [line 69]\n n$1=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 69]\n *&return:int =n$1 [line 69]\n " shape="box"] 54 -> 53 ; -53 [label="53: Exit branch_div1 \n " color=yellow style=filled] +53 [label="53: Exit conversion_operator::branch_div1 \n " color=yellow style=filled] -52 [label="52: Start branch_div1\nFormals: \nLocals: v:int x:class X \n DECLARE_LOCALS(&return,&v,&x); [line 61]\n " color=yellow style=filled] +52 [label="52: Start conversion_operator::branch_div1\nFormals: \nLocals: v:int x:class conversion_operator::X \n DECLARE_LOCALS(&return,&v,&x); [line 63]\n " color=yellow style=filled] 52 -> 61 ; -51 [label="51: DeclStmt \n _fun_X_X(&x:class X *,0:int ,0:_Bool ) [line 53]\n " shape="box"] +51 [label="51: DeclStmt \n _fun_conversion_operator::X_X(&x:class conversion_operator::X *,0:int ,0:_Bool ) [line 55]\n " shape="box"] 51 -> 46 ; -50 [label="50: DeclStmt \n _=*&x:class X [line 55]\n n$6=_fun_X_operator_int(&x:class X &) [line 55]\n *&v:int =n$6 [line 55]\n " shape="box"] +50 [label="50: DeclStmt \n _=*&x:class conversion_operator::X [line 57]\n n$6=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 57]\n *&v:int =n$6 [line 57]\n " shape="box"] 50 -> 49 ; -49 [label="49: Return Stmt \n n$4=*&v:int [line 56]\n *&return:int =(1 / n$4) [line 56]\n " shape="box"] +49 [label="49: Return Stmt \n n$4=*&v:int [line 58]\n *&return:int =(1 / n$4) [line 58]\n " shape="box"] 49 -> 43 ; -48 [label="48: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 54]\n " shape="invhouse"] +48 [label="48: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 56]\n " shape="invhouse"] 48 -> 45 ; -47 [label="47: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 54]\n " shape="invhouse"] +47 [label="47: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 56]\n " shape="invhouse"] 47 -> 50 ; -46 [label="46: Call _fun_X_operator_bool \n _=*&x:class X [line 54]\n n$3=_fun_X_operator_bool(&x:class X &) [line 54]\n " shape="box"] +46 [label="46: Call _fun_conversion_operator::X_operator_bool \n _=*&x:class conversion_operator::X [line 56]\n n$3=_fun_conversion_operator::X_operator_bool(&x:class conversion_operator::X &) [line 56]\n " shape="box"] 46 -> 47 ; @@ -69,46 +69,46 @@ digraph iCFG { 45 -> 44 ; -44 [label="44: Return Stmt \n _=*&x:class X [line 58]\n n$1=_fun_X_operator_int(&x:class X &) [line 58]\n *&return:int =n$1 [line 58]\n " shape="box"] +44 [label="44: Return Stmt \n _=*&x:class conversion_operator::X [line 60]\n n$1=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 60]\n *&return:int =n$1 [line 60]\n " shape="box"] 44 -> 43 ; -43 [label="43: Exit branch_no_div \n " color=yellow style=filled] +43 [label="43: Exit conversion_operator::branch_no_div \n " color=yellow style=filled] -42 [label="42: Start branch_no_div\nFormals: \nLocals: v:int x:class X \n DECLARE_LOCALS(&return,&v,&x); [line 52]\n " color=yellow style=filled] +42 [label="42: Start conversion_operator::branch_no_div\nFormals: \nLocals: v:int x:class conversion_operator::X \n DECLARE_LOCALS(&return,&v,&x); [line 54]\n " color=yellow style=filled] 42 -> 51 ; -41 [label="41: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 42]\n " shape="box"] +41 [label="41: DeclStmt \n _fun_conversion_operator::Y_Y(&y:class conversion_operator::Y *) [line 44]\n " shape="box"] 41 -> 40 ; -40 [label="40: BinaryOperatorStmt: Assign \n *&y.f:int =0 [line 43]\n " shape="box"] +40 [label="40: BinaryOperatorStmt: Assign \n *&y.f:int =0 [line 45]\n " shape="box"] 40 -> 39 ; -39 [label="39: BinaryOperatorStmt: Assign \n *&y.b:int =1 [line 44]\n " shape="box"] +39 [label="39: BinaryOperatorStmt: Assign \n *&y.b:int =1 [line 46]\n " shape="box"] 39 -> 34 ; -38 [label="38: DeclStmt \n _=*&y:class Y [line 46]\n _fun_Y_operator_X(&y:class Y &,&0$?%__sil_tmpSIL_materialize_temp__n$12:class X *) [line 46]\n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$11:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$12:class X &) [line 46]\n n$15=_fun_X_operator_int(&0$?%__sil_tmp__temp_construct_n$11:class X &) [line 46]\n *&v:int =n$15 [line 46]\n " shape="box"] +38 [label="38: DeclStmt \n _=*&y:class conversion_operator::Y [line 48]\n _fun_conversion_operator::Y_operator_X(&y:class conversion_operator::Y &,&0$?%__sil_tmpSIL_materialize_temp__n$12:class conversion_operator::X *) [line 48]\n _fun_conversion_operator::X_X(&0$?%__sil_tmp__temp_construct_n$11:class conversion_operator::X *,&0$?%__sil_tmpSIL_materialize_temp__n$12:class conversion_operator::X &) [line 48]\n n$15=_fun_conversion_operator::X_operator_int(&0$?%__sil_tmp__temp_construct_n$11:class conversion_operator::X &) [line 48]\n *&v:int =n$15 [line 48]\n " shape="box"] 38 -> 37 ; -37 [label="37: Return Stmt \n n$10=*&v:int [line 47]\n *&return:int =(1 / n$10) [line 47]\n " shape="box"] +37 [label="37: Return Stmt \n n$10=*&v:int [line 49]\n *&return:int =(1 / n$10) [line 49]\n " shape="box"] 37 -> 31 ; -36 [label="36: Prune (false branch) \n PRUNE((n$9 == 0), false); [line 45]\n " shape="invhouse"] +36 [label="36: Prune (false branch) \n PRUNE((n$9 == 0), false); [line 47]\n " shape="invhouse"] 36 -> 33 ; -35 [label="35: Prune (true branch) \n PRUNE((n$9 != 0), true); [line 45]\n " shape="invhouse"] +35 [label="35: Prune (true branch) \n PRUNE((n$9 != 0), true); [line 47]\n " shape="invhouse"] 35 -> 38 ; -34 [label="34: Call _fun_X_operator_bool \n _=*&y:class Y [line 45]\n _fun_Y_operator_X(&y:class Y &,&0$?%__sil_tmpSIL_materialize_temp__n$6:class X *) [line 45]\n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$5:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$6:class X &) [line 45]\n n$9=_fun_X_operator_bool(&0$?%__sil_tmp__temp_construct_n$5:class X &) [line 45]\n " shape="box"] +34 [label="34: Call _fun_conversion_operator::X_operator_bool \n _=*&y:class conversion_operator::Y [line 47]\n _fun_conversion_operator::Y_operator_X(&y:class conversion_operator::Y &,&0$?%__sil_tmpSIL_materialize_temp__n$6:class conversion_operator::X *) [line 47]\n _fun_conversion_operator::X_X(&0$?%__sil_tmp__temp_construct_n$5:class conversion_operator::X *,&0$?%__sil_tmpSIL_materialize_temp__n$6:class conversion_operator::X &) [line 47]\n n$9=_fun_conversion_operator::X_operator_bool(&0$?%__sil_tmp__temp_construct_n$5:class conversion_operator::X &) [line 47]\n " shape="box"] 34 -> 35 ; @@ -117,38 +117,38 @@ digraph iCFG { 33 -> 32 ; -32 [label="32: Return Stmt \n _=*&y:class Y [line 49]\n _fun_Y_operator_X(&y:class Y &,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *) [line 49]\n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 49]\n n$4=_fun_X_operator_int(&0$?%__sil_tmp__temp_construct_n$0:class X &) [line 49]\n *&return:int =n$4 [line 49]\n " shape="box"] +32 [label="32: Return Stmt \n _=*&y:class conversion_operator::Y [line 51]\n _fun_conversion_operator::Y_operator_X(&y:class conversion_operator::Y &,&0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X *) [line 51]\n _fun_conversion_operator::X_X(&0$?%__sil_tmp__temp_construct_n$0:class conversion_operator::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X &) [line 51]\n n$4=_fun_conversion_operator::X_operator_int(&0$?%__sil_tmp__temp_construct_n$0:class conversion_operator::X &) [line 51]\n *&return:int =n$4 [line 51]\n " shape="box"] 32 -> 31 ; -31 [label="31: Exit y_branch_div0 \n " color=yellow style=filled] +31 [label="31: Exit conversion_operator::y_branch_div0 \n " color=yellow style=filled] -30 [label="30: Start y_branch_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X 0$?%__sil_tmpSIL_materialize_temp__n$1:class X 0$?%__sil_tmp__temp_construct_n$5:class X 0$?%__sil_tmpSIL_materialize_temp__n$6:class X v:int 0$?%__sil_tmp__temp_construct_n$11:class X 0$?%__sil_tmpSIL_materialize_temp__n$12:class X y:class Y \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmp__temp_construct_n$5,&0$?%__sil_tmpSIL_materialize_temp__n$6,&v,&0$?%__sil_tmp__temp_construct_n$11,&0$?%__sil_tmpSIL_materialize_temp__n$12,&y); [line 41]\n " color=yellow style=filled] +30 [label="30: Start conversion_operator::y_branch_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class conversion_operator::X 0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X 0$?%__sil_tmp__temp_construct_n$5:class conversion_operator::X 0$?%__sil_tmpSIL_materialize_temp__n$6:class conversion_operator::X v:int 0$?%__sil_tmp__temp_construct_n$11:class conversion_operator::X 0$?%__sil_tmpSIL_materialize_temp__n$12:class conversion_operator::X y:class conversion_operator::Y \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1,&0$?%__sil_tmp__temp_construct_n$5,&0$?%__sil_tmpSIL_materialize_temp__n$6,&v,&0$?%__sil_tmp__temp_construct_n$11,&0$?%__sil_tmpSIL_materialize_temp__n$12,&y); [line 43]\n " color=yellow style=filled] 30 -> 41 ; -29 [label="29: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:_Bool ) [line 33]\n " shape="box"] +29 [label="29: DeclStmt \n _fun_conversion_operator::X_X(&x:class conversion_operator::X *,0:int ,1:_Bool ) [line 35]\n " shape="box"] 29 -> 24 ; -28 [label="28: DeclStmt \n _=*&x:class X [line 35]\n n$6=_fun_X_operator_int(&x:class X &) [line 35]\n *&v:int =n$6 [line 35]\n " shape="box"] +28 [label="28: DeclStmt \n _=*&x:class conversion_operator::X [line 37]\n n$6=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 37]\n *&v:int =n$6 [line 37]\n " shape="box"] 28 -> 27 ; -27 [label="27: Return Stmt \n n$4=*&v:int [line 36]\n *&return:int =(1 / n$4) [line 36]\n " shape="box"] +27 [label="27: Return Stmt \n n$4=*&v:int [line 38]\n *&return:int =(1 / n$4) [line 38]\n " shape="box"] 27 -> 21 ; -26 [label="26: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 34]\n " shape="invhouse"] +26 [label="26: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 36]\n " shape="invhouse"] 26 -> 23 ; -25 [label="25: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 34]\n " shape="invhouse"] +25 [label="25: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 36]\n " shape="invhouse"] 25 -> 28 ; -24 [label="24: Call _fun_X_operator_bool \n _=*&x:class X [line 34]\n n$3=_fun_X_operator_bool(&x:class X &) [line 34]\n " shape="box"] +24 [label="24: Call _fun_conversion_operator::X_operator_bool \n _=*&x:class conversion_operator::X [line 36]\n n$3=_fun_conversion_operator::X_operator_bool(&x:class conversion_operator::X &) [line 36]\n " shape="box"] 24 -> 25 ; @@ -157,84 +157,84 @@ digraph iCFG { 23 -> 22 ; -22 [label="22: Return Stmt \n _=*&x:class X [line 38]\n n$1=_fun_X_operator_int(&x:class X &) [line 38]\n *&return:int =n$1 [line 38]\n " shape="box"] +22 [label="22: Return Stmt \n _=*&x:class conversion_operator::X [line 40]\n n$1=_fun_conversion_operator::X_operator_int(&x:class conversion_operator::X &) [line 40]\n *&return:int =n$1 [line 40]\n " shape="box"] 22 -> 21 ; -21 [label="21: Exit branch_div0 \n " color=yellow style=filled] +21 [label="21: Exit conversion_operator::branch_div0 \n " color=yellow style=filled] -20 [label="20: Start branch_div0\nFormals: \nLocals: v:int x:class X \n DECLARE_LOCALS(&return,&v,&x); [line 32]\n " color=yellow style=filled] +20 [label="20: Start conversion_operator::branch_div0\nFormals: \nLocals: v:int x:class conversion_operator::X \n DECLARE_LOCALS(&return,&v,&x); [line 34]\n " color=yellow style=filled] 20 -> 29 ; -19 [label="19: Exit Y_Y \n " color=yellow style=filled] +19 [label="19: Exit conversion_operator::Y_Y \n " color=yellow style=filled] -18 [label="18: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +18 [label="18: Start conversion_operator::Y_Y\nFormals: this:class conversion_operator::Y *\nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] 18 -> 19 ; -17 [label="17: Return Stmt \n n$0=*&__return_param:class X * [line 27]\n n$2=*&this:class Y * [line 27]\n n$3=*n$2.f:int [line 27]\n n$4=*&this:class Y * [line 27]\n n$5=*n$4.b:int [line 27]\n _fun_X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *,n$3:int ,n$5:_Bool ) [line 27]\n _fun_X_X(n$0:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 27]\n " shape="box"] +17 [label="17: Return Stmt \n n$0=*&__return_param:class conversion_operator::X * [line 29]\n n$2=*&this:class conversion_operator::Y * [line 29]\n n$3=*n$2.f:int [line 29]\n n$4=*&this:class conversion_operator::Y * [line 29]\n n$5=*n$4.b:int [line 29]\n _fun_conversion_operator::X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X *,n$3:int ,n$5:_Bool ) [line 29]\n _fun_conversion_operator::X_X(n$0:class conversion_operator::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X &) [line 29]\n " shape="box"] 17 -> 16 ; -16 [label="16: Exit Y_operator_X \n " color=yellow style=filled] +16 [label="16: Exit conversion_operator::Y_operator_X \n " color=yellow style=filled] -15 [label="15: Start Y_operator_X\nFormals: this:class Y * __return_param:class X *\nLocals: 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 27]\n " color=yellow style=filled] +15 [label="15: Start conversion_operator::Y_operator_X\nFormals: this:class conversion_operator::Y * __return_param:class conversion_operator::X *\nLocals: 0$?%__sil_tmpSIL_materialize_temp__n$1:class conversion_operator::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 29]\n " color=yellow style=filled] 15 -> 17 ; -14 [label="14: BinaryOperatorStmt: Assign \n n$3=*&this:class X * [line 20]\n n$4=*&x:class X & [line 20]\n n$5=*n$4.f_:int [line 20]\n *n$3.f_:int =n$5 [line 20]\n " shape="box"] +14 [label="14: BinaryOperatorStmt: Assign \n n$3=*&this:class conversion_operator::X * [line 22]\n n$4=*&x:class conversion_operator::X & [line 22]\n n$5=*n$4.f_:int [line 22]\n *n$3.f_:int =n$5 [line 22]\n " shape="box"] 14 -> 13 ; -13 [label="13: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 21]\n n$1=*&x:class X & [line 21]\n n$2=*n$1.b_:_Bool [line 21]\n *n$0.b_:_Bool =n$2 [line 21]\n " shape="box"] +13 [label="13: BinaryOperatorStmt: Assign \n n$0=*&this:class conversion_operator::X * [line 23]\n n$1=*&x:class conversion_operator::X & [line 23]\n n$2=*n$1.b_:_Bool [line 23]\n *n$0.b_:_Bool =n$2 [line 23]\n " shape="box"] 13 -> 12 ; -12 [label="12: Exit X_X \n " color=yellow style=filled] +12 [label="12: Exit conversion_operator::X_X \n " color=yellow style=filled] -11 [label="11: Start X_X\nFormals: this:class X * x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +11 [label="11: Start conversion_operator::X_X\nFormals: this:class conversion_operator::X * x:class conversion_operator::X &\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 11 -> 14 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$2=*&this:class X * [line 16]\n n$3=*&f:int [line 16]\n *n$2.f_:int =n$3 [line 16]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n n$2=*&this:class conversion_operator::X * [line 18]\n n$3=*&f:int [line 18]\n *n$2.f_:int =n$3 [line 18]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 17]\n n$1=*&b:_Bool [line 17]\n *n$0.b_:_Bool =n$1 [line 17]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class conversion_operator::X * [line 19]\n n$1=*&b:_Bool [line 19]\n *n$0.b_:_Bool =n$1 [line 19]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit X_X \n " color=yellow style=filled] +8 [label="8: Exit conversion_operator::X_X \n " color=yellow style=filled] -7 [label="7: Start X_X\nFormals: this:class X * f:int b:_Bool \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +7 [label="7: Start conversion_operator::X_X\nFormals: this:class conversion_operator::X * f:int b:_Bool \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: Return Stmt \n n$0=*&this:class X * [line 12]\n n$1=*n$0.b_:_Bool [line 12]\n *&return:_Bool =n$1 [line 12]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&this:class conversion_operator::X * [line 14]\n n$1=*n$0.b_:_Bool [line 14]\n *&return:_Bool =n$1 [line 14]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit X_operator_bool \n " color=yellow style=filled] +5 [label="5: Exit conversion_operator::X_operator_bool \n " color=yellow style=filled] -4 [label="4: Start X_operator_bool\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +4 [label="4: Start conversion_operator::X_operator_bool\nFormals: this:class conversion_operator::X *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&this:class X * [line 11]\n n$1=*n$0.f_:int [line 11]\n *&return:int =n$1 [line 11]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&this:class conversion_operator::X * [line 13]\n n$1=*n$0.f_:int [line 13]\n *&return:int =n$1 [line 13]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_operator_int \n " color=yellow style=filled] +2 [label="2: Exit conversion_operator::X_operator_int \n " color=yellow style=filled] -1 [label="1: Start X_operator_int\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] +1 [label="1: Start conversion_operator::X_operator_int\nFormals: this:class conversion_operator::X *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp index 616be8d12..6b97cdc70 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace reference_field { + struct X { int f; }; @@ -140,3 +142,4 @@ int val_getI_div0() { x.f = 1; return 1 / r.getI(); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp.dot index f87ddd4a8..bc982b1f3 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp.dot @@ -1,455 +1,455 @@ /* @generated */ digraph iCFG { -119 [label="119: DeclStmt \n _fun_X_X(&x:class X *) [line 137]\n " shape="box"] +119 [label="119: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 139]\n " shape="box"] 119 -> 118 ; -118 [label="118: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 138]\n " shape="box"] +118 [label="118: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 140]\n " shape="box"] 118 -> 117 ; -117 [label="117: DeclStmt \n _fun_Val_Val(&r:class Val *,&x:class X &) [line 139]\n " shape="box"] +117 [label="117: DeclStmt \n _fun_reference_field::Val_Val(&r:class reference_field::Val *,&x:class reference_field::X &) [line 141]\n " shape="box"] 117 -> 116 ; -116 [label="116: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 140]\n " shape="box"] +116 [label="116: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 142]\n " shape="box"] 116 -> 115 ; -115 [label="115: Return Stmt \n _=*&r:class Val [line 141]\n n$1=_fun_Val_getI(&r:class Val &) [line 141]\n *&return:int =(1 / n$1) [line 141]\n " shape="box"] +115 [label="115: Return Stmt \n _=*&r:class reference_field::Val [line 143]\n n$1=_fun_reference_field::Val_getI(&r:class reference_field::Val &) [line 143]\n *&return:int =(1 / n$1) [line 143]\n " shape="box"] 115 -> 114 ; -114 [label="114: Exit val_getI_div0 \n " color=yellow style=filled] +114 [label="114: Exit reference_field::val_getI_div0 \n " color=yellow style=filled] -113 [label="113: Start val_getI_div0\nFormals: \nLocals: r:class Val x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 136]\n " color=yellow style=filled] +113 [label="113: Start reference_field::val_getI_div0\nFormals: \nLocals: r:class reference_field::Val x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 138]\n " color=yellow style=filled] 113 -> 119 ; -112 [label="112: DeclStmt \n _fun_X_X(&x:class X *) [line 129]\n " shape="box"] +112 [label="112: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 131]\n " shape="box"] 112 -> 111 ; -111 [label="111: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 130]\n " shape="box"] +111 [label="111: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 132]\n " shape="box"] 111 -> 110 ; -110 [label="110: DeclStmt \n _fun_Val_Val(&r:class Val *,&x:class X &) [line 131]\n " shape="box"] +110 [label="110: DeclStmt \n _fun_reference_field::Val_Val(&r:class reference_field::Val *,&x:class reference_field::X &) [line 133]\n " shape="box"] 110 -> 109 ; -109 [label="109: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 132]\n " shape="box"] +109 [label="109: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 134]\n " shape="box"] 109 -> 108 ; -108 [label="108: Return Stmt \n _=*&r:class Val [line 133]\n n$1=_fun_Val_getF(&r:class Val &) [line 133]\n *&return:int =(1 / n$1) [line 133]\n " shape="box"] +108 [label="108: Return Stmt \n _=*&r:class reference_field::Val [line 135]\n n$1=_fun_reference_field::Val_getF(&r:class reference_field::Val &) [line 135]\n *&return:int =(1 / n$1) [line 135]\n " shape="box"] 108 -> 107 ; -107 [label="107: Exit val_getF_div0 \n " color=yellow style=filled] +107 [label="107: Exit reference_field::val_getF_div0 \n " color=yellow style=filled] -106 [label="106: Start val_getF_div0\nFormals: \nLocals: r:class Val x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 128]\n " color=yellow style=filled] +106 [label="106: Start reference_field::val_getF_div0\nFormals: \nLocals: r:class reference_field::Val x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 130]\n " color=yellow style=filled] 106 -> 112 ; -105 [label="105: DeclStmt \n _fun_X_X(&x:class X *) [line 121]\n " shape="box"] +105 [label="105: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 123]\n " shape="box"] 105 -> 104 ; -104 [label="104: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 122]\n " shape="box"] +104 [label="104: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 124]\n " shape="box"] 104 -> 103 ; -103 [label="103: DeclStmt \n _fun_Val_Val(&r:class Val *,&x:class X &) [line 123]\n " shape="box"] +103 [label="103: DeclStmt \n _fun_reference_field::Val_Val(&r:class reference_field::Val *,&x:class reference_field::X &) [line 125]\n " shape="box"] 103 -> 102 ; -102 [label="102: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 124]\n " shape="box"] +102 [label="102: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 126]\n " shape="box"] 102 -> 101 ; -101 [label="101: Return Stmt \n n$0=*&r.i:int [line 125]\n *&return:int =(1 / n$0) [line 125]\n " shape="box"] +101 [label="101: Return Stmt \n n$0=*&r.i:int [line 127]\n *&return:int =(1 / n$0) [line 127]\n " shape="box"] 101 -> 100 ; -100 [label="100: Exit val_I_div0 \n " color=yellow style=filled] +100 [label="100: Exit reference_field::val_I_div0 \n " color=yellow style=filled] -99 [label="99: Start val_I_div0\nFormals: \nLocals: r:class Val x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 120]\n " color=yellow style=filled] +99 [label="99: Start reference_field::val_I_div0\nFormals: \nLocals: r:class reference_field::Val x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 122]\n " color=yellow style=filled] 99 -> 105 ; -98 [label="98: DeclStmt \n _fun_X_X(&x:class X *) [line 113]\n " shape="box"] +98 [label="98: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 115]\n " shape="box"] 98 -> 97 ; -97 [label="97: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 114]\n " shape="box"] +97 [label="97: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 116]\n " shape="box"] 97 -> 96 ; -96 [label="96: DeclStmt \n _fun_Val_Val(&r:class Val *,&x:class X &) [line 115]\n " shape="box"] +96 [label="96: DeclStmt \n _fun_reference_field::Val_Val(&r:class reference_field::Val *,&x:class reference_field::X &) [line 117]\n " shape="box"] 96 -> 95 ; -95 [label="95: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 116]\n " shape="box"] +95 [label="95: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 118]\n " shape="box"] 95 -> 94 ; -94 [label="94: Return Stmt \n n$0=*&r.x.f:int [line 117]\n *&return:int =(1 / n$0) [line 117]\n " shape="box"] +94 [label="94: Return Stmt \n n$0=*&r.x.f:int [line 119]\n *&return:int =(1 / n$0) [line 119]\n " shape="box"] 94 -> 93 ; -93 [label="93: Exit val_F_div0 \n " color=yellow style=filled] +93 [label="93: Exit reference_field::val_F_div0 \n " color=yellow style=filled] -92 [label="92: Start val_F_div0\nFormals: \nLocals: r:class Val x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 112]\n " color=yellow style=filled] +92 [label="92: Start reference_field::val_F_div0\nFormals: \nLocals: r:class reference_field::Val x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 114]\n " color=yellow style=filled] 92 -> 98 ; -91 [label="91: DeclStmt \n _fun_X_X(&x:class X *) [line 104]\n " shape="box"] +91 [label="91: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 106]\n " shape="box"] 91 -> 90 ; -90 [label="90: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 105]\n " shape="box"] +90 [label="90: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 107]\n " shape="box"] 90 -> 89 ; -89 [label="89: DeclStmt \n _fun_Ptr_Ptr(&r:class Ptr *,&x:class X &) [line 106]\n " shape="box"] +89 [label="89: DeclStmt \n _fun_reference_field::Ptr_Ptr(&r:class reference_field::Ptr *,&x:class reference_field::X &) [line 108]\n " shape="box"] 89 -> 88 ; -88 [label="88: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 107]\n " shape="box"] +88 [label="88: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 109]\n " shape="box"] 88 -> 87 ; -87 [label="87: Return Stmt \n _=*&r:class Ptr [line 108]\n n$1=_fun_Ptr_getI(&r:class Ptr &) [line 108]\n *&return:int =(1 / n$1) [line 108]\n " shape="box"] +87 [label="87: Return Stmt \n _=*&r:class reference_field::Ptr [line 110]\n n$1=_fun_reference_field::Ptr_getI(&r:class reference_field::Ptr &) [line 110]\n *&return:int =(1 / n$1) [line 110]\n " shape="box"] 87 -> 86 ; -86 [label="86: Exit ptr_getI_div0 \n " color=yellow style=filled] +86 [label="86: Exit reference_field::ptr_getI_div0 \n " color=yellow style=filled] -85 [label="85: Start ptr_getI_div0\nFormals: \nLocals: r:class Ptr x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 103]\n " color=yellow style=filled] +85 [label="85: Start reference_field::ptr_getI_div0\nFormals: \nLocals: r:class reference_field::Ptr x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 105]\n " color=yellow style=filled] 85 -> 91 ; -84 [label="84: DeclStmt \n _fun_X_X(&x:class X *) [line 96]\n " shape="box"] +84 [label="84: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 98]\n " shape="box"] 84 -> 83 ; -83 [label="83: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 97]\n " shape="box"] +83 [label="83: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 99]\n " shape="box"] 83 -> 82 ; -82 [label="82: DeclStmt \n _fun_Ptr_Ptr(&r:class Ptr *,&x:class X &) [line 98]\n " shape="box"] +82 [label="82: DeclStmt \n _fun_reference_field::Ptr_Ptr(&r:class reference_field::Ptr *,&x:class reference_field::X &) [line 100]\n " shape="box"] 82 -> 81 ; -81 [label="81: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 99]\n " shape="box"] +81 [label="81: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 101]\n " shape="box"] 81 -> 80 ; -80 [label="80: Return Stmt \n _=*&r:class Ptr [line 100]\n n$1=_fun_Ptr_getF(&r:class Ptr &) [line 100]\n *&return:int =(1 / n$1) [line 100]\n " shape="box"] +80 [label="80: Return Stmt \n _=*&r:class reference_field::Ptr [line 102]\n n$1=_fun_reference_field::Ptr_getF(&r:class reference_field::Ptr &) [line 102]\n *&return:int =(1 / n$1) [line 102]\n " shape="box"] 80 -> 79 ; -79 [label="79: Exit ptr_getF_div0 \n " color=yellow style=filled] +79 [label="79: Exit reference_field::ptr_getF_div0 \n " color=yellow style=filled] -78 [label="78: Start ptr_getF_div0\nFormals: \nLocals: r:class Ptr x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 95]\n " color=yellow style=filled] +78 [label="78: Start reference_field::ptr_getF_div0\nFormals: \nLocals: r:class reference_field::Ptr x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 97]\n " color=yellow style=filled] 78 -> 84 ; -77 [label="77: DeclStmt \n _fun_X_X(&x:class X *) [line 88]\n " shape="box"] +77 [label="77: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 90]\n " shape="box"] 77 -> 76 ; -76 [label="76: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 89]\n " shape="box"] +76 [label="76: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 91]\n " shape="box"] 76 -> 75 ; -75 [label="75: DeclStmt \n _fun_Ptr_Ptr(&r:class Ptr *,&x:class X &) [line 90]\n " shape="box"] +75 [label="75: DeclStmt \n _fun_reference_field::Ptr_Ptr(&r:class reference_field::Ptr *,&x:class reference_field::X &) [line 92]\n " shape="box"] 75 -> 74 ; -74 [label="74: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 91]\n " shape="box"] +74 [label="74: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 93]\n " shape="box"] 74 -> 73 ; -73 [label="73: Return Stmt \n n$0=*&r.i:int * [line 92]\n n$1=*n$0:int [line 92]\n *&return:int =(1 / n$1) [line 92]\n " shape="box"] +73 [label="73: Return Stmt \n n$0=*&r.i:int * [line 94]\n n$1=*n$0:int [line 94]\n *&return:int =(1 / n$1) [line 94]\n " shape="box"] 73 -> 72 ; -72 [label="72: Exit ptr_I_div0 \n " color=yellow style=filled] +72 [label="72: Exit reference_field::ptr_I_div0 \n " color=yellow style=filled] -71 [label="71: Start ptr_I_div0\nFormals: \nLocals: r:class Ptr x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 87]\n " color=yellow style=filled] +71 [label="71: Start reference_field::ptr_I_div0\nFormals: \nLocals: r:class reference_field::Ptr x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 89]\n " color=yellow style=filled] 71 -> 77 ; -70 [label="70: DeclStmt \n _fun_X_X(&x:class X *) [line 80]\n " shape="box"] +70 [label="70: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 82]\n " shape="box"] 70 -> 69 ; -69 [label="69: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 81]\n " shape="box"] +69 [label="69: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 83]\n " shape="box"] 69 -> 68 ; -68 [label="68: DeclStmt \n _fun_Ptr_Ptr(&r:class Ptr *,&x:class X &) [line 82]\n " shape="box"] +68 [label="68: DeclStmt \n _fun_reference_field::Ptr_Ptr(&r:class reference_field::Ptr *,&x:class reference_field::X &) [line 84]\n " shape="box"] 68 -> 67 ; -67 [label="67: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 83]\n " shape="box"] +67 [label="67: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 85]\n " shape="box"] 67 -> 66 ; -66 [label="66: Return Stmt \n n$0=*&r.x:class X * [line 84]\n n$1=*n$0.f:int [line 84]\n *&return:int =(1 / n$1) [line 84]\n " shape="box"] +66 [label="66: Return Stmt \n n$0=*&r.x:class reference_field::X * [line 86]\n n$1=*n$0.f:int [line 86]\n *&return:int =(1 / n$1) [line 86]\n " shape="box"] 66 -> 65 ; -65 [label="65: Exit ptr_F_div0 \n " color=yellow style=filled] +65 [label="65: Exit reference_field::ptr_F_div0 \n " color=yellow style=filled] -64 [label="64: Start ptr_F_div0\nFormals: \nLocals: r:class Ptr x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 79]\n " color=yellow style=filled] +64 [label="64: Start reference_field::ptr_F_div0\nFormals: \nLocals: r:class reference_field::Ptr x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 81]\n " color=yellow style=filled] 64 -> 70 ; -63 [label="63: DeclStmt \n _fun_X_X(&x:class X *) [line 71]\n " shape="box"] +63 [label="63: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 73]\n " shape="box"] 63 -> 62 ; -62 [label="62: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 72]\n " shape="box"] +62 [label="62: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 74]\n " shape="box"] 62 -> 61 ; -61 [label="61: DeclStmt \n _fun_Ref_Ref(&r:class Ref *,&x:class X &) [line 73]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_reference_field::Ref_Ref(&r:class reference_field::Ref *,&x:class reference_field::X &) [line 75]\n " shape="box"] 61 -> 60 ; -60 [label="60: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 74]\n " shape="box"] +60 [label="60: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 76]\n " shape="box"] 60 -> 59 ; -59 [label="59: Return Stmt \n _=*&r:class Ref [line 75]\n n$1=_fun_Ref_getI(&r:class Ref &) [line 75]\n *&return:int =(1 / n$1) [line 75]\n " shape="box"] +59 [label="59: Return Stmt \n _=*&r:class reference_field::Ref [line 77]\n n$1=_fun_reference_field::Ref_getI(&r:class reference_field::Ref &) [line 77]\n *&return:int =(1 / n$1) [line 77]\n " shape="box"] 59 -> 58 ; -58 [label="58: Exit ref_getI_div0 \n " color=yellow style=filled] +58 [label="58: Exit reference_field::ref_getI_div0 \n " color=yellow style=filled] -57 [label="57: Start ref_getI_div0\nFormals: \nLocals: r:class Ref x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 70]\n " color=yellow style=filled] +57 [label="57: Start reference_field::ref_getI_div0\nFormals: \nLocals: r:class reference_field::Ref x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 72]\n " color=yellow style=filled] 57 -> 63 ; -56 [label="56: DeclStmt \n _fun_X_X(&x:class X *) [line 63]\n " shape="box"] +56 [label="56: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 65]\n " shape="box"] 56 -> 55 ; -55 [label="55: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 64]\n " shape="box"] +55 [label="55: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 66]\n " shape="box"] 55 -> 54 ; -54 [label="54: DeclStmt \n _fun_Ref_Ref(&r:class Ref *,&x:class X &) [line 65]\n " shape="box"] +54 [label="54: DeclStmt \n _fun_reference_field::Ref_Ref(&r:class reference_field::Ref *,&x:class reference_field::X &) [line 67]\n " shape="box"] 54 -> 53 ; -53 [label="53: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 66]\n " shape="box"] +53 [label="53: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 68]\n " shape="box"] 53 -> 52 ; -52 [label="52: Return Stmt \n _=*&r:class Ref [line 67]\n n$1=_fun_Ref_getF(&r:class Ref &) [line 67]\n *&return:int =(1 / n$1) [line 67]\n " shape="box"] +52 [label="52: Return Stmt \n _=*&r:class reference_field::Ref [line 69]\n n$1=_fun_reference_field::Ref_getF(&r:class reference_field::Ref &) [line 69]\n *&return:int =(1 / n$1) [line 69]\n " shape="box"] 52 -> 51 ; -51 [label="51: Exit ref_getF_div0 \n " color=yellow style=filled] +51 [label="51: Exit reference_field::ref_getF_div0 \n " color=yellow style=filled] -50 [label="50: Start ref_getF_div0\nFormals: \nLocals: r:class Ref x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 62]\n " color=yellow style=filled] +50 [label="50: Start reference_field::ref_getF_div0\nFormals: \nLocals: r:class reference_field::Ref x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 64]\n " color=yellow style=filled] 50 -> 56 ; -49 [label="49: DeclStmt \n _fun_X_X(&x:class X *) [line 55]\n " shape="box"] +49 [label="49: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 57]\n " shape="box"] 49 -> 48 ; -48 [label="48: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 56]\n " shape="box"] +48 [label="48: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 58]\n " shape="box"] 48 -> 47 ; -47 [label="47: DeclStmt \n _fun_Ref_Ref(&r:class Ref *,&x:class X &) [line 57]\n " shape="box"] +47 [label="47: DeclStmt \n _fun_reference_field::Ref_Ref(&r:class reference_field::Ref *,&x:class reference_field::X &) [line 59]\n " shape="box"] 47 -> 46 ; -46 [label="46: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 58]\n " shape="box"] +46 [label="46: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 60]\n " shape="box"] 46 -> 45 ; -45 [label="45: Return Stmt \n n$0=*&r.i:int & [line 59]\n n$1=*n$0:int & [line 59]\n *&return:int =(1 / n$1) [line 59]\n " shape="box"] +45 [label="45: Return Stmt \n n$0=*&r.i:int & [line 61]\n n$1=*n$0:int & [line 61]\n *&return:int =(1 / n$1) [line 61]\n " shape="box"] 45 -> 44 ; -44 [label="44: Exit ref_I_div0 \n " color=yellow style=filled] +44 [label="44: Exit reference_field::ref_I_div0 \n " color=yellow style=filled] -43 [label="43: Start ref_I_div0\nFormals: \nLocals: r:class Ref x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 54]\n " color=yellow style=filled] +43 [label="43: Start reference_field::ref_I_div0\nFormals: \nLocals: r:class reference_field::Ref x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 56]\n " color=yellow style=filled] 43 -> 49 ; -42 [label="42: DeclStmt \n _fun_X_X(&x:class X *) [line 47]\n " shape="box"] +42 [label="42: DeclStmt \n _fun_reference_field::X_X(&x:class reference_field::X *) [line 49]\n " shape="box"] 42 -> 41 ; -41 [label="41: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 48]\n " shape="box"] +41 [label="41: BinaryOperatorStmt: Assign \n *&x.f:int =1 [line 50]\n " shape="box"] 41 -> 40 ; -40 [label="40: DeclStmt \n _fun_Ref_Ref(&r:class Ref *,&x:class X &) [line 49]\n " shape="box"] +40 [label="40: DeclStmt \n _fun_reference_field::Ref_Ref(&r:class reference_field::Ref *,&x:class reference_field::X &) [line 51]\n " shape="box"] 40 -> 39 ; -39 [label="39: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 50]\n " shape="box"] +39 [label="39: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 52]\n " shape="box"] 39 -> 38 ; -38 [label="38: Return Stmt \n n$0=*&r.x:class X & [line 51]\n n$1=*n$0.f:int [line 51]\n *&return:int =(1 / n$1) [line 51]\n " shape="box"] +38 [label="38: Return Stmt \n n$0=*&r.x:class reference_field::X & [line 53]\n n$1=*n$0.f:int [line 53]\n *&return:int =(1 / n$1) [line 53]\n " shape="box"] 38 -> 37 ; -37 [label="37: Exit ref_F_div0 \n " color=yellow style=filled] +37 [label="37: Exit reference_field::ref_F_div0 \n " color=yellow style=filled] -36 [label="36: Start ref_F_div0\nFormals: \nLocals: r:class Ref x:class X \n DECLARE_LOCALS(&return,&r,&x); [line 46]\n " color=yellow style=filled] +36 [label="36: Start reference_field::ref_F_div0\nFormals: \nLocals: r:class reference_field::Ref x:class reference_field::X \n DECLARE_LOCALS(&return,&r,&x); [line 48]\n " color=yellow style=filled] 36 -> 42 ; -35 [label="35: Return Stmt \n n$0=*&this:class Val * [line 42]\n n$1=*n$0.i:int [line 42]\n *&return:int =n$1 [line 42]\n " shape="box"] +35 [label="35: Return Stmt \n n$0=*&this:class reference_field::Val * [line 44]\n n$1=*n$0.i:int [line 44]\n *&return:int =n$1 [line 44]\n " shape="box"] 35 -> 34 ; -34 [label="34: Exit Val_getI \n " color=yellow style=filled] +34 [label="34: Exit reference_field::Val_getI \n " color=yellow style=filled] -33 [label="33: Start Val_getI\nFormals: this:class Val *\nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] +33 [label="33: Start reference_field::Val_getI\nFormals: this:class reference_field::Val *\nLocals: \n DECLARE_LOCALS(&return); [line 44]\n " color=yellow style=filled] 33 -> 35 ; -32 [label="32: Return Stmt \n n$0=*&this:class Val * [line 41]\n n$1=*n$0.x.f:int [line 41]\n *&return:int =n$1 [line 41]\n " shape="box"] +32 [label="32: Return Stmt \n n$0=*&this:class reference_field::Val * [line 43]\n n$1=*n$0.x.f:int [line 43]\n *&return:int =n$1 [line 43]\n " shape="box"] 32 -> 31 ; -31 [label="31: Exit Val_getF \n " color=yellow style=filled] +31 [label="31: Exit reference_field::Val_getF \n " color=yellow style=filled] -30 [label="30: Start Val_getF\nFormals: this:class Val *\nLocals: \n DECLARE_LOCALS(&return); [line 41]\n " color=yellow style=filled] +30 [label="30: Start reference_field::Val_getF\nFormals: this:class reference_field::Val *\nLocals: \n DECLARE_LOCALS(&return); [line 43]\n " color=yellow style=filled] 30 -> 32 ; -29 [label="29: Constructor Init \n n$3=*&this:class Val * [line 40]\n n$4=*&r_:class X & [line 40]\n _fun_X_X(n$3.x:class X *,n$4:class X &) [line 40]\n " shape="box"] +29 [label="29: Constructor Init \n n$3=*&this:class reference_field::Val * [line 42]\n n$4=*&r_:class reference_field::X & [line 42]\n _fun_reference_field::X_X(n$3.x:class reference_field::X *,n$4:class reference_field::X &) [line 42]\n " shape="box"] 29 -> 28 ; -28 [label="28: Constructor Init \n n$0=*&this:class Val * [line 40]\n n$1=*&this:class Val * [line 40]\n n$2=*n$1.x.f:int [line 40]\n *n$0.i:int =n$2 [line 40]\n " shape="box"] +28 [label="28: Constructor Init \n n$0=*&this:class reference_field::Val * [line 42]\n n$1=*&this:class reference_field::Val * [line 42]\n n$2=*n$1.x.f:int [line 42]\n *n$0.i:int =n$2 [line 42]\n " shape="box"] 28 -> 27 ; -27 [label="27: Exit Val_Val \n " color=yellow style=filled] +27 [label="27: Exit reference_field::Val_Val \n " color=yellow style=filled] -26 [label="26: Start Val_Val\nFormals: this:class Val * r_:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] +26 [label="26: Start reference_field::Val_Val\nFormals: this:class reference_field::Val * r_:class reference_field::X &\nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] 26 -> 29 ; -25 [label="25: Return Stmt \n n$0=*&this:class Ptr * [line 34]\n n$1=*n$0.i:int * [line 34]\n n$2=*n$1:int [line 34]\n *&return:int =n$2 [line 34]\n " shape="box"] +25 [label="25: Return Stmt \n n$0=*&this:class reference_field::Ptr * [line 36]\n n$1=*n$0.i:int * [line 36]\n n$2=*n$1:int [line 36]\n *&return:int =n$2 [line 36]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit Ptr_getI \n " color=yellow style=filled] +24 [label="24: Exit reference_field::Ptr_getI \n " color=yellow style=filled] -23 [label="23: Start Ptr_getI\nFormals: this:class Ptr *\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] +23 [label="23: Start reference_field::Ptr_getI\nFormals: this:class reference_field::Ptr *\nLocals: \n DECLARE_LOCALS(&return); [line 36]\n " color=yellow style=filled] 23 -> 25 ; -22 [label="22: Return Stmt \n n$0=*&this:class Ptr * [line 33]\n n$1=*n$0.x:class X * [line 33]\n n$2=*n$1.f:int [line 33]\n *&return:int =n$2 [line 33]\n " shape="box"] +22 [label="22: Return Stmt \n n$0=*&this:class reference_field::Ptr * [line 35]\n n$1=*n$0.x:class reference_field::X * [line 35]\n n$2=*n$1.f:int [line 35]\n *&return:int =n$2 [line 35]\n " shape="box"] 22 -> 21 ; -21 [label="21: Exit Ptr_getF \n " color=yellow style=filled] +21 [label="21: Exit reference_field::Ptr_getF \n " color=yellow style=filled] -20 [label="20: Start Ptr_getF\nFormals: this:class Ptr *\nLocals: \n DECLARE_LOCALS(&return); [line 33]\n " color=yellow style=filled] +20 [label="20: Start reference_field::Ptr_getF\nFormals: this:class reference_field::Ptr *\nLocals: \n DECLARE_LOCALS(&return); [line 35]\n " color=yellow style=filled] 20 -> 22 ; -19 [label="19: Constructor Init \n n$3=*&this:class Ptr * [line 32]\n n$4=*&r_:class X & [line 32]\n *n$3.x:class X *=n$4 [line 32]\n " shape="box"] +19 [label="19: Constructor Init \n n$3=*&this:class reference_field::Ptr * [line 34]\n n$4=*&r_:class reference_field::X & [line 34]\n *n$3.x:class reference_field::X *=n$4 [line 34]\n " shape="box"] 19 -> 18 ; -18 [label="18: Constructor Init \n n$0=*&this:class Ptr * [line 32]\n n$1=*&this:class Ptr * [line 32]\n n$2=*n$1.x:class X * [line 32]\n *n$0.i:int *=n$2.f [line 32]\n " shape="box"] +18 [label="18: Constructor Init \n n$0=*&this:class reference_field::Ptr * [line 34]\n n$1=*&this:class reference_field::Ptr * [line 34]\n n$2=*n$1.x:class reference_field::X * [line 34]\n *n$0.i:int *=n$2.f [line 34]\n " shape="box"] 18 -> 17 ; -17 [label="17: Exit Ptr_Ptr \n " color=yellow style=filled] +17 [label="17: Exit reference_field::Ptr_Ptr \n " color=yellow style=filled] -16 [label="16: Start Ptr_Ptr\nFormals: this:class Ptr * r_:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +16 [label="16: Start reference_field::Ptr_Ptr\nFormals: this:class reference_field::Ptr * r_:class reference_field::X &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 16 -> 19 ; -15 [label="15: Return Stmt \n n$0=*&this:class Ref * [line 26]\n n$1=*n$0.i:int & [line 26]\n n$2=*n$1:int & [line 26]\n *&return:int =n$2 [line 26]\n " shape="box"] +15 [label="15: Return Stmt \n n$0=*&this:class reference_field::Ref * [line 28]\n n$1=*n$0.i:int & [line 28]\n n$2=*n$1:int & [line 28]\n *&return:int =n$2 [line 28]\n " shape="box"] 15 -> 14 ; -14 [label="14: Exit Ref_getI \n " color=yellow style=filled] +14 [label="14: Exit reference_field::Ref_getI \n " color=yellow style=filled] -13 [label="13: Start Ref_getI\nFormals: this:class Ref *\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] +13 [label="13: Start reference_field::Ref_getI\nFormals: this:class reference_field::Ref *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Return Stmt \n n$0=*&this:class Ref * [line 25]\n n$1=*n$0.x:class X & [line 25]\n n$2=*n$1.f:int [line 25]\n *&return:int =n$2 [line 25]\n " shape="box"] +12 [label="12: Return Stmt \n n$0=*&this:class reference_field::Ref * [line 27]\n n$1=*n$0.x:class reference_field::X & [line 27]\n n$2=*n$1.f:int [line 27]\n *&return:int =n$2 [line 27]\n " shape="box"] 12 -> 11 ; -11 [label="11: Exit Ref_getF \n " color=yellow style=filled] +11 [label="11: Exit reference_field::Ref_getF \n " color=yellow style=filled] -10 [label="10: Start Ref_getF\nFormals: this:class Ref *\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +10 [label="10: Start reference_field::Ref_getF\nFormals: this:class reference_field::Ref *\nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] 10 -> 12 ; -9 [label="9: Constructor Init \n n$3=*&this:class Ref * [line 24]\n n$4=*&r_:class X & [line 24]\n *n$3.x:class X &=n$4 [line 24]\n " shape="box"] +9 [label="9: Constructor Init \n n$3=*&this:class reference_field::Ref * [line 26]\n n$4=*&r_:class reference_field::X & [line 26]\n *n$3.x:class reference_field::X &=n$4 [line 26]\n " shape="box"] 9 -> 8 ; -8 [label="8: Constructor Init \n n$0=*&this:class Ref * [line 24]\n n$1=*&this:class Ref * [line 24]\n n$2=*n$1.x:class X & [line 24]\n *n$0.i:int &=n$2.f [line 24]\n " shape="box"] +8 [label="8: Constructor Init \n n$0=*&this:class reference_field::Ref * [line 26]\n n$1=*&this:class reference_field::Ref * [line 26]\n n$2=*n$1.x:class reference_field::X & [line 26]\n *n$0.i:int &=n$2.f [line 26]\n " shape="box"] 8 -> 7 ; -7 [label="7: Exit Ref_Ref \n " color=yellow style=filled] +7 [label="7: Exit reference_field::Ref_Ref \n " color=yellow style=filled] -6 [label="6: Start Ref_Ref\nFormals: this:class Ref * r_:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +6 [label="6: Start reference_field::Ref_Ref\nFormals: this:class reference_field::Ref * r_:class reference_field::X &\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 6 -> 9 ; -5 [label="5: Constructor Init \n n$0=*&this:class X * [line 10]\n n$1=*&__param_0:class X & [line 10]\n n$2=*n$1.f:int [line 10]\n *n$0.f:int =n$2 [line 10]\n " shape="box"] +5 [label="5: Constructor Init \n n$0=*&this:class reference_field::X * [line 12]\n n$1=*&__param_0:class reference_field::X & [line 12]\n n$2=*n$1.f:int [line 12]\n *n$0.f:int =n$2 [line 12]\n " shape="box"] 5 -> 4 ; -4 [label="4: Exit X_X \n " color=yellow style=filled] +4 [label="4: Exit reference_field::X_X \n " color=yellow style=filled] -3 [label="3: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +3 [label="3: Start reference_field::X_X\nFormals: this:class reference_field::X * __param_0:class reference_field::X &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 3 -> 5 ; -2 [label="2: Exit X_X \n " color=yellow style=filled] +2 [label="2: Exit reference_field::X_X \n " color=yellow style=filled] -1 [label="1: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +1 [label="1: Start reference_field::X_X\nFormals: this:class reference_field::X *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 1 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp index 0ae6337f1..af0f21d60 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace function { + struct X1 { int getVal() { return 1; } }; @@ -71,3 +73,4 @@ int div0_create_and_get_val() { int div1_create_and_get_val() { return createAndGetVal() / createAndGetVal(); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp.dot index 112729080..e6c9d52fc 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp.dot @@ -1,183 +1,183 @@ /* @generated */ digraph iCFG { -49 [label="49: Return Stmt \n n$0=_fun_createAndGetVal() [line 72]\n n$1=_fun_createAndGetVal() [line 72]\n *&return:int =(n$0 / n$1) [line 72]\n " shape="box"] +49 [label="49: Return Stmt \n n$0=_fun_function::createAndGetVal() [line 74]\n n$1=_fun_function::createAndGetVal() [line 74]\n *&return:int =(n$0 / n$1) [line 74]\n " shape="box"] 49 -> 48 ; -48 [label="48: Exit div1_create_and_get_val \n " color=yellow style=filled] +48 [label="48: Exit function::div1_create_and_get_val \n " color=yellow style=filled] -47 [label="47: Start div1_create_and_get_val\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 71]\n " color=yellow style=filled] +47 [label="47: Start function::div1_create_and_get_val\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 73]\n " color=yellow style=filled] 47 -> 49 ; -46 [label="46: Return Stmt \n n$0=_fun_createAndGetVal() [line 68]\n n$1=_fun_createAndGetVal() [line 68]\n *&return:int =(n$0 / n$1) [line 68]\n " shape="box"] +46 [label="46: Return Stmt \n n$0=_fun_function::createAndGetVal() [line 70]\n n$1=_fun_function::createAndGetVal() [line 70]\n *&return:int =(n$0 / n$1) [line 70]\n " shape="box"] 46 -> 45 ; -45 [label="45: Exit div0_create_and_get_val \n " color=yellow style=filled] +45 [label="45: Exit function::div0_create_and_get_val \n " color=yellow style=filled] -44 [label="44: Start div0_create_and_get_val\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 67]\n " color=yellow style=filled] +44 [label="44: Start function::div0_create_and_get_val\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 69]\n " color=yellow style=filled] 44 -> 46 ; -43 [label="43: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 62]\n " shape="box"] +43 [label="43: DeclStmt \n _fun_function::X1_X1(&x1:class function::X1 *) [line 64]\n " shape="box"] 43 -> 42 ; -42 [label="42: DeclStmt \n _fun_X3_X3(&x3:class X3 *) [line 63]\n " shape="box"] +42 [label="42: DeclStmt \n _fun_function::X3_X3(&x3:class function::X3 *) [line 65]\n " shape="box"] 42 -> 41 ; -41 [label="41: Return Stmt \n n$0=_fun_getVal(&x3:class X3 &) [line 64]\n n$1=_fun_getVal(&x1:class X1 &) [line 64]\n *&return:int =(n$0 / n$1) [line 64]\n " shape="box"] +41 [label="41: Return Stmt \n n$0=_fun_function::getVal(&x3:class function::X3 &) [line 66]\n n$1=_fun_function::getVal(&x1:class function::X1 &) [line 66]\n *&return:int =(n$0 / n$1) [line 66]\n " shape="box"] 41 -> 40 ; -40 [label="40: Exit div1_get_val \n " color=yellow style=filled] +40 [label="40: Exit function::div1_get_val \n " color=yellow style=filled] -39 [label="39: Start div1_get_val\nFormals: \nLocals: x3:class X3 x1:class X1 \n DECLARE_LOCALS(&return,&x3,&x1); [line 61]\n " color=yellow style=filled] +39 [label="39: Start function::div1_get_val\nFormals: \nLocals: x3:class function::X3 x1:class function::X1 \n DECLARE_LOCALS(&return,&x3,&x1); [line 63]\n " color=yellow style=filled] 39 -> 43 ; -38 [label="38: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 56]\n " shape="box"] +38 [label="38: DeclStmt \n _fun_function::X1_X1(&x1:class function::X1 *) [line 58]\n " shape="box"] 38 -> 37 ; -37 [label="37: DeclStmt \n _fun_X3_X3(&x3:class X3 *) [line 57]\n " shape="box"] +37 [label="37: DeclStmt \n _fun_function::X3_X3(&x3:class function::X3 *) [line 59]\n " shape="box"] 37 -> 36 ; -36 [label="36: Return Stmt \n n$0=_fun_getVal(&x1:class X1 &) [line 58]\n n$1=_fun_getVal(&x3:class X3 &) [line 58]\n *&return:int =(n$0 / n$1) [line 58]\n " shape="box"] +36 [label="36: Return Stmt \n n$0=_fun_function::getVal(&x1:class function::X1 &) [line 60]\n n$1=_fun_function::getVal(&x3:class function::X3 &) [line 60]\n *&return:int =(n$0 / n$1) [line 60]\n " shape="box"] 36 -> 35 ; -35 [label="35: Exit div0_get_val \n " color=yellow style=filled] +35 [label="35: Exit function::div0_get_val \n " color=yellow style=filled] -34 [label="34: Start div0_get_val\nFormals: \nLocals: x3:class X3 x1:class X1 \n DECLARE_LOCALS(&return,&x3,&x1); [line 55]\n " color=yellow style=filled] +34 [label="34: Start function::div0_get_val\nFormals: \nLocals: x3:class function::X3 x1:class function::X1 \n DECLARE_LOCALS(&return,&x3,&x1); [line 57]\n " color=yellow style=filled] 34 -> 38 ; -33 [label="33: Return Stmt \n n$0=_fun_createAndGetVal() [line 41]\n *&return:int =(1 / n$0) [line 41]\n " shape="box"] +33 [label="33: Return Stmt \n n$0=_fun_function::createAndGetVal() [line 43]\n *&return:int =(1 / n$0) [line 43]\n " shape="box"] 33 -> 32 ; -32 [label="32: Exit createAndDiv \n " color=yellow style=filled] +32 [label="32: Exit function::createAndDiv \n " color=yellow style=filled] -31 [label="31: Start createAndDiv\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] +31 [label="31: Start function::createAndDiv\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] 31 -> 33 ; -30 [label="30: Return Stmt \n n$0=_fun_createAndGetVal() [line 41]\n *&return:int =(1 / n$0) [line 41]\n " shape="box"] +30 [label="30: Return Stmt \n n$0=_fun_function::createAndGetVal() [line 43]\n *&return:int =(1 / n$0) [line 43]\n " shape="box"] 30 -> 29 ; -29 [label="29: Exit createAndDiv \n " color=yellow style=filled] +29 [label="29: Exit function::createAndDiv \n " color=yellow style=filled] -28 [label="28: Start createAndDiv\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] +28 [label="28: Start function::createAndDiv\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] 28 -> 30 ; -27 [label="27: DeclStmt \n _fun_X1_X1(&x:class X1 *) [line 35]\n " shape="box"] +27 [label="27: DeclStmt \n _fun_function::X1_X1(&x:class function::X1 *) [line 37]\n " shape="box"] 27 -> 26 ; -26 [label="26: Return Stmt \n n$0=_fun_getVal(&x:class X1 &) [line 36]\n *&return:int =n$0 [line 36]\n " shape="box"] +26 [label="26: Return Stmt \n n$0=_fun_function::getVal(&x:class function::X1 &) [line 38]\n *&return:int =n$0 [line 38]\n " shape="box"] 26 -> 25 ; -25 [label="25: Exit createAndGetVal \n " color=yellow style=filled] +25 [label="25: Exit function::createAndGetVal \n " color=yellow style=filled] -24 [label="24: Start createAndGetVal\nFormals: \nLocals: x:class X1 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled] +24 [label="24: Start function::createAndGetVal\nFormals: \nLocals: x:class function::X1 \n DECLARE_LOCALS(&return,&x); [line 36]\n " color=yellow style=filled] 24 -> 27 ; -23 [label="23: DeclStmt \n _fun_X3_X3(&x:class X3 *) [line 35]\n " shape="box"] +23 [label="23: DeclStmt \n _fun_function::X3_X3(&x:class function::X3 *) [line 37]\n " shape="box"] 23 -> 22 ; -22 [label="22: Return Stmt \n n$0=_fun_getVal(&x:class X3 &) [line 36]\n *&return:int =n$0 [line 36]\n " shape="box"] +22 [label="22: Return Stmt \n n$0=_fun_function::getVal(&x:class function::X3 &) [line 38]\n *&return:int =n$0 [line 38]\n " shape="box"] 22 -> 21 ; -21 [label="21: Exit createAndGetVal \n " color=yellow style=filled] +21 [label="21: Exit function::createAndGetVal \n " color=yellow style=filled] -20 [label="20: Start createAndGetVal\nFormals: \nLocals: x:class X3 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled] +20 [label="20: Start function::createAndGetVal\nFormals: \nLocals: x:class function::X3 \n DECLARE_LOCALS(&return,&x); [line 36]\n " color=yellow style=filled] 20 -> 23 ; -19 [label="19: Return Stmt \n n$0=*&x:class X3 & [line 30]\n _=*n$0:class X3 [line 30]\n n$2=_fun_X3_get(n$0:class X3 &) [line 30]\n *&return:int =n$2 [line 30]\n " shape="box"] +19 [label="19: Return Stmt \n n$0=*&x:class function::X3 & [line 32]\n _=*n$0:class function::X3 [line 32]\n n$2=_fun_function::X3_get(n$0:class function::X3 &) [line 32]\n *&return:int =n$2 [line 32]\n " shape="box"] 19 -> 18 ; -18 [label="18: Exit getVal \n " color=yellow style=filled] +18 [label="18: Exit function::getVal \n " color=yellow style=filled] -17 [label="17: Start getVal\nFormals: x:class X3 &\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] +17 [label="17: Start function::getVal\nFormals: x:class function::X3 &\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 17 -> 19 ; -16 [label="16: Return Stmt \n n$0=*&x:class X1 & [line 24]\n _=*n$0:class X1 [line 24]\n n$2=_fun_X1_getVal(n$0:class X1 &) [line 24]\n *&return:int =n$2 [line 24]\n " shape="box"] +16 [label="16: Return Stmt \n n$0=*&x:class function::X1 & [line 26]\n _=*n$0:class function::X1 [line 26]\n n$2=_fun_function::X1_getVal(n$0:class function::X1 &) [line 26]\n *&return:int =n$2 [line 26]\n " shape="box"] 16 -> 15 ; -15 [label="15: Exit getVal \n " color=yellow style=filled] +15 [label="15: Exit function::getVal \n " color=yellow style=filled] -14 [label="14: Start getVal\nFormals: x:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] +14 [label="14: Start function::getVal\nFormals: x:class function::X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 14 -> 16 ; -13 [label="13: Exit X3_X3 \n " color=yellow style=filled] +13 [label="13: Exit function::X3_X3 \n " color=yellow style=filled] -12 [label="12: Start X3_X3\nFormals: this:class X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] +12 [label="12: Start function::X3_X3\nFormals: this:class function::X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 12 -> 13 ; -11 [label="11: Return Stmt \n *&return:int =0 [line 19]\n " shape="box"] +11 [label="11: Return Stmt \n *&return:int =0 [line 21]\n " shape="box"] 11 -> 10 ; -10 [label="10: Exit X3_get \n " color=yellow style=filled] +10 [label="10: Exit function::X3_get \n " color=yellow style=filled] -9 [label="9: Start X3_get\nFormals: this:class X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +9 [label="9: Start function::X3_get\nFormals: this:class function::X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 9 -> 11 ; -8 [label="8: Return Stmt \n *&return:int =0 [line 15]\n " shape="box"] +8 [label="8: Return Stmt \n *&return:int =0 [line 17]\n " shape="box"] 8 -> 7 ; -7 [label="7: Exit X2_getVal \n " color=yellow style=filled] +7 [label="7: Exit function::X2_getVal \n " color=yellow style=filled] -6 [label="6: Start X2_getVal\nFormals: this:class X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +6 [label="6: Start function::X2_getVal\nFormals: this:class function::X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: Exit X1_X1 \n " color=yellow style=filled] +5 [label="5: Exit function::X1_X1 \n " color=yellow style=filled] -4 [label="4: Start X1_X1\nFormals: this:class X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +4 [label="4: Start function::X1_X1\nFormals: this:class function::X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 4 -> 5 ; -3 [label="3: Return Stmt \n *&return:int =1 [line 11]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =1 [line 13]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X1_getVal \n " color=yellow style=filled] +2 [label="2: Exit function::X1_getVal \n " color=yellow style=filled] -1 [label="1: Start X1_getVal\nFormals: this:class X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] +1 [label="1: Start function::X1_getVal\nFormals: this:class function::X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp index 545234aa3..d0cc68f3a 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace method { + struct X1 { int get() { return 1; } }; @@ -73,3 +75,4 @@ int div1_getter_templ2() { GetterTempl g; return 1 / g.get(x1_1, x1_2); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot index 3f7e45444..4afbfe8b2 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot @@ -1,280 +1,280 @@ /* @generated */ digraph iCFG { -75 [label="75: DeclStmt \n _fun_X1_X1(&x1_1:class X1 *) [line 71]\n " shape="box"] +75 [label="75: DeclStmt \n _fun_method::X1_X1(&x1_1:class method::X1 *) [line 73]\n " shape="box"] 75 -> 74 ; -74 [label="74: DeclStmt \n _fun_X1_X1(&x1_2:class X1 *) [line 72]\n " shape="box"] +74 [label="74: DeclStmt \n _fun_method::X1_X1(&x1_2:class method::X1 *) [line 74]\n " shape="box"] 74 -> 73 ; -73 [label="73: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 73]\n " shape="box"] +73 [label="73: DeclStmt \n _fun_method::GetterTempl_GetterTempl(&g:class method::GetterTempl *) [line 75]\n " shape="box"] 73 -> 72 ; -72 [label="72: Return Stmt \n _=*&g:class GetterTempl [line 74]\n n$1=_fun_GetterTempl_get(&g:class GetterTempl &,&x1_1:class X1 &,&x1_2:class X1 &) [line 74]\n *&return:int =(1 / n$1) [line 74]\n " shape="box"] +72 [label="72: Return Stmt \n _=*&g:class method::GetterTempl [line 76]\n n$1=_fun_method::GetterTempl_get(&g:class method::GetterTempl &,&x1_1:class method::X1 &,&x1_2:class method::X1 &) [line 76]\n *&return:int =(1 / n$1) [line 76]\n " shape="box"] 72 -> 71 ; -71 [label="71: Exit div1_getter_templ2 \n " color=yellow style=filled] +71 [label="71: Exit method::div1_getter_templ2 \n " color=yellow style=filled] -70 [label="70: Start div1_getter_templ2\nFormals: \nLocals: g:class GetterTempl x1_2:class X1 x1_1:class X1 \n DECLARE_LOCALS(&return,&g,&x1_2,&x1_1); [line 70]\n " color=yellow style=filled] +70 [label="70: Start method::div1_getter_templ2\nFormals: \nLocals: g:class method::GetterTempl x1_2:class method::X1 x1_1:class method::X1 \n DECLARE_LOCALS(&return,&g,&x1_2,&x1_1); [line 72]\n " color=yellow style=filled] 70 -> 75 ; -69 [label="69: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 64]\n " shape="box"] +69 [label="69: DeclStmt \n _fun_method::X1_X1(&x1:class method::X1 *) [line 66]\n " shape="box"] 69 -> 68 ; -68 [label="68: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 65]\n " shape="box"] +68 [label="68: DeclStmt \n _fun_method::X2_X2(&x2:class method::X2 *) [line 67]\n " shape="box"] 68 -> 67 ; -67 [label="67: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 66]\n " shape="box"] +67 [label="67: DeclStmt \n _fun_method::GetterTempl_GetterTempl(&g:class method::GetterTempl *) [line 68]\n " shape="box"] 67 -> 66 ; -66 [label="66: Return Stmt \n _=*&g:class GetterTempl [line 67]\n n$1=_fun_GetterTempl_get(&g:class GetterTempl &,&x2:class X2 &,&x1:class X1 &) [line 67]\n *&return:int =(1 / n$1) [line 67]\n " shape="box"] +66 [label="66: Return Stmt \n _=*&g:class method::GetterTempl [line 69]\n n$1=_fun_method::GetterTempl_get(&g:class method::GetterTempl &,&x2:class method::X2 &,&x1:class method::X1 &) [line 69]\n *&return:int =(1 / n$1) [line 69]\n " shape="box"] 66 -> 65 ; -65 [label="65: Exit div1_getter_templ \n " color=yellow style=filled] +65 [label="65: Exit method::div1_getter_templ \n " color=yellow style=filled] -64 [label="64: Start div1_getter_templ\nFormals: \nLocals: g:class GetterTempl x2:class X2 x1:class X1 \n DECLARE_LOCALS(&return,&g,&x2,&x1); [line 63]\n " color=yellow style=filled] +64 [label="64: Start method::div1_getter_templ\nFormals: \nLocals: g:class method::GetterTempl x2:class method::X2 x1:class method::X1 \n DECLARE_LOCALS(&return,&g,&x2,&x1); [line 65]\n " color=yellow style=filled] 64 -> 69 ; -63 [label="63: DeclStmt \n _fun_X2_X2(&x2_1:class X2 *) [line 57]\n " shape="box"] +63 [label="63: DeclStmt \n _fun_method::X2_X2(&x2_1:class method::X2 *) [line 59]\n " shape="box"] 63 -> 62 ; -62 [label="62: DeclStmt \n _fun_X2_X2(&x2_2:class X2 *) [line 58]\n " shape="box"] +62 [label="62: DeclStmt \n _fun_method::X2_X2(&x2_2:class method::X2 *) [line 60]\n " shape="box"] 62 -> 61 ; -61 [label="61: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 59]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_method::GetterTempl_GetterTempl(&g:class method::GetterTempl *) [line 61]\n " shape="box"] 61 -> 60 ; -60 [label="60: Return Stmt \n _=*&g:class GetterTempl [line 60]\n n$1=_fun_GetterTempl_get(&g:class GetterTempl &,&x2_1:class X2 &,&x2_2:class X2 &) [line 60]\n *&return:int =(1 / n$1) [line 60]\n " shape="box"] +60 [label="60: Return Stmt \n _=*&g:class method::GetterTempl [line 62]\n n$1=_fun_method::GetterTempl_get(&g:class method::GetterTempl &,&x2_1:class method::X2 &,&x2_2:class method::X2 &) [line 62]\n *&return:int =(1 / n$1) [line 62]\n " shape="box"] 60 -> 59 ; -59 [label="59: Exit div0_getter_templ2 \n " color=yellow style=filled] +59 [label="59: Exit method::div0_getter_templ2 \n " color=yellow style=filled] -58 [label="58: Start div0_getter_templ2\nFormals: \nLocals: g:class GetterTempl x2_2:class X2 x2_1:class X2 \n DECLARE_LOCALS(&return,&g,&x2_2,&x2_1); [line 56]\n " color=yellow style=filled] +58 [label="58: Start method::div0_getter_templ2\nFormals: \nLocals: g:class method::GetterTempl x2_2:class method::X2 x2_1:class method::X2 \n DECLARE_LOCALS(&return,&g,&x2_2,&x2_1); [line 58]\n " color=yellow style=filled] 58 -> 63 ; -57 [label="57: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 50]\n " shape="box"] +57 [label="57: DeclStmt \n _fun_method::X2_X2(&x2:class method::X2 *) [line 52]\n " shape="box"] 57 -> 56 ; -56 [label="56: DeclStmt \n _fun_X3_X3(&x3:class X3 *) [line 51]\n " shape="box"] +56 [label="56: DeclStmt \n _fun_method::X3_X3(&x3:class method::X3 *) [line 53]\n " shape="box"] 56 -> 55 ; -55 [label="55: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 52]\n " shape="box"] +55 [label="55: DeclStmt \n _fun_method::GetterTempl_GetterTempl(&g:class method::GetterTempl *) [line 54]\n " shape="box"] 55 -> 54 ; -54 [label="54: Return Stmt \n _=*&g:class GetterTempl [line 53]\n n$1=_fun_GetterTempl_get(&g:class GetterTempl &,&x3:class X3 &,&x2:class X2 &) [line 53]\n *&return:int =(1 / n$1) [line 53]\n " shape="box"] +54 [label="54: Return Stmt \n _=*&g:class method::GetterTempl [line 55]\n n$1=_fun_method::GetterTempl_get(&g:class method::GetterTempl &,&x3:class method::X3 &,&x2:class method::X2 &) [line 55]\n *&return:int =(1 / n$1) [line 55]\n " shape="box"] 54 -> 53 ; -53 [label="53: Exit div0_getter_templ \n " color=yellow style=filled] +53 [label="53: Exit method::div0_getter_templ \n " color=yellow style=filled] -52 [label="52: Start div0_getter_templ\nFormals: \nLocals: g:class GetterTempl x3:class X3 x2:class X2 \n DECLARE_LOCALS(&return,&g,&x3,&x2); [line 49]\n " color=yellow style=filled] +52 [label="52: Start method::div0_getter_templ\nFormals: \nLocals: g:class method::GetterTempl x3:class method::X3 x2:class method::X2 \n DECLARE_LOCALS(&return,&g,&x3,&x2); [line 51]\n " color=yellow style=filled] 52 -> 57 ; -51 [label="51: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 44]\n " shape="box"] +51 [label="51: DeclStmt \n _fun_method::X1_X1(&x1:class method::X1 *) [line 46]\n " shape="box"] 51 -> 50 ; -50 [label="50: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 45]\n " shape="box"] +50 [label="50: DeclStmt \n _fun_method::Getter_Getter(&g:class method::Getter *) [line 47]\n " shape="box"] 50 -> 49 ; -49 [label="49: Return Stmt \n _=*&g:class Getter [line 46]\n n$1=_fun_Getter_get(&g:class Getter &,&x1:class X1 &) [line 46]\n *&return:int =(1 / n$1) [line 46]\n " shape="box"] +49 [label="49: Return Stmt \n _=*&g:class method::Getter [line 48]\n n$1=_fun_method::Getter_get(&g:class method::Getter &,&x1:class method::X1 &) [line 48]\n *&return:int =(1 / n$1) [line 48]\n " shape="box"] 49 -> 48 ; -48 [label="48: Exit div1_getter \n " color=yellow style=filled] +48 [label="48: Exit method::div1_getter \n " color=yellow style=filled] -47 [label="47: Start div1_getter\nFormals: \nLocals: g:class Getter x1:class X1 \n DECLARE_LOCALS(&return,&g,&x1); [line 43]\n " color=yellow style=filled] +47 [label="47: Start method::div1_getter\nFormals: \nLocals: g:class method::Getter x1:class method::X1 \n DECLARE_LOCALS(&return,&g,&x1); [line 45]\n " color=yellow style=filled] 47 -> 51 ; -46 [label="46: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 38]\n " shape="box"] +46 [label="46: DeclStmt \n _fun_method::X2_X2(&x2:class method::X2 *) [line 40]\n " shape="box"] 46 -> 45 ; -45 [label="45: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 39]\n " shape="box"] +45 [label="45: DeclStmt \n _fun_method::Getter_Getter(&g:class method::Getter *) [line 41]\n " shape="box"] 45 -> 44 ; -44 [label="44: Return Stmt \n _=*&g:class Getter [line 40]\n n$1=_fun_Getter_get(&g:class Getter &,&x2:class X2 &) [line 40]\n *&return:int =(1 / n$1) [line 40]\n " shape="box"] +44 [label="44: Return Stmt \n _=*&g:class method::Getter [line 42]\n n$1=_fun_method::Getter_get(&g:class method::Getter &,&x2:class method::X2 &) [line 42]\n *&return:int =(1 / n$1) [line 42]\n " shape="box"] 44 -> 43 ; -43 [label="43: Exit div0_getter \n " color=yellow style=filled] +43 [label="43: Exit method::div0_getter \n " color=yellow style=filled] -42 [label="42: Start div0_getter\nFormals: \nLocals: g:class Getter x2:class X2 \n DECLARE_LOCALS(&return,&g,&x2); [line 37]\n " color=yellow style=filled] +42 [label="42: Start method::div0_getter\nFormals: \nLocals: g:class method::Getter x2:class method::X2 \n DECLARE_LOCALS(&return,&g,&x2); [line 39]\n " color=yellow style=filled] 42 -> 46 ; -41 [label="41: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] +41 [label="41: Exit method::GetterTempl_GetterTempl \n " color=yellow style=filled] -40 [label="40: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] +40 [label="40: Start method::GetterTempl_GetterTempl\nFormals: this:class method::GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] 40 -> 41 ; -39 [label="39: Return Stmt \n n$0=*&t:class X1 & [line 33]\n _=*n$0:class X1 [line 33]\n n$2=_fun_X1_get(n$0:class X1 &) [line 33]\n n$3=*&s:class X1 & [line 33]\n _=*n$3:class X1 [line 33]\n n$5=_fun_X1_get(n$3:class X1 &) [line 33]\n *&return:int =(n$2 + n$5) [line 33]\n " shape="box"] +39 [label="39: Return Stmt \n n$0=*&t:class method::X1 & [line 35]\n _=*n$0:class method::X1 [line 35]\n n$2=_fun_method::X1_get(n$0:class method::X1 &) [line 35]\n n$3=*&s:class method::X1 & [line 35]\n _=*n$3:class method::X1 [line 35]\n n$5=_fun_method::X1_get(n$3:class method::X1 &) [line 35]\n *&return:int =(n$2 + n$5) [line 35]\n " shape="box"] 39 -> 38 ; -38 [label="38: Exit GetterTempl_get \n " color=yellow style=filled] +38 [label="38: Exit method::GetterTempl_get \n " color=yellow style=filled] -37 [label="37: Start GetterTempl_get\nFormals: this:class GetterTempl * t:class X1 & s:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +37 [label="37: Start method::GetterTempl_get\nFormals: this:class method::GetterTempl * t:class method::X1 & s:class method::X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 37 -> 39 ; -36 [label="36: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] +36 [label="36: Exit method::GetterTempl_GetterTempl \n " color=yellow style=filled] -35 [label="35: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] +35 [label="35: Start method::GetterTempl_GetterTempl\nFormals: this:class method::GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] 35 -> 36 ; -34 [label="34: Return Stmt \n n$0=*&t:class X2 & [line 33]\n _=*n$0:class X2 [line 33]\n n$2=_fun_X2_get(n$0:class X2 &) [line 33]\n n$3=*&s:class X1 & [line 33]\n _=*n$3:class X1 [line 33]\n n$5=_fun_X1_get(n$3:class X1 &) [line 33]\n *&return:int =(n$2 + n$5) [line 33]\n " shape="box"] +34 [label="34: Return Stmt \n n$0=*&t:class method::X2 & [line 35]\n _=*n$0:class method::X2 [line 35]\n n$2=_fun_method::X2_get(n$0:class method::X2 &) [line 35]\n n$3=*&s:class method::X1 & [line 35]\n _=*n$3:class method::X1 [line 35]\n n$5=_fun_method::X1_get(n$3:class method::X1 &) [line 35]\n *&return:int =(n$2 + n$5) [line 35]\n " shape="box"] 34 -> 33 ; -33 [label="33: Exit GetterTempl_get \n " color=yellow style=filled] +33 [label="33: Exit method::GetterTempl_get \n " color=yellow style=filled] -32 [label="32: Start GetterTempl_get\nFormals: this:class GetterTempl * t:class X2 & s:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +32 [label="32: Start method::GetterTempl_get\nFormals: this:class method::GetterTempl * t:class method::X2 & s:class method::X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 32 -> 34 ; -31 [label="31: Return Stmt \n n$0=*&t:class X2 & [line 33]\n _=*n$0:class X2 [line 33]\n n$2=_fun_X2_get(n$0:class X2 &) [line 33]\n n$3=*&s:class X2 & [line 33]\n _=*n$3:class X2 [line 33]\n n$5=_fun_X2_get(n$3:class X2 &) [line 33]\n *&return:int =(n$2 + n$5) [line 33]\n " shape="box"] +31 [label="31: Return Stmt \n n$0=*&t:class method::X2 & [line 35]\n _=*n$0:class method::X2 [line 35]\n n$2=_fun_method::X2_get(n$0:class method::X2 &) [line 35]\n n$3=*&s:class method::X2 & [line 35]\n _=*n$3:class method::X2 [line 35]\n n$5=_fun_method::X2_get(n$3:class method::X2 &) [line 35]\n *&return:int =(n$2 + n$5) [line 35]\n " shape="box"] 31 -> 30 ; -30 [label="30: Exit GetterTempl_get \n " color=yellow style=filled] +30 [label="30: Exit method::GetterTempl_get \n " color=yellow style=filled] -29 [label="29: Start GetterTempl_get\nFormals: this:class GetterTempl * t:class X2 & s:class X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +29 [label="29: Start method::GetterTempl_get\nFormals: this:class method::GetterTempl * t:class method::X2 & s:class method::X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 29 -> 31 ; -28 [label="28: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] +28 [label="28: Exit method::GetterTempl_GetterTempl \n " color=yellow style=filled] -27 [label="27: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] +27 [label="27: Start method::GetterTempl_GetterTempl\nFormals: this:class method::GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] 27 -> 28 ; -26 [label="26: Return Stmt \n n$0=*&t:class X3 & [line 33]\n _=*n$0:class X3 [line 33]\n n$2=_fun_X3_get(n$0:class X3 &) [line 33]\n n$3=*&s:class X2 & [line 33]\n _=*n$3:class X2 [line 33]\n n$5=_fun_X2_get(n$3:class X2 &) [line 33]\n *&return:int =(n$2 + n$5) [line 33]\n " shape="box"] +26 [label="26: Return Stmt \n n$0=*&t:class method::X3 & [line 35]\n _=*n$0:class method::X3 [line 35]\n n$2=_fun_method::X3_get(n$0:class method::X3 &) [line 35]\n n$3=*&s:class method::X2 & [line 35]\n _=*n$3:class method::X2 [line 35]\n n$5=_fun_method::X2_get(n$3:class method::X2 &) [line 35]\n *&return:int =(n$2 + n$5) [line 35]\n " shape="box"] 26 -> 25 ; -25 [label="25: Exit GetterTempl_get \n " color=yellow style=filled] +25 [label="25: Exit method::GetterTempl_get \n " color=yellow style=filled] -24 [label="24: Start GetterTempl_get\nFormals: this:class GetterTempl * t:class X3 & s:class X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +24 [label="24: Start method::GetterTempl_get\nFormals: this:class method::GetterTempl * t:class method::X3 & s:class method::X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 24 -> 26 ; -23 [label="23: Exit Getter_Getter \n " color=yellow style=filled] +23 [label="23: Exit method::Getter_Getter \n " color=yellow style=filled] -22 [label="22: Start Getter_Getter\nFormals: this:class Getter *\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] +22 [label="22: Start method::Getter_Getter\nFormals: this:class method::Getter *\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 22 -> 23 ; -21 [label="21: Return Stmt \n n$0=*&s:class X1 & [line 25]\n _=*n$0:class X1 [line 25]\n n$2=_fun_X1_get(n$0:class X1 &) [line 25]\n *&return:int =n$2 [line 25]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&s:class method::X1 & [line 27]\n _=*n$0:class method::X1 [line 27]\n n$2=_fun_method::X1_get(n$0:class method::X1 &) [line 27]\n *&return:int =n$2 [line 27]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit Getter_get \n " color=yellow style=filled] +20 [label="20: Exit method::Getter_get \n " color=yellow style=filled] -19 [label="19: Start Getter_get\nFormals: this:class Getter * s:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +19 [label="19: Start method::Getter_get\nFormals: this:class method::Getter * s:class method::X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 19 -> 21 ; -18 [label="18: Return Stmt \n n$0=*&s:class X2 & [line 25]\n _=*n$0:class X2 [line 25]\n n$2=_fun_X2_get(n$0:class X2 &) [line 25]\n *&return:int =n$2 [line 25]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&s:class method::X2 & [line 27]\n _=*n$0:class method::X2 [line 27]\n n$2=_fun_method::X2_get(n$0:class method::X2 &) [line 27]\n *&return:int =n$2 [line 27]\n " shape="box"] 18 -> 17 ; -17 [label="17: Exit Getter_get \n " color=yellow style=filled] +17 [label="17: Exit method::Getter_get \n " color=yellow style=filled] -16 [label="16: Start Getter_get\nFormals: this:class Getter * s:class X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +16 [label="16: Start method::Getter_get\nFormals: this:class method::Getter * s:class method::X2 &\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 16 -> 18 ; -15 [label="15: Exit X3_X3 \n " color=yellow style=filled] +15 [label="15: Exit method::X3_X3 \n " color=yellow style=filled] -14 [label="14: Start X3_X3\nFormals: this:class X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] +14 [label="14: Start method::X3_X3\nFormals: this:class method::X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 14 -> 15 ; -13 [label="13: Return Stmt \n *&return:int =0 [line 19]\n " shape="box"] +13 [label="13: Return Stmt \n *&return:int =0 [line 21]\n " shape="box"] 13 -> 12 ; -12 [label="12: Exit X3_get \n " color=yellow style=filled] +12 [label="12: Exit method::X3_get \n " color=yellow style=filled] -11 [label="11: Start X3_get\nFormals: this:class X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +11 [label="11: Start method::X3_get\nFormals: this:class method::X3 *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: Exit X2_X2 \n " color=yellow style=filled] +10 [label="10: Exit method::X2_X2 \n " color=yellow style=filled] -9 [label="9: Start X2_X2\nFormals: this:class X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +9 [label="9: Start method::X2_X2\nFormals: this:class method::X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] 9 -> 10 ; -8 [label="8: Return Stmt \n *&return:int =0 [line 15]\n " shape="box"] +8 [label="8: Return Stmt \n *&return:int =0 [line 17]\n " shape="box"] 8 -> 7 ; -7 [label="7: Exit X2_get \n " color=yellow style=filled] +7 [label="7: Exit method::X2_get \n " color=yellow style=filled] -6 [label="6: Start X2_get\nFormals: this:class X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +6 [label="6: Start method::X2_get\nFormals: this:class method::X2 *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: Exit X1_X1 \n " color=yellow style=filled] +5 [label="5: Exit method::X1_X1 \n " color=yellow style=filled] -4 [label="4: Start X1_X1\nFormals: this:class X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +4 [label="4: Start method::X1_X1\nFormals: this:class method::X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 4 -> 5 ; -3 [label="3: Return Stmt \n *&return:int =1 [line 11]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =1 [line 13]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X1_get \n " color=yellow style=filled] +2 [label="2: Exit method::X1_get \n " color=yellow style=filled] -1 [label="1: Start X1_get\nFormals: this:class X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] +1 [label="1: Start method::X1_get\nFormals: this:class method::X1 *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp index 4c8d5953d..da1257f40 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace return_struct { + struct X { int f; // copy constructor that doesn't use init list @@ -42,3 +44,4 @@ int get_div1() { int get_field_div1() { return 1 / get(1).f; } int get_method_div1() { return get(1).div(); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot index 2b44b2d25..0756ef1c7 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot @@ -1,132 +1,132 @@ /* @generated */ digraph iCFG { -35 [label="35: Return Stmt \n _fun_get(1:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 44]\n n$2=_fun_X_div(&0$?%__sil_tmp__temp_return_n$1:class X &) [line 44]\n *&return:int =n$2 [line 44]\n " shape="box"] +35 [label="35: Return Stmt \n _fun_return_struct::get(1:int ,&0$?%__sil_tmp__temp_return_n$1:class return_struct::X *) [line 46]\n n$2=_fun_return_struct::X_div(&0$?%__sil_tmp__temp_return_n$1:class return_struct::X &) [line 46]\n *&return:int =n$2 [line 46]\n " shape="box"] 35 -> 34 ; -34 [label="34: Exit get_method_div1 \n " color=yellow style=filled] +34 [label="34: Exit return_struct::get_method_div1 \n " color=yellow style=filled] -33 [label="33: Start get_method_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 44]\n " color=yellow style=filled] +33 [label="33: Start return_struct::get_method_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class return_struct::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 46]\n " color=yellow style=filled] 33 -> 35 ; -32 [label="32: Return Stmt \n _fun_get(1:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 42]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 42]\n *&return:int =(1 / n$2) [line 42]\n " shape="box"] +32 [label="32: Return Stmt \n _fun_return_struct::get(1:int ,&0$?%__sil_tmp__temp_return_n$1:class return_struct::X *) [line 44]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 44]\n *&return:int =(1 / n$2) [line 44]\n " shape="box"] 32 -> 31 ; -31 [label="31: Exit get_field_div1 \n " color=yellow style=filled] +31 [label="31: Exit return_struct::get_field_div1 \n " color=yellow style=filled] -30 [label="30: Start get_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 42]\n " color=yellow style=filled] +30 [label="30: Start return_struct::get_field_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class return_struct::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 44]\n " color=yellow style=filled] 30 -> 32 ; -29 [label="29: DeclStmt \n _fun_get(1:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *) [line 38]\n _fun_X_X(&x:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 38]\n " shape="box"] +29 [label="29: DeclStmt \n _fun_return_struct::get(1:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X *) [line 40]\n _fun_return_struct::X_X(&x:class return_struct::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X &) [line 40]\n " shape="box"] 29 -> 28 ; -28 [label="28: Return Stmt \n n$0=*&x.f:int [line 39]\n *&return:int =(1 / n$0) [line 39]\n " shape="box"] +28 [label="28: Return Stmt \n n$0=*&x.f:int [line 41]\n *&return:int =(1 / n$0) [line 41]\n " shape="box"] 28 -> 27 ; -27 [label="27: Exit get_div1 \n " color=yellow style=filled] +27 [label="27: Exit return_struct::get_div1 \n " color=yellow style=filled] -26 [label="26: Start get_div1\nFormals: \nLocals: x:class X 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 37]\n " color=yellow style=filled] +26 [label="26: Start return_struct::get_div1\nFormals: \nLocals: x:class return_struct::X 0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 39]\n " color=yellow style=filled] 26 -> 29 ; -25 [label="25: Return Stmt \n _fun_get(0:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 35]\n n$2=_fun_X_div(&0$?%__sil_tmp__temp_return_n$1:class X &) [line 35]\n *&return:int =n$2 [line 35]\n " shape="box"] +25 [label="25: Return Stmt \n _fun_return_struct::get(0:int ,&0$?%__sil_tmp__temp_return_n$1:class return_struct::X *) [line 37]\n n$2=_fun_return_struct::X_div(&0$?%__sil_tmp__temp_return_n$1:class return_struct::X &) [line 37]\n *&return:int =n$2 [line 37]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit get_method_div0 \n " color=yellow style=filled] +24 [label="24: Exit return_struct::get_method_div0 \n " color=yellow style=filled] -23 [label="23: Start get_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 35]\n " color=yellow style=filled] +23 [label="23: Start return_struct::get_method_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class return_struct::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1); [line 37]\n " color=yellow style=filled] 23 -> 25 ; -22 [label="22: Call _fun_X_skip \n _fun_get(0:int ,&0$?%__sil_tmp__temp_return_n$4:class X *) [line 31]\n n$5=_fun_X_skip(&0$?%__sil_tmp__temp_return_n$4:class X &) [line 31]\n " shape="box"] +22 [label="22: Call _fun_return_struct::X_skip \n _fun_return_struct::get(0:int ,&0$?%__sil_tmp__temp_return_n$4:class return_struct::X *) [line 33]\n n$5=_fun_return_struct::X_skip(&0$?%__sil_tmp__temp_return_n$4:class return_struct::X &) [line 33]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n _fun_get(0:int ,&0$?%__sil_tmp__temp_return_n$1:class X *) [line 32]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 32]\n *&return:int =(1 / n$2) [line 32]\n " shape="box"] +21 [label="21: Return Stmt \n _fun_return_struct::get(0:int ,&0$?%__sil_tmp__temp_return_n$1:class return_struct::X *) [line 34]\n n$2=*&0$?%__sil_tmp__temp_return_n$1.f:int [line 34]\n *&return:int =(1 / n$2) [line 34]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit get_field_div0 \n " color=yellow style=filled] +20 [label="20: Exit return_struct::get_field_div0 \n " color=yellow style=filled] -19 [label="19: Start get_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class X 0$?%__sil_tmp__temp_return_n$4:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1,&0$?%__sil_tmp__temp_return_n$4); [line 30]\n " color=yellow style=filled] +19 [label="19: Start return_struct::get_field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_return_n$1:class return_struct::X 0$?%__sil_tmp__temp_return_n$4:class return_struct::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_return_n$1,&0$?%__sil_tmp__temp_return_n$4); [line 32]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: DeclStmt \n _fun_get(0:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *) [line 26]\n _fun_X_X(&x:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 26]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_return_struct::get(0:int ,&0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X *) [line 28]\n _fun_return_struct::X_X(&x:class return_struct::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X &) [line 28]\n " shape="box"] 18 -> 17 ; -17 [label="17: Return Stmt \n n$0=*&x.f:int [line 27]\n *&return:int =(1 / n$0) [line 27]\n " shape="box"] +17 [label="17: Return Stmt \n n$0=*&x.f:int [line 29]\n *&return:int =(1 / n$0) [line 29]\n " shape="box"] 17 -> 16 ; -16 [label="16: Exit get_div0 \n " color=yellow style=filled] +16 [label="16: Exit return_struct::get_div0 \n " color=yellow style=filled] -15 [label="15: Start get_div0\nFormals: \nLocals: x:class X 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 25]\n " color=yellow style=filled] +15 [label="15: Start return_struct::get_div0\nFormals: \nLocals: x:class return_struct::X 0$?%__sil_tmpSIL_materialize_temp__n$1:class return_struct::X \n DECLARE_LOCALS(&return,&x,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 27]\n " color=yellow style=filled] 15 -> 18 ; -14 [label="14: DeclStmt \n _fun_X_X(&x:class X *) [line 20]\n " shape="box"] +14 [label="14: DeclStmt \n _fun_return_struct::X_X(&x:class return_struct::X *) [line 22]\n " shape="box"] 14 -> 13 ; -13 [label="13: BinaryOperatorStmt: Assign \n n$1=*&a:int [line 21]\n *&x.f:int =n$1 [line 21]\n " shape="box"] +13 [label="13: BinaryOperatorStmt: Assign \n n$1=*&a:int [line 23]\n *&x.f:int =n$1 [line 23]\n " shape="box"] 13 -> 12 ; -12 [label="12: Return Stmt \n n$0=*&__return_param:class X * [line 22]\n _fun_X_X(n$0:class X *,&x:class X &) [line 22]\n " shape="box"] +12 [label="12: Return Stmt \n n$0=*&__return_param:class return_struct::X * [line 24]\n _fun_return_struct::X_X(n$0:class return_struct::X *,&x:class return_struct::X &) [line 24]\n " shape="box"] 12 -> 11 ; -11 [label="11: Exit get \n " color=yellow style=filled] +11 [label="11: Exit return_struct::get \n " color=yellow style=filled] -10 [label="10: Start get\nFormals: a:int __return_param:class X *\nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 19]\n " color=yellow style=filled] +10 [label="10: Start return_struct::get\nFormals: a:int __return_param:class return_struct::X *\nLocals: x:class return_struct::X \n DECLARE_LOCALS(&return,&x); [line 21]\n " color=yellow style=filled] 10 -> 14 ; -9 [label="9: Return Stmt \n n$0=*&this:class X * [line 15]\n n$1=*n$0.f:int [line 15]\n *&return:int =(1 / n$1) [line 15]\n " shape="box"] +9 [label="9: Return Stmt \n n$0=*&this:class return_struct::X * [line 17]\n n$1=*n$0.f:int [line 17]\n *&return:int =(1 / n$1) [line 17]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit X_div \n " color=yellow style=filled] +8 [label="8: Exit return_struct::X_div \n " color=yellow style=filled] -7 [label="7: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +7 [label="7: Start return_struct::X_div\nFormals: this:class return_struct::X *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 14]\n *n$0.f:int =1 [line 14]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class return_struct::X * [line 16]\n *n$0.f:int =1 [line 16]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit X_X \n " color=yellow style=filled] +5 [label="5: Exit return_struct::X_X \n " color=yellow style=filled] -4 [label="4: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +4 [label="4: Start return_struct::X_X\nFormals: this:class return_struct::X *\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 13]\n n$1=*&x:class X & [line 13]\n n$2=*n$1.f:int [line 13]\n *n$0.f:int =n$2 [line 13]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class return_struct::X * [line 15]\n n$1=*&x:class return_struct::X & [line 15]\n n$2=*n$1.f:int [line 15]\n *n$0.f:int =n$2 [line 15]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_X \n " color=yellow style=filled] +2 [label="2: Exit return_struct::X_X \n " color=yellow style=filled] -1 [label="1: Start X_X\nFormals: this:class X * x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +1 [label="1: Start return_struct::X_X\nFormals: this:class return_struct::X * x:class return_struct::X &\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp index ead4ff884..7109a1f15 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace struct_forward_declare { + // this will never be defined struct Y; @@ -65,3 +67,4 @@ int Z_ptr_div0(Z* z) { z->f = 0; return 1 / z->getF(); } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp.dot index 19dc2b7f8..c175c962f 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp.dot @@ -1,61 +1,61 @@ /* @generated */ digraph iCFG { -41 [label="41: BinaryOperatorStmt: Assign \n n$3=*&z:class Z * [line 65]\n *n$3.f:int =0 [line 65]\n " shape="box"] +41 [label="41: BinaryOperatorStmt: Assign \n n$3=*&z:class struct_forward_declare::Z * [line 67]\n *n$3.f:int =0 [line 67]\n " shape="box"] 41 -> 40 ; -40 [label="40: Return Stmt \n n$0=*&z:class Z * [line 66]\n _=*n$0:class Z [line 66]\n n$2=_fun_Z_getF(n$0:class Z *) [line 66]\n *&return:int =(1 / n$2) [line 66]\n " shape="box"] +40 [label="40: Return Stmt \n n$0=*&z:class struct_forward_declare::Z * [line 68]\n _=*n$0:class struct_forward_declare::Z [line 68]\n n$2=_fun_struct_forward_declare::Z_getF(n$0:class struct_forward_declare::Z *) [line 68]\n *&return:int =(1 / n$2) [line 68]\n " shape="box"] 40 -> 39 ; -39 [label="39: Exit Z_ptr_div0 \n " color=yellow style=filled] +39 [label="39: Exit struct_forward_declare::Z_ptr_div0 \n " color=yellow style=filled] -38 [label="38: Start Z_ptr_div0\nFormals: z:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 61]\n " color=yellow style=filled] +38 [label="38: Start struct_forward_declare::Z_ptr_div0\nFormals: z:class struct_forward_declare::Z *\nLocals: \n DECLARE_LOCALS(&return); [line 63]\n " color=yellow style=filled] 38 -> 41 ; -37 [label="37: DeclStmt \n _fun_Z_Z(&z:class Z *) [line 56]\n " shape="box"] +37 [label="37: DeclStmt \n _fun_struct_forward_declare::Z_Z(&z:class struct_forward_declare::Z *) [line 58]\n " shape="box"] 37 -> 36 ; -36 [label="36: BinaryOperatorStmt: Assign \n *&z.f:int =0 [line 57]\n " shape="box"] +36 [label="36: BinaryOperatorStmt: Assign \n *&z.f:int =0 [line 59]\n " shape="box"] 36 -> 35 ; -35 [label="35: Return Stmt \n _=*&z:class Z [line 58]\n n$1=_fun_Z_getF(&z:class Z &) [line 58]\n *&return:int =(1 / n$1) [line 58]\n " shape="box"] +35 [label="35: Return Stmt \n _=*&z:class struct_forward_declare::Z [line 60]\n n$1=_fun_struct_forward_declare::Z_getF(&z:class struct_forward_declare::Z &) [line 60]\n *&return:int =(1 / n$1) [line 60]\n " shape="box"] 35 -> 34 ; -34 [label="34: Exit Z_div0 \n " color=yellow style=filled] +34 [label="34: Exit struct_forward_declare::Z_div0 \n " color=yellow style=filled] -33 [label="33: Start Z_div0\nFormals: \nLocals: z:class Z \n DECLARE_LOCALS(&return,&z); [line 55]\n " color=yellow style=filled] +33 [label="33: Start struct_forward_declare::Z_div0\nFormals: \nLocals: z:class struct_forward_declare::Z \n DECLARE_LOCALS(&return,&z); [line 57]\n " color=yellow style=filled] 33 -> 37 ; -32 [label="32: DeclStmt \n _fun_X_X(&x:class X *) [line 46]\n " shape="box"] +32 [label="32: DeclStmt \n _fun_struct_forward_declare::X_X(&x:class struct_forward_declare::X *) [line 48]\n " shape="box"] 32 -> 31 ; -31 [label="31: BinaryOperatorStmt: Assign \n *&x.y:class Y *=null [line 47]\n " shape="box"] +31 [label="31: BinaryOperatorStmt: Assign \n *&x.y:class struct_forward_declare::Y *=null [line 49]\n " shape="box"] 31 -> 30 ; -30 [label="30: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 48]\n " shape="box"] +30 [label="30: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 50]\n " shape="box"] 30 -> 27 ; 30 -> 28 ; -29 [label="29: Return Stmt \n *&return:int =1 [line 50]\n " shape="box"] +29 [label="29: Return Stmt \n *&return:int =1 [line 52]\n " shape="box"] 29 -> 24 ; -28 [label="28: Prune (false branch) \n n$2=*&x.y:class Y * [line 49]\n PRUNE((n$2 == 0), false); [line 49]\n " shape="invhouse"] +28 [label="28: Prune (false branch) \n n$2=*&x.y:class struct_forward_declare::Y * [line 51]\n PRUNE((n$2 == 0), false); [line 51]\n " shape="invhouse"] 28 -> 26 ; -27 [label="27: Prune (true branch) \n n$2=*&x.y:class Y * [line 49]\n PRUNE((n$2 != 0), true); [line 49]\n " shape="invhouse"] +27 [label="27: Prune (true branch) \n n$2=*&x.y:class struct_forward_declare::Y * [line 51]\n PRUNE((n$2 != 0), true); [line 51]\n " shape="invhouse"] 27 -> 29 ; @@ -63,95 +63,95 @@ digraph iCFG { 26 -> 25 ; -25 [label="25: Return Stmt \n _=*&x:class X [line 52]\n n$1=_fun_X_getF(&x:class X &) [line 52]\n *&return:int =(1 / n$1) [line 52]\n " shape="box"] +25 [label="25: Return Stmt \n _=*&x:class struct_forward_declare::X [line 54]\n n$1=_fun_struct_forward_declare::X_getF(&x:class struct_forward_declare::X &) [line 54]\n *&return:int =(1 / n$1) [line 54]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit X_Y_div0 \n " color=yellow style=filled] +24 [label="24: Exit struct_forward_declare::X_Y_div0 \n " color=yellow style=filled] -23 [label="23: Start X_Y_div0\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 45]\n " color=yellow style=filled] +23 [label="23: Start struct_forward_declare::X_Y_div0\nFormals: \nLocals: x:class struct_forward_declare::X \n DECLARE_LOCALS(&return,&x); [line 47]\n " color=yellow style=filled] 23 -> 32 ; -22 [label="22: BinaryOperatorStmt: Assign \n n$3=*&x:class X * [line 41]\n *n$3.f:int =0 [line 41]\n " shape="box"] +22 [label="22: BinaryOperatorStmt: Assign \n n$3=*&x:class struct_forward_declare::X * [line 43]\n *n$3.f:int =0 [line 43]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n n$0=*&x:class X * [line 42]\n _=*n$0:class X [line 42]\n n$2=_fun_X_getF(n$0:class X *) [line 42]\n *&return:int =(1 / n$2) [line 42]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&x:class struct_forward_declare::X * [line 44]\n _=*n$0:class struct_forward_declare::X [line 44]\n n$2=_fun_struct_forward_declare::X_getF(n$0:class struct_forward_declare::X *) [line 44]\n *&return:int =(1 / n$2) [line 44]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit X_ptr_div0 \n " color=yellow style=filled] +20 [label="20: Exit struct_forward_declare::X_ptr_div0 \n " color=yellow style=filled] -19 [label="19: Start X_ptr_div0\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] +19 [label="19: Start struct_forward_declare::X_ptr_div0\nFormals: x:class struct_forward_declare::X *\nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: DeclStmt \n _fun_X_X(&x:class X *) [line 35]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_struct_forward_declare::X_X(&x:class struct_forward_declare::X *) [line 37]\n " shape="box"] 18 -> 17 ; -17 [label="17: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 36]\n " shape="box"] +17 [label="17: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 38]\n " shape="box"] 17 -> 16 ; -16 [label="16: Return Stmt \n _=*&x:class X [line 37]\n n$1=_fun_X_getF(&x:class X &) [line 37]\n *&return:int =(1 / n$1) [line 37]\n " shape="box"] +16 [label="16: Return Stmt \n _=*&x:class struct_forward_declare::X [line 39]\n n$1=_fun_struct_forward_declare::X_getF(&x:class struct_forward_declare::X &) [line 39]\n *&return:int =(1 / n$1) [line 39]\n " shape="box"] 16 -> 15 ; -15 [label="15: Exit X_div0 \n " color=yellow style=filled] +15 [label="15: Exit struct_forward_declare::X_div0 \n " color=yellow style=filled] -14 [label="14: Start X_div0\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled] +14 [label="14: Start struct_forward_declare::X_div0\nFormals: \nLocals: x:class struct_forward_declare::X \n DECLARE_LOCALS(&return,&x); [line 36]\n " color=yellow style=filled] 14 -> 18 ; -13 [label="13: Exit Z_Z \n " color=yellow style=filled] +13 [label="13: Exit struct_forward_declare::Z_Z \n " color=yellow style=filled] -12 [label="12: Start Z_Z\nFormals: this:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] +12 [label="12: Start struct_forward_declare::Z_Z\nFormals: this:class struct_forward_declare::Z *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 12 -> 13 ; -11 [label="11: Return Stmt \n n$0=*&this:class Z * [line 28]\n n$1=*n$0.f:int [line 28]\n *&return:int =n$1 [line 28]\n " shape="box"] +11 [label="11: Return Stmt \n n$0=*&this:class struct_forward_declare::Z * [line 30]\n n$1=*n$0.f:int [line 30]\n *&return:int =n$1 [line 30]\n " shape="box"] 11 -> 10 ; -10 [label="10: Exit Z_getF \n " color=yellow style=filled] +10 [label="10: Exit struct_forward_declare::Z_getF \n " color=yellow style=filled] -9 [label="9: Start Z_getF\nFormals: this:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] +9 [label="9: Start struct_forward_declare::Z_getF\nFormals: this:class struct_forward_declare::Z *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 9 -> 11 ; -8 [label="8: DeclStmt \n n$0=*&z1:class Z * [line 24]\n *&z2:class Z *=n$0 [line 24]\n " shape="box"] +8 [label="8: DeclStmt \n n$0=*&z1:class struct_forward_declare::Z * [line 26]\n *&z2:class struct_forward_declare::Z *=n$0 [line 26]\n " shape="box"] 8 -> 7 ; -7 [label="7: Exit fun_with_Z \n " color=yellow style=filled] +7 [label="7: Exit struct_forward_declare::fun_with_Z \n " color=yellow style=filled] -6 [label="6: Start fun_with_Z\nFormals: z1:class Z *\nLocals: z2:class Z * \n DECLARE_LOCALS(&return,&z2); [line 24]\n " color=yellow style=filled] +6 [label="6: Start struct_forward_declare::fun_with_Z\nFormals: z1:class struct_forward_declare::Z *\nLocals: z2:class struct_forward_declare::Z * \n DECLARE_LOCALS(&return,&z2); [line 26]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: Exit X_X \n " color=yellow style=filled] +5 [label="5: Exit struct_forward_declare::X_X \n " color=yellow style=filled] -4 [label="4: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +4 [label="4: Start struct_forward_declare::X_X\nFormals: this:class struct_forward_declare::X *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] 4 -> 5 ; -3 [label="3: Return Stmt \n n$0=*&this:class X * [line 19]\n n$1=*n$0.f:int [line 19]\n *&return:int =n$1 [line 19]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&this:class struct_forward_declare::X * [line 21]\n n$1=*n$0.f:int [line 21]\n *&return:int =n$1 [line 21]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_getF \n " color=yellow style=filled] +2 [label="2: Exit struct_forward_declare::X_getF \n " color=yellow style=filled] -1 [label="1: Start X_getF\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +1 [label="1: Start struct_forward_declare::X_getF\nFormals: this:class struct_forward_declare::X *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp index 26a724ec8..0cbf247f4 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +namespace struct_pass_by_value { + struct X { int f; X(int f) : f(f) {} @@ -53,3 +55,4 @@ int param_get_copied_div1() { set_f(x, 0); // this won't change x return 1 / x.f; } +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp.dot index c4ca05ffb..995097051 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp.dot @@ -1,177 +1,177 @@ /* @generated */ digraph iCFG { -47 [label="47: DeclStmt \n _fun_X_X(&x:class X *,1:int ) [line 52]\n " shape="box"] +47 [label="47: DeclStmt \n _fun_struct_pass_by_value::X_X(&x:class struct_pass_by_value::X *,1:int ) [line 54]\n " shape="box"] 47 -> 46 ; -46 [label="46: Call _fun_set_f \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$1:class X *,&x:class X &) [line 53]\n _fun_set_f(&0$?%__sil_tmp__temp_construct_n$1:class X ,0:int ) [line 53]\n " shape="box"] +46 [label="46: Call _fun_struct_pass_by_value::set_f \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X *,&x:class struct_pass_by_value::X &) [line 55]\n _fun_struct_pass_by_value::set_f(&0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X ,0:int ) [line 55]\n " shape="box"] 46 -> 45 ; -45 [label="45: Return Stmt \n n$0=*&x.f:int [line 54]\n *&return:int =(1 / n$0) [line 54]\n " shape="box"] +45 [label="45: Return Stmt \n n$0=*&x.f:int [line 56]\n *&return:int =(1 / n$0) [line 56]\n " shape="box"] 45 -> 44 ; -44 [label="44: Exit param_get_copied_div1 \n " color=yellow style=filled] +44 [label="44: Exit struct_pass_by_value::param_get_copied_div1 \n " color=yellow style=filled] -43 [label="43: Start param_get_copied_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$1:class X x:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$1,&x); [line 51]\n " color=yellow style=filled] +43 [label="43: Start struct_pass_by_value::param_get_copied_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X x:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$1,&x); [line 53]\n " color=yellow style=filled] 43 -> 47 ; -42 [label="42: DeclStmt \n _fun_X_X(&x:class X *,0:int ) [line 46]\n " shape="box"] +42 [label="42: DeclStmt \n _fun_struct_pass_by_value::X_X(&x:class struct_pass_by_value::X *,0:int ) [line 48]\n " shape="box"] 42 -> 41 ; -41 [label="41: Call _fun_set_f \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$1:class X *,&x:class X &) [line 47]\n _fun_set_f(&0$?%__sil_tmp__temp_construct_n$1:class X ,1:int ) [line 47]\n " shape="box"] +41 [label="41: Call _fun_struct_pass_by_value::set_f \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X *,&x:class struct_pass_by_value::X &) [line 49]\n _fun_struct_pass_by_value::set_f(&0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X ,1:int ) [line 49]\n " shape="box"] 41 -> 40 ; -40 [label="40: Return Stmt \n n$0=*&x.f:int [line 48]\n *&return:int =(1 / n$0) [line 48]\n " shape="box"] +40 [label="40: Return Stmt \n n$0=*&x.f:int [line 50]\n *&return:int =(1 / n$0) [line 50]\n " shape="box"] 40 -> 39 ; -39 [label="39: Exit param_get_copied_div0 \n " color=yellow style=filled] +39 [label="39: Exit struct_pass_by_value::param_get_copied_div0 \n " color=yellow style=filled] -38 [label="38: Start param_get_copied_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$1:class X x:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$1,&x); [line 45]\n " color=yellow style=filled] +38 [label="38: Start struct_pass_by_value::param_get_copied_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$1:class struct_pass_by_value::X x:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$1,&x); [line 47]\n " color=yellow style=filled] 38 -> 42 ; -37 [label="37: DeclStmt \n _fun_X_X(&x:class X *,0:int ) [line 40]\n " shape="box"] +37 [label="37: DeclStmt \n _fun_struct_pass_by_value::X_X(&x:class struct_pass_by_value::X *,0:int ) [line 42]\n " shape="box"] 37 -> 36 ; -36 [label="36: DeclStmt \n _fun_Y_Y(&y:class Y *,&x:class X &) [line 41]\n " shape="box"] +36 [label="36: DeclStmt \n _fun_struct_pass_by_value::Y_Y(&y:class struct_pass_by_value::Y *,&x:class struct_pass_by_value::X &) [line 43]\n " shape="box"] 36 -> 35 ; -35 [label="35: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&y.x:class X &) [line 42]\n n$1=_fun_get_f(&0$?%__sil_tmp__temp_construct_n$0:class X ) [line 42]\n *&return:int =(1 / n$1) [line 42]\n " shape="box"] +35 [label="35: Return Stmt \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X *,&y.x:class struct_pass_by_value::X &) [line 44]\n n$1=_fun_struct_pass_by_value::get_f(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X ) [line 44]\n *&return:int =(1 / n$1) [line 44]\n " shape="box"] 35 -> 34 ; -34 [label="34: Exit field_div0 \n " color=yellow style=filled] +34 [label="34: Exit struct_pass_by_value::field_div0 \n " color=yellow style=filled] -33 [label="33: Start field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X y:class Y x:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&y,&x); [line 39]\n " color=yellow style=filled] +33 [label="33: Start struct_pass_by_value::field_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X y:class struct_pass_by_value::Y x:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&y,&x); [line 41]\n " color=yellow style=filled] 33 -> 37 ; -32 [label="32: Return Stmt \n _fun_X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *,1:int ) [line 37]\n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 37]\n n$2=_fun_get_f(&0$?%__sil_tmp__temp_construct_n$0:class X ) [line 37]\n *&return:int =(1 / n$2) [line 37]\n " shape="box"] +32 [label="32: Return Stmt \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X *,1:int ) [line 39]\n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X &) [line 39]\n n$2=_fun_struct_pass_by_value::get_f(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X ) [line 39]\n *&return:int =(1 / n$2) [line 39]\n " shape="box"] 32 -> 31 ; -31 [label="31: Exit temp_div1 \n " color=yellow style=filled] +31 [label="31: Exit struct_pass_by_value::temp_div1 \n " color=yellow style=filled] -30 [label="30: Start temp_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 37]\n " color=yellow style=filled] +30 [label="30: Start struct_pass_by_value::temp_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X 0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 39]\n " color=yellow style=filled] 30 -> 32 ; -29 [label="29: Return Stmt \n _fun_X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class X *,0:int ) [line 35]\n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class X &) [line 35]\n n$2=_fun_get_f(&0$?%__sil_tmp__temp_construct_n$0:class X ) [line 35]\n *&return:int =(1 / n$2) [line 35]\n " shape="box"] +29 [label="29: Return Stmt \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X *,0:int ) [line 37]\n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X *,&0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X &) [line 37]\n n$2=_fun_struct_pass_by_value::get_f(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X ) [line 37]\n *&return:int =(1 / n$2) [line 37]\n " shape="box"] 29 -> 28 ; -28 [label="28: Exit temp_div0 \n " color=yellow style=filled] +28 [label="28: Exit struct_pass_by_value::temp_div0 \n " color=yellow style=filled] -27 [label="27: Start temp_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X 0$?%__sil_tmpSIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 35]\n " color=yellow style=filled] +27 [label="27: Start struct_pass_by_value::temp_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X 0$?%__sil_tmpSIL_materialize_temp__n$1:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&0$?%__sil_tmpSIL_materialize_temp__n$1); [line 37]\n " color=yellow style=filled] 27 -> 29 ; -26 [label="26: DeclStmt \n _fun_X_X(&x:class X *,1:int ) [line 31]\n " shape="box"] +26 [label="26: DeclStmt \n _fun_struct_pass_by_value::X_X(&x:class struct_pass_by_value::X *,1:int ) [line 33]\n " shape="box"] 26 -> 25 ; -25 [label="25: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&x:class X &) [line 32]\n n$1=_fun_get_f(&0$?%__sil_tmp__temp_construct_n$0:class X ) [line 32]\n *&return:int =(1 / n$1) [line 32]\n " shape="box"] +25 [label="25: Return Stmt \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X *,&x:class struct_pass_by_value::X &) [line 34]\n n$1=_fun_struct_pass_by_value::get_f(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X ) [line 34]\n *&return:int =(1 / n$1) [line 34]\n " shape="box"] 25 -> 24 ; -24 [label="24: Exit var_div1 \n " color=yellow style=filled] +24 [label="24: Exit struct_pass_by_value::var_div1 \n " color=yellow style=filled] -23 [label="23: Start var_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X x:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&x); [line 30]\n " color=yellow style=filled] +23 [label="23: Start struct_pass_by_value::var_div1\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X x:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&x); [line 32]\n " color=yellow style=filled] 23 -> 26 ; -22 [label="22: DeclStmt \n _fun_X_X(&x:class X *,0:int ) [line 26]\n " shape="box"] +22 [label="22: DeclStmt \n _fun_struct_pass_by_value::X_X(&x:class struct_pass_by_value::X *,0:int ) [line 28]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n _fun_X_X(&0$?%__sil_tmp__temp_construct_n$0:class X *,&x:class X &) [line 27]\n n$1=_fun_get_f(&0$?%__sil_tmp__temp_construct_n$0:class X ) [line 27]\n *&return:int =(1 / n$1) [line 27]\n " shape="box"] +21 [label="21: Return Stmt \n _fun_struct_pass_by_value::X_X(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X *,&x:class struct_pass_by_value::X &) [line 29]\n n$1=_fun_struct_pass_by_value::get_f(&0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X ) [line 29]\n *&return:int =(1 / n$1) [line 29]\n " shape="box"] 21 -> 20 ; -20 [label="20: Exit var_div0 \n " color=yellow style=filled] +20 [label="20: Exit struct_pass_by_value::var_div0 \n " color=yellow style=filled] -19 [label="19: Start var_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class X x:class X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&x); [line 25]\n " color=yellow style=filled] +19 [label="19: Start struct_pass_by_value::var_div0\nFormals: \nLocals: 0$?%__sil_tmp__temp_construct_n$0:class struct_pass_by_value::X x:class struct_pass_by_value::X \n DECLARE_LOCALS(&return,&0$?%__sil_tmp__temp_construct_n$0,&x); [line 27]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: BinaryOperatorStmt: Assign \n n$0=*&val:class X & [line 23]\n n$1=*&f:int [line 23]\n *n$0.f:int =n$1 [line 23]\n " shape="box"] +18 [label="18: BinaryOperatorStmt: Assign \n n$0=*&val:class struct_pass_by_value::X & [line 25]\n n$1=*&f:int [line 25]\n *n$0.f:int =n$1 [line 25]\n " shape="box"] 18 -> 17 ; -17 [label="17: Exit set_f \n " color=yellow style=filled] +17 [label="17: Exit struct_pass_by_value::set_f \n " color=yellow style=filled] -16 [label="16: Start set_f\nFormals: val:class X & f:int \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] +16 [label="16: Start struct_pass_by_value::set_f\nFormals: val:class struct_pass_by_value::X & f:int \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 16 -> 18 ; -15 [label="15: Return Stmt \n n$0=*&val:class X & [line 20]\n n$1=*n$0.f:int [line 20]\n *&return:int =n$1 [line 20]\n " shape="box"] +15 [label="15: Return Stmt \n n$0=*&val:class struct_pass_by_value::X & [line 22]\n n$1=*n$0.f:int [line 22]\n *&return:int =n$1 [line 22]\n " shape="box"] 15 -> 14 ; -14 [label="14: Exit get_f \n " color=yellow style=filled] +14 [label="14: Exit struct_pass_by_value::get_f \n " color=yellow style=filled] -13 [label="13: Start get_f\nFormals: val:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] +13 [label="13: Start struct_pass_by_value::get_f\nFormals: val:class struct_pass_by_value::X &\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Constructor Init \n n$0=*&this:class Y * [line 16]\n n$1=*&x:class X & [line 16]\n _fun_X_X(n$0.x:class X *,n$1:class X &) [line 16]\n " shape="box"] +12 [label="12: Constructor Init \n n$0=*&this:class struct_pass_by_value::Y * [line 18]\n n$1=*&x:class struct_pass_by_value::X & [line 18]\n _fun_struct_pass_by_value::X_X(n$0.x:class struct_pass_by_value::X *,n$1:class struct_pass_by_value::X &) [line 18]\n " shape="box"] 12 -> 11 ; -11 [label="11: Exit Y_Y \n " color=yellow style=filled] +11 [label="11: Exit struct_pass_by_value::Y_Y \n " color=yellow style=filled] -10 [label="10: Start Y_Y\nFormals: this:class Y * x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] +10 [label="10: Start struct_pass_by_value::Y_Y\nFormals: this:class struct_pass_by_value::Y * x:class struct_pass_by_value::X &\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 10 -> 12 ; -9 [label="9: Constructor Init \n n$0=*&this:class X * [line 10]\n n$1=*&__param_0:class X & [line 10]\n n$2=*n$1.f:int [line 10]\n *n$0.f:int =n$2 [line 10]\n " shape="box"] +9 [label="9: Constructor Init \n n$0=*&this:class struct_pass_by_value::X * [line 12]\n n$1=*&__param_0:class struct_pass_by_value::X & [line 12]\n n$2=*n$1.f:int [line 12]\n *n$0.f:int =n$2 [line 12]\n " shape="box"] 9 -> 8 ; -8 [label="8: Exit X_X \n " color=yellow style=filled] +8 [label="8: Exit struct_pass_by_value::X_X \n " color=yellow style=filled] -7 [label="7: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +7 [label="7: Start struct_pass_by_value::X_X\nFormals: this:class struct_pass_by_value::X * __param_0:class struct_pass_by_value::X &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Constructor Init \n n$0=*&this:class X * [line 10]\n n$1=*&__param_0:class X & [line 10]\n n$2=*n$1.f:int [line 10]\n *n$0.f:int =n$2 [line 10]\n " shape="box"] +6 [label="6: Constructor Init \n n$0=*&this:class struct_pass_by_value::X * [line 12]\n n$1=*&__param_0:class struct_pass_by_value::X & [line 12]\n n$2=*n$1.f:int [line 12]\n *n$0.f:int =n$2 [line 12]\n " shape="box"] 6 -> 5 ; -5 [label="5: Exit X_X \n " color=yellow style=filled] +5 [label="5: Exit struct_pass_by_value::X_X \n " color=yellow style=filled] -4 [label="4: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 10]\n " color=yellow style=filled] +4 [label="4: Start struct_pass_by_value::X_X\nFormals: this:class struct_pass_by_value::X * __param_0:class struct_pass_by_value::X &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Constructor Init \n n$0=*&this:class X * [line 12]\n n$1=*&f:int [line 12]\n *n$0.f:int =n$1 [line 12]\n " shape="box"] +3 [label="3: Constructor Init \n n$0=*&this:class struct_pass_by_value::X * [line 14]\n n$1=*&f:int [line 14]\n *n$0.f:int =n$1 [line 14]\n " shape="box"] 3 -> 2 ; -2 [label="2: Exit X_X \n " color=yellow style=filled] +2 [label="2: Exit struct_pass_by_value::X_X \n " color=yellow style=filled] -1 [label="1: Start X_X\nFormals: this:class X * f:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +1 [label="1: Start struct_pass_by_value::X_X\nFormals: this:class struct_pass_by_value::X * f:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/endtoend/BUCK b/infer/tests/endtoend/BUCK index 7b897c1bf..1ef22792f 100644 --- a/infer/tests/endtoend/BUCK +++ b/infer/tests/endtoend/BUCK @@ -34,17 +34,6 @@ java_test( ], ) -# ############### Cpp endtoend tests ######################## -java_test( - name='cpp_endtoend_tests', - deps=[ - '//infer/tests/endtoend/cpp/infer:infer', - ], - visibility=[ - 'PUBLIC', - ], -) - # ############### ObjCpp endtoend tests ######################## java_test( name='objcpp_endtoend_tests', diff --git a/infer/tests/endtoend/cpp/infer/BUCK b/infer/tests/endtoend/cpp/infer/BUCK deleted file mode 100644 index c1a3eab2c..000000000 --- a/infer/tests/endtoend/cpp/infer/BUCK +++ /dev/null @@ -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', - ], -) diff --git a/infer/tests/endtoend/cpp/infer/BoxedPtrTest.java b/infer/tests/endtoend/cpp/infer/BoxedPtrTest.java deleted file mode 100644 index 2087c1d84..000000000 --- a/infer/tests/endtoend/cpp/infer/BoxedPtrTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/CBugsTest.java b/infer/tests/endtoend/cpp/infer/CBugsTest.java deleted file mode 100644 index cc882eeb4..000000000 --- a/infer/tests/endtoend/cpp/infer/CBugsTest.java +++ /dev/null @@ -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 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")); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ClassTemplateTest.java b/infer/tests/endtoend/cpp/infer/ClassTemplateTest.java deleted file mode 100644 index 9a07ca4e9..000000000 --- a/infer/tests/endtoend/cpp/infer/ClassTemplateTest.java +++ /dev/null @@ -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 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_call_div", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ConstructorInitTest.java b/infer/tests/endtoend/cpp/infer/ConstructorInitTest.java deleted file mode 100644 index 1d48f9a53..000000000 --- a/infer/tests/endtoend/cpp/infer/ConstructorInitTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ConstructorNewTest.java b/infer/tests/endtoend/cpp/infer/ConstructorNewTest.java deleted file mode 100644 index 75313cbb2..000000000 --- a/infer/tests/endtoend/cpp/infer/ConstructorNewTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ConstructorWithBodyTest.java b/infer/tests/endtoend/cpp/infer/ConstructorWithBodyTest.java deleted file mode 100644 index c39191236..000000000 --- a/infer/tests/endtoend/cpp/infer/ConstructorWithBodyTest.java +++ /dev/null @@ -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 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" - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ConversionOperatorTest.java b/infer/tests/endtoend/cpp/infer/ConversionOperatorTest.java deleted file mode 100644 index a29617892..000000000 --- a/infer/tests/endtoend/cpp/infer/ConversionOperatorTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/CopyMoveConstructorTest.java b/infer/tests/endtoend/cpp/infer/CopyMoveConstructorTest.java deleted file mode 100644 index f634d4d76..000000000 --- a/infer/tests/endtoend/cpp/infer/CopyMoveConstructorTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/DeprecatedHackTest.java b/infer/tests/endtoend/cpp/infer/DeprecatedHackTest.java deleted file mode 100644 index 84005b37b..000000000 --- a/infer/tests/endtoend/cpp/infer/DeprecatedHackTest.java +++ /dev/null @@ -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 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 - ) - ); - } - - -} diff --git a/infer/tests/endtoend/cpp/infer/DerefAfterMoveTest.java b/infer/tests/endtoend/cpp/infer/DerefAfterMoveTest.java deleted file mode 100644 index 26427a747..000000000 --- a/infer/tests/endtoend/cpp/infer/DerefAfterMoveTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/DynamicCastTest.java b/infer/tests/endtoend/cpp/infer/DynamicCastTest.java deleted file mode 100644 index 9b7075200..000000000 --- a/infer/tests/endtoend/cpp/infer/DynamicCastTest.java +++ /dev/null @@ -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 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")); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/ExceptionsTest.java b/infer/tests/endtoend/cpp/infer/ExceptionsTest.java deleted file mode 100644 index 4e979b966..000000000 --- a/infer/tests/endtoend/cpp/infer/ExceptionsTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/FallthroughTest.java b/infer/tests/endtoend/cpp/infer/FallthroughTest.java deleted file mode 100644 index f98a5f540..000000000 --- a/infer/tests/endtoend/cpp/infer/FallthroughTest.java +++ /dev/null @@ -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 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 - ) - ); - } - - -} diff --git a/infer/tests/endtoend/cpp/infer/FunctionTemplateTest.java b/infer/tests/endtoend/cpp/infer/FunctionTemplateTest.java deleted file mode 100644 index 336978075..000000000 --- a/infer/tests/endtoend/cpp/infer/FunctionTemplateTest.java +++ /dev/null @@ -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 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", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/IncludeHeaderNoTemplTest.java b/infer/tests/endtoend/cpp/infer/IncludeHeaderNoTemplTest.java deleted file mode 100644 index ff575565f..000000000 --- a/infer/tests/endtoend/cpp/infer/IncludeHeaderNoTemplTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/IncludeHeaderTemplTest.java b/infer/tests/endtoend/cpp/infer/IncludeHeaderTemplTest.java deleted file mode 100644 index a50f06348..000000000 --- a/infer/tests/endtoend/cpp/infer/IncludeHeaderTemplTest.java +++ /dev/null @@ -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 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_div0", - "B_div0", - "div0_fun", - "div0_templ", - "div0_templ", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - HEADER, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/InheritanceFieldTest.java b/infer/tests/endtoend/cpp/infer/InheritanceFieldTest.java deleted file mode 100644 index 01093a2fb..000000000 --- a/infer/tests/endtoend/cpp/infer/InheritanceFieldTest.java +++ /dev/null @@ -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 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 - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/LValueConditionalTest.java b/infer/tests/endtoend/cpp/infer/LValueConditionalTest.java deleted file mode 100644 index a08a374dd..000000000 --- a/infer/tests/endtoend/cpp/infer/LValueConditionalTest.java +++ /dev/null @@ -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 LValueConditionalTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp"; - - private static ImmutableList 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_choose_lvalue", - "div0_choose_rvalue", - "div0_assign_conditional", - "div0_temp_lvalue", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/LambdaTest.java b/infer/tests/endtoend/cpp/infer/LambdaTest.java deleted file mode 100644 index 10fe53742..000000000 --- a/infer/tests/endtoend/cpp/infer/LambdaTest.java +++ /dev/null @@ -1,67 +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.ResultContainsNoErrorInMethod.doesNotContain; -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 LambdaTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/lambda/lambda1.cpp"; - - private static ImmutableList 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 = { - "bar", - "foo", - "foo::lambda_infer_tests_codetoanalyze_cpp_frontend_lambda_lambda1.cpp:19:17_operator()", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/MemoryLeakArrayTest.java b/infer/tests/endtoend/cpp/infer/MemoryLeakArrayTest.java deleted file mode 100644 index 36158d178..000000000 --- a/infer/tests/endtoend/cpp/infer/MemoryLeakArrayTest.java +++ /dev/null @@ -1,62 +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 MemoryLeakArrayTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/memory_leaks/array_leak.cpp"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCPPInferCommandWithMLBuckets(folder, FILE, "cpp"); - } - - @Test - public void whenInferRunsOnObject_leakThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] methods = { "leak" }; - assertThat( - "Results should contain " + MEMORY_LEAK, - inferResults, - containsExactly( - MEMORY_LEAK, - FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/MemoryLeakCppBucketTest.java b/infer/tests/endtoend/cpp/infer/MemoryLeakCppBucketTest.java deleted file mode 100644 index b6154bc69..000000000 --- a/infer/tests/endtoend/cpp/infer/MemoryLeakCppBucketTest.java +++ /dev/null @@ -1,62 +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 MemoryLeakCppBucketTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCPPInferCommandWithMLBuckets(folder, FILE, "cpp"); - } - - @Test - public void whenInferRunsOnObject_leakThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] methods = { "main" }; - assertThat( - "Results should contain " + MEMORY_LEAK, - inferResults, - containsExactly( - MEMORY_LEAK, - FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/MemoryLeakRaiiTest.java b/infer/tests/endtoend/cpp/infer/MemoryLeakRaiiTest.java deleted file mode 100644 index 9bbf2da6f..000000000 --- a/infer/tests/endtoend/cpp/infer/MemoryLeakRaiiTest.java +++ /dev/null @@ -1,62 +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 MemoryLeakRaiiTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/memory_leaks/raii_malloc.cpp"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCPPInferCommandWithMLBuckets(folder, FILE, "cpp"); - } - - @Test - public void whenInferRunsOnObject_leakThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] methods = { "memory_leak" }; - assertThat( - "Results should contain " + MEMORY_LEAK, - inferResults, - containsExactly( - MEMORY_LEAK, - FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/MemoryLeakTest.java b/infer/tests/endtoend/cpp/infer/MemoryLeakTest.java deleted file mode 100644 index c6df21288..000000000 --- a/infer/tests/endtoend/cpp/infer/MemoryLeakTest.java +++ /dev/null @@ -1,62 +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 MemoryLeakTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp"; - - private static ImmutableList inferCmd; - - public static final String MEMORY_LEAK = "MEMORY_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCPPInferCommand(folder, FILE); - } - - @Test - public void whenInferRunsOnObject_leakThenMLIsNotFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] methods = { }; // no memory leak - assertThat( - "Results should contain " + MEMORY_LEAK, - inferResults, - containsExactly( - MEMORY_LEAK, - FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/MethodTemplateTest.java b/infer/tests/endtoend/cpp/infer/MethodTemplateTest.java deleted file mode 100644 index ebb0c205e..000000000 --- a/infer/tests/endtoend/cpp/infer/MethodTemplateTest.java +++ /dev/null @@ -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 MethodTemplateTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp"; - - private static ImmutableList 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_getter", - "div0_getter_templ", - "div0_getter_templ2", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/MinMaxNumericTest.java b/infer/tests/endtoend/cpp/infer/MinMaxNumericTest.java deleted file mode 100644 index c9136a882..000000000 --- a/infer/tests/endtoend/cpp/infer/MinMaxNumericTest.java +++ /dev/null @@ -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 MinMaxNumericTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/numeric/min_max.cpp"; - - private static ImmutableList 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 = { - "min_int_div0", - "max_int_div0", - "min_X_div0", - "max_X_inv_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/MoveModelTest.java b/infer/tests/endtoend/cpp/infer/MoveModelTest.java deleted file mode 100644 index 7a5b6e2cd..000000000 --- a/infer/tests/endtoend/cpp/infer/MoveModelTest.java +++ /dev/null @@ -1,65 +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 MoveModelTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/models/move.cpp"; - - private static ImmutableList 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_moved_from", - "div0_moved_to", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NPEAddedToB1Test.java b/infer/tests/endtoend/cpp/infer/NPEAddedToB1Test.java deleted file mode 100644 index 68743b738..000000000 --- a/infer/tests/endtoend/cpp/infer/NPEAddedToB1Test.java +++ /dev/null @@ -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.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 NPEAddedToB1Test { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp"; - - private static ImmutableList 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, - ImmutableList.of("--filtering")); - } - - @Test - public void whenInferRunsOnMethodCallThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] procedures = {"causes_npe", "causes_npe_person"}; - assertThat( - "Results should contain " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NPEWhenMethodCallTest.java b/infer/tests/endtoend/cpp/infer/NPEWhenMethodCallTest.java deleted file mode 100644 index 5d5726b45..000000000 --- a/infer/tests/endtoend/cpp/infer/NPEWhenMethodCallTest.java +++ /dev/null @@ -1,63 +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 NPEWhenMethodCallTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/method_call.cpp"; - - private static ImmutableList 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 whenInferRunsOnMethodCallThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] procedures = {"npe_call", "npe_call_after_call", "npe_call_with_forward_declaration"}; - assertThat( - "Results should contain " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NamespaceFunctionTest.java b/infer/tests/endtoend/cpp/infer/NamespaceFunctionTest.java deleted file mode 100644 index 24ab5c873..000000000 --- a/infer/tests/endtoend/cpp/infer/NamespaceFunctionTest.java +++ /dev/null @@ -1,64 +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 NamespaceFunctionTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp"; - - private static ImmutableList 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_using", - "div0_namespace_resolution", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NamespaceGlobalVariableTest.java b/infer/tests/endtoend/cpp/infer/NamespaceGlobalVariableTest.java deleted file mode 100644 index 29589ce42..000000000 --- a/infer/tests/endtoend/cpp/infer/NamespaceGlobalVariableTest.java +++ /dev/null @@ -1,65 +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 NamespaceGlobalVariableTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp"; - - private static ImmutableList 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_namepace_res", - "div0_static_field", - "div0_static_field_member_access", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NestedCPPOperatorsTest.java b/infer/tests/endtoend/cpp/infer/NestedCPPOperatorsTest.java deleted file mode 100644 index 949d24595..000000000 --- a/infer/tests/endtoend/cpp/infer/NestedCPPOperatorsTest.java +++ /dev/null @@ -1,81 +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 NestedCPPOperatorsTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp"; - - private static ImmutableList inferCmd; - - public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; - 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 whenInferRunsOnDiv0MethodsErrorIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] proceduresWithDiv0 = { - "simple_init_div0", - "simple_inif_elseif_div0", - "function_call_init_div0", - "conditional_init_div0", - "reference_init_div0", - }; - for (String procedure : proceduresWithDiv0) { - assertThat( - "Results should contain the expected divide by zero", - inferResults, - contains( - DIVIDE_BY_ZERO, - FILE, - procedure - ) - ); - } - /* null dereference */ - assertThat( - "Results should contain the expected null dereference", - inferResults, - contains( - NULL_DEREFERENCE, - FILE, - "simple_init_null_deref" - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NoNPEAfterDynamicCastTest.java b/infer/tests/endtoend/cpp/infer/NoNPEAfterDynamicCastTest.java deleted file mode 100644 index 3693a9b8d..000000000 --- a/infer/tests/endtoend/cpp/infer/NoNPEAfterDynamicCastTest.java +++ /dev/null @@ -1,63 +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 NoNPEAfterDynamicCastTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/subtyping/cast_with_enforce.cpp"; - - private static ImmutableList 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 whenInferRunsOnCast_with_no_npeThenNoNPEFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] procedures = {"cast_with_npe"}; - assertThat( - "Results should not contain " + NULL_DEREFERENCE, - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/NullReturnedByMethodTest.java b/infer/tests/endtoend/cpp/infer/NullReturnedByMethodTest.java deleted file mode 100644 index 8b317dd43..000000000 --- a/infer/tests/endtoend/cpp/infer/NullReturnedByMethodTest.java +++ /dev/null @@ -1,77 +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 NullReturnedByMethodTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp"; - - private static ImmutableList 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 whenInferRunsOnTestNullDerefThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - FILE, - "testNullDeref" - ) - ); - } - - @Test - public void whenInferRunsOnTestNoNullDerefThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should not contain null pointer dereference error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - FILE, - "testNoNullDeref" - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/ObjectDereferenceTest.java b/infer/tests/endtoend/cpp/infer/ObjectDereferenceTest.java deleted file mode 100644 index a3fcb2133..000000000 --- a/infer/tests/endtoend/cpp/infer/ObjectDereferenceTest.java +++ /dev/null @@ -1,77 +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 ObjectDereferenceTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp"; - - private static ImmutableList 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 whenInferRunsOnDerefNullFieldThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain null pointer dereference error", - inferResults, - contains( - NULL_DEREFERENCE, - FILE, - "derefNullField" - ) - ); - } - - @Test - public void whenInferRunsOnDerefNonNullFieldThenNpeIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should not contain null pointer dereference error", - inferResults, - doesNotContain( - NULL_DEREFERENCE, - FILE, - "derefNonNullField" - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/OperatorOverloadTest.java b/infer/tests/endtoend/cpp/infer/OperatorOverloadTest.java deleted file mode 100644 index e0b27e79a..000000000 --- a/infer/tests/endtoend/cpp/infer/OperatorOverloadTest.java +++ /dev/null @@ -1,67 +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 OperatorOverloadTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp"; - - private static ImmutableList 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_method_op", - "div0_method_op_ptr", - "div0_function_op", - "div0_method", - "div0_inheritted_op", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ReferenceFieldTest.java b/infer/tests/endtoend/cpp/infer/ReferenceFieldTest.java deleted file mode 100644 index 501a5df61..000000000 --- a/infer/tests/endtoend/cpp/infer/ReferenceFieldTest.java +++ /dev/null @@ -1,74 +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 ReferenceFieldTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/reference/reference_field.cpp"; - - private static ImmutableList 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 = { - "ref_F_div0", - "ref_I_div0", - "ref_getF_div0", - "ref_getI_div0", - "ptr_F_div0", - "ptr_I_div0", - "ptr_getF_div0", - "ptr_getI_div0", - "val_F_div0", - "val_I_div0", - "val_getF_div0", - "val_getI_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ReferenceStructTest.java b/infer/tests/endtoend/cpp/infer/ReferenceStructTest.java deleted file mode 100644 index e3daaff8d..000000000 --- a/infer/tests/endtoend/cpp/infer/ReferenceStructTest.java +++ /dev/null @@ -1,70 +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 ReferenceStructTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp"; - - private static ImmutableList 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 = { - "method_div0_ptr", - "field_div0_ptr", - "get_global_ptr_div0_method", - "get_global_ptr_div0_field", - "method_div0_ref", - "field_div0_ref", - "get_global_ref_div0_method", - "get_global_ref_div0_field" - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ReferenceTypeTest.java b/infer/tests/endtoend/cpp/infer/ReferenceTypeTest.java deleted file mode 100644 index b1004c9e6..000000000 --- a/infer/tests/endtoend/cpp/infer/ReferenceTypeTest.java +++ /dev/null @@ -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 ReferenceTypeTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/reference/reference_type_e2e.cpp"; - - private static ImmutableList 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 = { - "ptr_div0", - "ptr_div0_function", - "ptr_div0_function_temp_var", - "ref_div0", - "ref_div0_function", - "ref_div0_function_temp_var", - "ref_div0_nested_assignment" - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ResourceLeakRaiiTest.java b/infer/tests/endtoend/cpp/infer/ResourceLeakRaiiTest.java deleted file mode 100644 index 1c954cc11..000000000 --- a/infer/tests/endtoend/cpp/infer/ResourceLeakRaiiTest.java +++ /dev/null @@ -1,62 +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 ResourceLeakRaiiTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/resource_leaks/raii.cpp"; - - private static ImmutableList inferCmd; - - public static final String RESOURCE_LEAK = "RESOURCE_LEAK"; - - @ClassRule - public static DebuggableTemporaryFolder folder = - new DebuggableTemporaryFolder(); - - @BeforeClass - public static void runInfer() throws InterruptedException, IOException { - inferCmd = InferRunner.createCPPInferCommandWithMLBuckets(folder, FILE, "cpp"); - } - - @Test - public void whenInferRunsOnObject_leakThenMLIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] methods = { "resource_leak" }; - assertThat( - "Results should contain " + RESOURCE_LEAK, - inferResults, - containsExactly( - RESOURCE_LEAK, - FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/cpp/infer/ReturnStructTest.java b/infer/tests/endtoend/cpp/infer/ReturnStructTest.java deleted file mode 100644 index 6ae9a5d21..000000000 --- a/infer/tests/endtoend/cpp/infer/ReturnStructTest.java +++ /dev/null @@ -1,65 +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 ReturnStructTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp"; - - private static ImmutableList 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 = { - "get_div0", - "get_field_div0", - "get_method_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/SharedPtrConstructorsTest.java b/infer/tests/endtoend/cpp/infer/SharedPtrConstructorsTest.java deleted file mode 100644 index 44428ca38..000000000 --- a/infer/tests/endtoend/cpp/infer/SharedPtrConstructorsTest.java +++ /dev/null @@ -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 SharedPtrConstructorsTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_constructors.cpp"; - - private static ImmutableList 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 = { - "get_from_base1_nullptr_deref", - "get_from_base2_nullptr_deref", - "get_from_derived1_nullptr_deref", - "get_from_derived2_nullptr_deref", - "get_from_derived3_nullptr_deref", - "get_from_base1_null_f1_deref", - "get_from_base2_null_f1_deref", - "get_from_derived1_null_f1_deref", - "get_from_derived2_null_f1_deref", - "get_from_derived3_null_f1_deref", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/SharedPtrDerefTest.java b/infer/tests/endtoend/cpp/infer/SharedPtrDerefTest.java deleted file mode 100644 index 427cb19fb..000000000 --- a/infer/tests/endtoend/cpp/infer/SharedPtrDerefTest.java +++ /dev/null @@ -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 SharedPtrDerefTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/smart_ptr/shared_ptr_deref.cpp"; - - private static ImmutableList 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 = { - "empty_ptr_deref", - "nullptr_ptr_deref", - "empty_ptr_field_deref", - "empty_ptr_field_deref2", - "empty_ptr_method_deref", - "reset_ptr_null_deref", - "reset_ptr_null_deref2", - "shared_ptr_copy_null_deref", - "shared_ptr_assign_null_deref", - "shared_ptr_move_null_deref", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain divide by 0 error", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/SkipFunctionWithConstFormalsTest.java b/infer/tests/endtoend/cpp/infer/SkipFunctionWithConstFormalsTest.java deleted file mode 100644 index c6e1dfc68..000000000 --- a/infer/tests/endtoend/cpp/infer/SkipFunctionWithConstFormalsTest.java +++ /dev/null @@ -1,68 +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 SkipFunctionWithConstFormalsTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp"; - - private static ImmutableList 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 = { - "skip_then_split_case", - "typedef_skip_then_split_case", // Infer should not report there - // but currently we don't look - // at const qualifiers - // underneath typedef's - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/StaticMethodTest.java b/infer/tests/endtoend/cpp/infer/StaticMethodTest.java deleted file mode 100644 index 14a91dc98..000000000 --- a/infer/tests/endtoend/cpp/infer/StaticMethodTest.java +++ /dev/null @@ -1,64 +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 StaticMethodTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp"; - - private static ImmutableList 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_class", - "div0_instance", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/StructForwardDeclareTest.java b/infer/tests/endtoend/cpp/infer/StructForwardDeclareTest.java deleted file mode 100644 index 15368fcba..000000000 --- a/infer/tests/endtoend/cpp/infer/StructForwardDeclareTest.java +++ /dev/null @@ -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 StructForwardDeclareTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp"; - - private static ImmutableList 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 = { - "X_div0", - "X_ptr_div0", - "X_Y_div0", - "Z_div0", - "Z_ptr_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/StructPassByValueTest.java b/infer/tests/endtoend/cpp/infer/StructPassByValueTest.java deleted file mode 100644 index 7aecb56c4..000000000 --- a/infer/tests/endtoend/cpp/infer/StructPassByValueTest.java +++ /dev/null @@ -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 StructPassByValueTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/types/struct_pass_by_value.cpp"; - - private static ImmutableList 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 = { - "var_div0", - "temp_div0", - "field_div0", - "param_get_copied_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/SubtypingCheckTest.java b/infer/tests/endtoend/cpp/infer/SubtypingCheckTest.java deleted file mode 100644 index 04ab63763..000000000 --- a/infer/tests/endtoend/cpp/infer/SubtypingCheckTest.java +++ /dev/null @@ -1,63 +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 SubtypingCheckTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/subtyping/subtyping_check.cpp"; - - private static ImmutableList 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 = { - "B_setFG", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/TempObjectTest.java b/infer/tests/endtoend/cpp/infer/TempObjectTest.java deleted file mode 100644 index 115a59583..000000000 --- a/infer/tests/endtoend/cpp/infer/TempObjectTest.java +++ /dev/null @@ -1,68 +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 TempObjectTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp"; - - private static ImmutableList 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 = { - "assign_temp_div0", - "temp_field_div0", - "temp_field2_div0", - "temp_method_div0", - "getX_field_div0", - "getX_method_div0", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/TemplateFunctionPackTest.java b/infer/tests/endtoend/cpp/infer/TemplateFunctionPackTest.java deleted file mode 100644 index 3e07e4b9c..000000000 --- a/infer/tests/endtoend/cpp/infer/TemplateFunctionPackTest.java +++ /dev/null @@ -1,68 +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 TemplateFunctionPackTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/templates/function_pack.cpp"; - - private static ImmutableList 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_1arg", - "div0_3args1", - "div0_3args2", - "div0_3args3", - "div0_3args4", - "div0_10args", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/TemporaryLValueTest.java b/infer/tests/endtoend/cpp/infer/TemporaryLValueTest.java deleted file mode 100644 index f186bcb88..000000000 --- a/infer/tests/endtoend/cpp/infer/TemporaryLValueTest.java +++ /dev/null @@ -1,65 +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 TemporaryLValueTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp"; - - private static ImmutableList 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_init_expr", - "div0_function_param_cast", - "div0_no_const_ref", - }; - assertThat( - "Results should contain the expected divide by zero", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ThisNotNullTest.java b/infer/tests/endtoend/cpp/infer/ThisNotNullTest.java deleted file mode 100644 index 4b9a8f820..000000000 --- a/infer/tests/endtoend/cpp/infer/ThisNotNullTest.java +++ /dev/null @@ -1,63 +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 ThisNotNullTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/this_not_null.cpp"; - - private static ImmutableList 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 whenInferRunsNoNullDerefErrorIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] proceduresWithNullDeref = { - /* nothing should be reported */ - }; - assertThat( - "Results should not contain any null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - proceduresWithNullDeref - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/ThrowAsAssertTest.java b/infer/tests/endtoend/cpp/infer/ThrowAsAssertTest.java deleted file mode 100644 index edc31e4fe..000000000 --- a/infer/tests/endtoend/cpp/infer/ThrowAsAssertTest.java +++ /dev/null @@ -1,63 +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 ThrowAsAssertTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/npe/throw_as_assert.cpp"; - - private static ImmutableList 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 whenInferRunsOnMethodNoThisNullDerefErrorIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] proceduresWithNullDeref = { - /* nothing should be reported */ - }; - assertThat( - "Results should not contain any null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - proceduresWithNullDeref - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/TypeIdExprTest.java b/infer/tests/endtoend/cpp/infer/TypeIdExprTest.java deleted file mode 100644 index 6e6eb4b92..000000000 --- a/infer/tests/endtoend/cpp/infer/TypeIdExprTest.java +++ /dev/null @@ -1,67 +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 TypeIdExprTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/types/typeid_expr.cpp"; - - private static ImmutableList 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 whenInferRunsOnMethodsDivideByZeroIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] procedures = { - "person_typeid", - "person_typeid_name", - "employee_typeid", - "person_ptr_typeid", - "template_type_id_person" - }; - assertThat( - "Results should contain the no null dereference", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/UniquePtrDerefTest.java b/infer/tests/endtoend/cpp/infer/UniquePtrDerefTest.java deleted file mode 100644 index e59453599..000000000 --- a/infer/tests/endtoend/cpp/infer/UniquePtrDerefTest.java +++ /dev/null @@ -1,75 +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 UniquePtrDerefTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp"; - - private static ImmutableList 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 = { - "empty_ptr_deref", - "empty_array_ptr_deref", - "nullptr_ptr_deref", - "nullptr_array_ptr_deref", - "empty_ptr_field_deref", - "empty_ptr_field_deref2", - "empty_ptr_method_deref", - "reset_ptr_null_deref", - "reset_ptr_null_deref2", - "unique_ptr_copy_null_deref", - "unique_ptr_assign_null_deref", - "unique_ptr_move_null_deref", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain null dereference", - inferResults, - containsExactly( - NULL_DEREFERENCE, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/VectorEmptyAccessTest.java b/infer/tests/endtoend/cpp/infer/VectorEmptyAccessTest.java deleted file mode 100644 index f68da0730..000000000 --- a/infer/tests/endtoend/cpp/infer/VectorEmptyAccessTest.java +++ /dev/null @@ -1,74 +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 VectorEmptyAccessTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/errors/vector/empty_access.cpp"; - - private static ImmutableList inferCmd; - - public static final String EMPTY_VECTOR_ACCESS = "EMPTY_VECTOR_ACCESS"; - - @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 = { - "access_empty", - "clear_empty", - //"resize0_empty", // resize(0) doesn't make vector empty - "copy_empty", - "assign_empty", - "empty_check_access_empty", - "size_check0_empty", - "vector_as_param_empty", - "vector_as_param_clear", - "vector_as_param_by_value_empty", - "getter_empty", - }; - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - assertThat( - "Results should contain empty vector access", - inferResults, - containsExactly( - EMPTY_VECTOR_ACCESS, - FILE, - procedures - ) - ); - } -} diff --git a/infer/tests/endtoend/cpp/infer/VirtualMethodsTest.java b/infer/tests/endtoend/cpp/infer/VirtualMethodsTest.java deleted file mode 100644 index 188840ed5..000000000 --- a/infer/tests/endtoend/cpp/infer/VirtualMethodsTest.java +++ /dev/null @@ -1,63 +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 VirtualMethodsTest { - - public static final String FILE = - "infer/tests/codetoanalyze/cpp/frontend/methods/virtual_methods.cpp"; - - private static ImmutableList 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 whenInferRunsOnMethodsDivideByZeroIsFound() - throws InterruptedException, IOException, InferException { - InferResults inferResults = InferRunner.runInferCPP(inferCmd); - String[] proceduresWithNullDeref = { - "rect_area", "tri_area", "poly_area", "tri_not_virtual_area" - }; - assertThat( - "Results should contain the no null dereference", - inferResults, - containsExactly( - DIVIDE_BY_ZERO, - FILE, - proceduresWithNullDeref - ) - ); - } -}