From 4584f7f6fc6c9c119b43205466073cc4390a78da Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Fri, 19 Feb 2016 13:51:38 +0000 Subject: [PATCH] [clang-format] Reformat all c/cpp/objc sources with clang-format Reviewed By: jul Differential Revision: https://phabricator.fb.com/D2953843 --- examples/Hello.m | 6 +- examples/c_hello/example.c | 30 +- examples/hello.c | 2 +- .../ios_hello/HelloWorldApp/AppDelegate.h | 6 +- .../ios_hello/HelloWorldApp/AppDelegate.m | 86 +- examples/ios_hello/HelloWorldApp/Hello.h | 12 +- examples/ios_hello/HelloWorldApp/Hello.m | 24 +- .../ios_hello/HelloWorldApp/ViewController.h | 2 - .../ios_hello/HelloWorldApp/ViewController.m | 8 +- examples/ios_hello/HelloWorldApp/main.m | 11 +- .../HelloWorldAppTests/HelloWorldAppTests.m | 22 +- infer/models/c/src/glib.c | 37 +- infer/models/c/src/infer_builtins.c | 9 +- infer/models/c/src/infer_builtins.h | 22 +- infer/models/c/src/libc_basic.c | 998 +++++++++--------- infer/models/c/src/math.c | 798 +++----------- infer/models/c/src/wchar.c | 332 +++--- infer/models/c/src/wctype.c | 95 +- infer/models/c/src/xlib.c | 4 +- infer/models/cpp/src/shared_ptr.cpp | 17 +- infer/models/objc/src/CADisplayLink.h | 7 +- infer/models/objc/src/CADisplayLink.m | 15 +- .../models/objc/src/CoreFoundation/CFArray.c | 34 +- .../objc/src/CoreFoundation/CFBinaryHeap.c | 10 +- .../objc/src/CoreFoundation/CFBitVector.c | 6 +- infer/models/objc/src/CoreFoundation/CFDate.c | 3 +- .../objc/src/CoreFoundation/CFDictionary.c | 78 +- .../models/objc/src/CoreFoundation/CFError.c | 5 +- .../objc/src/CoreFoundation/CFHTTPMessage.c | 41 +- .../models/objc/src/CoreFoundation/CFLocale.c | 4 +- .../objc/src/CoreFoundation/CFMutableArray.c | 6 +- .../CFMutableAttributedString.c | 8 +- .../src/CoreFoundation/CFMutableDictionary.c | 26 +- .../objc/src/CoreFoundation/CFMutableSet.c | 13 +- .../models/objc/src/CoreFoundation/CFNumber.c | 11 +- .../objc/src/CoreFoundation/CFRunLoop.c | 20 +- .../src/CoreFoundation/CFRunLoopObserver.c | 35 +- .../models/objc/src/CoreFoundation/CFSocket.c | 18 +- .../models/objc/src/CoreFoundation/CFString.c | 31 +- .../src/CoreFoundation/CFStringTokenizer.c | 14 +- infer/models/objc/src/CoreFoundation/CFType.c | 4 +- infer/models/objc/src/CoreFoundation/CFUUID.c | 12 +- infer/models/objc/src/CoreFoundation/CTFont.c | 6 +- .../objc/src/CoreFoundation/CTFramesetter.c | 7 +- .../src/CoreFoundation/CTParagraphStyle.c | 11 +- .../CoreFoundation/SCNetworkReachability.c | 19 +- .../objc/src/CoreFoundation/SecCertificate.c | 9 +- infer/models/objc/src/CoreFoundation/SecKey.c | 19 +- infer/models/objc/src/CoreGraphics/CGColor.c | 29 +- .../objc/src/CoreGraphics/CGColorSpace.c | 17 +- .../models/objc/src/CoreGraphics/CGContext.c | 23 +- .../objc/src/CoreGraphics/CGDataConsumer.c | 5 +- .../objc/src/CoreGraphics/CGDataProvider.c | 47 +- infer/models/objc/src/CoreGraphics/CGFont.c | 11 +- .../models/objc/src/CoreGraphics/CGFunction.c | 5 +- .../models/objc/src/CoreGraphics/CGGradient.c | 27 +- infer/models/objc/src/CoreGraphics/CGImage.c | 100 +- .../src/CoreGraphics/CGImageDestination.c | 25 +- .../objc/src/CoreGraphics/CGImageSource.c | 37 +- infer/models/objc/src/CoreGraphics/CGLayer.c | 5 +- .../src/CoreGraphics/CGPDFContentStream.c | 5 +- .../objc/src/CoreGraphics/CGPDFDocument.c | 5 +- .../src/CoreGraphics/CGPDFOperatorTable.c | 5 +- .../models/objc/src/CoreGraphics/CGPDFPage.c | 5 +- .../objc/src/CoreGraphics/CGPDFScanner.c | 5 +- infer/models/objc/src/CoreGraphics/CGPath.c | 53 +- .../models/objc/src/CoreGraphics/CGPattern.c | 5 +- .../models/objc/src/CoreGraphics/CGShading.c | 5 +- infer/models/objc/src/NSArray.m | 2 +- infer/models/objc/src/NSAutoreleasePool.m | 18 +- infer/models/objc/src/NSData.m | 34 +- infer/models/objc/src/NSDictionary.m | 2 +- infer/models/objc/src/NSFileHandle.m | 16 +- infer/models/objc/src/NSMutableArray.m | 15 +- infer/models/objc/src/NSMutableDictionary.m | 18 +- infer/models/objc/src/NSNotificationCenter.m | 42 +- infer/models/objc/src/NSNumber.h | 2 +- infer/models/objc/src/NSNumber.m | 49 +- infer/models/objc/src/NSObject.m | 2 +- infer/models/objc/src/NSRunLoop.h | 31 +- infer/models/objc/src/NSRunLoop.m | 50 +- infer/models/objc/src/NSString.h | 4 +- infer/models/objc/src/NSString.m | 25 +- infer/models/objc/src/NSTimer.h | 80 +- infer/models/objc/src/NSTimer.m | 175 ++- infer/src/clang/plugin/InferPlugin.cpp | 77 +- .../c/errors/assertions/assertion_failure.c | 26 +- .../c/errors/attributes/sentinel.c | 4 +- .../c/errors/custom_error/custom.c | 7 +- .../c/errors/dangling_deref/dpd.c | 40 +- .../errors/initialization/compound_literal.c | 8 +- .../c/errors/initialization/initlistexpr.c | 4 +- .../codetoanalyze/c/errors/lists/lists.c | 20 +- .../c/errors/local_vars/local_vars.c | 61 +- .../c/errors/memory_leaks/test.c | 21 +- .../c/errors/null_dereference/angelism.c | 46 +- .../c/errors/null_dereference/getc.c | 460 ++++---- .../null_pointer_dereference.c | 80 +- .../c/errors/resource_leaks/leak.c | 103 +- .../c/frontend/arithmetic/int_const.c | 16 +- .../c/frontend/arithmetic/unary.c | 4 +- .../c/frontend/booleans/bool_example.c | 4 +- .../c/frontend/booleans/bool_example.c.dot | 2 +- .../c/frontend/booleans/condition_as_param.c | 7 +- .../booleans/condition_as_param.c.dot | 6 +- .../c/frontend/c_prototype/prototype.c | 14 +- .../c/frontend/c_prototype/prototype.c.dot | 2 +- .../codetoanalyze/c/frontend/comma/comma.c | 18 +- .../conditional_operator/array_access.c | 14 +- .../conditional_operator/array_access.c.dot | 20 +- .../conditional_operator/assert_example.c | 8 +- .../conditional_operator/binary_operator.c | 1 - .../binary_operator.c.dot | 38 +- .../c/frontend/conditional_operator/cond2.c | 24 +- .../frontend/conditional_operator/cond2.c.dot | 58 +- .../conditional_operator.c | 29 +- .../conditional_operator.c.dot | 80 +- .../conditional_operator/function_call.c | 12 +- .../conditional_operator/function_call.c.dot | 102 +- .../conditional_operator/if_short_circuit.c | 75 +- .../if_short_circuit.c.dot | 108 +- .../conditional_operator/int_negation.c | 29 +- .../conditional_operator/int_negation.c.dot | 50 +- .../conditional_operator/member_access.c | 12 +- .../conditional_operator/member_access.c.dot | 22 +- .../conditional_operator/preincrement.c | 2 +- .../conditional_operator/unary_operator.c | 8 +- .../c/frontend/enumeration/enum.c | 14 +- .../c/frontend/enumeration/enum.c.dot | 14 +- .../c/frontend/enumeration/enum_bitmask.c | 8 +- .../c/frontend/enumeration/other_enum.c | 25 +- .../c/frontend/enumeration/other_enum.c.dot | 2 +- .../c/frontend/gotostmt/goto_ex.c | 297 +++--- .../c/frontend/gotostmt/goto_ex.c.dot | 368 +++---- .../initialization/array_initlistexpr.c | 4 +- .../initialization/compound_literal.c | 6 +- .../initialization/compound_literal.c.dot | 8 +- .../initialization/struct_initlistexpr.c | 42 +- .../initialization/struct_initlistexpr.c.dot | 18 +- .../codetoanalyze/c/frontend/loops/do_while.c | 4 +- .../loops/do_while_condition_side_effects.c | 4 +- .../c/frontend/loops/do_while_nested.c | 6 +- .../loops/for_condition_side_effects.c | 6 +- .../c/frontend/loops/for_nested.c | 4 +- .../c/frontend/loops/for_no_condition.c | 2 +- .../c/frontend/loops/for_no_condition_incr.c | 6 +- .../loops/for_no_condition_incr_body.c | 2 +- .../c/frontend/loops/for_simple.c | 2 +- .../c/frontend/loops/for_while_nested.c | 4 +- .../c/frontend/loops/while_no_body.c | 5 +- .../c/frontend/loops/while_no_body.c.dot | 2 +- .../loops/while_with_continue_and_break.c | 24 +- .../nestedoperators/assign_in_condition.c | 4 +- .../nestedoperators/assign_in_condition.cpp | 16 +- .../c/frontend/nestedoperators/gnuexpr.c | 19 +- .../c/frontend/nestedoperators/gnuexpr.c.dot | 8 +- .../c/frontend/nestedoperators/union.c | 19 +- .../c/frontend/nestedoperators/union.c.dot | 12 +- .../c/frontend/nestedoperators/union.cpp | 39 +- .../c/frontend/nestedoperators/union.cpp.dot | 16 +- infer/tests/codetoanalyze/c/frontend/struct.c | 4 +- .../c/frontend/switchstmt/switch.c | 347 +++--- .../c/frontend/switchstmt/switch.c.dot | 354 +++---- .../codetoanalyze/c/frontend/types/struct.c | 4 +- .../cpp/errors/c_tests/c_bugs.cpp | 16 +- .../cpp/errors/memory_leaks/object_leak.cpp | 13 +- .../errors/npe/null_returned_by_method.cpp | 12 +- .../cpp/errors/npe/object_deref.cpp | 6 +- .../cpp/errors/subtyping/dynamic_cast.cpp | 71 +- .../cpp/errors/subtyping/subtyping_check.cpp | 23 +- .../cpp/frontend/builtin/new.cpp | 4 +- .../conditional/lvalue_conditional.cpp | 34 +- .../conditional/lvalue_conditional.cpp.dot | 30 +- .../constructors/constructor_default_arg.cpp | 7 +- .../constructor_default_arg.cpp.dot | 14 +- .../constructors/constructor_init.cpp | 35 +- .../constructors/constructor_init.cpp.dot | 64 +- .../constructors/constructor_with_body.cpp | 7 +- .../constructor_with_body.cpp.dot | 32 +- .../constructors/copy_move_constructor.cpp | 15 +- .../copy_move_constructor.cpp.dot | 52 +- .../cpp/frontend/constructors/temp_object.cpp | 32 +- .../frontend/constructors/temp_object.cpp.dot | 26 +- .../frontend/destructors/call_on_delete.cpp | 8 +- .../destructors/call_on_delete.cpp.dot | 6 +- .../cpp/frontend/destructors/simple_decl.cpp | 8 +- .../frontend/destructors/simple_decl.cpp.dot | 6 +- .../cpp/frontend/include_header/header.h | 8 +- .../frontend/include_header/include_templ.cpp | 8 +- .../include_header/include_templ.cpp.dot | 10 +- .../cpp/frontend/keywords/self_parameter.cpp | 14 +- .../frontend/keywords/self_parameter.cpp.dot | 10 +- .../cpp/frontend/literals/nullptr.cpp | 2 +- .../frontend/literals/scalar_value_init.cpp | 8 +- .../literals/scalar_value_init.cpp.dot | 34 +- .../cpp/frontend/loops/foreach1.cpp | 35 +- .../cpp/frontend/loops/foreach1.cpp.dot | 62 +- .../frontend/methods/conversion_operator.cpp | 12 +- .../methods/conversion_operator.cpp.dot | 84 +- .../frontend/methods/default_parameters.cpp | 10 +- .../cpp/frontend/methods/dereference_this.cpp | 7 +- .../frontend/methods/dereference_this.cpp.dot | 14 +- .../cpp/frontend/methods/inline_method.cpp | 11 +- .../frontend/methods/inline_method.cpp.dot | 10 +- .../cpp/frontend/methods/overloading.cpp | 14 +- .../cpp/frontend/methods/overloading.cpp.dot | 12 +- .../cpp/frontend/methods/return_struct.cpp | 2 +- .../cpp/frontend/methods/static.cpp | 10 +- .../cpp/frontend/methods/static.cpp.dot | 6 +- .../cpp/frontend/namespace/function.cpp | 10 +- .../cpp/frontend/namespace/function.cpp.dot | 2 +- .../frontend/namespace/global_variable.cpp | 7 +- .../namespace/global_variable.cpp.dot | 24 +- .../cpp/frontend/namespace/namespace.cpp | 72 +- .../cpp/frontend/namespace/namespace.cpp.dot | 26 +- .../nestedoperators/var_decl_inside_if.cpp | 12 +- .../var_decl_inside_if.cpp.dot | 62 +- .../var_decl_inside_switch.cpp | 6 +- .../nestedoperators/var_decl_inside_while.cpp | 4 +- .../cpp/frontend/reference/increment.cpp | 10 +- .../cpp/frontend/reference/init.cpp | 4 +- .../cpp/frontend/reference/member_access.cpp | 2 +- .../reference/member_access_from_return.cpp | 6 +- .../frontend/reference/nested_assignment.cpp | 12 +- .../reference/nested_assignment.cpp.dot | 6 +- .../reference/reference_struct_e2e.cpp | 50 +- .../reference/reference_struct_e2e.cpp.dot | 166 +-- .../frontend/reference/reference_type_e2e.cpp | 28 +- .../frontend/reference/temporary_lvalue.cpp | 4 +- .../reference/temporary_lvalue.cpp.dot | 8 +- .../cpp/frontend/reference/unbox.cpp | 8 +- .../templates/class_template_instantiate.cpp | 21 +- .../class_template_instantiate.cpp.dot | 20 +- .../cpp/frontend/templates/function.cpp | 12 +- .../cpp/frontend/templates/method.cpp | 14 +- .../cpp/frontend/templates/method.cpp.dot | 78 +- .../cpp/frontend/templates/simple.cpp | 6 +- .../cpp/frontend/types/casts.cpp | 4 +- .../cpp/frontend/types/casts.cpp.dot | 2 +- .../cpp/frontend/types/functions.cpp | 18 +- .../cpp/frontend/types/functions.cpp.dot | 26 +- .../cpp/frontend/types/inheritance.cpp | 12 +- .../cpp/frontend/types/inheritance_field.cpp | 14 +- .../cpp/frontend/types/operator_overload.cpp | 24 +- .../frontend/types/operator_overload.cpp.dot | 34 +- .../cpp/frontend/types/return_struct.cpp | 13 +- .../cpp/frontend/types/return_struct.cpp.dot | 38 +- .../cpp/frontend/types/struct.cpp | 14 +- .../frontend/types/struct_forward_declare.cpp | 12 +- .../types/struct_forward_declare.cpp.dot | 52 +- infer/tests/codetoanalyze/llvm/interproc.c | 8 +- infer/tests/codetoanalyze/llvm/null_deref.c | 4 +- .../errors/bad_ptr_comparisons/badpointer.m | 64 +- .../errors/bad_ptr_comparisons/nsnumber.m | 18 +- .../errors/category_procdesc/EOCPerson.dot | 4 +- .../objc/errors/category_procdesc/EOCPerson.h | 11 +- .../objc/errors/category_procdesc/EOCPerson.m | 7 +- .../objc/errors/category_procdesc/main.c | 9 +- .../objc/errors/category_procdesc/main.dot | 10 +- .../objc/errors/field_superclass/A.h | 7 +- .../objc/errors/field_superclass/B.h | 1 - .../field_superclass/SubtypingExample.m | 74 +- .../errors/field_superclass/SuperExample.dot | 16 +- .../errors/field_superclass/SuperExample.m | 27 +- .../objc/errors/field_superclass/field.c | 9 +- .../memory_leaks_benchmark/ArcExample.m | 16 +- .../AutoreleaseExample.m | 64 +- .../CADisplayLinkRetainCycle.m | 39 +- .../MemoryLeakExample.dot | 64 +- .../MemoryLeakExample.h | 4 +- .../MemoryLeakExample.m | 101 +- .../NSMakeCollectableExample.m | 11 +- .../NSStringInitWithBytesNoCopyExample.m | 79 +- .../RetainCycleStaticVar.m | 48 +- .../RetainReleaseExample.m | 6 +- .../RetainReleaseExample2.dot | 50 +- .../RetainReleaseExample2.m | 39 +- .../RetainReleaseExampleBucketing.m | 4 +- .../TollBridgeExample.dot | 28 +- .../TollBridgeExample.m | 22 +- .../memory_leaks_benchmark/arc_methods.m | 36 +- .../memory_leaks_benchmark/retain_cycle.m | 52 +- .../memory_leaks_benchmark/retain_cycle2.m | 77 +- .../codetoanalyze/objc/errors/npe/Fraction.m | 27 +- .../objc/errors/npe/NPD_core_foundation.h | 4 +- .../objc/errors/npe/NPD_core_foundation.m | 50 +- .../errors/npe/Nonnull_attribute_example.dot | 10 +- .../errors/npe/Nonnull_attribute_example.m | 24 +- .../objc/errors/npe/Npe_with_equal_names.m | 25 +- .../errors/npe/ObjCMethodCallInCondition.m | 30 +- .../objc/errors/npe/UpdateDict.m | 99 +- .../codetoanalyze/objc/errors/npe/block.m | 88 +- .../codetoanalyze/objc/errors/npe/blockenum.m | 60 +- .../objc/errors/npe/nil_in_array_literal.m | 33 +- .../errors/npe/nil_in_dictionary_literal.m | 73 +- .../codetoanalyze/objc/errors/npe/nil_param.m | 18 +- .../objc/errors/npe/npe_malloc.dot | 6 +- .../objc/errors/npe/npe_malloc.m | 13 +- .../codetoanalyze/objc/errors/npe/npe_self.m | 40 +- .../objc/errors/npe/null_returned_by_method.m | 10 +- .../codetoanalyze/objc/errors/npe/nullable.m | 29 +- .../objc/errors/procdescs/MethodCall.h | 2 +- .../objc/errors/procdescs/MethodCall.m | 4 +- .../objc/errors/procdescs/main.c | 12 +- .../objc/errors/property/ExplicitIvarName.m | 37 +- .../codetoanalyze/objc/errors/property/main.c | 8 +- .../objc/errors/protocol_procdesc/Bicycle.m | 14 +- .../errors/protocol_procdesc/StreetVehicle.h | 4 +- .../objc/errors/protocol_procdesc/main.c | 7 +- .../objc/errors/protocol_procdesc/main.dot | 8 +- .../resource_leaks/ResourceLeakExample.m | 62 +- .../objc/errors/returnstmt/return_npe_test.m | 22 +- .../errors/subtyping/KindOfClassExample.m | 48 +- .../objc/errors/taint/viewController.m | 73 +- .../premature_nil_termination.m | 16 +- .../frontend/assertions/NSAssert_example.m | 16 +- .../objc/frontend/block/BlockVar.dot | 4 +- .../objc/frontend/block/BlockVar.m | 22 +- .../objc/frontend/block/block-it.dot | 88 +- .../objc/frontend/block/block-it.m | 66 +- .../objc/frontend/block/block.dot | 34 +- .../codetoanalyze/objc/frontend/block/block.m | 52 +- .../objc/frontend/block/block_no_args.dot | 24 +- .../objc/frontend/block/block_no_args.m | 29 +- .../objc/frontend/block/block_release.dot | 18 +- .../objc/frontend/block/block_release.m | 31 +- .../objc/frontend/block/dispatch.dot | 38 +- .../objc/frontend/block/dispatch.m | 42 +- .../objc/frontend/block/dispatch_examples.dot | 92 +- .../objc/frontend/block/dispatch_examples.m | 95 +- .../objc/frontend/block/dispatch_in_macro.m | 20 +- .../objc/frontend/block/retain_cycle.dot | 28 +- .../objc/frontend/block/retain_cycle.m | 39 +- .../objc/frontend/block/static.dot | 42 +- .../objc/frontend/block/static.m | 72 +- .../objc/frontend/boxing/Boxing.m | 19 +- .../objc/frontend/boxing/array.dot | 20 +- .../objc/frontend/boxing/array.m | 19 +- .../objc/frontend/boxing/array_literal.c | 4 +- .../objc/frontend/boxing/dict_literal.c | 14 +- .../objc/frontend/boxing/dict_literal.dot | 8 +- .../objc/frontend/boxing/string_literal.c | 7 +- .../objc/frontend/boxing/string_literal.dot | 2 +- .../ConditionalOperation.m | 10 +- .../frontend/exceptions/ExceptionExample.dot | 18 +- .../frontend/exceptions/ExceptionExample.m | 34 +- .../fast_enumeration/Fast_enumeration.m | 26 +- .../predefined_expr/PredefinedExprExample.m | 12 +- .../frontend/property/PropertyAttributes.m | 26 +- .../property/PropertyCustomAccessor.m | 4 +- .../frontend/property/PropertyImplSetter.dot | 2 +- .../frontend/property/PropertyImplSetter.h | 2 +- .../frontend/property/PropertyImplSetter.m | 5 +- .../objc/frontend/property/Property_getter.m | 2 +- .../objc/frontend/property/aclass.m | 3 +- .../objc/frontend/property/main_car.m | 6 +- .../property_in_protocol/MyProtocol.h | 2 +- .../objc/frontend/property_in_protocol/Test.h | 5 +- .../objc/frontend/protocol/protocol.dot | 10 +- .../objc/frontend/protocol/protocol.m | 9 +- .../objc/frontend/returnstmt/void_return.m | 18 +- .../objc/frontend/self_static/Self.dot | 68 +- .../objc/frontend/self_static/Self.m | 71 +- .../objc/frontend/self_static/static.m | 14 +- .../strings/global_string_literal.dot | 2 +- .../frontend/strings/global_string_literal.m | 6 +- .../objc/frontend/strings/string_literal.m | 4 +- .../codetoanalyze/objc/frontend/subclass/A.h | 2 +- .../codetoanalyze/objc/frontend/subclass/A.m | 11 +- .../objc/frontend/subclass/MyClass.h | 2 +- .../objc/frontend/subclass/MySubClass.m | 2 +- .../objc/frontend/subclass/main.c | 4 +- .../objc/frontend/types/attributes.dot | 2 +- .../objc/frontend/types/attributes.m | 47 +- .../objc/frontend/types/testloop.dot | 4 +- .../objc/frontend/types/testloop.m | 27 +- .../objc/frontend/types/void_call.dot | 36 +- .../objc/frontend/types/void_call.m | 44 +- .../objc/frontend/vardecl/aclass.dot | 4 +- .../objc/frontend/vardecl/aclass.m | 10 +- .../objc/frontend/vardecl/aclass_2.dot | 4 +- .../objc/frontend/vardecl/aclass_2.m | 10 +- .../objc/frontend/vardecl/initlist.m | 6 +- .../objc/frontend/vardecl/last_af.dot | 4 +- .../objc/frontend/vardecl/last_af.m | 4 +- .../warnings/ParameterNotNullableExample.m | 60 +- .../codetoanalyze/objc/warnings/atomic_prop.m | 111 +- .../objc/warnings/strong_delegate.m | 18 +- .../objcpp/errors/blocks/block.mm | 48 +- .../frontend/funcoverloading/af_test.mm | 10 +- .../tests/endtoend/c/NullDereferenceTest.java | 2 +- 391 files changed, 6071 insertions(+), 6935 deletions(-) mode change 120000 => 100644 infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp mode change 120000 => 100644 infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp diff --git a/examples/Hello.m b/examples/Hello.m index 3f8ff3614..0bea2f544 100644 --- a/examples/Hello.m +++ b/examples/Hello.m @@ -9,13 +9,13 @@ #import -@interface Hello: NSObject +@interface Hello : NSObject @property NSString* s; @end @implementation Hello NSString* m() { - Hello* hello = nil; - return hello->_s; + Hello* hello = nil; + return hello->_s; } @end diff --git a/examples/c_hello/example.c b/examples/c_hello/example.c index 57abab965..eda2491b5 100644 --- a/examples/c_hello/example.c +++ b/examples/c_hello/example.c @@ -7,17 +7,17 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include #include #include #include #include #include #include +#include #include +#include #include #include -#include #include struct Person { @@ -27,26 +27,23 @@ struct Person { }; int simple_null_pointer() { - struct Person *max = 0; + struct Person* max = 0; return max->age; } -struct Person *Person_create(int age, int height, int weight) { - struct Person *who = 0; +struct Person* Person_create(int age, int height, int weight) { + struct Person* who = 0; return who; } -int get_age(struct Person *who) { - return who->age; -} +int get_age(struct Person* who) { return who->age; } int null_pointer_interproc() { - struct Person *joe = Person_create(32, 64, 140); + struct Person* joe = Person_create(32, 64, 140); return get_age(joe); } -void fileNotClosed() -{ +void fileNotClosed() { int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd != -1) { char buffer[256]; @@ -56,14 +53,15 @@ void fileNotClosed() } void simple_leak() { - int *p; - p = (int*) malloc(sizeof(int)); + int* p; + p = (int*)malloc(sizeof(int)); } void common_realloc_leak() { int *p, *q; - p = (int*) malloc(sizeof(int)); - q = (int*) realloc(p, sizeof(int) * 42); + p = (int*)malloc(sizeof(int)); + q = (int*)realloc(p, sizeof(int) * 42); // if realloc fails, then p becomes unreachable - if (q != NULL) free(q); + if (q != NULL) + free(q); } diff --git a/examples/hello.c b/examples/hello.c index 6436c2881..a3c29e227 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -10,6 +10,6 @@ #include void test() { - int *s = NULL; + int* s = NULL; *s = 42; } diff --git a/examples/ios_hello/HelloWorldApp/AppDelegate.h b/examples/ios_hello/HelloWorldApp/AppDelegate.h index 2ceae3191..53424c6fe 100644 --- a/examples/ios_hello/HelloWorldApp/AppDelegate.h +++ b/examples/ios_hello/HelloWorldApp/AppDelegate.h @@ -14,10 +14,8 @@ #import -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; +@interface AppDelegate : UIResponder +@property(strong, nonatomic) UIWindow* window; @end - diff --git a/examples/ios_hello/HelloWorldApp/AppDelegate.m b/examples/ios_hello/HelloWorldApp/AppDelegate.m index d98681844..64a2d9e33 100644 --- a/examples/ios_hello/HelloWorldApp/AppDelegate.m +++ b/examples/ios_hello/HelloWorldApp/AppDelegate.m @@ -22,63 +22,75 @@ @implementation AppDelegate --(void) memory_leak_bug { - CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL); +- (void)memory_leak_bug { + CGPathRef shadowPath = CGPathCreateWithRect(self.inputView.bounds, NULL); } --(void) resource_leak_bug { - FILE *fp; - fp=fopen("c:\\test.txt", "r"); +- (void)resource_leak_bug { + FILE* fp; + fp = fopen("c:\\test.txt", "r"); } --(void) parameter_not_null_checked_block_bug:(void (^)())callback { - callback(); +- (void)parameter_not_null_checked_block_bug:(void (^)())callback { + callback(); } --(NSArray*) npe_in_array_literal_bug { - NSString *str = nil; - return @[@"horse", str, @"dolphin"]; +- (NSArray*)npe_in_array_literal_bug { + NSString* str = nil; + return @[ @"horse", str, @"dolphin" ]; } --(NSArray*) premature_nil_termination_argument_bug { - NSString *str = nil; - return [NSArray arrayWithObjects: @"horse", str, @"dolphin", nil]; +- (NSArray*)premature_nil_termination_argument_bug { + NSString* str = nil; + return [NSArray arrayWithObjects:@"horse", str, @"dolphin", nil]; } -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - Hello *hello = [Hello new]; - [hello null_dereference_bug]; - [self memory_leak_bug]; - [self resource_leak_bug]; - [hello parameter_not_null_checked_bug:nil]; - [self parameter_not_null_checked_block_bug:nil]; - [hello ivar_not_nullable_bug:nil]; - [self npe_in_array_literal_bug]; - [self premature_nil_termination_argument_bug]; - return YES; +- (BOOL)application:(UIApplication*)application + didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { + // Override point for customization after application launch. + Hello* hello = [Hello new]; + [hello null_dereference_bug]; + [self memory_leak_bug]; + [self resource_leak_bug]; + [hello parameter_not_null_checked_bug:nil]; + [self parameter_not_null_checked_block_bug:nil]; + [hello ivar_not_nullable_bug:nil]; + [self npe_in_array_literal_bug]; + [self premature_nil_termination_argument_bug]; + return YES; } -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +- (void)applicationWillResignActive:(UIApplication*)application { + // Sent when the application is about to move from active to inactive state. + // This can occur for certain types of temporary interruptions (such as an + // incoming phone call or SMS message) or when the user quits the application + // and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down + // OpenGL ES frame rates. Games should use this method to pause the game. } -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +- (void)applicationDidEnterBackground:(UIApplication*)application { + // Use this method to release shared resources, save user data, invalidate + // timers, and store enough application state information to restore your + // application to its current state in case it is terminated later. + // If your application supports background execution, this method is called + // instead of applicationWillTerminate: when the user quits. } -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +- (void)applicationWillEnterForeground:(UIApplication*)application { + // Called as part of the transition from the background to the inactive state; + // here you can undo many of the changes made on entering the background. } -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +- (void)applicationDidBecomeActive:(UIApplication*)application { + // Restart any tasks that were paused (or not yet started) while the + // application was inactive. If the application was previously in the + // background, optionally refresh the user interface. } -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +- (void)applicationWillTerminate:(UIApplication*)application { + // Called when the application is about to terminate. Save data if + // appropriate. See also applicationDidEnterBackground:. } @end diff --git a/examples/ios_hello/HelloWorldApp/Hello.h b/examples/ios_hello/HelloWorldApp/Hello.h index 09b028e90..90013128e 100644 --- a/examples/ios_hello/HelloWorldApp/Hello.h +++ b/examples/ios_hello/HelloWorldApp/Hello.h @@ -16,15 +16,15 @@ @interface Hello : NSObject -@property (strong) NSString* s; -@property (strong) Hello* hello; +@property(strong) NSString* s; +@property(strong) Hello* hello; --(Hello*) return_hello; +- (Hello*)return_hello; --(NSString*) null_dereference_bug; +- (NSString*)null_dereference_bug; --(NSString*) ivar_not_nullable_bug:(Hello*) hello; +- (NSString*)ivar_not_nullable_bug:(Hello*)hello; --(NSString*) parameter_not_null_checked_bug:(Hello*) hello; +- (NSString*)parameter_not_null_checked_bug:(Hello*)hello; @end diff --git a/examples/ios_hello/HelloWorldApp/Hello.m b/examples/ios_hello/HelloWorldApp/Hello.m index ef4f99ca3..67ea068b3 100644 --- a/examples/ios_hello/HelloWorldApp/Hello.m +++ b/examples/ios_hello/HelloWorldApp/Hello.m @@ -12,28 +12,28 @@ // HelloWorldApp // -#import #import "Hello.h" +#import @implementation Hello --(Hello*) return_hello { - return [Hello new]; +- (Hello*)return_hello { + return [Hello new]; } --(NSString*) null_dereference_bug { - Hello *hello = nil; - return hello->_s; +- (NSString*)null_dereference_bug { + Hello* hello = nil; + return hello->_s; } --(NSString*) ivar_not_nullable_bug:(Hello*) hello { - Hello* ret_hello = [hello->_hello return_hello]; - return ret_hello->_s; +- (NSString*)ivar_not_nullable_bug:(Hello*)hello { + Hello* ret_hello = [hello->_hello return_hello]; + return ret_hello->_s; } --(NSString*) parameter_not_null_checked_bug:(Hello*) hello { - Hello *ret_hello = [hello return_hello]; - return ret_hello->_s; +- (NSString*)parameter_not_null_checked_bug:(Hello*)hello { + Hello* ret_hello = [hello return_hello]; + return ret_hello->_s; } @end diff --git a/examples/ios_hello/HelloWorldApp/ViewController.h b/examples/ios_hello/HelloWorldApp/ViewController.h index e7d83ca3f..056c78387 100644 --- a/examples/ios_hello/HelloWorldApp/ViewController.h +++ b/examples/ios_hello/HelloWorldApp/ViewController.h @@ -16,6 +16,4 @@ @interface ViewController : UIViewController - @end - diff --git a/examples/ios_hello/HelloWorldApp/ViewController.m b/examples/ios_hello/HelloWorldApp/ViewController.m index efbb6b1da..e9ffa15c6 100644 --- a/examples/ios_hello/HelloWorldApp/ViewController.m +++ b/examples/ios_hello/HelloWorldApp/ViewController.m @@ -21,13 +21,13 @@ @implementation ViewController - (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. } @end diff --git a/examples/ios_hello/HelloWorldApp/main.m b/examples/ios_hello/HelloWorldApp/main.m index e8f601160..5d91285eb 100644 --- a/examples/ios_hello/HelloWorldApp/main.m +++ b/examples/ios_hello/HelloWorldApp/main.m @@ -12,11 +12,12 @@ // HelloWorldApp // -#import #import "AppDelegate.h" +#import -int main(int argc, char * argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } +int main(int argc, char* argv[]) { + @autoreleasepool { + return UIApplicationMain( + argc, argv, nil, NSStringFromClass([AppDelegate class])); + } } diff --git a/examples/ios_hello/HelloWorldAppTests/HelloWorldAppTests.m b/examples/ios_hello/HelloWorldAppTests/HelloWorldAppTests.m index 3faa8a275..3e2049642 100644 --- a/examples/ios_hello/HelloWorldAppTests/HelloWorldAppTests.m +++ b/examples/ios_hello/HelloWorldAppTests/HelloWorldAppTests.m @@ -23,25 +23,27 @@ @implementation HelloWorldAppTests - (void)setUp { - [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. + [super setUp]; + // Put setup code here. This method is called before the invocation of each + // test method in the class. } - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. - [super tearDown]; + // Put teardown code here. This method is called after the invocation of each + // test method in the class. + [super tearDown]; } - (void)testExample { - // This is an example of a functional test case. - XCTAssert(YES, @"Pass"); + // This is an example of a functional test case. + XCTAssert(YES, @"Pass"); } - (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; } @end diff --git a/infer/models/c/src/glib.c b/infer/models/c/src/glib.c index 35a19d757..078124bde 100644 --- a/infer/models/c/src/glib.c +++ b/infer/models/c/src/glib.c @@ -15,41 +15,42 @@ #include // similar to malloc, but never fails, and returns NULL when size==0 -void *g_malloc(size_t size) { - if(size==0) return NULL; - void *res = malloc(size); +void* g_malloc(size_t size) { + if (size == 0) + return NULL; + void* res = malloc(size); INFER_EXCLUDE_CONDITION(!res); return res; } // modelled as free -void g_free(void *ptr) { - free(ptr); -} +void g_free(void* ptr) { free(ptr); } -void *g_realloc(void *ptr, size_t size) { - if(size==0) { // return NULL and free ptr unless it is NULL - if(ptr) free(ptr); +void* g_realloc(void* ptr, size_t size) { + if (size == 0) { // return NULL and free ptr unless it is NULL + if (ptr) + free(ptr); return NULL; } int old_size; old_size = __get_array_size(ptr); // force ptr to be an array - int can_enlarge; // nondeterministically choose whether the current block can be enlarged - if(can_enlarge) { + int can_enlarge; // nondeterministically choose whether the current block can + // be enlarged + if (can_enlarge) { __set_array_size(ptr, size); // enlarge the block return ptr; } - int *newblock = (int*)malloc(size); - if(newblock) { + int* newblock = (int*)malloc(size); + if (newblock) { free(ptr); return newblock; - } - else exit(0); // assume that new allocation does not fail + } else + exit(0); // assume that new allocation does not fail } - // simply return object, and assume it is not NULL -void *gtk_type_check_object_cast(void *object, void *cast_type) { - if(!object) exit(0); +void* gtk_type_check_object_cast(void* object, void* cast_type) { + if (!object) + exit(0); return object; } diff --git a/infer/models/c/src/infer_builtins.c b/infer/models/c/src/infer_builtins.c index 9db241772..c387e6cbb 100644 --- a/infer/models/c/src/infer_builtins.c +++ b/infer/models/c/src/infer_builtins.c @@ -43,8 +43,8 @@ unsigned long int __infer_nondet_unsigned_long_int() { } // model returning an arbitrary (nondeterministic) pointer -void *__infer_nondet_ptr() { - void *res; +void* __infer_nondet_ptr() { + void* res; return res; } @@ -92,7 +92,10 @@ long infer__builtin_expect(long e, long x) { } } -void *infer__builtin___memset_chk(void *dest, int val, unsigned long len, unsigned long dstlen) { +void* infer__builtin___memset_chk(void* dest, + int val, + unsigned long len, + unsigned long dstlen) { INFER_EXCLUDE_CONDITION(dstlen < len); return dest; } diff --git a/infer/models/c/src/infer_builtins.h b/infer/models/c/src/infer_builtins.h index aa8e9f0ce..cee8485b9 100644 --- a/infer/models/c/src/infer_builtins.h +++ b/infer/models/c/src/infer_builtins.h @@ -10,8 +10,8 @@ // builtins to be used to model library functions -#include #include +#include #include // model returning an arbitrary (nondeterministic) short @@ -30,7 +30,7 @@ long long int __infer_nondet_long_long_int(); unsigned long int __infer_nondet_unsigned_long_int(); // model returning an arbitrary (nondeterministic) pointer -void *__infer_nondet_ptr(); +void* __infer_nondet_ptr(); // model returning an arbitrary (nondeterministic) float float __infer_nondet_float(); @@ -51,17 +51,21 @@ time_t __infer_nondet_time_t(); clock_t __infer_nondet_clock_t(); // assume that the cond is false -// and add any constraints to the precondition so that cond is false, if possible -#define INFER_EXCLUDE_CONDITION(cond) if (cond) while(1) +// and add any constraints to the precondition so that cond is false, if +// possible +#define INFER_EXCLUDE_CONDITION(cond) \ + if (cond) \ + while (1) // builtin: force arr to be an array and return the size -extern size_t __get_array_size(const void *arr); +extern size_t __get_array_size(const void* arr); // builtin: change the attribute of ret to a file attribute -extern void __set_file_attribute(void *ret); +extern void __set_file_attribute(void* ret); // builtin: change the size of the array to size -extern void __set_array_size(void *ptr, size_t size); +extern void __set_array_size(void* ptr, size_t size); -// builtin: set the flag to the given value for the procedure where this call appears -extern void __infer_set_flag(char *flag, char *value); +// builtin: set the flag to the given value for the procedure where this call +// appears +extern void __infer_set_flag(char* flag, char* value); diff --git a/infer/models/c/src/libc_basic.c b/infer/models/c/src/libc_basic.c index 052d59020..b5ee70217 100644 --- a/infer/models/c/src/libc_basic.c +++ b/infer/models/c/src/libc_basic.c @@ -30,28 +30,28 @@ #include "infer_builtins.h" -#include -#include -#include -#include -#include #include +#include +#include #include +#include #include -#include +#include +#include +#include #include -#include -#include -#include #include -#include -#include #include +#include #include +#include +#include +#include +#include #ifdef __APPLE__ // includes for statfs are system-dependent -#include #include +#include #else #include #endif @@ -74,25 +74,25 @@ extern int errno; #else #define __ERRNO_FUN_NAME __errno_location #endif -int *__ERRNO_FUN_NAME() { - return &errno; -} +int* __ERRNO_FUN_NAME() { return &errno; } // the strings s1 and s2 need to be allocated // check that s2 fits inside s1 -char *strcpy(char *s1, const char *s2) { +char* strcpy(char* s1, const char* s2) { int size1; int size2; - __infer_set_flag("ignore_return", ""); // no warnings if the return value is ignored + __infer_set_flag("ignore_return", + ""); // no warnings if the return value is ignored size1 = __get_array_size(s1); size2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION(size2>size1); + INFER_EXCLUDE_CONDITION(size2 > size1); return s1; } -// the string s must be allocated; return the result of malloc with the same size -char *strdup(const char *s) { +// the string s must be allocated; return the result of malloc with the same +// size +char* strdup(const char* s) { int size; size = __get_array_size(s); return (char*)malloc(size); @@ -100,13 +100,13 @@ char *strdup(const char *s) { // the strings s1 and s2 need to be allocated // check that s2 fits inside s1 -char *strcat(char *s1, const char *s2) { +char* strcat(char* s1, const char* s2) { int size1; int size2; size1 = __get_array_size(s1); size2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION(size2>size1); + INFER_EXCLUDE_CONDITION(size2 > size1); return s1; } @@ -117,13 +117,11 @@ char *strcat(char *s1, const char *s2) { // The string s must be allocated // nondeterministically return 0 or a pointer inside the buffer #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO -char *strchr(const char *s, int c) { +char* strchr(const char* s, int c) { #else -const char *strchr(const char *s, int c) throw() { - return strchr((char*) s, c); -} +const char* strchr(const char* s, int c) throw() { return strchr((char*)s, c); } -char *strchr(char *s, int c) throw() { +char* strchr(char* s, int c) throw() { #endif int size; int nondet; @@ -132,29 +130,26 @@ char *strchr(char *s, int c) throw() { offset = __infer_nondet_int(); size = __get_array_size(s); - if(nondet) return 0; - INFER_EXCLUDE_CONDITION(offset < 0 || offset >=size); - return (char *)s + offset; + if (nondet) + return 0; + INFER_EXCLUDE_CONDITION(offset < 0 || offset >= size); + return (char*)s + offset; } // modelled like strchr #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO -char *strrchr(const char *s, int c) { - return strchr(s,c); -} +char* strrchr(const char* s, int c) { return strchr(s, c); } #else -const char *strrchr(const char *s, int c) throw() { - return strchr((char*) s, c); +const char* strrchr(const char* s, int c) throw() { + return strchr((char*)s, c); } -char *strrchr(char *s, int c) throw() { - return strchr(s, c); -} +char* strrchr(char* s, int c) throw() { return strchr(s, c); } #endif // s1 and s2 must be allocated. // return a non-deterministic integer -int strcmp(const char *s1, const char *s2) { +int strcmp(const char* s1, const char* s2) { int size_s1; int size_s2; int res; @@ -167,15 +162,15 @@ int strcmp(const char *s1, const char *s2) { // the string s must be allocated // return the size of the buffer - 1 -size_t strlen(const char *s) { +size_t strlen(const char* s) { int size; size = __get_array_size(s); - return size-1; + return size - 1; } // s must be allocated // return s -char *strlwr(char *s) { +char* strlwr(char* s) { int size1; size1 = __get_array_size(s); return s; @@ -184,20 +179,20 @@ char *strlwr(char *s) { // s1 and s2 must be allocated // n should not be greater than the size of s1 or s2 // return s1 -char *strncat(char *s1, const char *s2, size_t n) { +char* strncat(char* s1, const char* s2, size_t n) { int size_s1; int size_s2; size_s1 = __get_array_size(s1); size_s2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION((n>size_s1) || (n>size_s2)); + INFER_EXCLUDE_CONDITION((n > size_s1) || (n > size_s2)); return s1; } // s1 and s2 must be allocated // n should not be greater than the size of s1 or s2 // return a non-deterministic integer -int strncmp(const char *s1, const char *s2, size_t n) { +int strncmp(const char* s1, const char* s2, size_t n) { int size_s1; int size_s2; int res; @@ -205,15 +200,17 @@ int strncmp(const char *s1, const char *s2, size_t n) { size_s1 = __get_array_size(s1); size_s2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION((n>size_s1) || (n>size_s2)); + INFER_EXCLUDE_CONDITION((n > size_s1) || (n > size_s2)); return res; } // the strings s1 and s2 need to be allocated -// check that n characters fit in s1 (because even if s2 is shorter than n, null characters are appended to s1) -char *strncpy(char *s1, const char *s2, size_t n) { +// check that n characters fit in s1 (because even if s2 is shorter than n, null +// characters are appended to s1) +char* strncpy(char* s1, const char* s2, size_t n) { int size1, size2; - __infer_set_flag("ignore_return", ""); // no warnings if the return value is ignored + __infer_set_flag("ignore_return", + ""); // no warnings if the return value is ignored size1 = __get_array_size(s1); size2 = __get_array_size(s2); @@ -222,13 +219,13 @@ char *strncpy(char *s1, const char *s2, size_t n) { } #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO -char *strpbrk(const char *s1, const char *s2) { +char* strpbrk(const char* s1, const char* s2) { #else -const char *strpbrk(const char *s1, const char *s2) throw() { - return strpbrk((char*) s1, s2); +const char* strpbrk(const char* s1, const char* s2) throw() { + return strpbrk((char*)s1, s2); } -char *strpbrk(char *s1, const char *s2) throw() { +char* strpbrk(char* s1, const char* s2) throw() { #endif int size1, size2; int nondet; @@ -238,14 +235,15 @@ char *strpbrk(char *s1, const char *s2) throw() { size1 = __get_array_size(s1); size2 = __get_array_size(s2); - if(nondet) return 0; - INFER_EXCLUDE_CONDITION(offset < 0 || offset >=size1); - return (char *)s1 + offset; + if (nondet) + return 0; + INFER_EXCLUDE_CONDITION(offset < 0 || offset >= size1); + return (char*)s1 + offset; } // s1 and s2 must be allocated. // return an integer between 0 ans the size of s1 -size_t strspn(const char *s1, const char *s2) { +size_t strspn(const char* s1, const char* s2) { int size_s1; int size_s2; int res; @@ -258,14 +256,14 @@ size_t strspn(const char *s1, const char *s2) { } #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO -char *strstr(const char *s1, const char *s2) { +char* strstr(const char* s1, const char* s2) { #else -const char *strstr(const char *s1, const char *s2) throw() { - return strstr((char*) s1, s2); +const char* strstr(const char* s1, const char* s2) throw() { + return strstr((char*)s1, s2); } -char *strstr(char *s1, const char *s2) throw() { +char* strstr(char* s1, const char* s2) throw() { #endif int size1, size2; int nondet; @@ -275,32 +273,34 @@ char *strstr(char *s1, const char *s2) throw() { size1 = __get_array_size(s1); size2 = __get_array_size(s2); - if(nondet) return 0; - INFER_EXCLUDE_CONDITION(offset < 0 || offset >=size1); - return (char *)s1 + offset; + if (nondet) + return 0; + INFER_EXCLUDE_CONDITION(offset < 0 || offset >= size1); + return (char*)s1 + offset; } // modeled using strtoul -double strtod(const char *str, char **endptr) { - return (double) strtoul(str, endptr, 0); +double strtod(const char* str, char** endptr) { + return (double)strtoul(str, endptr, 0); } // modeled like strtoul -long strtol(const char *str, char **endptr, int base) { - return (long) strtoul(str, endptr, base); +long strtol(const char* str, char** endptr, int base) { + return (long)strtoul(str, endptr, base); } // the string s must be allocated // assign to endptr a pointer somewhere inside the string str // result is nondeterministic -unsigned long strtoul(const char *str, char **endptr, int base) { +unsigned long strtoul(const char* str, char** endptr, int base) { int size; int offset; int res; size = __get_array_size(str); offset = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(offset < 0 || offset >= size); - if(endptr) *endptr = (char *) (str + offset); + if (endptr) + *endptr = (char*)(str + offset); res = __infer_nondet_int(); int errno_val = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(errno_val < 0); @@ -310,7 +310,7 @@ unsigned long strtoul(const char *str, char **endptr, int base) { // s must be allocated // return s -char *strupr(char *s) { +char* strupr(char* s) { int size1; size1 = __get_array_size(s); return s; @@ -320,14 +320,14 @@ char *strupr(char *s) { // n should not be greater than the size of s // nondeterministically return 0 or a pointer within the first n elements of s #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO -void *memchr(const void *s, int c, size_t n) { +void* memchr(const void* s, int c, size_t n) { #else -const void *memchr(const void *s, int c, size_t n) throw() { - return memchr((void*) s, c, n); +const void* memchr(const void* s, int c, size_t n) throw() { + return memchr((void*)s, c, n); } -void *memchr(void *s, int c, size_t n) throw() { +void* memchr(void* s, int c, size_t n) throw() { #endif int size; int nondet; @@ -337,123 +337,134 @@ void *memchr(void *s, int c, size_t n) throw() { size = __get_array_size(s); INFER_EXCLUDE_CONDITION(n > size); - if(nondet) return 0; + if (nondet) + return 0; INFER_EXCLUDE_CONDITION(offset < 0 || offset >= n); - return (char *)s + offset; + return (char*)s + offset; } // s1 and s2 must be allocated // n should not be greater than the size of s1 or s2 // return a non-deterministic integer -int memcmp(const void *s1, const void *s2, size_t n) { +int memcmp(const void* s1, const void* s2, size_t n) { int size_s1; int size_s2; size_s1 = __get_array_size(s1); size_s2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION((n>size_s1) || (n>size_s2)); + INFER_EXCLUDE_CONDITION((n > size_s1) || (n > size_s2)); return __infer_nondet_int(); } // s1 and s2 must be allocated // n must be between 0 and the minumum of the sizes of s1 and s2 -void *memcpy(void *s1, const void *s2, size_t n) { +void* memcpy(void* s1, const void* s2, size_t n) { int size_s1; int size_s2; - __infer_set_flag("ignore_return", ""); // no warnings if the return value is ignored + __infer_set_flag("ignore_return", + ""); // no warnings if the return value is ignored size_s1 = __get_array_size(s1); size_s2 = __get_array_size(s2); - INFER_EXCLUDE_CONDITION((n < 0) || (n>size_s1) || (n>size_s2)); + INFER_EXCLUDE_CONDITION((n < 0) || (n > size_s1) || (n > size_s2)); return s1; } // modeld using memcpy -void *memmove(void *s1, const void *s2, size_t n) { - __infer_set_flag("ignore_return", ""); // no warnings if the return value is ignored +void* memmove(void* s1, const void* s2, size_t n) { + __infer_set_flag("ignore_return", + ""); // no warnings if the return value is ignored return memcpy(s1, s2, n); } // s needs to be allocated // n should not be greater than the size of s -void *memset(void *s, int c, size_t n) { +void* memset(void* s, int c, size_t n) { int size_s; - __infer_set_flag("ignore_return", ""); // no warnings if the return value is ignored + __infer_set_flag("ignore_return", + ""); // no warnings if the return value is ignored size_s = __get_array_size(s); - INFER_EXCLUDE_CONDITION(n>size_s); + INFER_EXCLUDE_CONDITION(n > size_s); return s; } // return a nondeterministic double -double atof(const char *str) { - return __infer_nondet_double(); -} +double atof(const char* str) { return __infer_nondet_double(); } // return a nondeterministic value between INT_MIN and INT_MAX -int atoi(const char *str) { +int atoi(const char* str) { int retu = INT_MAX; int retl = INT_MIN; int ret; - if (__infer_nondet_int()) ret = retu; - else ret = retl; + if (__infer_nondet_int()) + ret = retu; + else + ret = retl; return ret; } // modeled using malloc and set file attribute -FILE *fopen (const char *filename, const char *mode) { - FILE *ret; - ret = (FILE*) malloc(sizeof(FILE)); - if(ret) __set_file_attribute(ret); +FILE* fopen(const char* filename, const char* mode) { + FILE* ret; + ret = (FILE*)malloc(sizeof(FILE)); + if (ret) + __set_file_attribute(ret); return ret; } // modeled using fopen -FILE *tmpfile(void) { - return fopen("foo", ""); -} +FILE* tmpfile(void) { return fopen("foo", ""); } // use a global variable to model the return value of tmpnam -extern char *_tmpnam_global; -// return NULL, or if s is NULL return a global variable, otherwise check that s has size at least L_tmpnam and return s -char *tmpnam(char *s) { +extern char* _tmpnam_global; +// return NULL, or if s is NULL return a global variable, otherwise check that s +// has size at least L_tmpnam and return s +char* tmpnam(char* s) { int success; int size; success = __infer_nondet_int(); - if(!success) return NULL; - if(s) { + if (!success) + return NULL; + if (s) { size = __get_array_size(s); INFER_EXCLUDE_CONDITION(size < L_tmpnam); return s; - } - else return _tmpnam_global; + } else + return _tmpnam_global; } // nondeterministically return NULL or the original stream -FILE *freopen(const char *__restrict filename, const char *__restrict mode, FILE *__restrict stream) { +FILE* freopen(const char* __restrict filename, + const char* __restrict mode, + FILE* __restrict stream) { int n; n = __infer_nondet_int(); - if(n) return NULL; - else return stream; + if (n) + return NULL; + else + return stream; } // modeled using free, can return EOF -int fclose (FILE *stream) { +int fclose(FILE* stream) { int n; free(stream); n = __infer_nondet_int(); - if (n>0) return 0; - else return EOF; + if (n > 0) + return 0; + else + return EOF; } // modeled using malloc and set file attribute // return the allocated ptr - 1 if malloc succeeds, otherwise return -1 -int open(const char *path, int oflag, ...) { - int *ret = (int*)malloc(sizeof(int)); - if(ret) { +int open(const char* path, int oflag, ...) { + int* ret = (int*)malloc(sizeof(int)); + if (ret) { __set_file_attribute(ret); - INFER_EXCLUDE_CONDITION(ret < (int *)1); // force result to be > 0 + INFER_EXCLUDE_CONDITION(ret < (int*)1); // force result to be > 0 return (size_t)ret; } return -1; @@ -463,43 +474,49 @@ int open(const char *path, int oflag, ...) { int close(int fildes) { int n; if (fildes != -1) - free((int *) (long) fildes); + free((int*)(long)fildes); n = __infer_nondet_int(); - if (n>0) return 0; - else return -1; + if (n > 0) + return 0; + else + return -1; } // modeled as close followed by fopen -FILE *fdopen(int fildes, const char *mode) { +FILE* fdopen(int fildes, const char* mode) { close(fildes); return fopen("foo", mode); } // return nonteterministically 0 or -1 // requires stream to be allocated -int fseek(FILE *stream, long int offset, int whence) { +int fseek(FILE* stream, long int offset, int whence) { int n; FILE tmp; tmp = *stream; n = __infer_nondet_int(); - if (n) return 0; - else return -1; + if (n) + return 0; + else + return -1; } // return nondeterministically a nonnegative value or -1 // requires stream to be allocated -long int ftell(FILE *stream) { +long int ftell(FILE* stream) { int n; FILE tmp; tmp = *stream; n = __infer_nondet_int(); - if (n>=0) return n; - else return -1; + if (n >= 0) + return n; + else + return -1; } // on success return str otherwise null // requires stream to be allocated -char *fgets( char *str, int num, FILE *stream ) { +char* fgets(char* str, int num, FILE* stream) { int n; int size1; FILE tmp; @@ -507,27 +524,29 @@ char *fgets( char *str, int num, FILE *stream ) { tmp = *stream; n = __infer_nondet_int(); - if (n>0) { + if (n > 0) { size1 = __get_array_size(str); - INFER_EXCLUDE_CONDITION(num>size1); + INFER_EXCLUDE_CONDITION(num > size1); return str; - } - else return NULL; + } else + return NULL; } // string s must be allocated; return nondeterministically s or NULL -char *gets(char *s) { +char* gets(char* s) { int n; int size; size = __get_array_size(s); n = __infer_nondet_int(); - if(n) return s; - else return NULL; + if (n) + return s; + else + return NULL; } // str must be allocated, return a nondeterministic value -int puts(const char *str) { +int puts(const char* str) { int size1; size1 = __get_array_size(str); return __infer_nondet_int(); @@ -535,7 +554,7 @@ int puts(const char *str) { // modeled using puts // require the stream to be allocated -int fputs(const char *str, FILE *stream) { +int fputs(const char* str, FILE* stream) { FILE tmp; tmp = *stream; return puts(str); @@ -543,8 +562,7 @@ int fputs(const char *str, FILE *stream) { // return a nondeterministic value // requires stream to be allocated -int getc(FILE *stream) -{ +int getc(FILE* stream) { FILE tmp; tmp = *stream; return __infer_nondet_int(); @@ -552,8 +570,7 @@ int getc(FILE *stream) // return a nondeterministic value // requires stream to be allocated -int fgetc(FILE *stream) -{ +int fgetc(FILE* stream) { FILE tmp; tmp = *stream; return __infer_nondet_int(); @@ -561,180 +578,187 @@ int fgetc(FILE *stream) // return nondeterministically c or EOF // requires stream to be allocated -int ungetc(int c, FILE *stream) { +int ungetc(int c, FILE* stream) { int n; FILE tmp; tmp = *stream; n = __infer_nondet_int(); - if (n) return c; - else return EOF; + if (n) + return c; + else + return EOF; } // modeled like putc // requires stream to be allocated -int fputc(int c, FILE *stream) -{ +int fputc(int c, FILE* stream) { FILE tmp; tmp = *stream; - return putc(c,stream); + return putc(c, stream); } // on success return buffer otherwise null -char *getcwd (char *buffer, size_t size) { +char* getcwd(char* buffer, size_t size) { int n; int size_buf; n = __infer_nondet_int(); - if (n>0) { - size_buf= __get_array_size(buffer); - INFER_EXCLUDE_CONDITION(size>size_buf); + if (n > 0) { + size_buf = __get_array_size(buffer); + INFER_EXCLUDE_CONDITION(size > size_buf); return buffer; - } - else return NULL; + } else + return NULL; } // return nonteterministically 0 or -1 -int rename(const char *old, const char *new_) { +int rename(const char* old, const char* new_) { int n; n = __infer_nondet_int(); - if (n) return 0; - else return -1; + if (n) + return 0; + else + return -1; } // modeled as skip // requires stream to be allocated -void rewind(FILE *stream) { - FILE tmp; - tmp = *stream; +void rewind(FILE* stream) { + FILE tmp; + tmp = *stream; } // modeled as exit() -void longjmp(jmp_buf env, int val) { - exit(0); -} +void longjmp(jmp_buf env, int val) { exit(0); } // modeled as skip. -//If sleep() returns because the requested time has elapsed, -//the value returned shall be 0. If sleep() returns due to delivery of a signal, -//the return value shall be the "unslept" amount (the requested time minus the time actually slept) in seconds. +// If sleep() returns because the requested time has elapsed, +// the value returned shall be 0. If sleep() returns due to delivery of a +// signal, +// the return value shall be the "unslept" amount (the requested time minus the +// time actually slept) in seconds. unsigned sleep(unsigned seconds) { int n; n = __infer_nondet_int(); - INFER_EXCLUDE_CONDITION(n<0); + INFER_EXCLUDE_CONDITION(n < 0); return n; } #ifdef __CYGWIN__ // define __WAIT_STATUS as int * on cygwin -#define __WAIT_STATUS int * +#define __WAIT_STATUS int* #endif #ifdef __APPLE__ // define __WAIT_STATUS as int * on mac -#define __WAIT_STATUS int * +#define __WAIT_STATUS int* #endif -// the waiting is modeled as skip. Then the return value is a random value of a process or +// the waiting is modeled as skip. Then the return value is a random value of a +// process or // -1 in case of an error pid_t wait(__WAIT_STATUS stat_loc) { int n; pid_t tmp; n = __infer_nondet_int(); tmp = __infer_nondet_int(); - if (n>0) return tmp; - else return -1; + if (n > 0) + return tmp; + else + return -1; } #ifndef __cplusplus // return a nondeterministic pointer void (*signal(int sig, void (*func)(int)))(int) { - void (*res) (int) = __infer_nondet_ptr(); + void (*res)(int) = __infer_nondet_ptr(); return res; }; #endif // modelled as exit -void pthread_exit(void *value_ptr) { exit(0); }; - -//INTENDED SEMANTICS: The setitimer() function shall set the timer specified by which -//to the value specified in the structure pointed to by value, and if ovalue is not a null pointer, -//store the previous value of the timer in the structure pointed to by ovalue. -int setitimer(int which, const struct itimerval *__restrict value, struct itimerval *__restrict ovalue) { +void pthread_exit(void* value_ptr) { exit(0); }; + +// INTENDED SEMANTICS: The setitimer() function shall set the timer specified by +// which +// to the value specified in the structure pointed to by value, and if ovalue is +// not a null pointer, +// store the previous value of the timer in the structure pointed to by ovalue. +int setitimer(int which, + const struct itimerval* __restrict value, + struct itimerval* __restrict ovalue) { int n; int tmp; n = __infer_nondet_int(); tmp = __infer_nondet_int(); // not sure about this assignment. - //it should somehow change the value of the timer which. - //But which is just an int, so it looks like this is useless - which=tmp; - if (n>0) return 0; - else return -1; + // it should somehow change the value of the timer which. + // But which is just an int, so it looks like this is useless + which = tmp; + if (n > 0) + return 0; + else + return -1; } // pause returns only when a signal is received // the return value is always -1 -int pause(void) { - return -1; -} +int pause(void) { return -1; } // modeled with nondeterministic value n -pid_t fork(void) { - return __infer_nondet_int(); -} +pid_t fork(void) { return __infer_nondet_int(); } // allocate memory directly, and return -1 if malloc fails. int shmget(key_t key, size_t size, int shmflg) { - void *res = malloc(size); - if(!res) return -1; - return (long) res; + void* res = malloc(size); + if (!res) + return -1; + return (long)res; } // simply return the first parameter -void *shmat(int shmid, const void *shmaddr, int shmflg) { - return (void *) (long) shmid; +void* shmat(int shmid, const void* shmaddr, int shmflg) { + return (void*)(long)shmid; } // return a non-deterministic value -int shmdt(const void *shmaddr) { - return __infer_nondet_int(); -} +int shmdt(const void* shmaddr) { return __infer_nondet_int(); } -// if the command is IPC_RMID free the first parameter; return a non-deterministic value -int shmctl(int shmid, int cmd, struct shmid_ds *buf) { +// if the command is IPC_RMID free the first parameter; return a +// non-deterministic value +int shmctl(int shmid, int cmd, struct shmid_ds* buf) { int n; - void *shmaddr; + void* shmaddr; n = __infer_nondet_int(); - shmaddr = (void *) (long) shmid; - if(cmd == IPC_RMID) free(shmaddr); + shmaddr = (void*)(long)shmid; + if (cmd == IPC_RMID) + free(shmaddr); return n; } -void *realloc(void *ptr, size_t size) { - if(ptr==0) { // if ptr in NULL, behave as malloc +void* realloc(void* ptr, size_t size) { + if (ptr == 0) { // if ptr in NULL, behave as malloc return malloc(size); } int old_size; int can_enlarge; old_size = __get_array_size(ptr); // force ptr to be an array - can_enlarge = __infer_nondet_int(); // nondeterministically choose whether the current block can be enlarged - if(can_enlarge) { + can_enlarge = __infer_nondet_int(); // nondeterministically choose whether the + // current block can be enlarged + if (can_enlarge) { __set_array_size(ptr, size); // enlarge the block return ptr; } - int *newblock = (int*)malloc(size); - if(newblock) { + int* newblock = (int*)malloc(size); + if (newblock) { free(ptr); return newblock; - } - else { // if new allocation fails, do not free the old block + } else { // if new allocation fails, do not free the old block return newblock; } } // modelled as a call to malloc -void *calloc(size_t nmemb, size_t size) { - return malloc(nmemb *size); -} +void* calloc(size_t nmemb, size_t size) { return malloc(nmemb * size); } // character functions from ctype.h // all modelled as returning a nondeterministic value @@ -755,29 +779,28 @@ int toupper(int x) { return __infer_nondet_int(); } int isascii(int x) { return __infer_nondet_int(); } int toascii(int x) { return __infer_nondet_int(); } -//modeled as skip. n>0 models success. -//Upon successful completion a non-negative integer, namely the file descriptor, shall be returned; +// modeled as skip. n>0 models success. +// Upon successful completion a non-negative integer, namely the file +// descriptor, shall be returned; // otherwise, -1 shall be returned. int dup(int fildes) { int n; n = __infer_nondet_int(); - if (n>0) return fildes; - else return -1; - + if (n > 0) + return fildes; + else + return -1; }; // modeled as skip. -//The getuid() function shall always be successful and no return value is reserved to indicate the error. -uid_t getuid(void) { - return __infer_nondet_int(); -}; - +// The getuid() function shall always be successful and no return value is +// reserved to indicate the error. +uid_t getuid(void) { return __infer_nondet_int(); }; -//modeled as skip -//The getpid() function shall always be successful and no return value is reserved to indicate an error. -pid_t getpid(void) { - return __infer_nondet_int(); -}; +// modeled as skip +// The getpid() function shall always be successful and no return value is +// reserved to indicate an error. +pid_t getpid(void) { return __infer_nondet_int(); }; // modeled as skip. // success is modeled by n>0, if lseek fails (off_t)-1 should be returned. @@ -787,74 +810,82 @@ off_t lseek(int fildes, off_t offset, int whence) { n = __infer_nondet_int(); tmp = __infer_nondet_int(); - if (n>0) return tmp; - else return (off_t)-1; + if (n > 0) + return tmp; + else + return (off_t)-1; }; // modeled using malloc and set file attribute -DIR *opendir(const char *dirname) { - DIR *ret; - ret = (DIR*)malloc(sizeof(void *)); - if(ret) __set_file_attribute(ret); +DIR* opendir(const char* dirname) { + DIR* ret; + ret = (DIR*)malloc(sizeof(void*)); + if (ret) + __set_file_attribute(ret); return ret; } // modeled using free, can return EOF -int closedir(DIR *dirp) { +int closedir(DIR* dirp) { DIR tmp = *dirp; int n; n = __infer_nondet_int(); free(dirp); - if (n>0) return 0; - else return EOF; + if (n > 0) + return 0; + else + return EOF; } // use a global variable to model the return value of readdir -extern struct dirent *_dirent_global; +extern struct dirent* _dirent_global; // dirp must be allocated // return 0 or the allocated pointerq _dirent_global, nondeterministically -struct dirent *readdir(DIR *dirp) { +struct dirent* readdir(DIR* dirp) { int len; int nondet; - struct dirent *ret = _dirent_global; + struct dirent* ret = _dirent_global; len = __get_array_size(dirp); nondet = __infer_nondet_int(); - if(nondet) return 0; + if (nondet) + return 0; return ret; } // use a global variable to model the return value of getenv -extern char *_getenv_global; +extern char* _getenv_global; // string name must be allocated // return 0 or the allocated string _getenv_global, nondeterministically -char *getenv(const char *name) { +char* getenv(const char* name) { int size; int nondet; - size =__get_array_size(name); - size =__get_array_size(_getenv_global); + size = __get_array_size(name); + size = __get_array_size(_getenv_global); nondet = __infer_nondet_int(); - if(nondet) return 0; + if (nondet) + return 0; return _getenv_global; } // use a global variable to model the return value of setlocale -extern char *_locale_global; +extern char* _locale_global; // string locale must be allocated // return 0 or the allocated string _locale_global, nondeterministically -char *setlocale(int category, const char *locale) { +char* setlocale(int category, const char* locale) { int size; int nondet; - size =__get_array_size(locale); - size =__get_array_size(_locale_global); + size = __get_array_size(locale); + size = __get_array_size(_locale_global); nondet = __infer_nondet_int(); - if(nondet) return 0; + if (nondet) + return 0; return _locale_global; } // use a global variable to model the return value of localeconv -extern struct lconv *_lconv_global; +extern struct lconv* _lconv_global; // return the allocated pointer _lconv_global -struct lconv *localeconv() { +struct lconv* localeconv() { int nondet; struct lconv tmp; tmp = *_lconv_global; @@ -862,48 +893,42 @@ struct lconv *localeconv() { } // use a global variable to model the return value of localtime -extern struct tm *_tm_global; +extern struct tm* _tm_global; // return nondeterministically NULL or the global variable _tm_global -struct tm *localtime(const time_t *clock) { +struct tm* localtime(const time_t* clock) { int fail; fail = __infer_nondet_int(); - if (fail) return NULL; - else return _tm_global; + if (fail) + return NULL; + else + return _tm_global; } // return nondeterministically NULL or the global variable _tm_global -struct tm *gmtime(const time_t *timer) -{ +struct tm* gmtime(const time_t* timer) { int fail; fail = __infer_nondet_int(); - if (fail) return NULL; - else return _tm_global; + if (fail) + return NULL; + else + return _tm_global; } // use a global variable to model the return value of asctime -extern char *_asctime_global; +extern char* _asctime_global; // return the global variable _asctime_global -char *asctime(const struct tm *timeptr) -{ - return _asctime_global; -} +char* asctime(const struct tm* timeptr) { return _asctime_global; } // modelled using asctime and localtime -char *ctime(const time_t *clock) { - return asctime(localtime(clock)); -} +char* ctime(const time_t* clock) { return asctime(localtime(clock)); } // return a nondeterministic double -double difftime(time_t time1, time_t time0) -{ - return __infer_nondet_double(); -} +double difftime(time_t time1, time_t time0) { return __infer_nondet_double(); } // return a nondeterministic nonnegative value or -1 -time_t mktime(struct tm *timeptr) -{ +time_t mktime(struct tm* timeptr) { time_t res; res = __infer_nondet_time_t(); INFER_EXCLUDE_CONDITION(res < -1); @@ -911,8 +936,7 @@ time_t mktime(struct tm *timeptr) } // return a nondeterministic nonnegative value or -1 -clock_t clock() -{ +clock_t clock() { clock_t res; res = __infer_nondet_clock_t(); INFER_EXCLUDE_CONDITION(res < -1); @@ -920,8 +944,10 @@ clock_t clock() } // return a nondeterministic nonnegative value -size_t strftime(char *__restrict s, size_t maxsize, const char *__restrict format, const struct tm *__restrict timeptr) -{ +size_t strftime(char* __restrict s, + size_t maxsize, + const char* __restrict format, + const struct tm* __restrict timeptr) { size_t res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -929,76 +955,84 @@ size_t strftime(char *__restrict s, size_t maxsize, const char *__restrict forma } // return a nondeterministic value of type time_t -time_t time(time_t *tloc) { +time_t time(time_t* tloc) { time_t t; t = __infer_nondet_time_t(); - if(tloc) *tloc = t; + if (tloc) + *tloc = t; return t; } // use a global variable to model the return value of getpwuid -extern struct passwd *_getpwuid_global; +extern struct passwd* _getpwuid_global; // return either NULL or the global variable _getpwuid_global -struct passwd *getpwuid(uid_t uid) { +struct passwd* getpwuid(uid_t uid) { int found; found = __infer_nondet_int(); - if (found) return _getpwuid_global; - else return NULL; + if (found) + return _getpwuid_global; + else + return NULL; } // use a global variable to model the return value of getpwent -extern struct passwd *_getpwent_global; +extern struct passwd* _getpwent_global; // return either NULL or the global variable _getpwent_global -struct passwd *getpwent(void) { +struct passwd* getpwent(void) { int found; found = __infer_nondet_int(); - if (found) return _getpwent_global; - else return NULL; + if (found) + return _getpwent_global; + else + return NULL; } // use a global variable to model the return value of getpwnam -extern struct passwd *_getpwnam_global; +extern struct passwd* _getpwnam_global; // login must be allocated // return either NULL or the global variable _getpnam_global -struct passwd *getpwnam(const char *login) { +struct passwd* getpwnam(const char* login) { int found; int size1; size1 = __get_array_size(login); found = __infer_nondet_int(); - if (found) return _getpwnam_global; - else return NULL; + if (found) + return _getpwnam_global; + else + return NULL; } // nondeterministically return 0 (failure) or 1 (success) int setpassent(int stayopen) { int success; success = __infer_nondet_int(); - if(success) return 1; - else return 0; + if (success) + return 1; + else + return 0; } // modled as skip -void setpwent(void) { -} +void setpwent(void) {} // modled as skip -void endpwent(void) { -} +void endpwent(void) {} // use a global variable to model the return value of getlogin -extern char *_getlogin_global; +extern char* _getlogin_global; // string name must be allocated // return 0 or the allocated string _getlogin_global, nondeterministically -char *getlogin() { +char* getlogin() { int size; int nondet; size = __get_array_size(_getlogin_global); nondet = __infer_nondet_int(); - if(nondet) return 0; + if (nondet) + return 0; return _getlogin_global; } -int setlogin(const char *name) { +int setlogin(const char* name) { int success; int size1; size1 = __get_array_size(name); @@ -1006,15 +1040,15 @@ int setlogin(const char *name) { if (success) { strcpy(_getlogin_global, name); return 0; - } - else return -1; + } else + return -1; } // use a global variable to model the return value of getpass -extern char *_getpass_global; +extern char* _getpass_global; // prompt must be allocated // return the global variable _getpass_global, which must be allocated -char *getpass(const char *prompt) { +char* getpass(const char* prompt) { int size1; size1 = __get_array_size(prompt); size1 = __get_array_size(_getpass_global); @@ -1022,8 +1056,7 @@ char *getpass(const char *prompt) { } // return a nondeterministic nonnegative integer -int printf(const char *format, ...) -{ +int printf(const char* format, ...) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -1032,19 +1065,17 @@ int printf(const char *format, ...) // return a nondeterministic nonnegative integer // requires stream to be allocated -int fprintf(FILE *stream, const char *format, ...) -{ +int fprintf(FILE* stream, const char* format, ...) { int res; FILE tmp; - tmp= *stream; + tmp = *stream; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); return res; } // return a nondeterministic nonnegative integer -int snprintf(char * __restrict s, size_t n, const char * __restrict format, ...) -{ +int snprintf(char* __restrict s, size_t n, const char* __restrict format, ...) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -1053,8 +1084,7 @@ int snprintf(char * __restrict s, size_t n, const char * __restrict format, ...) // s must be allocated // return a nondeterministic nonnegative integer -int sprintf(char *s, const char *format, ...) -{ +int sprintf(char* s, const char* format, ...) { int res; int size1; size1 = __get_array_size(s); @@ -1065,20 +1095,18 @@ int sprintf(char *s, const char *format, ...) // return a nondeterministic nonnegative integer // requires stream to be allocated -int vfprintf(FILE *stream, const char *format, va_list arg) -{ +int vfprintf(FILE* stream, const char* format, va_list arg) { int res; FILE tmp; - tmp= *stream; + tmp = *stream; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); return res; } // return a nondeterministic nonnegative integer -int vsprintf(char *s, const char *format, va_list arg) -{ +int vsprintf(char* s, const char* format, va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -1086,8 +1114,7 @@ int vsprintf(char *s, const char *format, va_list arg) } // return a nondeterministic nonnegative integer -int vsnprintf(char *s, size_t n, const char *format, va_list arg) -{ +int vsnprintf(char* s, size_t n, const char* format, va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -1095,8 +1122,7 @@ int vsnprintf(char *s, size_t n, const char *format, va_list arg) } // return a nondeterministic nonnegative integer -int vprintf(const char *format, va_list arg) -{ +int vprintf(const char* format, va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -1104,28 +1130,26 @@ int vprintf(const char *format, va_list arg) } // forces path to be allocated -//return nondeterministically 0 or -1 -int utimes(const char *path, const struct timeval times[2]) { +// return nondeterministically 0 or -1 +int utimes(const char* path, const struct timeval times[2]) { int size1; int success = __infer_nondet_int(); - size1= __get_array_size(path); - //return random result + size1 = __get_array_size(path); + // return random result return (success > 0) ? 0 : -1; } - // forces filename to be allocated -//return nondeterministically 0 or -1 -int unlink (const char *filename) { +// return nondeterministically 0 or -1 +int unlink(const char* filename) { int size1; int success = __infer_nondet_int(); - size1=__get_array_size(filename); + size1 = __get_array_size(filename); return (success > 0) ? 0 : -1; } - -//return nondeterministically 0 or -1 +// return nondeterministically 0 or -1 int usleep(useconds_t useconds) { int success = __infer_nondet_int(); return (success > 0) ? 0 : -1; @@ -1133,7 +1157,7 @@ int usleep(useconds_t useconds) { // dst and src must be allocated // return an integer between 0 and size -size_t strlcpy(char *dst, const char *src, size_t size) { +size_t strlcpy(char* dst, const char* src, size_t size) { int size_src; int size_dst; int res; @@ -1145,7 +1169,7 @@ size_t strlcpy(char *dst, const char *src, size_t size) { // force dst to be allocated for at least size size_dst = __get_array_size(dst); - INFER_EXCLUDE_CONDITION(size>size_dst); + INFER_EXCLUDE_CONDITION(size > size_dst); INFER_EXCLUDE_CONDITION(res > size || res < 0); @@ -1154,19 +1178,19 @@ size_t strlcpy(char *dst, const char *src, size_t size) { // dst and src must be allocated // return an integer between 0 and size -size_t strlcat(char *dst, const char *src, size_t size) { +size_t strlcat(char* dst, const char* src, size_t size) { int size_src; int size_dst; int res; res = __infer_nondet_int(); - //force src to be allocated + // force src to be allocated size_src = __get_array_size(src); - //force dst to be allocated for at least size + // force dst to be allocated for at least size size_dst = __get_array_size(dst); - INFER_EXCLUDE_CONDITION(size>size_dst); + INFER_EXCLUDE_CONDITION(size > size_dst); INFER_EXCLUDE_CONDITION(res > size || res < 0); @@ -1176,7 +1200,7 @@ size_t strlcat(char *dst, const char *src, size_t size) { // path must be allocated // assign nonteterministically to the contents of buf // return 0 or -1 -int statfs(const char *path, struct statfs *buf) { +int statfs(const char* path, struct statfs* buf) { int success; int size_path; @@ -1194,7 +1218,7 @@ int statfs(const char *path, struct statfs *buf) { // path must be allocated // assign nonteterministically to the contents of buf // return 0 or -1 -int stat(const char *path, struct stat *buf) { +int stat(const char* path, struct stat* buf) { int success; int size_path; @@ -1209,32 +1233,32 @@ int stat(const char *path, struct stat *buf) { return (success > 0) ? 0 : -1; } -int remove(const char *path) { +int remove(const char* path) { int size_path; int success; - //force path to be allocated + // force path to be allocated size_path = __get_array_size(path); success = __infer_nondet_int(); return (success > 0) ? 0 : -1; } -char *readline(const char *prompt) { +char* readline(const char* prompt) { int size_prompt; - char *ret; + char* ret; int size; - //force prompt to be allocated when not null - if (prompt != NULL){ + // force prompt to be allocated when not null + if (prompt != NULL) { size_prompt = __get_array_size(prompt); } - //return random string of positive size + // return random string of positive size size = __infer_nondet_int(); - INFER_EXCLUDE_CONDITION(size<0); + INFER_EXCLUDE_CONDITION(size < 0); - ret = (char*) malloc(sizeof(size)); + ret = (char*)malloc(sizeof(size)); return ret; } @@ -1242,60 +1266,58 @@ long random(void) { long ret; ret = __infer_nondet_long_int(); - INFER_EXCLUDE_CONDITION(ret<0); + INFER_EXCLUDE_CONDITION(ret < 0); return ret; } // requires stream to be allocated -int putc(int c, FILE *stream){ +int putc(int c, FILE* stream) { int rand; FILE tmp; tmp = *stream; rand = __infer_nondet_int(); if (rand > 0) - return c; //success + return c; // success else - return EOF; //failure + return EOF; // failure } -int access(const char *path, int mode){ +int access(const char* path, int mode) { int size; int success; - //force path to be allocated + // force path to be allocated size = __get_array_size(path); - //determine return value + // determine return value success = __infer_nondet_int(); return (success > 0) ? 0 : -1; } - -size_t confstr(int name, char *buf, size_t len){ +size_t confstr(int name, char* buf, size_t len) { int size; int ret; - - //determine return value + // determine return value ret = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(ret < 0); - //buf should be allocated if len is not zero. Otherwise, we want buf=0. - if (len) size = __get_array_size(buf); - else INFER_EXCLUDE_CONDITION(buf !=0); + // buf should be allocated if len is not zero. Otherwise, we want buf=0. + if (len) + size = __get_array_size(buf); + else + INFER_EXCLUDE_CONDITION(buf != 0); return ret; } // return a non-deterministic value // stream is not required to be allocated -int fflush(FILE *stream){ - return __infer_nondet_int(); -} +int fflush(FILE* stream) { return __infer_nondet_int(); } -int flock(int fd, int operation){ +int flock(int fd, int operation) { int ret; ret = __infer_nondet_int(); @@ -1304,7 +1326,7 @@ int flock(int fd, int operation){ return ret; } -int fsync(int fildes){ +int fsync(int fildes) { int ret; ret = __infer_nondet_int(); @@ -1313,13 +1335,15 @@ int fsync(int fildes){ return ret; } - -int fsctl(const char *path, unsigned long request, void *data, unsigned int options){ +int fsctl(const char* path, + unsigned long request, + void* data, + unsigned int options) { int size1; int size2; int ret; - //forces path and data to be allocated + // forces path and data to be allocated size1 = __get_array_size(path); size2 = __get_array_size(data); @@ -1329,7 +1353,7 @@ int fsctl(const char *path, unsigned long request, void *data, unsigned int opti return ret; } -int getrusage(int who, struct rusage *r_usage){ +int getrusage(int who, struct rusage* r_usage) { int ret; INFER_EXCLUDE_CONDITION(r_usage == 0); @@ -1340,32 +1364,32 @@ int getrusage(int who, struct rusage *r_usage){ return ret; } - #ifdef __APPLE__ -#define gettimeofday_tzp_decl void *__restrict tzp +#define gettimeofday_tzp_decl void* __restrict tzp #else #ifdef __CYGWIN__ -#define gettimeofday_tzp_decl void *__restrict tzp +#define gettimeofday_tzp_decl void* __restrict tzp #else -#define gettimeofday_tzp_decl struct timezone *__restrict tzp +#define gettimeofday_tzp_decl struct timezone* __restrict tzp #endif #endif - -int gettimeofday(struct timeval *__restrict tp, gettimeofday_tzp_decl){ +int gettimeofday(struct timeval* __restrict tp, gettimeofday_tzp_decl) { struct timeval tmp_tp; struct timezone tmp_tzp; int success; - if (tp!=0) *tp = tmp_tp; - if (tzp!=0) *(struct timezone *)tzp = tmp_tzp; + if (tp != 0) + *tp = tmp_tp; + if (tzp != 0) + *(struct timezone*)tzp = tmp_tzp; success = __infer_nondet_int(); return success ? 0 : -1; } - -struct tm *localtime_r(const time_t *__restrict timer, struct tm *__restrict result){ +struct tm* localtime_r(const time_t* __restrict timer, + struct tm* __restrict result) { int success; struct tm tmp; @@ -1378,9 +1402,7 @@ struct tm *localtime_r(const time_t *__restrict timer, struct tm *__restrict res return (success > 0) ? result : 0; } - - -int mkdir (const char *filename, mode_t mode){ +int mkdir(const char* filename, mode_t mode) { int size; int ret; @@ -1392,8 +1414,7 @@ int mkdir (const char *filename, mode_t mode){ return ret; } - -int munmap(void *addr, size_t len){ +int munmap(void* addr, size_t len) { int ret; INFER_EXCLUDE_CONDITION(addr == 0); @@ -1404,84 +1425,85 @@ int munmap(void *addr, size_t len){ } // returns a nondeterministc value -int pthread_mutex_destroy(pthread_mutex_t *mutex){ +int pthread_mutex_destroy(pthread_mutex_t* mutex) { INFER_EXCLUDE_CONDITION(mutex == 0); return __infer_nondet_int(); } - // returns a nondeterministc value -int pthread_mutex_init(pthread_mutex_t *__restrict mutex, const pthread_mutexattr_t *__restrict attr){ +int pthread_mutex_init(pthread_mutex_t* __restrict mutex, + const pthread_mutexattr_t* __restrict attr) { INFER_EXCLUDE_CONDITION(mutex == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutex_lock(pthread_mutex_t *mutex){ +int pthread_mutex_lock(pthread_mutex_t* mutex) { INFER_EXCLUDE_CONDITION(mutex == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutex_trylock(pthread_mutex_t *mutex){ +int pthread_mutex_trylock(pthread_mutex_t* mutex) { INFER_EXCLUDE_CONDITION(mutex == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutex_unlock(pthread_mutex_t *mutex){ +int pthread_mutex_unlock(pthread_mutex_t* mutex) { INFER_EXCLUDE_CONDITION(mutex == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutexattr_destroy(pthread_mutexattr_t *attr){ +int pthread_mutexattr_destroy(pthread_mutexattr_t* attr) { INFER_EXCLUDE_CONDITION(attr == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutexattr_init(pthread_mutexattr_t *attr){ +int pthread_mutexattr_init(pthread_mutexattr_t* attr) { INFER_EXCLUDE_CONDITION(attr == 0); return __infer_nondet_int(); } // returns a nondeterministc value -int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type){ +int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type) { INFER_EXCLUDE_CONDITION(attr == 0); return __infer_nondet_int(); } -// returns a nondeterministc value and forces type to be allocated and set its content -int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type){ +// returns a nondeterministc value and forces type to be allocated and set its +// content +int pthread_mutexattr_gettype(const pthread_mutexattr_t* attr, int* type) { INFER_EXCLUDE_CONDITION(attr == 0); - *type= __infer_nondet_int(); + *type = __infer_nondet_int(); return __infer_nondet_int(); } // return a positive non-deterministic number or -1. // requires stream to be allocated -int fileno(FILE *stream){ +int fileno(FILE* stream) { int ret = __infer_nondet_int(); FILE tmp; tmp = *stream; - INFER_EXCLUDE_CONDITION(ret<-1 || ret==0 ); + INFER_EXCLUDE_CONDITION(ret < -1 || ret == 0); return ret; } -int fstat(int fildes, struct stat *buf) { +int fstat(int fildes, struct stat* buf) { int ret; struct stat s; // uninitialized struct stat *buf = s; ret = __infer_nondet_int(); - INFER_EXCLUDE_CONDITION(ret < -1 || ret>0); + INFER_EXCLUDE_CONDITION(ret < -1 || ret > 0); return ret; } // treates as skyp. Return nondeterministically 0 or -1 int futimes(int fildes, const struct timeval times[2]) { int ret = __infer_nondet_int(); - INFER_EXCLUDE_CONDITION(ret < -1 || ret>0); + INFER_EXCLUDE_CONDITION(ret < -1 || ret > 0); return ret; } @@ -1489,10 +1511,12 @@ int futimes(int fildes, const struct timeval times[2]) { #undef getchar #endif int getchar(void) { - //randomly produce an error + // randomly produce an error int ret = __infer_nondet_int(); - if (ret < 0) return EOF; - else return ret; + if (ret < 0) + return EOF; + else + return ret; } int isatty(int fildes) { @@ -1503,7 +1527,7 @@ int isatty(int fildes) { return ret; } -void perror(const char *s) { +void perror(const char* s) { int size = __get_array_size(s); size = 0; } @@ -1514,12 +1538,11 @@ int pipe(int fildes[2]) { return ret; } -int raise(int sig){ - return __infer_nondet_int(); -} +int raise(int sig) { return __infer_nondet_int(); } -ssize_t read(int fildes, void *buf, size_t nbyte) { - if (nbyte==0) return 0; +ssize_t read(int fildes, void* buf, size_t nbyte) { + if (nbyte == 0) + return 0; INFER_EXCLUDE_CONDITION(__get_array_size(buf) < nbyte); int ret = __infer_nondet_int(); @@ -1527,27 +1550,29 @@ ssize_t read(int fildes, void *buf, size_t nbyte) { return ret; } -int sigaction(int sig, const struct sigaction *act, struct sigaction *oact){ +int sigaction(int sig, const struct sigaction* act, struct sigaction* oact) { int ret = __infer_nondet_int(); - INFER_EXCLUDE_CONDITION(ret < -1 || ret >0); + INFER_EXCLUDE_CONDITION(ret < -1 || ret > 0); return ret; } // return the first argument -//long __builtin_expect(long x, long y) { +// long __builtin_expect(long x, long y) { // return x; //} -//TODO: this function has been disabled because it cannot be compiled with LLVM. -//It is normally a builtin that should not be implemented and LLVM complains about this +// TODO: this function has been disabled because it cannot be compiled with +// LLVM. +// It is normally a builtin that should not be implemented and LLVM complains +// about this #ifdef clearerr // cygwin defines clearerr as a macro #undef clearerr #endif // modelled as skip // stream is required to be allocated -void clearerr(FILE *stream) { - FILE tmp; - tmp = *stream; +void clearerr(FILE* stream) { + FILE tmp; + tmp = *stream; } #ifdef ferror // cygwin defines ferror as a macro @@ -1555,7 +1580,7 @@ void clearerr(FILE *stream) { #endif // return a nondeterministic value // stream required to be allocated -int ferror(FILE *stream) { +int ferror(FILE* stream) { FILE tmp; tmp = *stream; @@ -1567,7 +1592,7 @@ int ferror(FILE *stream) { #endif // return a nondeterministic value // stream required to be allocated -int feof(FILE *stream) { +int feof(FILE* stream) { FILE tmp; tmp = *stream; @@ -1576,24 +1601,26 @@ int feof(FILE *stream) { // write to *pos and return either 0 or -1 // stream is required to be allocated -int fgetpos(FILE *__restrict stream, fpos_t *__restrict pos) { +int fgetpos(FILE* __restrict stream, fpos_t* __restrict pos) { int success; FILE tmp; tmp = *stream; - #ifdef __APPLE__ //fpos_t is a long in MacOS, but a struct in Linux. - *pos = __infer_nondet_long_int(); - #else - pos->__pos = __infer_nondet_long_int(); - #endif +#ifdef __APPLE__ // fpos_t is a long in MacOS, but a struct in Linux. + *pos = __infer_nondet_long_int(); +#else + pos->__pos = __infer_nondet_long_int(); +#endif success = __infer_nondet_int(); - if(success) return 0; - else return -1; + if (success) + return 0; + else + return -1; } // read from *pos and return either 0 or -1 // stream is required to be allocated -int fsetpos(FILE *stream, const fpos_t *pos) { +int fsetpos(FILE* stream, const fpos_t* pos) { int success; FILE tmp; @@ -1601,32 +1628,43 @@ int fsetpos(FILE *stream, const fpos_t *pos) { fpos_t t; t = *pos; success = __infer_nondet_int(); - if(success) return 0; - else return -1; + if (success) + return 0; + else + return -1; } // return a value between 0 and nmemb -size_t fread(void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream) { +size_t fread(void* __restrict ptr, + size_t size, + size_t nmemb, + FILE* __restrict stream) { size_t res; res = __infer_nondet_size_t(); - if(size == 0 || nmemb == 0) return 0; + if (size == 0 || nmemb == 0) + return 0; INFER_EXCLUDE_CONDITION(res < 0 || res > nmemb); return res; } // return a value between 0 and nmemb -size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream) { +size_t fwrite(const void* __restrict ptr, + size_t size, + size_t nmemb, + FILE* __restrict stream) { size_t res; res = __infer_nondet_size_t(); - if(size == 0 || nmemb == 0) return 0; + if (size == 0 || nmemb == 0) + return 0; INFER_EXCLUDE_CONDITION(res < 0 || res > nmemb); return res; } -size_t strcspn(const char *s1, const char *s2){ +size_t strcspn(const char* s1, const char* s2) { int size1, size2; size1 = __get_array_size(s1); - size2 = __get_array_size(s2);; + size2 = __get_array_size(s2); + ; int ret = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(ret < 0); @@ -1636,15 +1674,15 @@ size_t strcspn(const char *s1, const char *s2){ // There is non-standard version of strerr_r: // http://linux.die.net/man/3/strerror_r // It's not modelled right now -# if defined __APPLE__ || (defined __USE_XOPEN2K && !defined __USE_GNU) -int strerror_r(int errnum, char *strerrbuf, size_t buflen) { +#if defined __APPLE__ || (defined __USE_XOPEN2K && !defined __USE_GNU) +int strerror_r(int errnum, char* strerrbuf, size_t buflen) { INFER_EXCLUDE_CONDITION(__get_array_size(strerrbuf) < buflen); return __infer_nondet_int(); } #endif -ssize_t write(int fildes, const void *buf, size_t nbyte) { +ssize_t write(int fildes, const void* buf, size_t nbyte) { INFER_EXCLUDE_CONDITION(__get_array_size(buf) < nbyte); int ret = __infer_nondet_int(); @@ -1652,7 +1690,7 @@ ssize_t write(int fildes, const void *buf, size_t nbyte) { return ret; } -int creat(const char *path, mode_t mode) { +int creat(const char* path, mode_t mode) { int size; size = __get_array_size(path); @@ -1662,35 +1700,42 @@ int creat(const char *path, mode_t mode) { } // modeled as skip -int fcntl(int fildes, int cmd, ...){ +int fcntl(int fildes, int cmd, ...) { int ret = __infer_nondet_int(); return ret; } // modelled as skip -int sigprocmask(int how, const sigset_t *set, sigset_t *oset){ +int sigprocmask(int how, const sigset_t* set, sigset_t* oset) { int ret = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(ret < -1 || 0 < ret); return ret; } // modelled as skip -void setbuf(FILE * __restrict stream, char * __restrict buf) { -} +void setbuf(FILE* __restrict stream, char* __restrict buf) {} // return nondeterministically 0 or EOF -int setvbuf(FILE * __restrict stream, char * __restrict buf, int mode, size_t size) { +int setvbuf(FILE* __restrict stream, + char* __restrict buf, + int mode, + size_t size) { int n; n = __infer_nondet_int(); - if (n) return 0; - else return EOF; + if (n) + return 0; + else + return EOF; } // the array base must be allocated with at least nmemb elements // nondeterministically return 0 or a pointer inside the array -void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) -{ +void* bsearch(const void* key, + const void* base, + size_t nmemb, + size_t size, + int (*compar)(const void*, const void*)) { int base_size; int nondet; int offset; @@ -1699,64 +1744,61 @@ void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int base_size = __get_array_size(base); INFER_EXCLUDE_CONDITION(nmemb > base_size); - if(nondet) return 0; + if (nondet) + return 0; INFER_EXCLUDE_CONDITION(offset < 0 || offset >= nmemb); return (char*)base + offset; } // return a nondeterministic value -int mblen(const char *s, size_t n) { - return __infer_nondet_int(); -} +int mblen(const char* s, size_t n) { return __infer_nondet_int(); } // return a nondeterministic value -size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n) { +size_t mbstowcs(wchar_t* __restrict pwcs, const char* __restrict s, size_t n) { return (size_t)__infer_nondet_int(); } // return a nondeterministic value -int mbtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n) { +int mbtowc(wchar_t* __restrict pwc, const char* __restrict s, size_t n) { return __infer_nondet_int(); } // modeled as skip -void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { -} +void qsort(void* base, + size_t nmemb, + size_t size, + int (*compar)(const void*, const void*)) {} // return a nondeterministic value -int strcoll(const char *s1, const char *s2) { - return __infer_nondet_int(); -} +int strcoll(const char* s1, const char* s2) { return __infer_nondet_int(); } // return a nondeterministic value -size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n) { +size_t wcstombs(char* __restrict s, const wchar_t* __restrict pwcs, size_t n) { return (size_t)__infer_nondet_int(); } // return a nondeterministic value -int wctomb(char *s, wchar_t wc) { - return __infer_nondet_int(); -} +int wctomb(char* s, wchar_t wc) { return __infer_nondet_int(); } // modeled like open int socket(int namespace_, int style, int protocol) { - int *ret = (int*)malloc(sizeof(int)); - if(ret) { + int* ret = (int*)malloc(sizeof(int)); + if (ret) { __set_file_attribute(ret); - INFER_EXCLUDE_CONDITION(ret < (int *)1); // force result to be > 0 + INFER_EXCLUDE_CONDITION(ret < (int*)1); // force result to be > 0 return (size_t)ret; } return -1; } -void *xcalloc(size_t nmemb, size_t size) { - void *ret = calloc(nmemb, size); +void* xcalloc(size_t nmemb, size_t size) { + void* ret = calloc(nmemb, size); INFER_EXCLUDE_CONDITION(ret == NULL); return ret; } -void *xmalloc(size_t size) { - void *ret = malloc(size); +void* xmalloc(size_t size) { + void* ret = malloc(size); INFER_EXCLUDE_CONDITION(ret == NULL); return ret; } diff --git a/infer/models/c/src/math.c b/infer/models/c/src/math.c index fb0a6894d..3b6951f66 100644 --- a/infer/models/c/src/math.c +++ b/infer/models/c/src/math.c @@ -14,854 +14,392 @@ #include -double acos(double x) -{ - return __infer_nondet_double(); -} +double acos(double x) { return __infer_nondet_double(); } -float acosf(float x) -{ - return __infer_nondet_float(); -} +float acosf(float x) { return __infer_nondet_float(); } -long double acosl(long double x) -{ - return __infer_nondet_long_double(); -} +long double acosl(long double x) { return __infer_nondet_long_double(); } -double acosh(double x) -{ - return __infer_nondet_double(); -} +double acosh(double x) { return __infer_nondet_double(); } -float acoshf(float x) -{ - return __infer_nondet_float(); -} +float acoshf(float x) { return __infer_nondet_float(); } -long double acoshl(long double x) -{ - return __infer_nondet_long_double(); -} +long double acoshl(long double x) { return __infer_nondet_long_double(); } -double asin(double x) -{ - return __infer_nondet_double(); -} +double asin(double x) { return __infer_nondet_double(); } -float asinf(float x) -{ - return __infer_nondet_float(); -} +float asinf(float x) { return __infer_nondet_float(); } -long double asinl(long double x) -{ - return __infer_nondet_long_double(); -} +long double asinl(long double x) { return __infer_nondet_long_double(); } -double asinh(double x) -{ - return __infer_nondet_double(); -} +double asinh(double x) { return __infer_nondet_double(); } -float asinhf(float x) -{ - return __infer_nondet_float(); -} +float asinhf(float x) { return __infer_nondet_float(); } -long double asinhl(long double x) -{ - return __infer_nondet_long_double(); -} +long double asinhl(long double x) { return __infer_nondet_long_double(); } -double atan(double x) -{ - return __infer_nondet_double(); -} +double atan(double x) { return __infer_nondet_double(); } -float atanf(float x) -{ - return __infer_nondet_float(); -} +float atanf(float x) { return __infer_nondet_float(); } -long double atanl(long double x) -{ - return __infer_nondet_long_double(); -} +long double atanl(long double x) { return __infer_nondet_long_double(); } -double atanh(double x) -{ - return __infer_nondet_double(); -} +double atanh(double x) { return __infer_nondet_double(); } -float atanhf(float x) -{ - return __infer_nondet_float(); -} +float atanhf(float x) { return __infer_nondet_float(); } -long double atanhl(long double x) -{ - return __infer_nondet_long_double(); -} +long double atanhl(long double x) { return __infer_nondet_long_double(); } -double atan2(double y, double x) -{ - return __infer_nondet_double(); -} +double atan2(double y, double x) { return __infer_nondet_double(); } -float atan2f(float y, float x) -{ - return __infer_nondet_float(); -} +float atan2f(float y, float x) { return __infer_nondet_float(); } -long double atan2l(long double y, long double x) -{ +long double atan2l(long double y, long double x) { return __infer_nondet_long_double(); } -double cbrt(double x) -{ - return __infer_nondet_double(); -} +double cbrt(double x) { return __infer_nondet_double(); } -float cbrtf(float x) -{ - return __infer_nondet_float(); -} +float cbrtf(float x) { return __infer_nondet_float(); } -long double cbrtl(long double x) -{ - return __infer_nondet_long_double(); -} +long double cbrtl(long double x) { return __infer_nondet_long_double(); } -double ceil(double x) -{ - return __infer_nondet_double(); -} +double ceil(double x) { return __infer_nondet_double(); } -float ceilf(float x) -{ - return __infer_nondet_float(); -} +float ceilf(float x) { return __infer_nondet_float(); } -long double ceill(long double x) -{ - return __infer_nondet_long_double(); -} +long double ceill(long double x) { return __infer_nondet_long_double(); } -double copysign(double x, double y) -{ - return __infer_nondet_double(); -} +double copysign(double x, double y) { return __infer_nondet_double(); } -float copysignf(float x, float y) -{ - return __infer_nondet_float(); -} +float copysignf(float x, float y) { return __infer_nondet_float(); } -long double copysignl(long double x, long double y) -{ +long double copysignl(long double x, long double y) { return __infer_nondet_long_double(); } -double cos(double x) -{ - return __infer_nondet_double(); -} +double cos(double x) { return __infer_nondet_double(); } -float cosf(float x) -{ - return __infer_nondet_float(); -} +float cosf(float x) { return __infer_nondet_float(); } -long double cosl(long double x) -{ - return __infer_nondet_long_double(); -} +long double cosl(long double x) { return __infer_nondet_long_double(); } -double cosh(double x) -{ - return __infer_nondet_double(); -} +double cosh(double x) { return __infer_nondet_double(); } -float coshf(float x) -{ - return __infer_nondet_float(); -} +float coshf(float x) { return __infer_nondet_float(); } -long double coshl(long double x) -{ - return __infer_nondet_long_double(); -} +long double coshl(long double x) { return __infer_nondet_long_double(); } -double exp(double x) -{ - return __infer_nondet_double(); -} +double exp(double x) { return __infer_nondet_double(); } -float expf(float x) -{ - return __infer_nondet_float(); -} +float expf(float x) { return __infer_nondet_float(); } -long double expl(long double x) -{ - return __infer_nondet_long_double(); -} +long double expl(long double x) { return __infer_nondet_long_double(); } -double exp2(double x) -{ - return __infer_nondet_double(); -} +double exp2(double x) { return __infer_nondet_double(); } -float exp2f(float x) -{ - return __infer_nondet_float(); -} +float exp2f(float x) { return __infer_nondet_float(); } -long double exp2l(long double x) -{ - return __infer_nondet_long_double(); -} +long double exp2l(long double x) { return __infer_nondet_long_double(); } -double expm1(double x) -{ - return __infer_nondet_double(); -} +double expm1(double x) { return __infer_nondet_double(); } -float expm1f(float x) -{ - return __infer_nondet_float(); -} +float expm1f(float x) { return __infer_nondet_float(); } -long double expm1l(long double x) -{ - return __infer_nondet_long_double(); -} +long double expm1l(long double x) { return __infer_nondet_long_double(); } -double erf(double x) -{ - return __infer_nondet_double(); -} +double erf(double x) { return __infer_nondet_double(); } -float erff(float x) -{ - return __infer_nondet_float(); -} +float erff(float x) { return __infer_nondet_float(); } -long double erfl(long double x) -{ - return __infer_nondet_long_double(); -} +long double erfl(long double x) { return __infer_nondet_long_double(); } -double erfc(double x) -{ - return __infer_nondet_double(); -} +double erfc(double x) { return __infer_nondet_double(); } -float erfcf(float x) -{ - return __infer_nondet_float(); -} +float erfcf(float x) { return __infer_nondet_float(); } -long double erfcl(long double x) -{ - return __infer_nondet_long_double(); -} +long double erfcl(long double x) { return __infer_nondet_long_double(); } -double fabs(double x) -{ - return __infer_nondet_double(); -} +double fabs(double x) { return __infer_nondet_double(); } -float fabsf(float x) -{ - return __infer_nondet_float(); -} +float fabsf(float x) { return __infer_nondet_float(); } -long double fabsl(long double x) -{ - return __infer_nondet_long_double(); -} +long double fabsl(long double x) { return __infer_nondet_long_double(); } -double fdim(double x, double y) -{ - return __infer_nondet_double(); -} +double fdim(double x, double y) { return __infer_nondet_double(); } -float fdimf(float x, float y) -{ - return __infer_nondet_float(); -} +float fdimf(float x, float y) { return __infer_nondet_float(); } -long double fdiml(long double x, long double y) -{ +long double fdiml(long double x, long double y) { return __infer_nondet_long_double(); } -double floor(double x) -{ - return __infer_nondet_double(); -} +double floor(double x) { return __infer_nondet_double(); } -float floorf(float x) -{ - return __infer_nondet_float(); -} +float floorf(float x) { return __infer_nondet_float(); } -long double floorl(long double x) -{ - return __infer_nondet_long_double(); -} +long double floorl(long double x) { return __infer_nondet_long_double(); } -double fma(double x, double y, double z) -{ - return __infer_nondet_double(); -} +double fma(double x, double y, double z) { return __infer_nondet_double(); } -float fmaf(float x, float y, float z) -{ - return __infer_nondet_float(); -} +float fmaf(float x, float y, float z) { return __infer_nondet_float(); } -long double fmal(long double x, long double y,long double z) -{ +long double fmal(long double x, long double y, long double z) { return __infer_nondet_long_double(); } -double fmax(double x, double y) -{ - return __infer_nondet_double(); -} +double fmax(double x, double y) { return __infer_nondet_double(); } -float fmaxf(float x, float y) -{ - return __infer_nondet_float(); -} +float fmaxf(float x, float y) { return __infer_nondet_float(); } -long double fmaxl(long double x, long double y) -{ +long double fmaxl(long double x, long double y) { return __infer_nondet_long_double(); } -double fmin(double x, double y) -{ - return __infer_nondet_double(); -} +double fmin(double x, double y) { return __infer_nondet_double(); } -float fminf(float x, float y) -{ - return __infer_nondet_float(); -} +float fminf(float x, float y) { return __infer_nondet_float(); } -long double fminl(long double x, long double y) -{ +long double fminl(long double x, long double y) { return __infer_nondet_long_double(); } -double fmod(double x, double y) -{ - return __infer_nondet_double(); -} +double fmod(double x, double y) { return __infer_nondet_double(); } -float fmodf(float x, float y) -{ - return __infer_nondet_float(); -} +float fmodf(float x, float y) { return __infer_nondet_float(); } -long double fmodl(long double x, long double y) -{ +long double fmodl(long double x, long double y) { return __infer_nondet_long_double(); } -double frexp(double value, int *exp) -{ +double frexp(double value, int* exp) { *exp = __infer_nondet_int(); return __infer_nondet_double(); } -float frexpf(float value, int *exp) -{ +float frexpf(float value, int* exp) { *exp = __infer_nondet_int(); return __infer_nondet_float(); } -long double frexpl(long double value, int *exp) -{ +long double frexpl(long double value, int* exp) { *exp = __infer_nondet_int(); return __infer_nondet_long_double(); } -double hypot(double x, double y) -{ - return __infer_nondet_double(); -} +double hypot(double x, double y) { return __infer_nondet_double(); } -float hypotf(float x, float y) -{ - return __infer_nondet_float(); -} +float hypotf(float x, float y) { return __infer_nondet_float(); } -long double hypotl(long double x, long double y) -{ +long double hypotl(long double x, long double y) { return __infer_nondet_long_double(); } -int ilogb(double x) -{ - return __infer_nondet_int(); -} +int ilogb(double x) { return __infer_nondet_int(); } -int ilogbf(float x) -{ - return __infer_nondet_int(); -} +int ilogbf(float x) { return __infer_nondet_int(); } -int ilogbl(long double x) -{ - return __infer_nondet_int(); -} +int ilogbl(long double x) { return __infer_nondet_int(); } -double ldexp(double x, int exp) -{ - return __infer_nondet_double(); -} +double ldexp(double x, int exp) { return __infer_nondet_double(); } -float ldexpf(float x, int exp) -{ - return __infer_nondet_float(); -} +float ldexpf(float x, int exp) { return __infer_nondet_float(); } -long double ldexpl(long double x, int exp) -{ +long double ldexpl(long double x, int exp) { return __infer_nondet_long_double(); } -double lgamma(double x) -{ - return __infer_nondet_double(); -} +double lgamma(double x) { return __infer_nondet_double(); } -float lgammaf(float x) -{ - return __infer_nondet_float(); -} +float lgammaf(float x) { return __infer_nondet_float(); } -long double lgammal(long double x) -{ - return __infer_nondet_long_double(); -} +long double lgammal(long double x) { return __infer_nondet_long_double(); } -double log(double x) -{ - return __infer_nondet_double(); -} +double log(double x) { return __infer_nondet_double(); } -float logf(float x) -{ - return __infer_nondet_float(); -} +float logf(float x) { return __infer_nondet_float(); } -long double logl(long double x) -{ - return __infer_nondet_long_double(); -} +long double logl(long double x) { return __infer_nondet_long_double(); } -double log10(double x) -{ - return __infer_nondet_double(); -} +double log10(double x) { return __infer_nondet_double(); } -float log10f(float x) -{ - return __infer_nondet_float(); -} +float log10f(float x) { return __infer_nondet_float(); } -long double log10l(long double x) -{ - return __infer_nondet_long_double(); -} +long double log10l(long double x) { return __infer_nondet_long_double(); } -double log1p(double x) -{ - return __infer_nondet_double(); -} +double log1p(double x) { return __infer_nondet_double(); } -float log1pf(float x) -{ - return __infer_nondet_float(); -} +float log1pf(float x) { return __infer_nondet_float(); } -long double log1pl(long double x) -{ - return __infer_nondet_long_double(); -} +long double log1pl(long double x) { return __infer_nondet_long_double(); } #ifdef log2 #undef log2 // disable expansion of log2 #endif -double log2(double x) -{ - return __infer_nondet_double(); -} +double log2(double x) { return __infer_nondet_double(); } #ifdef log2f #undef log2f // disable expansion of log2f #endif -float log2f(float x) -{ - return __infer_nondet_float(); -} +float log2f(float x) { return __infer_nondet_float(); } -long double log2l(long double x) -{ - return __infer_nondet_long_double(); -} +long double log2l(long double x) { return __infer_nondet_long_double(); } -double logb(double x) -{ - return __infer_nondet_double(); -} +double logb(double x) { return __infer_nondet_double(); } -float logbf(float x) -{ - return __infer_nondet_float(); -} +float logbf(float x) { return __infer_nondet_float(); } -long double logbl(long double x) -{ - return __infer_nondet_long_double(); -} +long double logbl(long double x) { return __infer_nondet_long_double(); } -long int lrint(double x) -{ - return __infer_nondet_long_int(); -} +long int lrint(double x) { return __infer_nondet_long_int(); } -long int lrintf(float x) -{ - return __infer_nondet_long_int(); -} +long int lrintf(float x) { return __infer_nondet_long_int(); } -long int lrintl(long double x) -{ - return __infer_nondet_long_int(); -} +long int lrintl(long double x) { return __infer_nondet_long_int(); } -long long int llrint(double x) -{ - return __infer_nondet_long_long_int(); -} +long long int llrint(double x) { return __infer_nondet_long_long_int(); } -long long int llrintf(float x) -{ - return __infer_nondet_long_long_int(); -} +long long int llrintf(float x) { return __infer_nondet_long_long_int(); } -long long int llrintl(long double x) -{ - return __infer_nondet_long_long_int(); -} +long long int llrintl(long double x) { return __infer_nondet_long_long_int(); } -long int lround(double x) -{ - return __infer_nondet_long_int(); -} +long int lround(double x) { return __infer_nondet_long_int(); } -long int lroundf(float x) -{ - return __infer_nondet_long_int(); -} +long int lroundf(float x) { return __infer_nondet_long_int(); } -long int lroundl(long double x) -{ - return __infer_nondet_long_int(); -} +long int lroundl(long double x) { return __infer_nondet_long_int(); } -long long int llround(double x) -{ - return __infer_nondet_long_long_int(); -} +long long int llround(double x) { return __infer_nondet_long_long_int(); } -long long int llroundf(float x) -{ - return __infer_nondet_long_long_int(); -} +long long int llroundf(float x) { return __infer_nondet_long_long_int(); } -long long int llroundl(long double x) -{ - return __infer_nondet_long_long_int(); -} +long long int llroundl(long double x) { return __infer_nondet_long_long_int(); } -double modf(double value, double *iptr) -{ +double modf(double value, double* iptr) { *iptr = __infer_nondet_double(); return __infer_nondet_double(); } -float modff(float value, float *iptr) -{ +float modff(float value, float* iptr) { *iptr = __infer_nondet_float(); return __infer_nondet_float(); } -long double modfl(long double value, long double *iptr) -{ +long double modfl(long double value, long double* iptr) { *iptr = __infer_nondet_long_double(); return __infer_nondet_long_double(); } -double nearbyint(double x) -{ - return __infer_nondet_double(); -} +double nearbyint(double x) { return __infer_nondet_double(); } -double nan(const char *tagp) -{ - return __infer_nondet_double(); -} +double nan(const char* tagp) { return __infer_nondet_double(); } -float nanf(const char *tagp) -{ - return __infer_nondet_float(); -} +float nanf(const char* tagp) { return __infer_nondet_float(); } -long double nanl(const char *tagp) -{ - return __infer_nondet_long_double(); -} +long double nanl(const char* tagp) { return __infer_nondet_long_double(); } -float nearbyintf(float x) -{ - return __infer_nondet_float(); -} +float nearbyintf(float x) { return __infer_nondet_float(); } -long double nearbyintl(long double x) -{ - return __infer_nondet_long_double(); -} +long double nearbyintl(long double x) { return __infer_nondet_long_double(); } -double nextafter(double x, double y) -{ - return __infer_nondet_double(); -} +double nextafter(double x, double y) { return __infer_nondet_double(); } -float nextafterf(float x, float y) -{ - return __infer_nondet_float(); -} +float nextafterf(float x, float y) { return __infer_nondet_float(); } -long double nextafterl(long double x, long double y) -{ +long double nextafterl(long double x, long double y) { return __infer_nondet_long_double(); } -double nexttoward(double x, long double y) -{ - return __infer_nondet_double(); -} +double nexttoward(double x, long double y) { return __infer_nondet_double(); } -float nexttowardf(float x, long double y) -{ - return __infer_nondet_float(); -} +float nexttowardf(float x, long double y) { return __infer_nondet_float(); } -long double nexttowardl(long double x, long double y) -{ +long double nexttowardl(long double x, long double y) { return __infer_nondet_long_double(); } -double pow(double x, double y) -{ - return __infer_nondet_double(); -} +double pow(double x, double y) { return __infer_nondet_double(); } -float powf(float x, float y) -{ - return __infer_nondet_float(); -} +float powf(float x, float y) { return __infer_nondet_float(); } -long double powl(long double x, long double y) -{ +long double powl(long double x, long double y) { return __infer_nondet_long_double(); } -double rint(double x) -{ - return __infer_nondet_double(); -} +double rint(double x) { return __infer_nondet_double(); } -float rintf(float x) -{ - return __infer_nondet_float(); -} +float rintf(float x) { return __infer_nondet_float(); } -long double rintl(long double x) -{ - return __infer_nondet_long_double(); -} +long double rintl(long double x) { return __infer_nondet_long_double(); } -double remainder(double x, double y) -{ - return __infer_nondet_double(); -} +double remainder(double x, double y) { return __infer_nondet_double(); } -float remainderf(float x, float y) -{ - return __infer_nondet_float(); -} +float remainderf(float x, float y) { return __infer_nondet_float(); } -long double remainderl(long double x, long double y) -{ +long double remainderl(long double x, long double y) { return __infer_nondet_long_double(); } -double round(double x) -{ - return __infer_nondet_double(); -} +double round(double x) { return __infer_nondet_double(); } -float roundf(float x) -{ - return __infer_nondet_float(); -} +float roundf(float x) { return __infer_nondet_float(); } -long double roundl(long double x) -{ - return __infer_nondet_long_double(); -} +long double roundl(long double x) { return __infer_nondet_long_double(); } -double scalbn(double x, int n) -{ - return __infer_nondet_double(); -} +double scalbn(double x, int n) { return __infer_nondet_double(); } -float scalbnf(float x, int n) -{ - return __infer_nondet_float(); -} +float scalbnf(float x, int n) { return __infer_nondet_float(); } -long double scalbnl(long double x, int n) -{ +long double scalbnl(long double x, int n) { return __infer_nondet_long_double(); } -double scalbln(double x, long int n) -{ - return __infer_nondet_double(); -} +double scalbln(double x, long int n) { return __infer_nondet_double(); } -float scalblnf(float x, long int n) -{ - return __infer_nondet_float(); -} +float scalblnf(float x, long int n) { return __infer_nondet_float(); } -long double scalblnl(long double x, long int n) -{ +long double scalblnl(long double x, long int n) { return __infer_nondet_long_double(); } -double sin(double x) -{ - return __infer_nondet_double(); -} +double sin(double x) { return __infer_nondet_double(); } -float sinf(float x) -{ - return __infer_nondet_float(); -} +float sinf(float x) { return __infer_nondet_float(); } -long double sinl(long double x) -{ - return __infer_nondet_long_double(); -} +long double sinl(long double x) { return __infer_nondet_long_double(); } -double sinh(double x) -{ - return __infer_nondet_double(); -} +double sinh(double x) { return __infer_nondet_double(); } -float sinhf(float x) -{ - return __infer_nondet_float(); -} +float sinhf(float x) { return __infer_nondet_float(); } -long double sinhl(long double x) -{ - return __infer_nondet_long_double(); -} +long double sinhl(long double x) { return __infer_nondet_long_double(); } -double sqrt(double x) -{ - return __infer_nondet_double(); -} +double sqrt(double x) { return __infer_nondet_double(); } -float sqrtf(float x) -{ - return __infer_nondet_float(); -} +float sqrtf(float x) { return __infer_nondet_float(); } -long double sqrtl(long double x) -{ - return __infer_nondet_long_double(); -} +long double sqrtl(long double x) { return __infer_nondet_long_double(); } -double tan(double x) -{ - return __infer_nondet_double(); -} +double tan(double x) { return __infer_nondet_double(); } -float tanf(float x) -{ - return __infer_nondet_float(); -} +float tanf(float x) { return __infer_nondet_float(); } -long double tanl(long double x) -{ - return __infer_nondet_long_double(); -} +long double tanl(long double x) { return __infer_nondet_long_double(); } -double tanh(double x) -{ - return __infer_nondet_double(); -} +double tanh(double x) { return __infer_nondet_double(); } -float tanhf(float x) -{ - return __infer_nondet_float(); -} +float tanhf(float x) { return __infer_nondet_float(); } -long double tanhl(long double x) -{ - return __infer_nondet_long_double(); -} +long double tanhl(long double x) { return __infer_nondet_long_double(); } -double tgamma(double x) -{ - return __infer_nondet_double(); -} +double tgamma(double x) { return __infer_nondet_double(); } -float tgammaf(float x) -{ - return __infer_nondet_float(); -} +float tgammaf(float x) { return __infer_nondet_float(); } -long double tgammal(long double x) -{ - return __infer_nondet_long_double(); -} +long double tgammal(long double x) { return __infer_nondet_long_double(); } -double trunc(double x) -{ - return __infer_nondet_double(); -} +double trunc(double x) { return __infer_nondet_double(); } -float truncf(float x) -{ - return __infer_nondet_float(); -} +float truncf(float x) { return __infer_nondet_float(); } -long double truncl(long double x) -{ - return __infer_nondet_long_double(); -} +long double truncl(long double x) { return __infer_nondet_long_double(); } diff --git a/infer/models/c/src/wchar.c b/infer/models/c/src/wchar.c index 6d5034360..ebb8c32d2 100644 --- a/infer/models/c/src/wchar.c +++ b/infer/models/c/src/wchar.c @@ -19,126 +19,112 @@ #define USE_CPP_OVERLOADS #endif -#include #include +#include #include #include #define restrict - #ifdef _WIN32 #define CLIBCALL __cdecl #else #define CLIBCALL #endif -int CLIBCALL fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...); // builtin: modeled internally -int CLIBCALL swscanf(const wchar_t * restrict s, const wchar_t * restrict format, ...); // builtin: modeled internally -int CLIBCALL vfwscanf(FILE * restrict stream, const wchar_t * restrict format, va_list arg); // builtin: modeled internally -int CLIBCALL vswscanf(const wchar_t * restrict s, const wchar_t * restrict format, va_list arg); // builtin: modeled internally -int CLIBCALL vwscanf(const wchar_t * restrict format, va_list arg); // builtin: modeled internally -int CLIBCALL wscanf(const wchar_t * restrict format, ...); // builtin: modeled internally - - -wint_t CLIBCALL btowc(int c) -{ - return __infer_nondet_int(); -} - -wint_t CLIBCALL fgetwc(FILE *stream) -{ - return __infer_nondet_int(); -} +int CLIBCALL fwscanf(FILE* restrict stream, + const wchar_t* restrict format, + ...); // builtin: modeled internally +int CLIBCALL swscanf(const wchar_t* restrict s, + const wchar_t* restrict format, + ...); // builtin: modeled internally +int CLIBCALL vfwscanf(FILE* restrict stream, + const wchar_t* restrict format, + va_list arg); // builtin: modeled internally +int CLIBCALL vswscanf(const wchar_t* restrict s, + const wchar_t* restrict format, + va_list arg); // builtin: modeled internally +int CLIBCALL vwscanf(const wchar_t* restrict format, + va_list arg); // builtin: modeled internally +int CLIBCALL wscanf(const wchar_t* restrict format, + ...); // builtin: modeled internally + +wint_t CLIBCALL btowc(int c) { return __infer_nondet_int(); } + +wint_t CLIBCALL fgetwc(FILE* stream) { return __infer_nondet_int(); } // modelled like fgets -wchar_t * CLIBCALL fgetws(wchar_t * restrict s, int n, FILE * restrict stream) -{ - return (wchar_t *) fgets((char *)s, n, stream); +wchar_t* CLIBCALL fgetws(wchar_t* restrict s, int n, FILE* restrict stream) { + return (wchar_t*)fgets((char*)s, n, stream); } -wint_t CLIBCALL fputwc(wchar_t c, FILE *stream) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL fputwc(wchar_t c, FILE* stream) { return __infer_nondet_int(); } // modeled using fputs -int CLIBCALL fputws(const wchar_t * restrict s, FILE * restrict stream) -{ - return fputs((char *)s, stream); +int CLIBCALL fputws(const wchar_t* restrict s, FILE* restrict stream) { + return fputs((char*)s, stream); } -int CLIBCALL fwide(FILE *stream, int mode) -{ - return __infer_nondet_int(); -} +int CLIBCALL fwide(FILE* stream, int mode) { return __infer_nondet_int(); } // return a nondeterministic nonnegative integer -int CLIBCALL fwprintf(FILE * restrict stream, const wchar_t * restrict format, ...) -{ +int CLIBCALL fwprintf(FILE* restrict stream, + const wchar_t* restrict format, + ...) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); return res; } - #ifdef getwc #undef getwc // disable expansion of getwc #endif -wint_t CLIBCALL getwc(FILE *stream) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL getwc(FILE* stream) { return __infer_nondet_int(); } #ifdef getwchar #undef getwchar // disable expansion of getwchar #endif -wint_t CLIBCALL getwchar() -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL getwchar() { return __infer_nondet_int(); } -size_t CLIBCALL mbrlen(const char * restrict s, size_t n, mbstate_t * restrict ps) -{ +size_t CLIBCALL mbrlen(const char* restrict s, + size_t n, + mbstate_t* restrict ps) { return __infer_nondet_int(); } -size_t CLIBCALL mbrtowc(wchar_t * restrict pwc, const char * restrict s, size_t n, mbstate_t * restrict ps) -{ +size_t CLIBCALL mbrtowc(wchar_t* restrict pwc, + const char* restrict s, + size_t n, + mbstate_t* restrict ps) { return __infer_nondet_int(); } -int CLIBCALL mbsinit(const mbstate_t *ps) -{ - return __infer_nondet_int(); -} +int CLIBCALL mbsinit(const mbstate_t* ps) { return __infer_nondet_int(); } -size_t CLIBCALL mbsrtowcs(wchar_t * restrict dst, const char ** restrict src, size_t len, mbstate_t * restrict ps) -{ +size_t CLIBCALL mbsrtowcs(wchar_t* restrict dst, + const char** restrict src, + size_t len, + mbstate_t* restrict ps) { return __infer_nondet_int(); } #ifdef putwc #undef putwc // disable expansion of putwc #endif -wint_t CLIBCALL putwc(wchar_t c, FILE *stream) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL putwc(wchar_t c, FILE* stream) { return __infer_nondet_int(); } #ifdef putwchar #undef putwchar // disable expansion of putwchar #endif -wint_t CLIBCALL putwchar(wchar_t c) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL putwchar(wchar_t c) { return __infer_nondet_int(); } // s must be allocated // return a nondeterministic nonnegative integer -int CLIBCALL swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, ...) -{ +int CLIBCALL swprintf(wchar_t* restrict s, + size_t n, + const wchar_t* restrict format, + ...) { int res; int size1; size1 = __get_array_size(s); @@ -147,14 +133,12 @@ int CLIBCALL swprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict f return res; } -wint_t CLIBCALL ungetwc(wint_t c, FILE *stream) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL ungetwc(wint_t c, FILE* stream) { return __infer_nondet_int(); } // return a nondeterministic nonnegative integer -int CLIBCALL vfwprintf(FILE * restrict stream, const wchar_t * restrict format, va_list arg) -{ +int CLIBCALL vfwprintf(FILE* restrict stream, + const wchar_t* restrict format, + va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -162,8 +146,10 @@ int CLIBCALL vfwprintf(FILE * restrict stream, const wchar_t * restrict format, } // return a nondeterministic nonnegative integer -int CLIBCALL vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict format, va_list arg) -{ +int CLIBCALL vswprintf(wchar_t* restrict s, + size_t n, + const wchar_t* restrict format, + va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -171,27 +157,26 @@ int CLIBCALL vswprintf(wchar_t * restrict s, size_t n, const wchar_t * restrict } // return a nondeterministic nonnegative integer -int CLIBCALL vwprintf(const wchar_t * restrict format, va_list arg) -{ +int CLIBCALL vwprintf(const wchar_t* restrict format, va_list arg) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); return res; } -size_t CLIBCALL wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps) -{ +size_t CLIBCALL wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps) { return __infer_nondet_int(); } -size_t CLIBCALL wcsrtombs(char * restrict dst, const wchar_t ** restrict src, size_t len, mbstate_t * restrict ps) -{ +size_t CLIBCALL wcsrtombs(char* restrict dst, + const wchar_t** restrict src, + size_t len, + mbstate_t* restrict ps) { return __infer_nondet_int(); } // return a nondeterministic nonnegative integer -int CLIBCALL wprintf(const wchar_t * restrict format, ...) -{ +int CLIBCALL wprintf(const wchar_t* restrict format, ...) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -199,41 +184,39 @@ int CLIBCALL wprintf(const wchar_t * restrict format, ...) } // modeled using strcat -wchar_t * CLIBCALL wcscat(wchar_t * restrict s1, const wchar_t * restrict s2) -{ - return (wchar_t *) strcat((char *) s1, (char *) s2); +wchar_t* CLIBCALL wcscat(wchar_t* restrict s1, const wchar_t* restrict s2) { + return (wchar_t*)strcat((char*)s1, (char*)s2); } // modeled using strchr #ifndef USE_CPP_OVERLOADS -wchar_t * CLIBCALL wcschr(const wchar_t *s, wchar_t c) -# else -const wchar_t * CLIBCALL wcschr(const wchar_t *s, wchar_t c) -{ - return wcschr((wchar_t*) s, c); +wchar_t* CLIBCALL wcschr(const wchar_t* s, wchar_t c) +#else +const wchar_t* CLIBCALL wcschr(const wchar_t* s, wchar_t c) { + return wcschr((wchar_t*)s, c); } -wchar_t * CLIBCALL wcschr(wchar_t *s, wchar_t c) +wchar_t* CLIBCALL wcschr(wchar_t* s, wchar_t c) #endif { - return (wchar_t *) strchr((char *) s, c); + return (wchar_t*)strchr((char*)s, c); } // modeled using strcmp -int CLIBCALL wcscmp(const wchar_t *s1, const wchar_t *s2) -{ - return strcmp((char *) s1, (char *) s2); +int CLIBCALL wcscmp(const wchar_t* s1, const wchar_t* s2) { + return strcmp((char*)s1, (char*)s2); } // modeled using strcmp -int CLIBCALL wcscoll(const wchar_t *s1, const wchar_t *s2) -{ - return strcmp((char *) s1, (char *) s2); +int CLIBCALL wcscoll(const wchar_t* s1, const wchar_t* s2) { + return strcmp((char*)s1, (char*)s2); } // return a nondeterministic nonnegative integer -size_t CLIBCALL wcsftime(wchar_t * restrict s, size_t maxsize,const wchar_t * restrict format, const struct tm * restrict timeptr) -{ +size_t CLIBCALL wcsftime(wchar_t* restrict s, + size_t maxsize, + const wchar_t* restrict format, + const struct tm* restrict timeptr) { int res; res = __infer_nondet_int(); INFER_EXCLUDE_CONDITION(res < 0); @@ -241,178 +224,169 @@ size_t CLIBCALL wcsftime(wchar_t * restrict s, size_t maxsize,const wchar_t * re } // modeled using strcpy -wchar_t * CLIBCALL wcscpy(wchar_t * restrict s1, const wchar_t * restrict s2) -{ - return (wchar_t *) strcpy((char *) s1, (char *) s2); +wchar_t* CLIBCALL wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2) { + return (wchar_t*)strcpy((char*)s1, (char*)s2); } // modeled using strcmp -size_t CLIBCALL wcscspn(const wchar_t *s1, const wchar_t *s2) -{ - return strcmp((char *) s1, (char *) s2); +size_t CLIBCALL wcscspn(const wchar_t* s1, const wchar_t* s2) { + return strcmp((char*)s1, (char*)s2); } // modeled using strlen -size_t CLIBCALL wcslen(const wchar_t *s) -{ - return strlen((char *) s); -} +size_t CLIBCALL wcslen(const wchar_t* s) { return strlen((char*)s); } // modeled using strncat -wchar_t * CLIBCALL wcsncat(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) -{ - return (wchar_t *) strncat((char *) s1, (char *) s2, n); +wchar_t* CLIBCALL wcsncat(wchar_t* restrict s1, + const wchar_t* restrict s2, + size_t n) { + return (wchar_t*)strncat((char*)s1, (char*)s2, n); } // modeled using strncmp -int CLIBCALL wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - return strncmp((char *) s1, (char *) s2, n); +int CLIBCALL wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n) { + return strncmp((char*)s1, (char*)s2, n); } // modeled using strpbrk #ifndef USE_CPP_OVERLOADS -wchar_t * CLIBCALL wcspbrk(const wchar_t *s1, const wchar_t *s2) +wchar_t* CLIBCALL wcspbrk(const wchar_t* s1, const wchar_t* s2) #else -const wchar_t * CLIBCALL wcspbrk(const wchar_t *s1, const wchar_t *s2) -{ - return wcspbrk((wchar_t*) s1, s2); +const wchar_t* CLIBCALL wcspbrk(const wchar_t* s1, const wchar_t* s2) { + return wcspbrk((wchar_t*)s1, s2); } -wchar_t * CLIBCALL wcspbrk(wchar_t *s1, const wchar_t *s2) +wchar_t* CLIBCALL wcspbrk(wchar_t* s1, const wchar_t* s2) #endif { - return (wchar_t *) strpbrk((char *) s1, (char *) s2); + return (wchar_t*)strpbrk((char*)s1, (char*)s2); } // modeled using strchr #ifndef USE_CPP_OVERLOADS -wchar_t * CLIBCALL wcsrchr(const wchar_t *s, wchar_t c) +wchar_t* CLIBCALL wcsrchr(const wchar_t* s, wchar_t c) #else -const wchar_t * CLIBCALL wcsrchr(const wchar_t *s, wchar_t c) -{ - return wcsrchr((wchar_t*) s, c); +const wchar_t* CLIBCALL wcsrchr(const wchar_t* s, wchar_t c) { + return wcsrchr((wchar_t*)s, c); } -wchar_t * CLIBCALL wcsrchr(wchar_t *s, wchar_t c) +wchar_t* CLIBCALL wcsrchr(wchar_t* s, wchar_t c) #endif { - return (wchar_t *) strchr((char *) s, c); + return (wchar_t*)strchr((char*)s, c); } // modeled using strncpy -wchar_t * CLIBCALL wcsncpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) -{ - return (wchar_t *) strncpy((char *) s1, (char *) s2, n); +wchar_t* CLIBCALL wcsncpy(wchar_t* restrict s1, + const wchar_t* restrict s2, + size_t n) { + return (wchar_t*)strncpy((char*)s1, (char*)s2, n); } // modeled using strspn -size_t CLIBCALL wcsspn(const wchar_t *s1, const wchar_t *s2) -{ - return strspn((char *) s1, (char *) s2); +size_t CLIBCALL wcsspn(const wchar_t* s1, const wchar_t* s2) { + return strspn((char*)s1, (char*)s2); } // modeled using strstr #ifndef USE_CPP_OVERLOADS -wchar_t * CLIBCALL wcsstr(const wchar_t *s1, const wchar_t *s2) +wchar_t* CLIBCALL wcsstr(const wchar_t* s1, const wchar_t* s2) #else -const wchar_t * CLIBCALL wcsstr(const wchar_t *s1, const wchar_t *s2) -{ - return wcsstr((wchar_t*) s1, s2); +const wchar_t* CLIBCALL wcsstr(const wchar_t* s1, const wchar_t* s2) { + return wcsstr((wchar_t*)s1, s2); } -wchar_t * CLIBCALL wcsstr(wchar_t *s1, const wchar_t *s2) +wchar_t* CLIBCALL wcsstr(wchar_t* s1, const wchar_t* s2) #endif { - return (wchar_t *) strstr((char *) s1, (char *) s2); + return (wchar_t*)strstr((char*)s1, (char*)s2); } -int CLIBCALL wctob(wint_t c) -{ - return __infer_nondet_int(); -} +int CLIBCALL wctob(wint_t c) { return __infer_nondet_int(); } -double CLIBCALL wcstod(const wchar_t * restrict nptr, wchar_t ** restrict endptr) -{ +double CLIBCALL wcstod(const wchar_t* restrict nptr, + wchar_t** restrict endptr) { return __infer_nondet_double(); } -float CLIBCALL wcstof(const wchar_t * restrict nptr, wchar_t ** restrict endptr) -{ +float CLIBCALL wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr) { return __infer_nondet_float(); } // simplified modeling which returns s1 -wchar_t * CLIBCALL wcstok(wchar_t * restrict s1, const wchar_t * restrict s2, wchar_t ** restrict ptr) -{ +wchar_t* CLIBCALL wcstok(wchar_t* restrict s1, + const wchar_t* restrict s2, + wchar_t** restrict ptr) { return s1; } -long double CLIBCALL wcstold(const wchar_t * restrict nptr, wchar_t ** restrict endptr) -{ +long double CLIBCALL wcstold(const wchar_t* restrict nptr, + wchar_t** restrict endptr) { return __infer_nondet_long_double(); } -long int CLIBCALL wcstol(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) -{ +long int CLIBCALL wcstol(const wchar_t* restrict nptr, + wchar_t** restrict endptr, + int base) { return __infer_nondet_long_int(); } -long long int CLIBCALL wcstoll(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) -{ +long long int CLIBCALL wcstoll(const wchar_t* restrict nptr, + wchar_t** restrict endptr, + int base) { return __infer_nondet_long_long_int(); } -unsigned long int CLIBCALL wcstoul(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) -{ +unsigned long int CLIBCALL wcstoul(const wchar_t* restrict nptr, + wchar_t** restrict endptr, + int base) { return __infer_nondet_unsigned_long_int(); } -unsigned long long int CLIBCALL wcstoull(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base) -{ +unsigned long long int CLIBCALL wcstoull(const wchar_t* restrict nptr, + wchar_t** restrict endptr, + int base) { return __infer_nondet_long_long_int(); } // modeled using strncmp -size_t CLIBCALL wcsxfrm(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) -{ - return strncmp((char *) s1, (char *) s2, n); +size_t CLIBCALL wcsxfrm(wchar_t* restrict s1, + const wchar_t* restrict s2, + size_t n) { + return strncmp((char*)s1, (char*)s2, n); } // modeled using memchr #ifndef USE_CPP_OVERLOADS -wchar_t * CLIBCALL wmemchr(const wchar_t *s, wchar_t c, size_t n) +wchar_t* CLIBCALL wmemchr(const wchar_t* s, wchar_t c, size_t n) #else -const wchar_t * CLIBCALL wmemchr(const wchar_t *s, wchar_t c, size_t n) -{ - return wmemchr((wchar_t*) s, c, n); +const wchar_t* CLIBCALL wmemchr(const wchar_t* s, wchar_t c, size_t n) { + return wmemchr((wchar_t*)s, c, n); } -wchar_t * CLIBCALL wmemchr(wchar_t *s, wchar_t c, size_t n) +wchar_t* CLIBCALL wmemchr(wchar_t* s, wchar_t c, size_t n) #endif { - return (wchar_t *) memchr((char *) s, c, n); + return (wchar_t*)memchr((char*)s, c, n); } // modeled using memcmp -int CLIBCALL wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - return memcmp((char *) s1, (char *) s2, n); +int CLIBCALL wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n) { + return memcmp((char*)s1, (char*)s2, n); } // modeled using memcpy -wchar_t * CLIBCALL wmemcpy(wchar_t * restrict s1, const wchar_t * restrict s2, size_t n) -{ - return (wchar_t *) memcpy((char *) s1, (char *) s2, n); +wchar_t* CLIBCALL wmemcpy(wchar_t* restrict s1, + const wchar_t* restrict s2, + size_t n) { + return (wchar_t*)memcpy((char*)s1, (char*)s2, n); } // modeled using memmove -wchar_t * CLIBCALL wmemmove(wchar_t *s1, const wchar_t *s2, size_t n) -{ - return (wchar_t *) memmove((char *) s1, (char *) s2, n); +wchar_t* CLIBCALL wmemmove(wchar_t* s1, const wchar_t* s2, size_t n) { + return (wchar_t*)memmove((char*)s1, (char*)s2, n); } // modeled using memset -wchar_t * CLIBCALL wmemset(wchar_t *s, wchar_t c, size_t n) -{ - return (wchar_t *) memset((char *) s, c, n); +wchar_t* CLIBCALL wmemset(wchar_t* s, wchar_t c, size_t n) { + return (wchar_t*)memset((char*)s, c, n); } diff --git a/infer/models/c/src/wctype.c b/infer/models/c/src/wctype.c index 57c9b42de..071d0d540 100644 --- a/infer/models/c/src/wctype.c +++ b/infer/models/c/src/wctype.c @@ -23,105 +23,50 @@ #define CLIBCALL #endif - // Microsoft-specific -int CLIBCALL __iswcsymf(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL __iswcsymf(wint_t wc) { return __infer_nondet_int(); } // Microsoft-specific, inline -int CLIBCALL isleadbyte(int wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL isleadbyte(int wc) { return __infer_nondet_int(); } -int CLIBCALL iswalnum(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswalnum(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswalpha(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswalpha(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswblank(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswblank(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswcntrl(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswcntrl(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswctype(wint_t wc, wctype_t desc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswctype(wint_t wc, wctype_t desc) { return __infer_nondet_int(); } -int CLIBCALL iswdigit(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswdigit(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswgraph(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswgraph(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswlower(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswlower(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswprint(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswprint(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswpunct(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswpunct(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswspace(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswspace(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswupper(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswupper(wint_t wc) { return __infer_nondet_int(); } -int CLIBCALL iswxdigit(wint_t wc) -{ - return __infer_nondet_int(); -} +int CLIBCALL iswxdigit(wint_t wc) { return __infer_nondet_int(); } -wint_t CLIBCALL towlower(wint_t wc) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL towlower(wint_t wc) { return __infer_nondet_int(); } -wint_t CLIBCALL towctrans(wint_t wc, wctrans_t desc) -{ +wint_t CLIBCALL towctrans(wint_t wc, wctrans_t desc) { return __infer_nondet_int(); } -wint_t CLIBCALL towupper(wint_t wc) -{ - return __infer_nondet_int(); -} +wint_t CLIBCALL towupper(wint_t wc) { return __infer_nondet_int(); } -wctrans_t CLIBCALL wctrans(const char *property) -{ +wctrans_t CLIBCALL wctrans(const char* property) { return (wctrans_t)__infer_nondet_int(); } -wctype_t CLIBCALL wctype(const char *property) -{ +wctype_t CLIBCALL wctype(const char* property) { return (wctype_t)__infer_nondet_int(); } diff --git a/infer/models/c/src/xlib.c b/infer/models/c/src/xlib.c index 2c571bac0..0a4d66c97 100644 --- a/infer/models/c/src/xlib.c +++ b/infer/models/c/src/xlib.c @@ -15,14 +15,14 @@ #include // modelled using malloc -char *XGetAtomName(void *display, void *atom) { +char* XGetAtomName(void* display, void* atom) { int size; INFER_EXCLUDE_CONDITION(size <= 0); return (char*)malloc(size); } // modelled as free, requires NONNULL pointer -void XFree(void *ptr) { +void XFree(void* ptr) { INFER_EXCLUDE_CONDITION(!ptr); free(ptr); } diff --git a/infer/models/cpp/src/shared_ptr.cpp b/infer/models/cpp/src/shared_ptr.cpp index 44010b401..a918ce854 100644 --- a/infer/models/cpp/src/shared_ptr.cpp +++ b/infer/models/cpp/src/shared_ptr.cpp @@ -10,35 +10,32 @@ // models for shared_ptr -extern "C" void __method_set_ignore_attribute(void **self, void *arg); +extern "C" void __method_set_ignore_attribute(void** self, void* arg); // standard constructor -extern "C" void __infer_shared_ptr(void **self, void *arg) { +extern "C" void __infer_shared_ptr(void** self, void* arg) { __method_set_ignore_attribute(self, arg); // auto memory management *self = arg; } // constructor taking a reference to a shared_ptr -extern "C" void __infer_shared_ptr_ref(void **arg1, void **arg2) { +extern "C" void __infer_shared_ptr_ref(void** arg1, void** arg2) { *arg1 = *arg2; } // operator= -extern "C" void** __infer_shared_ptr_eq(void **arg1, void **arg2) { +extern "C" void** __infer_shared_ptr_eq(void** arg1, void** arg2) { *arg1 = *arg2; return arg1; } // operator== -extern "C" int __infer_shared_ptr_eqeq(void **arg1, void **arg2) { +extern "C" int __infer_shared_ptr_eqeq(void** arg1, void** arg2) { return (*arg1 == *arg2); } // operator-> -extern "C" void* __infer_shared_ptr_arrow(void **arg) { - return *arg; -} +extern "C" void* __infer_shared_ptr_arrow(void** arg) { return *arg; } // destructor -extern "C" void __infer_shared_ptr_destructor(void **arg) { -} +extern "C" void __infer_shared_ptr_destructor(void** arg) {} diff --git a/infer/models/objc/src/CADisplayLink.h b/infer/models/objc/src/CADisplayLink.h index 9ccef2010..cb3817379 100644 --- a/infer/models/objc/src/CADisplayLink.h +++ b/infer/models/objc/src/CADisplayLink.h @@ -12,7 +12,7 @@ @interface CADisplayLink : NSObject { id _target; - SEL _selector; + SEL _selector; } @property(readonly, nonatomic) CFTimeInterval duration; @@ -24,10 +24,9 @@ @property(readonly, nonatomic) CFTimeInterval timestamp; // Returns a new display link. -+ (CADisplayLink *)displayLinkWithTarget:(id)target - selector:(SEL)sel; ++ (CADisplayLink*)displayLinkWithTarget:(id)target selector:(SEL)sel; // Release the target -- (void) invalidate; +- (void)invalidate; @end diff --git a/infer/models/objc/src/CADisplayLink.m b/infer/models/objc/src/CADisplayLink.m index 656e4df78..296e3cd12 100644 --- a/infer/models/objc/src/CADisplayLink.m +++ b/infer/models/objc/src/CADisplayLink.m @@ -13,19 +13,18 @@ // Returns a new display link. // The model retains strongly the target object. -+ (CADisplayLink *)displayLinkWithTarget:(id)target - selector:(SEL)sel { ++ (CADisplayLink*)displayLinkWithTarget:(id)target selector:(SEL)sel { - CADisplayLink *c = [CADisplayLink alloc]; - c->_target = target; - c->_selector = sel; + CADisplayLink* c = [CADisplayLink alloc]; + c->_target = target; + c->_selector = sel; - return c; + return c; } // Release the target -- (void) invalidate { - self->_target = nil; +- (void)invalidate { + self->_target = nil; } @end diff --git a/infer/models/objc/src/CoreFoundation/CFArray.c b/infer/models/objc/src/CoreFoundation/CFArray.c index 1e963385f..87b3b1c88 100644 --- a/infer/models/objc/src/CoreFoundation/CFArray.c +++ b/infer/models/objc/src/CoreFoundation/CFArray.c @@ -7,47 +7,49 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import +#import CFArrayRef __cf_alloc(CFArrayRef); CFArrayRef __cf_non_null_alloc(CFArrayRef); -CFArrayRef CFArrayCreate ( CFAllocatorRef allocator, - const void **values, - CFIndex numValues, - const CFArrayCallBacks *callBacks ) { +CFArrayRef CFArrayCreate(CFAllocatorRef allocator, + const void** values, + CFIndex numValues, + const CFArrayCallBacks* callBacks) { CFArrayRef c; return __cf_alloc(c); } -CFArrayRef CFNetworkCopyProxiesForURL ( CFURLRef url, CFDictionaryRef proxySettings ) { +CFArrayRef CFNetworkCopyProxiesForURL(CFURLRef url, + CFDictionaryRef proxySettings) { CFArrayRef c; return __cf_alloc(c); } -CFArrayRef CFStringCreateArrayWithFindResults ( CFAllocatorRef alloc, - CFStringRef theString, - CFStringRef stringToFind, - CFRange rangeToSearch, - CFStringCompareFlags compareOptions ) { +CFArrayRef CFStringCreateArrayWithFindResults( + CFAllocatorRef alloc, + CFStringRef theString, + CFStringRef stringToFind, + CFRange rangeToSearch, + CFStringCompareFlags compareOptions) { CFArrayRef c; return __cf_alloc(c); } -CFArrayRef CFPreferencesCopyKeyList ( CFStringRef applicationID, - CFStringRef userName, - CFStringRef hostName ) { +CFArrayRef CFPreferencesCopyKeyList(CFStringRef applicationID, + CFStringRef userName, + CFStringRef hostName) { CFArrayRef c; return __cf_non_null_alloc(c); } -CFArrayRef CNCopySupportedInterfaces ( void ) { +CFArrayRef CNCopySupportedInterfaces(void) { CFArrayRef c; return __cf_non_null_alloc(c); } -CFArrayRef ABAddressBookCopyArrayOfAllPeople ( ABAddressBookRef addressBook ) { +CFArrayRef ABAddressBookCopyArrayOfAllPeople(ABAddressBookRef addressBook) { CFArrayRef c; return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFBinaryHeap.c b/infer/models/objc/src/CoreFoundation/CFBinaryHeap.c index 8a943ff11..b0c472c27 100644 --- a/infer/models/objc/src/CoreFoundation/CFBinaryHeap.c +++ b/infer/models/objc/src/CoreFoundation/CFBinaryHeap.c @@ -11,11 +11,11 @@ CFBinaryHeapRef __cf_alloc(CFBinaryHeapRef); - -CFBinaryHeapRef CFBinaryHeapCreate ( CFAllocatorRef allocator, - CFIndex capacity, - const CFBinaryHeapCallBacks *callBacks, - const CFBinaryHeapCompareContext *compareContext) { +CFBinaryHeapRef CFBinaryHeapCreate( + CFAllocatorRef allocator, + CFIndex capacity, + const CFBinaryHeapCallBacks* callBacks, + const CFBinaryHeapCompareContext* compareContext) { CFBinaryHeapRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFBitVector.c b/infer/models/objc/src/CoreFoundation/CFBitVector.c index ca7ffe192..267e96aed 100644 --- a/infer/models/objc/src/CoreFoundation/CFBitVector.c +++ b/infer/models/objc/src/CoreFoundation/CFBitVector.c @@ -12,9 +12,9 @@ CFBitVectorRef __cf_alloc(CFBitVectorRef); CFBitVectorRef __cf_non_null_alloc(CFBitVectorRef); -CFBitVectorRef CFBitVectorCreate ( CFAllocatorRef allocator, - const UInt8 *bytes, - CFIndex numBits ) { +CFBitVectorRef CFBitVectorCreate(CFAllocatorRef allocator, + const UInt8* bytes, + CFIndex numBits) { CFBitVectorRef c; return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFDate.c b/infer/models/objc/src/CoreFoundation/CFDate.c index fc0aa7920..a780c3682 100644 --- a/infer/models/objc/src/CoreFoundation/CFDate.c +++ b/infer/models/objc/src/CoreFoundation/CFDate.c @@ -12,8 +12,7 @@ CFDateRef __cf_alloc(CFDateRef); CFDateRef __cf_non_null_alloc(CFDateRef); - -CFDateRef CFDateCreate ( CFAllocatorRef allocator, CFAbsoluteTime at ) { +CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) { CFDateRef c; return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFDictionary.c b/infer/models/objc/src/CoreFoundation/CFDictionary.c index 12fd76c8d..f08267e6f 100644 --- a/infer/models/objc/src/CoreFoundation/CFDictionary.c +++ b/infer/models/objc/src/CoreFoundation/CFDictionary.c @@ -7,69 +7,67 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - -#import #import #import +#import CFDictionaryRef __cf_non_null_alloc(CFDictionaryRef); CFDictionaryRef __cf_alloc(CFDictionaryRef); -CFDictionaryRef CGImageSourceCopyPropertiesAtIndex ( CGImageSourceRef isrc, - size_t index, - CFDictionaryRef options ) -{ - CFDictionaryRef c; - return __cf_non_null_alloc(c); +CFDictionaryRef CGImageSourceCopyPropertiesAtIndex(CGImageSourceRef isrc, + size_t index, + CFDictionaryRef options) { + CFDictionaryRef c; + return __cf_non_null_alloc(c); } - -CFDictionaryRef CFDictionaryCreate ( CFAllocatorRef allocator, - const void **keys, - const void **values, - CFIndex numValues, - const CFDictionaryKeyCallBacks *keyCallBacks, - const CFDictionaryValueCallBacks *valueCallBacks ) { - CFDictionaryRef c; - return __cf_alloc(c); +CFDictionaryRef CFDictionaryCreate( + CFAllocatorRef allocator, + const void** keys, + const void** values, + CFIndex numValues, + const CFDictionaryKeyCallBacks* keyCallBacks, + const CFDictionaryValueCallBacks* valueCallBacks) { + CFDictionaryRef c; + return __cf_alloc(c); } -CFDictionaryRef CFDictionaryCreateCopy ( CFAllocatorRef allocator, - CFDictionaryRef theDict ) { - CFDictionaryRef c; - return __cf_alloc(c); +CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, + CFDictionaryRef theDict) { + CFDictionaryRef c; + return __cf_alloc(c); } -CFDictionaryRef CFNetworkCopySystemProxySettings ( void ) { - CFDictionaryRef c; - return __cf_non_null_alloc(c); +CFDictionaryRef CFNetworkCopySystemProxySettings(void) { + CFDictionaryRef c; + return __cf_non_null_alloc(c); } -CFDictionaryRef CGImageSourceCopyProperties ( CGImageSourceRef isrc, CFDictionaryRef options ) { - CFDictionaryRef c; - return __cf_non_null_alloc(c); +CFDictionaryRef CGImageSourceCopyProperties(CGImageSourceRef isrc, + CFDictionaryRef options) { + CFDictionaryRef c; + return __cf_non_null_alloc(c); } -CFDictionaryRef CMCopyDictionaryOfAttachments ( CFAllocatorRef allocator, - CMAttachmentBearerRef target, - CMAttachmentMode attachmentMode ) { - CFDictionaryRef c; - return __cf_alloc(c); +CFDictionaryRef CMCopyDictionaryOfAttachments(CFAllocatorRef allocator, + CMAttachmentBearerRef target, + CMAttachmentMode attachmentMode) { + CFDictionaryRef c; + return __cf_alloc(c); } -CFDictionaryRef CFHTTPMessageCopyAllHeaderFields ( CFHTTPMessageRef message ) { - CFDictionaryRef c; - return __cf_alloc(c); +CFDictionaryRef CFHTTPMessageCopyAllHeaderFields(CFHTTPMessageRef message) { + CFDictionaryRef c; + return __cf_alloc(c); } -CFDictionaryRef CNCopyCurrentNetworkInfo ( CFStringRef interfaceName ) { - CFDictionaryRef c; - return __cf_non_null_alloc(c); +CFDictionaryRef CNCopyCurrentNetworkInfo(CFStringRef interfaceName) { + CFDictionaryRef c; + return __cf_non_null_alloc(c); } -CFDictionaryRef CMTimeCopyAsDictionary (CMTime time, - CFAllocatorRef allocator ) { +CFDictionaryRef CMTimeCopyAsDictionary(CMTime time, CFAllocatorRef allocator) { CFDictionaryRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFError.c b/infer/models/objc/src/CoreFoundation/CFError.c index ad8b71dc5..8056a194b 100644 --- a/infer/models/objc/src/CoreFoundation/CFError.c +++ b/infer/models/objc/src/CoreFoundation/CFError.c @@ -12,13 +12,12 @@ CFErrorRef __cf_alloc(CFErrorRef); CFErrorRef __cf_non_null_alloc(CFErrorRef); - -CFErrorRef CFReadStreamCopyError ( CFReadStreamRef stream ) { +CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream) { CFErrorRef c; return __cf_alloc(c); } -CFErrorRef CFWriteStreamCopyError ( CFWriteStreamRef stream ) { +CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream) { CFErrorRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFHTTPMessage.c b/infer/models/objc/src/CoreFoundation/CFHTTPMessage.c index 9fd8df662..28a694052 100644 --- a/infer/models/objc/src/CoreFoundation/CFHTTPMessage.c +++ b/infer/models/objc/src/CoreFoundation/CFHTTPMessage.c @@ -11,31 +11,30 @@ CFHTTPMessageRef __cf_alloc(CFHTTPMessageRef); - -CFHTTPMessageRef CFHTTPMessageCreateCopy ( CFAllocatorRef alloc, - CFHTTPMessageRef message ) { - CFHTTPMessageRef c; - return __cf_alloc(c); +CFHTTPMessageRef CFHTTPMessageCreateCopy(CFAllocatorRef alloc, + CFHTTPMessageRef message) { + CFHTTPMessageRef c; + return __cf_alloc(c); } -CFHTTPMessageRef CFHTTPMessageCreateEmpty ( CFAllocatorRef alloc, - Boolean isRequest ) { - CFHTTPMessageRef c; - return __cf_alloc(c); +CFHTTPMessageRef CFHTTPMessageCreateEmpty(CFAllocatorRef alloc, + Boolean isRequest) { + CFHTTPMessageRef c; + return __cf_alloc(c); } -CFHTTPMessageRef CFHTTPMessageCreateRequest ( CFAllocatorRef alloc, - CFStringRef requestMethod, - CFURLRef url, - CFStringRef httpVersion ) { - CFHTTPMessageRef c; - return __cf_alloc(c); +CFHTTPMessageRef CFHTTPMessageCreateRequest(CFAllocatorRef alloc, + CFStringRef requestMethod, + CFURLRef url, + CFStringRef httpVersion) { + CFHTTPMessageRef c; + return __cf_alloc(c); } -CFHTTPMessageRef CFHTTPMessageCreateResponse ( CFAllocatorRef alloc, - CFIndex statusCode, - CFStringRef statusDescription, - CFStringRef httpVersion ) { - CFHTTPMessageRef c; - return __cf_alloc(c); +CFHTTPMessageRef CFHTTPMessageCreateResponse(CFAllocatorRef alloc, + CFIndex statusCode, + CFStringRef statusDescription, + CFStringRef httpVersion) { + CFHTTPMessageRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFLocale.c b/infer/models/objc/src/CoreFoundation/CFLocale.c index 405fd1bcb..1ccabd5c5 100644 --- a/infer/models/objc/src/CoreFoundation/CFLocale.c +++ b/infer/models/objc/src/CoreFoundation/CFLocale.c @@ -17,8 +17,8 @@ CFLocaleRef CFLocaleCopyCurrent(void) { return __cf_non_null_alloc(c); } -CFLocaleRef CFLocaleCreate ( CFAllocatorRef allocator, - CFStringRef localeIdentifier ) { +CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, + CFStringRef localeIdentifier) { CFLocaleRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFMutableArray.c b/infer/models/objc/src/CoreFoundation/CFMutableArray.c index 7f64742e3..69788b476 100644 --- a/infer/models/objc/src/CoreFoundation/CFMutableArray.c +++ b/infer/models/objc/src/CoreFoundation/CFMutableArray.c @@ -12,9 +12,9 @@ CFMutableArrayRef __cf_alloc(CFMutableArrayRef); CFMutableArrayRef __cf_non_null_alloc(CFMutableArrayRef); -CFMutableArrayRef CFArrayCreateMutable ( CFAllocatorRef allocator, - CFIndex capacity, - const CFArrayCallBacks *callBacks ) { +CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, + CFIndex capacity, + const CFArrayCallBacks* callBacks) { CFMutableArrayRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFMutableAttributedString.c b/infer/models/objc/src/CoreFoundation/CFMutableAttributedString.c index b7a2f6636..7dfd681ab 100644 --- a/infer/models/objc/src/CoreFoundation/CFMutableAttributedString.c +++ b/infer/models/objc/src/CoreFoundation/CFMutableAttributedString.c @@ -11,8 +11,8 @@ CFMutableAttributedStringRef __cf_non_null_alloc(CFMutableAttributedStringRef); -CFMutableAttributedStringRef CFAttributedStringCreateMutable (CFAllocatorRef alloc, - CFIndex maxLength ) { - CFMutableAttributedStringRef c; - return __cf_non_null_alloc(c); +CFMutableAttributedStringRef CFAttributedStringCreateMutable( + CFAllocatorRef alloc, CFIndex maxLength) { + CFMutableAttributedStringRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFMutableDictionary.c b/infer/models/objc/src/CoreFoundation/CFMutableDictionary.c index 2da197aac..d2bc98f11 100644 --- a/infer/models/objc/src/CoreFoundation/CFMutableDictionary.c +++ b/infer/models/objc/src/CoreFoundation/CFMutableDictionary.c @@ -7,26 +7,26 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - -#import #import +#import CFMutableDictionaryRef __cf_non_null_alloc(CFMutableDictionaryRef); CFMutableDictionaryRef __cf_alloc(CFMutableDictionaryRef); -CFMutableDictionaryRef CFDictionaryCreateMutable ( CFAllocatorRef allocator, - CFIndex capacity, - const CFDictionaryKeyCallBacks *keyCallBacks, - const CFDictionaryValueCallBacks *valueCallBacks ) { +CFMutableDictionaryRef CFDictionaryCreateMutable( + CFAllocatorRef allocator, + CFIndex capacity, + const CFDictionaryKeyCallBacks* keyCallBacks, + const CFDictionaryValueCallBacks* valueCallBacks) { - CFMutableDictionaryRef c; - return __cf_alloc(c); + CFMutableDictionaryRef c; + return __cf_alloc(c); } -CFMutableDictionaryRef CFDictionaryCreateMutableCopy ( CFAllocatorRef allocator, - CFIndex capacity, - CFDictionaryRef theDict ) { - CFMutableDictionaryRef c; - return __cf_non_null_alloc(c); +CFMutableDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, + CFIndex capacity, + CFDictionaryRef theDict) { + CFMutableDictionaryRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFMutableSet.c b/infer/models/objc/src/CoreFoundation/CFMutableSet.c index 567ffa0a8..af046031b 100644 --- a/infer/models/objc/src/CoreFoundation/CFMutableSet.c +++ b/infer/models/objc/src/CoreFoundation/CFMutableSet.c @@ -7,22 +7,21 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - #import CFMutableSetRef __cf_alloc(CFMutableSetRef); CFMutableSetRef __cf_non_null_alloc(CFMutableSetRef); -CFMutableSetRef CFSetCreateMutable (CFAllocatorRef allocator, - CFIndex capacity, - const CFSetCallBacks *callBacks) { +CFMutableSetRef CFSetCreateMutable(CFAllocatorRef allocator, + CFIndex capacity, + const CFSetCallBacks* callBacks) { CFMutableSetRef c; return __cf_alloc(c); } -CFMutableSetRef CFSetCreateMutableCopy ( CFAllocatorRef allocator, - CFIndex capacity, - CFSetRef theSet ) { +CFMutableSetRef CFSetCreateMutableCopy(CFAllocatorRef allocator, + CFIndex capacity, + CFSetRef theSet) { CFMutableSetRef c; return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFNumber.c b/infer/models/objc/src/CoreFoundation/CFNumber.c index a48ab916e..01ebf3227 100644 --- a/infer/models/objc/src/CoreFoundation/CFNumber.c +++ b/infer/models/objc/src/CoreFoundation/CFNumber.c @@ -11,10 +11,9 @@ CFNumberRef __cf_alloc(CFNumberRef); - -CFNumberRef CFNumberCreate ( CFAllocatorRef allocator, - CFNumberType theType, - const void *valuePtr ) { - CFNumberRef c; - return __cf_alloc(c); +CFNumberRef CFNumberCreate(CFAllocatorRef allocator, + CFNumberType theType, + const void* valuePtr) { + CFNumberRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFRunLoop.c b/infer/models/objc/src/CoreFoundation/CFRunLoop.c index 644879a3f..7b5f03610 100644 --- a/infer/models/objc/src/CoreFoundation/CFRunLoop.c +++ b/infer/models/objc/src/CoreFoundation/CFRunLoop.c @@ -12,16 +12,16 @@ CFRunLoopSourceRef __cf_alloc(CFRunLoopSourceRef); CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef); -CFRunLoopSourceRef CFRunLoopSourceCreate ( CFAllocatorRef allocator, - CFIndex order, - CFRunLoopSourceContext *context ) { - CFRunLoopSourceRef c; - return __cf_non_null_alloc(c); +CFRunLoopSourceRef CFRunLoopSourceCreate(CFAllocatorRef allocator, + CFIndex order, + CFRunLoopSourceContext* context) { + CFRunLoopSourceRef c; + return __cf_non_null_alloc(c); } -CFRunLoopSourceRef CFSocketCreateRunLoopSource ( CFAllocatorRef allocator, - CFSocketRef s, - CFIndex order ) { - CFRunLoopSourceRef c; - return __cf_non_null_alloc(c); +CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, + CFSocketRef s, + CFIndex order) { + CFRunLoopSourceRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFRunLoopObserver.c b/infer/models/objc/src/CoreFoundation/CFRunLoopObserver.c index 019fc1d62..132207d12 100644 --- a/infer/models/objc/src/CoreFoundation/CFRunLoopObserver.c +++ b/infer/models/objc/src/CoreFoundation/CFRunLoopObserver.c @@ -12,24 +12,23 @@ CFRunLoopObserverRef __cf_alloc(CFRunLoopObserverRef); CFRunLoopSourceRef __cf_non_null_alloc(CFRunLoopSourceRef); -CFRunLoopObserverRef CFRunLoopObserverCreate ( CFAllocatorRef allocator, - CFOptionFlags activities, - Boolean repeats, - CFIndex order, - CFRunLoopObserverCallBack callout, - CFRunLoopObserverContext *context) { - CFRunLoopObserverRef c; - return __cf_non_null_alloc(c); +CFRunLoopObserverRef CFRunLoopObserverCreate( + CFAllocatorRef allocator, + CFOptionFlags activities, + Boolean repeats, + CFIndex order, + CFRunLoopObserverCallBack callout, + CFRunLoopObserverContext* context) { + CFRunLoopObserverRef c; + return __cf_non_null_alloc(c); } - -CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler ( CFAllocatorRef allocator, - CFOptionFlags activities, - Boolean repeats, - CFIndex order, - void (^block)( - CFRunLoopObserverRef observer, - CFRunLoopActivity activity) ) { - CFRunLoopObserverRef c; - return __cf_non_null_alloc(c); +CFRunLoopObserverRef CFRunLoopObserverCreateWithHandler( + CFAllocatorRef allocator, + CFOptionFlags activities, + Boolean repeats, + CFIndex order, + void (^block)(CFRunLoopObserverRef observer, CFRunLoopActivity activity)) { + CFRunLoopObserverRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFSocket.c b/infer/models/objc/src/CoreFoundation/CFSocket.c index 3bd235351..8a13e25fa 100644 --- a/infer/models/objc/src/CoreFoundation/CFSocket.c +++ b/infer/models/objc/src/CoreFoundation/CFSocket.c @@ -11,13 +11,13 @@ CFSocketRef __cf_alloc(CFSocketRef); -CFSocketRef CFSocketCreate ( CFAllocatorRef allocator, - SInt32 protocolFamily, - SInt32 socketType, - SInt32 protocol, - CFOptionFlags callBackTypes, - CFSocketCallBack callout, - const CFSocketContext *context ) { - CFSocketRef c; - return __cf_alloc(c); +CFSocketRef CFSocketCreate(CFAllocatorRef allocator, + SInt32 protocolFamily, + SInt32 socketType, + SInt32 protocol, + CFOptionFlags callBackTypes, + CFSocketCallBack callout, + const CFSocketContext* context) { + CFSocketRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFString.c b/infer/models/objc/src/CoreFoundation/CFString.c index 74ce162c4..16a4dbf93 100644 --- a/infer/models/objc/src/CoreFoundation/CFString.c +++ b/infer/models/objc/src/CoreFoundation/CFString.c @@ -14,20 +14,19 @@ CFStringRef __cf_alloc(CFStringRef); void __get_array_size(const UInt8); -CFStringRef CFStringCreateWithBytesNoCopy ( - CFAllocatorRef alloc, - const UInt8 *bytes, - CFIndex numBytes, - CFStringEncoding encoding, - Boolean isExternalRepresentation, - CFAllocatorRef contentsDeallocator ) { - CFStringRef c; - CFStringRef s = __cf_alloc(c); - if (s) { - if (bytes) { - __get_array_size(bytes); - free(bytes); - } - } - return s; +CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, + const UInt8* bytes, + CFIndex numBytes, + CFStringEncoding encoding, + Boolean isExternalRepresentation, + CFAllocatorRef contentsDeallocator) { + CFStringRef c; + CFStringRef s = __cf_alloc(c); + if (s) { + if (bytes) { + __get_array_size(bytes); + free(bytes); + } + } + return s; } diff --git a/infer/models/objc/src/CoreFoundation/CFStringTokenizer.c b/infer/models/objc/src/CoreFoundation/CFStringTokenizer.c index 9f0a0ff88..7309fd241 100644 --- a/infer/models/objc/src/CoreFoundation/CFStringTokenizer.c +++ b/infer/models/objc/src/CoreFoundation/CFStringTokenizer.c @@ -12,11 +12,11 @@ CFStringTokenizerRef __cf_alloc(CFStringTokenizerRef); CFStringTokenizerRef __cf_non_null_alloc(CFStringTokenizerRef); -CFStringTokenizerRef CFStringTokenizerCreate ( CFAllocatorRef alloc, - CFStringRef string, - CFRange range, - CFOptionFlags options, - CFLocaleRef locale ) { - CFStringTokenizerRef c; - return __cf_non_null_alloc(c); +CFStringTokenizerRef CFStringTokenizerCreate(CFAllocatorRef alloc, + CFStringRef string, + CFRange range, + CFOptionFlags options, + CFLocaleRef locale) { + CFStringTokenizerRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CFType.c b/infer/models/objc/src/CoreFoundation/CFType.c index 59839f7e0..53c05dd14 100644 --- a/infer/models/objc/src/CoreFoundation/CFType.c +++ b/infer/models/objc/src/CoreFoundation/CFType.c @@ -9,6 +9,4 @@ #import -CFTypeRef CFMakeCollectable ( CFTypeRef cf ) { - return cf; -} +CFTypeRef CFMakeCollectable(CFTypeRef cf) { return cf; } diff --git a/infer/models/objc/src/CoreFoundation/CFUUID.c b/infer/models/objc/src/CoreFoundation/CFUUID.c index 4b2ecd5cf..c88573879 100644 --- a/infer/models/objc/src/CoreFoundation/CFUUID.c +++ b/infer/models/objc/src/CoreFoundation/CFUUID.c @@ -12,13 +12,13 @@ CFUUIDRef __cf_alloc(CFUUIDRef); CFUUIDRef __cf_non_null_alloc(CFUUIDRef); -CFUUIDRef CFUUIDCreate ( CFAllocatorRef alloc ){ - CFUUIDRef c; - return __cf_non_null_alloc(c); +CFUUIDRef CFUUIDCreate(CFAllocatorRef alloc) { + CFUUIDRef c; + return __cf_non_null_alloc(c); } -CFUUIDRef CFUUIDCreateFromUUIDBytes ( CFAllocatorRef alloc, CFUUIDBytes bytes ) { +CFUUIDRef CFUUIDCreateFromUUIDBytes(CFAllocatorRef alloc, CFUUIDBytes bytes) { - CFUUIDRef c; - return __cf_non_null_alloc(c); + CFUUIDRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CTFont.c b/infer/models/objc/src/CoreFoundation/CTFont.c index 5d3eb2a2d..5b388d14d 100644 --- a/infer/models/objc/src/CoreFoundation/CTFont.c +++ b/infer/models/objc/src/CoreFoundation/CTFont.c @@ -11,9 +11,9 @@ CTFontRef __cf_alloc(CTFontRef); -CTFontRef CTFontCreateWithName ( CFStringRef name, - CGFloat size, - const CGAffineTransform *matrix ) { +CTFontRef CTFontCreateWithName(CFStringRef name, + CGFloat size, + const CGAffineTransform* matrix) { CTFontRef c; return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CTFramesetter.c b/infer/models/objc/src/CoreFoundation/CTFramesetter.c index dd3d6d2dc..c84b3549e 100644 --- a/infer/models/objc/src/CoreFoundation/CTFramesetter.c +++ b/infer/models/objc/src/CoreFoundation/CTFramesetter.c @@ -11,7 +11,8 @@ CTFramesetterRef __cf_alloc(CTFramesetterRef); -CTFramesetterRef CTFramesetterCreateWithAttributedString ( CFAttributedStringRef string ) { - CTFramesetterRef c; - return __cf_alloc(c); +CTFramesetterRef CTFramesetterCreateWithAttributedString( + CFAttributedStringRef string) { + CTFramesetterRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/CTParagraphStyle.c b/infer/models/objc/src/CoreFoundation/CTParagraphStyle.c index 2fe94c86b..064ab3985 100644 --- a/infer/models/objc/src/CoreFoundation/CTParagraphStyle.c +++ b/infer/models/objc/src/CoreFoundation/CTParagraphStyle.c @@ -7,15 +7,14 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import +#import CTParagraphStyleRef __cf_alloc(CTParagraphStyleRef); CTParagraphStyleRef __cf_non_null_alloc(CTParagraphStyleRef); - -CTParagraphStyleRef CTParagraphStyleCreate ( const CTParagraphStyleSetting *settings, - size_t settingCount ) { - CTParagraphStyleRef c; - return __cf_alloc(c); +CTParagraphStyleRef CTParagraphStyleCreate( + const CTParagraphStyleSetting* settings, size_t settingCount) { + CTParagraphStyleRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/SCNetworkReachability.c b/infer/models/objc/src/CoreFoundation/SCNetworkReachability.c index 9a7d7fc16..5afd462c7 100644 --- a/infer/models/objc/src/CoreFoundation/SCNetworkReachability.c +++ b/infer/models/objc/src/CoreFoundation/SCNetworkReachability.c @@ -7,20 +7,19 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import "SystemConfiguration/SCNetworkReachability.h" +#import SCNetworkReachabilityRef __cf_non_null_alloc(SCNetworkReachabilityRef); -SCNetworkReachabilityRef SCNetworkReachabilityCreateWithName ( - CFAllocatorRef allocator, - const char *nodename ) { - SCNetworkReachabilityRef c; - return __cf_non_null_alloc(c); +SCNetworkReachabilityRef SCNetworkReachabilityCreateWithName( + CFAllocatorRef allocator, const char* nodename) { + SCNetworkReachabilityRef c; + return __cf_non_null_alloc(c); } -SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress ( CFAllocatorRef allocator, - const struct sockaddr *address ) { - SCNetworkReachabilityRef c; - return __cf_non_null_alloc(c); +SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress( + CFAllocatorRef allocator, const struct sockaddr* address) { + SCNetworkReachabilityRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/SecCertificate.c b/infer/models/objc/src/CoreFoundation/SecCertificate.c index 830cd5ab3..da16f6937 100644 --- a/infer/models/objc/src/CoreFoundation/SecCertificate.c +++ b/infer/models/objc/src/CoreFoundation/SecCertificate.c @@ -13,9 +13,8 @@ SecCertificateRef __cf_alloc(SecCertificateRef); SecCertificateRef __cf_non_null_alloc(SecCertificateRef); - -SecCertificateRef SecCertificateCreateWithData ( CFAllocatorRef allocator, - CFDataRef data ) { - SecCertificateRef c; - return __cf_alloc(c); +SecCertificateRef SecCertificateCreateWithData(CFAllocatorRef allocator, + CFDataRef data) { + SecCertificateRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreFoundation/SecKey.c b/infer/models/objc/src/CoreFoundation/SecKey.c index 5d83b2c74..670f45a5c 100644 --- a/infer/models/objc/src/CoreFoundation/SecKey.c +++ b/infer/models/objc/src/CoreFoundation/SecKey.c @@ -14,18 +14,17 @@ SecKeyRef __cf_alloc(SecKeyRef); SecPolicyRef __cf_non_null_alloc(SecPolicyRef); -SecKeyRef SecTrustCopyPublicKey ( SecTrustRef trust ){ - SecKeyRef c; - return __cf_alloc(c); +SecKeyRef SecTrustCopyPublicKey(SecTrustRef trust) { + SecKeyRef c; + return __cf_alloc(c); } - -SecPolicyRef SecPolicyCreateSSL ( Boolean server, CFStringRef hostname ) { - SecPolicyRef c; - return __cf_non_null_alloc(c); +SecPolicyRef SecPolicyCreateSSL(Boolean server, CFStringRef hostname) { + SecPolicyRef c; + return __cf_non_null_alloc(c); } -SecPolicyRef SecPolicyCreateBasicX509 ( void ) { - SecPolicyRef c; - return __cf_non_null_alloc(c); +SecPolicyRef SecPolicyCreateBasicX509(void) { + SecPolicyRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGColor.c b/infer/models/objc/src/CoreGraphics/CGColor.c index dc9997ffd..fba9301a2 100644 --- a/infer/models/objc/src/CoreGraphics/CGColor.c +++ b/infer/models/objc/src/CoreGraphics/CGColor.c @@ -13,33 +13,34 @@ CGColorRef __cf_non_null_alloc(CGColorRef); void __objc_release_cf(CGColorRef); -void CGColorRelease (CGColorRef color) { - if (color) __objc_release_cf(color); +void CGColorRelease(CGColorRef color) { + if (color) + __objc_release_cf(color); } CGColorRef CGColorCreate(CGColorSpaceRef space, const CGFloat components[]) { - CGColorRef c; - return __cf_non_null_alloc(c); + CGColorRef c; + return __cf_non_null_alloc(c); } -CGColorRef CGColorCreateCopyWithAlpha ( CGColorRef color, CGFloat alpha ) { - CGColorRef c; - return __cf_non_null_alloc(c); +CGColorRef CGColorCreateCopyWithAlpha(CGColorRef color, CGFloat alpha) { + CGColorRef c; + return __cf_non_null_alloc(c); } -//FB own code +// FB own code CGColorRef FBColorCreateWithGray(CGFloat gray, CGFloat a) { - CGColorRef c; - return __cf_non_null_alloc(c); + CGColorRef c; + return __cf_non_null_alloc(c); } CGColorRef FBColorCreateWithRGBA(uint8_t r, uint8_t g, uint8_t b, CGFloat a) { - CGColorRef c; - return __cf_non_null_alloc(c); + CGColorRef c; + return __cf_non_null_alloc(c); } CGColorRef FBColorCreateWithRGB(uint8_t r, uint8_t g, uint8_t b) { - CGColorRef c; - return __cf_non_null_alloc(c); + CGColorRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGColorSpace.c b/infer/models/objc/src/CoreGraphics/CGColorSpace.c index 680241a27..8726f2f17 100644 --- a/infer/models/objc/src/CoreGraphics/CGColorSpace.c +++ b/infer/models/objc/src/CoreGraphics/CGColorSpace.c @@ -11,18 +11,19 @@ void __objc_release_cf(CGColorSpaceRef); -void CGColorSpaceRelease ( CGColorSpaceRef space ) { - if (space) __objc_release_cf(space); +void CGColorSpaceRelease(CGColorSpaceRef space) { + if (space) + __objc_release_cf(space); } CGColorSpaceRef __cf_alloc(CGColorSpaceRef); -CGColorSpaceRef CGColorSpaceCreateDeviceRGB ( void ) { - CGColorSpaceRef c; - return __cf_alloc(c); +CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void) { + CGColorSpaceRef c; + return __cf_alloc(c); } -CGColorSpaceRef CGColorSpaceCreateDeviceGray ( void ) { - CGColorSpaceRef c; - return __cf_alloc(c); +CGColorSpaceRef CGColorSpaceCreateDeviceGray(void) { + CGColorSpaceRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGContext.c b/infer/models/objc/src/CoreGraphics/CGContext.c index 3c62f25ec..5f959b034 100644 --- a/infer/models/objc/src/CoreGraphics/CGContext.c +++ b/infer/models/objc/src/CoreGraphics/CGContext.c @@ -13,19 +13,20 @@ void __objc_release_cf(CGContextRef); -void CGContextRelease ( CGContextRef c ){ - if (c) __objc_release_cf(c); +void CGContextRelease(CGContextRef c) { + if (c) + __objc_release_cf(c); } CGContextRef __cf_alloc(CGContextRef); -CGContextRef CGBitmapContextCreate ( void *data, - size_t width, - size_t height, - size_t bitsPerComponent, - size_t bytesPerRow, - CGColorSpaceRef space, - CGBitmapInfo bitmapInfo ) { - CGContextRef c; - return __cf_alloc(c); +CGContextRef CGBitmapContextCreate(void* data, + size_t width, + size_t height, + size_t bitsPerComponent, + size_t bytesPerRow, + CGColorSpaceRef space, + CGBitmapInfo bitmapInfo) { + CGContextRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGDataConsumer.c b/infer/models/objc/src/CoreGraphics/CGDataConsumer.c index c8a56c8b4..433348131 100644 --- a/infer/models/objc/src/CoreGraphics/CGDataConsumer.c +++ b/infer/models/objc/src/CoreGraphics/CGDataConsumer.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGDataConsumerRef); -void CGDataConsumerRelease ( CGDataConsumerRef consumer ) { - if (consumer) __objc_release_cf(consumer); +void CGDataConsumerRelease(CGDataConsumerRef consumer) { + if (consumer) + __objc_release_cf(consumer); } diff --git a/infer/models/objc/src/CoreGraphics/CGDataProvider.c b/infer/models/objc/src/CoreGraphics/CGDataProvider.c index c07341b3c..6ab5cb3ee 100644 --- a/infer/models/objc/src/CoreGraphics/CGDataProvider.c +++ b/infer/models/objc/src/CoreGraphics/CGDataProvider.c @@ -11,41 +11,42 @@ void __objc_release_cf(CGDataProviderRef); -void CGDataProviderRelease ( CGDataProviderRef provider ){ - if (provider) __objc_release_cf(provider); +void CGDataProviderRelease(CGDataProviderRef provider) { + if (provider) + __objc_release_cf(provider); } CGDataProviderRef __cf_alloc(CGDataProviderRef); CGDataProviderRef __cf_non_null_alloc(CGDataProviderRef); -CGDataProviderRef CGDataProviderCreateWithCFData ( CFDataRef data ) { - CGDataProviderRef c; - return __cf_non_null_alloc(c); +CGDataProviderRef CGDataProviderCreateWithCFData(CFDataRef data) { + CGDataProviderRef c; + return __cf_non_null_alloc(c); } -CGDataProviderRef CGDataProviderCreateWithData ( void *info, - const void *data, size_t size, - CGDataProviderReleaseDataCallback releaseData ) { - CGDataProviderRef c; - return __cf_non_null_alloc(c); +CGDataProviderRef CGDataProviderCreateWithData( + void* info, + const void* data, + size_t size, + CGDataProviderReleaseDataCallback releaseData) { + CGDataProviderRef c; + return __cf_non_null_alloc(c); } -CGDataProviderRef CGDataProviderCreateWithURL ( CFURLRef url ) { - CGDataProviderRef c; - return __cf_alloc(c); +CGDataProviderRef CGDataProviderCreateWithURL(CFURLRef url) { + CGDataProviderRef c; + return __cf_alloc(c); } - -CGDataProviderRef CGDataProviderCreateDirect ( void *info, - off_t size, - const CGDataProviderDirectCallbacks *callbacks) { - CGDataProviderRef c; - return __cf_non_null_alloc(c); +CGDataProviderRef CGDataProviderCreateDirect( + void* info, off_t size, const CGDataProviderDirectCallbacks* callbacks) { + CGDataProviderRef c; + return __cf_non_null_alloc(c); } -CGDataProviderRef CGDataProviderCreateSequential ( void *info, - const CGDataProviderSequentialCallbacks *callbacks ) { - CGDataProviderRef c; - return __cf_non_null_alloc(c); +CGDataProviderRef CGDataProviderCreateSequential( + void* info, const CGDataProviderSequentialCallbacks* callbacks) { + CGDataProviderRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGFont.c b/infer/models/objc/src/CoreGraphics/CGFont.c index 25dca4360..bc252857f 100644 --- a/infer/models/objc/src/CoreGraphics/CGFont.c +++ b/infer/models/objc/src/CoreGraphics/CGFont.c @@ -13,11 +13,12 @@ void __objc_release_cf(CGFontRef); CGFontRef __cf_alloc(CGFontRef); -void CGFontRelease ( CGFontRef font ) { - if (font) __objc_release_cf(font); +void CGFontRelease(CGFontRef font) { + if (font) + __objc_release_cf(font); } -CGFontRef CGFontCreateWithDataProvider ( CGDataProviderRef provider ) { - CGFontRef c; - return __cf_alloc(c); +CGFontRef CGFontCreateWithDataProvider(CGDataProviderRef provider) { + CGFontRef c; + return __cf_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGFunction.c b/infer/models/objc/src/CoreGraphics/CGFunction.c index 6ff6ec6ea..657c6a755 100644 --- a/infer/models/objc/src/CoreGraphics/CGFunction.c +++ b/infer/models/objc/src/CoreGraphics/CGFunction.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGFunctionRef); -void CGFunctionRelease ( CGFunctionRef function ) { - if (function) __objc_release_cf(function); +void CGFunctionRelease(CGFunctionRef function) { + if (function) + __objc_release_cf(function); } diff --git a/infer/models/objc/src/CoreGraphics/CGGradient.c b/infer/models/objc/src/CoreGraphics/CGGradient.c index 390124d74..0847aa25f 100644 --- a/infer/models/objc/src/CoreGraphics/CGGradient.c +++ b/infer/models/objc/src/CoreGraphics/CGGradient.c @@ -11,23 +11,24 @@ void __objc_release_cf(CGGradientRef); -void CGGradientRelease ( CGGradientRef gradient ) { - if (gradient) __objc_release_cf(gradient); +void CGGradientRelease(CGGradientRef gradient) { + if (gradient) + __objc_release_cf(gradient); } CGGradientRef __cf_non_null_alloc(CGGradientRef); -CGGradientRef CGGradientCreateWithColors ( CGColorSpaceRef space, - CFArrayRef colors, - const CGFloat locations[]) { - CGGradientRef c; - return __cf_non_null_alloc(c); +CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space, + CFArrayRef colors, + const CGFloat locations[]) { + CGGradientRef c; + return __cf_non_null_alloc(c); } -CGGradientRef CGGradientCreateWithColorComponents ( CGColorSpaceRef space, - const CGFloat components[], - const CGFloat locations[], - size_t count ) { - CGGradientRef c; - return __cf_non_null_alloc(c); +CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef space, + const CGFloat components[], + const CGFloat locations[], + size_t count) { + CGGradientRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGImage.c b/infer/models/objc/src/CoreGraphics/CGImage.c index d0156855e..a9cbaf026 100644 --- a/infer/models/objc/src/CoreGraphics/CGImage.c +++ b/infer/models/objc/src/CoreGraphics/CGImage.c @@ -14,72 +14,72 @@ CGImageRef __cf_non_null_alloc(CGImageRef); CGImageRef __cf_alloc(CGImageRef); void __objc_release_cf(CGImageRef); -CGImageRef CGImageSourceCreateImageAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options ) -{ - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageSourceCreateImageAtIndex(CGImageSourceRef isrc, + size_t index, + CFDictionaryRef options) { + CGImageRef c; + return __cf_non_null_alloc(c); } -CGImageRef CGImageSourceCreateThumbnailAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options ) -{ - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageSourceCreateThumbnailAtIndex(CGImageSourceRef isrc, + size_t index, + CFDictionaryRef options) { + CGImageRef c; + return __cf_non_null_alloc(c); } - -void CGImageRelease ( CGImageRef image ) -{ - if (image) __objc_release_cf(image); +void CGImageRelease(CGImageRef image) { + if (image) + __objc_release_cf(image); } -CGImageRef CGBitmapContextCreateImage ( CGContextRef context ) -{ - CGImageRef c; - return __cf_alloc(c); +CGImageRef CGBitmapContextCreateImage(CGContextRef context) { + CGImageRef c; + return __cf_alloc(c); } -CGImageRef CGImageCreateCopy ( CGImageRef image ) { - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageCreateCopy(CGImageRef image) { + CGImageRef c; + return __cf_non_null_alloc(c); } -CGImageRef CGImageCreateWithImageInRect ( CGImageRef image, CGRect rect ) { - CGImageRef c; - return __cf_alloc(c); +CGImageRef CGImageCreateWithImageInRect(CGImageRef image, CGRect rect) { + CGImageRef c; + return __cf_alloc(c); } -CGImageRef CGImageCreateWithJPEGDataProvider ( CGDataProviderRef source, - const CGFloat decode[], - bool shouldInterpolate, - CGColorRenderingIntent intent) { - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageCreateWithJPEGDataProvider(CGDataProviderRef source, + const CGFloat decode[], + bool shouldInterpolate, + CGColorRenderingIntent intent) { + CGImageRef c; + return __cf_non_null_alloc(c); } -CGImageRef CGImageCreateWithPNGDataProvider ( CGDataProviderRef source, - const CGFloat decode[], - bool shouldInterpolate, - CGColorRenderingIntent intent ) { - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageCreateWithPNGDataProvider(CGDataProviderRef source, + const CGFloat decode[], + bool shouldInterpolate, + CGColorRenderingIntent intent) { + CGImageRef c; + return __cf_non_null_alloc(c); } -CGImageRef CGImageCreate ( size_t width, - size_t height, - size_t bitsPerComponent, - size_t bitsPerPixel, - size_t bytesPerRow, - CGColorSpaceRef space, - CGBitmapInfo bitmapInfo, - CGDataProviderRef provider, - const CGFloat decode[], - bool shouldInterpolate, - CGColorRenderingIntent intent) { - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageCreate(size_t width, + size_t height, + size_t bitsPerComponent, + size_t bitsPerPixel, + size_t bytesPerRow, + CGColorSpaceRef space, + CGBitmapInfo bitmapInfo, + CGDataProviderRef provider, + const CGFloat decode[], + bool shouldInterpolate, + CGColorRenderingIntent intent) { + CGImageRef c; + return __cf_non_null_alloc(c); } -CGImageRef CGImageCreateWithMask ( CGImageRef image, CGImageRef mask ) { - CGImageRef c; - return __cf_non_null_alloc(c); +CGImageRef CGImageCreateWithMask(CGImageRef image, CGImageRef mask) { + CGImageRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGImageDestination.c b/infer/models/objc/src/CoreGraphics/CGImageDestination.c index b8e38e5e2..b9feed705 100644 --- a/infer/models/objc/src/CoreGraphics/CGImageDestination.c +++ b/infer/models/objc/src/CoreGraphics/CGImageDestination.c @@ -13,18 +13,19 @@ CGImageDestinationRef __cf_non_null_alloc(CGImageDestinationRef); CGImageDestinationRef __cf_alloc(CGImageDestinationRef); -CGImageDestinationRef CGImageDestinationCreateWithURL (CFURLRef url, - CFStringRef type, - size_t count, - CFDictionaryRef options) { - CGImageDestinationRef c; - return __cf_non_null_alloc(c); +CGImageDestinationRef CGImageDestinationCreateWithURL(CFURLRef url, + CFStringRef type, + size_t count, + CFDictionaryRef options) { + CGImageDestinationRef c; + return __cf_non_null_alloc(c); } -CGImageDestinationRef CGImageDestinationCreateWithData ( CFMutableDataRef data, - CFStringRef type, - size_t count, - CFDictionaryRef options) { - CGImageDestinationRef c; - return __cf_non_null_alloc(c); +CGImageDestinationRef CGImageDestinationCreateWithData( + CFMutableDataRef data, + CFStringRef type, + size_t count, + CFDictionaryRef options) { + CGImageDestinationRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGImageSource.c b/infer/models/objc/src/CoreGraphics/CGImageSource.c index 7db153b95..15402b384 100644 --- a/infer/models/objc/src/CoreGraphics/CGImageSource.c +++ b/infer/models/objc/src/CoreGraphics/CGImageSource.c @@ -14,31 +14,30 @@ CGImageSourceRef __cf_non_null_alloc(CGImageSourceRef); CGImageSourceRef __cf_alloc(CGImageSourceRef); void __objc_release_cf(CGImageSourceRef); -CGImageSourceRef CGImageSourceCreateWithData ( CFDataRef data, CFDictionaryRef options ) -{ - CGImageSourceRef c; - return __cf_non_null_alloc(c); +CGImageSourceRef CGImageSourceCreateWithData(CFDataRef data, + CFDictionaryRef options) { + CGImageSourceRef c; + return __cf_non_null_alloc(c); } -CGImageSourceRef CGImageSourceCreateWithDataProvider ( CGDataProviderRef provider, CFDictionaryRef options ) -{ - CGImageSourceRef c; - return __cf_non_null_alloc(c); +CGImageSourceRef CGImageSourceCreateWithDataProvider(CGDataProviderRef provider, + CFDictionaryRef options) { + CGImageSourceRef c; + return __cf_non_null_alloc(c); } -CGImageSourceRef CGImageSourceCreateWithURL ( CFURLRef url, CFDictionaryRef options ) -{ - CGImageSourceRef c; - return __cf_alloc(c); +CGImageSourceRef CGImageSourceCreateWithURL(CFURLRef url, + CFDictionaryRef options) { + CGImageSourceRef c; + return __cf_alloc(c); } -CGImageSourceRef CGImageSourceCreateIncremental ( CFDictionaryRef options ) -{ - CGImageSourceRef c; - return __cf_non_null_alloc(c); +CGImageSourceRef CGImageSourceCreateIncremental(CFDictionaryRef options) { + CGImageSourceRef c; + return __cf_non_null_alloc(c); } -void CGImageSourceRelease ( CGImageSourceRef image ) -{ - if (image) __objc_release_cf(image); +void CGImageSourceRelease(CGImageSourceRef image) { + if (image) + __objc_release_cf(image); } diff --git a/infer/models/objc/src/CoreGraphics/CGLayer.c b/infer/models/objc/src/CoreGraphics/CGLayer.c index 5d0882436..fc87dbede 100644 --- a/infer/models/objc/src/CoreGraphics/CGLayer.c +++ b/infer/models/objc/src/CoreGraphics/CGLayer.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGLayerRef); -void CGLayerRelease ( CGLayerRef layer ){ - if (layer) __objc_release_cf(layer); +void CGLayerRelease(CGLayerRef layer) { + if (layer) + __objc_release_cf(layer); } diff --git a/infer/models/objc/src/CoreGraphics/CGPDFContentStream.c b/infer/models/objc/src/CoreGraphics/CGPDFContentStream.c index 58126b57d..27b8fd39c 100644 --- a/infer/models/objc/src/CoreGraphics/CGPDFContentStream.c +++ b/infer/models/objc/src/CoreGraphics/CGPDFContentStream.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPDFContentStreamRef); -void CGPDFContentStreamRelease ( CGPDFContentStreamRef cs ) { - if (cs) __objc_release_cf(cs); +void CGPDFContentStreamRelease(CGPDFContentStreamRef cs) { + if (cs) + __objc_release_cf(cs); } diff --git a/infer/models/objc/src/CoreGraphics/CGPDFDocument.c b/infer/models/objc/src/CoreGraphics/CGPDFDocument.c index 32bd31fa6..8ce1e7538 100644 --- a/infer/models/objc/src/CoreGraphics/CGPDFDocument.c +++ b/infer/models/objc/src/CoreGraphics/CGPDFDocument.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPDFDocumentRef); -void CGPDFDocumentRelease ( CGPDFDocumentRef document ) { - if (document) __objc_release_cf(document); +void CGPDFDocumentRelease(CGPDFDocumentRef document) { + if (document) + __objc_release_cf(document); } diff --git a/infer/models/objc/src/CoreGraphics/CGPDFOperatorTable.c b/infer/models/objc/src/CoreGraphics/CGPDFOperatorTable.c index 03038c265..b0b2b4a2f 100644 --- a/infer/models/objc/src/CoreGraphics/CGPDFOperatorTable.c +++ b/infer/models/objc/src/CoreGraphics/CGPDFOperatorTable.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPDFOperatorTableRef); -void CGPDFOperatorTableRelease ( CGPDFOperatorTableRef table ) { - if (table) __objc_release_cf(table); +void CGPDFOperatorTableRelease(CGPDFOperatorTableRef table) { + if (table) + __objc_release_cf(table); } diff --git a/infer/models/objc/src/CoreGraphics/CGPDFPage.c b/infer/models/objc/src/CoreGraphics/CGPDFPage.c index 4fb3c4f98..c249d6b98 100644 --- a/infer/models/objc/src/CoreGraphics/CGPDFPage.c +++ b/infer/models/objc/src/CoreGraphics/CGPDFPage.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPDFPageRef); -void CGPDFPageRelease ( CGPDFPageRef page ) { - if (page) __objc_release_cf(page); +void CGPDFPageRelease(CGPDFPageRef page) { + if (page) + __objc_release_cf(page); } diff --git a/infer/models/objc/src/CoreGraphics/CGPDFScanner.c b/infer/models/objc/src/CoreGraphics/CGPDFScanner.c index 19e924fa0..1787a1ea0 100644 --- a/infer/models/objc/src/CoreGraphics/CGPDFScanner.c +++ b/infer/models/objc/src/CoreGraphics/CGPDFScanner.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPDFScannerRef); -void CGPDFScannerRelease ( CGPDFScannerRef scanner ) { - if (scanner) __objc_release_cf(scanner); +void CGPDFScannerRelease(CGPDFScannerRef scanner) { + if (scanner) + __objc_release_cf(scanner); } diff --git a/infer/models/objc/src/CoreGraphics/CGPath.c b/infer/models/objc/src/CoreGraphics/CGPath.c index 53eaf2446..74eec17ea 100644 --- a/infer/models/objc/src/CoreGraphics/CGPath.c +++ b/infer/models/objc/src/CoreGraphics/CGPath.c @@ -13,42 +13,43 @@ CGPathRef __cf_non_null_alloc(CGPathRef); void __objc_release_cf(CGPathRef); -CGMutablePathRef CGPathCreateMutable () { - CGMutablePathRef c; - return (CGMutablePathRef) __cf_non_null_alloc(c); +CGMutablePathRef CGPathCreateMutable() { + CGMutablePathRef c; + return (CGMutablePathRef)__cf_non_null_alloc(c); } -CGPathRef CGPathCreateWithRect ( CGRect rect, const CGAffineTransform *transform ) { - CGPathRef c; - return __cf_non_null_alloc(c); +CGPathRef CGPathCreateWithRect(CGRect rect, + const CGAffineTransform* transform) { + CGPathRef c; + return __cf_non_null_alloc(c); } -void CGPathRelease ( CGPathRef path ) { - if (path) __objc_release_cf(path); +void CGPathRelease(CGPathRef path) { + if (path) + __objc_release_cf(path); } - -CGPathRef CGPathCreateWithEllipseInRect ( CGRect rect, - const CGAffineTransform *transform ){ - CGPathRef c; - return __cf_non_null_alloc(c); +CGPathRef CGPathCreateWithEllipseInRect(CGRect rect, + const CGAffineTransform* transform) { + CGPathRef c; + return __cf_non_null_alloc(c); } -CGPathRef CGPathCreateCopy ( CGPathRef path ) { - CGPathRef c; - return __cf_non_null_alloc(c); +CGPathRef CGPathCreateCopy(CGPathRef path) { + CGPathRef c; + return __cf_non_null_alloc(c); } -CGPathRef CGPathCreateCopyByTransformingPath ( CGPathRef path, - const CGAffineTransform *transform ) { - CGPathRef c; - return __cf_non_null_alloc(c); +CGPathRef CGPathCreateCopyByTransformingPath( + CGPathRef path, const CGAffineTransform* transform) { + CGPathRef c; + return __cf_non_null_alloc(c); } -CGPathRef CGPathCreateWithRoundedRect ( CGRect rect, - CGFloat cornerWidth, - CGFloat cornerHeight, - const CGAffineTransform *transform) { - CGPathRef c; - return __cf_non_null_alloc(c); +CGPathRef CGPathCreateWithRoundedRect(CGRect rect, + CGFloat cornerWidth, + CGFloat cornerHeight, + const CGAffineTransform* transform) { + CGPathRef c; + return __cf_non_null_alloc(c); } diff --git a/infer/models/objc/src/CoreGraphics/CGPattern.c b/infer/models/objc/src/CoreGraphics/CGPattern.c index 14dd80156..cee7dad3f 100644 --- a/infer/models/objc/src/CoreGraphics/CGPattern.c +++ b/infer/models/objc/src/CoreGraphics/CGPattern.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGPatternRef); -void CGPatternRelease ( CGPatternRef pattern ) { - if (pattern) __objc_release_cf(pattern); +void CGPatternRelease(CGPatternRef pattern) { + if (pattern) + __objc_release_cf(pattern); } diff --git a/infer/models/objc/src/CoreGraphics/CGShading.c b/infer/models/objc/src/CoreGraphics/CGShading.c index 81fa29661..d7fd5d9c3 100644 --- a/infer/models/objc/src/CoreGraphics/CGShading.c +++ b/infer/models/objc/src/CoreGraphics/CGShading.c @@ -11,6 +11,7 @@ void __objc_release_cf(CGShadingRef); -void CGShadingRelease ( CGShadingRef shading ) { - if (shading) __objc_release_cf(shading); +void CGShadingRelease(CGShadingRef shading) { + if (shading) + __objc_release_cf(shading); } diff --git a/infer/models/objc/src/NSArray.m b/infer/models/objc/src/NSArray.m index 1a0099672..c73bdb125 100644 --- a/infer/models/objc/src/NSArray.m +++ b/infer/models/objc/src/NSArray.m @@ -12,7 +12,7 @@ @implementation NSArray + (instancetype)array { - return [NSArray alloc]; + return [NSArray alloc]; } @end diff --git a/infer/models/objc/src/NSAutoreleasePool.m b/infer/models/objc/src/NSAutoreleasePool.m index 5d4f9ade4..554c4a39f 100644 --- a/infer/models/objc/src/NSAutoreleasePool.m +++ b/infer/models/objc/src/NSAutoreleasePool.m @@ -7,18 +7,18 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - #pragma clang diagnostic ignored "-Wprotocol" +#pragma clang diagnostic ignored "-Wprotocol" - #pragma clang diagnostic ignored "-Wincomplete-implementation" +#pragma clang diagnostic ignored "-Wincomplete-implementation" - #pragma clang diagnostic ignored "-Wimplicit-function-declaration" +#pragma clang diagnostic ignored "-Wimplicit-function-declaration" - #import +#import - @implementation NSAutoreleasePool +@implementation NSAutoreleasePool - - (id)init { - return (id)[self autorelease]; - } +- (id)init { + return (id)[self autorelease]; +} - @end +@end diff --git a/infer/models/objc/src/NSData.m b/infer/models/objc/src/NSData.m index e67ac2e9e..23ae79056 100644 --- a/infer/models/objc/src/NSData.m +++ b/infer/models/objc/src/NSData.m @@ -14,30 +14,34 @@ NSData* __objc_alloc(NSData*); @interface NSData : NSObject -@property (nonatomic, readonly) const void *bytes; +@property(nonatomic, readonly) const void* bytes; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; ++ (instancetype)dataWithBytesNoCopy:(void*)bytes length:(NSUInteger)length; ++ (instancetype)dataWithBytesNoCopy:(void*)bytes + length:(NSUInteger)length + freeWhenDone:(BOOL)b; @end @implementation NSData -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length { - return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES]; ++ (instancetype)dataWithBytesNoCopy:(void*)bytes length:(NSUInteger)length { + return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES]; } -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b { - NSData* data = __objc_alloc(self); - if (data) { - data->_bytes = bytes; - return data; - } - else return nil; ++ (instancetype)dataWithBytesNoCopy:(void*)bytes + length:(NSUInteger)length + freeWhenDone:(BOOL)b { + NSData* data = __objc_alloc(self); + if (data) { + data->_bytes = bytes; + return data; + } else + return nil; } -- (void) dealloc { - if (self) - free(self->_bytes); +- (void)dealloc { + if (self) + free(self->_bytes); } @end diff --git a/infer/models/objc/src/NSDictionary.m b/infer/models/objc/src/NSDictionary.m index 338280526..f98cb5f61 100644 --- a/infer/models/objc/src/NSDictionary.m +++ b/infer/models/objc/src/NSDictionary.m @@ -16,7 +16,7 @@ @implementation NSDictionary + (instancetype)dictionary { - return [NSDictionary alloc]; + return [NSDictionary alloc]; } @end diff --git a/infer/models/objc/src/NSFileHandle.m b/infer/models/objc/src/NSFileHandle.m index af7743ad0..440bea034 100644 --- a/infer/models/objc/src/NSFileHandle.m +++ b/infer/models/objc/src/NSFileHandle.m @@ -20,29 +20,29 @@ - (instancetype)initWithFileDescriptor:(int)fd; -@property (nonatomic, readonly) int fileDescriptor; +@property(nonatomic, readonly) int fileDescriptor; @end @implementation NSFileHandle - (instancetype)initWithFileDescriptor:(int)fd closeOnDealloc:(BOOL)closeopt { - if (self) { - self->_fileDescriptor = fd; - return self; - } + if (self) { + self->_fileDescriptor = fd; + return self; + } } - (instancetype)initWithFileDescriptor:(int)fd { - [self initWithFileDescriptor:fd closeOnDealloc:NO]; + [self initWithFileDescriptor:fd closeOnDealloc:NO]; } - (void)closeFile { - close(self->_fileDescriptor); + close(self->_fileDescriptor); } - (void)dealloc { - [self closeFile]; + [self closeFile]; } @end diff --git a/infer/models/objc/src/NSMutableArray.m b/infer/models/objc/src/NSMutableArray.m index 35416a259..11c8c880d 100644 --- a/infer/models/objc/src/NSMutableArray.m +++ b/infer/models/objc/src/NSMutableArray.m @@ -16,23 +16,22 @@ @implementation NSMutableArray - (void)setObject:(id)anObject atIndexedSubscript:(NSUInteger)index { - NSObject *obj = (NSObject*)anObject; - id isa = obj->isa; + NSObject* obj = (NSObject*)anObject; + id isa = obj->isa; } - (void)addObject:(id)anObject { - NSObject *obj = (NSObject*)anObject; - id isa = obj->isa; + NSObject* obj = (NSObject*)anObject; + id isa = obj->isa; } - (void)insertObject:(id)anObject atIndex:(NSUInteger)index { - NSObject *obj = (NSObject*)anObject; - id isa = obj->isa; + NSObject* obj = (NSObject*)anObject; + id isa = obj->isa; } + (instancetype)array { - return [NSMutableArray alloc]; + return [NSMutableArray alloc]; } - @end diff --git a/infer/models/objc/src/NSMutableDictionary.m b/infer/models/objc/src/NSMutableDictionary.m index 5de97bafc..7bcccd98c 100644 --- a/infer/models/objc/src/NSMutableDictionary.m +++ b/infer/models/objc/src/NSMutableDictionary.m @@ -16,21 +16,21 @@ @implementation NSMutableDictionary - (void)setObject:(id)object forKeyedSubscript:(id)aKey { - NSObject *obj = (NSObject*)object; - id isa = obj->isa; - NSObject *key = (NSObject*)aKey; - id isa2 = key->isa; + NSObject* obj = (NSObject*)object; + id isa = obj->isa; + NSObject* key = (NSObject*)aKey; + id isa2 = key->isa; } - (void)setObject:(id)anObject forKey:(id)aKey { - NSObject *obj = (NSObject*)anObject; - id isa = obj->isa; - NSObject *key = (NSObject*)aKey; - id isa2 = key->isa; + NSObject* obj = (NSObject*)anObject; + id isa = obj->isa; + NSObject* key = (NSObject*)aKey; + id isa2 = key->isa; } + (instancetype)dictionary { - return [NSMutableDictionary alloc]; + return [NSMutableDictionary alloc]; } @end diff --git a/infer/models/objc/src/NSNotificationCenter.m b/infer/models/objc/src/NSNotificationCenter.m index e89e39804..26fc1867b 100644 --- a/infer/models/objc/src/NSNotificationCenter.m +++ b/infer/models/objc/src/NSNotificationCenter.m @@ -14,39 +14,35 @@ void __set_unsubscribed_observer_attribute(id); @interface NSNotificationCenter : NSObject -- (void) addObserver:(id)notificationObserver - selector:(SEL)notificationSelector - name:(NSString *)notificationName - object:(id)notificationSender; +- (void)addObserver:(id)notificationObserver + selector:(SEL)notificationSelector + name:(NSString*)notificationName + object:(id)notificationSender; -- (void) removeObserver:(id)notificationObserver; +- (void)removeObserver:(id)notificationObserver; -- (void) removeObserver:(id)notificationObserver - name:(NSString *)notificationName - object:(id)notificationSender; +- (void)removeObserver:(id)notificationObserver + name:(NSString*)notificationName + object:(id)notificationSender; @end @implementation NSNotificationCenter - -- (void) addObserver:(id)notificationObserver - selector:(SEL)notificationSelector - name:(NSString *)notificationName - object:(id)notificationSender -{ - __set_observer_attribute(notificationObserver); +- (void)addObserver:(id)notificationObserver + selector:(SEL)notificationSelector + name:(NSString*)notificationName + object:(id)notificationSender { + __set_observer_attribute(notificationObserver); } -- (void) removeObserver:(id)notificationObserver -{ - __set_unsubscribed_observer_attribute(notificationObserver); +- (void)removeObserver:(id)notificationObserver { + __set_unsubscribed_observer_attribute(notificationObserver); } -- (void) removeObserver:(id)notificationObserver - name:(NSString *)notificationName - object:(id)notificationSender -{ - __set_unsubscribed_observer_attribute(notificationObserver); +- (void)removeObserver:(id)notificationObserver + name:(NSString*)notificationName + object:(id)notificationSender { + __set_unsubscribed_observer_attribute(notificationObserver); } @end diff --git a/infer/models/objc/src/NSNumber.h b/infer/models/objc/src/NSNumber.h index 067c74cc8..705e58d18 100644 --- a/infer/models/objc/src/NSNumber.h +++ b/infer/models/objc/src/NSNumber.h @@ -10,7 +10,7 @@ #import @interface NSNumber : NSObject { - double value; + double value; } @end diff --git a/infer/models/objc/src/NSNumber.m b/infer/models/objc/src/NSNumber.m index d5ace34e1..476de3f22 100644 --- a/infer/models/objc/src/NSNumber.m +++ b/infer/models/objc/src/NSNumber.m @@ -9,51 +9,50 @@ #import "NSNumber.h" - @implementation NSNumber -+(NSNumber *)numberWithInt:(int)value { - // using alloc as the documentation doesn't say it may return nil - NSNumber *number = [self alloc]; - return [number initWithInt:value]; ++ (NSNumber*)numberWithInt:(int)value { + // using alloc as the documentation doesn't say it may return nil + NSNumber* number = [self alloc]; + return [number initWithInt:value]; } - (id)initWithInt:(int)v { - self->value = (double)v; - return self; + self->value = (double)v; + return self; } -+(NSNumber *)numberWithFloat:(float)value { - // using alloc as the documentation doesn't say it may return nil - NSNumber *number = [NSNumber alloc]; - return [number initWithInt:value]; ++ (NSNumber*)numberWithFloat:(float)value { + // using alloc as the documentation doesn't say it may return nil + NSNumber* number = [NSNumber alloc]; + return [number initWithInt:value]; } - (id)initWithFloat:(float)v { - self->value = (double)v; - return self; + self->value = (double)v; + return self; } -+(NSNumber *)numberWithDouble:(double)value { - // using alloc as the documentation doesn't say it may return nil - NSNumber *number = [self alloc]; - return [number initWithInt:value]; ++ (NSNumber*)numberWithDouble:(double)value { + // using alloc as the documentation doesn't say it may return nil + NSNumber* number = [self alloc]; + return [number initWithInt:value]; } - (id)initWithDouble:(double)v { - self->value = v; - return self; + self->value = v; + return self; } -+(NSNumber *)numberWithBool:(BOOL)value { - // using alloc as the documentation doesn't say it may return nil - NSNumber *number = [self alloc]; - return [number initWithBool:value]; ++ (NSNumber*)numberWithBool:(BOOL)value { + // using alloc as the documentation doesn't say it may return nil + NSNumber* number = [self alloc]; + return [number initWithBool:value]; } - (id)initWithBool:(BOOL)v { - self->value = (double)v; - return self; + self->value = (double)v; + return self; } @end diff --git a/infer/models/objc/src/NSObject.m b/infer/models/objc/src/NSObject.m index 54b8bdcf7..2a5926d75 100644 --- a/infer/models/objc/src/NSObject.m +++ b/infer/models/objc/src/NSObject.m @@ -18,6 +18,6 @@ @implementation NSObject - (id)init { - return (id)self; + return (id)self; } @end diff --git a/infer/models/objc/src/NSRunLoop.h b/infer/models/objc/src/NSRunLoop.h index 17613d68b..a41ece72a 100644 --- a/infer/models/objc/src/NSRunLoop.h +++ b/infer/models/objc/src/NSRunLoop.h @@ -7,39 +7,28 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - -#import #import - - +#import @class NSTimer; - - @interface NSRunLoop : NSObject -+ (NSRunLoop*) currentRunLoop; -+ (NSRunLoop*) mainRunLoop; ++ (NSRunLoop*)currentRunLoop; ++ (NSRunLoop*)mainRunLoop; +- (void)acceptInputForMode:(NSString*)mode beforeDate:(NSDate*)limit_date; -- (void) acceptInputForMode: (NSString*)mode - beforeDate: (NSDate*)limit_date; +- (void)addTimer:(NSTimer*)timer forMode:(NSString*)mode; -- (void) addTimer: (NSTimer*)timer - forMode: (NSString*)mode; +- (NSString*)currentMode; -- (NSString*) currentMode; +- (NSDate*)limitDateForMode:(NSString*)mode; -- (NSDate*) limitDateForMode: (NSString*)mode; +- (void)run; -- (void) run; +- (BOOL)runMode:(NSString*)mode beforeDate:(NSDate*)date; -- (BOOL) runMode: (NSString*)mode - beforeDate: (NSDate*)date; - -- (void) runUntilDate: (NSDate*)date; +- (void)runUntilDate:(NSDate*)date; @end - - diff --git a/infer/models/objc/src/NSRunLoop.m b/infer/models/objc/src/NSRunLoop.m index c80958ad9..e82a15ee3 100644 --- a/infer/models/objc/src/NSRunLoop.m +++ b/infer/models/objc/src/NSRunLoop.m @@ -7,50 +7,44 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - #import "NSRunLoop.h" -@implementation NSRunLoop +@implementation NSRunLoop -+ (NSRunLoop*) currentRunLoop { - - return [NSRunLoop alloc]; -}; ++ (NSRunLoop*)currentRunLoop { -+ (NSRunLoop*) mainRunLoop { - - return [NSRunLoop alloc]; + return [NSRunLoop alloc]; }; ++ (NSRunLoop*)mainRunLoop { -- (void) acceptInputForMode: (NSString*)mode - beforeDate: (NSDate*)limit_date { + return [NSRunLoop alloc]; }; -- (void) addTimer: (NSTimer*)timer - forMode: (NSString*)mode { - -}; +- (void)acceptInputForMode:(NSString*)mode beforeDate:(NSDate*)limit_date{}; + +- (void)addTimer:(NSTimer*)timer + forMode:(NSString*)mode{ -- (NSString*) currentMode { - return @""; + }; + +- (NSString*)currentMode { + return @""; }; -- (NSDate*) limitDateForMode: (NSString*)mode { - - return [NSDate alloc]; +- (NSDate*)limitDateForMode:(NSString*)mode { + + return [NSDate alloc]; }; -- (void) run {}; +- (void)run{}; -- (BOOL) runMode: (NSString*)mode - beforeDate: (NSDate*)date { - - int res; - return res; +- (BOOL)runMode:(NSString*)mode beforeDate:(NSDate*)date { + + int res; + return res; }; -- (void) runUntilDate: (NSDate*)date {}; +- (void)runUntilDate:(NSDate*)date{}; @end - diff --git a/infer/models/objc/src/NSString.h b/infer/models/objc/src/NSString.h index c5748f1d0..f4724e80f 100644 --- a/infer/models/objc/src/NSString.h +++ b/infer/models/objc/src/NSString.h @@ -10,9 +10,9 @@ #import @interface NSString : NSObject { - const char * value; + const char* value; } -+ (instancetype)stringWithUTF8String:(const char *)bytes; ++ (instancetype)stringWithUTF8String:(const char*)bytes; @end diff --git a/infer/models/objc/src/NSString.m b/infer/models/objc/src/NSString.m index 986f9aeed..309b9fafe 100644 --- a/infer/models/objc/src/NSString.m +++ b/infer/models/objc/src/NSString.m @@ -14,24 +14,23 @@ void __get_array_size(const UInt8); @implementation NSString -+ (instancetype)stringWithUTF8String:(const char *)bytes { - // using alloc as the documentation doesn't say it may return nil - NSString *s = [NSString alloc]; - s->value = bytes; - return s; ++ (instancetype)stringWithUTF8String:(const char*)bytes { + // using alloc as the documentation doesn't say it may return nil + NSString* s = [NSString alloc]; + s->value = bytes; + return s; } - (instancetype)initWithBytesNoCopy:(char*)bytes length:(NSUInteger)length encoding:(id)encoding freeWhenDone:(BOOL)flag { - if (flag == YES) { - if (bytes) { - __get_array_size(bytes); - free(bytes); - } - } - return self; - + if (flag == YES) { + if (bytes) { + __get_array_size(bytes); + free(bytes); + } + } + return self; } @end diff --git a/infer/models/objc/src/NSTimer.h b/infer/models/objc/src/NSTimer.h index 2a02362de..6109f8aad 100644 --- a/infer/models/objc/src/NSTimer.h +++ b/infer/models/objc/src/NSTimer.h @@ -11,49 +11,47 @@ @class NSInvocation; - -@interface NSTimer : NSObject -{ - NSTimeInterval _interval; - id _info; - id _target; - SEL _selector; - unsigned _repeats:2; - unsigned _timer_filler:6; -@public - NSDate *_fireDate; - BOOL _is_valid; +@interface NSTimer : NSObject { + NSTimeInterval _interval; + id _info; + id _target; + SEL _selector; + unsigned _repeats : 2; + unsigned _timer_filler : 6; + @public + NSDate* _fireDate; + BOOL _is_valid; } -+ (NSTimer *) scheduledTimerWithTimeInterval:(NSTimeInterval) ti - invocation:(NSInvocation *) invocation - repeats:(BOOL) f; -+ (NSTimer *) scheduledTimerWithTimeInterval:(NSTimeInterval) ti - target:(id) object - selector:(SEL) selector - userInfo:(id) info - repeats:(BOOL) f; -+ (NSTimer *) timerWithTimeInterval:(NSTimeInterval) ti - invocation:(NSInvocation *) invocation - repeats:(BOOL) f; -+ (NSTimer *) timerWithTimeInterval:(NSTimeInterval) ti - target:(id) object - selector:(SEL) selector - userInfo:(id) info - repeats:(BOOL) f; ++ (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti + invocation:(NSInvocation*)invocation + repeats:(BOOL)f; ++ (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti + target:(id)object + selector:(SEL)selector + userInfo:(id)info + repeats:(BOOL)f; ++ (NSTimer*)timerWithTimeInterval:(NSTimeInterval)ti + invocation:(NSInvocation*)invocation + repeats:(BOOL)f; ++ (NSTimer*)timerWithTimeInterval:(NSTimeInterval)ti + target:(id)object + selector:(SEL)selector + userInfo:(id)info + repeats:(BOOL)f; -- (void) fire; -- (NSDate *) fireDate; -- (id) initWithFireDate:(NSDate *) date - interval:(NSTimeInterval) seconds - target:(id) target - selector:(SEL) aSelector - userInfo:(id) userInfo - repeats:(BOOL) repeats; -- (void) invalidate; -- (BOOL) isValid; -- (void) setFireDate:(NSDate *) date; -- (NSTimeInterval) timeInterval; -- (id) userInfo; +- (void)fire; +- (NSDate*)fireDate; +- (id)initWithFireDate:(NSDate*)date + interval:(NSTimeInterval)seconds + target:(id)target + selector:(SEL)aSelector + userInfo:(id)userInfo + repeats:(BOOL)repeats; +- (void)invalidate; +- (BOOL)isValid; +- (void)setFireDate:(NSDate*)date; +- (NSTimeInterval)timeInterval; +- (id)userInfo; @end diff --git a/infer/models/objc/src/NSTimer.m b/infer/models/objc/src/NSTimer.m index 02bd45112..11b79eb43 100644 --- a/infer/models/objc/src/NSTimer.m +++ b/infer/models/objc/src/NSTimer.m @@ -13,132 +13,117 @@ // Note: we do not link timers to NSRunLoop as this is irrelevant for // our models. If at some point becomes important it needs to be changed. - -void free(void *ptr); +void free(void* ptr); @implementation NSTimer -+ (NSTimer*) timerWithTimeInterval:(NSTimeInterval)seconds - invocation:(NSInvocation *)invocation - repeats:(BOOL)f -{ - NSTimer *t = [self alloc]; - if(t) - { - t->_interval = seconds; - t->_fireDate = [NSDate alloc]; - t->_is_valid = YES; - t->_target = invocation; - t->_repeats = f; - } - return t; ++ (NSTimer*)timerWithTimeInterval:(NSTimeInterval)seconds + invocation:(NSInvocation*)invocation + repeats:(BOOL)f { + NSTimer* t = [self alloc]; + if (t) { + t->_interval = seconds; + t->_fireDate = [NSDate alloc]; + t->_is_valid = YES; + t->_target = invocation; + t->_repeats = f; + } + return t; } -+ (NSTimer*) timerWithTimeInterval:(NSTimeInterval)seconds - target:(id)object - selector:(SEL)selector - userInfo:(id)info - repeats:(BOOL)f -{ - NSDate *d = [NSDate alloc]; - return [[self alloc] initWithFireDate:d - interval:seconds - target:object - selector:selector - userInfo:info - repeats:f]; ++ (NSTimer*)timerWithTimeInterval:(NSTimeInterval)seconds + target:(id)object + selector:(SEL)selector + userInfo:(id)info + repeats:(BOOL)f { + NSDate* d = [NSDate alloc]; + return [[self alloc] initWithFireDate:d + interval:seconds + target:object + selector:selector + userInfo:info + repeats:f]; } -+ (NSTimer*) scheduledTimerWithTimeInterval:(NSTimeInterval)ti - invocation:(NSInvocation *)invocation - repeats:(BOOL)f -{ - NSTimer *t = [self timerWithTimeInterval:ti invocation:invocation repeats:f]; - return t; ++ (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti + invocation:(NSInvocation*)invocation + repeats:(BOOL)f { + NSTimer* t = [self timerWithTimeInterval:ti invocation:invocation repeats:f]; + return t; } -+ (NSTimer*) scheduledTimerWithTimeInterval:(NSTimeInterval)ti - target:(id)object - selector:(SEL)selector - userInfo:(id)info - repeats:(BOOL)f -{ - NSTimer *t = [self timerWithTimeInterval: ti - target: object - selector: selector - userInfo: info - repeats: f]; - return t; ++ (NSTimer*)scheduledTimerWithTimeInterval:(NSTimeInterval)ti + target:(id)object + selector:(SEL)selector + userInfo:(id)info + repeats:(BOOL)f { + NSTimer* t = [self timerWithTimeInterval:ti + target:object + selector:selector + userInfo:info + repeats:f]; + return t; } -- (id) initWithFireDate:(NSDate *) date - interval:(NSTimeInterval)seconds - target:(id)object - selector:(SEL)selector - userInfo:(id)info - repeats:(BOOL)f -{ - _interval = seconds; - _fireDate = date; - _is_valid = YES; - _selector = selector; - _target = object; - _info = info; - _repeats = f; - - return self; +- (id)initWithFireDate:(NSDate*)date + interval:(NSTimeInterval)seconds + target:(id)object + selector:(SEL)selector + userInfo:(id)info + repeats:(BOOL)f { + _interval = seconds; + _fireDate = date; + _is_valid = YES; + _selector = selector; + _target = object; + _info = info; + _repeats = f; + + return self; } -- (void) dealloc -{ - _fireDate=nil; - free(self); +- (void)dealloc { + _fireDate = nil; + free(self); } -- (NSString *) description; -{ - return [NSString alloc]; -} +- (NSString*)description; +{ return [NSString alloc]; } // Abstract everything except making the timer invalid if // cannot repeat -- (void) fire -{ - if(!_repeats) - _is_valid = NO; - } - -- (void) invalidate -{ +- (void)fire { + if (!_repeats) _is_valid = NO; } -- (BOOL) isValid { - return _is_valid; +- (void)invalidate { + _is_valid = NO; } -- (NSDate *) fireDate { - - return _fireDate; +- (BOOL)isValid { + return _is_valid; } -- (NSTimeInterval) timeInterval { - return _interval; +- (NSDate*)fireDate { + + return _fireDate; } -- (id) userInfo { - return _info; +- (NSTimeInterval)timeInterval { + return _interval; } -- (void) setFireDate:(NSDate *)date; -{ - _fireDate =date; +- (id)userInfo { + return _info; } -- (int) compare:(NSTimer*)anotherTimer -{ - int res; - return res; +- (void)setFireDate:(NSDate*)date; +{ _fireDate = date; } + +- (int)compare:(NSTimer*)anotherTimer { + int res; + return res; } @end diff --git a/infer/src/clang/plugin/InferPlugin.cpp b/infer/src/clang/plugin/InferPlugin.cpp index 6296abfc0..c9284044b 100644 --- a/infer/src/clang/plugin/InferPlugin.cpp +++ b/infer/src/clang/plugin/InferPlugin.cpp @@ -8,58 +8,57 @@ */ #include "clang/Frontend/FrontendPluginRegistry.h" -#include "clang/AST/ASTConsumer.h" #include "clang/AST/AST.h" +#include "clang/AST/ASTConsumer.h" #include "clang/Frontend/CompilerInstance.h" #include "llvm/Support/raw_ostream.h" using namespace clang; namespace { - class PrintFunctionsConsumer : public ASTConsumer { - public: - virtual bool HandleTopLevelDecl(DeclGroupRef DG) { - for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) { - const Decl *D = *i; - if (const NamedDecl *ND = dyn_cast(D)) - llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n"; - } - - return true; +class PrintFunctionsConsumer : public ASTConsumer { + public: + virtual bool HandleTopLevelDecl(DeclGroupRef DG) { + for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) { + const Decl* D = *i; + if (const NamedDecl* ND = dyn_cast(D)) + llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n"; } - }; - class PrintFunctionNamesAction : public PluginASTAction { - protected: - ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) { - return new PrintFunctionsConsumer(); - } + return true; + } +}; - bool ParseArgs(const CompilerInstance &CI, - const std::vector& args) { - for (unsigned i = 0, e = args.size(); i != e; ++i) { - llvm::errs() << "toplevel-plugin arg = " << args[i] << "\n"; +class PrintFunctionNamesAction : public PluginASTAction { + protected: + ASTConsumer* CreateASTConsumer(CompilerInstance& CI, llvm::StringRef) { + return new PrintFunctionsConsumer(); + } - // Example error handling. - if (args[i] == "-an-error") { - DiagnosticsEngine &D = CI.getDiagnostics(); - unsigned DiagID = D.getCustomDiagID( - DiagnosticsEngine::Error, "invalid argument '" + args[i] + "'"); - D.Report(DiagID); - return false; - } - } - if (args.size() && args[0] == "help") - PrintHelp(llvm::errs()); + bool ParseArgs(const CompilerInstance& CI, + const std::vector& args) { + for (unsigned i = 0, e = args.size(); i != e; ++i) { + llvm::errs() << "toplevel-plugin arg = " << args[i] << "\n"; - return true; - } - void PrintHelp(llvm::raw_ostream& ros) { - ros << "Help for toplevel-plugin plugin goes here\n"; + // Example error handling. + if (args[i] == "-an-error") { + DiagnosticsEngine& D = CI.getDiagnostics(); + unsigned DiagID = D.getCustomDiagID( + DiagnosticsEngine::Error, "invalid argument '" + args[i] + "'"); + D.Report(DiagID); + return false; + } } + if (args.size() && args[0] == "help") + PrintHelp(llvm::errs()); - }; - + return true; + } + void PrintHelp(llvm::raw_ostream& ros) { + ros << "Help for toplevel-plugin plugin goes here\n"; + } +}; } -static FrontendPluginRegistry::Add X("infer-plugin", "print function names"); +static FrontendPluginRegistry::Add X( + "infer-plugin", "print function names"); diff --git a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c index 010bfdd9e..b61e693b1 100644 --- a/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c +++ b/infer/tests/codetoanalyze/c/errors/assertions/assertion_failure.c @@ -7,12 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include #include +#include -void simple_check(int x) { - assert(x < 3); -} +void simple_check(int x) { assert(x < 3); } void simple_assertion_failure() { int x = 4; @@ -24,16 +22,12 @@ void no_assertion_failure() { simple_check(x); } -typedef struct { - int value; -} node; +typedef struct { int value; } node; -void check_node(node *n) { - assert(n->value < 3); -} +void check_node(node* n) { assert(n->value < 3); } node* assertion_failure_with_heap() { - node *n = malloc(sizeof(node)); + node* n = malloc(sizeof(node)); if (n != NULL) { n->value = 4; check_node(n); @@ -42,7 +36,7 @@ node* assertion_failure_with_heap() { } node* no_assertion_failure_with_heap() { - node *n = malloc(sizeof(node)); + node* n = malloc(sizeof(node)); if (n != NULL) { n->value = 2; check_node(n); @@ -58,9 +52,7 @@ void my_assert(int x) { } } -void should_not_report_assertion_failure(int x) { - my_assert(x); -} +void should_not_report_assertion_failure(int x) { my_assert(x); } void should_report_assertion_failure(int x) { x = 0; @@ -69,9 +61,7 @@ void should_report_assertion_failure(int x) { int global; -void check_global() { - assert(global != 0); -} +void check_global() { assert(global != 0); } void skip() {} diff --git a/infer/tests/codetoanalyze/c/errors/attributes/sentinel.c b/infer/tests/codetoanalyze/c/errors/attributes/sentinel.c index 0d0d98269..0b231f101 100644 --- a/infer/tests/codetoanalyze/c/errors/attributes/sentinel.c +++ b/infer/tests/codetoanalyze/c/errors/attributes/sentinel.c @@ -11,14 +11,14 @@ extern int add_all_ints(int x, int y, int z, ...) __attribute__((sentinel)); -void valid_call(int *a, int *b, int *c) { +void valid_call(int* a, int* b, int* c) { // fine int x = add_all_ints(0, 0, 0, a, b, c, NULL); } void truncated_call(void) { int a = 0, b = 1, c = 2, d = 3; - int *p = NULL; + int* p = NULL; // warning: p is NULL so only first argument sent to add_all_ints int x = add_all_ints(0, 0, 0, &a, p, &b, &c, &d, NULL); diff --git a/infer/tests/codetoanalyze/c/errors/custom_error/custom.c b/infer/tests/codetoanalyze/c/errors/custom_error/custom.c index 526e18f5c..4e266c3fe 100644 --- a/infer/tests/codetoanalyze/c/errors/custom_error/custom.c +++ b/infer/tests/codetoanalyze/c/errors/custom_error/custom.c @@ -12,7 +12,8 @@ void __infer_fail(char*); void check_exponent(int x) { - if (x < 0) __infer_fail("UNEXPECTED_NEGATIVE_EXPONENT"); + if (x < 0) + __infer_fail("UNEXPECTED_NEGATIVE_EXPONENT"); } int power(int x) { @@ -32,9 +33,7 @@ int paf() { int global; -void set_global() { - global = -2; -} +void set_global() { global = -2; } int pouf() { set_global(); diff --git a/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c b/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c index 07d834123..3e84f89fb 100644 --- a/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c +++ b/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c @@ -10,32 +10,32 @@ #include #include -int *set42(int* x) { - *x = 42; - return x; +int* set42(int* x) { + *x = 42; + return x; } -void nodpd () { - int w,*z; - z = set42(&w); +void nodpd() { + int w, *z; + z = set42(&w); } -void nodpd1 () { - int *y = malloc(sizeof(int)); - int *z; - z = set42(y); - free(y); +void nodpd1() { + int* y = malloc(sizeof(int)); + int* z; + z = set42(y); + free(y); } -void dpd () { - int *y; - int *z; - z = set42(y); +void dpd() { + int* y; + int* z; + z = set42(y); } -void intraprocdpd () { - int *y; - int *z; - *y = 42; - z = y; +void intraprocdpd() { + int* y; + int* z; + *y = 42; + z = y; } diff --git a/infer/tests/codetoanalyze/c/errors/initialization/compound_literal.c b/infer/tests/codetoanalyze/c/errors/initialization/compound_literal.c index 3ea4f50d2..eb1eab221 100644 --- a/infer/tests/codetoanalyze/c/errors/initialization/compound_literal.c +++ b/infer/tests/codetoanalyze/c/errors/initialization/compound_literal.c @@ -12,10 +12,6 @@ struct point { int y; }; -int return_zero() { - return ((struct point) { .y = 32, .x = 0 }).x; -} +int return_zero() { return ((struct point){.y = 32, .x = 0}).x; } -int divide_by_zero() { - return 1/return_zero(); -} +int divide_by_zero() { return 1 / return_zero(); } diff --git a/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c b/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c index 9d74f18f2..aa3934333 100644 --- a/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c +++ b/infer/tests/codetoanalyze/c/errors/initialization/initlistexpr.c @@ -8,6 +8,6 @@ */ int init_divide_by_zero() { - int t[2][3][2] = {{{1,1},{2,2},{3,3}},{{4,4},{5,5},{1,0}}}; - return t[0][1][0]/t[1][2][1]; + int t[2][3][2] = {{{1, 1}, {2, 2}, {3, 3}}, {{4, 4}, {5, 5}, {1, 0}}}; + return t[0][1][0] / t[1][2][1]; } diff --git a/infer/tests/codetoanalyze/c/errors/lists/lists.c b/infer/tests/codetoanalyze/c/errors/lists/lists.c index 755c28c68..e05fd485b 100644 --- a/infer/tests/codetoanalyze/c/errors/lists/lists.c +++ b/infer/tests/codetoanalyze/c/errors/lists/lists.c @@ -8,20 +8,20 @@ */ struct l2 { - int b; - struct l2 *a; + int b; + struct l2* a; }; -int add2(struct l2 *l) { - int r = 0; - for (; l; l = l->a) { - r += l->b; - } - return r; +int add2(struct l2* l) { + int r = 0; + for (; l; l = l->a) { + r += l->b; + } + return r; } /* Divide by zero error shows that we get a spec for add2 */ int main() { - int res = add2(0); - return 5/res; + int res = add2(0); + return 5 / res; } diff --git a/infer/tests/codetoanalyze/c/errors/local_vars/local_vars.c b/infer/tests/codetoanalyze/c/errors/local_vars/local_vars.c index 0ed200538..20e081c12 100644 --- a/infer/tests/codetoanalyze/c/errors/local_vars/local_vars.c +++ b/infer/tests/codetoanalyze/c/errors/local_vars/local_vars.c @@ -7,40 +7,45 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - int m(int z) { - int y = 0; - int x = 5; - if (z < 10) { - int x = 7; - if (x == 7) return x/y; - } - if (x == 5) - return x/y; - else return 0; + int y = 0; + int x = 5; + if (z < 10) { + int x = 7; + if (x == 7) + return x / y; + } + if (x == 5) + return x / y; + else + return 0; } int mm() { - int y = 0; - int x = 0; - { - int x = 5; - if (x == 5) return x/y; - } - if (x == 0) - return x/y; - else return 0; + int y = 0; + int x = 0; + { + int x = 5; + if (x == 5) + return x / y; + } + if (x == 0) + return x / y; + else + return 0; } int t() { - int y = 0; - int x = 1; - int z = 0; + int y = 0; + int x = 1; + int z = 0; - for (int x = 0; x < 10; x++) { - int x = 9; - if (x == 9) return x/y; - else return 0; - } - return 0; + for (int x = 0; x < 10; x++) { + int x = 9; + if (x == 9) + return x / y; + else + return 0; + } + return 0; } diff --git a/infer/tests/codetoanalyze/c/errors/memory_leaks/test.c b/infer/tests/codetoanalyze/c/errors/memory_leaks/test.c index 97b61bac1..2e719a6b4 100644 --- a/infer/tests/codetoanalyze/c/errors/memory_leaks/test.c +++ b/infer/tests/codetoanalyze/c/errors/memory_leaks/test.c @@ -11,32 +11,31 @@ #include void simple_leak() { - int *p; - p = (int*) malloc(sizeof(int)); + int* p; + p = (int*)malloc(sizeof(int)); } void common_realloc_leak() { int *p, *q; - p = (int*) malloc(sizeof(int)); - q = (int*) realloc(p, sizeof(int) * 42); + p = (int*)malloc(sizeof(int)); + q = (int*)realloc(p, sizeof(int) * 42); // if realloc fails, then p becomes unreachable - if (q != NULL) free(q); + if (q != NULL) + free(q); } int* allocate() { - int *p = NULL; + int* p = NULL; do { - p = (int*) malloc(sizeof(int)); + p = (int*)malloc(sizeof(int)); } while (p == NULL); return p; } void uses_allocator() { - int *p; + int* p; p = allocate(); *p = 42; } -void * builtin_no_leak(size_t s) { - return memset(malloc(s), 0, s); -} +void* builtin_no_leak(size_t s) { return memset(malloc(s), 0, s); } diff --git a/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c b/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c index 8d5e2a413..fc139858d 100644 --- a/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c +++ b/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c @@ -13,17 +13,17 @@ struct delicious { int yum; }; -struct delicious *bake(struct delicious **cake) { - int *zero = NULL; +struct delicious* bake(struct delicious** cake) { + int* zero = NULL; *zero = 3; return NULL; } -struct delicious *skip_function_with_no_spec(void) { - struct delicious *cake = NULL; +struct delicious* skip_function_with_no_spec(void) { + struct delicious* cake = NULL; int i; - if(bake(&cake) == NULL) { + if (bake(&cake) == NULL) { return 0; } @@ -31,17 +31,17 @@ struct delicious *skip_function_with_no_spec(void) { return cake; } -extern struct delicious *bakery(struct delicious **cake); -extern struct delicious *bakery2(struct delicious **cake, - struct delicious **pie); -extern struct delicious *returnPassByRef(); -extern void skip(struct delicious * s); +extern struct delicious* bakery(struct delicious** cake); +extern struct delicious* bakery2(struct delicious** cake, + struct delicious** pie); +extern struct delicious* returnPassByRef(); +extern void skip(struct delicious* s); -struct delicious *skip_external_function(void) { - struct delicious *cake = NULL; +struct delicious* skip_external_function(void) { + struct delicious* cake = NULL; int i; - if(bakery(&cake) == NULL) { + if (bakery(&cake) == NULL) { return 0; } @@ -49,9 +49,9 @@ struct delicious *skip_external_function(void) { return cake; } -void by_ref_actual_already_in_footprint(struct delicious *param) { +void by_ref_actual_already_in_footprint(struct delicious* param) { int i; - struct delicious * ret = bakery(¶m); + struct delicious* ret = bakery(¶m); i = param->yum; } @@ -59,11 +59,11 @@ void call_by_ref_actual_already_in_footprint_ok() { by_ref_actual_already_in_footprint(NULL); // should not report a warning } -void by_ref_actual_already_in_footprint2(struct delicious *param) { +void by_ref_actual_already_in_footprint2(struct delicious* param) { int i; - i = param->yum; // should not report a warning - struct delicious * ret = bakery(¶m); - i = param->yum; // should not report a warning + i = param->yum; // should not report a warning + struct delicious* ret = bakery(¶m); + i = param->yum; // should not report a warning } void call_by_ref_actual_already_in_footprint_bad() { @@ -71,20 +71,20 @@ void call_by_ref_actual_already_in_footprint_bad() { } void passByRefTwice() { - struct delicious *param; + struct delicious* param; bakery2(¶m, ¶m); // should not report a warning int i = param->yum; } -struct delicious * returnPassByRef2() { - struct delicious *param = NULL; +struct delicious* returnPassByRef2() { + struct delicious* param = NULL; bakery(¶m); int i = param->yum; // should not report a warning return param; } void returnPassByRefDeref() { - struct delicious *ret = returnPassByRef(); + struct delicious* ret = returnPassByRef(); ret->yum = 2; // should not report a warning free(ret); } diff --git a/infer/tests/codetoanalyze/c/errors/null_dereference/getc.c b/infer/tests/codetoanalyze/c/errors/null_dereference/getc.c index 1c4f70e3f..3facf6c08 100644 --- a/infer/tests/codetoanalyze/c/errors/null_dereference/getc.c +++ b/infer/tests/codetoanalyze/c/errors/null_dereference/getc.c @@ -11,392 +11,338 @@ #include void crash_getc() { - FILE *f; - int i; - f = fopen("this_file_doesnt_exist", "r"); + FILE* f; + int i; + f = fopen("this_file_doesnt_exist", "r"); + i = getc(f); + printf("i =%i\n", i); + fclose(f); +} + +void nocrash_getc() { + FILE* f; + int i; + f = fopen("this_file_doesnt_exist", "r"); + if (f) { i = getc(f); printf("i =%i\n", i); fclose(f); + } } -void nocrash_getc() { - FILE *f; - int i; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - i = getc(f); - printf("i =%i\n", i); - fclose(f); - } +void crash_fgetc() { + FILE* f; + int i; + f = fopen("this_file_doesnt_exist", "r"); + i = fgetc(f); + printf("i =%i\n", i); + fclose(f); } -void crash_fgetc() { - FILE *f; - int i; - f = fopen("this_file_doesnt_exist", "r"); +void nocrash_fgetc() { + FILE* f; + int i; + f = fopen("this_file_doesnt_exist", "r"); + if (f) { i = fgetc(f); printf("i =%i\n", i); fclose(f); + } } -void nocrash_fgetc() { - FILE *f; - int i; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - i = fgetc(f); - printf("i =%i\n", i); - fclose(f); - } -} +void crash_ungetc() { + FILE* f; + f = fopen("this_file_doesnt_exist", "r"); -void crash_ungetc() -{ - FILE *f; + int i = ungetc(10, f); + fclose(f); +} - f = fopen("this_file_doesnt_exist", "r"); +void nocrash_ungetc() { + FILE* f; - int i =ungetc(10,f); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + int i = ungetc(10, f); fclose(f); - + } } -void nocrash_ungetc() -{ - FILE *f; +void crash_fputs() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - int i =ungetc(10,f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fputs("blablabla", f); + fclose(f); } -void crash_fputs() -{ - FILE *f; +void nocrash_fputs() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { fputs("blablabla", f); fclose(f); - + } } -void nocrash_fputs() -{ - FILE *f; +void crash_fputc() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fputs("blablabla", f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fputc(42, f); + fclose(f); } -void crash_fputc() -{ - FILE *f; +void nocrash_fputc() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { fputc(42, f); fclose(f); - + } } -void nocrash_fputc() -{ - FILE *f; +void crash_putc() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fputc(42, f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + putc(42, f); + fclose(f); } -void crash_putc() -{ - FILE *f; +void nocrash_putc() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { putc(42, f); fclose(f); - + } } -void nocrash_putc() -{ - FILE *f; +void crash_fseeks() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - putc(42, f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fseek(f, 7, SEEK_SET); + fclose(f); } -void crash_fseeks() -{ - FILE *f; +void nocrash_fseek() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - fseek( f, 7, SEEK_SET ); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + fseek(f, 7, SEEK_SET); fclose(f); - + } } -void nocrash_fseek() -{ - FILE *f; +void crash_ftell() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fseek( f, 7, SEEK_SET ); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + ftell(f); + fclose(f); } -void crash_ftell() -{ - FILE *f; +void nocrash_ftell() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { ftell(f); fclose(f); - + } } -void nocrash_ftell() -{ - FILE *f; +void crash_fgets() { + FILE* f; + char str[60]; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - ftell( f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fgets(str, 60, f); + fclose(f); } -void crash_fgets() -{ - FILE *f; - char str[60]; +void nocrash_fgets() { + FILE* f; + char str[60]; - f = fopen("this_file_doesnt_exist", "r"); - fgets(str,60, f); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + fgets(str, 60, f); fclose(f); - + } } -void nocrash_fgets() -{ - FILE *f; - char str[60]; +void crash_rewind() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fgets(str,60, f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + rewind(f); + fclose(f); } +void nocrash_rewind() { + FILE* f; -void crash_rewind() -{ - FILE *f; - - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { rewind(f); fclose(f); - + } } -void nocrash_rewind() -{ - FILE *f; +void crash_fileno() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - rewind( f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fileno(f); + fclose(f); } -void crash_fileno() -{ - FILE *f; +void nocrash_fileno() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { fileno(f); fclose(f); - + } } -void nocrash_fileno() -{ - FILE *f; +void crash_clearerr() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fileno( f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + clearerr(f); + fclose(f); } +void nocrash_clearerr() { + FILE* f; -void crash_clearerr() -{ - FILE *f; - - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { clearerr(f); fclose(f); - + } } -void nocrash_clearerr() -{ - FILE *f; +void crash_ferror() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - clearerr( f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + ferror(f); + fclose(f); } -void crash_ferror() -{ - FILE *f; +void nocrash_ferror() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { ferror(f); fclose(f); - + } } -void nocrash_ferror() -{ - FILE *f; +void crash_feof() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - ferror( f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + feof(f); + fclose(f); } -void crash_feof() -{ - FILE *f; +void nocrash_feof() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { feof(f); fclose(f); - + } } -void nocrash_feof() -{ - FILE *f; +void crash_fprintf() { + FILE* f; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - feof(f); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fprintf(f, "blablabla\n"); + fclose(f); } +void nocrash_fprintf() { + FILE* f; - -void crash_fprintf() -{ - FILE *f; - - f = fopen("this_file_doesnt_exist", "r"); - fprintf(f,"blablabla\n"); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + fprintf(f, "blablabla\n"); fclose(f); - + } } -void nocrash_fprintf() -{ - FILE *f; +void crash_vfprintf() { + FILE* f; + va_list arg; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fprintf(f,"blablabla\n"); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + vfprintf(f, "blablabla\n", arg); + fclose(f); } -void crash_vfprintf() -{ - FILE *f; - va_list arg; +void nocrash_vfprintf() { + FILE* f; + va_list arg; - f = fopen("this_file_doesnt_exist", "r"); - vfprintf(f,"blablabla\n",arg); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + vfprintf(f, "blablabla\n", arg); fclose(f); - + } } -void nocrash_vfprintf() -{ - FILE *f; - va_list arg; +void crash_fgetpos() { + FILE* f; + fpos_t position; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - vfprintf(f,"blablabla\n",arg); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fgetpos(f, &position); + fclose(f); } +void nocrash_fgetpos() { + FILE* f; + fpos_t position; -void crash_fgetpos() -{ - FILE *f; - fpos_t position; - - f = fopen("this_file_doesnt_exist", "r"); - fgetpos(f,&position); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + fgetpos(f, &position); fclose(f); - + } } -void nocrash_fgetpos() -{ - FILE *f; - fpos_t position; +void crash_fsetpos() { + FILE* f; + fpos_t position; - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fgetpos(f,&position); - fclose(f); - } + f = fopen("this_file_doesnt_exist", "r"); + fsetpos(f, &position); + fclose(f); } -void crash_fsetpos() -{ - FILE *f; - fpos_t position; +void nocrash_fsetpos() { + FILE* f; + fpos_t position; - f = fopen("this_file_doesnt_exist", "r"); - fsetpos(f,&position); + f = fopen("this_file_doesnt_exist", "r"); + if (f) { + fsetpos(f, &position); fclose(f); - -} - -void nocrash_fsetpos() -{ - FILE *f; - fpos_t position; - - f = fopen("this_file_doesnt_exist", "r"); - if (f) { - fsetpos(f,&position); - fclose(f); - } + } } diff --git a/infer/tests/codetoanalyze/c/errors/null_dereference/null_pointer_dereference.c b/infer/tests/codetoanalyze/c/errors/null_dereference/null_pointer_dereference.c index ebfab1753..76aab269c 100644 --- a/infer/tests/codetoanalyze/c/errors/null_dereference/null_pointer_dereference.c +++ b/infer/tests/codetoanalyze/c/errors/null_dereference/null_pointer_dereference.c @@ -16,90 +16,86 @@ struct Person { }; int simple_null_pointer() { - struct Person *max = 0; + struct Person* max = 0; return max->age; } -struct Person *Person_create(int age, int height, int weight) { - struct Person *who = 0; +struct Person* Person_create(int age, int height, int weight) { + struct Person* who = 0; return who; } -int get_age(struct Person *who) { - return who->age; -} +int get_age(struct Person* who) { return who->age; } int null_pointer_interproc() { - struct Person *joe = Person_create(32, 64, 140); + struct Person* joe = Person_create(32, 64, 140); return get_age(joe); } int negation_in_conditional() { - int *x = 0; - if (!x) return 0; - else return *x; // this never happens + int* x = 0; + if (!x) + return 0; + else + return *x; // this never happens } -int * foo() { - return 0; -} +int* foo() { return 0; } void null_pointer_with_function_pointer() { - int * (*fp)(); + int* (*fp)(); fp = foo; - int *x = fp(); + int* x = fp(); *x = 3; } -void use_exit (struct Person *htbl) { - if (!htbl) - exit(0); - int x = htbl->age; +void use_exit(struct Person* htbl) { + if (!htbl) + exit(0); + int x = htbl->age; } void basic_null_dereference() { - int *p = NULL; + int* p = NULL; *p = 42; // NULL dereference } void no_check_for_null_after_malloc() { - int *p; - p = (int*) malloc(sizeof(int)); + int* p; + p = (int*)malloc(sizeof(int)); *p = 42; // NULL dereference free(p); } void no_check_for_null_after_realloc() { - int *p; - p = (int*) malloc(sizeof(int) * 5); + int* p; + p = (int*)malloc(sizeof(int) * 5); if (p) { p[3] = 42; } - int *q = (int*) realloc(p, sizeof(int) * 10); + int* q = (int*)realloc(p, sizeof(int) * 10); if (!q) free(p); - q[7] = 0; // NULL dereference + q[7] = 0; // NULL dereference free(q); } -void assign(int *p, int n) { - *p = n; -} +void assign(int* p, int n) { *p = n; } void potentially_null_pointer_passed_as_argument() { - int *p = NULL; - p = (int*) malloc(sizeof(int)); - assign(p, 42); // NULL dereference + int* p = NULL; + p = (int*)malloc(sizeof(int)); + assign(p, 42); // NULL dereference free(p); } void null_passed_as_argument() { - assign(NULL, 42); // NULL dereference + assign(NULL, 42); // NULL dereference } void allocated_pointer_passed_as_argument() { - int *p = NULL; - p = (int*) malloc(sizeof(int)); + int* p = NULL; + p = (int*)malloc(sizeof(int)); if (p) { assign(p, 42); free(p); @@ -107,28 +103,28 @@ void allocated_pointer_passed_as_argument() { } int* unsafe_allocate() { - int *p = NULL; - p = (int*) malloc(sizeof(int)); + int* p = NULL; + p = (int*)malloc(sizeof(int)); return p; } int* safe_allocate() { - int *p = NULL; + int* p = NULL; while (!p) { - p = (int*) malloc(sizeof(int)); + p = (int*)malloc(sizeof(int)); } return p; } void function_call_can_return_null_pointer() { - int *p = NULL; + int* p = NULL; p = unsafe_allocate(); - assign(p, 42); // NULL dereference + assign(p, 42); // NULL dereference free(p); } void function_call_returns_allocated_pointer() { - int *p = NULL; + int* p = NULL; p = safe_allocate(); assign(p, 42); free(p); diff --git a/infer/tests/codetoanalyze/c/errors/resource_leaks/leak.c b/infer/tests/codetoanalyze/c/errors/resource_leaks/leak.c index cae56e1be..55caa574e 100644 --- a/infer/tests/codetoanalyze/c/errors/resource_leaks/leak.c +++ b/infer/tests/codetoanalyze/c/errors/resource_leaks/leak.c @@ -14,72 +14,69 @@ #include #include #include -#include -#include #include #include +#include +#include #include - -void fileNotClosed() -{ - int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fd != -1) { - char buffer[256]; - // We can easily batch that by separating with space - write(fd, buffer, strlen(buffer)); - } +void fileNotClosed() { + int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd != -1) { + char buffer[256]; + // We can easily batch that by separating with space + write(fd, buffer, strlen(buffer)); + } } -void fileClosed() -{ - int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fd != -1) { - char buffer[256]; - // We can easily batch that by separating with space - write(fd, buffer, strlen(buffer)); - close(fd); - } +void fileClosed() { + int fd = open("hi.txt", O_WRONLY | O_CREAT | O_TRUNC, 0600); + if (fd != -1) { + char buffer[256]; + // We can easily batch that by separating with space + write(fd, buffer, strlen(buffer)); + close(fd); + } } -void socketNotClosed() -{ - int fd = socket(AF_LOCAL, SOCK_RAW, 0); - if (fd != -1) { - char buffer[256]; - // We can easily batch that by separating with space - write(fd, buffer, strlen(buffer)); - } +void socketNotClosed() { + int fd = socket(AF_LOCAL, SOCK_RAW, 0); + if (fd != -1) { + char buffer[256]; + // We can easily batch that by separating with space + write(fd, buffer, strlen(buffer)); + } } -int socketClosed() -{ - int socketFD = socket(AF_LOCAL, SOCK_RAW, 0); - if (socketFD == -1) { - return -1; - } +int socketClosed() { + int socketFD = socket(AF_LOCAL, SOCK_RAW, 0); + if (socketFD == -1) { + return -1; + } - int status; + int status; - status = fcntl(socketFD, F_SETFL, O_NONBLOCK); - if (status == -1) { - close(socketFD); - return -1; - } + status = fcntl(socketFD, F_SETFL, O_NONBLOCK); + if (status == -1) { + close(socketFD); + return -1; + } - int reuseaddr = 1; - status = setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)); - if (status == -1) { - close(socketFD); - return -1; - } + int reuseaddr = 1; + status = setsockopt( + socketFD, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)); + if (status == -1) { + close(socketFD); + return -1; + } - int nosigpipe = 1; - status = setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &nosigpipe, sizeof(nosigpipe)); - if (status == -1) { - close(socketFD); - return -1; - } + int nosigpipe = 1; + status = setsockopt( + socketFD, SOL_SOCKET, SO_REUSEADDR, &nosigpipe, sizeof(nosigpipe)); + if (status == -1) { + close(socketFD); + return -1; + } - return socketFD; + return socketFD; } diff --git a/infer/tests/codetoanalyze/c/frontend/arithmetic/int_const.c b/infer/tests/codetoanalyze/c/frontend/arithmetic/int_const.c index 081dabb46..781344016 100644 --- a/infer/tests/codetoanalyze/c/frontend/arithmetic/int_const.c +++ b/infer/tests/codetoanalyze/c/frontend/arithmetic/int_const.c @@ -9,15 +9,15 @@ int main() { -int volatile a; -int *volatile b; -float *const c; -long double d; + int volatile a; + int* volatile b; + float* const c; + long double d; - static const int kDuration = 3; + static const int kDuration = 3; - int large_int = 9223372036854775807; - int overflow_int = 9223372036854775808; + int large_int = 9223372036854775807; + int overflow_int = 9223372036854775808; - return 0; + return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/arithmetic/unary.c b/infer/tests/codetoanalyze/c/frontend/arithmetic/unary.c index f8df85d4e..55b3d8527 100644 --- a/infer/tests/codetoanalyze/c/frontend/arithmetic/unary.c +++ b/infer/tests/codetoanalyze/c/frontend/arithmetic/unary.c @@ -22,10 +22,10 @@ int main() { y = x--; int a; - int *b; + int* b; b = &a; - a = *(b+1); + a = *(b + 1); *b = *b + 1; a = *(&a); diff --git a/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c b/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c index a27bbd12b..96ef5303c 100644 --- a/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c +++ b/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c @@ -9,6 +9,4 @@ #include -bool revert(bool e) { - return e; -} +bool revert(bool e) { return e; } diff --git a/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c.dot b/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c.dot index c25623458..3d14c2f66 100644 --- a/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/booleans/bool_example.c.dot @@ -1,5 +1,5 @@ digraph iCFG { -3 [label="3: Return Stmt \n n$0=*&e:_Bool [line 13]\n *&return:_Bool =n$0 [line 13]\n REMOVE_TEMPS(n$0); [line 13]\n NULLIFY(&e,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&e:_Bool [line 12]\n *&return:_Bool =n$0 [line 12]\n REMOVE_TEMPS(n$0); [line 12]\n NULLIFY(&e,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c b/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c index 15ed0e1a9..db0099188 100644 --- a/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c +++ b/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c @@ -7,10 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -void check(int x) { -} +void check(int x) {} void main() { - int x = 3; - check(x<2); + int x = 3; + check(x < 2); } diff --git a/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c.dot b/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c.dot index 841d8cbe1..6685bb64a 100644 --- a/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/booleans/condition_as_param.c.dot @@ -1,16 +1,16 @@ digraph iCFG { -6 [label="6: DeclStmt \n *&x:int =3 [line 14]\n " shape="box"] +6 [label="6: DeclStmt \n *&x:int =3 [line 13]\n " shape="box"] 6 -> 5 ; -5 [label="5: Call _fun_check \n n$0=*&x:int [line 15]\n _fun_check((n$0 < 2):int ) [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&x,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +5 [label="5: Call _fun_check \n n$0=*&x:int [line 14]\n _fun_check((n$0 < 2):int ) [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n NULLIFY(&x,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 5 -> 4 ; 4 [label="4: Exit main \n " color=yellow style=filled] -3 [label="3: Start main\nFormals: \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 13]\n NULLIFY(&x,false); [line 13]\n " color=yellow style=filled] +3 [label="3: Start main\nFormals: \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 12]\n NULLIFY(&x,false); [line 12]\n " color=yellow style=filled] 3 -> 6 ; diff --git a/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c b/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c index 34319cb52..aca7007fd 100644 --- a/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c +++ b/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c @@ -12,16 +12,14 @@ to be used before it is defined. */ -int sum (int, int); +int sum(int, int); -int main (void) { - int total; +int main(void) { + int total; - total = sum (2, 3); + total = sum(2, 3); - return 0; + return 0; } -int sum (int a, int b) { - return a + b; -} +int sum(int a, int b) { return a + b; } diff --git a/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c.dot b/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c.dot index b24956c5b..bbd892ab9 100644 --- a/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/c_prototype/prototype.c.dot @@ -1,5 +1,5 @@ digraph iCFG { -7 [label="7: Return Stmt \n n$0=*&a:int [line 26]\n n$1=*&b:int [line 26]\n *&return:int =(n$0 + n$1) [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&a,false); [line 26]\n NULLIFY(&b,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +7 [label="7: Return Stmt \n n$0=*&a:int [line 25]\n n$1=*&b:int [line 25]\n *&return:int =(n$0 + n$1) [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n NULLIFY(&a,false); [line 25]\n NULLIFY(&b,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 7 -> 6 ; diff --git a/infer/tests/codetoanalyze/c/frontend/comma/comma.c b/infer/tests/codetoanalyze/c/frontend/comma/comma.c index 075441c6a..99c04e687 100644 --- a/infer/tests/codetoanalyze/c/frontend/comma/comma.c +++ b/infer/tests/codetoanalyze/c/frontend/comma/comma.c @@ -8,19 +8,19 @@ */ int comma_1() { - int a = 9, b = 7; - int d = (a = a * 2, b = 7 * a++); - return d; + int a = 9, b = 7; + int d = (a = a * 2, b = 7 * a++); + return d; } int comma_2() { - int a = 9, b = 7; - int d = (a = a * 2, b = 7 * a++, a+b+9); - return d; + int a = 9, b = 7; + int d = (a = a * 2, b = 7 * a++, a + b + 9); + return d; } int comma_3() { - int a = 9, b = 7, c = 3; - int d = (a = a * 2, b = 7 * a++, c = a+b+9, c); - return d; + int a = 9, b = 7, c = 3; + int d = (a = a * 2, b = 7 * a++, c = a + b + 9, c); + return d; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c index adb4754e2..63e98288d 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c @@ -7,9 +7,13 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -void dereference_in_array_access(int **p) { - if (p[0]); - if ((*p)[1]); - if (p[**p]); - if ((*p)[**p]); +void dereference_in_array_access(int** p) { + if (p[0]) + ; + if ((*p)[1]) + ; + if (p[**p]) + ; + if ((*p)[**p]) + ; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c.dot index b3d100ff4..8983161f5 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/array_access.c.dot @@ -11,15 +11,15 @@ digraph iCFG { 16 -> 13 ; -15 [label="15: Prune (false branch) \n n$12=*n$11:int * [line 12]\n n$13=*n$12[1]:int [line 12]\n PRUNE((n$13 == 0), false); [line 12]\n REMOVE_TEMPS(n$11,n$12,n$13); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="invhouse"] +15 [label="15: Prune (false branch) \n n$12=*n$11:int * [line 13]\n n$13=*n$12[1]:int [line 13]\n PRUNE((n$13 == 0), false); [line 13]\n REMOVE_TEMPS(n$11,n$12,n$13); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] 15 -> 12 ; -14 [label="14: Prune (true branch) \n n$12=*n$11:int * [line 12]\n n$13=*n$12[1]:int [line 12]\n PRUNE((n$13 != 0), true); [line 12]\n REMOVE_TEMPS(n$11,n$12,n$13); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="invhouse"] +14 [label="14: Prune (true branch) \n n$12=*n$11:int * [line 13]\n n$13=*n$12[1]:int [line 13]\n PRUNE((n$13 != 0), true); [line 13]\n REMOVE_TEMPS(n$11,n$12,n$13); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] 14 -> 12 ; -13 [label="13: UnaryOperator \n n$11=*&p:int ** [line 12]\n " shape="box"] +13 [label="13: UnaryOperator \n n$11=*&p:int ** [line 13]\n " shape="box"] 13 -> 14 ; @@ -28,15 +28,15 @@ digraph iCFG { 12 -> 9 ; -11 [label="11: Prune (false branch) \n n$6=*&p:int ** [line 13]\n n$9=*n$8:int [line 13]\n n$10=*n$6[n$9]:int * [line 13]\n PRUNE((n$10 == 0), false); [line 13]\n REMOVE_TEMPS(n$7,n$8,n$9,n$6,n$10); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] +11 [label="11: Prune (false branch) \n n$6=*&p:int ** [line 15]\n n$9=*n$8:int [line 15]\n n$10=*n$6[n$9]:int * [line 15]\n PRUNE((n$10 == 0), false); [line 15]\n REMOVE_TEMPS(n$7,n$8,n$9,n$6,n$10); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="invhouse"] 11 -> 8 ; -10 [label="10: Prune (true branch) \n n$6=*&p:int ** [line 13]\n n$9=*n$8:int [line 13]\n n$10=*n$6[n$9]:int * [line 13]\n PRUNE((n$10 != 0), true); [line 13]\n REMOVE_TEMPS(n$7,n$8,n$9,n$6,n$10); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] +10 [label="10: Prune (true branch) \n n$6=*&p:int ** [line 15]\n n$9=*n$8:int [line 15]\n n$10=*n$6[n$9]:int * [line 15]\n PRUNE((n$10 != 0), true); [line 15]\n REMOVE_TEMPS(n$7,n$8,n$9,n$6,n$10); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="invhouse"] 10 -> 8 ; -9 [label="9: UnaryOperator \n n$7=*&p:int ** [line 13]\n n$8=*n$7:int * [line 13]\n " shape="box"] +9 [label="9: UnaryOperator \n n$7=*&p:int ** [line 15]\n n$8=*n$7:int * [line 15]\n " shape="box"] 9 -> 10 ; @@ -45,20 +45,20 @@ digraph iCFG { 8 -> 4 ; -7 [label="7: Prune (false branch) \n n$1=*n$0:int * [line 14]\n n$4=*n$3:int [line 14]\n n$5=*n$1[n$4]:int [line 14]\n PRUNE((n$5 == 0), false); [line 14]\n REMOVE_TEMPS(n$2,n$3,n$4,n$0,n$1,n$5); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="invhouse"] +7 [label="7: Prune (false branch) \n n$1=*n$0:int * [line 17]\n n$4=*n$3:int [line 17]\n n$5=*n$1[n$4]:int [line 17]\n PRUNE((n$5 == 0), false); [line 17]\n REMOVE_TEMPS(n$2,n$3,n$4,n$0,n$1,n$5); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="invhouse"] 7 -> 3 ; -6 [label="6: Prune (true branch) \n n$1=*n$0:int * [line 14]\n n$4=*n$3:int [line 14]\n n$5=*n$1[n$4]:int [line 14]\n PRUNE((n$5 != 0), true); [line 14]\n REMOVE_TEMPS(n$2,n$3,n$4,n$0,n$1,n$5); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="invhouse"] +6 [label="6: Prune (true branch) \n n$1=*n$0:int * [line 17]\n n$4=*n$3:int [line 17]\n n$5=*n$1[n$4]:int [line 17]\n PRUNE((n$5 != 0), true); [line 17]\n REMOVE_TEMPS(n$2,n$3,n$4,n$0,n$1,n$5); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="invhouse"] 6 -> 3 ; -5 [label="5: UnaryOperator \n n$2=*&p:int ** [line 14]\n n$3=*n$2:int * [line 14]\n NULLIFY(&p,false); [line 14]\n " shape="box"] +5 [label="5: UnaryOperator \n n$2=*&p:int ** [line 17]\n n$3=*n$2:int * [line 17]\n NULLIFY(&p,false); [line 17]\n " shape="box"] 5 -> 6 ; 5 -> 7 ; -4 [label="4: UnaryOperator \n n$0=*&p:int ** [line 14]\n " shape="box"] +4 [label="4: UnaryOperator \n n$0=*&p:int ** [line 17]\n " shape="box"] 4 -> 5 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/assert_example.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/assert_example.c index ad129fc2b..e3a8a250e 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/assert_example.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/assert_example.c @@ -10,10 +10,10 @@ #include struct MyPoint { - int x; + int x; }; -int test (struct MyPoint* activeq) { - assert(activeq != 0); - return activeq->x; +int test(struct MyPoint* activeq) { + assert(activeq != 0); + return activeq->x; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c index eb7833b3f..4705dda17 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c @@ -18,7 +18,6 @@ void binop_with_side_effects(int z) { int x3; x3 = (1 ? z : z) + (1 ? z : z); - // initializer int y1 = (1 ? z : z) + 77; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c.dot index 4e61eb1bd..e4fba09b3 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/binary_operator.c.dot @@ -95,24 +95,24 @@ digraph iCFG { 26 -> 32 ; 26 -> 33 ; -25 [label="25: DeclStmt \n n$11=*&SIL_temp_conditional___20:int [line 23]\n NULLIFY(&SIL_temp_conditional___20,true); [line 23]\n *&y1:int =(n$11 + 77) [line 23]\n REMOVE_TEMPS(n$11); [line 23]\n NULLIFY(&y1,false); [line 23]\n " shape="box"] +25 [label="25: DeclStmt \n n$11=*&SIL_temp_conditional___20:int [line 22]\n NULLIFY(&SIL_temp_conditional___20,true); [line 22]\n *&y1:int =(n$11 + 77) [line 22]\n REMOVE_TEMPS(n$11); [line 22]\n NULLIFY(&y1,false); [line 22]\n " shape="box"] 25 -> 15 ; 25 -> 16 ; -24 [label="24: ConditinalStmt Branch \n n$10=*&z:int [line 23]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 23]\n *&SIL_temp_conditional___20:int =n$10 [line 23]\n REMOVE_TEMPS(n$10); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +24 [label="24: ConditinalStmt Branch \n n$10=*&z:int [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 22]\n *&SIL_temp_conditional___20:int =n$10 [line 22]\n REMOVE_TEMPS(n$10); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 24 -> 20 ; -23 [label="23: ConditinalStmt Branch \n n$9=*&z:int [line 23]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 23]\n *&SIL_temp_conditional___20:int =n$9 [line 23]\n REMOVE_TEMPS(n$9); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +23 [label="23: ConditinalStmt Branch \n n$9=*&z:int [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 22]\n *&SIL_temp_conditional___20:int =n$9 [line 22]\n REMOVE_TEMPS(n$9); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 23 -> 20 ; -22 [label="22: Prune (false branch) \n PRUNE((1 == 0), false); [line 23]\n " shape="invhouse"] +22 [label="22: Prune (false branch) \n PRUNE((1 == 0), false); [line 22]\n " shape="invhouse"] 22 -> 24 ; -21 [label="21: Prune (true branch) \n PRUNE((1 != 0), true); [line 23]\n " shape="invhouse"] +21 [label="21: Prune (true branch) \n PRUNE((1 != 0), true); [line 22]\n " shape="invhouse"] 21 -> 23 ; @@ -120,24 +120,24 @@ digraph iCFG { 20 -> 25 ; -19 [label="19: DeclStmt \n n$8=*&SIL_temp_conditional___14:int [line 25]\n NULLIFY(&SIL_temp_conditional___14,true); [line 25]\n *&y2:int =(77 + n$8) [line 25]\n REMOVE_TEMPS(n$8); [line 25]\n NULLIFY(&y2,false); [line 25]\n " shape="box"] +19 [label="19: DeclStmt \n n$8=*&SIL_temp_conditional___14:int [line 24]\n NULLIFY(&SIL_temp_conditional___14,true); [line 24]\n *&y2:int =(77 + n$8) [line 24]\n REMOVE_TEMPS(n$8); [line 24]\n NULLIFY(&y2,false); [line 24]\n " shape="box"] 19 -> 4 ; 19 -> 5 ; -18 [label="18: ConditinalStmt Branch \n n$7=*&z:int [line 25]\n DECLARE_LOCALS(&SIL_temp_conditional___14); [line 25]\n *&SIL_temp_conditional___14:int =n$7 [line 25]\n REMOVE_TEMPS(n$7); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +18 [label="18: ConditinalStmt Branch \n n$7=*&z:int [line 24]\n DECLARE_LOCALS(&SIL_temp_conditional___14); [line 24]\n *&SIL_temp_conditional___14:int =n$7 [line 24]\n REMOVE_TEMPS(n$7); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 18 -> 14 ; -17 [label="17: ConditinalStmt Branch \n n$6=*&z:int [line 25]\n DECLARE_LOCALS(&SIL_temp_conditional___14); [line 25]\n *&SIL_temp_conditional___14:int =n$6 [line 25]\n REMOVE_TEMPS(n$6); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +17 [label="17: ConditinalStmt Branch \n n$6=*&z:int [line 24]\n DECLARE_LOCALS(&SIL_temp_conditional___14); [line 24]\n *&SIL_temp_conditional___14:int =n$6 [line 24]\n REMOVE_TEMPS(n$6); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 17 -> 14 ; -16 [label="16: Prune (false branch) \n PRUNE((1 == 0), false); [line 25]\n " shape="invhouse"] +16 [label="16: Prune (false branch) \n PRUNE((1 == 0), false); [line 24]\n " shape="invhouse"] 16 -> 18 ; -15 [label="15: Prune (true branch) \n PRUNE((1 != 0), true); [line 25]\n " shape="invhouse"] +15 [label="15: Prune (true branch) \n PRUNE((1 != 0), true); [line 24]\n " shape="invhouse"] 15 -> 17 ; @@ -145,23 +145,23 @@ digraph iCFG { 14 -> 19 ; -13 [label="13: DeclStmt \n n$2=*&SIL_temp_conditional___3:int [line 27]\n NULLIFY(&SIL_temp_conditional___3,true); [line 27]\n n$5=*&SIL_temp_conditional___8:int [line 27]\n NULLIFY(&SIL_temp_conditional___8,true); [line 27]\n *&y3:int =(n$2 + n$5) [line 27]\n REMOVE_TEMPS(n$2,n$5); [line 27]\n NULLIFY(&y3,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +13 [label="13: DeclStmt \n n$2=*&SIL_temp_conditional___3:int [line 26]\n NULLIFY(&SIL_temp_conditional___3,true); [line 26]\n n$5=*&SIL_temp_conditional___8:int [line 26]\n NULLIFY(&SIL_temp_conditional___8,true); [line 26]\n *&y3:int =(n$2 + n$5) [line 26]\n REMOVE_TEMPS(n$2,n$5); [line 26]\n NULLIFY(&y3,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 13 -> 2 ; -12 [label="12: ConditinalStmt Branch \n n$4=*&z:int [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___8); [line 27]\n *&SIL_temp_conditional___8:int =n$4 [line 27]\n REMOVE_TEMPS(n$4); [line 27]\n NULLIFY(&z,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +12 [label="12: ConditinalStmt Branch \n n$4=*&z:int [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___8); [line 26]\n *&SIL_temp_conditional___8:int =n$4 [line 26]\n REMOVE_TEMPS(n$4); [line 26]\n NULLIFY(&z,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 12 -> 8 ; -11 [label="11: ConditinalStmt Branch \n n$3=*&z:int [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___8); [line 27]\n *&SIL_temp_conditional___8:int =n$3 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n NULLIFY(&z,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +11 [label="11: ConditinalStmt Branch \n n$3=*&z:int [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___8); [line 26]\n *&SIL_temp_conditional___8:int =n$3 [line 26]\n REMOVE_TEMPS(n$3); [line 26]\n NULLIFY(&z,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 11 -> 8 ; -10 [label="10: Prune (false branch) \n PRUNE((1 == 0), false); [line 27]\n " shape="invhouse"] +10 [label="10: Prune (false branch) \n PRUNE((1 == 0), false); [line 26]\n " shape="invhouse"] 10 -> 12 ; -9 [label="9: Prune (true branch) \n PRUNE((1 != 0), true); [line 27]\n " shape="invhouse"] +9 [label="9: Prune (true branch) \n PRUNE((1 != 0), true); [line 26]\n " shape="invhouse"] 9 -> 11 ; @@ -169,19 +169,19 @@ digraph iCFG { 8 -> 13 ; -7 [label="7: ConditinalStmt Branch \n n$1=*&z:int [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 27]\n *&SIL_temp_conditional___3:int =n$1 [line 27]\n REMOVE_TEMPS(n$1); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +7 [label="7: ConditinalStmt Branch \n n$1=*&z:int [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 26]\n *&SIL_temp_conditional___3:int =n$1 [line 26]\n REMOVE_TEMPS(n$1); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 7 -> 3 ; -6 [label="6: ConditinalStmt Branch \n n$0=*&z:int [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 27]\n *&SIL_temp_conditional___3:int =n$0 [line 27]\n REMOVE_TEMPS(n$0); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +6 [label="6: ConditinalStmt Branch \n n$0=*&z:int [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 26]\n *&SIL_temp_conditional___3:int =n$0 [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 6 -> 3 ; -5 [label="5: Prune (false branch) \n PRUNE((1 == 0), false); [line 27]\n " shape="invhouse"] +5 [label="5: Prune (false branch) \n PRUNE((1 == 0), false); [line 26]\n " shape="invhouse"] 5 -> 7 ; -4 [label="4: Prune (true branch) \n PRUNE((1 != 0), true); [line 27]\n " shape="invhouse"] +4 [label="4: Prune (true branch) \n PRUNE((1 != 0), true); [line 26]\n " shape="invhouse"] 4 -> 6 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c index 11d523211..49ac61d3b 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c @@ -7,19 +7,19 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int foo() -{ - int x=5; - if (3 < 4 || 7<(x++)) { x=0;}; - int y =19; - int n = ((3 < 4 || 7<((x++)-y )) ? 1 : 2); - n = (2 < 1 ? 1 : (5>4 ? 1:2)); - return (0 + (7 > 9 ? 1 : 0)); - +int foo() { + int x = 5; + if (3 < 4 || 7 < (x++)) { + x = 0; + }; + int y = 19; + int n = ((3 < 4 || 7 < ((x++) - y)) ? 1 : 2); + n = (2 < 1 ? 1 : (5 > 4 ? 1 : 2)); + return (0 + (7 > 9 ? 1 : 0)); } int bar() { - int x,y; - y=(x=1) > 1 ? (++x) : (x--); - return (0 + ( (3>4 ? 1:2) > 1 ? (x=1) : 0)); + int x, y; + y = (x = 1) > 1 ? (++x) : (x--); + return (0 + ((3 > 4 ? 1 : 2) > 1 ? (x = 1) : 0)); } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c.dot index 2d2ea41e2..e1cecf3ad 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/cond2.c.dot @@ -85,7 +85,7 @@ digraph iCFG { 38 -> 53 ; -37 [label="37: DeclStmt \n *&x:int =5 [line 12]\n " shape="box"] +37 [label="37: DeclStmt \n *&x:int =5 [line 11]\n " shape="box"] 37 -> 31 ; @@ -94,24 +94,24 @@ digraph iCFG { 36 -> 30 ; -35 [label="35: Prune (false branch) \n PRUNE(((7 < n$6) == 0), false); [line 13]\n REMOVE_TEMPS(n$6); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] +35 [label="35: Prune (false branch) \n PRUNE(((7 < n$6) == 0), false); [line 12]\n REMOVE_TEMPS(n$6); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="invhouse"] 35 -> 30 ; -34 [label="34: Prune (true branch) \n PRUNE(((7 < n$6) != 0), true); [line 13]\n REMOVE_TEMPS(n$6); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] +34 [label="34: Prune (true branch) \n PRUNE(((7 < n$6) != 0), true); [line 12]\n REMOVE_TEMPS(n$6); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="invhouse"] 34 -> 36 ; -33 [label="33: BinaryOperatorStmt: LT \n n$6=*&x:int [line 13]\n *&x:int =(n$6 + 1) [line 13]\n " shape="box"] +33 [label="33: BinaryOperatorStmt: LT \n n$6=*&x:int [line 12]\n *&x:int =(n$6 + 1) [line 12]\n " shape="box"] 33 -> 34 ; 33 -> 35 ; -32 [label="32: Prune (false branch) \n PRUNE(((3 < 4) == 0), false); [line 13]\n " shape="invhouse"] +32 [label="32: Prune (false branch) \n PRUNE(((3 < 4) == 0), false); [line 12]\n " shape="invhouse"] 32 -> 33 ; -31 [label="31: Prune (true branch) \n PRUNE(((3 < 4) != 0), true); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="invhouse"] +31 [label="31: Prune (true branch) \n PRUNE(((3 < 4) != 0), true); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="invhouse"] 31 -> 36 ; @@ -119,42 +119,42 @@ digraph iCFG { 30 -> 29 ; -29 [label="29: DeclStmt \n *&y:int =19 [line 14]\n " shape="box"] +29 [label="29: DeclStmt \n *&y:int =19 [line 15]\n " shape="box"] 29 -> 21 ; 29 -> 22 ; -28 [label="28: DeclStmt \n n$5=*&SIL_temp_conditional___20:int [line 15]\n NULLIFY(&SIL_temp_conditional___20,true); [line 15]\n *&n:int =n$5 [line 15]\n REMOVE_TEMPS(n$5); [line 15]\n NULLIFY(&n,false); [line 15]\n " shape="box"] +28 [label="28: DeclStmt \n n$5=*&SIL_temp_conditional___20:int [line 16]\n NULLIFY(&SIL_temp_conditional___20,true); [line 16]\n *&n:int =n$5 [line 16]\n REMOVE_TEMPS(n$5); [line 16]\n NULLIFY(&n,false); [line 16]\n " shape="box"] 28 -> 10 ; 28 -> 11 ; -27 [label="27: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 15]\n *&SIL_temp_conditional___20:int =2 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +27 [label="27: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 16]\n *&SIL_temp_conditional___20:int =2 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 27 -> 20 ; -26 [label="26: ConditinalStmt Branch \n NULLIFY(&x,false); [line 15]\n NULLIFY(&y,false); [line 15]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 15]\n *&SIL_temp_conditional___20:int =1 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +26 [label="26: ConditinalStmt Branch \n NULLIFY(&x,false); [line 16]\n NULLIFY(&y,false); [line 16]\n DECLARE_LOCALS(&SIL_temp_conditional___20); [line 16]\n *&SIL_temp_conditional___20:int =1 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 26 -> 20 ; -25 [label="25: Prune (false branch) \n PRUNE(((7 < (n$3 - n$4)) == 0), false); [line 15]\n REMOVE_TEMPS(n$3,n$4); [line 15]\n " shape="invhouse"] +25 [label="25: Prune (false branch) \n PRUNE(((7 < (n$3 - n$4)) == 0), false); [line 16]\n REMOVE_TEMPS(n$3,n$4); [line 16]\n " shape="invhouse"] 25 -> 27 ; -24 [label="24: Prune (true branch) \n PRUNE(((7 < (n$3 - n$4)) != 0), true); [line 15]\n REMOVE_TEMPS(n$3,n$4); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="invhouse"] +24 [label="24: Prune (true branch) \n PRUNE(((7 < (n$3 - n$4)) != 0), true); [line 16]\n REMOVE_TEMPS(n$3,n$4); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="invhouse"] 24 -> 26 ; -23 [label="23: BinaryOperatorStmt: LT \n n$3=*&x:int [line 15]\n *&x:int =(n$3 + 1) [line 15]\n n$4=*&y:int [line 15]\n NULLIFY(&x,false); [line 15]\n NULLIFY(&y,false); [line 15]\n " shape="box"] +23 [label="23: BinaryOperatorStmt: LT \n n$3=*&x:int [line 16]\n *&x:int =(n$3 + 1) [line 16]\n n$4=*&y:int [line 16]\n NULLIFY(&x,false); [line 16]\n NULLIFY(&y,false); [line 16]\n " shape="box"] 23 -> 24 ; 23 -> 25 ; -22 [label="22: Prune (false branch) \n PRUNE(((3 < 4) == 0), false); [line 15]\n " shape="invhouse"] +22 [label="22: Prune (false branch) \n PRUNE(((3 < 4) == 0), false); [line 16]\n " shape="invhouse"] 22 -> 23 ; -21 [label="21: Prune (true branch) \n PRUNE(((3 < 4) != 0), true); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="invhouse"] +21 [label="21: Prune (true branch) \n PRUNE(((3 < 4) != 0), true); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="invhouse"] 21 -> 26 ; @@ -162,28 +162,28 @@ digraph iCFG { 20 -> 28 ; -19 [label="19: BinaryOperatorStmt: Assign \n n$2=*&SIL_temp_conditional___9:int [line 16]\n NULLIFY(&SIL_temp_conditional___9,true); [line 16]\n *&n:int =n$2 [line 16]\n REMOVE_TEMPS(n$2); [line 16]\n NULLIFY(&n,false); [line 16]\n " shape="box"] +19 [label="19: BinaryOperatorStmt: Assign \n n$2=*&SIL_temp_conditional___9:int [line 17]\n NULLIFY(&SIL_temp_conditional___9,true); [line 17]\n *&n:int =n$2 [line 17]\n REMOVE_TEMPS(n$2); [line 17]\n NULLIFY(&n,false); [line 17]\n " shape="box"] 19 -> 4 ; 19 -> 5 ; -18 [label="18: ConditinalStmt Branch \n n$1=*&SIL_temp_conditional___13:int [line 16]\n NULLIFY(&SIL_temp_conditional___13,true); [line 16]\n DECLARE_LOCALS(&SIL_temp_conditional___9); [line 16]\n *&SIL_temp_conditional___9:int =n$1 [line 16]\n REMOVE_TEMPS(n$1); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +18 [label="18: ConditinalStmt Branch \n n$1=*&SIL_temp_conditional___13:int [line 17]\n NULLIFY(&SIL_temp_conditional___13,true); [line 17]\n DECLARE_LOCALS(&SIL_temp_conditional___9); [line 17]\n *&SIL_temp_conditional___9:int =n$1 [line 17]\n REMOVE_TEMPS(n$1); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 18 -> 9 ; -17 [label="17: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___13); [line 16]\n *&SIL_temp_conditional___13:int =2 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +17 [label="17: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___13); [line 17]\n *&SIL_temp_conditional___13:int =2 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 17 -> 13 ; -16 [label="16: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___13); [line 16]\n *&SIL_temp_conditional___13:int =1 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +16 [label="16: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___13); [line 17]\n *&SIL_temp_conditional___13:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 16 -> 13 ; -15 [label="15: Prune (false branch) \n PRUNE(((5 > 4) == 0), false); [line 16]\n " shape="invhouse"] +15 [label="15: Prune (false branch) \n PRUNE(((5 > 4) == 0), false); [line 17]\n " shape="invhouse"] 15 -> 17 ; -14 [label="14: Prune (true branch) \n PRUNE(((5 > 4) != 0), true); [line 16]\n " shape="invhouse"] +14 [label="14: Prune (true branch) \n PRUNE(((5 > 4) != 0), true); [line 17]\n " shape="invhouse"] 14 -> 16 ; @@ -191,16 +191,16 @@ digraph iCFG { 13 -> 18 ; -12 [label="12: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___9); [line 16]\n *&SIL_temp_conditional___9:int =1 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +12 [label="12: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___9); [line 17]\n *&SIL_temp_conditional___9:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 12 -> 9 ; -11 [label="11: Prune (false branch) \n PRUNE(((2 < 1) == 0), false); [line 16]\n " shape="invhouse"] +11 [label="11: Prune (false branch) \n PRUNE(((2 < 1) == 0), false); [line 17]\n " shape="invhouse"] 11 -> 14 ; 11 -> 15 ; -10 [label="10: Prune (true branch) \n PRUNE(((2 < 1) != 0), true); [line 16]\n " shape="invhouse"] +10 [label="10: Prune (true branch) \n PRUNE(((2 < 1) != 0), true); [line 17]\n " shape="invhouse"] 10 -> 12 ; @@ -208,23 +208,23 @@ digraph iCFG { 9 -> 19 ; -8 [label="8: Return Stmt \n n$0=*&SIL_temp_conditional___3:int [line 17]\n NULLIFY(&SIL_temp_conditional___3,true); [line 17]\n *&return:int =(0 + n$0) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +8 [label="8: Return Stmt \n n$0=*&SIL_temp_conditional___3:int [line 18]\n NULLIFY(&SIL_temp_conditional___3,true); [line 18]\n *&return:int =(0 + n$0) [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 8 -> 2 ; -7 [label="7: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 17]\n *&SIL_temp_conditional___3:int =0 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +7 [label="7: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 18]\n *&SIL_temp_conditional___3:int =0 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 7 -> 3 ; -6 [label="6: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 17]\n *&SIL_temp_conditional___3:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +6 [label="6: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 18]\n *&SIL_temp_conditional___3:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 6 -> 3 ; -5 [label="5: Prune (false branch) \n PRUNE(((7 > 9) == 0), false); [line 17]\n " shape="invhouse"] +5 [label="5: Prune (false branch) \n PRUNE(((7 > 9) == 0), false); [line 18]\n " shape="invhouse"] 5 -> 7 ; -4 [label="4: Prune (true branch) \n PRUNE(((7 > 9) != 0), true); [line 17]\n " shape="invhouse"] +4 [label="4: Prune (true branch) \n PRUNE(((7 > 9) != 0), true); [line 18]\n " shape="invhouse"] 4 -> 6 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c index e6a7c03a8..5ffc58a57 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c @@ -9,36 +9,25 @@ #include -int test2(int x) { - return x; -} - +int test2(int x) { return x; } -int test(int b) { - return test2(b ? b : 1); -} +int test(int b) { return test2(b ? b : 1); } int test1(int b) { - int x = b ? b : 1; - return x; + int x = b ? b : 1; + return x; } int test3(int b) { - int x = b ? : 1; - return x; + int x = b ?: 1; + return x; } +int test4(int b) { return test2(b ?: 1); } -int test4(int b) { - return test2(b ? : 1); -} - - -int test5(int b) { - return b ? : 1; -} +int test5(int b) { return b ?: 1; } -int test6(int *p) { +int test6(int* p) { int z = 1 ? *p : 0; return z; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c.dot index 7cb271fa9..7b2734aa2 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/conditional_operator.c.dot @@ -1,21 +1,21 @@ digraph iCFG { -54 [label="54: DeclStmt \n n$3=*&SIL_temp_conditional___49:int [line 42]\n NULLIFY(&SIL_temp_conditional___49,true); [line 42]\n *&z:int =n$3 [line 42]\n REMOVE_TEMPS(n$3); [line 42]\n " shape="box"] +54 [label="54: DeclStmt \n n$3=*&SIL_temp_conditional___49:int [line 31]\n NULLIFY(&SIL_temp_conditional___49,true); [line 31]\n *&z:int =n$3 [line 31]\n REMOVE_TEMPS(n$3); [line 31]\n " shape="box"] 54 -> 48 ; -53 [label="53: ConditinalStmt Branch \n NULLIFY(&p,false); [line 42]\n DECLARE_LOCALS(&SIL_temp_conditional___49); [line 42]\n *&SIL_temp_conditional___49:int =0 [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +53 [label="53: ConditinalStmt Branch \n NULLIFY(&p,false); [line 31]\n DECLARE_LOCALS(&SIL_temp_conditional___49); [line 31]\n *&SIL_temp_conditional___49:int =0 [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 53 -> 49 ; -52 [label="52: ConditinalStmt Branch \n n$1=*&p:int * [line 42]\n n$2=*n$1:int [line 42]\n DECLARE_LOCALS(&SIL_temp_conditional___49); [line 42]\n *&SIL_temp_conditional___49:int =n$2 [line 42]\n REMOVE_TEMPS(n$1,n$2); [line 42]\n NULLIFY(&p,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +52 [label="52: ConditinalStmt Branch \n n$1=*&p:int * [line 31]\n n$2=*n$1:int [line 31]\n DECLARE_LOCALS(&SIL_temp_conditional___49); [line 31]\n *&SIL_temp_conditional___49:int =n$2 [line 31]\n REMOVE_TEMPS(n$1,n$2); [line 31]\n NULLIFY(&p,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 52 -> 49 ; -51 [label="51: Prune (false branch) \n PRUNE((1 == 0), false); [line 42]\n " shape="invhouse"] +51 [label="51: Prune (false branch) \n PRUNE((1 == 0), false); [line 31]\n " shape="invhouse"] 51 -> 53 ; -50 [label="50: Prune (true branch) \n PRUNE((1 != 0), true); [line 42]\n " shape="invhouse"] +50 [label="50: Prune (true branch) \n PRUNE((1 != 0), true); [line 31]\n " shape="invhouse"] 50 -> 52 ; @@ -23,35 +23,35 @@ digraph iCFG { 49 -> 54 ; -48 [label="48: Return Stmt \n n$0=*&z:int [line 43]\n *&return:int =n$0 [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&z,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +48 [label="48: Return Stmt \n n$0=*&z:int [line 32]\n *&return:int =n$0 [line 32]\n REMOVE_TEMPS(n$0); [line 32]\n NULLIFY(&z,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 48 -> 47 ; 47 [label="47: Exit test6 \n " color=yellow style=filled] -46 [label="46: Start test6\nFormals: p:int *\nLocals: z:int \n DECLARE_LOCALS(&return,&z); [line 41]\n NULLIFY(&z,false); [line 41]\n " color=yellow style=filled] +46 [label="46: Start test6\nFormals: p:int *\nLocals: z:int \n DECLARE_LOCALS(&return,&z); [line 30]\n NULLIFY(&z,false); [line 30]\n " color=yellow style=filled] 46 -> 50 ; 46 -> 51 ; -45 [label="45: Return Stmt \n n$2=*&SIL_temp_conditional___40:int [line 38]\n NULLIFY(&SIL_temp_conditional___40,true); [line 38]\n *&return:int =n$2 [line 38]\n REMOVE_TEMPS(n$2); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +45 [label="45: Return Stmt \n n$2=*&SIL_temp_conditional___40:int [line 28]\n NULLIFY(&SIL_temp_conditional___40,true); [line 28]\n *&return:int =n$2 [line 28]\n REMOVE_TEMPS(n$2); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 45 -> 39 ; -44 [label="44: ConditinalStmt Branch \n NULLIFY(&b,false); [line 38]\n DECLARE_LOCALS(&SIL_temp_conditional___40); [line 38]\n *&SIL_temp_conditional___40:int =1 [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +44 [label="44: ConditinalStmt Branch \n NULLIFY(&b,false); [line 28]\n DECLARE_LOCALS(&SIL_temp_conditional___40); [line 28]\n *&SIL_temp_conditional___40:int =1 [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 44 -> 40 ; -43 [label="43: ConditinalStmt Branch \n n$1=*&b:int [line 38]\n DECLARE_LOCALS(&SIL_temp_conditional___40); [line 38]\n *&SIL_temp_conditional___40:int =n$1 [line 38]\n REMOVE_TEMPS(n$1); [line 38]\n NULLIFY(&b,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +43 [label="43: ConditinalStmt Branch \n n$1=*&b:int [line 28]\n DECLARE_LOCALS(&SIL_temp_conditional___40); [line 28]\n *&SIL_temp_conditional___40:int =n$1 [line 28]\n REMOVE_TEMPS(n$1); [line 28]\n NULLIFY(&b,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 43 -> 40 ; -42 [label="42: Prune (false branch) \n n$0=*&b:int [line 38]\n PRUNE((n$0 == 0), false); [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n " shape="invhouse"] +42 [label="42: Prune (false branch) \n n$0=*&b:int [line 28]\n PRUNE((n$0 == 0), false); [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n " shape="invhouse"] 42 -> 44 ; -41 [label="41: Prune (true branch) \n n$0=*&b:int [line 38]\n PRUNE((n$0 != 0), true); [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n " shape="invhouse"] +41 [label="41: Prune (true branch) \n n$0=*&b:int [line 28]\n PRUNE((n$0 != 0), true); [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n " shape="invhouse"] 41 -> 43 ; @@ -62,28 +62,28 @@ digraph iCFG { 39 [label="39: Exit test5 \n " color=yellow style=filled] -38 [label="38: Start test5\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 37]\n " color=yellow style=filled] +38 [label="38: Start test5\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 38 -> 41 ; 38 -> 42 ; -37 [label="37: Return Stmt \n n$2=*&SIL_temp_conditional___32:int [line 33]\n NULLIFY(&SIL_temp_conditional___32,true); [line 33]\n n$3=_fun_test2(n$2:int ) [line 33]\n *&return:int =n$3 [line 33]\n REMOVE_TEMPS(n$2,n$3); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +37 [label="37: Return Stmt \n n$2=*&SIL_temp_conditional___32:int [line 26]\n NULLIFY(&SIL_temp_conditional___32,true); [line 26]\n n$3=_fun_test2(n$2:int ) [line 26]\n *&return:int =n$3 [line 26]\n REMOVE_TEMPS(n$2,n$3); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 37 -> 31 ; -36 [label="36: ConditinalStmt Branch \n NULLIFY(&b,false); [line 33]\n DECLARE_LOCALS(&SIL_temp_conditional___32); [line 33]\n *&SIL_temp_conditional___32:int =1 [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +36 [label="36: ConditinalStmt Branch \n NULLIFY(&b,false); [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___32); [line 26]\n *&SIL_temp_conditional___32:int =1 [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 36 -> 32 ; -35 [label="35: ConditinalStmt Branch \n n$1=*&b:int [line 33]\n DECLARE_LOCALS(&SIL_temp_conditional___32); [line 33]\n *&SIL_temp_conditional___32:int =n$1 [line 33]\n REMOVE_TEMPS(n$1); [line 33]\n NULLIFY(&b,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +35 [label="35: ConditinalStmt Branch \n n$1=*&b:int [line 26]\n DECLARE_LOCALS(&SIL_temp_conditional___32); [line 26]\n *&SIL_temp_conditional___32:int =n$1 [line 26]\n REMOVE_TEMPS(n$1); [line 26]\n NULLIFY(&b,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 35 -> 32 ; -34 [label="34: Prune (false branch) \n n$0=*&b:int [line 33]\n PRUNE((n$0 == 0), false); [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n " shape="invhouse"] +34 [label="34: Prune (false branch) \n n$0=*&b:int [line 26]\n PRUNE((n$0 == 0), false); [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n " shape="invhouse"] 34 -> 36 ; -33 [label="33: Prune (true branch) \n n$0=*&b:int [line 33]\n PRUNE((n$0 != 0), true); [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n " shape="invhouse"] +33 [label="33: Prune (true branch) \n n$0=*&b:int [line 26]\n PRUNE((n$0 != 0), true); [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n " shape="invhouse"] 33 -> 35 ; @@ -94,28 +94,28 @@ digraph iCFG { 31 [label="31: Exit test4 \n " color=yellow style=filled] -30 [label="30: Start test4\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +30 [label="30: Start test4\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 30 -> 33 ; 30 -> 34 ; -29 [label="29: DeclStmt \n n$3=*&SIL_temp_conditional___24:int [line 27]\n NULLIFY(&SIL_temp_conditional___24,true); [line 27]\n *&x:int =n$3 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] +29 [label="29: DeclStmt \n n$3=*&SIL_temp_conditional___24:int [line 22]\n NULLIFY(&SIL_temp_conditional___24,true); [line 22]\n *&x:int =n$3 [line 22]\n REMOVE_TEMPS(n$3); [line 22]\n " shape="box"] 29 -> 23 ; -28 [label="28: ConditinalStmt Branch \n NULLIFY(&b,false); [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___24); [line 27]\n *&SIL_temp_conditional___24:int =1 [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +28 [label="28: ConditinalStmt Branch \n NULLIFY(&b,false); [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___24); [line 22]\n *&SIL_temp_conditional___24:int =1 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 28 -> 24 ; -27 [label="27: ConditinalStmt Branch \n n$2=*&b:int [line 27]\n DECLARE_LOCALS(&SIL_temp_conditional___24); [line 27]\n *&SIL_temp_conditional___24:int =n$2 [line 27]\n REMOVE_TEMPS(n$2); [line 27]\n NULLIFY(&b,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +27 [label="27: ConditinalStmt Branch \n n$2=*&b:int [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___24); [line 22]\n *&SIL_temp_conditional___24:int =n$2 [line 22]\n REMOVE_TEMPS(n$2); [line 22]\n NULLIFY(&b,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 27 -> 24 ; -26 [label="26: Prune (false branch) \n n$1=*&b:int [line 27]\n PRUNE((n$1 == 0), false); [line 27]\n REMOVE_TEMPS(n$1); [line 27]\n " shape="invhouse"] +26 [label="26: Prune (false branch) \n n$1=*&b:int [line 22]\n PRUNE((n$1 == 0), false); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n " shape="invhouse"] 26 -> 28 ; -25 [label="25: Prune (true branch) \n n$1=*&b:int [line 27]\n PRUNE((n$1 != 0), true); [line 27]\n REMOVE_TEMPS(n$1); [line 27]\n " shape="invhouse"] +25 [label="25: Prune (true branch) \n n$1=*&b:int [line 22]\n PRUNE((n$1 != 0), true); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n " shape="invhouse"] 25 -> 27 ; @@ -123,35 +123,35 @@ digraph iCFG { 24 -> 29 ; -23 [label="23: Return Stmt \n n$0=*&x:int [line 28]\n *&return:int =n$0 [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n NULLIFY(&x,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +23 [label="23: Return Stmt \n n$0=*&x:int [line 23]\n *&return:int =n$0 [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 23 -> 22 ; 22 [label="22: Exit test3 \n " color=yellow style=filled] -21 [label="21: Start test3\nFormals: b:int \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 26]\n NULLIFY(&x,false); [line 26]\n " color=yellow style=filled] +21 [label="21: Start test3\nFormals: b:int \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 21]\n NULLIFY(&x,false); [line 21]\n " color=yellow style=filled] 21 -> 25 ; 21 -> 26 ; -20 [label="20: DeclStmt \n n$3=*&SIL_temp_conditional___15:int [line 22]\n NULLIFY(&SIL_temp_conditional___15,true); [line 22]\n *&x:int =n$3 [line 22]\n REMOVE_TEMPS(n$3); [line 22]\n " shape="box"] +20 [label="20: DeclStmt \n n$3=*&SIL_temp_conditional___15:int [line 17]\n NULLIFY(&SIL_temp_conditional___15,true); [line 17]\n *&x:int =n$3 [line 17]\n REMOVE_TEMPS(n$3); [line 17]\n " shape="box"] 20 -> 14 ; -19 [label="19: ConditinalStmt Branch \n NULLIFY(&b,false); [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =1 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +19 [label="19: ConditinalStmt Branch \n NULLIFY(&b,false); [line 17]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 17]\n *&SIL_temp_conditional___15:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 19 -> 15 ; -18 [label="18: ConditinalStmt Branch \n n$2=*&b:int [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =n$2 [line 22]\n REMOVE_TEMPS(n$2); [line 22]\n NULLIFY(&b,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +18 [label="18: ConditinalStmt Branch \n n$2=*&b:int [line 17]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 17]\n *&SIL_temp_conditional___15:int =n$2 [line 17]\n REMOVE_TEMPS(n$2); [line 17]\n NULLIFY(&b,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 18 -> 15 ; -17 [label="17: Prune (false branch) \n n$1=*&b:int [line 22]\n PRUNE((n$1 == 0), false); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n " shape="invhouse"] +17 [label="17: Prune (false branch) \n n$1=*&b:int [line 17]\n PRUNE((n$1 == 0), false); [line 17]\n REMOVE_TEMPS(n$1); [line 17]\n " shape="invhouse"] 17 -> 19 ; -16 [label="16: Prune (true branch) \n n$1=*&b:int [line 22]\n PRUNE((n$1 != 0), true); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n " shape="invhouse"] +16 [label="16: Prune (true branch) \n n$1=*&b:int [line 17]\n PRUNE((n$1 != 0), true); [line 17]\n REMOVE_TEMPS(n$1); [line 17]\n " shape="invhouse"] 16 -> 18 ; @@ -159,35 +159,35 @@ digraph iCFG { 15 -> 20 ; -14 [label="14: Return Stmt \n n$0=*&x:int [line 23]\n *&return:int =n$0 [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +14 [label="14: Return Stmt \n n$0=*&x:int [line 18]\n *&return:int =n$0 [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&x,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 14 -> 13 ; 13 [label="13: Exit test1 \n " color=yellow style=filled] -12 [label="12: Start test1\nFormals: b:int \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 21]\n NULLIFY(&x,false); [line 21]\n " color=yellow style=filled] +12 [label="12: Start test1\nFormals: b:int \nLocals: x:int \n DECLARE_LOCALS(&return,&x); [line 16]\n NULLIFY(&x,false); [line 16]\n " color=yellow style=filled] 12 -> 16 ; 12 -> 17 ; -11 [label="11: Return Stmt \n n$2=*&SIL_temp_conditional___6:int [line 18]\n NULLIFY(&SIL_temp_conditional___6,true); [line 18]\n n$3=_fun_test2(n$2:int ) [line 18]\n *&return:int =n$3 [line 18]\n REMOVE_TEMPS(n$2,n$3); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +11 [label="11: Return Stmt \n n$2=*&SIL_temp_conditional___6:int [line 14]\n NULLIFY(&SIL_temp_conditional___6,true); [line 14]\n n$3=_fun_test2(n$2:int ) [line 14]\n *&return:int =n$3 [line 14]\n REMOVE_TEMPS(n$2,n$3); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 11 -> 5 ; -10 [label="10: ConditinalStmt Branch \n NULLIFY(&b,false); [line 18]\n DECLARE_LOCALS(&SIL_temp_conditional___6); [line 18]\n *&SIL_temp_conditional___6:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +10 [label="10: ConditinalStmt Branch \n NULLIFY(&b,false); [line 14]\n DECLARE_LOCALS(&SIL_temp_conditional___6); [line 14]\n *&SIL_temp_conditional___6:int =1 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 10 -> 6 ; -9 [label="9: ConditinalStmt Branch \n n$1=*&b:int [line 18]\n DECLARE_LOCALS(&SIL_temp_conditional___6); [line 18]\n *&SIL_temp_conditional___6:int =n$1 [line 18]\n REMOVE_TEMPS(n$1); [line 18]\n NULLIFY(&b,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +9 [label="9: ConditinalStmt Branch \n n$1=*&b:int [line 14]\n DECLARE_LOCALS(&SIL_temp_conditional___6); [line 14]\n *&SIL_temp_conditional___6:int =n$1 [line 14]\n REMOVE_TEMPS(n$1); [line 14]\n NULLIFY(&b,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 9 -> 6 ; -8 [label="8: Prune (false branch) \n n$0=*&b:int [line 18]\n PRUNE((n$0 == 0), false); [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n " shape="invhouse"] +8 [label="8: Prune (false branch) \n n$0=*&b:int [line 14]\n PRUNE((n$0 == 0), false); [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n " shape="invhouse"] 8 -> 10 ; -7 [label="7: Prune (true branch) \n n$0=*&b:int [line 18]\n PRUNE((n$0 != 0), true); [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n " shape="invhouse"] +7 [label="7: Prune (true branch) \n n$0=*&b:int [line 14]\n PRUNE((n$0 != 0), true); [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n " shape="invhouse"] 7 -> 9 ; @@ -198,12 +198,12 @@ digraph iCFG { 5 [label="5: Exit test \n " color=yellow style=filled] -4 [label="4: Start test\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +4 [label="4: Start test\nFormals: b:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 7 ; 4 -> 8 ; -3 [label="3: Return Stmt \n n$0=*&x:int [line 13]\n *&return:int =n$0 [line 13]\n REMOVE_TEMPS(n$0); [line 13]\n NULLIFY(&x,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&x:int [line 12]\n *&return:int =n$0 [line 12]\n REMOVE_TEMPS(n$0); [line 12]\n NULLIFY(&x,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c index 44019a4e2..db5c8345f 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c @@ -9,18 +9,12 @@ void some_f(int, int, int); -void fun_ifthenelse1() { - (1 ? some_f : some_f)(1, 2, 3); -} +void fun_ifthenelse1() { (1 ? some_f : some_f)(1, 2, 3); } void fun_ifthenelse2() { (1 ? some_f : some_f)(0 ? 1 : 1, 0 ? 2 : 2, 0 ? 3 : 3); } -void fun_ifthenelse3() { - some_f(0 ? 1 : 1, 0 ? 2 : 2, 0 ? 3 : 3); -} +void fun_ifthenelse3() { some_f(0 ? 1 : 1, 0 ? 2 : 2, 0 ? 3 : 3); } -void fun_ifthenelse4() { - (1 ? some_f : some_f)(0 ? 1 : 1, 2, 0 ? 3 : 3); -} +void fun_ifthenelse4() { (1 ? some_f : some_f)(0 ? 1 : 1, 2, 0 ? 3 : 3); } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c.dot index 146019c83..a57f22a30 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/function_call.c.dot @@ -1,21 +1,21 @@ digraph iCFG { -67 [label="67: Call n$0 \n n$0=*&SIL_temp_conditional___52:_fn_ (*) [line 25]\n NULLIFY(&SIL_temp_conditional___52,true); [line 25]\n n$1=*&SIL_temp_conditional___57:int [line 25]\n NULLIFY(&SIL_temp_conditional___57,true); [line 25]\n n$2=*&SIL_temp_conditional___62:int [line 25]\n NULLIFY(&SIL_temp_conditional___62,true); [line 25]\n n$0(n$1:int ,2:int ,n$2:int ) [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +67 [label="67: Call n$0 \n n$0=*&SIL_temp_conditional___52:_fn_ (*) [line 20]\n NULLIFY(&SIL_temp_conditional___52,true); [line 20]\n n$1=*&SIL_temp_conditional___57:int [line 20]\n NULLIFY(&SIL_temp_conditional___57,true); [line 20]\n n$2=*&SIL_temp_conditional___62:int [line 20]\n NULLIFY(&SIL_temp_conditional___62,true); [line 20]\n n$0(n$1:int ,2:int ,n$2:int ) [line 20]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 67 -> 51 ; -66 [label="66: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___62); [line 25]\n *&SIL_temp_conditional___62:int =3 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +66 [label="66: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___62); [line 20]\n *&SIL_temp_conditional___62:int =3 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 66 -> 62 ; -65 [label="65: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___62); [line 25]\n *&SIL_temp_conditional___62:int =3 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +65 [label="65: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___62); [line 20]\n *&SIL_temp_conditional___62:int =3 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 65 -> 62 ; -64 [label="64: Prune (false branch) \n PRUNE((0 == 0), false); [line 25]\n " shape="invhouse"] +64 [label="64: Prune (false branch) \n PRUNE((0 == 0), false); [line 20]\n " shape="invhouse"] 64 -> 66 ; -63 [label="63: Prune (true branch) \n PRUNE((0 != 0), true); [line 25]\n " shape="invhouse"] +63 [label="63: Prune (true branch) \n PRUNE((0 != 0), true); [line 20]\n " shape="invhouse"] 63 -> 65 ; @@ -23,19 +23,19 @@ digraph iCFG { 62 -> 67 ; -61 [label="61: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___57); [line 25]\n *&SIL_temp_conditional___57:int =1 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +61 [label="61: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___57); [line 20]\n *&SIL_temp_conditional___57:int =1 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 61 -> 57 ; -60 [label="60: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___57); [line 25]\n *&SIL_temp_conditional___57:int =1 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +60 [label="60: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___57); [line 20]\n *&SIL_temp_conditional___57:int =1 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 60 -> 57 ; -59 [label="59: Prune (false branch) \n PRUNE((0 == 0), false); [line 25]\n " shape="invhouse"] +59 [label="59: Prune (false branch) \n PRUNE((0 == 0), false); [line 20]\n " shape="invhouse"] 59 -> 61 ; -58 [label="58: Prune (true branch) \n PRUNE((0 != 0), true); [line 25]\n " shape="invhouse"] +58 [label="58: Prune (true branch) \n PRUNE((0 != 0), true); [line 20]\n " shape="invhouse"] 58 -> 60 ; @@ -44,19 +44,19 @@ digraph iCFG { 57 -> 63 ; 57 -> 64 ; -56 [label="56: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___52); [line 25]\n *&SIL_temp_conditional___52:_fn_ (*)=_fun_some_f [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +56 [label="56: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___52); [line 20]\n *&SIL_temp_conditional___52:_fn_ (*)=_fun_some_f [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 56 -> 52 ; -55 [label="55: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___52); [line 25]\n *&SIL_temp_conditional___52:_fn_ (*)=_fun_some_f [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +55 [label="55: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___52); [line 20]\n *&SIL_temp_conditional___52:_fn_ (*)=_fun_some_f [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 55 -> 52 ; -54 [label="54: Prune (false branch) \n PRUNE((1 == 0), false); [line 25]\n " shape="invhouse"] +54 [label="54: Prune (false branch) \n PRUNE((1 == 0), false); [line 20]\n " shape="invhouse"] 54 -> 56 ; -53 [label="53: Prune (true branch) \n PRUNE((1 != 0), true); [line 25]\n " shape="invhouse"] +53 [label="53: Prune (true branch) \n PRUNE((1 != 0), true); [line 20]\n " shape="invhouse"] 53 -> 55 ; @@ -68,28 +68,28 @@ digraph iCFG { 51 [label="51: Exit fun_ifthenelse4 \n " color=yellow style=filled] -50 [label="50: Start fun_ifthenelse4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +50 [label="50: Start fun_ifthenelse4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 50 -> 53 ; 50 -> 54 ; -49 [label="49: Call _fun_some_f \n n$0=*&SIL_temp_conditional___34:int [line 21]\n NULLIFY(&SIL_temp_conditional___34,true); [line 21]\n n$1=*&SIL_temp_conditional___39:int [line 21]\n NULLIFY(&SIL_temp_conditional___39,true); [line 21]\n n$2=*&SIL_temp_conditional___44:int [line 21]\n NULLIFY(&SIL_temp_conditional___44,true); [line 21]\n _fun_some_f(n$0:int ,n$1:int ,n$2:int ) [line 21]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +49 [label="49: Call _fun_some_f \n n$0=*&SIL_temp_conditional___34:int [line 18]\n NULLIFY(&SIL_temp_conditional___34,true); [line 18]\n n$1=*&SIL_temp_conditional___39:int [line 18]\n NULLIFY(&SIL_temp_conditional___39,true); [line 18]\n n$2=*&SIL_temp_conditional___44:int [line 18]\n NULLIFY(&SIL_temp_conditional___44,true); [line 18]\n _fun_some_f(n$0:int ,n$1:int ,n$2:int ) [line 18]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 49 -> 33 ; -48 [label="48: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 21]\n *&SIL_temp_conditional___44:int =3 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +48 [label="48: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 18]\n *&SIL_temp_conditional___44:int =3 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 48 -> 44 ; -47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 21]\n *&SIL_temp_conditional___44:int =3 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 18]\n *&SIL_temp_conditional___44:int =3 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 47 -> 44 ; -46 [label="46: Prune (false branch) \n PRUNE((0 == 0), false); [line 21]\n " shape="invhouse"] +46 [label="46: Prune (false branch) \n PRUNE((0 == 0), false); [line 18]\n " shape="invhouse"] 46 -> 48 ; -45 [label="45: Prune (true branch) \n PRUNE((0 != 0), true); [line 21]\n " shape="invhouse"] +45 [label="45: Prune (true branch) \n PRUNE((0 != 0), true); [line 18]\n " shape="invhouse"] 45 -> 47 ; @@ -97,19 +97,19 @@ digraph iCFG { 44 -> 49 ; -43 [label="43: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___39); [line 21]\n *&SIL_temp_conditional___39:int =2 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +43 [label="43: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___39); [line 18]\n *&SIL_temp_conditional___39:int =2 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 43 -> 39 ; -42 [label="42: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___39); [line 21]\n *&SIL_temp_conditional___39:int =2 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +42 [label="42: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___39); [line 18]\n *&SIL_temp_conditional___39:int =2 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 42 -> 39 ; -41 [label="41: Prune (false branch) \n PRUNE((0 == 0), false); [line 21]\n " shape="invhouse"] +41 [label="41: Prune (false branch) \n PRUNE((0 == 0), false); [line 18]\n " shape="invhouse"] 41 -> 43 ; -40 [label="40: Prune (true branch) \n PRUNE((0 != 0), true); [line 21]\n " shape="invhouse"] +40 [label="40: Prune (true branch) \n PRUNE((0 != 0), true); [line 18]\n " shape="invhouse"] 40 -> 42 ; @@ -118,19 +118,19 @@ digraph iCFG { 39 -> 45 ; 39 -> 46 ; -38 [label="38: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___34); [line 21]\n *&SIL_temp_conditional___34:int =1 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +38 [label="38: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___34); [line 18]\n *&SIL_temp_conditional___34:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 38 -> 34 ; -37 [label="37: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___34); [line 21]\n *&SIL_temp_conditional___34:int =1 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +37 [label="37: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___34); [line 18]\n *&SIL_temp_conditional___34:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 37 -> 34 ; -36 [label="36: Prune (false branch) \n PRUNE((0 == 0), false); [line 21]\n " shape="invhouse"] +36 [label="36: Prune (false branch) \n PRUNE((0 == 0), false); [line 18]\n " shape="invhouse"] 36 -> 38 ; -35 [label="35: Prune (true branch) \n PRUNE((0 != 0), true); [line 21]\n " shape="invhouse"] +35 [label="35: Prune (true branch) \n PRUNE((0 != 0), true); [line 18]\n " shape="invhouse"] 35 -> 37 ; @@ -142,28 +142,28 @@ digraph iCFG { 33 [label="33: Exit fun_ifthenelse3 \n " color=yellow style=filled] -32 [label="32: Start fun_ifthenelse3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] +32 [label="32: Start fun_ifthenelse3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 32 -> 35 ; 32 -> 36 ; -31 [label="31: Call n$0 \n n$0=*&SIL_temp_conditional___11:_fn_ (*) [line 17]\n NULLIFY(&SIL_temp_conditional___11,true); [line 17]\n n$1=*&SIL_temp_conditional___16:int [line 17]\n NULLIFY(&SIL_temp_conditional___16,true); [line 17]\n n$2=*&SIL_temp_conditional___21:int [line 17]\n NULLIFY(&SIL_temp_conditional___21,true); [line 17]\n n$3=*&SIL_temp_conditional___26:int [line 17]\n NULLIFY(&SIL_temp_conditional___26,true); [line 17]\n n$0(n$1:int ,n$2:int ,n$3:int ) [line 17]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +31 [label="31: Call n$0 \n n$0=*&SIL_temp_conditional___11:_fn_ (*) [line 15]\n NULLIFY(&SIL_temp_conditional___11,true); [line 15]\n n$1=*&SIL_temp_conditional___16:int [line 15]\n NULLIFY(&SIL_temp_conditional___16,true); [line 15]\n n$2=*&SIL_temp_conditional___21:int [line 15]\n NULLIFY(&SIL_temp_conditional___21,true); [line 15]\n n$3=*&SIL_temp_conditional___26:int [line 15]\n NULLIFY(&SIL_temp_conditional___26,true); [line 15]\n n$0(n$1:int ,n$2:int ,n$3:int ) [line 15]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 31 -> 10 ; -30 [label="30: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___26); [line 17]\n *&SIL_temp_conditional___26:int =3 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +30 [label="30: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___26); [line 15]\n *&SIL_temp_conditional___26:int =3 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 30 -> 26 ; -29 [label="29: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___26); [line 17]\n *&SIL_temp_conditional___26:int =3 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +29 [label="29: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___26); [line 15]\n *&SIL_temp_conditional___26:int =3 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 29 -> 26 ; -28 [label="28: Prune (false branch) \n PRUNE((0 == 0), false); [line 17]\n " shape="invhouse"] +28 [label="28: Prune (false branch) \n PRUNE((0 == 0), false); [line 15]\n " shape="invhouse"] 28 -> 30 ; -27 [label="27: Prune (true branch) \n PRUNE((0 != 0), true); [line 17]\n " shape="invhouse"] +27 [label="27: Prune (true branch) \n PRUNE((0 != 0), true); [line 15]\n " shape="invhouse"] 27 -> 29 ; @@ -171,19 +171,19 @@ digraph iCFG { 26 -> 31 ; -25 [label="25: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___21); [line 17]\n *&SIL_temp_conditional___21:int =2 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +25 [label="25: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___21); [line 15]\n *&SIL_temp_conditional___21:int =2 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 25 -> 21 ; -24 [label="24: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___21); [line 17]\n *&SIL_temp_conditional___21:int =2 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +24 [label="24: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___21); [line 15]\n *&SIL_temp_conditional___21:int =2 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 24 -> 21 ; -23 [label="23: Prune (false branch) \n PRUNE((0 == 0), false); [line 17]\n " shape="invhouse"] +23 [label="23: Prune (false branch) \n PRUNE((0 == 0), false); [line 15]\n " shape="invhouse"] 23 -> 25 ; -22 [label="22: Prune (true branch) \n PRUNE((0 != 0), true); [line 17]\n " shape="invhouse"] +22 [label="22: Prune (true branch) \n PRUNE((0 != 0), true); [line 15]\n " shape="invhouse"] 22 -> 24 ; @@ -192,19 +192,19 @@ digraph iCFG { 21 -> 27 ; 21 -> 28 ; -20 [label="20: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___16); [line 17]\n *&SIL_temp_conditional___16:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +20 [label="20: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___16); [line 15]\n *&SIL_temp_conditional___16:int =1 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 20 -> 16 ; -19 [label="19: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___16); [line 17]\n *&SIL_temp_conditional___16:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +19 [label="19: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___16); [line 15]\n *&SIL_temp_conditional___16:int =1 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 19 -> 16 ; -18 [label="18: Prune (false branch) \n PRUNE((0 == 0), false); [line 17]\n " shape="invhouse"] +18 [label="18: Prune (false branch) \n PRUNE((0 == 0), false); [line 15]\n " shape="invhouse"] 18 -> 20 ; -17 [label="17: Prune (true branch) \n PRUNE((0 != 0), true); [line 17]\n " shape="invhouse"] +17 [label="17: Prune (true branch) \n PRUNE((0 != 0), true); [line 15]\n " shape="invhouse"] 17 -> 19 ; @@ -213,19 +213,19 @@ digraph iCFG { 16 -> 22 ; 16 -> 23 ; -15 [label="15: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 17]\n *&SIL_temp_conditional___11:_fn_ (*)=_fun_some_f [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +15 [label="15: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 15]\n *&SIL_temp_conditional___11:_fn_ (*)=_fun_some_f [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 15 -> 11 ; -14 [label="14: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 17]\n *&SIL_temp_conditional___11:_fn_ (*)=_fun_some_f [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +14 [label="14: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 15]\n *&SIL_temp_conditional___11:_fn_ (*)=_fun_some_f [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 14 -> 11 ; -13 [label="13: Prune (false branch) \n PRUNE((1 == 0), false); [line 17]\n " shape="invhouse"] +13 [label="13: Prune (false branch) \n PRUNE((1 == 0), false); [line 15]\n " shape="invhouse"] 13 -> 15 ; -12 [label="12: Prune (true branch) \n PRUNE((1 != 0), true); [line 17]\n " shape="invhouse"] +12 [label="12: Prune (true branch) \n PRUNE((1 != 0), true); [line 15]\n " shape="invhouse"] 12 -> 14 ; @@ -237,28 +237,28 @@ digraph iCFG { 10 [label="10: Exit fun_ifthenelse2 \n " color=yellow style=filled] -9 [label="9: Start fun_ifthenelse2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] +9 [label="9: Start fun_ifthenelse2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 9 -> 12 ; 9 -> 13 ; -8 [label="8: Call n$0 \n n$0=*&SIL_temp_conditional___3:_fn_ (*) [line 13]\n NULLIFY(&SIL_temp_conditional___3,true); [line 13]\n n$0(1:int ,2:int ,3:int ) [line 13]\n REMOVE_TEMPS(n$0); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +8 [label="8: Call n$0 \n n$0=*&SIL_temp_conditional___3:_fn_ (*) [line 12]\n NULLIFY(&SIL_temp_conditional___3,true); [line 12]\n n$0(1:int ,2:int ,3:int ) [line 12]\n REMOVE_TEMPS(n$0); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 8 -> 2 ; -7 [label="7: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 13]\n *&SIL_temp_conditional___3:_fn_ (*)=_fun_some_f [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +7 [label="7: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 12]\n *&SIL_temp_conditional___3:_fn_ (*)=_fun_some_f [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 7 -> 3 ; -6 [label="6: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 13]\n *&SIL_temp_conditional___3:_fn_ (*)=_fun_some_f [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +6 [label="6: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___3); [line 12]\n *&SIL_temp_conditional___3:_fn_ (*)=_fun_some_f [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 6 -> 3 ; -5 [label="5: Prune (false branch) \n PRUNE((1 == 0), false); [line 13]\n " shape="invhouse"] +5 [label="5: Prune (false branch) \n PRUNE((1 == 0), false); [line 12]\n " shape="invhouse"] 5 -> 7 ; -4 [label="4: Prune (true branch) \n PRUNE((1 != 0), true); [line 13]\n " shape="invhouse"] +4 [label="4: Prune (true branch) \n PRUNE((1 != 0), true); [line 12]\n " shape="invhouse"] 4 -> 6 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c index 0f7cf7096..4cab9b883 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c @@ -7,60 +7,51 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include - -void shortcircuit_or(int *x) { - //x = 0; - if (x == 0 || *x == 2){ x=17;} else {x=32; }; +#include + +void shortcircuit_or(int* x) { + // x = 0; + if (x == 0 || *x == 2) { + x = 17; + } else { + x = 32; + }; } -void shortcircuit_and(int *x) { - if (!x && !(x =getenv ("BLOCK"))) { - x=17; - } - else { - *x=32; - }; +void shortcircuit_and(int* x) { + if (!x && !(x = getenv("BLOCK"))) { + x = 17; + } else { + *x = 32; + }; } +void test_loop() { + char* spec; + char* block_size; -void test_loop () { - - char* spec; - char* block_size; - - spec= getenv ("BLOCK"); - -while((! spec - && ! (spec = getenv ("BLOCK_SIZE")) - && ! (spec = getenv ("BLOCKSIZE")))) { - block_size =0; - - } - + spec = getenv("BLOCK"); + while ((!spec && !(spec = getenv("BLOCK_SIZE")) && + !(spec = getenv("BLOCKSIZE")))) { + block_size = 0; + } } - int main() { - char* spec; - char* block_size; - - spec= getenv ("BLOCK"); - - + char* spec; + char* block_size; - if (! spec - && ! (spec = getenv ("BLOCK_SIZE")) - && ! (spec = getenv ("BLOCKSIZE"))) - block_size = 0; - else - { - if (*spec == '\'') - block_size=0; } + spec = getenv("BLOCK"); + if (!spec && !(spec = getenv("BLOCK_SIZE")) && !(spec = getenv("BLOCKSIZE"))) + block_size = 0; + else { + if (*spec == '\'') + block_size = 0; + } - return 0; + return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot index cf5ddc6ee..fd8755b70 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/if_short_circuit.c.dot @@ -1,22 +1,22 @@ digraph iCFG { -93 [label="93: BinaryOperatorStmt: Assign \n n$10=_fun_getenv(\"BLOCK\":char *) [line 51]\n *&spec:char *=n$10 [line 51]\n REMOVE_TEMPS(n$10); [line 51]\n " shape="box"] +93 [label="93: BinaryOperatorStmt: Assign \n n$10=_fun_getenv(\"BLOCK\":char *) [line 47]\n *&spec:char *=n$10 [line 47]\n REMOVE_TEMPS(n$10); [line 47]\n " shape="box"] 93 -> 65 ; 93 -> 66 ; -92 [label="92: BinaryOperatorStmt: Assign \n *&block_size:char *=0 [line 62]\n NULLIFY(&block_size,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +92 [label="92: BinaryOperatorStmt: Assign \n *&block_size:char *=0 [line 53]\n NULLIFY(&block_size,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] 92 -> 88 ; -91 [label="91: Prune (false branch) \n PRUNE(((n$9 == 39) == 0), false); [line 61]\n REMOVE_TEMPS(n$8,n$9); [line 61]\n APPLY_ABSTRACTION; [line 61]\n " shape="invhouse"] +91 [label="91: Prune (false branch) \n PRUNE(((n$9 == 39) == 0), false); [line 52]\n REMOVE_TEMPS(n$8,n$9); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="invhouse"] 91 -> 88 ; -90 [label="90: Prune (true branch) \n PRUNE(((n$9 == 39) != 0), true); [line 61]\n REMOVE_TEMPS(n$8,n$9); [line 61]\n " shape="invhouse"] +90 [label="90: Prune (true branch) \n PRUNE(((n$9 == 39) != 0), true); [line 52]\n REMOVE_TEMPS(n$8,n$9); [line 52]\n " shape="invhouse"] 90 -> 92 ; -89 [label="89: BinaryOperatorStmt: EQ \n n$8=*&spec:char * [line 61]\n n$9=*n$8:char [line 61]\n NULLIFY(&spec,false); [line 61]\n " shape="box"] +89 [label="89: BinaryOperatorStmt: EQ \n n$8=*&spec:char * [line 52]\n n$9=*n$8:char [line 52]\n NULLIFY(&spec,false); [line 52]\n " shape="box"] 89 -> 90 ; @@ -25,35 +25,35 @@ digraph iCFG { 88 -> 63 ; -87 [label="87: BinaryOperatorStmt: Assign \n *&block_size:char *=0 [line 58]\n NULLIFY(&block_size,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] +87 [label="87: BinaryOperatorStmt: Assign \n *&block_size:char *=0 [line 50]\n NULLIFY(&block_size,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] 87 -> 63 ; -86 [label="86: Prune (false branch) \n n$7=*&SIL_temp_conditional___79:int [line 57]\n NULLIFY(&SIL_temp_conditional___79,true); [line 57]\n PRUNE((n$7 == 0), false); [line 57]\n REMOVE_TEMPS(n$7); [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="invhouse"] +86 [label="86: Prune (false branch) \n n$7=*&SIL_temp_conditional___79:int [line 49]\n NULLIFY(&SIL_temp_conditional___79,true); [line 49]\n PRUNE((n$7 == 0), false); [line 49]\n REMOVE_TEMPS(n$7); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="invhouse"] 86 -> 89 ; -85 [label="85: Prune (true branch) \n n$7=*&SIL_temp_conditional___79:int [line 57]\n NULLIFY(&SIL_temp_conditional___79,true); [line 57]\n PRUNE((n$7 != 0), true); [line 57]\n REMOVE_TEMPS(n$7); [line 57]\n NULLIFY(&spec,false); [line 57]\n " shape="invhouse"] +85 [label="85: Prune (true branch) \n n$7=*&SIL_temp_conditional___79:int [line 49]\n NULLIFY(&SIL_temp_conditional___79,true); [line 49]\n PRUNE((n$7 != 0), true); [line 49]\n REMOVE_TEMPS(n$7); [line 49]\n NULLIFY(&spec,false); [line 49]\n " shape="invhouse"] 85 -> 87 ; -84 [label="84: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___79); [line 57]\n *&SIL_temp_conditional___79:int =1 [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] +84 [label="84: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___79); [line 49]\n *&SIL_temp_conditional___79:int =1 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 84 -> 79 ; -83 [label="83: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___79); [line 57]\n *&SIL_temp_conditional___79:int =0 [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] +83 [label="83: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___79); [line 49]\n *&SIL_temp_conditional___79:int =0 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 83 -> 79 ; -82 [label="82: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 57]\n REMOVE_TEMPS(n$5,n$6); [line 57]\n " shape="invhouse"] +82 [label="82: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 49]\n REMOVE_TEMPS(n$5,n$6); [line 49]\n " shape="invhouse"] 82 -> 84 ; -81 [label="81: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 57]\n REMOVE_TEMPS(n$5,n$6); [line 57]\n " shape="invhouse"] +81 [label="81: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 49]\n REMOVE_TEMPS(n$5,n$6); [line 49]\n " shape="invhouse"] 81 -> 83 ; -80 [label="80: BinaryOperatorStmt: Assign \n n$5=_fun_getenv(\"BLOCKSIZE\":char *) [line 57]\n *&spec:char *=n$5 [line 57]\n n$6=*&spec:char * [line 57]\n " shape="box"] +80 [label="80: BinaryOperatorStmt: Assign \n n$5=_fun_getenv(\"BLOCKSIZE\":char *) [line 49]\n *&spec:char *=n$5 [line 49]\n n$6=*&spec:char * [line 49]\n " shape="box"] 80 -> 81 ; @@ -63,31 +63,31 @@ digraph iCFG { 79 -> 85 ; 79 -> 86 ; -78 [label="78: Prune (false branch) \n n$4=*&SIL_temp_conditional___71:int [line 56]\n NULLIFY(&SIL_temp_conditional___71,true); [line 56]\n PRUNE((n$4 == 0), false); [line 56]\n REMOVE_TEMPS(n$4); [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="invhouse"] +78 [label="78: Prune (false branch) \n n$4=*&SIL_temp_conditional___71:int [line 49]\n NULLIFY(&SIL_temp_conditional___71,true); [line 49]\n PRUNE((n$4 == 0), false); [line 49]\n REMOVE_TEMPS(n$4); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="invhouse"] 78 -> 89 ; -77 [label="77: Prune (true branch) \n n$4=*&SIL_temp_conditional___71:int [line 56]\n NULLIFY(&SIL_temp_conditional___71,true); [line 56]\n PRUNE((n$4 != 0), true); [line 56]\n REMOVE_TEMPS(n$4); [line 56]\n NULLIFY(&spec,false); [line 56]\n " shape="invhouse"] +77 [label="77: Prune (true branch) \n n$4=*&SIL_temp_conditional___71:int [line 49]\n NULLIFY(&SIL_temp_conditional___71,true); [line 49]\n PRUNE((n$4 != 0), true); [line 49]\n REMOVE_TEMPS(n$4); [line 49]\n NULLIFY(&spec,false); [line 49]\n " shape="invhouse"] 77 -> 80 ; -76 [label="76: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___71); [line 56]\n *&SIL_temp_conditional___71:int =1 [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] +76 [label="76: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___71); [line 49]\n *&SIL_temp_conditional___71:int =1 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 76 -> 71 ; -75 [label="75: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___71); [line 56]\n *&SIL_temp_conditional___71:int =0 [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] +75 [label="75: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___71); [line 49]\n *&SIL_temp_conditional___71:int =0 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 75 -> 71 ; -74 [label="74: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 56]\n REMOVE_TEMPS(n$2,n$3); [line 56]\n " shape="invhouse"] +74 [label="74: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 49]\n REMOVE_TEMPS(n$2,n$3); [line 49]\n " shape="invhouse"] 74 -> 76 ; -73 [label="73: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 56]\n REMOVE_TEMPS(n$2,n$3); [line 56]\n " shape="invhouse"] +73 [label="73: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 49]\n REMOVE_TEMPS(n$2,n$3); [line 49]\n " shape="invhouse"] 73 -> 75 ; -72 [label="72: BinaryOperatorStmt: Assign \n n$2=_fun_getenv(\"BLOCK_SIZE\":char *) [line 56]\n *&spec:char *=n$2 [line 56]\n n$3=*&spec:char * [line 56]\n " shape="box"] +72 [label="72: BinaryOperatorStmt: Assign \n n$2=_fun_getenv(\"BLOCK_SIZE\":char *) [line 49]\n *&spec:char *=n$2 [line 49]\n n$3=*&spec:char * [line 49]\n " shape="box"] 72 -> 73 ; @@ -97,27 +97,27 @@ digraph iCFG { 71 -> 77 ; 71 -> 78 ; -70 [label="70: Prune (false branch) \n n$1=*&SIL_temp_conditional___64:int [line 55]\n NULLIFY(&SIL_temp_conditional___64,true); [line 55]\n PRUNE((n$1 == 0), false); [line 55]\n REMOVE_TEMPS(n$1); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="invhouse"] +70 [label="70: Prune (false branch) \n n$1=*&SIL_temp_conditional___64:int [line 49]\n NULLIFY(&SIL_temp_conditional___64,true); [line 49]\n PRUNE((n$1 == 0), false); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="invhouse"] 70 -> 89 ; -69 [label="69: Prune (true branch) \n n$1=*&SIL_temp_conditional___64:int [line 55]\n NULLIFY(&SIL_temp_conditional___64,true); [line 55]\n PRUNE((n$1 != 0), true); [line 55]\n REMOVE_TEMPS(n$1); [line 55]\n NULLIFY(&spec,false); [line 55]\n " shape="invhouse"] +69 [label="69: Prune (true branch) \n n$1=*&SIL_temp_conditional___64:int [line 49]\n NULLIFY(&SIL_temp_conditional___64,true); [line 49]\n PRUNE((n$1 != 0), true); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n NULLIFY(&spec,false); [line 49]\n " shape="invhouse"] 69 -> 72 ; -68 [label="68: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___64); [line 55]\n *&SIL_temp_conditional___64:int =1 [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +68 [label="68: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___64); [line 49]\n *&SIL_temp_conditional___64:int =1 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 68 -> 64 ; -67 [label="67: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___64); [line 55]\n *&SIL_temp_conditional___64:int =0 [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +67 [label="67: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___64); [line 49]\n *&SIL_temp_conditional___64:int =0 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 67 -> 64 ; -66 [label="66: Prune (false branch) \n n$0=*&spec:char * [line 55]\n PRUNE((n$0 == 0), false); [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n " shape="invhouse"] +66 [label="66: Prune (false branch) \n n$0=*&spec:char * [line 49]\n PRUNE((n$0 == 0), false); [line 49]\n REMOVE_TEMPS(n$0); [line 49]\n " shape="invhouse"] 66 -> 68 ; -65 [label="65: Prune (true branch) \n n$0=*&spec:char * [line 55]\n PRUNE((n$0 != 0), true); [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n " shape="invhouse"] +65 [label="65: Prune (true branch) \n n$0=*&spec:char * [line 49]\n PRUNE((n$0 != 0), true); [line 49]\n REMOVE_TEMPS(n$0); [line 49]\n " shape="invhouse"] 65 -> 67 ; @@ -130,18 +130,18 @@ digraph iCFG { 63 -> 62 ; -62 [label="62: Return Stmt \n *&return:int =0 [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] +62 [label="62: Return Stmt \n *&return:int =0 [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] 62 -> 61 ; 61 [label="61: Exit main \n " color=yellow style=filled] -60 [label="60: Start main\nFormals: \nLocals: block_size:char * spec:char * \n DECLARE_LOCALS(&return,&block_size,&spec); [line 46]\n NULLIFY(&block_size,false); [line 46]\n NULLIFY(&spec,false); [line 46]\n " color=yellow style=filled] +60 [label="60: Start main\nFormals: \nLocals: block_size:char * spec:char * \n DECLARE_LOCALS(&return,&block_size,&spec); [line 42]\n NULLIFY(&block_size,false); [line 42]\n NULLIFY(&spec,false); [line 42]\n " color=yellow style=filled] 60 -> 93 ; -59 [label="59: BinaryOperatorStmt: Assign \n n$8=_fun_getenv(\"BLOCK\":char *) [line 33]\n *&spec:char *=n$8 [line 33]\n REMOVE_TEMPS(n$8); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +59 [label="59: BinaryOperatorStmt: Assign \n n$8=_fun_getenv(\"BLOCK\":char *) [line 34]\n *&spec:char *=n$8 [line 34]\n REMOVE_TEMPS(n$8); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] 59 -> 34 ; @@ -217,27 +217,27 @@ digraph iCFG { 42 -> 48 ; 42 -> 49 ; -41 [label="41: Prune (false branch) \n n$1=*&SIL_temp_conditional___35:int [line 35]\n NULLIFY(&SIL_temp_conditional___35,true); [line 35]\n PRUNE((n$1 == 0), false); [line 35]\n REMOVE_TEMPS(n$1); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="invhouse"] +41 [label="41: Prune (false branch) \n n$1=*&SIL_temp_conditional___35:int [line 36]\n NULLIFY(&SIL_temp_conditional___35,true); [line 36]\n PRUNE((n$1 == 0), false); [line 36]\n REMOVE_TEMPS(n$1); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="invhouse"] 41 -> 33 ; -40 [label="40: Prune (true branch) \n n$1=*&SIL_temp_conditional___35:int [line 35]\n NULLIFY(&SIL_temp_conditional___35,true); [line 35]\n PRUNE((n$1 != 0), true); [line 35]\n REMOVE_TEMPS(n$1); [line 35]\n " shape="invhouse"] +40 [label="40: Prune (true branch) \n n$1=*&SIL_temp_conditional___35:int [line 36]\n NULLIFY(&SIL_temp_conditional___35,true); [line 36]\n PRUNE((n$1 != 0), true); [line 36]\n REMOVE_TEMPS(n$1); [line 36]\n " shape="invhouse"] 40 -> 43 ; -39 [label="39: ConditinalStmt Branch \n NULLIFY(&spec,false); [line 35]\n DECLARE_LOCALS(&SIL_temp_conditional___35); [line 35]\n *&SIL_temp_conditional___35:int =1 [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] +39 [label="39: ConditinalStmt Branch \n NULLIFY(&spec,false); [line 36]\n DECLARE_LOCALS(&SIL_temp_conditional___35); [line 36]\n *&SIL_temp_conditional___35:int =1 [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 39 -> 35 ; -38 [label="38: ConditinalStmt Branch \n NULLIFY(&spec,false); [line 35]\n DECLARE_LOCALS(&SIL_temp_conditional___35); [line 35]\n *&SIL_temp_conditional___35:int =0 [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] +38 [label="38: ConditinalStmt Branch \n NULLIFY(&spec,false); [line 36]\n DECLARE_LOCALS(&SIL_temp_conditional___35); [line 36]\n *&SIL_temp_conditional___35:int =0 [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 38 -> 35 ; -37 [label="37: Prune (false branch) \n n$0=*&spec:char * [line 35]\n PRUNE((n$0 == 0), false); [line 35]\n REMOVE_TEMPS(n$0); [line 35]\n " shape="invhouse"] +37 [label="37: Prune (false branch) \n n$0=*&spec:char * [line 36]\n PRUNE((n$0 == 0), false); [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n " shape="invhouse"] 37 -> 39 ; -36 [label="36: Prune (true branch) \n n$0=*&spec:char * [line 35]\n PRUNE((n$0 != 0), true); [line 35]\n REMOVE_TEMPS(n$0); [line 35]\n " shape="invhouse"] +36 [label="36: Prune (true branch) \n n$0=*&spec:char * [line 36]\n PRUNE((n$0 != 0), true); [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n " shape="invhouse"] 36 -> 38 ; @@ -254,43 +254,43 @@ digraph iCFG { 33 [label="33: Exit test_loop \n " color=yellow style=filled] -32 [label="32: Start test_loop\nFormals: \nLocals: block_size:char * spec:char * \n DECLARE_LOCALS(&return,&block_size,&spec); [line 28]\n NULLIFY(&block_size,false); [line 28]\n NULLIFY(&spec,false); [line 28]\n " color=yellow style=filled] +32 [label="32: Start test_loop\nFormals: \nLocals: block_size:char * spec:char * \n DECLARE_LOCALS(&return,&block_size,&spec); [line 29]\n NULLIFY(&block_size,false); [line 29]\n NULLIFY(&spec,false); [line 29]\n " color=yellow style=filled] 32 -> 59 ; -31 [label="31: BinaryOperatorStmt: Assign \n n$5=*&x:int * [line 22]\n *n$5:int =32 [line 22]\n REMOVE_TEMPS(n$5); [line 22]\n NULLIFY(&x,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +31 [label="31: BinaryOperatorStmt: Assign \n n$5=*&x:int * [line 25]\n *n$5:int =32 [line 25]\n REMOVE_TEMPS(n$5); [line 25]\n NULLIFY(&x,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 31 -> 14 ; -30 [label="30: BinaryOperatorStmt: Assign \n *&x:int *=17 [line 19]\n NULLIFY(&x,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +30 [label="30: BinaryOperatorStmt: Assign \n *&x:int *=17 [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 30 -> 14 ; -29 [label="29: Prune (false branch) \n n$4=*&SIL_temp_conditional___22:int [line 18]\n NULLIFY(&SIL_temp_conditional___22,true); [line 18]\n PRUNE((n$4 == 0), false); [line 18]\n REMOVE_TEMPS(n$4); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="invhouse"] +29 [label="29: Prune (false branch) \n n$4=*&SIL_temp_conditional___22:int [line 22]\n NULLIFY(&SIL_temp_conditional___22,true); [line 22]\n PRUNE((n$4 == 0), false); [line 22]\n REMOVE_TEMPS(n$4); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="invhouse"] 29 -> 31 ; -28 [label="28: Prune (true branch) \n n$4=*&SIL_temp_conditional___22:int [line 18]\n NULLIFY(&SIL_temp_conditional___22,true); [line 18]\n PRUNE((n$4 != 0), true); [line 18]\n REMOVE_TEMPS(n$4); [line 18]\n NULLIFY(&x,false); [line 18]\n " shape="invhouse"] +28 [label="28: Prune (true branch) \n n$4=*&SIL_temp_conditional___22:int [line 22]\n NULLIFY(&SIL_temp_conditional___22,true); [line 22]\n PRUNE((n$4 != 0), true); [line 22]\n REMOVE_TEMPS(n$4); [line 22]\n NULLIFY(&x,false); [line 22]\n " shape="invhouse"] 28 -> 30 ; -27 [label="27: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___22); [line 18]\n *&SIL_temp_conditional___22:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +27 [label="27: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___22); [line 22]\n *&SIL_temp_conditional___22:int =1 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 27 -> 22 ; -26 [label="26: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___22); [line 18]\n *&SIL_temp_conditional___22:int =0 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +26 [label="26: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___22); [line 22]\n *&SIL_temp_conditional___22:int =0 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 26 -> 22 ; -25 [label="25: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 18]\n REMOVE_TEMPS(n$2,n$3); [line 18]\n " shape="invhouse"] +25 [label="25: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 22]\n REMOVE_TEMPS(n$2,n$3); [line 22]\n " shape="invhouse"] 25 -> 27 ; -24 [label="24: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 18]\n REMOVE_TEMPS(n$2,n$3); [line 18]\n " shape="invhouse"] +24 [label="24: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 22]\n REMOVE_TEMPS(n$2,n$3); [line 22]\n " shape="invhouse"] 24 -> 26 ; -23 [label="23: BinaryOperatorStmt: Assign \n n$2=_fun_getenv(\"BLOCK\":char *) [line 18]\n *&x:int *=n$2 [line 18]\n n$3=*&x:int * [line 18]\n " shape="box"] +23 [label="23: BinaryOperatorStmt: Assign \n n$2=_fun_getenv(\"BLOCK\":char *) [line 22]\n *&x:int *=n$2 [line 22]\n n$3=*&x:int * [line 22]\n " shape="box"] 23 -> 24 ; @@ -300,27 +300,27 @@ digraph iCFG { 22 -> 28 ; 22 -> 29 ; -21 [label="21: Prune (false branch) \n n$1=*&SIL_temp_conditional___15:int [line 18]\n NULLIFY(&SIL_temp_conditional___15,true); [line 18]\n PRUNE((n$1 == 0), false); [line 18]\n REMOVE_TEMPS(n$1); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="invhouse"] +21 [label="21: Prune (false branch) \n n$1=*&SIL_temp_conditional___15:int [line 22]\n NULLIFY(&SIL_temp_conditional___15,true); [line 22]\n PRUNE((n$1 == 0), false); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="invhouse"] 21 -> 31 ; -20 [label="20: Prune (true branch) \n n$1=*&SIL_temp_conditional___15:int [line 18]\n NULLIFY(&SIL_temp_conditional___15,true); [line 18]\n PRUNE((n$1 != 0), true); [line 18]\n REMOVE_TEMPS(n$1); [line 18]\n NULLIFY(&x,false); [line 18]\n " shape="invhouse"] +20 [label="20: Prune (true branch) \n n$1=*&SIL_temp_conditional___15:int [line 22]\n NULLIFY(&SIL_temp_conditional___15,true); [line 22]\n PRUNE((n$1 != 0), true); [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n NULLIFY(&x,false); [line 22]\n " shape="invhouse"] 20 -> 23 ; -19 [label="19: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 18]\n *&SIL_temp_conditional___15:int =1 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +19 [label="19: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =1 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 19 -> 15 ; -18 [label="18: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 18]\n *&SIL_temp_conditional___15:int =0 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +18 [label="18: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =0 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 18 -> 15 ; -17 [label="17: Prune (false branch) \n n$0=*&x:int * [line 18]\n PRUNE((n$0 == 0), false); [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n " shape="invhouse"] +17 [label="17: Prune (false branch) \n n$0=*&x:int * [line 22]\n PRUNE((n$0 == 0), false); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] 17 -> 19 ; -16 [label="16: Prune (true branch) \n n$0=*&x:int * [line 18]\n PRUNE((n$0 != 0), true); [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n " shape="invhouse"] +16 [label="16: Prune (true branch) \n n$0=*&x:int * [line 22]\n PRUNE((n$0 != 0), true); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] 16 -> 18 ; @@ -336,16 +336,16 @@ digraph iCFG { 13 [label="13: Exit shortcircuit_and \n " color=yellow style=filled] -12 [label="12: Start shortcircuit_and\nFormals: x:int *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +12 [label="12: Start shortcircuit_and\nFormals: x:int *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 12 -> 16 ; 12 -> 17 ; -11 [label="11: BinaryOperatorStmt: Assign \n *&x:int *=32 [line 14]\n NULLIFY(&x,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +11 [label="11: BinaryOperatorStmt: Assign \n *&x:int *=32 [line 17]\n NULLIFY(&x,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 11 -> 3 ; -10 [label="10: BinaryOperatorStmt: Assign \n NULLIFY(&x,false); [line 14]\n *&x:int *=17 [line 14]\n NULLIFY(&x,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n NULLIFY(&x,false); [line 15]\n *&x:int *=17 [line 15]\n NULLIFY(&x,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 10 -> 3 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c index 3fa9dbd73..0b7e98c43 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c @@ -7,28 +7,23 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int identity(int x) { - return x; -} - +int identity(int x) { return x; } int bar(int x) { - if (identity(x)) { - return 1; - } else { - return 0; - } + if (identity(x)) { + return 1; + } else { + return 0; + } } int baz(int x) { - if (identity(!x)) { - return 1; - } else { - return 0; - } + if (identity(!x)) { + return 1; + } else { + return 0; + } } -int neg(int x) { - return !x; -} +int neg(int x) { return !x; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c.dot index 24d706e3a..013472aab 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/int_negation.c.dot @@ -1,21 +1,21 @@ digraph iCFG { -32 [label="32: Return Stmt \n n$1=*&SIL_temp_conditional___27:int [line 33]\n NULLIFY(&SIL_temp_conditional___27,true); [line 33]\n *&return:int =n$1 [line 33]\n REMOVE_TEMPS(n$1); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +32 [label="32: Return Stmt \n n$1=*&SIL_temp_conditional___27:int [line 29]\n NULLIFY(&SIL_temp_conditional___27,true); [line 29]\n *&return:int =n$1 [line 29]\n REMOVE_TEMPS(n$1); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 32 -> 26 ; -31 [label="31: ConditinalStmt Branch \n NULLIFY(&x,false); [line 33]\n DECLARE_LOCALS(&SIL_temp_conditional___27); [line 33]\n *&SIL_temp_conditional___27:int =1 [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +31 [label="31: ConditinalStmt Branch \n NULLIFY(&x,false); [line 29]\n DECLARE_LOCALS(&SIL_temp_conditional___27); [line 29]\n *&SIL_temp_conditional___27:int =1 [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 31 -> 27 ; -30 [label="30: ConditinalStmt Branch \n NULLIFY(&x,false); [line 33]\n DECLARE_LOCALS(&SIL_temp_conditional___27); [line 33]\n *&SIL_temp_conditional___27:int =0 [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +30 [label="30: ConditinalStmt Branch \n NULLIFY(&x,false); [line 29]\n DECLARE_LOCALS(&SIL_temp_conditional___27); [line 29]\n *&SIL_temp_conditional___27:int =0 [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 30 -> 27 ; -29 [label="29: Prune (false branch) \n n$0=*&x:int [line 33]\n PRUNE((n$0 == 0), false); [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n " shape="invhouse"] +29 [label="29: Prune (false branch) \n n$0=*&x:int [line 29]\n PRUNE((n$0 == 0), false); [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n " shape="invhouse"] 29 -> 31 ; -28 [label="28: Prune (true branch) \n n$0=*&x:int [line 33]\n PRUNE((n$0 != 0), true); [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n " shape="invhouse"] +28 [label="28: Prune (true branch) \n n$0=*&x:int [line 29]\n PRUNE((n$0 != 0), true); [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n " shape="invhouse"] 28 -> 30 ; @@ -26,45 +26,45 @@ digraph iCFG { 26 [label="26: Exit neg \n " color=yellow style=filled] -25 [label="25: Start neg\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +25 [label="25: Start neg\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] 25 -> 28 ; 25 -> 29 ; -24 [label="24: Return Stmt \n *&return:int =0 [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +24 [label="24: Return Stmt \n *&return:int =0 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 24 -> 13 ; -23 [label="23: Return Stmt \n *&return:int =1 [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +23 [label="23: Return Stmt \n *&return:int =1 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 23 -> 13 ; -22 [label="22: Prune (false branch) \n PRUNE((n$2 == 0), false); [line 25]\n REMOVE_TEMPS(n$1,n$2); [line 25]\n " shape="invhouse"] +22 [label="22: Prune (false branch) \n PRUNE((n$2 == 0), false); [line 22]\n REMOVE_TEMPS(n$1,n$2); [line 22]\n " shape="invhouse"] 22 -> 24 ; -21 [label="21: Prune (true branch) \n PRUNE((n$2 != 0), true); [line 25]\n REMOVE_TEMPS(n$1,n$2); [line 25]\n " shape="invhouse"] +21 [label="21: Prune (true branch) \n PRUNE((n$2 != 0), true); [line 22]\n REMOVE_TEMPS(n$1,n$2); [line 22]\n " shape="invhouse"] 21 -> 23 ; -20 [label="20: Call _fun_identity \n n$1=*&SIL_temp_conditional___15:int [line 25]\n NULLIFY(&SIL_temp_conditional___15,true); [line 25]\n n$2=_fun_identity(n$1:int ) [line 25]\n " shape="box"] +20 [label="20: Call _fun_identity \n n$1=*&SIL_temp_conditional___15:int [line 22]\n NULLIFY(&SIL_temp_conditional___15,true); [line 22]\n n$2=_fun_identity(n$1:int ) [line 22]\n " shape="box"] 20 -> 21 ; 20 -> 22 ; -19 [label="19: ConditinalStmt Branch \n NULLIFY(&x,false); [line 25]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 25]\n *&SIL_temp_conditional___15:int =1 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +19 [label="19: ConditinalStmt Branch \n NULLIFY(&x,false); [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =1 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 19 -> 15 ; -18 [label="18: ConditinalStmt Branch \n NULLIFY(&x,false); [line 25]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 25]\n *&SIL_temp_conditional___15:int =0 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +18 [label="18: ConditinalStmt Branch \n NULLIFY(&x,false); [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___15); [line 22]\n *&SIL_temp_conditional___15:int =0 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 18 -> 15 ; -17 [label="17: Prune (false branch) \n n$0=*&x:int [line 25]\n PRUNE((n$0 == 0), false); [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n " shape="invhouse"] +17 [label="17: Prune (false branch) \n n$0=*&x:int [line 22]\n PRUNE((n$0 == 0), false); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] 17 -> 19 ; -16 [label="16: Prune (true branch) \n n$0=*&x:int [line 25]\n PRUNE((n$0 != 0), true); [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n " shape="invhouse"] +16 [label="16: Prune (true branch) \n n$0=*&x:int [line 22]\n PRUNE((n$0 != 0), true); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] 16 -> 18 ; @@ -72,51 +72,51 @@ digraph iCFG { 15 -> 20 ; -14 [label="14: + \n NULLIFY(&x,false); [line 25]\n " ] +14 [label="14: + \n NULLIFY(&x,false); [line 22]\n " ] 14 -> 13 ; 13 [label="13: Exit baz \n " color=yellow style=filled] -12 [label="12: Start baz\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] +12 [label="12: Start baz\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 12 -> 16 ; 12 -> 17 ; -11 [label="11: Return Stmt \n *&return:int =0 [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +11 [label="11: Return Stmt \n *&return:int =0 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 11 -> 5 ; -10 [label="10: Return Stmt \n *&return:int =1 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +10 [label="10: Return Stmt \n *&return:int =1 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 10 -> 5 ; -9 [label="9: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 16]\n REMOVE_TEMPS(n$0,n$1); [line 16]\n " shape="invhouse"] +9 [label="9: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n " shape="invhouse"] 9 -> 11 ; -8 [label="8: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 16]\n REMOVE_TEMPS(n$0,n$1); [line 16]\n " shape="invhouse"] +8 [label="8: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n " shape="invhouse"] 8 -> 10 ; -7 [label="7: Call _fun_identity \n n$0=*&x:int [line 16]\n n$1=_fun_identity(n$0:int ) [line 16]\n NULLIFY(&x,false); [line 16]\n " shape="box"] +7 [label="7: Call _fun_identity \n n$0=*&x:int [line 13]\n n$1=_fun_identity(n$0:int ) [line 13]\n NULLIFY(&x,false); [line 13]\n " shape="box"] 7 -> 8 ; 7 -> 9 ; -6 [label="6: + \n NULLIFY(&x,false); [line 16]\n " ] +6 [label="6: + \n NULLIFY(&x,false); [line 13]\n " ] 6 -> 5 ; 5 [label="5: Exit bar \n " color=yellow style=filled] -4 [label="4: Start bar\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +4 [label="4: Start bar\nFormals: x:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 4 -> 7 ; -3 [label="3: Return Stmt \n n$0=*&x:int [line 11]\n *&return:int =n$0 [line 11]\n REMOVE_TEMPS(n$0); [line 11]\n NULLIFY(&x,false); [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&x:int [line 10]\n *&return:int =n$0 [line 10]\n REMOVE_TEMPS(n$0); [line 10]\n NULLIFY(&x,false); [line 10]\n APPLY_ABSTRACTION; [line 10]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c index fea1a70f4..bc82db8fc 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c @@ -11,16 +11,12 @@ struct s { int field; }; -struct s *ret_ptr(int); +struct s* ret_ptr(int); -void ife_then_access_field(struct s *p, struct s *q) { +void ife_then_access_field(struct s* p, struct s* q) { int z = (1 ? p : q)->field; } -void call_ife_then_access_field() { - int z = (ret_ptr(1 ? 2 : 3))->field; -} +void call_ife_then_access_field() { int z = (ret_ptr(1 ? 2 : 3))->field; } -void access_field_in_ife_branch() { - int z = 1 ? (ret_ptr(4))->field : 0; -} +void access_field_in_ife_branch() { int z = 1 ? (ret_ptr(4))->field : 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c.dot b/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c.dot index e7871734b..eceb18957 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/member_access.c.dot @@ -1,21 +1,21 @@ digraph iCFG { -24 [label="24: DeclStmt \n n$2=*&SIL_temp_conditional___19:int [line 25]\n NULLIFY(&SIL_temp_conditional___19,true); [line 25]\n *&z:int =n$2 [line 25]\n REMOVE_TEMPS(n$2); [line 25]\n NULLIFY(&z,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +24 [label="24: DeclStmt \n n$2=*&SIL_temp_conditional___19:int [line 22]\n NULLIFY(&SIL_temp_conditional___19,true); [line 22]\n *&z:int =n$2 [line 22]\n REMOVE_TEMPS(n$2); [line 22]\n NULLIFY(&z,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 24 -> 18 ; -23 [label="23: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___19); [line 25]\n *&SIL_temp_conditional___19:int =0 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +23 [label="23: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___19); [line 22]\n *&SIL_temp_conditional___19:int =0 [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 23 -> 19 ; -22 [label="22: ConditinalStmt Branch \n n$0=_fun_ret_ptr(4:int ) [line 25]\n n$1=*n$0.field:int [line 25]\n DECLARE_LOCALS(&SIL_temp_conditional___19); [line 25]\n *&SIL_temp_conditional___19:int =n$1 [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +22 [label="22: ConditinalStmt Branch \n n$0=_fun_ret_ptr(4:int ) [line 22]\n n$1=*n$0.field:int [line 22]\n DECLARE_LOCALS(&SIL_temp_conditional___19); [line 22]\n *&SIL_temp_conditional___19:int =n$1 [line 22]\n REMOVE_TEMPS(n$0,n$1); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 22 -> 19 ; -21 [label="21: Prune (false branch) \n PRUNE((1 == 0), false); [line 25]\n " shape="invhouse"] +21 [label="21: Prune (false branch) \n PRUNE((1 == 0), false); [line 22]\n " shape="invhouse"] 21 -> 23 ; -20 [label="20: Prune (true branch) \n PRUNE((1 != 0), true); [line 25]\n " shape="invhouse"] +20 [label="20: Prune (true branch) \n PRUNE((1 != 0), true); [line 22]\n " shape="invhouse"] 20 -> 22 ; @@ -26,28 +26,28 @@ digraph iCFG { 18 [label="18: Exit access_field_in_ife_branch \n " color=yellow style=filled] -17 [label="17: Start access_field_in_ife_branch\nFormals: \nLocals: z:int \n DECLARE_LOCALS(&return,&z); [line 24]\n NULLIFY(&z,false); [line 24]\n " color=yellow style=filled] +17 [label="17: Start access_field_in_ife_branch\nFormals: \nLocals: z:int \n DECLARE_LOCALS(&return,&z); [line 22]\n NULLIFY(&z,false); [line 22]\n " color=yellow style=filled] 17 -> 20 ; 17 -> 21 ; -16 [label="16: DeclStmt \n n$0=*&SIL_temp_conditional___11:int [line 21]\n NULLIFY(&SIL_temp_conditional___11,true); [line 21]\n n$1=_fun_ret_ptr(n$0:int ) [line 21]\n n$2=*n$1.field:int [line 21]\n *&z:int =n$2 [line 21]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 21]\n NULLIFY(&z,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +16 [label="16: DeclStmt \n n$0=*&SIL_temp_conditional___11:int [line 20]\n NULLIFY(&SIL_temp_conditional___11,true); [line 20]\n n$1=_fun_ret_ptr(n$0:int ) [line 20]\n n$2=*n$1.field:int [line 20]\n *&z:int =n$2 [line 20]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 20]\n NULLIFY(&z,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 16 -> 10 ; -15 [label="15: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 21]\n *&SIL_temp_conditional___11:int =3 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +15 [label="15: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 20]\n *&SIL_temp_conditional___11:int =3 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 15 -> 11 ; -14 [label="14: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 21]\n *&SIL_temp_conditional___11:int =2 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +14 [label="14: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___11); [line 20]\n *&SIL_temp_conditional___11:int =2 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 14 -> 11 ; -13 [label="13: Prune (false branch) \n PRUNE((1 == 0), false); [line 21]\n " shape="invhouse"] +13 [label="13: Prune (false branch) \n PRUNE((1 == 0), false); [line 20]\n " shape="invhouse"] 13 -> 15 ; -12 [label="12: Prune (true branch) \n PRUNE((1 != 0), true); [line 21]\n " shape="invhouse"] +12 [label="12: Prune (true branch) \n PRUNE((1 != 0), true); [line 20]\n " shape="invhouse"] 12 -> 14 ; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/preincrement.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/preincrement.c index d79a6ce98..4536e5c1e 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/preincrement.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/preincrement.c @@ -11,7 +11,7 @@ struct s { int x; }; -void preincrement(struct s *p) { +void preincrement(struct s* p) { p->x += 1; (1 ? p : p)->x += 1; p->x += 1 ? 3 : 7; diff --git a/infer/tests/codetoanalyze/c/frontend/conditional_operator/unary_operator.c b/infer/tests/codetoanalyze/c/frontend/conditional_operator/unary_operator.c index ac164b4b0..c64c0346a 100644 --- a/infer/tests/codetoanalyze/c/frontend/conditional_operator/unary_operator.c +++ b/infer/tests/codetoanalyze/c/frontend/conditional_operator/unary_operator.c @@ -7,11 +7,11 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -void dereference_ifthenelse(int *p) { +void dereference_ifthenelse(int* p) { int x; - x = * (1 ? p : p); + x = *(1 ? p : p); - int y = * (1 ? p : p); + int y = *(1 ? p : p); - * (1 ? p : p); + *(1 ? p : p); } diff --git a/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c b/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c index 9d653d661..22029dba8 100644 --- a/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c +++ b/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c @@ -7,14 +7,22 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -enum week{ sunday, monday, tuesday, wednesday = 0, thursday, friday, saturday}; +enum week { + sunday, + monday, + tuesday, + wednesday = 0, + thursday, + friday, + saturday +}; -int main(){ +int main() { enum week today; today = wednesday; today = monday; today = today + 4; - today = (enum week) tuesday + 1; + today = (enum week)tuesday + 1; int i = tuesday + (friday - sunday); return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c.dot b/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c.dot index e8288e7af..9c091fd85 100644 --- a/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/enumeration/enum.c.dot @@ -1,32 +1,32 @@ digraph iCFG { -8 [label="8: BinaryOperatorStmt: Assign \n *&today:int =0 [line 14]\n NULLIFY(&today,false); [line 14]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n *&today:int =0 [line 22]\n NULLIFY(&today,false); [line 22]\n " shape="box"] 8 -> 7 ; -7 [label="7: BinaryOperatorStmt: Assign \n *&today:int =1 [line 15]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n *&today:int =1 [line 23]\n " shape="box"] 7 -> 6 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&today:int [line 16]\n *&today:int =(n$0 + 4) [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&today,false); [line 16]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&today:int [line 24]\n *&today:int =(n$0 + 4) [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n NULLIFY(&today,false); [line 24]\n " shape="box"] 6 -> 5 ; -5 [label="5: BinaryOperatorStmt: Assign \n *&today:int =(2 + 1) [line 17]\n NULLIFY(&today,false); [line 17]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: Assign \n *&today:int =(2 + 1) [line 25]\n NULLIFY(&today,false); [line 25]\n " shape="box"] 5 -> 4 ; -4 [label="4: DeclStmt \n *&i:int =(2 + (2 - 0)) [line 18]\n NULLIFY(&i,false); [line 18]\n " shape="box"] +4 [label="4: DeclStmt \n *&i:int =(2 + (2 - 0)) [line 26]\n NULLIFY(&i,false); [line 26]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit main \n " color=yellow style=filled] -1 [label="1: Start main\nFormals: \nLocals: i:int today:int \n DECLARE_LOCALS(&return,&i,&today); [line 12]\n NULLIFY(&i,false); [line 12]\n NULLIFY(&today,false); [line 12]\n " color=yellow style=filled] +1 [label="1: Start main\nFormals: \nLocals: i:int today:int \n DECLARE_LOCALS(&return,&i,&today); [line 20]\n NULLIFY(&i,false); [line 20]\n NULLIFY(&today,false); [line 20]\n " color=yellow style=filled] 1 -> 8 ; diff --git a/infer/tests/codetoanalyze/c/frontend/enumeration/enum_bitmask.c b/infer/tests/codetoanalyze/c/frontend/enumeration/enum_bitmask.c index fe8252a96..b938aafe1 100644 --- a/infer/tests/codetoanalyze/c/frontend/enumeration/enum_bitmask.c +++ b/infer/tests/codetoanalyze/c/frontend/enumeration/enum_bitmask.c @@ -8,11 +8,11 @@ */ typedef enum MyOption { - MyOption1 = 1 << 0, - MyOption2 = 1 << 1, + MyOption1 = 1 << 0, + MyOption2 = 1 << 1, }; int main() { - MyOption option1 = MyOption1; - MyOption option2 = MyOption2; + MyOption option1 = MyOption1; + MyOption option2 = MyOption2; } diff --git a/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c b/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c index bd7055070..f1bc9426a 100644 --- a/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c +++ b/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c @@ -10,19 +10,20 @@ enum Foo { A, B, C = 10, D, E = 1, F, G = F + C }; int main() { - enum Foo foo_a = A; - enum Foo foo_b = B; - enum Foo foo_c = C; - enum Foo foo_d = D; - enum Foo foo_e = E; - enum Foo foo_f = F; - enum Foo foo_g = G; + enum Foo foo_a = A; + enum Foo foo_b = B; + enum Foo foo_c = C; + enum Foo foo_d = D; + enum Foo foo_e = E; + enum Foo foo_f = F; + enum Foo foo_g = G; } int test() { - enum Foo foo_g = G; - enum Foo foo_a = A; - if (foo_g == 12) - return foo_g/ foo_a; - else return 0; + enum Foo foo_g = G; + enum Foo foo_a = A; + if (foo_g == 12) + return foo_g / foo_a; + else + return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c.dot b/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c.dot index 980b9f947..4134ea00c 100644 --- a/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/enumeration/other_enum.c.dot @@ -7,7 +7,7 @@ digraph iCFG { 18 -> 13 ; -17 [label="17: Return Stmt \n NULLIFY(&foo_a,false); [line 27]\n NULLIFY(&foo_g,false); [line 27]\n *&return:int =0 [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +17 [label="17: Return Stmt \n NULLIFY(&foo_a,false); [line 28]\n NULLIFY(&foo_g,false); [line 28]\n *&return:int =0 [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 17 -> 11 ; diff --git a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c index eb84e58de..12ac1661a 100644 --- a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c +++ b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c @@ -9,193 +9,182 @@ #import -int getValue() { - return 2; +int getValue() { return 2; } + +int g0() { + int a = 0; + if (getValue() > 1) + goto stepC; + +stepB: +stepC: +stepD: + a = 1; + return 1; } -int g0() -{ - int a = 0; - if (getValue() > 1) - goto stepC; - - stepB: - stepC: - stepD: - a = 1; - return 1; +int g1() { + int a = 0; + if (getValue() > 1) + goto stepB; + return 0; + +stepB: + a = 1; + return 1; } -int g1() -{ - int a = 0; - if (getValue() > 1) - goto stepB; - return 0; +int g2() { + int a = 0; +stepB: + a = 1; - stepB: - a = 1; - return 1; -} + if (!getValue()) + goto exit_step; + if (!getValue()) + goto stepA; + if (getValue() > 1) + goto stepB; + return 0; -int g2() -{ - int a = 0; - stepB: - a = 1; - - if (!getValue()) - goto exit_step; - if (!getValue()) - goto stepA; - if (getValue() > 1) - goto stepB; - return 0; - -stepA: { - a = 2; - return 2; +stepA : { + a = 2; + return 2; } exit_step: - a = 3; - return 1; + a = 3; + return 1; } -int g3() -{ - stepB: - printf("B\n"); - - if (!getValue()) - goto exit_step; - if (!getValue()) - goto stepA; - if (getValue() > 1) - goto stepB; - printf("g3\n"); - return 0; - -stepA: { - int a = 2; - printf("A\n"); +int g3() { +stepB: + printf("B\n"); + + if (!getValue()) + goto exit_step; + if (!getValue()) + goto stepA; + if (getValue() > 1) + goto stepB; + printf("g3\n"); + return 0; + +stepA : { + int a = 2; + printf("A\n"); } exit_step: - printf("exit\n"); - return 1; + printf("exit\n"); + return 1; } -int g4() -{ - stepB: - printf("B\n"); - - if (!getValue()) - goto exit_step; - if (!getValue()) - goto stepA; - if (getValue() > 1) - goto stepB; - printf("g4\n"); - -stepA: { - int a = 2; - printf("A\n"); +int g4() { +stepB: + printf("B\n"); + + if (!getValue()) + goto exit_step; + if (!getValue()) + goto stepA; + if (getValue() > 1) + goto stepB; + printf("g4\n"); + +stepA : { + int a = 2; + printf("A\n"); } exit_step: - printf("exit\n"); - return 1; + printf("exit\n"); + return 1; } -int g5() -{ - stepB: - printf("B\n"); - - if (!getValue()) - goto exit_step; - if (!getValue()) - goto stepA; - if (getValue() > 1) - goto stepB; - goto exit_step; +int g5() { +stepB: + printf("B\n"); -stepA: { - int a = 2; - printf("A\n"); - return 1; + if (!getValue()) + goto exit_step; + if (!getValue()) + goto stepA; + if (getValue() > 1) + goto stepB; + goto exit_step; + +stepA : { + int a = 2; + printf("A\n"); + return 1; } exit_step: - printf("exit\n"); - goto stepA; + printf("exit\n"); + goto stepA; } -int g6() -{ - stepB: - printf("B\n"); - - if (!getValue()) - goto exit_step; - if (!getValue()) - goto stepA; - if (getValue() > 1) - goto stepB; +int g6() { +stepB: + printf("B\n"); + + if (!getValue()) goto exit_step; + if (!getValue()) + goto stepA; + if (getValue() > 1) + goto stepB; + goto exit_step; -stepA: { - int a = 2; - printf("A\n"); +stepA : { + int a = 2; + printf("A\n"); } -return 1; + return 1; exit_step: - printf("exit\n"); - goto stepA; + printf("exit\n"); + goto stepA; } - -int g7() -{ - int i = 0, j = 0, k = 0; - while (i < 10) { - while (j < 10) { - while (k < 10) { - int v = i + j + k; - if (v >= 15) { - goto out; - print: - printf("wow\n"); - goto terminate; - } - } +int g7() { + int i = 0, j = 0, k = 0; + while (i < 10) { + while (j < 10) { + while (k < 10) { + int v = i + j + k; + if (v >= 15) { + goto out; + print: + printf("wow\n"); + goto terminate; } + } } - out: - printf("out!\n"); - goto print; - terminate: - printf("terminating!\n"); - return 2; + } +out: + printf("out!\n"); + goto print; +terminate: + printf("terminating!\n"); + return 2; } -int g8(int q) -{ - int i = 0, j = 0, k = 0; - if(q) goto print; - while (i < 10) { - while (j < 10) { - while (k < 10) { - int v = i + j + k; - if (v >= 15) { - print: - printf("wow\n"); - //goto terminate; - } - } +int g8(int q) { + int i = 0, j = 0, k = 0; + if (q) + goto print; + while (i < 10) { + while (j < 10) { + while (k < 10) { + int v = i + j + k; + if (v >= 15) { + print: + printf("wow\n"); + // goto terminate; } + } } - out: - printf("out!\n"); - terminate: - printf("terminating!\n"); - return 2; + } +out: + printf("out!\n"); +terminate: + printf("terminating!\n"); + return 2; } diff --git a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot index 932e52ebb..ab0b44647 100644 --- a/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/gotostmt/goto_ex.c.dot @@ -1,22 +1,22 @@ digraph iCFG { -252 [label="252: DeclStmt \n *&i:int =0 [line 182]\n " shape="box"] +252 [label="252: DeclStmt \n *&i:int =0 [line 170]\n " shape="box"] 252 -> 251 ; -251 [label="251: DeclStmt \n *&j:int =0 [line 182]\n " shape="box"] +251 [label="251: DeclStmt \n *&j:int =0 [line 170]\n " shape="box"] 251 -> 250 ; -250 [label="250: DeclStmt \n *&k:int =0 [line 182]\n " shape="box"] +250 [label="250: DeclStmt \n *&k:int =0 [line 170]\n " shape="box"] 250 -> 248 ; 250 -> 249 ; -249 [label="249: Prune (false branch) \n n$10=*&q:int [line 183]\n PRUNE((n$10 == 0), false); [line 183]\n REMOVE_TEMPS(n$10); [line 183]\n " shape="invhouse"] +249 [label="249: Prune (false branch) \n n$10=*&q:int [line 171]\n PRUNE((n$10 == 0), false); [line 171]\n REMOVE_TEMPS(n$10); [line 171]\n " shape="invhouse"] 249 -> 247 ; -248 [label="248: Prune (true branch) \n n$10=*&q:int [line 183]\n PRUNE((n$10 != 0), true); [line 183]\n REMOVE_TEMPS(n$10); [line 183]\n APPLY_ABSTRACTION; [line 183]\n " shape="invhouse"] +248 [label="248: Prune (true branch) \n n$10=*&q:int [line 171]\n PRUNE((n$10 != 0), true); [line 171]\n REMOVE_TEMPS(n$10); [line 171]\n APPLY_ABSTRACTION; [line 171]\n " shape="invhouse"] 248 -> 245 ; @@ -24,27 +24,27 @@ digraph iCFG { 247 -> 228 ; -246 [label="246: DeclStmt \n n$7=*&i:int [line 187]\n n$8=*&j:int [line 187]\n n$9=*&k:int [line 187]\n *&v:int =((n$7 + n$8) + n$9) [line 187]\n REMOVE_TEMPS(n$7,n$8,n$9); [line 187]\n " shape="box"] +246 [label="246: DeclStmt \n n$7=*&i:int [line 176]\n n$8=*&j:int [line 176]\n n$9=*&k:int [line 176]\n *&v:int =((n$7 + n$8) + n$9) [line 176]\n REMOVE_TEMPS(n$7,n$8,n$9); [line 176]\n " shape="box"] 246 -> 241 ; -245 [label="245: Skip GotoLabel_print \n NULLIFY(&q,false); [line 189]\n " color="gray"] +245 [label="245: Skip GotoLabel_print \n NULLIFY(&q,false); [line 178]\n " color="gray"] 245 -> 244 ; -244 [label="244: Call _fun_printf \n n$6=_fun_printf(\"wow\\n\":char *) [line 190]\n REMOVE_TEMPS(n$6); [line 190]\n APPLY_ABSTRACTION; [line 190]\n " shape="box"] +244 [label="244: Call _fun_printf \n n$6=_fun_printf(\"wow\\n\":char *) [line 179]\n REMOVE_TEMPS(n$6); [line 179]\n APPLY_ABSTRACTION; [line 179]\n " shape="box"] 244 -> 240 ; -243 [label="243: Prune (false branch) \n PRUNE(((n$5 >= 15) == 0), false); [line 188]\n REMOVE_TEMPS(n$5); [line 188]\n APPLY_ABSTRACTION; [line 188]\n " shape="invhouse"] +243 [label="243: Prune (false branch) \n PRUNE(((n$5 >= 15) == 0), false); [line 177]\n REMOVE_TEMPS(n$5); [line 177]\n APPLY_ABSTRACTION; [line 177]\n " shape="invhouse"] 243 -> 240 ; -242 [label="242: Prune (true branch) \n PRUNE(((n$5 >= 15) != 0), true); [line 188]\n REMOVE_TEMPS(n$5); [line 188]\n APPLY_ABSTRACTION; [line 188]\n " shape="invhouse"] +242 [label="242: Prune (true branch) \n PRUNE(((n$5 >= 15) != 0), true); [line 177]\n REMOVE_TEMPS(n$5); [line 177]\n APPLY_ABSTRACTION; [line 177]\n " shape="invhouse"] 242 -> 245 ; -241 [label="241: BinaryOperatorStmt: GE \n n$5=*&v:int [line 188]\n NULLIFY(&v,false); [line 188]\n " shape="box"] +241 [label="241: BinaryOperatorStmt: GE \n n$5=*&v:int [line 177]\n NULLIFY(&v,false); [line 177]\n " shape="box"] 241 -> 242 ; @@ -53,15 +53,15 @@ digraph iCFG { 240 -> 236 ; -239 [label="239: Prune (false branch) \n PRUNE(((n$4 < 10) == 0), false); [line 186]\n REMOVE_TEMPS(n$4); [line 186]\n APPLY_ABSTRACTION; [line 186]\n " shape="invhouse"] +239 [label="239: Prune (false branch) \n PRUNE(((n$4 < 10) == 0), false); [line 175]\n REMOVE_TEMPS(n$4); [line 175]\n APPLY_ABSTRACTION; [line 175]\n " shape="invhouse"] 239 -> 232 ; -238 [label="238: Prune (true branch) \n PRUNE(((n$4 < 10) != 0), true); [line 186]\n REMOVE_TEMPS(n$4); [line 186]\n " shape="invhouse"] +238 [label="238: Prune (true branch) \n PRUNE(((n$4 < 10) != 0), true); [line 175]\n REMOVE_TEMPS(n$4); [line 175]\n " shape="invhouse"] 238 -> 246 ; -237 [label="237: BinaryOperatorStmt: LT \n n$4=*&k:int [line 186]\n " shape="box"] +237 [label="237: BinaryOperatorStmt: LT \n n$4=*&k:int [line 175]\n " shape="box"] 237 -> 238 ; @@ -70,15 +70,15 @@ digraph iCFG { 236 -> 237 ; -235 [label="235: Prune (false branch) \n PRUNE(((n$3 < 10) == 0), false); [line 185]\n REMOVE_TEMPS(n$3); [line 185]\n APPLY_ABSTRACTION; [line 185]\n " shape="invhouse"] +235 [label="235: Prune (false branch) \n PRUNE(((n$3 < 10) == 0), false); [line 174]\n REMOVE_TEMPS(n$3); [line 174]\n APPLY_ABSTRACTION; [line 174]\n " shape="invhouse"] 235 -> 228 ; -234 [label="234: Prune (true branch) \n PRUNE(((n$3 < 10) != 0), true); [line 185]\n REMOVE_TEMPS(n$3); [line 185]\n APPLY_ABSTRACTION; [line 185]\n " shape="invhouse"] +234 [label="234: Prune (true branch) \n PRUNE(((n$3 < 10) != 0), true); [line 174]\n REMOVE_TEMPS(n$3); [line 174]\n APPLY_ABSTRACTION; [line 174]\n " shape="invhouse"] 234 -> 236 ; -233 [label="233: BinaryOperatorStmt: LT \n n$3=*&j:int [line 185]\n " shape="box"] +233 [label="233: BinaryOperatorStmt: LT \n n$3=*&j:int [line 174]\n " shape="box"] 233 -> 234 ; @@ -87,15 +87,15 @@ digraph iCFG { 232 -> 233 ; -231 [label="231: Prune (false branch) \n PRUNE(((n$2 < 10) == 0), false); [line 184]\n REMOVE_TEMPS(n$2); [line 184]\n " shape="invhouse"] +231 [label="231: Prune (false branch) \n PRUNE(((n$2 < 10) == 0), false); [line 173]\n REMOVE_TEMPS(n$2); [line 173]\n " shape="invhouse"] 231 -> 227 ; -230 [label="230: Prune (true branch) \n PRUNE(((n$2 < 10) != 0), true); [line 184]\n REMOVE_TEMPS(n$2); [line 184]\n APPLY_ABSTRACTION; [line 184]\n " shape="invhouse"] +230 [label="230: Prune (true branch) \n PRUNE(((n$2 < 10) != 0), true); [line 173]\n REMOVE_TEMPS(n$2); [line 173]\n APPLY_ABSTRACTION; [line 173]\n " shape="invhouse"] 230 -> 232 ; -229 [label="229: BinaryOperatorStmt: LT \n NULLIFY(&q,false); [line 184]\n n$2=*&i:int [line 184]\n " shape="box"] +229 [label="229: BinaryOperatorStmt: LT \n NULLIFY(&q,false); [line 173]\n n$2=*&i:int [line 173]\n " shape="box"] 229 -> 230 ; @@ -104,11 +104,11 @@ digraph iCFG { 228 -> 229 ; -227 [label="227: Skip GotoLabel_out \n NULLIFY(&i,false); [line 196]\n NULLIFY(&j,false); [line 196]\n NULLIFY(&k,false); [line 196]\n " color="gray"] +227 [label="227: Skip GotoLabel_out \n NULLIFY(&i,false); [line 185]\n NULLIFY(&j,false); [line 185]\n NULLIFY(&k,false); [line 185]\n " color="gray"] 227 -> 226 ; -226 [label="226: Call _fun_printf \n n$1=_fun_printf(\"out!\\n\":char *) [line 197]\n REMOVE_TEMPS(n$1); [line 197]\n " shape="box"] +226 [label="226: Call _fun_printf \n n$1=_fun_printf(\"out!\\n\":char *) [line 186]\n REMOVE_TEMPS(n$1); [line 186]\n " shape="box"] 226 -> 225 ; @@ -116,50 +116,50 @@ digraph iCFG { 225 -> 224 ; -224 [label="224: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char *) [line 199]\n REMOVE_TEMPS(n$0); [line 199]\n " shape="box"] +224 [label="224: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char *) [line 188]\n REMOVE_TEMPS(n$0); [line 188]\n " shape="box"] 224 -> 223 ; -223 [label="223: Return Stmt \n *&return:int =2 [line 200]\n APPLY_ABSTRACTION; [line 200]\n " shape="box"] +223 [label="223: Return Stmt \n *&return:int =2 [line 189]\n APPLY_ABSTRACTION; [line 189]\n " shape="box"] 223 -> 222 ; 222 [label="222: Exit g8 \n " color=yellow style=filled] -221 [label="221: Start g8\nFormals: q:int \nLocals: v:int k:int j:int i:int \n DECLARE_LOCALS(&return,&v,&k,&j,&i); [line 180]\n NULLIFY(&i,false); [line 180]\n NULLIFY(&j,false); [line 180]\n NULLIFY(&k,false); [line 180]\n NULLIFY(&v,false); [line 180]\n " color=yellow style=filled] +221 [label="221: Start g8\nFormals: q:int \nLocals: v:int k:int j:int i:int \n DECLARE_LOCALS(&return,&v,&k,&j,&i); [line 169]\n NULLIFY(&i,false); [line 169]\n NULLIFY(&j,false); [line 169]\n NULLIFY(&k,false); [line 169]\n NULLIFY(&v,false); [line 169]\n " color=yellow style=filled] 221 -> 252 ; -220 [label="220: DeclStmt \n *&i:int =0 [line 158]\n " shape="box"] +220 [label="220: DeclStmt \n *&i:int =0 [line 147]\n " shape="box"] 220 -> 219 ; -219 [label="219: DeclStmt \n *&j:int =0 [line 158]\n " shape="box"] +219 [label="219: DeclStmt \n *&j:int =0 [line 147]\n " shape="box"] 219 -> 218 ; -218 [label="218: DeclStmt \n *&k:int =0 [line 158]\n APPLY_ABSTRACTION; [line 158]\n " shape="box"] +218 [label="218: DeclStmt \n *&k:int =0 [line 147]\n APPLY_ABSTRACTION; [line 147]\n " shape="box"] 218 -> 200 ; -217 [label="217: DeclStmt \n n$7=*&i:int [line 162]\n n$8=*&j:int [line 162]\n n$9=*&k:int [line 162]\n *&v:int =((n$7 + n$8) + n$9) [line 162]\n REMOVE_TEMPS(n$7,n$8,n$9); [line 162]\n " shape="box"] +217 [label="217: DeclStmt \n n$7=*&i:int [line 151]\n n$8=*&j:int [line 151]\n n$9=*&k:int [line 151]\n *&v:int =((n$7 + n$8) + n$9) [line 151]\n REMOVE_TEMPS(n$7,n$8,n$9); [line 151]\n " shape="box"] 217 -> 213 ; -216 [label="216: Call _fun_printf \n n$6=_fun_printf(\"wow\\n\":char *) [line 166]\n REMOVE_TEMPS(n$6); [line 166]\n " shape="box"] +216 [label="216: Call _fun_printf \n n$6=_fun_printf(\"wow\\n\":char *) [line 155]\n REMOVE_TEMPS(n$6); [line 155]\n " shape="box"] 216 -> 196 ; -215 [label="215: Prune (false branch) \n PRUNE(((n$5 >= 15) == 0), false); [line 163]\n REMOVE_TEMPS(n$5); [line 163]\n " shape="invhouse"] +215 [label="215: Prune (false branch) \n PRUNE(((n$5 >= 15) == 0), false); [line 152]\n REMOVE_TEMPS(n$5); [line 152]\n " shape="invhouse"] 215 -> 212 ; -214 [label="214: Prune (true branch) \n PRUNE(((n$5 >= 15) != 0), true); [line 163]\n REMOVE_TEMPS(n$5); [line 163]\n APPLY_ABSTRACTION; [line 163]\n " shape="invhouse"] +214 [label="214: Prune (true branch) \n PRUNE(((n$5 >= 15) != 0), true); [line 152]\n REMOVE_TEMPS(n$5); [line 152]\n APPLY_ABSTRACTION; [line 152]\n " shape="invhouse"] 214 -> 199 ; -213 [label="213: BinaryOperatorStmt: GE \n n$5=*&v:int [line 163]\n NULLIFY(&v,false); [line 163]\n " shape="box"] +213 [label="213: BinaryOperatorStmt: GE \n n$5=*&v:int [line 152]\n NULLIFY(&v,false); [line 152]\n " shape="box"] 213 -> 214 ; @@ -168,15 +168,15 @@ digraph iCFG { 212 -> 208 ; -211 [label="211: Prune (false branch) \n PRUNE(((n$4 < 10) == 0), false); [line 161]\n REMOVE_TEMPS(n$4); [line 161]\n APPLY_ABSTRACTION; [line 161]\n " shape="invhouse"] +211 [label="211: Prune (false branch) \n PRUNE(((n$4 < 10) == 0), false); [line 150]\n REMOVE_TEMPS(n$4); [line 150]\n APPLY_ABSTRACTION; [line 150]\n " shape="invhouse"] 211 -> 204 ; -210 [label="210: Prune (true branch) \n PRUNE(((n$4 < 10) != 0), true); [line 161]\n REMOVE_TEMPS(n$4); [line 161]\n " shape="invhouse"] +210 [label="210: Prune (true branch) \n PRUNE(((n$4 < 10) != 0), true); [line 150]\n REMOVE_TEMPS(n$4); [line 150]\n " shape="invhouse"] 210 -> 217 ; -209 [label="209: BinaryOperatorStmt: LT \n n$4=*&k:int [line 161]\n " shape="box"] +209 [label="209: BinaryOperatorStmt: LT \n n$4=*&k:int [line 150]\n " shape="box"] 209 -> 210 ; @@ -185,15 +185,15 @@ digraph iCFG { 208 -> 209 ; -207 [label="207: Prune (false branch) \n PRUNE(((n$3 < 10) == 0), false); [line 160]\n REMOVE_TEMPS(n$3); [line 160]\n APPLY_ABSTRACTION; [line 160]\n " shape="invhouse"] +207 [label="207: Prune (false branch) \n PRUNE(((n$3 < 10) == 0), false); [line 149]\n REMOVE_TEMPS(n$3); [line 149]\n APPLY_ABSTRACTION; [line 149]\n " shape="invhouse"] 207 -> 200 ; -206 [label="206: Prune (true branch) \n PRUNE(((n$3 < 10) != 0), true); [line 160]\n REMOVE_TEMPS(n$3); [line 160]\n APPLY_ABSTRACTION; [line 160]\n " shape="invhouse"] +206 [label="206: Prune (true branch) \n PRUNE(((n$3 < 10) != 0), true); [line 149]\n REMOVE_TEMPS(n$3); [line 149]\n APPLY_ABSTRACTION; [line 149]\n " shape="invhouse"] 206 -> 208 ; -205 [label="205: BinaryOperatorStmt: LT \n n$3=*&j:int [line 160]\n " shape="box"] +205 [label="205: BinaryOperatorStmt: LT \n n$3=*&j:int [line 149]\n " shape="box"] 205 -> 206 ; @@ -202,15 +202,15 @@ digraph iCFG { 204 -> 205 ; -203 [label="203: Prune (false branch) \n PRUNE(((n$2 < 10) == 0), false); [line 159]\n REMOVE_TEMPS(n$2); [line 159]\n APPLY_ABSTRACTION; [line 159]\n " shape="invhouse"] +203 [label="203: Prune (false branch) \n PRUNE(((n$2 < 10) == 0), false); [line 148]\n REMOVE_TEMPS(n$2); [line 148]\n APPLY_ABSTRACTION; [line 148]\n " shape="invhouse"] 203 -> 199 ; -202 [label="202: Prune (true branch) \n PRUNE(((n$2 < 10) != 0), true); [line 159]\n REMOVE_TEMPS(n$2); [line 159]\n APPLY_ABSTRACTION; [line 159]\n " shape="invhouse"] +202 [label="202: Prune (true branch) \n PRUNE(((n$2 < 10) != 0), true); [line 148]\n REMOVE_TEMPS(n$2); [line 148]\n APPLY_ABSTRACTION; [line 148]\n " shape="invhouse"] 202 -> 204 ; -201 [label="201: BinaryOperatorStmt: LT \n n$2=*&i:int [line 159]\n " shape="box"] +201 [label="201: BinaryOperatorStmt: LT \n n$2=*&i:int [line 148]\n " shape="box"] 201 -> 202 ; @@ -219,11 +219,11 @@ digraph iCFG { 200 -> 201 ; -199 [label="199: Skip GotoLabel_out \n NULLIFY(&i,false); [line 172]\n NULLIFY(&j,false); [line 172]\n NULLIFY(&k,false); [line 172]\n " color="gray"] +199 [label="199: Skip GotoLabel_out \n NULLIFY(&i,false); [line 161]\n NULLIFY(&j,false); [line 161]\n NULLIFY(&k,false); [line 161]\n " color="gray"] 199 -> 198 ; -198 [label="198: Call _fun_printf \n n$1=_fun_printf(\"out!\\n\":char *) [line 173]\n REMOVE_TEMPS(n$1); [line 173]\n " shape="box"] +198 [label="198: Call _fun_printf \n n$1=_fun_printf(\"out!\\n\":char *) [line 162]\n REMOVE_TEMPS(n$1); [line 162]\n " shape="box"] 198 -> 197 ; @@ -235,50 +235,50 @@ digraph iCFG { 196 -> 195 ; -195 [label="195: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char *) [line 176]\n REMOVE_TEMPS(n$0); [line 176]\n " shape="box"] +195 [label="195: Call _fun_printf \n n$0=_fun_printf(\"terminating!\\n\":char *) [line 165]\n REMOVE_TEMPS(n$0); [line 165]\n " shape="box"] 195 -> 194 ; -194 [label="194: Return Stmt \n *&return:int =2 [line 177]\n APPLY_ABSTRACTION; [line 177]\n " shape="box"] +194 [label="194: Return Stmt \n *&return:int =2 [line 166]\n APPLY_ABSTRACTION; [line 166]\n " shape="box"] 194 -> 193 ; 193 [label="193: Exit g7 \n " color=yellow style=filled] -192 [label="192: Start g7\nFormals: \nLocals: v:int k:int j:int i:int \n DECLARE_LOCALS(&return,&v,&k,&j,&i); [line 156]\n NULLIFY(&i,false); [line 156]\n NULLIFY(&j,false); [line 156]\n NULLIFY(&k,false); [line 156]\n NULLIFY(&v,false); [line 156]\n " color=yellow style=filled] +192 [label="192: Start g7\nFormals: \nLocals: v:int k:int j:int i:int \n DECLARE_LOCALS(&return,&v,&k,&j,&i); [line 146]\n NULLIFY(&i,false); [line 146]\n NULLIFY(&j,false); [line 146]\n NULLIFY(&k,false); [line 146]\n NULLIFY(&v,false); [line 146]\n " color=yellow style=filled] 192 -> 220 ; -191 [label="191: Call _fun_printf \n n$7=_fun_printf(\"B\\n\":char *) [line 135]\n REMOVE_TEMPS(n$7); [line 135]\n " shape="box"] +191 [label="191: Call _fun_printf \n n$7=_fun_printf(\"B\\n\":char *) [line 126]\n REMOVE_TEMPS(n$7); [line 126]\n " shape="box"] 191 -> 184 ; -190 [label="190: Prune (false branch) \n n$6=*&SIL_temp_conditional___183:int [line 137]\n NULLIFY(&SIL_temp_conditional___183,true); [line 137]\n PRUNE((n$6 == 0), false); [line 137]\n REMOVE_TEMPS(n$6); [line 137]\n " shape="invhouse"] +190 [label="190: Prune (false branch) \n n$6=*&SIL_temp_conditional___183:int [line 128]\n NULLIFY(&SIL_temp_conditional___183,true); [line 128]\n PRUNE((n$6 == 0), false); [line 128]\n REMOVE_TEMPS(n$6); [line 128]\n " shape="invhouse"] 190 -> 182 ; -189 [label="189: Prune (true branch) \n n$6=*&SIL_temp_conditional___183:int [line 137]\n NULLIFY(&SIL_temp_conditional___183,true); [line 137]\n PRUNE((n$6 != 0), true); [line 137]\n REMOVE_TEMPS(n$6); [line 137]\n APPLY_ABSTRACTION; [line 137]\n " shape="invhouse"] +189 [label="189: Prune (true branch) \n n$6=*&SIL_temp_conditional___183:int [line 128]\n NULLIFY(&SIL_temp_conditional___183,true); [line 128]\n PRUNE((n$6 != 0), true); [line 128]\n REMOVE_TEMPS(n$6); [line 128]\n APPLY_ABSTRACTION; [line 128]\n " shape="invhouse"] 189 -> 164 ; -188 [label="188: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___183); [line 137]\n *&SIL_temp_conditional___183:int =1 [line 137]\n APPLY_ABSTRACTION; [line 137]\n " shape="box"] +188 [label="188: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___183); [line 128]\n *&SIL_temp_conditional___183:int =1 [line 128]\n APPLY_ABSTRACTION; [line 128]\n " shape="box"] 188 -> 183 ; -187 [label="187: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___183); [line 137]\n *&SIL_temp_conditional___183:int =0 [line 137]\n APPLY_ABSTRACTION; [line 137]\n " shape="box"] +187 [label="187: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___183); [line 128]\n *&SIL_temp_conditional___183:int =0 [line 128]\n APPLY_ABSTRACTION; [line 128]\n " shape="box"] 187 -> 183 ; -186 [label="186: Prune (false branch) \n PRUNE((n$5 == 0), false); [line 137]\n REMOVE_TEMPS(n$5); [line 137]\n " shape="invhouse"] +186 [label="186: Prune (false branch) \n PRUNE((n$5 == 0), false); [line 128]\n REMOVE_TEMPS(n$5); [line 128]\n " shape="invhouse"] 186 -> 188 ; -185 [label="185: Prune (true branch) \n PRUNE((n$5 != 0), true); [line 137]\n REMOVE_TEMPS(n$5); [line 137]\n " shape="invhouse"] +185 [label="185: Prune (true branch) \n PRUNE((n$5 != 0), true); [line 128]\n REMOVE_TEMPS(n$5); [line 128]\n " shape="invhouse"] 185 -> 187 ; -184 [label="184: Call _fun_getValue \n n$5=_fun_getValue() [line 137]\n " shape="box"] +184 [label="184: Call _fun_getValue \n n$5=_fun_getValue() [line 128]\n " shape="box"] 184 -> 185 ; @@ -292,31 +292,31 @@ digraph iCFG { 182 -> 175 ; -181 [label="181: Prune (false branch) \n n$4=*&SIL_temp_conditional___174:int [line 139]\n NULLIFY(&SIL_temp_conditional___174,true); [line 139]\n PRUNE((n$4 == 0), false); [line 139]\n REMOVE_TEMPS(n$4); [line 139]\n " shape="invhouse"] +181 [label="181: Prune (false branch) \n n$4=*&SIL_temp_conditional___174:int [line 130]\n NULLIFY(&SIL_temp_conditional___174,true); [line 130]\n PRUNE((n$4 == 0), false); [line 130]\n REMOVE_TEMPS(n$4); [line 130]\n " shape="invhouse"] 181 -> 173 ; -180 [label="180: Prune (true branch) \n n$4=*&SIL_temp_conditional___174:int [line 139]\n NULLIFY(&SIL_temp_conditional___174,true); [line 139]\n PRUNE((n$4 != 0), true); [line 139]\n REMOVE_TEMPS(n$4); [line 139]\n APPLY_ABSTRACTION; [line 139]\n " shape="invhouse"] +180 [label="180: Prune (true branch) \n n$4=*&SIL_temp_conditional___174:int [line 130]\n NULLIFY(&SIL_temp_conditional___174,true); [line 130]\n PRUNE((n$4 != 0), true); [line 130]\n REMOVE_TEMPS(n$4); [line 130]\n APPLY_ABSTRACTION; [line 130]\n " shape="invhouse"] 180 -> 162 ; -179 [label="179: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___174); [line 139]\n *&SIL_temp_conditional___174:int =1 [line 139]\n APPLY_ABSTRACTION; [line 139]\n " shape="box"] +179 [label="179: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___174); [line 130]\n *&SIL_temp_conditional___174:int =1 [line 130]\n APPLY_ABSTRACTION; [line 130]\n " shape="box"] 179 -> 174 ; -178 [label="178: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___174); [line 139]\n *&SIL_temp_conditional___174:int =0 [line 139]\n APPLY_ABSTRACTION; [line 139]\n " shape="box"] +178 [label="178: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___174); [line 130]\n *&SIL_temp_conditional___174:int =0 [line 130]\n APPLY_ABSTRACTION; [line 130]\n " shape="box"] 178 -> 174 ; -177 [label="177: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 139]\n REMOVE_TEMPS(n$3); [line 139]\n " shape="invhouse"] +177 [label="177: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 130]\n REMOVE_TEMPS(n$3); [line 130]\n " shape="invhouse"] 177 -> 179 ; -176 [label="176: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 139]\n REMOVE_TEMPS(n$3); [line 139]\n " shape="invhouse"] +176 [label="176: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 130]\n REMOVE_TEMPS(n$3); [line 130]\n " shape="invhouse"] 176 -> 178 ; -175 [label="175: Call _fun_getValue \n n$3=_fun_getValue() [line 139]\n " shape="box"] +175 [label="175: Call _fun_getValue \n n$3=_fun_getValue() [line 130]\n " shape="box"] 175 -> 176 ; @@ -334,15 +334,15 @@ digraph iCFG { 172 -> 191 ; -171 [label="171: Prune (false branch) \n PRUNE(((n$2 > 1) == 0), false); [line 141]\n REMOVE_TEMPS(n$2); [line 141]\n " shape="invhouse"] +171 [label="171: Prune (false branch) \n PRUNE(((n$2 > 1) == 0), false); [line 132]\n REMOVE_TEMPS(n$2); [line 132]\n " shape="invhouse"] 171 -> 168 ; -170 [label="170: Prune (true branch) \n PRUNE(((n$2 > 1) != 0), true); [line 141]\n REMOVE_TEMPS(n$2); [line 141]\n APPLY_ABSTRACTION; [line 141]\n " shape="invhouse"] +170 [label="170: Prune (true branch) \n PRUNE(((n$2 > 1) != 0), true); [line 132]\n REMOVE_TEMPS(n$2); [line 132]\n APPLY_ABSTRACTION; [line 132]\n " shape="invhouse"] 170 -> 172 ; -169 [label="169: BinaryOperatorStmt: GT \n n$2=_fun_getValue() [line 141]\n " shape="box"] +169 [label="169: BinaryOperatorStmt: GT \n n$2=_fun_getValue() [line 132]\n " shape="box"] 169 -> 170 ; @@ -351,15 +351,15 @@ digraph iCFG { 168 -> 164 ; -167 [label="167: DeclStmt \n *&a:int =2 [line 146]\n NULLIFY(&a,false); [line 146]\n " shape="box"] +167 [label="167: DeclStmt \n *&a:int =2 [line 137]\n NULLIFY(&a,false); [line 137]\n " shape="box"] 167 -> 166 ; -166 [label="166: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 147]\n REMOVE_TEMPS(n$1); [line 147]\n " shape="box"] +166 [label="166: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 138]\n REMOVE_TEMPS(n$1); [line 138]\n " shape="box"] 166 -> 165 ; -165 [label="165: Return Stmt \n *&return:int =1 [line 149]\n APPLY_ABSTRACTION; [line 149]\n " shape="box"] +165 [label="165: Return Stmt \n *&return:int =1 [line 140]\n APPLY_ABSTRACTION; [line 140]\n " shape="box"] 165 -> 161 ; @@ -367,7 +367,7 @@ digraph iCFG { 164 -> 163 ; -163 [label="163: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 151]\n REMOVE_TEMPS(n$0); [line 151]\n APPLY_ABSTRACTION; [line 151]\n " shape="box"] +163 [label="163: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 142]\n REMOVE_TEMPS(n$0); [line 142]\n APPLY_ABSTRACTION; [line 142]\n " shape="box"] 163 -> 162 ; @@ -378,39 +378,39 @@ digraph iCFG { 161 [label="161: Exit g6 \n " color=yellow style=filled] -160 [label="160: Start g6\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 132]\n NULLIFY(&a,false); [line 132]\n " color=yellow style=filled] +160 [label="160: Start g6\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 124]\n NULLIFY(&a,false); [line 124]\n " color=yellow style=filled] 160 -> 172 ; -159 [label="159: Call _fun_printf \n n$7=_fun_printf(\"B\\n\":char *) [line 112]\n REMOVE_TEMPS(n$7); [line 112]\n " shape="box"] +159 [label="159: Call _fun_printf \n n$7=_fun_printf(\"B\\n\":char *) [line 104]\n REMOVE_TEMPS(n$7); [line 104]\n " shape="box"] 159 -> 152 ; -158 [label="158: Prune (false branch) \n n$6=*&SIL_temp_conditional___151:int [line 114]\n NULLIFY(&SIL_temp_conditional___151,true); [line 114]\n PRUNE((n$6 == 0), false); [line 114]\n REMOVE_TEMPS(n$6); [line 114]\n " shape="invhouse"] +158 [label="158: Prune (false branch) \n n$6=*&SIL_temp_conditional___151:int [line 106]\n NULLIFY(&SIL_temp_conditional___151,true); [line 106]\n PRUNE((n$6 == 0), false); [line 106]\n REMOVE_TEMPS(n$6); [line 106]\n " shape="invhouse"] 158 -> 150 ; -157 [label="157: Prune (true branch) \n n$6=*&SIL_temp_conditional___151:int [line 114]\n NULLIFY(&SIL_temp_conditional___151,true); [line 114]\n PRUNE((n$6 != 0), true); [line 114]\n REMOVE_TEMPS(n$6); [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="invhouse"] +157 [label="157: Prune (true branch) \n n$6=*&SIL_temp_conditional___151:int [line 106]\n NULLIFY(&SIL_temp_conditional___151,true); [line 106]\n PRUNE((n$6 != 0), true); [line 106]\n REMOVE_TEMPS(n$6); [line 106]\n APPLY_ABSTRACTION; [line 106]\n " shape="invhouse"] 157 -> 132 ; -156 [label="156: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 114]\n *&SIL_temp_conditional___151:int =1 [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="box"] +156 [label="156: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 106]\n *&SIL_temp_conditional___151:int =1 [line 106]\n APPLY_ABSTRACTION; [line 106]\n " shape="box"] 156 -> 151 ; -155 [label="155: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 114]\n *&SIL_temp_conditional___151:int =0 [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="box"] +155 [label="155: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 106]\n *&SIL_temp_conditional___151:int =0 [line 106]\n APPLY_ABSTRACTION; [line 106]\n " shape="box"] 155 -> 151 ; -154 [label="154: Prune (false branch) \n PRUNE((n$5 == 0), false); [line 114]\n REMOVE_TEMPS(n$5); [line 114]\n " shape="invhouse"] +154 [label="154: Prune (false branch) \n PRUNE((n$5 == 0), false); [line 106]\n REMOVE_TEMPS(n$5); [line 106]\n " shape="invhouse"] 154 -> 156 ; -153 [label="153: Prune (true branch) \n PRUNE((n$5 != 0), true); [line 114]\n REMOVE_TEMPS(n$5); [line 114]\n " shape="invhouse"] +153 [label="153: Prune (true branch) \n PRUNE((n$5 != 0), true); [line 106]\n REMOVE_TEMPS(n$5); [line 106]\n " shape="invhouse"] 153 -> 155 ; -152 [label="152: Call _fun_getValue \n n$5=_fun_getValue() [line 114]\n " shape="box"] +152 [label="152: Call _fun_getValue \n n$5=_fun_getValue() [line 106]\n " shape="box"] 152 -> 153 ; @@ -424,31 +424,31 @@ digraph iCFG { 150 -> 143 ; -149 [label="149: Prune (false branch) \n n$4=*&SIL_temp_conditional___142:int [line 116]\n NULLIFY(&SIL_temp_conditional___142,true); [line 116]\n PRUNE((n$4 == 0), false); [line 116]\n REMOVE_TEMPS(n$4); [line 116]\n " shape="invhouse"] +149 [label="149: Prune (false branch) \n n$4=*&SIL_temp_conditional___142:int [line 108]\n NULLIFY(&SIL_temp_conditional___142,true); [line 108]\n PRUNE((n$4 == 0), false); [line 108]\n REMOVE_TEMPS(n$4); [line 108]\n " shape="invhouse"] 149 -> 141 ; -148 [label="148: Prune (true branch) \n n$4=*&SIL_temp_conditional___142:int [line 116]\n NULLIFY(&SIL_temp_conditional___142,true); [line 116]\n PRUNE((n$4 != 0), true); [line 116]\n REMOVE_TEMPS(n$4); [line 116]\n APPLY_ABSTRACTION; [line 116]\n " shape="invhouse"] +148 [label="148: Prune (true branch) \n n$4=*&SIL_temp_conditional___142:int [line 108]\n NULLIFY(&SIL_temp_conditional___142,true); [line 108]\n PRUNE((n$4 != 0), true); [line 108]\n REMOVE_TEMPS(n$4); [line 108]\n APPLY_ABSTRACTION; [line 108]\n " shape="invhouse"] 148 -> 130 ; -147 [label="147: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___142); [line 116]\n *&SIL_temp_conditional___142:int =1 [line 116]\n APPLY_ABSTRACTION; [line 116]\n " shape="box"] +147 [label="147: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___142); [line 108]\n *&SIL_temp_conditional___142:int =1 [line 108]\n APPLY_ABSTRACTION; [line 108]\n " shape="box"] 147 -> 142 ; -146 [label="146: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___142); [line 116]\n *&SIL_temp_conditional___142:int =0 [line 116]\n APPLY_ABSTRACTION; [line 116]\n " shape="box"] +146 [label="146: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___142); [line 108]\n *&SIL_temp_conditional___142:int =0 [line 108]\n APPLY_ABSTRACTION; [line 108]\n " shape="box"] 146 -> 142 ; -145 [label="145: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 116]\n REMOVE_TEMPS(n$3); [line 116]\n " shape="invhouse"] +145 [label="145: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 108]\n REMOVE_TEMPS(n$3); [line 108]\n " shape="invhouse"] 145 -> 147 ; -144 [label="144: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 116]\n REMOVE_TEMPS(n$3); [line 116]\n " shape="invhouse"] +144 [label="144: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 108]\n REMOVE_TEMPS(n$3); [line 108]\n " shape="invhouse"] 144 -> 146 ; -143 [label="143: Call _fun_getValue \n n$3=_fun_getValue() [line 116]\n " shape="box"] +143 [label="143: Call _fun_getValue \n n$3=_fun_getValue() [line 108]\n " shape="box"] 143 -> 144 ; @@ -466,15 +466,15 @@ digraph iCFG { 140 -> 159 ; -139 [label="139: Prune (false branch) \n PRUNE(((n$2 > 1) == 0), false); [line 118]\n REMOVE_TEMPS(n$2); [line 118]\n " shape="invhouse"] +139 [label="139: Prune (false branch) \n PRUNE(((n$2 > 1) == 0), false); [line 110]\n REMOVE_TEMPS(n$2); [line 110]\n " shape="invhouse"] 139 -> 136 ; -138 [label="138: Prune (true branch) \n PRUNE(((n$2 > 1) != 0), true); [line 118]\n REMOVE_TEMPS(n$2); [line 118]\n APPLY_ABSTRACTION; [line 118]\n " shape="invhouse"] +138 [label="138: Prune (true branch) \n PRUNE(((n$2 > 1) != 0), true); [line 110]\n REMOVE_TEMPS(n$2); [line 110]\n APPLY_ABSTRACTION; [line 110]\n " shape="invhouse"] 138 -> 140 ; -137 [label="137: BinaryOperatorStmt: GT \n n$2=_fun_getValue() [line 118]\n " shape="box"] +137 [label="137: BinaryOperatorStmt: GT \n n$2=_fun_getValue() [line 110]\n " shape="box"] 137 -> 138 ; @@ -483,15 +483,15 @@ digraph iCFG { 136 -> 132 ; -135 [label="135: DeclStmt \n *&a:int =2 [line 123]\n NULLIFY(&a,false); [line 123]\n " shape="box"] +135 [label="135: DeclStmt \n *&a:int =2 [line 115]\n NULLIFY(&a,false); [line 115]\n " shape="box"] 135 -> 134 ; -134 [label="134: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 124]\n REMOVE_TEMPS(n$1); [line 124]\n " shape="box"] +134 [label="134: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 116]\n REMOVE_TEMPS(n$1); [line 116]\n " shape="box"] 134 -> 133 ; -133 [label="133: Return Stmt \n *&return:int =1 [line 125]\n APPLY_ABSTRACTION; [line 125]\n " shape="box"] +133 [label="133: Return Stmt \n *&return:int =1 [line 117]\n APPLY_ABSTRACTION; [line 117]\n " shape="box"] 133 -> 129 ; @@ -499,7 +499,7 @@ digraph iCFG { 132 -> 131 ; -131 [label="131: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 128]\n REMOVE_TEMPS(n$0); [line 128]\n APPLY_ABSTRACTION; [line 128]\n " shape="box"] +131 [label="131: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 120]\n REMOVE_TEMPS(n$0); [line 120]\n APPLY_ABSTRACTION; [line 120]\n " shape="box"] 131 -> 130 ; @@ -510,39 +510,39 @@ digraph iCFG { 129 [label="129: Exit g5 \n " color=yellow style=filled] -128 [label="128: Start g5\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 109]\n NULLIFY(&a,false); [line 109]\n " color=yellow style=filled] +128 [label="128: Start g5\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 102]\n NULLIFY(&a,false); [line 102]\n " color=yellow style=filled] 128 -> 140 ; -127 [label="127: Call _fun_printf \n n$8=_fun_printf(\"B\\n\":char *) [line 90]\n REMOVE_TEMPS(n$8); [line 90]\n " shape="box"] +127 [label="127: Call _fun_printf \n n$8=_fun_printf(\"B\\n\":char *) [line 83]\n REMOVE_TEMPS(n$8); [line 83]\n " shape="box"] 127 -> 120 ; -126 [label="126: Prune (false branch) \n n$7=*&SIL_temp_conditional___119:int [line 92]\n NULLIFY(&SIL_temp_conditional___119,true); [line 92]\n PRUNE((n$7 == 0), false); [line 92]\n REMOVE_TEMPS(n$7); [line 92]\n " shape="invhouse"] +126 [label="126: Prune (false branch) \n n$7=*&SIL_temp_conditional___119:int [line 85]\n NULLIFY(&SIL_temp_conditional___119,true); [line 85]\n PRUNE((n$7 == 0), false); [line 85]\n REMOVE_TEMPS(n$7); [line 85]\n " shape="invhouse"] 126 -> 118 ; -125 [label="125: Prune (true branch) \n n$7=*&SIL_temp_conditional___119:int [line 92]\n NULLIFY(&SIL_temp_conditional___119,true); [line 92]\n PRUNE((n$7 != 0), true); [line 92]\n REMOVE_TEMPS(n$7); [line 92]\n APPLY_ABSTRACTION; [line 92]\n " shape="invhouse"] +125 [label="125: Prune (true branch) \n n$7=*&SIL_temp_conditional___119:int [line 85]\n NULLIFY(&SIL_temp_conditional___119,true); [line 85]\n PRUNE((n$7 != 0), true); [line 85]\n REMOVE_TEMPS(n$7); [line 85]\n APPLY_ABSTRACTION; [line 85]\n " shape="invhouse"] 125 -> 99 ; -124 [label="124: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___119); [line 92]\n *&SIL_temp_conditional___119:int =1 [line 92]\n APPLY_ABSTRACTION; [line 92]\n " shape="box"] +124 [label="124: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___119); [line 85]\n *&SIL_temp_conditional___119:int =1 [line 85]\n APPLY_ABSTRACTION; [line 85]\n " shape="box"] 124 -> 119 ; -123 [label="123: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___119); [line 92]\n *&SIL_temp_conditional___119:int =0 [line 92]\n APPLY_ABSTRACTION; [line 92]\n " shape="box"] +123 [label="123: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___119); [line 85]\n *&SIL_temp_conditional___119:int =0 [line 85]\n APPLY_ABSTRACTION; [line 85]\n " shape="box"] 123 -> 119 ; -122 [label="122: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 92]\n REMOVE_TEMPS(n$6); [line 92]\n " shape="invhouse"] +122 [label="122: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 85]\n REMOVE_TEMPS(n$6); [line 85]\n " shape="invhouse"] 122 -> 124 ; -121 [label="121: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 92]\n REMOVE_TEMPS(n$6); [line 92]\n " shape="invhouse"] +121 [label="121: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 85]\n REMOVE_TEMPS(n$6); [line 85]\n " shape="invhouse"] 121 -> 123 ; -120 [label="120: Call _fun_getValue \n n$6=_fun_getValue() [line 92]\n " shape="box"] +120 [label="120: Call _fun_getValue \n n$6=_fun_getValue() [line 85]\n " shape="box"] 120 -> 121 ; @@ -556,31 +556,31 @@ digraph iCFG { 118 -> 111 ; -117 [label="117: Prune (false branch) \n n$5=*&SIL_temp_conditional___110:int [line 94]\n NULLIFY(&SIL_temp_conditional___110,true); [line 94]\n PRUNE((n$5 == 0), false); [line 94]\n REMOVE_TEMPS(n$5); [line 94]\n " shape="invhouse"] +117 [label="117: Prune (false branch) \n n$5=*&SIL_temp_conditional___110:int [line 87]\n NULLIFY(&SIL_temp_conditional___110,true); [line 87]\n PRUNE((n$5 == 0), false); [line 87]\n REMOVE_TEMPS(n$5); [line 87]\n " shape="invhouse"] 117 -> 109 ; -116 [label="116: Prune (true branch) \n n$5=*&SIL_temp_conditional___110:int [line 94]\n NULLIFY(&SIL_temp_conditional___110,true); [line 94]\n PRUNE((n$5 != 0), true); [line 94]\n REMOVE_TEMPS(n$5); [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="invhouse"] +116 [label="116: Prune (true branch) \n n$5=*&SIL_temp_conditional___110:int [line 87]\n NULLIFY(&SIL_temp_conditional___110,true); [line 87]\n PRUNE((n$5 != 0), true); [line 87]\n REMOVE_TEMPS(n$5); [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="invhouse"] 116 -> 102 ; -115 [label="115: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___110); [line 94]\n *&SIL_temp_conditional___110:int =1 [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="box"] +115 [label="115: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___110); [line 87]\n *&SIL_temp_conditional___110:int =1 [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 115 -> 110 ; -114 [label="114: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___110); [line 94]\n *&SIL_temp_conditional___110:int =0 [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="box"] +114 [label="114: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___110); [line 87]\n *&SIL_temp_conditional___110:int =0 [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 114 -> 110 ; -113 [label="113: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 94]\n REMOVE_TEMPS(n$4); [line 94]\n " shape="invhouse"] +113 [label="113: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 87]\n REMOVE_TEMPS(n$4); [line 87]\n " shape="invhouse"] 113 -> 115 ; -112 [label="112: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 94]\n REMOVE_TEMPS(n$4); [line 94]\n " shape="invhouse"] +112 [label="112: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 87]\n REMOVE_TEMPS(n$4); [line 87]\n " shape="invhouse"] 112 -> 114 ; -111 [label="111: Call _fun_getValue \n n$4=_fun_getValue() [line 94]\n " shape="box"] +111 [label="111: Call _fun_getValue \n n$4=_fun_getValue() [line 87]\n " shape="box"] 111 -> 112 ; @@ -598,15 +598,15 @@ digraph iCFG { 108 -> 127 ; -107 [label="107: Prune (false branch) \n PRUNE(((n$3 > 1) == 0), false); [line 96]\n REMOVE_TEMPS(n$3); [line 96]\n " shape="invhouse"] +107 [label="107: Prune (false branch) \n PRUNE(((n$3 > 1) == 0), false); [line 89]\n REMOVE_TEMPS(n$3); [line 89]\n " shape="invhouse"] 107 -> 104 ; -106 [label="106: Prune (true branch) \n PRUNE(((n$3 > 1) != 0), true); [line 96]\n REMOVE_TEMPS(n$3); [line 96]\n APPLY_ABSTRACTION; [line 96]\n " shape="invhouse"] +106 [label="106: Prune (true branch) \n PRUNE(((n$3 > 1) != 0), true); [line 89]\n REMOVE_TEMPS(n$3); [line 89]\n APPLY_ABSTRACTION; [line 89]\n " shape="invhouse"] 106 -> 108 ; -105 [label="105: BinaryOperatorStmt: GT \n n$3=_fun_getValue() [line 96]\n " shape="box"] +105 [label="105: BinaryOperatorStmt: GT \n n$3=_fun_getValue() [line 89]\n " shape="box"] 105 -> 106 ; @@ -615,7 +615,7 @@ digraph iCFG { 104 -> 103 ; -103 [label="103: Call _fun_printf \n n$2=_fun_printf(\"g4\\n\":char *) [line 98]\n REMOVE_TEMPS(n$2); [line 98]\n APPLY_ABSTRACTION; [line 98]\n " shape="box"] +103 [label="103: Call _fun_printf \n n$2=_fun_printf(\"g4\\n\":char *) [line 91]\n REMOVE_TEMPS(n$2); [line 91]\n APPLY_ABSTRACTION; [line 91]\n " shape="box"] 103 -> 102 ; @@ -623,11 +623,11 @@ digraph iCFG { 102 -> 101 ; -101 [label="101: DeclStmt \n *&a:int =2 [line 101]\n NULLIFY(&a,false); [line 101]\n " shape="box"] +101 [label="101: DeclStmt \n *&a:int =2 [line 94]\n NULLIFY(&a,false); [line 94]\n " shape="box"] 101 -> 100 ; -100 [label="100: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 102]\n REMOVE_TEMPS(n$1); [line 102]\n APPLY_ABSTRACTION; [line 102]\n " shape="box"] +100 [label="100: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 95]\n REMOVE_TEMPS(n$1); [line 95]\n APPLY_ABSTRACTION; [line 95]\n " shape="box"] 100 -> 99 ; @@ -635,50 +635,50 @@ digraph iCFG { 99 -> 98 ; -98 [label="98: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 105]\n REMOVE_TEMPS(n$0); [line 105]\n " shape="box"] +98 [label="98: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 98]\n REMOVE_TEMPS(n$0); [line 98]\n " shape="box"] 98 -> 97 ; -97 [label="97: Return Stmt \n *&return:int =1 [line 106]\n APPLY_ABSTRACTION; [line 106]\n " shape="box"] +97 [label="97: Return Stmt \n *&return:int =1 [line 99]\n APPLY_ABSTRACTION; [line 99]\n " shape="box"] 97 -> 96 ; 96 [label="96: Exit g4 \n " color=yellow style=filled] -95 [label="95: Start g4\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 87]\n NULLIFY(&a,false); [line 87]\n " color=yellow style=filled] +95 [label="95: Start g4\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 81]\n NULLIFY(&a,false); [line 81]\n " color=yellow style=filled] 95 -> 108 ; -94 [label="94: Call _fun_printf \n n$8=_fun_printf(\"B\\n\":char *) [line 67]\n REMOVE_TEMPS(n$8); [line 67]\n " shape="box"] +94 [label="94: Call _fun_printf \n n$8=_fun_printf(\"B\\n\":char *) [line 61]\n REMOVE_TEMPS(n$8); [line 61]\n " shape="box"] 94 -> 87 ; -93 [label="93: Prune (false branch) \n n$7=*&SIL_temp_conditional___86:int [line 69]\n NULLIFY(&SIL_temp_conditional___86,true); [line 69]\n PRUNE((n$7 == 0), false); [line 69]\n REMOVE_TEMPS(n$7); [line 69]\n " shape="invhouse"] +93 [label="93: Prune (false branch) \n n$7=*&SIL_temp_conditional___86:int [line 63]\n NULLIFY(&SIL_temp_conditional___86,true); [line 63]\n PRUNE((n$7 == 0), false); [line 63]\n REMOVE_TEMPS(n$7); [line 63]\n " shape="invhouse"] 93 -> 85 ; -92 [label="92: Prune (true branch) \n n$7=*&SIL_temp_conditional___86:int [line 69]\n NULLIFY(&SIL_temp_conditional___86,true); [line 69]\n PRUNE((n$7 != 0), true); [line 69]\n REMOVE_TEMPS(n$7); [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="invhouse"] +92 [label="92: Prune (true branch) \n n$7=*&SIL_temp_conditional___86:int [line 63]\n NULLIFY(&SIL_temp_conditional___86,true); [line 63]\n PRUNE((n$7 != 0), true); [line 63]\n REMOVE_TEMPS(n$7); [line 63]\n APPLY_ABSTRACTION; [line 63]\n " shape="invhouse"] 92 -> 65 ; -91 [label="91: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___86); [line 69]\n *&SIL_temp_conditional___86:int =1 [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="box"] +91 [label="91: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___86); [line 63]\n *&SIL_temp_conditional___86:int =1 [line 63]\n APPLY_ABSTRACTION; [line 63]\n " shape="box"] 91 -> 86 ; -90 [label="90: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___86); [line 69]\n *&SIL_temp_conditional___86:int =0 [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="box"] +90 [label="90: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___86); [line 63]\n *&SIL_temp_conditional___86:int =0 [line 63]\n APPLY_ABSTRACTION; [line 63]\n " shape="box"] 90 -> 86 ; -89 [label="89: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 69]\n REMOVE_TEMPS(n$6); [line 69]\n " shape="invhouse"] +89 [label="89: Prune (false branch) \n PRUNE((n$6 == 0), false); [line 63]\n REMOVE_TEMPS(n$6); [line 63]\n " shape="invhouse"] 89 -> 91 ; -88 [label="88: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 69]\n REMOVE_TEMPS(n$6); [line 69]\n " shape="invhouse"] +88 [label="88: Prune (true branch) \n PRUNE((n$6 != 0), true); [line 63]\n REMOVE_TEMPS(n$6); [line 63]\n " shape="invhouse"] 88 -> 90 ; -87 [label="87: Call _fun_getValue \n n$6=_fun_getValue() [line 69]\n " shape="box"] +87 [label="87: Call _fun_getValue \n n$6=_fun_getValue() [line 63]\n " shape="box"] 87 -> 88 ; @@ -692,31 +692,31 @@ digraph iCFG { 85 -> 78 ; -84 [label="84: Prune (false branch) \n n$5=*&SIL_temp_conditional___77:int [line 71]\n NULLIFY(&SIL_temp_conditional___77,true); [line 71]\n PRUNE((n$5 == 0), false); [line 71]\n REMOVE_TEMPS(n$5); [line 71]\n " shape="invhouse"] +84 [label="84: Prune (false branch) \n n$5=*&SIL_temp_conditional___77:int [line 65]\n NULLIFY(&SIL_temp_conditional___77,true); [line 65]\n PRUNE((n$5 == 0), false); [line 65]\n REMOVE_TEMPS(n$5); [line 65]\n " shape="invhouse"] 84 -> 76 ; -83 [label="83: Prune (true branch) \n n$5=*&SIL_temp_conditional___77:int [line 71]\n NULLIFY(&SIL_temp_conditional___77,true); [line 71]\n PRUNE((n$5 != 0), true); [line 71]\n REMOVE_TEMPS(n$5); [line 71]\n " shape="invhouse"] +83 [label="83: Prune (true branch) \n n$5=*&SIL_temp_conditional___77:int [line 65]\n NULLIFY(&SIL_temp_conditional___77,true); [line 65]\n PRUNE((n$5 != 0), true); [line 65]\n REMOVE_TEMPS(n$5); [line 65]\n " shape="invhouse"] 83 -> 68 ; -82 [label="82: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___77); [line 71]\n *&SIL_temp_conditional___77:int =1 [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="box"] +82 [label="82: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___77); [line 65]\n *&SIL_temp_conditional___77:int =1 [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] 82 -> 77 ; -81 [label="81: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___77); [line 71]\n *&SIL_temp_conditional___77:int =0 [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="box"] +81 [label="81: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___77); [line 65]\n *&SIL_temp_conditional___77:int =0 [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] 81 -> 77 ; -80 [label="80: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 71]\n REMOVE_TEMPS(n$4); [line 71]\n " shape="invhouse"] +80 [label="80: Prune (false branch) \n PRUNE((n$4 == 0), false); [line 65]\n REMOVE_TEMPS(n$4); [line 65]\n " shape="invhouse"] 80 -> 82 ; -79 [label="79: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 71]\n REMOVE_TEMPS(n$4); [line 71]\n " shape="invhouse"] +79 [label="79: Prune (true branch) \n PRUNE((n$4 != 0), true); [line 65]\n REMOVE_TEMPS(n$4); [line 65]\n " shape="invhouse"] 79 -> 81 ; -78 [label="78: Call _fun_getValue \n n$4=_fun_getValue() [line 71]\n " shape="box"] +78 [label="78: Call _fun_getValue \n n$4=_fun_getValue() [line 65]\n " shape="box"] 78 -> 79 ; @@ -734,15 +734,15 @@ digraph iCFG { 75 -> 94 ; -74 [label="74: Prune (false branch) \n PRUNE(((n$3 > 1) == 0), false); [line 73]\n REMOVE_TEMPS(n$3); [line 73]\n " shape="invhouse"] +74 [label="74: Prune (false branch) \n PRUNE(((n$3 > 1) == 0), false); [line 67]\n REMOVE_TEMPS(n$3); [line 67]\n " shape="invhouse"] 74 -> 71 ; -73 [label="73: Prune (true branch) \n PRUNE(((n$3 > 1) != 0), true); [line 73]\n REMOVE_TEMPS(n$3); [line 73]\n APPLY_ABSTRACTION; [line 73]\n " shape="invhouse"] +73 [label="73: Prune (true branch) \n PRUNE(((n$3 > 1) != 0), true); [line 67]\n REMOVE_TEMPS(n$3); [line 67]\n APPLY_ABSTRACTION; [line 67]\n " shape="invhouse"] 73 -> 75 ; -72 [label="72: BinaryOperatorStmt: GT \n n$3=_fun_getValue() [line 73]\n " shape="box"] +72 [label="72: BinaryOperatorStmt: GT \n n$3=_fun_getValue() [line 67]\n " shape="box"] 72 -> 73 ; @@ -751,11 +751,11 @@ digraph iCFG { 71 -> 70 ; -70 [label="70: Call _fun_printf \n n$2=_fun_printf(\"g3\\n\":char *) [line 75]\n REMOVE_TEMPS(n$2); [line 75]\n " shape="box"] +70 [label="70: Call _fun_printf \n n$2=_fun_printf(\"g3\\n\":char *) [line 69]\n REMOVE_TEMPS(n$2); [line 69]\n " shape="box"] 70 -> 69 ; -69 [label="69: Return Stmt \n *&return:int =0 [line 76]\n APPLY_ABSTRACTION; [line 76]\n " shape="box"] +69 [label="69: Return Stmt \n *&return:int =0 [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 69 -> 62 ; @@ -763,11 +763,11 @@ digraph iCFG { 68 -> 67 ; -67 [label="67: DeclStmt \n *&a:int =2 [line 79]\n NULLIFY(&a,false); [line 79]\n " shape="box"] +67 [label="67: DeclStmt \n *&a:int =2 [line 73]\n NULLIFY(&a,false); [line 73]\n " shape="box"] 67 -> 66 ; -66 [label="66: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 80]\n REMOVE_TEMPS(n$1); [line 80]\n APPLY_ABSTRACTION; [line 80]\n " shape="box"] +66 [label="66: Call _fun_printf \n n$1=_fun_printf(\"A\\n\":char *) [line 74]\n REMOVE_TEMPS(n$1); [line 74]\n APPLY_ABSTRACTION; [line 74]\n " shape="box"] 66 -> 65 ; @@ -775,54 +775,54 @@ digraph iCFG { 65 -> 64 ; -64 [label="64: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 83]\n REMOVE_TEMPS(n$0); [line 83]\n " shape="box"] +64 [label="64: Call _fun_printf \n n$0=_fun_printf(\"exit\\n\":char *) [line 77]\n REMOVE_TEMPS(n$0); [line 77]\n " shape="box"] 64 -> 63 ; -63 [label="63: Return Stmt \n *&return:int =1 [line 84]\n APPLY_ABSTRACTION; [line 84]\n " shape="box"] +63 [label="63: Return Stmt \n *&return:int =1 [line 78]\n APPLY_ABSTRACTION; [line 78]\n " shape="box"] 63 -> 62 ; 62 [label="62: Exit g3 \n " color=yellow style=filled] -61 [label="61: Start g3\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 64]\n NULLIFY(&a,false); [line 64]\n " color=yellow style=filled] +61 [label="61: Start g3\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 59]\n NULLIFY(&a,false); [line 59]\n " color=yellow style=filled] 61 -> 75 ; -60 [label="60: DeclStmt \n *&a:int =0 [line 43]\n NULLIFY(&a,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +60 [label="60: DeclStmt \n *&a:int =0 [line 38]\n NULLIFY(&a,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] 60 -> 40 ; -59 [label="59: BinaryOperatorStmt: Assign \n *&a:int =1 [line 45]\n NULLIFY(&a,false); [line 45]\n " shape="box"] +59 [label="59: BinaryOperatorStmt: Assign \n *&a:int =1 [line 40]\n NULLIFY(&a,false); [line 40]\n " shape="box"] 59 -> 52 ; -58 [label="58: Prune (false branch) \n n$4=*&SIL_temp_conditional___51:int [line 47]\n NULLIFY(&SIL_temp_conditional___51,true); [line 47]\n PRUNE((n$4 == 0), false); [line 47]\n REMOVE_TEMPS(n$4); [line 47]\n " shape="invhouse"] +58 [label="58: Prune (false branch) \n n$4=*&SIL_temp_conditional___51:int [line 42]\n NULLIFY(&SIL_temp_conditional___51,true); [line 42]\n PRUNE((n$4 == 0), false); [line 42]\n REMOVE_TEMPS(n$4); [line 42]\n " shape="invhouse"] 58 -> 50 ; -57 [label="57: Prune (true branch) \n n$4=*&SIL_temp_conditional___51:int [line 47]\n NULLIFY(&SIL_temp_conditional___51,true); [line 47]\n PRUNE((n$4 != 0), true); [line 47]\n REMOVE_TEMPS(n$4); [line 47]\n " shape="invhouse"] +57 [label="57: Prune (true branch) \n n$4=*&SIL_temp_conditional___51:int [line 42]\n NULLIFY(&SIL_temp_conditional___51,true); [line 42]\n PRUNE((n$4 != 0), true); [line 42]\n REMOVE_TEMPS(n$4); [line 42]\n " shape="invhouse"] 57 -> 31 ; -56 [label="56: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___51); [line 47]\n *&SIL_temp_conditional___51:int =1 [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +56 [label="56: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___51); [line 42]\n *&SIL_temp_conditional___51:int =1 [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 56 -> 51 ; -55 [label="55: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___51); [line 47]\n *&SIL_temp_conditional___51:int =0 [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +55 [label="55: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___51); [line 42]\n *&SIL_temp_conditional___51:int =0 [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 55 -> 51 ; -54 [label="54: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 47]\n REMOVE_TEMPS(n$3); [line 47]\n " shape="invhouse"] +54 [label="54: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 42]\n REMOVE_TEMPS(n$3); [line 42]\n " shape="invhouse"] 54 -> 56 ; -53 [label="53: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 47]\n REMOVE_TEMPS(n$3); [line 47]\n " shape="invhouse"] +53 [label="53: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 42]\n REMOVE_TEMPS(n$3); [line 42]\n " shape="invhouse"] 53 -> 55 ; -52 [label="52: Call _fun_getValue \n n$3=_fun_getValue() [line 47]\n " shape="box"] +52 [label="52: Call _fun_getValue \n n$3=_fun_getValue() [line 42]\n " shape="box"] 52 -> 53 ; @@ -836,31 +836,31 @@ digraph iCFG { 50 -> 43 ; -49 [label="49: Prune (false branch) \n n$2=*&SIL_temp_conditional___42:int [line 49]\n NULLIFY(&SIL_temp_conditional___42,true); [line 49]\n PRUNE((n$2 == 0), false); [line 49]\n REMOVE_TEMPS(n$2); [line 49]\n " shape="invhouse"] +49 [label="49: Prune (false branch) \n n$2=*&SIL_temp_conditional___42:int [line 44]\n NULLIFY(&SIL_temp_conditional___42,true); [line 44]\n PRUNE((n$2 == 0), false); [line 44]\n REMOVE_TEMPS(n$2); [line 44]\n " shape="invhouse"] 49 -> 41 ; -48 [label="48: Prune (true branch) \n n$2=*&SIL_temp_conditional___42:int [line 49]\n NULLIFY(&SIL_temp_conditional___42,true); [line 49]\n PRUNE((n$2 != 0), true); [line 49]\n REMOVE_TEMPS(n$2); [line 49]\n " shape="invhouse"] +48 [label="48: Prune (true branch) \n n$2=*&SIL_temp_conditional___42:int [line 44]\n NULLIFY(&SIL_temp_conditional___42,true); [line 44]\n PRUNE((n$2 != 0), true); [line 44]\n REMOVE_TEMPS(n$2); [line 44]\n " shape="invhouse"] 48 -> 34 ; -47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___42); [line 49]\n *&SIL_temp_conditional___42:int =1 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___42); [line 44]\n *&SIL_temp_conditional___42:int =1 [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 47 -> 42 ; -46 [label="46: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___42); [line 49]\n *&SIL_temp_conditional___42:int =0 [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +46 [label="46: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___42); [line 44]\n *&SIL_temp_conditional___42:int =0 [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 46 -> 42 ; -45 [label="45: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n " shape="invhouse"] +45 [label="45: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 44]\n REMOVE_TEMPS(n$1); [line 44]\n " shape="invhouse"] 45 -> 47 ; -44 [label="44: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n " shape="invhouse"] +44 [label="44: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 44]\n REMOVE_TEMPS(n$1); [line 44]\n " shape="invhouse"] 44 -> 46 ; -43 [label="43: Call _fun_getValue \n n$1=_fun_getValue() [line 49]\n " shape="box"] +43 [label="43: Call _fun_getValue \n n$1=_fun_getValue() [line 44]\n " shape="box"] 43 -> 44 ; @@ -878,15 +878,15 @@ digraph iCFG { 40 -> 59 ; -39 [label="39: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 51]\n REMOVE_TEMPS(n$0); [line 51]\n " shape="invhouse"] +39 [label="39: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n " shape="invhouse"] 39 -> 36 ; -38 [label="38: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 51]\n REMOVE_TEMPS(n$0); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="invhouse"] +38 [label="38: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="invhouse"] 38 -> 40 ; -37 [label="37: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 51]\n " shape="box"] +37 [label="37: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 46]\n " shape="box"] 37 -> 38 ; @@ -895,7 +895,7 @@ digraph iCFG { 36 -> 35 ; -35 [label="35: Return Stmt \n *&return:int =0 [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] +35 [label="35: Return Stmt \n *&return:int =0 [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] 35 -> 28 ; @@ -903,11 +903,11 @@ digraph iCFG { 34 -> 33 ; -33 [label="33: BinaryOperatorStmt: Assign \n *&a:int =2 [line 56]\n NULLIFY(&a,false); [line 56]\n " shape="box"] +33 [label="33: BinaryOperatorStmt: Assign \n *&a:int =2 [line 51]\n NULLIFY(&a,false); [line 51]\n " shape="box"] 33 -> 32 ; -32 [label="32: Return Stmt \n *&return:int =2 [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] +32 [label="32: Return Stmt \n *&return:int =2 [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] 32 -> 28 ; @@ -915,34 +915,34 @@ digraph iCFG { 31 -> 30 ; -30 [label="30: BinaryOperatorStmt: Assign \n *&a:int =3 [line 60]\n NULLIFY(&a,false); [line 60]\n " shape="box"] +30 [label="30: BinaryOperatorStmt: Assign \n *&a:int =3 [line 55]\n NULLIFY(&a,false); [line 55]\n " shape="box"] 30 -> 29 ; -29 [label="29: Return Stmt \n *&return:int =1 [line 61]\n APPLY_ABSTRACTION; [line 61]\n " shape="box"] +29 [label="29: Return Stmt \n *&return:int =1 [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] 29 -> 28 ; 28 [label="28: Exit g2 \n " color=yellow style=filled] -27 [label="27: Start g2\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 41]\n NULLIFY(&a,false); [line 41]\n " color=yellow style=filled] +27 [label="27: Start g2\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 37]\n NULLIFY(&a,false); [line 37]\n " color=yellow style=filled] 27 -> 60 ; -26 [label="26: DeclStmt \n *&a:int =0 [line 31]\n NULLIFY(&a,false); [line 31]\n " shape="box"] +26 [label="26: DeclStmt \n *&a:int =0 [line 27]\n NULLIFY(&a,false); [line 27]\n " shape="box"] 26 -> 23 ; -25 [label="25: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 32]\n REMOVE_TEMPS(n$0); [line 32]\n " shape="invhouse"] +25 [label="25: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n " shape="invhouse"] 25 -> 22 ; -24 [label="24: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 32]\n REMOVE_TEMPS(n$0); [line 32]\n " shape="invhouse"] +24 [label="24: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n " shape="invhouse"] 24 -> 20 ; -23 [label="23: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 32]\n " shape="box"] +23 [label="23: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 28]\n " shape="box"] 23 -> 24 ; @@ -951,7 +951,7 @@ digraph iCFG { 22 -> 21 ; -21 [label="21: Return Stmt \n *&return:int =0 [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] +21 [label="21: Return Stmt \n *&return:int =0 [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 21 -> 17 ; @@ -959,34 +959,34 @@ digraph iCFG { 20 -> 19 ; -19 [label="19: BinaryOperatorStmt: Assign \n *&a:int =1 [line 37]\n NULLIFY(&a,false); [line 37]\n " shape="box"] +19 [label="19: BinaryOperatorStmt: Assign \n *&a:int =1 [line 33]\n NULLIFY(&a,false); [line 33]\n " shape="box"] 19 -> 18 ; -18 [label="18: Return Stmt \n *&return:int =1 [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +18 [label="18: Return Stmt \n *&return:int =1 [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit g1 \n " color=yellow style=filled] -16 [label="16: Start g1\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 29]\n NULLIFY(&a,false); [line 29]\n " color=yellow style=filled] +16 [label="16: Start g1\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 26]\n NULLIFY(&a,false); [line 26]\n " color=yellow style=filled] 16 -> 26 ; -15 [label="15: DeclStmt \n *&a:int =0 [line 18]\n NULLIFY(&a,false); [line 18]\n " shape="box"] +15 [label="15: DeclStmt \n *&a:int =0 [line 15]\n NULLIFY(&a,false); [line 15]\n " shape="box"] 15 -> 12 ; -14 [label="14: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n " shape="invhouse"] +14 [label="14: Prune (false branch) \n PRUNE(((n$0 > 1) == 0), false); [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n " shape="invhouse"] 14 -> 11 ; -13 [label="13: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="invhouse"] +13 [label="13: Prune (true branch) \n PRUNE(((n$0 > 1) != 0), true); [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="invhouse"] 13 -> 9 ; -12 [label="12: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 19]\n " shape="box"] +12 [label="12: BinaryOperatorStmt: GT \n n$0=_fun_getValue() [line 16]\n " shape="box"] 12 -> 13 ; @@ -995,7 +995,7 @@ digraph iCFG { 11 -> 10 ; -10 [label="10: Skip GotoLabel_stepB \n APPLY_ABSTRACTION; [line 22]\n " color="gray"] +10 [label="10: Skip GotoLabel_stepB \n APPLY_ABSTRACTION; [line 19]\n " color="gray"] 10 -> 9 ; @@ -1007,22 +1007,22 @@ digraph iCFG { 8 -> 7 ; -7 [label="7: BinaryOperatorStmt: Assign \n *&a:int =1 [line 25]\n NULLIFY(&a,false); [line 25]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n *&a:int =1 [line 22]\n NULLIFY(&a,false); [line 22]\n " shape="box"] 7 -> 6 ; -6 [label="6: Return Stmt \n *&return:int =1 [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +6 [label="6: Return Stmt \n *&return:int =1 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit g0 \n " color=yellow style=filled] -4 [label="4: Start g0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 16]\n NULLIFY(&a,false); [line 16]\n " color=yellow style=filled] +4 [label="4: Start g0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 14]\n NULLIFY(&a,false); [line 14]\n " color=yellow style=filled] 4 -> 15 ; -3 [label="3: Return Stmt \n *&return:int =2 [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =2 [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/initialization/array_initlistexpr.c b/infer/tests/codetoanalyze/c/frontend/initialization/array_initlistexpr.c index 0bfda22de..980b30495 100644 --- a/infer/tests/codetoanalyze/c/frontend/initialization/array_initlistexpr.c +++ b/infer/tests/codetoanalyze/c/frontend/initialization/array_initlistexpr.c @@ -8,6 +8,6 @@ */ int main() { - int z; - int a[2][3] = {{z+1, 2, 3}, {5,6,7}}; + int z; + int a[2][3] = {{z + 1, 2, 3}, {5, 6, 7}}; } diff --git a/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c b/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c index e42f1990f..dd226a296 100644 --- a/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c +++ b/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c @@ -12,11 +12,9 @@ struct point { int y; }; -int compound_literal_expr() { - return ((struct point) { .y = 32, .x = 52 }).x; -} +int compound_literal_expr() { return ((struct point){.y = 32, .x = 52}).x; } int init_with_compound_literal() { - struct point p = (struct point) { 32, 52 }; + struct point p = (struct point){32, 52}; return p.x; } diff --git a/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c.dot b/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c.dot index b92a9e00e..a0f2e0f99 100644 --- a/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/initialization/compound_literal.c.dot @@ -1,20 +1,20 @@ digraph iCFG { -7 [label="7: DeclStmt \n *&SIL_compound_literal__n$1.x:int =32 [line 20]\n *&SIL_compound_literal__n$1.y:int =52 [line 20]\n n$2=*&SIL_compound_literal__n$1:struct point [line 20]\n *&p:struct point =n$2 [line 20]\n REMOVE_TEMPS(n$2); [line 20]\n NULLIFY(&SIL_compound_literal__n$1,false); [line 20]\n " shape="box"] +7 [label="7: DeclStmt \n *&SIL_compound_literal__n$1.x:int =32 [line 18]\n *&SIL_compound_literal__n$1.y:int =52 [line 18]\n n$2=*&SIL_compound_literal__n$1:struct point [line 18]\n *&p:struct point =n$2 [line 18]\n REMOVE_TEMPS(n$2); [line 18]\n NULLIFY(&SIL_compound_literal__n$1,false); [line 18]\n " shape="box"] 7 -> 6 ; -6 [label="6: Return Stmt \n n$0=*&p.x:int [line 21]\n *&return:int =n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n NULLIFY(&p,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&p.x:int [line 19]\n *&return:int =n$0 [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n NULLIFY(&p,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit init_with_compound_literal \n " color=yellow style=filled] -4 [label="4: Start init_with_compound_literal\nFormals: \nLocals: p:struct point SIL_compound_literal__n$1:struct point \n DECLARE_LOCALS(&return,&p,&SIL_compound_literal__n$1); [line 19]\n NULLIFY(&p,false); [line 19]\n " color=yellow style=filled] +4 [label="4: Start init_with_compound_literal\nFormals: \nLocals: p:struct point SIL_compound_literal__n$1:struct point \n DECLARE_LOCALS(&return,&p,&SIL_compound_literal__n$1); [line 17]\n NULLIFY(&p,false); [line 17]\n " color=yellow style=filled] 4 -> 7 ; -3 [label="3: Return Stmt \n *&SIL_compound_literal__n$0.x:int =52 [line 16]\n *&SIL_compound_literal__n$0.y:int =32 [line 16]\n n$1=*&SIL_compound_literal__n$0.x:int [line 16]\n *&return:int =n$1 [line 16]\n REMOVE_TEMPS(n$1); [line 16]\n NULLIFY(&SIL_compound_literal__n$0,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: Return Stmt \n *&SIL_compound_literal__n$0.x:int =52 [line 15]\n *&SIL_compound_literal__n$0.y:int =32 [line 15]\n n$1=*&SIL_compound_literal__n$0.x:int [line 15]\n *&return:int =n$1 [line 15]\n REMOVE_TEMPS(n$1); [line 15]\n NULLIFY(&SIL_compound_literal__n$0,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c b/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c index a949a2015..9e4e313b4 100644 --- a/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c +++ b/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c @@ -8,36 +8,30 @@ */ typedef struct Point { - int x; - int y; + int x; + int y; } Point; -int foo() { - return 5; -} +int foo() { return 5; } -int main() { - struct Point p = {1, foo() + 3}; -} +int main() { struct Point p = {1, foo() + 3}; } -int test(Point *p) { - *p = (Point){4, 5}; - return 0; +int test(Point* p) { + *p = (Point){4, 5}; + return 0; } -struct Employee -{ - int ssn; - float salary; - struct date - { - int date; - int month; - int year; - }doj; -}emp1; +struct Employee { + int ssn; + float salary; + struct date { + int date; + int month; + int year; + } doj; +} emp1; int main2() { - struct Employee e = {12, 3000.50, 12, 12, 2010}; - return e.ssn; + struct Employee e = {12, 3000.50, 12, 12, 2010}; + return e.ssn; } diff --git a/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c.dot b/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c.dot index c075a180b..1690e2991 100644 --- a/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.c.dot @@ -1,46 +1,46 @@ digraph iCFG { -14 [label="14: DeclStmt \n *&e.doj.date:int =12 [line 41]\n *&e.doj.month:int =3000.500000 [line 41]\n *&e.doj.year:int =12 [line 41]\n *&e.salary:float =12 [line 41]\n *&e.ssn:int =2010 [line 41]\n " shape="box"] +14 [label="14: DeclStmt \n *&e.doj.date:int =12 [line 35]\n *&e.doj.month:int =3000.500000 [line 35]\n *&e.doj.year:int =12 [line 35]\n *&e.salary:float =12 [line 35]\n *&e.ssn:int =2010 [line 35]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$0=*&e.ssn:int [line 42]\n *&return:int =n$0 [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n NULLIFY(&e,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +13 [label="13: Return Stmt \n n$0=*&e.ssn:int [line 36]\n *&return:int =n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&e,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit main2 \n " color=yellow style=filled] -11 [label="11: Start main2\nFormals: \nLocals: e:struct Employee \n DECLARE_LOCALS(&return,&e); [line 40]\n " color=yellow style=filled] +11 [label="11: Start main2\nFormals: \nLocals: e:struct Employee \n DECLARE_LOCALS(&return,&e); [line 34]\n " color=yellow style=filled] 11 -> 14 ; -10 [label="10: InitListExp \n *&p.x:int =4 [line 24]\n *&p.y:int =5 [line 24]\n " shape="box"] +10 [label="10: InitListExp \n *&p.x:int =4 [line 20]\n *&p.y:int =5 [line 20]\n " shape="box"] 10 -> 9 ; -9 [label="9: Return Stmt \n *&return:int =0 [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +9 [label="9: Return Stmt \n *&return:int =0 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit test \n " color=yellow style=filled] -7 [label="7: Start test\nFormals: p:struct Point *\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n NULLIFY(&p,false); [line 23]\n " color=yellow style=filled] +7 [label="7: Start test\nFormals: p:struct Point *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&p,false); [line 19]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: DeclStmt \n n$0=_fun_foo() [line 20]\n *&p.x:int =1 [line 20]\n *&p.y:int =(n$0 + 3) [line 20]\n REMOVE_TEMPS(n$0); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +6 [label="6: DeclStmt \n n$0=_fun_foo() [line 17]\n *&p.x:int =1 [line 17]\n *&p.y:int =(n$0 + 3) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit main \n " color=yellow style=filled] -4 [label="4: Start main\nFormals: \nLocals: p:struct Point \n DECLARE_LOCALS(&return,&p); [line 19]\n NULLIFY(&p,false); [line 19]\n " color=yellow style=filled] +4 [label="4: Start main\nFormals: \nLocals: p:struct Point \n DECLARE_LOCALS(&return,&p); [line 17]\n NULLIFY(&p,false); [line 17]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n *&return:int =5 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =5 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/loops/do_while.c b/infer/tests/codetoanalyze/c/frontend/loops/do_while.c index e6bbcfd92..06f34e53b 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/do_while.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/do_while.c @@ -7,12 +7,12 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main () { +int main() { int a = 10; int b = 0; do { a = 1; - }while( b < 20 ); + } while (b < 20); return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/do_while_condition_side_effects.c b/infer/tests/codetoanalyze/c/frontend/loops/do_while_condition_side_effects.c index 2457cadf2..64aa955c7 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/do_while_condition_side_effects.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/do_while_condition_side_effects.c @@ -7,12 +7,12 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main () { +int main() { int a = 10; int b = 0; do { a = 1; - }while( (b = 40) ); + } while ((b = 40)); return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/do_while_nested.c b/infer/tests/codetoanalyze/c/frontend/loops/do_while_nested.c index 4fde94640..d06ba3067 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/do_while_nested.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/do_while_nested.c @@ -7,15 +7,15 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main () { +int main() { int a = 10; int b = 0; do { a = 1; do { a = 2; - }while( b < 30 ); - }while( b < 20 ); + } while (b < 30); + } while (b < 20); return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_condition_side_effects.c b/infer/tests/codetoanalyze/c/frontend/loops/for_condition_side_effects.c index f61a2c175..5a08b0507 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_condition_side_effects.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_condition_side_effects.c @@ -10,8 +10,8 @@ int main() { int j = 0; int i = 0; - for (int b=3; (b=10); i++) { - j += j; - } + for (int b = 3; (b = 10); i++) { + j += j; + } return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_nested.c b/infer/tests/codetoanalyze/c/frontend/loops/for_nested.c index 34497a6f0..a3a6e73e4 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_nested.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_nested.c @@ -9,8 +9,8 @@ int main() { int k = 0; - for (int i=0; i<10; i++) { - for (int j=0; j<10; j++) { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { k = k + i; } } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition.c b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition.c index 6fba5d980..ea2ed0590 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition.c @@ -9,7 +9,7 @@ int main() { int j = 0; - for (int b=0;; b++) { + for (int b = 0;; b++) { j += j; } return 0; diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr.c b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr.c index d73667525..396a91fd4 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr.c @@ -9,8 +9,8 @@ int main() { int j = 0; - for (int b=0;;) { - j += j; - } + for (int b = 0;;) { + j += j; + } return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr_body.c b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr_body.c index f658dc711..84b81e87e 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr_body.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_no_condition_incr_body.c @@ -9,7 +9,7 @@ int main() { int d = 0; - for (d=0;;) { + for (d = 0;;) { } return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_simple.c b/infer/tests/codetoanalyze/c/frontend/loops/for_simple.c index 8e5285b5e..80c5fd488 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_simple.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_simple.c @@ -9,7 +9,7 @@ int main() { int j = 0; - for (int i=0; i<10; i++) { + for (int i = 0; i < 10; i++) { j += j; } return 0; diff --git a/infer/tests/codetoanalyze/c/frontend/loops/for_while_nested.c b/infer/tests/codetoanalyze/c/frontend/loops/for_while_nested.c index de9d825c5..61eab39a9 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/for_while_nested.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/for_while_nested.c @@ -9,8 +9,8 @@ int main() { int k = 0; - for (int i=0; i<10; i++) { - while(k < 10) { + for (int i = 0; i < 10; i++) { + while (k < 10) { k++; } } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c b/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c index 637607edd..f5719f6f3 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c @@ -7,7 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main(){ - while(1) {} +int main() { + while (1) { + } return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c.dot b/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c.dot index 47810a8d7..ac866ae8a 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/loops/while_no_body.c.dot @@ -12,7 +12,7 @@ digraph iCFG { 4 -> 5 ; 4 -> 6 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/loops/while_with_continue_and_break.c b/infer/tests/codetoanalyze/c/frontend/loops/while_with_continue_and_break.c index 5673b3518..701469c1f 100644 --- a/infer/tests/codetoanalyze/c/frontend/loops/while_with_continue_and_break.c +++ b/infer/tests/codetoanalyze/c/frontend/loops/while_with_continue_and_break.c @@ -8,17 +8,17 @@ */ int main() { - int x = 0; - while(1) { - while(2) { - x += 1; - if (x > 5) { - break; - } - } - if (x == 2) { - continue; - } + int x = 0; + while (1) { + while (2) { + x += 1; + if (x > 5) { + break; + } } - return 0; + if (x == 2) { + continue; + } + } + return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.c b/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.c index ebb1d53e8..2242943e5 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.c +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.c @@ -7,8 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int foo(int *p) { - if((*p = 0)) { +int foo(int* p) { + if ((*p = 0)) { return 32; } return 52; diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp b/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp deleted file mode 120000 index 68d1b814d..000000000 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp +++ /dev/null @@ -1 +0,0 @@ -assign_in_condition.c \ No newline at end of file diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp b/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp new file mode 100644 index 000000000..2242943e5 --- /dev/null +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/assign_in_condition.cpp @@ -0,0 +1,15 @@ +/* + * 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. + */ + +int foo(int* p) { + if ((*p = 0)) { + return 32; + } + return 52; +} diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c b/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c index 34e91c35d..8030d5bb5 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c @@ -8,16 +8,19 @@ */ int main() { - int y = 3; + int y = 3; - y = ({int X = 4; X;}); - return 0; + y = ({ + int X = 4; + X; + }); + return 0; } int test(int* p) { - return ({ - int x = *p; - int y = 1; - x + y; - }); + return ({ + int x = *p; + int y = 1; + x + y; + }); } diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c.dot b/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c.dot index 4e9486678..96d14c7ee 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/gnuexpr.c.dot @@ -1,12 +1,12 @@ digraph iCFG { -8 [label="8: Return Stmt \n n$2=*&p:int * [line 19]\n n$3=*n$2:int [line 19]\n *&x:int =n$3 [line 19]\n *&y:int =1 [line 20]\n n$0=*&x:int [line 21]\n n$1=*&y:int [line 21]\n n$4=*(n$0 + n$1):int [line 18]\n *&return:int =n$4 [line 18]\n REMOVE_TEMPS(n$4,n$0,n$1,n$2,n$3); [line 18]\n NULLIFY(&p,false); [line 18]\n NULLIFY(&x,false); [line 18]\n NULLIFY(&y,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +8 [label="8: Return Stmt \n n$2=*&p:int * [line 22]\n n$3=*n$2:int [line 22]\n *&x:int =n$3 [line 22]\n *&y:int =1 [line 23]\n n$0=*&x:int [line 24]\n n$1=*&y:int [line 24]\n n$4=*(n$0 + n$1):int [line 21]\n *&return:int =n$4 [line 21]\n REMOVE_TEMPS(n$4,n$0,n$1,n$2,n$3); [line 21]\n NULLIFY(&p,false); [line 21]\n NULLIFY(&x,false); [line 21]\n NULLIFY(&y,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 8 -> 7 ; 7 [label="7: Exit test \n " color=yellow style=filled] -6 [label="6: Start test\nFormals: p:int *\nLocals: y:int x:int \n DECLARE_LOCALS(&return,&y,&x); [line 17]\n NULLIFY(&x,false); [line 17]\n NULLIFY(&y,false); [line 17]\n " color=yellow style=filled] +6 [label="6: Start test\nFormals: p:int *\nLocals: y:int x:int \n DECLARE_LOCALS(&return,&y,&x); [line 20]\n NULLIFY(&x,false); [line 20]\n NULLIFY(&y,false); [line 20]\n " color=yellow style=filled] 6 -> 8 ; @@ -14,11 +14,11 @@ digraph iCFG { 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n *&X:int =4 [line 13]\n n$0=*&X:int [line 13]\n n$1=*n$0:int [line 13]\n *&y:int =n$1 [line 13]\n REMOVE_TEMPS(n$1,n$0); [line 13]\n NULLIFY(&X,false); [line 13]\n NULLIFY(&y,false); [line 13]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n *&X:int =4 [line 14]\n n$0=*&X:int [line 15]\n n$1=*n$0:int [line 13]\n *&y:int =n$1 [line 13]\n REMOVE_TEMPS(n$1,n$0); [line 13]\n NULLIFY(&X,false); [line 13]\n NULLIFY(&y,false); [line 13]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c index 6df92a157..496d8383f 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c @@ -7,26 +7,31 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#include +#include -struct { int a; int b; } *x; +struct { + int a; + int b; +} * x; union { int e; int f; - struct { int w; int u;} g; + struct { + int w; + int u; + } g; int h; } y; - int main() { int l; - x->a=1; - y.f =7; - y.g.u=y.f; + x->a = 1; + y.f = 7; + y.g.u = y.f; y.g.w = x->b; return 0; diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot index d21eb6aad..b2f4652bc 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.c.dot @@ -1,28 +1,28 @@ digraph iCFG { -7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:struct (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 32]\n *n$3.a:int =1 [line 32]\n REMOVE_TEMPS(n$3); [line 32]\n " shape="box"] 7 -> 6 ; -6 [label="6: BinaryOperatorStmt: Assign \n *&#GB$y.f:int =7 [line 28]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n *&#GB$y.f:int =7 [line 33]\n " shape="box"] 6 -> 5 ; -5 [label="5: BinaryOperatorStmt: Assign \n n$2=*&#GB$y.f:int [line 29]\n *&#GB$y.g.u:int =n$2 [line 29]\n REMOVE_TEMPS(n$2); [line 29]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: Assign \n n$2=*&#GB$y.f:int [line 34]\n *&#GB$y.g.u:int =n$2 [line 34]\n REMOVE_TEMPS(n$2); [line 34]\n " shape="box"] 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:struct (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.c:12:1) * [line 36]\n n$1=*n$0.b:int [line 36]\n *&#GB$y.g.w:int =n$1 [line 36]\n REMOVE_TEMPS(n$0,n$1); [line 36]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit main \n " color=yellow style=filled] -1 [label="1: Start main\nFormals: \nLocals: l:int \n DECLARE_LOCALS(&return,&l); [line 24]\n NULLIFY(&l,false); [line 24]\n " color=yellow style=filled] +1 [label="1: Start main\nFormals: \nLocals: l:int \n DECLARE_LOCALS(&return,&l); [line 29]\n NULLIFY(&l,false); [line 29]\n " color=yellow style=filled] 1 -> 7 ; diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp deleted file mode 120000 index 4aa4c6033..000000000 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp +++ /dev/null @@ -1 +0,0 @@ -union.c \ No newline at end of file diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp new file mode 100644 index 000000000..496d8383f --- /dev/null +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#include + +struct { + int a; + int b; +} * x; + +union { + int e; + int f; + + struct { + int w; + int u; + } g; + + int h; +} y; + +int main() { + int l; + + x->a = 1; + y.f = 7; + y.g.u = y.f; + + y.g.w = x->b; + return 0; +} diff --git a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot index 07c5d995d..f19c14ee5 100644 --- a/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot +++ b/infer/tests/codetoanalyze/c/frontend/nestedoperators/union.cpp.dot @@ -1,35 +1,35 @@ digraph iCFG { -9 [label="9: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:class (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 27]\n *n$3.a:int =1 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$3=*&#GB$x:class (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 32]\n *n$3.a:int =1 [line 32]\n REMOVE_TEMPS(n$3); [line 32]\n " shape="box"] 9 -> 8 ; -8 [label="8: BinaryOperatorStmt: Assign \n *&#GB$y.f:int =7 [line 28]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n *&#GB$y.f:int =7 [line 33]\n " shape="box"] 8 -> 7 ; -7 [label="7: BinaryOperatorStmt: Assign \n n$2=*&#GB$y.f:int [line 29]\n *&#GB$y.g.u:int =n$2 [line 29]\n REMOVE_TEMPS(n$2); [line 29]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$2=*&#GB$y.f:int [line 34]\n *&#GB$y.g.u:int =n$2 [line 34]\n REMOVE_TEMPS(n$2); [line 34]\n " shape="box"] 7 -> 6 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:class (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 31]\n n$1=*n$0.b:int [line 31]\n *&#GB$y.g.w:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&#GB$x:class (anonymous struct at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:12:1) * [line 36]\n n$1=*n$0.b:int [line 36]\n *&#GB$y.g.w:int =n$1 [line 36]\n REMOVE_TEMPS(n$0,n$1); [line 36]\n " shape="box"] 6 -> 5 ; -5 [label="5: Return Stmt \n *&return:int =0 [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +5 [label="5: Return Stmt \n *&return:int =0 [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 5 -> 4 ; 4 [label="4: Exit main \n " color=yellow style=filled] -3 [label="3: Start main\nFormals: \nLocals: l:int \n DECLARE_LOCALS(&return,&l); [line 24]\n NULLIFY(&l,false); [line 24]\n " color=yellow style=filled] +3 [label="3: Start main\nFormals: \nLocals: l:int \n DECLARE_LOCALS(&return,&l); [line 29]\n NULLIFY(&l,false); [line 29]\n " color=yellow style=filled] 3 -> 9 ; -2 [label="2: Exit (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1)_ \n " color=yellow style=filled] +2 [label="2: Exit (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:17:1)_ \n " color=yellow style=filled] -1 [label="1: Start (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1)_\nFormals: this:class (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:14:1) *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n NULLIFY(&this,false); [line 14]\n " color=yellow style=filled] +1 [label="1: Start (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:17:1)_\nFormals: this:class (anonymous union at infer_tests_codetoanalyze_c_frontend_nestedoperators_union.cpp:17:1) *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n NULLIFY(&this,false); [line 17]\n " color=yellow style=filled] 1 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/struct.c b/infer/tests/codetoanalyze/c/frontend/struct.c index a2e698b4b..544cbd9a4 100644 --- a/infer/tests/codetoanalyze/c/frontend/struct.c +++ b/infer/tests/codetoanalyze/c/frontend/struct.c @@ -8,8 +8,8 @@ */ struct X { -int a; -int b; + int a; + int b; }; void test() { diff --git a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c index a0015371f..218abbf09 100644 --- a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c +++ b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c @@ -9,221 +9,190 @@ #import -int m1 () -{ - int value = 0; - while (value < 10) { - switch (value) { - int x = 1; - printf("(out)HELLO WORLD!"); - x = value + 1; - case 0: - printf("(0)HELLO WORLD!"); - break; - case 1: - printf("(1)HELLO WORLD!"); - continue; - case 2: - default: - printf("(2/def)HELLO WORLD!"); - continue; - } - printf("(after_switch)HELLO WORLD!"); +int m1() { + int value = 0; + while (value < 10) { + switch (value) { + int x = 1; + printf("(out)HELLO WORLD!"); + x = value + 1; + case 0: + printf("(0)HELLO WORLD!"); + break; + case 1: + printf("(1)HELLO WORLD!"); + continue; + case 2: + default: + printf("(2/def)HELLO WORLD!"); + continue; } - return 0; + printf("(after_switch)HELLO WORLD!"); + } + return 0; } - -int m2 () -{ - int value = 0; - switch (value) - { - int x = 1; - printf("(out)HELLO WORLD!"); - x = value + 1; - case 0: - printf("(0)HELLO WORLD!"); - break; - int z = 9; - default: - - case 1: { - int something = 1; - something++; - } - z = 42; - break; - case 2: - case 3: {} +int m2() { + int value = 0; + switch (value) { + int x = 1; + printf("(out)HELLO WORLD!"); + x = value + 1; + case 0: + printf("(0)HELLO WORLD!"); + break; + int z = 9; + default: + + case 1: { + int something = 1; + something++; } - return 0; -} - - -int m3 () -{ - int value = 0; - switch (value) - { - case 0: - printf("(0)HELLO WORLD!"); - break; - case 1: { - int something = 1; - something++; - } - break; - int z = 9; - case 2: - case 3: {} + z = 42; + break; + case 2: + case 3: { } - return 0; + } + return 0; } - -int m4 () -{ - int value = 0; - switch (value) - { - int x = 1; - printf("(out)HELLO WORLD!"); - x = value + 1; - case 0: - printf("(0)HELLO WORLD!"); - break; - int z = 9; - default: - - case 1: { - int something = 1; - something++; - } - z = 42; - break; - case 2: - case 3: {} +int m3() { + int value = 0; + switch (value) { + case 0: + printf("(0)HELLO WORLD!"); + break; + case 1: { + int something = 1; + something++; + } break; + int z = 9; + case 2: + case 3: { } - return 0; + } + return 0; } - -int m5 () -{ - int value = 0; - while (value < 10) { - switch (value) { - int x = 1; - printf("(out)HELLO WORLD!"); - x = value + 1; - continue; - case 0: - printf("(0)HELLO WORLD!"); - break; - } +int m4() { + int value = 0; + switch (value) { + int x = 1; + printf("(out)HELLO WORLD!"); + x = value + 1; + case 0: + printf("(0)HELLO WORLD!"); + break; + int z = 9; + default: + + case 1: { + int something = 1; + something++; } - return 0; + z = 42; + break; + case 2: + case 3: { + } + } + return 0; } - -int m6 () -{ - int value = 0; - switch (value > 0 ? 1 : 0) - { - case 0: - printf("(0)HELLO WORLD!"); - break; - case 1: { - int something = 1; - something++; - } - break; - int z = 9; - case 2: - case 3: {} +int m5() { + int value = 0; + while (value < 10) { + switch (value) { + int x = 1; + printf("(out)HELLO WORLD!"); + x = value + 1; + continue; + case 0: + printf("(0)HELLO WORLD!"); + break; } - return 0; + } + return 0; } - -int getValue () -{ - return 1; +int m6() { + int value = 0; + switch (value > 0 ? 1 : 0) { + case 0: + printf("(0)HELLO WORLD!"); + break; + case 1: { + int something = 1; + something++; + } break; + int z = 9; + case 2: + case 3: { + } + } + return 0; } -int m7 () -{ - int value = 0; - switch (getValue()) - { - case 0: - printf("(0)HELLO WORLD!"); - break; - case 1: { - int something = 1; - something++; - } - break; - int z = 9; - case 2: - case 3: {} +int getValue() { return 1; } + +int m7() { + int value = 0; + switch (getValue()) { + case 0: + printf("(0)HELLO WORLD!"); + break; + case 1: { + int something = 1; + something++; + } break; + int z = 9; + case 2: + case 3: { } - return 0; + } + return 0; } -int m8 () -{ - int value = 0; - while (value < 10) - { - switch (getValue() == 0 ? 1 : 2) - { - case 0: - printf("(0)HELLO WORLD!"); - return 0; - case 1: - { - int something = 1; - something++; - continue; - } - break; - int z = 9; - case 2: - case 3: {} - } - int a = 0; +int m8() { + int value = 0; + while (value < 10) { + switch (getValue() == 0 ? 1 : 2) { + case 0: + printf("(0)HELLO WORLD!"); + return 0; + case 1: { + int something = 1; + something++; + continue; + } break; + int z = 9; + case 2: + case 3: { + } } - return 0; + int a = 0; + } + return 0; } -int m9 () -{ - int value = 0; - switch (value) - { - } - return 0; +int m9() { + int value = 0; + switch (value) {} + return 0; } -int m10 () -{ - int value = 0; - switch (value = 7) - { - } - return 0; +int m10() { + int value = 0; + switch (value = 7) {} + return 0; } -int m11 () -{ - int value = 0; - switch (value = (value == 0 ? 7 : 9)) - { - case 0: - printf("(0)HELLO WORLD!"); - } - return 0; +int m11() { + int value = 0; + switch (value = (value == 0 ? 7 : 9)) { + case 0: + printf("(0)HELLO WORLD!"); + } + return 0; } diff --git a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot index 7976ed27d..549491dd8 100644 --- a/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot +++ b/infer/tests/codetoanalyze/c/frontend/switchstmt/switch.c.dot @@ -1,42 +1,42 @@ digraph iCFG { -195 [label="195: DeclStmt \n *&value:int =0 [line 222]\n " shape="box"] +195 [label="195: DeclStmt \n *&value:int =0 [line 192]\n " shape="box"] 195 -> 186 ; -194 [label="194: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 225]\n APPLY_ABSTRACTION; [line 225]\n " shape="invhouse"] +194 [label="194: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 194]\n APPLY_ABSTRACTION; [line 194]\n " shape="invhouse"] 194 -> 184 ; -193 [label="193: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 225]\n " shape="invhouse"] +193 [label="193: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 194]\n " shape="invhouse"] 193 -> 192 ; -192 [label="192: Call _fun_printf \n n$3=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 226]\n REMOVE_TEMPS(n$3); [line 226]\n APPLY_ABSTRACTION; [line 226]\n " shape="box"] +192 [label="192: Call _fun_printf \n n$3=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 195]\n REMOVE_TEMPS(n$3); [line 195]\n APPLY_ABSTRACTION; [line 195]\n " shape="box"] 192 -> 184 ; -191 [label="191: Switch_stmt \n n$1=*&SIL_temp_conditional___185:int [line 223]\n NULLIFY(&SIL_temp_conditional___185,true); [line 223]\n *&value:int =n$1 [line 223]\n n$2=*&value:int [line 223]\n NULLIFY(&value,false); [line 223]\n " shape="box"] +191 [label="191: Switch_stmt \n n$1=*&SIL_temp_conditional___185:int [line 193]\n NULLIFY(&SIL_temp_conditional___185,true); [line 193]\n *&value:int =n$1 [line 193]\n n$2=*&value:int [line 193]\n NULLIFY(&value,false); [line 193]\n " shape="box"] 191 -> 193 ; 191 -> 194 ; -190 [label="190: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___185); [line 223]\n *&SIL_temp_conditional___185:int =9 [line 223]\n APPLY_ABSTRACTION; [line 223]\n " shape="box"] +190 [label="190: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___185); [line 193]\n *&SIL_temp_conditional___185:int =9 [line 193]\n APPLY_ABSTRACTION; [line 193]\n " shape="box"] 190 -> 185 ; -189 [label="189: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___185); [line 223]\n *&SIL_temp_conditional___185:int =7 [line 223]\n APPLY_ABSTRACTION; [line 223]\n " shape="box"] +189 [label="189: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___185); [line 193]\n *&SIL_temp_conditional___185:int =7 [line 193]\n APPLY_ABSTRACTION; [line 193]\n " shape="box"] 189 -> 185 ; -188 [label="188: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 223]\n REMOVE_TEMPS(n$0); [line 223]\n " shape="invhouse"] +188 [label="188: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 193]\n REMOVE_TEMPS(n$0); [line 193]\n " shape="invhouse"] 188 -> 190 ; -187 [label="187: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 223]\n REMOVE_TEMPS(n$0); [line 223]\n " shape="invhouse"] +187 [label="187: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 193]\n REMOVE_TEMPS(n$0); [line 193]\n " shape="invhouse"] 187 -> 189 ; -186 [label="186: BinaryOperatorStmt: EQ \n n$0=*&value:int [line 223]\n NULLIFY(&value,false); [line 223]\n " shape="box"] +186 [label="186: BinaryOperatorStmt: EQ \n n$0=*&value:int [line 193]\n NULLIFY(&value,false); [line 193]\n " shape="box"] 186 -> 187 ; @@ -45,136 +45,136 @@ digraph iCFG { 185 -> 191 ; -184 [label="184: Return Stmt \n *&return:int =0 [line 228]\n REMOVE_TEMPS(n$1,n$2); [line 228]\n APPLY_ABSTRACTION; [line 228]\n " shape="box"] +184 [label="184: Return Stmt \n *&return:int =0 [line 197]\n REMOVE_TEMPS(n$1,n$2); [line 197]\n APPLY_ABSTRACTION; [line 197]\n " shape="box"] 184 -> 183 ; 183 [label="183: Exit m11 \n " color=yellow style=filled] -182 [label="182: Start m11\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 220]\n NULLIFY(&value,false); [line 220]\n " color=yellow style=filled] +182 [label="182: Start m11\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 191]\n NULLIFY(&value,false); [line 191]\n " color=yellow style=filled] 182 -> 195 ; -181 [label="181: DeclStmt \n *&value:int =0 [line 213]\n NULLIFY(&value,false); [line 213]\n " shape="box"] +181 [label="181: DeclStmt \n *&value:int =0 [line 186]\n NULLIFY(&value,false); [line 186]\n " shape="box"] 181 -> 180 ; -180 [label="180: Switch_stmt \n *&value:int =7 [line 214]\n n$0=*&value:int [line 214]\n NULLIFY(&value,false); [line 214]\n " shape="box"] +180 [label="180: Switch_stmt \n *&value:int =7 [line 187]\n n$0=*&value:int [line 187]\n NULLIFY(&value,false); [line 187]\n " shape="box"] 180 -> 179 ; -179 [label="179: Return Stmt \n *&return:int =0 [line 217]\n REMOVE_TEMPS(n$0); [line 217]\n APPLY_ABSTRACTION; [line 217]\n " shape="box"] +179 [label="179: Return Stmt \n *&return:int =0 [line 188]\n REMOVE_TEMPS(n$0); [line 188]\n APPLY_ABSTRACTION; [line 188]\n " shape="box"] 179 -> 178 ; 178 [label="178: Exit m10 \n " color=yellow style=filled] -177 [label="177: Start m10\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 211]\n NULLIFY(&value,false); [line 211]\n " color=yellow style=filled] +177 [label="177: Start m10\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 185]\n NULLIFY(&value,false); [line 185]\n " color=yellow style=filled] 177 -> 181 ; -176 [label="176: DeclStmt \n *&value:int =0 [line 204]\n " shape="box"] +176 [label="176: DeclStmt \n *&value:int =0 [line 180]\n " shape="box"] 176 -> 175 ; -175 [label="175: Switch_stmt \n n$0=*&value:int [line 205]\n NULLIFY(&value,false); [line 205]\n " shape="box"] +175 [label="175: Switch_stmt \n n$0=*&value:int [line 181]\n NULLIFY(&value,false); [line 181]\n " shape="box"] 175 -> 174 ; -174 [label="174: Return Stmt \n *&return:int =0 [line 208]\n REMOVE_TEMPS(n$0); [line 208]\n APPLY_ABSTRACTION; [line 208]\n " shape="box"] +174 [label="174: Return Stmt \n *&return:int =0 [line 182]\n REMOVE_TEMPS(n$0); [line 182]\n APPLY_ABSTRACTION; [line 182]\n " shape="box"] 174 -> 173 ; 173 [label="173: Exit m9 \n " color=yellow style=filled] -172 [label="172: Start m9\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 202]\n NULLIFY(&value,false); [line 202]\n " color=yellow style=filled] +172 [label="172: Start m9\nFormals: \nLocals: value:int \n DECLARE_LOCALS(&return,&value); [line 179]\n NULLIFY(&value,false); [line 179]\n " color=yellow style=filled] 172 -> 176 ; -171 [label="171: DeclStmt \n *&value:int =0 [line 178]\n APPLY_ABSTRACTION; [line 178]\n " shape="box"] +171 [label="171: DeclStmt \n *&value:int =0 [line 158]\n APPLY_ABSTRACTION; [line 158]\n " shape="box"] 171 -> 146 ; -170 [label="170: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 183]\n " shape="invhouse"] +170 [label="170: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 161]\n " shape="invhouse"] 170 -> 165 ; 170 -> 166 ; -169 [label="169: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 183]\n " shape="invhouse"] +169 [label="169: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 161]\n " shape="invhouse"] 169 -> 168 ; -168 [label="168: Call _fun_printf \n NULLIFY(&value,false); [line 184]\n n$4=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 184]\n REMOVE_TEMPS(n$4); [line 184]\n " shape="box"] +168 [label="168: Call _fun_printf \n NULLIFY(&value,false); [line 162]\n n$4=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 162]\n REMOVE_TEMPS(n$4); [line 162]\n " shape="box"] 168 -> 167 ; -167 [label="167: Return Stmt \n *&return:int =0 [line 185]\n APPLY_ABSTRACTION; [line 185]\n " shape="box"] +167 [label="167: Return Stmt \n *&return:int =0 [line 163]\n APPLY_ABSTRACTION; [line 163]\n " shape="box"] 167 -> 144 ; -166 [label="166: Prune (false branch) \n PRUNE(((n$2 == 1) == 0), false); [line 186]\n " shape="invhouse"] +166 [label="166: Prune (false branch) \n PRUNE(((n$2 == 1) == 0), false); [line 164]\n " shape="invhouse"] 166 -> 160 ; 166 -> 161 ; -165 [label="165: Prune (true branch) \n PRUNE(((n$2 == 1) != 0), true); [line 186]\n " shape="invhouse"] +165 [label="165: Prune (true branch) \n PRUNE(((n$2 == 1) != 0), true); [line 164]\n " shape="invhouse"] 165 -> 164 ; -164 [label="164: DeclStmt \n *&something:int =1 [line 188]\n " shape="box"] +164 [label="164: DeclStmt \n *&something:int =1 [line 165]\n " shape="box"] 164 -> 163 ; -163 [label="163: UnaryOperator \n n$3=*&something:int [line 189]\n *&something:int =(n$3 + 1) [line 189]\n REMOVE_TEMPS(n$3); [line 189]\n NULLIFY(&something,false); [line 189]\n APPLY_ABSTRACTION; [line 189]\n " shape="box"] +163 [label="163: UnaryOperator \n n$3=*&something:int [line 166]\n *&something:int =(n$3 + 1) [line 166]\n REMOVE_TEMPS(n$3); [line 166]\n NULLIFY(&something,false); [line 166]\n APPLY_ABSTRACTION; [line 166]\n " shape="box"] 163 -> 146 ; -162 [label="162: DeclStmt \n *&z:int =9 [line 193]\n NULLIFY(&a,false); [line 193]\n NULLIFY(&something,false); [line 193]\n NULLIFY(&z,false); [line 193]\n APPLY_ABSTRACTION; [line 193]\n " shape="box"] +162 [label="162: DeclStmt \n *&z:int =9 [line 169]\n NULLIFY(&a,false); [line 169]\n NULLIFY(&something,false); [line 169]\n NULLIFY(&z,false); [line 169]\n APPLY_ABSTRACTION; [line 169]\n " shape="box"] 162 -> 150 ; -161 [label="161: Prune (false branch) \n PRUNE(((n$2 == 2) == 0), false); [line 194]\n " shape="invhouse"] +161 [label="161: Prune (false branch) \n PRUNE(((n$2 == 2) == 0), false); [line 170]\n " shape="invhouse"] 161 -> 158 ; 161 -> 159 ; -160 [label="160: Prune (true branch) \n PRUNE(((n$2 == 2) != 0), true); [line 194]\n APPLY_ABSTRACTION; [line 194]\n " shape="invhouse"] +160 [label="160: Prune (true branch) \n PRUNE(((n$2 == 2) != 0), true); [line 170]\n APPLY_ABSTRACTION; [line 170]\n " shape="invhouse"] 160 -> 150 ; -159 [label="159: Prune (false branch) \n PRUNE(((n$2 == 3) == 0), false); [line 195]\n APPLY_ABSTRACTION; [line 195]\n " shape="invhouse"] +159 [label="159: Prune (false branch) \n PRUNE(((n$2 == 3) == 0), false); [line 171]\n APPLY_ABSTRACTION; [line 171]\n " shape="invhouse"] 159 -> 150 ; -158 [label="158: Prune (true branch) \n PRUNE(((n$2 == 3) != 0), true); [line 195]\n APPLY_ABSTRACTION; [line 195]\n " shape="invhouse"] +158 [label="158: Prune (true branch) \n PRUNE(((n$2 == 3) != 0), true); [line 171]\n APPLY_ABSTRACTION; [line 171]\n " shape="invhouse"] 158 -> 150 ; -157 [label="157: Switch_stmt \n n$2=*&SIL_temp_conditional___151:int [line 181]\n NULLIFY(&SIL_temp_conditional___151,true); [line 181]\n " shape="box"] +157 [label="157: Switch_stmt \n n$2=*&SIL_temp_conditional___151:int [line 160]\n NULLIFY(&SIL_temp_conditional___151,true); [line 160]\n " shape="box"] 157 -> 169 ; 157 -> 170 ; -156 [label="156: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 181]\n *&SIL_temp_conditional___151:int =2 [line 181]\n APPLY_ABSTRACTION; [line 181]\n " shape="box"] +156 [label="156: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 160]\n *&SIL_temp_conditional___151:int =2 [line 160]\n APPLY_ABSTRACTION; [line 160]\n " shape="box"] 156 -> 151 ; -155 [label="155: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 181]\n *&SIL_temp_conditional___151:int =1 [line 181]\n APPLY_ABSTRACTION; [line 181]\n " shape="box"] +155 [label="155: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___151); [line 160]\n *&SIL_temp_conditional___151:int =1 [line 160]\n APPLY_ABSTRACTION; [line 160]\n " shape="box"] 155 -> 151 ; -154 [label="154: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 181]\n REMOVE_TEMPS(n$1); [line 181]\n " shape="invhouse"] +154 [label="154: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 160]\n REMOVE_TEMPS(n$1); [line 160]\n " shape="invhouse"] 154 -> 156 ; -153 [label="153: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 181]\n REMOVE_TEMPS(n$1); [line 181]\n " shape="invhouse"] +153 [label="153: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 160]\n REMOVE_TEMPS(n$1); [line 160]\n " shape="invhouse"] 153 -> 155 ; -152 [label="152: BinaryOperatorStmt: EQ \n n$1=_fun_getValue() [line 181]\n " shape="box"] +152 [label="152: BinaryOperatorStmt: EQ \n n$1=_fun_getValue() [line 160]\n " shape="box"] 152 -> 153 ; @@ -183,19 +183,19 @@ digraph iCFG { 151 -> 157 ; -150 [label="150: DeclStmt \n *&a:int =0 [line 197]\n REMOVE_TEMPS(n$2); [line 197]\n NULLIFY(&a,false); [line 197]\n APPLY_ABSTRACTION; [line 197]\n " shape="box"] +150 [label="150: DeclStmt \n *&a:int =0 [line 174]\n REMOVE_TEMPS(n$2); [line 174]\n NULLIFY(&a,false); [line 174]\n APPLY_ABSTRACTION; [line 174]\n " shape="box"] 150 -> 146 ; -149 [label="149: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 179]\n REMOVE_TEMPS(n$0); [line 179]\n " shape="invhouse"] +149 [label="149: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 159]\n REMOVE_TEMPS(n$0); [line 159]\n " shape="invhouse"] 149 -> 145 ; -148 [label="148: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 179]\n REMOVE_TEMPS(n$0); [line 179]\n " shape="invhouse"] +148 [label="148: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 159]\n REMOVE_TEMPS(n$0); [line 159]\n " shape="invhouse"] 148 -> 152 ; -147 [label="147: BinaryOperatorStmt: LT \n n$0=*&value:int [line 179]\n " shape="box"] +147 [label="147: BinaryOperatorStmt: LT \n n$0=*&value:int [line 159]\n " shape="box"] 147 -> 148 ; @@ -204,176 +204,176 @@ digraph iCFG { 146 -> 147 ; -145 [label="145: Return Stmt \n NULLIFY(&value,false); [line 199]\n *&return:int =0 [line 199]\n APPLY_ABSTRACTION; [line 199]\n " shape="box"] +145 [label="145: Return Stmt \n NULLIFY(&value,false); [line 176]\n *&return:int =0 [line 176]\n APPLY_ABSTRACTION; [line 176]\n " shape="box"] 145 -> 144 ; 144 [label="144: Exit m8 \n " color=yellow style=filled] -143 [label="143: Start m8\nFormals: \nLocals: a:int z:int something:int value:int \n DECLARE_LOCALS(&return,&a,&z,&something,&value); [line 176]\n NULLIFY(&a,false); [line 176]\n NULLIFY(&something,false); [line 176]\n NULLIFY(&value,false); [line 176]\n NULLIFY(&z,false); [line 176]\n " color=yellow style=filled] +143 [label="143: Start m8\nFormals: \nLocals: a:int z:int something:int value:int \n DECLARE_LOCALS(&return,&a,&z,&something,&value); [line 157]\n NULLIFY(&a,false); [line 157]\n NULLIFY(&something,false); [line 157]\n NULLIFY(&value,false); [line 157]\n NULLIFY(&z,false); [line 157]\n " color=yellow style=filled] 143 -> 171 ; -142 [label="142: DeclStmt \n *&value:int =0 [line 158]\n NULLIFY(&value,false); [line 158]\n " shape="box"] +142 [label="142: DeclStmt \n *&value:int =0 [line 140]\n NULLIFY(&value,false); [line 140]\n " shape="box"] 142 -> 129 ; -141 [label="141: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 161]\n " shape="invhouse"] +141 [label="141: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 142]\n " shape="invhouse"] 141 -> 137 ; 141 -> 138 ; -140 [label="140: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 161]\n " shape="invhouse"] +140 [label="140: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 142]\n " shape="invhouse"] 140 -> 139 ; -139 [label="139: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 162]\n REMOVE_TEMPS(n$2); [line 162]\n APPLY_ABSTRACTION; [line 162]\n " shape="box"] +139 [label="139: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 143]\n REMOVE_TEMPS(n$2); [line 143]\n APPLY_ABSTRACTION; [line 143]\n " shape="box"] 139 -> 128 ; -138 [label="138: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 164]\n " shape="invhouse"] +138 [label="138: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 145]\n " shape="invhouse"] 138 -> 132 ; 138 -> 133 ; -137 [label="137: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 164]\n " shape="invhouse"] +137 [label="137: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 145]\n " shape="invhouse"] 137 -> 136 ; -136 [label="136: DeclStmt \n *&something:int =1 [line 165]\n " shape="box"] +136 [label="136: DeclStmt \n *&something:int =1 [line 146]\n " shape="box"] 136 -> 135 ; -135 [label="135: UnaryOperator \n n$1=*&something:int [line 166]\n *&something:int =(n$1 + 1) [line 166]\n REMOVE_TEMPS(n$1); [line 166]\n NULLIFY(&something,false); [line 166]\n APPLY_ABSTRACTION; [line 166]\n " shape="box"] +135 [label="135: UnaryOperator \n n$1=*&something:int [line 147]\n *&something:int =(n$1 + 1) [line 147]\n REMOVE_TEMPS(n$1); [line 147]\n NULLIFY(&something,false); [line 147]\n APPLY_ABSTRACTION; [line 147]\n " shape="box"] 135 -> 128 ; -134 [label="134: DeclStmt \n *&z:int =9 [line 169]\n NULLIFY(&something,false); [line 169]\n NULLIFY(&value,false); [line 169]\n NULLIFY(&z,false); [line 169]\n APPLY_ABSTRACTION; [line 169]\n " shape="box"] +134 [label="134: DeclStmt \n *&z:int =9 [line 149]\n NULLIFY(&something,false); [line 149]\n NULLIFY(&value,false); [line 149]\n NULLIFY(&z,false); [line 149]\n APPLY_ABSTRACTION; [line 149]\n " shape="box"] 134 -> 128 ; -133 [label="133: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 170]\n " shape="invhouse"] +133 [label="133: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 150]\n " shape="invhouse"] 133 -> 130 ; 133 -> 131 ; -132 [label="132: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 170]\n APPLY_ABSTRACTION; [line 170]\n " shape="invhouse"] +132 [label="132: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 150]\n APPLY_ABSTRACTION; [line 150]\n " shape="invhouse"] 132 -> 128 ; -131 [label="131: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 171]\n APPLY_ABSTRACTION; [line 171]\n " shape="invhouse"] +131 [label="131: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 151]\n APPLY_ABSTRACTION; [line 151]\n " shape="invhouse"] 131 -> 128 ; -130 [label="130: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 171]\n APPLY_ABSTRACTION; [line 171]\n " shape="invhouse"] +130 [label="130: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 151]\n APPLY_ABSTRACTION; [line 151]\n " shape="invhouse"] 130 -> 128 ; -129 [label="129: Switch_stmt \n n$0=_fun_getValue() [line 159]\n " shape="box"] +129 [label="129: Switch_stmt \n n$0=_fun_getValue() [line 141]\n " shape="box"] 129 -> 140 ; 129 -> 141 ; -128 [label="128: Return Stmt \n *&return:int =0 [line 173]\n REMOVE_TEMPS(n$0); [line 173]\n APPLY_ABSTRACTION; [line 173]\n " shape="box"] +128 [label="128: Return Stmt \n *&return:int =0 [line 154]\n REMOVE_TEMPS(n$0); [line 154]\n APPLY_ABSTRACTION; [line 154]\n " shape="box"] 128 -> 127 ; 127 [label="127: Exit m7 \n " color=yellow style=filled] -126 [label="126: Start m7\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 156]\n NULLIFY(&something,false); [line 156]\n NULLIFY(&value,false); [line 156]\n NULLIFY(&z,false); [line 156]\n " color=yellow style=filled] +126 [label="126: Start m7\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 139]\n NULLIFY(&something,false); [line 139]\n NULLIFY(&value,false); [line 139]\n NULLIFY(&z,false); [line 139]\n " color=yellow style=filled] 126 -> 142 ; -125 [label="125: Return Stmt \n *&return:int =1 [line 153]\n APPLY_ABSTRACTION; [line 153]\n " shape="box"] +125 [label="125: Return Stmt \n *&return:int =1 [line 137]\n APPLY_ABSTRACTION; [line 137]\n " shape="box"] 125 -> 124 ; 124 [label="124: Exit getValue \n " color=yellow style=filled] -123 [label="123: Start getValue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 151]\n " color=yellow style=filled] +123 [label="123: Start getValue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 137]\n " color=yellow style=filled] 123 -> 125 ; -122 [label="122: DeclStmt \n *&value:int =0 [line 132]\n " shape="box"] +122 [label="122: DeclStmt \n *&value:int =0 [line 120]\n " shape="box"] 122 -> 104 ; -121 [label="121: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 135]\n " shape="invhouse"] +121 [label="121: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 122]\n " shape="invhouse"] 121 -> 117 ; 121 -> 118 ; -120 [label="120: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 135]\n " shape="invhouse"] +120 [label="120: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 122]\n " shape="invhouse"] 120 -> 119 ; -119 [label="119: Call _fun_printf \n n$3=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 136]\n REMOVE_TEMPS(n$3); [line 136]\n APPLY_ABSTRACTION; [line 136]\n " shape="box"] +119 [label="119: Call _fun_printf \n n$3=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 123]\n REMOVE_TEMPS(n$3); [line 123]\n APPLY_ABSTRACTION; [line 123]\n " shape="box"] 119 -> 102 ; -118 [label="118: Prune (false branch) \n PRUNE(((n$1 == 1) == 0), false); [line 138]\n " shape="invhouse"] +118 [label="118: Prune (false branch) \n PRUNE(((n$1 == 1) == 0), false); [line 125]\n " shape="invhouse"] 118 -> 112 ; 118 -> 113 ; -117 [label="117: Prune (true branch) \n PRUNE(((n$1 == 1) != 0), true); [line 138]\n " shape="invhouse"] +117 [label="117: Prune (true branch) \n PRUNE(((n$1 == 1) != 0), true); [line 125]\n " shape="invhouse"] 117 -> 116 ; -116 [label="116: DeclStmt \n *&something:int =1 [line 139]\n " shape="box"] +116 [label="116: DeclStmt \n *&something:int =1 [line 126]\n " shape="box"] 116 -> 115 ; -115 [label="115: UnaryOperator \n n$2=*&something:int [line 140]\n *&something:int =(n$2 + 1) [line 140]\n REMOVE_TEMPS(n$2); [line 140]\n NULLIFY(&something,false); [line 140]\n APPLY_ABSTRACTION; [line 140]\n " shape="box"] +115 [label="115: UnaryOperator \n n$2=*&something:int [line 127]\n *&something:int =(n$2 + 1) [line 127]\n REMOVE_TEMPS(n$2); [line 127]\n NULLIFY(&something,false); [line 127]\n APPLY_ABSTRACTION; [line 127]\n " shape="box"] 115 -> 102 ; -114 [label="114: DeclStmt \n *&z:int =9 [line 143]\n NULLIFY(&something,false); [line 143]\n NULLIFY(&value,false); [line 143]\n NULLIFY(&z,false); [line 143]\n APPLY_ABSTRACTION; [line 143]\n " shape="box"] +114 [label="114: DeclStmt \n *&z:int =9 [line 129]\n NULLIFY(&something,false); [line 129]\n NULLIFY(&value,false); [line 129]\n NULLIFY(&z,false); [line 129]\n APPLY_ABSTRACTION; [line 129]\n " shape="box"] 114 -> 102 ; -113 [label="113: Prune (false branch) \n PRUNE(((n$1 == 2) == 0), false); [line 144]\n " shape="invhouse"] +113 [label="113: Prune (false branch) \n PRUNE(((n$1 == 2) == 0), false); [line 130]\n " shape="invhouse"] 113 -> 110 ; 113 -> 111 ; -112 [label="112: Prune (true branch) \n PRUNE(((n$1 == 2) != 0), true); [line 144]\n APPLY_ABSTRACTION; [line 144]\n " shape="invhouse"] +112 [label="112: Prune (true branch) \n PRUNE(((n$1 == 2) != 0), true); [line 130]\n APPLY_ABSTRACTION; [line 130]\n " shape="invhouse"] 112 -> 102 ; -111 [label="111: Prune (false branch) \n PRUNE(((n$1 == 3) == 0), false); [line 145]\n APPLY_ABSTRACTION; [line 145]\n " shape="invhouse"] +111 [label="111: Prune (false branch) \n PRUNE(((n$1 == 3) == 0), false); [line 131]\n APPLY_ABSTRACTION; [line 131]\n " shape="invhouse"] 111 -> 102 ; -110 [label="110: Prune (true branch) \n PRUNE(((n$1 == 3) != 0), true); [line 145]\n APPLY_ABSTRACTION; [line 145]\n " shape="invhouse"] +110 [label="110: Prune (true branch) \n PRUNE(((n$1 == 3) != 0), true); [line 131]\n APPLY_ABSTRACTION; [line 131]\n " shape="invhouse"] 110 -> 102 ; -109 [label="109: Switch_stmt \n n$1=*&SIL_temp_conditional___103:int [line 133]\n NULLIFY(&SIL_temp_conditional___103,true); [line 133]\n " shape="box"] +109 [label="109: Switch_stmt \n n$1=*&SIL_temp_conditional___103:int [line 121]\n NULLIFY(&SIL_temp_conditional___103,true); [line 121]\n " shape="box"] 109 -> 120 ; 109 -> 121 ; -108 [label="108: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___103); [line 133]\n *&SIL_temp_conditional___103:int =0 [line 133]\n APPLY_ABSTRACTION; [line 133]\n " shape="box"] +108 [label="108: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___103); [line 121]\n *&SIL_temp_conditional___103:int =0 [line 121]\n APPLY_ABSTRACTION; [line 121]\n " shape="box"] 108 -> 103 ; -107 [label="107: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___103); [line 133]\n *&SIL_temp_conditional___103:int =1 [line 133]\n APPLY_ABSTRACTION; [line 133]\n " shape="box"] +107 [label="107: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___103); [line 121]\n *&SIL_temp_conditional___103:int =1 [line 121]\n APPLY_ABSTRACTION; [line 121]\n " shape="box"] 107 -> 103 ; -106 [label="106: Prune (false branch) \n PRUNE(((n$0 > 0) == 0), false); [line 133]\n REMOVE_TEMPS(n$0); [line 133]\n " shape="invhouse"] +106 [label="106: Prune (false branch) \n PRUNE(((n$0 > 0) == 0), false); [line 121]\n REMOVE_TEMPS(n$0); [line 121]\n " shape="invhouse"] 106 -> 108 ; -105 [label="105: Prune (true branch) \n PRUNE(((n$0 > 0) != 0), true); [line 133]\n REMOVE_TEMPS(n$0); [line 133]\n " shape="invhouse"] +105 [label="105: Prune (true branch) \n PRUNE(((n$0 > 0) != 0), true); [line 121]\n REMOVE_TEMPS(n$0); [line 121]\n " shape="invhouse"] 105 -> 107 ; -104 [label="104: BinaryOperatorStmt: GT \n n$0=*&value:int [line 133]\n NULLIFY(&value,false); [line 133]\n " shape="box"] +104 [label="104: BinaryOperatorStmt: GT \n n$0=*&value:int [line 121]\n NULLIFY(&value,false); [line 121]\n " shape="box"] 104 -> 105 ; @@ -382,407 +382,407 @@ digraph iCFG { 103 -> 109 ; -102 [label="102: Return Stmt \n *&return:int =0 [line 147]\n REMOVE_TEMPS(n$1); [line 147]\n APPLY_ABSTRACTION; [line 147]\n " shape="box"] +102 [label="102: Return Stmt \n *&return:int =0 [line 134]\n REMOVE_TEMPS(n$1); [line 134]\n APPLY_ABSTRACTION; [line 134]\n " shape="box"] 102 -> 101 ; 101 [label="101: Exit m6 \n " color=yellow style=filled] -100 [label="100: Start m6\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 130]\n NULLIFY(&something,false); [line 130]\n NULLIFY(&value,false); [line 130]\n NULLIFY(&z,false); [line 130]\n " color=yellow style=filled] +100 [label="100: Start m6\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 119]\n NULLIFY(&something,false); [line 119]\n NULLIFY(&value,false); [line 119]\n NULLIFY(&z,false); [line 119]\n " color=yellow style=filled] 100 -> 122 ; -99 [label="99: DeclStmt \n *&value:int =0 [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="box"] +99 [label="99: DeclStmt \n *&value:int =0 [line 104]\n APPLY_ABSTRACTION; [line 104]\n " shape="box"] 99 -> 88 ; -98 [label="98: DeclStmt \n *&x:int =1 [line 117]\n NULLIFY(&x,false); [line 117]\n " shape="box"] +98 [label="98: DeclStmt \n *&x:int =1 [line 107]\n NULLIFY(&x,false); [line 107]\n " shape="box"] 98 -> 97 ; -97 [label="97: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 118]\n REMOVE_TEMPS(n$4); [line 118]\n " shape="box"] +97 [label="97: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 108]\n REMOVE_TEMPS(n$4); [line 108]\n " shape="box"] 97 -> 96 ; -96 [label="96: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 119]\n *&x:int =(n$3 + 1) [line 119]\n REMOVE_TEMPS(n$3); [line 119]\n NULLIFY(&x,false); [line 119]\n APPLY_ABSTRACTION; [line 119]\n " shape="box"] +96 [label="96: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 109]\n *&x:int =(n$3 + 1) [line 109]\n REMOVE_TEMPS(n$3); [line 109]\n NULLIFY(&x,false); [line 109]\n APPLY_ABSTRACTION; [line 109]\n " shape="box"] 96 -> 88 ; -95 [label="95: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 121]\n APPLY_ABSTRACTION; [line 121]\n " shape="invhouse"] +95 [label="95: Prune (false branch) \n PRUNE(((n$1 == 0) == 0), false); [line 111]\n APPLY_ABSTRACTION; [line 111]\n " shape="invhouse"] 95 -> 88 ; -94 [label="94: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 121]\n " shape="invhouse"] +94 [label="94: Prune (true branch) \n PRUNE(((n$1 == 0) != 0), true); [line 111]\n " shape="invhouse"] 94 -> 93 ; -93 [label="93: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 122]\n REMOVE_TEMPS(n$2); [line 122]\n APPLY_ABSTRACTION; [line 122]\n " shape="box"] +93 [label="93: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 112]\n REMOVE_TEMPS(n$2); [line 112]\n APPLY_ABSTRACTION; [line 112]\n " shape="box"] 93 -> 88 ; -92 [label="92: Switch_stmt \n n$1=*&value:int [line 116]\n " shape="box"] +92 [label="92: Switch_stmt \n n$1=*&value:int [line 106]\n " shape="box"] 92 -> 94 ; 92 -> 95 ; -91 [label="91: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 115]\n REMOVE_TEMPS(n$0); [line 115]\n " shape="invhouse"] +91 [label="91: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 105]\n REMOVE_TEMPS(n$0); [line 105]\n " shape="invhouse"] 91 -> 87 ; -90 [label="90: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 115]\n REMOVE_TEMPS(n$0); [line 115]\n " shape="invhouse"] +90 [label="90: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 105]\n REMOVE_TEMPS(n$0); [line 105]\n " shape="invhouse"] 90 -> 92 ; -89 [label="89: BinaryOperatorStmt: LT \n n$0=*&value:int [line 115]\n " shape="box"] +89 [label="89: BinaryOperatorStmt: LT \n n$0=*&value:int [line 105]\n " shape="box"] 89 -> 90 ; 89 -> 91 ; -88 [label="88: + \n REMOVE_TEMPS(n$1); [line 115]\n " ] +88 [label="88: + \n REMOVE_TEMPS(n$1); [line 105]\n " ] 88 -> 89 ; -87 [label="87: Return Stmt \n NULLIFY(&value,false); [line 126]\n *&return:int =0 [line 126]\n APPLY_ABSTRACTION; [line 126]\n " shape="box"] +87 [label="87: Return Stmt \n NULLIFY(&value,false); [line 116]\n *&return:int =0 [line 116]\n APPLY_ABSTRACTION; [line 116]\n " shape="box"] 87 -> 86 ; 86 [label="86: Exit m5 \n " color=yellow style=filled] -85 [label="85: Start m5\nFormals: \nLocals: x:int value:int \n DECLARE_LOCALS(&return,&x,&value); [line 112]\n NULLIFY(&value,false); [line 112]\n NULLIFY(&x,false); [line 112]\n " color=yellow style=filled] +85 [label="85: Start m5\nFormals: \nLocals: x:int value:int \n DECLARE_LOCALS(&return,&x,&value); [line 103]\n NULLIFY(&value,false); [line 103]\n NULLIFY(&x,false); [line 103]\n " color=yellow style=filled] 85 -> 99 ; -84 [label="84: DeclStmt \n *&value:int =0 [line 87]\n " shape="box"] +84 [label="84: DeclStmt \n *&value:int =0 [line 79]\n " shape="box"] 84 -> 66 ; -83 [label="83: DeclStmt \n *&x:int =1 [line 90]\n NULLIFY(&something,false); [line 90]\n NULLIFY(&x,false); [line 90]\n NULLIFY(&z,false); [line 90]\n " shape="box"] +83 [label="83: DeclStmt \n *&x:int =1 [line 81]\n NULLIFY(&something,false); [line 81]\n NULLIFY(&x,false); [line 81]\n NULLIFY(&z,false); [line 81]\n " shape="box"] 83 -> 82 ; -82 [label="82: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 91]\n REMOVE_TEMPS(n$4); [line 91]\n " shape="box"] +82 [label="82: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 82]\n REMOVE_TEMPS(n$4); [line 82]\n " shape="box"] 82 -> 81 ; -81 [label="81: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 92]\n *&x:int =(n$3 + 1) [line 92]\n REMOVE_TEMPS(n$3); [line 92]\n NULLIFY(&value,false); [line 92]\n NULLIFY(&x,false); [line 92]\n APPLY_ABSTRACTION; [line 92]\n " shape="box"] +81 [label="81: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 83]\n *&x:int =(n$3 + 1) [line 83]\n REMOVE_TEMPS(n$3); [line 83]\n NULLIFY(&value,false); [line 83]\n NULLIFY(&x,false); [line 83]\n APPLY_ABSTRACTION; [line 83]\n " shape="box"] 81 -> 78 ; -80 [label="80: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 93]\n " shape="invhouse"] +80 [label="80: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 84]\n " shape="invhouse"] 80 -> 75 ; 80 -> 76 ; -79 [label="79: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 93]\n APPLY_ABSTRACTION; [line 93]\n " shape="invhouse"] +79 [label="79: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 84]\n APPLY_ABSTRACTION; [line 84]\n " shape="invhouse"] 79 -> 78 ; -78 [label="78: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 94]\n REMOVE_TEMPS(n$2); [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="box"] +78 [label="78: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 85]\n REMOVE_TEMPS(n$2); [line 85]\n APPLY_ABSTRACTION; [line 85]\n " shape="box"] 78 -> 65 ; -77 [label="77: DeclStmt \n *&z:int =9 [line 96]\n NULLIFY(&something,false); [line 96]\n NULLIFY(&value,false); [line 96]\n NULLIFY(&x,false); [line 96]\n NULLIFY(&z,false); [line 96]\n APPLY_ABSTRACTION; [line 96]\n " shape="box"] +77 [label="77: DeclStmt \n *&z:int =9 [line 87]\n NULLIFY(&something,false); [line 87]\n NULLIFY(&value,false); [line 87]\n NULLIFY(&x,false); [line 87]\n NULLIFY(&z,false); [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 77 -> 74 ; -76 [label="76: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 99]\n " shape="invhouse"] +76 [label="76: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 90]\n " shape="invhouse"] 76 -> 70 ; 76 -> 71 ; -75 [label="75: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 99]\n APPLY_ABSTRACTION; [line 99]\n " shape="invhouse"] +75 [label="75: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 90]\n APPLY_ABSTRACTION; [line 90]\n " shape="invhouse"] 75 -> 74 ; -74 [label="74: DeclStmt \n *&something:int =1 [line 100]\n " shape="box"] +74 [label="74: DeclStmt \n *&something:int =1 [line 91]\n " shape="box"] 74 -> 73 ; -73 [label="73: UnaryOperator \n n$1=*&something:int [line 101]\n *&something:int =(n$1 + 1) [line 101]\n REMOVE_TEMPS(n$1); [line 101]\n NULLIFY(&something,false); [line 101]\n " shape="box"] +73 [label="73: UnaryOperator \n n$1=*&something:int [line 92]\n *&something:int =(n$1 + 1) [line 92]\n REMOVE_TEMPS(n$1); [line 92]\n NULLIFY(&something,false); [line 92]\n " shape="box"] 73 -> 72 ; -72 [label="72: BinaryOperatorStmt: Assign \n *&z:int =42 [line 103]\n NULLIFY(&z,false); [line 103]\n APPLY_ABSTRACTION; [line 103]\n " shape="box"] +72 [label="72: BinaryOperatorStmt: Assign \n *&z:int =42 [line 94]\n NULLIFY(&z,false); [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="box"] 72 -> 65 ; -71 [label="71: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 105]\n " shape="invhouse"] +71 [label="71: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 96]\n " shape="invhouse"] 71 -> 68 ; 71 -> 69 ; -70 [label="70: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 105]\n APPLY_ABSTRACTION; [line 105]\n " shape="invhouse"] +70 [label="70: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 96]\n APPLY_ABSTRACTION; [line 96]\n " shape="invhouse"] 70 -> 65 ; -69 [label="69: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 106]\n " shape="invhouse"] +69 [label="69: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 97]\n " shape="invhouse"] 69 -> 67 ; -68 [label="68: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 106]\n APPLY_ABSTRACTION; [line 106]\n " shape="invhouse"] +68 [label="68: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 97]\n APPLY_ABSTRACTION; [line 97]\n " shape="invhouse"] 68 -> 65 ; -67 [label="67: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 97]\n " shape="box"] +67 [label="67: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 88]\n " shape="box"] 67 -> 74 ; -66 [label="66: Switch_stmt \n n$0=*&value:int [line 88]\n NULLIFY(&value,false); [line 88]\n " shape="box"] +66 [label="66: Switch_stmt \n n$0=*&value:int [line 80]\n NULLIFY(&value,false); [line 80]\n " shape="box"] 66 -> 79 ; 66 -> 80 ; -65 [label="65: Return Stmt \n *&return:int =0 [line 108]\n REMOVE_TEMPS(n$0); [line 108]\n APPLY_ABSTRACTION; [line 108]\n " shape="box"] +65 [label="65: Return Stmt \n *&return:int =0 [line 100]\n REMOVE_TEMPS(n$0); [line 100]\n APPLY_ABSTRACTION; [line 100]\n " shape="box"] 65 -> 64 ; 64 [label="64: Exit m4 \n " color=yellow style=filled] -63 [label="63: Start m4\nFormals: \nLocals: something:int z:int x:int value:int \n DECLARE_LOCALS(&return,&something,&z,&x,&value); [line 85]\n NULLIFY(&something,false); [line 85]\n NULLIFY(&value,false); [line 85]\n NULLIFY(&x,false); [line 85]\n NULLIFY(&z,false); [line 85]\n " color=yellow style=filled] +63 [label="63: Start m4\nFormals: \nLocals: something:int z:int x:int value:int \n DECLARE_LOCALS(&return,&something,&z,&x,&value); [line 78]\n NULLIFY(&something,false); [line 78]\n NULLIFY(&value,false); [line 78]\n NULLIFY(&x,false); [line 78]\n NULLIFY(&z,false); [line 78]\n " color=yellow style=filled] 63 -> 84 ; -62 [label="62: DeclStmt \n *&value:int =0 [line 66]\n " shape="box"] +62 [label="62: DeclStmt \n *&value:int =0 [line 61]\n " shape="box"] 62 -> 49 ; -61 [label="61: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 69]\n " shape="invhouse"] +61 [label="61: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 63]\n " shape="invhouse"] 61 -> 57 ; 61 -> 58 ; -60 [label="60: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 69]\n " shape="invhouse"] +60 [label="60: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 63]\n " shape="invhouse"] 60 -> 59 ; -59 [label="59: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 70]\n REMOVE_TEMPS(n$2); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] +59 [label="59: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 64]\n REMOVE_TEMPS(n$2); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"] 59 -> 48 ; -58 [label="58: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 72]\n " shape="invhouse"] +58 [label="58: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 66]\n " shape="invhouse"] 58 -> 52 ; 58 -> 53 ; -57 [label="57: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 72]\n " shape="invhouse"] +57 [label="57: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 66]\n " shape="invhouse"] 57 -> 56 ; -56 [label="56: DeclStmt \n *&something:int =1 [line 73]\n " shape="box"] +56 [label="56: DeclStmt \n *&something:int =1 [line 67]\n " shape="box"] 56 -> 55 ; -55 [label="55: UnaryOperator \n n$1=*&something:int [line 74]\n *&something:int =(n$1 + 1) [line 74]\n REMOVE_TEMPS(n$1); [line 74]\n NULLIFY(&something,false); [line 74]\n APPLY_ABSTRACTION; [line 74]\n " shape="box"] +55 [label="55: UnaryOperator \n n$1=*&something:int [line 68]\n *&something:int =(n$1 + 1) [line 68]\n REMOVE_TEMPS(n$1); [line 68]\n NULLIFY(&something,false); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"] 55 -> 48 ; -54 [label="54: DeclStmt \n *&z:int =9 [line 77]\n NULLIFY(&something,false); [line 77]\n NULLIFY(&value,false); [line 77]\n NULLIFY(&z,false); [line 77]\n APPLY_ABSTRACTION; [line 77]\n " shape="box"] +54 [label="54: DeclStmt \n *&z:int =9 [line 70]\n NULLIFY(&something,false); [line 70]\n NULLIFY(&value,false); [line 70]\n NULLIFY(&z,false); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 54 -> 48 ; -53 [label="53: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 78]\n " shape="invhouse"] +53 [label="53: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 71]\n " shape="invhouse"] 53 -> 50 ; 53 -> 51 ; -52 [label="52: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 78]\n APPLY_ABSTRACTION; [line 78]\n " shape="invhouse"] +52 [label="52: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="invhouse"] 52 -> 48 ; -51 [label="51: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 79]\n APPLY_ABSTRACTION; [line 79]\n " shape="invhouse"] +51 [label="51: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="invhouse"] 51 -> 48 ; -50 [label="50: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 79]\n APPLY_ABSTRACTION; [line 79]\n " shape="invhouse"] +50 [label="50: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="invhouse"] 50 -> 48 ; -49 [label="49: Switch_stmt \n n$0=*&value:int [line 67]\n NULLIFY(&value,false); [line 67]\n " shape="box"] +49 [label="49: Switch_stmt \n n$0=*&value:int [line 62]\n NULLIFY(&value,false); [line 62]\n " shape="box"] 49 -> 60 ; 49 -> 61 ; -48 [label="48: Return Stmt \n *&return:int =0 [line 81]\n REMOVE_TEMPS(n$0); [line 81]\n APPLY_ABSTRACTION; [line 81]\n " shape="box"] +48 [label="48: Return Stmt \n *&return:int =0 [line 75]\n REMOVE_TEMPS(n$0); [line 75]\n APPLY_ABSTRACTION; [line 75]\n " shape="box"] 48 -> 47 ; 47 [label="47: Exit m3 \n " color=yellow style=filled] -46 [label="46: Start m3\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 64]\n NULLIFY(&something,false); [line 64]\n NULLIFY(&value,false); [line 64]\n NULLIFY(&z,false); [line 64]\n " color=yellow style=filled] +46 [label="46: Start m3\nFormals: \nLocals: z:int something:int value:int \n DECLARE_LOCALS(&return,&z,&something,&value); [line 60]\n NULLIFY(&something,false); [line 60]\n NULLIFY(&value,false); [line 60]\n NULLIFY(&z,false); [line 60]\n " color=yellow style=filled] 46 -> 62 ; -45 [label="45: DeclStmt \n *&value:int =0 [line 39]\n " shape="box"] +45 [label="45: DeclStmt \n *&value:int =0 [line 36]\n " shape="box"] 45 -> 27 ; -44 [label="44: DeclStmt \n *&x:int =1 [line 42]\n NULLIFY(&something,false); [line 42]\n NULLIFY(&x,false); [line 42]\n NULLIFY(&z,false); [line 42]\n " shape="box"] +44 [label="44: DeclStmt \n *&x:int =1 [line 38]\n NULLIFY(&something,false); [line 38]\n NULLIFY(&x,false); [line 38]\n NULLIFY(&z,false); [line 38]\n " shape="box"] 44 -> 43 ; -43 [label="43: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 43]\n REMOVE_TEMPS(n$4); [line 43]\n " shape="box"] +43 [label="43: Call _fun_printf \n n$4=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 39]\n REMOVE_TEMPS(n$4); [line 39]\n " shape="box"] 43 -> 42 ; -42 [label="42: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 44]\n *&x:int =(n$3 + 1) [line 44]\n REMOVE_TEMPS(n$3); [line 44]\n NULLIFY(&value,false); [line 44]\n NULLIFY(&x,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] +42 [label="42: BinaryOperatorStmt: Assign \n n$3=*&value:int [line 40]\n *&x:int =(n$3 + 1) [line 40]\n REMOVE_TEMPS(n$3); [line 40]\n NULLIFY(&value,false); [line 40]\n NULLIFY(&x,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] 42 -> 39 ; -41 [label="41: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 45]\n " shape="invhouse"] +41 [label="41: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 41]\n " shape="invhouse"] 41 -> 36 ; 41 -> 37 ; -40 [label="40: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="invhouse"] +40 [label="40: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="invhouse"] 40 -> 39 ; -39 [label="39: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 46]\n REMOVE_TEMPS(n$2); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +39 [label="39: Call _fun_printf \n n$2=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 42]\n REMOVE_TEMPS(n$2); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 39 -> 26 ; -38 [label="38: DeclStmt \n *&z:int =9 [line 48]\n NULLIFY(&something,false); [line 48]\n NULLIFY(&value,false); [line 48]\n NULLIFY(&x,false); [line 48]\n NULLIFY(&z,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +38 [label="38: DeclStmt \n *&z:int =9 [line 44]\n NULLIFY(&something,false); [line 44]\n NULLIFY(&value,false); [line 44]\n NULLIFY(&x,false); [line 44]\n NULLIFY(&z,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 38 -> 35 ; -37 [label="37: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 51]\n " shape="invhouse"] +37 [label="37: Prune (false branch) \n PRUNE(((n$0 == 1) == 0), false); [line 47]\n " shape="invhouse"] 37 -> 31 ; 37 -> 32 ; -36 [label="36: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="invhouse"] +36 [label="36: Prune (true branch) \n PRUNE(((n$0 == 1) != 0), true); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="invhouse"] 36 -> 35 ; -35 [label="35: DeclStmt \n *&something:int =1 [line 52]\n " shape="box"] +35 [label="35: DeclStmt \n *&something:int =1 [line 48]\n " shape="box"] 35 -> 34 ; -34 [label="34: UnaryOperator \n n$1=*&something:int [line 53]\n *&something:int =(n$1 + 1) [line 53]\n REMOVE_TEMPS(n$1); [line 53]\n NULLIFY(&something,false); [line 53]\n " shape="box"] +34 [label="34: UnaryOperator \n n$1=*&something:int [line 49]\n *&something:int =(n$1 + 1) [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n NULLIFY(&something,false); [line 49]\n " shape="box"] 34 -> 33 ; -33 [label="33: BinaryOperatorStmt: Assign \n *&z:int =42 [line 55]\n NULLIFY(&z,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +33 [label="33: BinaryOperatorStmt: Assign \n *&z:int =42 [line 51]\n NULLIFY(&z,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 33 -> 26 ; -32 [label="32: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 57]\n " shape="invhouse"] +32 [label="32: Prune (false branch) \n PRUNE(((n$0 == 2) == 0), false); [line 53]\n " shape="invhouse"] 32 -> 29 ; 32 -> 30 ; -31 [label="31: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="invhouse"] +31 [label="31: Prune (true branch) \n PRUNE(((n$0 == 2) != 0), true); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="invhouse"] 31 -> 26 ; -30 [label="30: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 58]\n " shape="invhouse"] +30 [label="30: Prune (false branch) \n PRUNE(((n$0 == 3) == 0), false); [line 54]\n " shape="invhouse"] 30 -> 28 ; -29 [label="29: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="invhouse"] +29 [label="29: Prune (true branch) \n PRUNE(((n$0 == 3) != 0), true); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="invhouse"] 29 -> 26 ; -28 [label="28: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +28 [label="28: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 28 -> 35 ; -27 [label="27: Switch_stmt \n n$0=*&value:int [line 40]\n NULLIFY(&value,false); [line 40]\n " shape="box"] +27 [label="27: Switch_stmt \n n$0=*&value:int [line 37]\n NULLIFY(&value,false); [line 37]\n " shape="box"] 27 -> 40 ; 27 -> 41 ; -26 [label="26: Return Stmt \n *&return:int =0 [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] +26 [label="26: Return Stmt \n *&return:int =0 [line 57]\n REMOVE_TEMPS(n$0); [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] 26 -> 25 ; 25 [label="25: Exit m2 \n " color=yellow style=filled] -24 [label="24: Start m2\nFormals: \nLocals: something:int z:int x:int value:int \n DECLARE_LOCALS(&return,&something,&z,&x,&value); [line 37]\n NULLIFY(&something,false); [line 37]\n NULLIFY(&value,false); [line 37]\n NULLIFY(&x,false); [line 37]\n NULLIFY(&z,false); [line 37]\n " color=yellow style=filled] +24 [label="24: Start m2\nFormals: \nLocals: something:int z:int x:int value:int \n DECLARE_LOCALS(&return,&something,&z,&x,&value); [line 35]\n NULLIFY(&something,false); [line 35]\n NULLIFY(&value,false); [line 35]\n NULLIFY(&x,false); [line 35]\n NULLIFY(&z,false); [line 35]\n " color=yellow style=filled] 24 -> 45 ; -23 [label="23: DeclStmt \n *&value:int =0 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +23 [label="23: DeclStmt \n *&value:int =0 [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] 23 -> 4 ; -22 [label="22: DeclStmt \n *&x:int =1 [line 17]\n NULLIFY(&x,false); [line 17]\n " shape="box"] +22 [label="22: DeclStmt \n *&x:int =1 [line 16]\n NULLIFY(&x,false); [line 16]\n " shape="box"] 22 -> 21 ; -21 [label="21: Call _fun_printf \n n$7=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 18]\n REMOVE_TEMPS(n$7); [line 18]\n " shape="box"] +21 [label="21: Call _fun_printf \n n$7=_fun_printf(\"(out)HELLO WORLD!\":char *) [line 17]\n REMOVE_TEMPS(n$7); [line 17]\n " shape="box"] 21 -> 20 ; -20 [label="20: BinaryOperatorStmt: Assign \n n$6=*&value:int [line 19]\n *&x:int =(n$6 + 1) [line 19]\n REMOVE_TEMPS(n$6); [line 19]\n NULLIFY(&x,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +20 [label="20: BinaryOperatorStmt: Assign \n n$6=*&value:int [line 18]\n *&x:int =(n$6 + 1) [line 18]\n REMOVE_TEMPS(n$6); [line 18]\n NULLIFY(&x,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 20 -> 17 ; -19 [label="19: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 20]\n " shape="invhouse"] +19 [label="19: Prune (false branch) \n PRUNE(((n$2 == 0) == 0), false); [line 19]\n " shape="invhouse"] 19 -> 15 ; 19 -> 16 ; -18 [label="18: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="invhouse"] +18 [label="18: Prune (true branch) \n PRUNE(((n$2 == 0) != 0), true); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="invhouse"] 18 -> 17 ; -17 [label="17: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 21]\n REMOVE_TEMPS(n$5); [line 21]\n " shape="box"] +17 [label="17: Call _fun_printf \n n$5=_fun_printf(\"(0)HELLO WORLD!\":char *) [line 20]\n REMOVE_TEMPS(n$5); [line 20]\n " shape="box"] 17 -> 8 ; -16 [label="16: Prune (false branch) \n PRUNE(((n$2 == 1) == 0), false); [line 23]\n " shape="invhouse"] +16 [label="16: Prune (false branch) \n PRUNE(((n$2 == 1) == 0), false); [line 22]\n " shape="invhouse"] 16 -> 12 ; 16 -> 13 ; -15 [label="15: Prune (true branch) \n PRUNE(((n$2 == 1) != 0), true); [line 23]\n " shape="invhouse"] +15 [label="15: Prune (true branch) \n PRUNE(((n$2 == 1) != 0), true); [line 22]\n " shape="invhouse"] 15 -> 14 ; -14 [label="14: Call _fun_printf \n n$4=_fun_printf(\"(1)HELLO WORLD!\":char *) [line 24]\n REMOVE_TEMPS(n$4); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +14 [label="14: Call _fun_printf \n n$4=_fun_printf(\"(1)HELLO WORLD!\":char *) [line 23]\n REMOVE_TEMPS(n$4); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 14 -> 4 ; -13 [label="13: Prune (false branch) \n PRUNE(((n$2 == 2) == 0), false); [line 26]\n " shape="invhouse"] +13 [label="13: Prune (false branch) \n PRUNE(((n$2 == 2) == 0), false); [line 25]\n " shape="invhouse"] 13 -> 10 ; -12 [label="12: Prune (true branch) \n PRUNE(((n$2 == 2) != 0), true); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="invhouse"] +12 [label="12: Prune (true branch) \n PRUNE(((n$2 == 2) != 0), true); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="invhouse"] 12 -> 11 ; -11 [label="11: Call _fun_printf \n n$3=_fun_printf(\"(2/def)HELLO WORLD!\":char *) [line 28]\n REMOVE_TEMPS(n$3); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +11 [label="11: Call _fun_printf \n n$3=_fun_printf(\"(2/def)HELLO WORLD!\":char *) [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 11 -> 4 ; -10 [label="10: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +10 [label="10: DefaultStmt_placeholder \n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 10 -> 11 ; -9 [label="9: Switch_stmt \n n$2=*&value:int [line 16]\n " shape="box"] +9 [label="9: Switch_stmt \n n$2=*&value:int [line 15]\n " shape="box"] 9 -> 18 ; 9 -> 19 ; -8 [label="8: Call _fun_printf \n n$1=_fun_printf(\"(after_switch)HELLO WORLD!\":char *) [line 31]\n REMOVE_TEMPS(n$1,n$2); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] +8 [label="8: Call _fun_printf \n n$1=_fun_printf(\"(after_switch)HELLO WORLD!\":char *) [line 30]\n REMOVE_TEMPS(n$1,n$2); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 8 -> 4 ; -7 [label="7: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n " shape="invhouse"] +7 [label="7: Prune (false branch) \n PRUNE(((n$0 < 10) == 0), false); [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n " shape="invhouse"] 7 -> 3 ; -6 [label="6: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n " shape="invhouse"] +6 [label="6: Prune (true branch) \n PRUNE(((n$0 < 10) != 0), true); [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n " shape="invhouse"] 6 -> 9 ; -5 [label="5: BinaryOperatorStmt: LT \n n$0=*&value:int [line 15]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: LT \n n$0=*&value:int [line 14]\n " shape="box"] 5 -> 6 ; @@ -791,7 +791,7 @@ digraph iCFG { 4 -> 5 ; -3 [label="3: Return Stmt \n NULLIFY(&value,false); [line 33]\n *&return:int =0 [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +3 [label="3: Return Stmt \n NULLIFY(&value,false); [line 32]\n *&return:int =0 [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/c/frontend/types/struct.c b/infer/tests/codetoanalyze/c/frontend/types/struct.c index 380c64085..eae2afa96 100644 --- a/infer/tests/codetoanalyze/c/frontend/types/struct.c +++ b/infer/tests/codetoanalyze/c/frontend/types/struct.c @@ -8,8 +8,8 @@ */ struct X { -int a; -int b; + int a; + int b; }; void test() { diff --git a/infer/tests/codetoanalyze/cpp/errors/c_tests/c_bugs.cpp b/infer/tests/codetoanalyze/cpp/errors/c_tests/c_bugs.cpp index 8b8c45996..3e5283b09 100644 --- a/infer/tests/codetoanalyze/cpp/errors/c_tests/c_bugs.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/c_tests/c_bugs.cpp @@ -8,32 +8,28 @@ */ #include -#include #include +#include // basic tests for C bugs in C++ code -void malloc_memory_leak_is_reported() { - int *p = (int*) malloc(sizeof(int)); -} +void malloc_memory_leak_is_reported() { int* p = (int*)malloc(sizeof(int)); } void malloc_free_works() { - int *p = (int*)malloc(sizeof(int)); + int* p = (int*)malloc(sizeof(int)); free(p); } void malloc_fail_gets_reported() { - int *p = (int*)malloc(sizeof(int)); + int* p = (int*)malloc(sizeof(int)); *p = 3; // Null dereference free(p); } -void resource_leak_is_reported() { - FILE * fd = fopen("hi.txt", "w"); -} +void resource_leak_is_reported() { FILE* fd = fopen("hi.txt", "w"); } void fopen_fclose_works() { - FILE * fd = fopen("hi.txt", "w"); + FILE* fd = fopen("hi.txt", "w"); if (fd) { fclose(fd); } 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 b99ac19b9..bdd11fb81 100644 --- a/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp @@ -8,13 +8,14 @@ */ class Rectangle { - int width, height; -public: - Rectangle(int x, int y) : width(x), height(y) {} - int area(void) { return width * height; } + int width, height; + + public: + Rectangle(int x, int y) : width(x), height(y) {} + int area(void) { return width * height; } }; int main() { - Rectangle *bar = new Rectangle (5, 6); - return 0; + Rectangle* bar = new Rectangle(5, 6); + return 0; } diff --git a/infer/tests/codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp b/infer/tests/codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp index 80edb2a64..a06f283e5 100644 --- a/infer/tests/codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp @@ -8,27 +8,27 @@ */ class X { -public: + public: int field; }; class XFactory { -public: + public: X nonNull; X* getNull() { return nullptr; } X* getNonNull() { return &nonNull; } }; -int testNullDeref(XFactory *factory) { +int testNullDeref(XFactory* factory) { if (factory) { - X *x = factory->getNull(); + X* x = factory->getNull(); return x->field; } } -int testNoNullDeref(XFactory *factory) { +int testNoNullDeref(XFactory* factory) { if (factory) { - X *x = factory->getNonNull(); + X* x = factory->getNonNull(); return x->field; } } diff --git a/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp b/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp index 492144f49..4861ef1af 100644 --- a/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/npe/object_deref.cpp @@ -8,7 +8,7 @@ */ class X { -public: + public: int field; }; @@ -18,11 +18,11 @@ X globalX; X* getNonNull() { return &globalX; } void derefNullField() { - X *x = getNull(); + X* x = getNull(); int c = x->field; } void derefNonNullField() { - X *x = getNonNull(); + X* x = getNonNull(); int c = x->field; } diff --git a/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp b/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp index cae8d729c..aeb9a54d1 100644 --- a/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/subtyping/dynamic_cast.cpp @@ -8,63 +8,68 @@ */ class Base { - virtual void dummy() {} -public: - int b; + virtual void dummy() {} + + public: + int b; }; -class Derived: public Base { - int a; +class Derived : public Base { + int a; }; int castOfArgumentPointer(Base* pb) { - if (dynamic_cast(pb)) { - return 1; - } - else return 0; + if (dynamic_cast(pb)) { + return 1; + } else + return 0; } int castOfArgumentReference(Base& pdd) { - Derived& pdd2 = dynamic_cast(pdd); - return 0; + Derived& pdd2 = dynamic_cast(pdd); + return 0; } -int wrongCastOfArgumentPointer(){ - Base pdd; - return 1/castOfArgumentPointer(&pdd); +int wrongCastOfArgumentPointer() { + Base pdd; + return 1 / castOfArgumentPointer(&pdd); } -int wrongCastOfArgumentReference(){ - Base pdd; - return castOfArgumentReference(pdd); +int wrongCastOfArgumentReference() { + Base pdd; + return castOfArgumentReference(pdd); } int wrongPointerCast() { - Base * pbb = new Base; - Derived * pd = dynamic_cast(pbb); - if (pd) return 1; - else return 1/0; + Base* pbb = new Base; + Derived* pd = dynamic_cast(pbb); + if (pd) + return 1; + else + return 1 / 0; } int rightPointerCast() { - Base * pbb = new Derived; - Derived * pd = dynamic_cast(pbb); - if (pd) return 1/0; - else return 1; + Base* pbb = new Derived; + Derived* pd = dynamic_cast(pbb); + if (pd) + return 1 / 0; + else + return 1; } void rightReferenceCast() { - Base * pbb = new Derived; - Derived& pdd1 = dynamic_cast(*pbb); + Base* pbb = new Derived; + Derived& pdd1 = dynamic_cast(*pbb); } void wrongReferenceCast() { - Base * pbb = new Base; - Base& pdd = *pbb; - Derived& pdd1 = dynamic_cast(pdd); + Base* pbb = new Base; + Base& pdd = *pbb; + Derived& pdd1 = dynamic_cast(pdd); } void wrongReferenceCastNotAssigned() { - Base * pbb = new Base; - Base& pdd = *pbb; - dynamic_cast(pdd); + Base* pbb = new Base; + Base& pdd = *pbb; + dynamic_cast(pdd); } diff --git a/infer/tests/codetoanalyze/cpp/errors/subtyping/subtyping_check.cpp b/infer/tests/codetoanalyze/cpp/errors/subtyping/subtyping_check.cpp index dcc8fb96f..7b5e87ea4 100644 --- a/infer/tests/codetoanalyze/cpp/errors/subtyping/subtyping_check.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/subtyping/subtyping_check.cpp @@ -8,19 +8,18 @@ */ struct A { - int f; - void setF() { - f = 1; - } + int f; + void setF() { f = 1; } }; struct B : public A { - int g; - void setFG() { - setF(); - g = 1; - if (g == 1) - g = 1/0; - else g = 0; - } + int g; + void setFG() { + setF(); + g = 1; + if (g == 1) + g = 1 / 0; + else + g = 0; + } }; diff --git a/infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp b/infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp index 3dee8047a..4acccdf93 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/builtin/new.cpp @@ -13,6 +13,6 @@ void test() { new int; // this will be leak - test that it gets to cfg delete i; - //int* i_a = new int[10]; - //delete[] i_a; + // int* i_a = new int[10]; + // delete[] i_a; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp b/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp index ac2c7f1c8..a627355ec 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp @@ -26,38 +26,22 @@ int assign_conditional(int a) { } int div_temp_lvalue(int a, int b) { - const int &r = a ? b : 1; + const int& r = a ? b : 1; return 1 / r; } -int div0_choose_lvalue() { - return 1 / choose_lvalue(1); -} +int div0_choose_lvalue() { return 1 / choose_lvalue(1); } -int div1_choose_lvalue() { - return 1 / choose_lvalue(0); -} +int div1_choose_lvalue() { return 1 / choose_lvalue(0); } -int div0_choose_rvalue() { - return 1 / choose_rvalue(1); -} +int div0_choose_rvalue() { return 1 / choose_rvalue(1); } -int div1_choose_rvalue() { - return 1 / choose_rvalue(0); -} +int div1_choose_rvalue() { return 1 / choose_rvalue(0); } -int div0_assign_conditional() { - return 1 / assign_conditional(0); -} +int div0_assign_conditional() { return 1 / assign_conditional(0); } -int div1_assign_conditional() { - return 1 / assign_conditional(1); -} +int div1_assign_conditional() { return 1 / assign_conditional(1); } -int div0_temp_lvalue() { - return div_temp_lvalue(1, 0); -} +int div0_temp_lvalue() { return div_temp_lvalue(1, 0); } -int div1_temp_lvalue() { - return div_temp_lvalue(0, 1); -} +int div1_temp_lvalue() { return div_temp_lvalue(0, 1); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp.dot index 36252d644..ac82e3b5a 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/conditional/lvalue_conditional.cpp.dot @@ -1,82 +1,82 @@ digraph iCFG { -65 [label="65: Return Stmt \n n$0=_fun_div_temp_lvalue(0:int ,1:int ) [line 62]\n *&return:int =n$0 [line 62]\n REMOVE_TEMPS(n$0); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +65 [label="65: Return Stmt \n n$0=_fun_div_temp_lvalue(0:int ,1:int ) [line 47]\n *&return:int =n$0 [line 47]\n REMOVE_TEMPS(n$0); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] 65 -> 64 ; 64 [label="64: Exit div1_temp_lvalue \n " color=yellow style=filled] -63 [label="63: Start div1_temp_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 61]\n " color=yellow style=filled] +63 [label="63: Start div1_temp_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 47]\n " color=yellow style=filled] 63 -> 65 ; -62 [label="62: Return Stmt \n n$0=_fun_div_temp_lvalue(1:int ,0:int ) [line 58]\n *&return:int =n$0 [line 58]\n REMOVE_TEMPS(n$0); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] +62 [label="62: Return Stmt \n n$0=_fun_div_temp_lvalue(1:int ,0:int ) [line 45]\n *&return:int =n$0 [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 62 -> 61 ; 61 [label="61: Exit div0_temp_lvalue \n " color=yellow style=filled] -60 [label="60: Start div0_temp_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 57]\n " color=yellow style=filled] +60 [label="60: Start div0_temp_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 45]\n " color=yellow style=filled] 60 -> 62 ; -59 [label="59: Return Stmt \n n$0=_fun_assign_conditional(1:int ) [line 54]\n *&return:int =(1 / n$0) [line 54]\n REMOVE_TEMPS(n$0); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +59 [label="59: Return Stmt \n n$0=_fun_assign_conditional(1:int ) [line 43]\n *&return:int =(1 / n$0) [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 59 -> 58 ; 58 [label="58: Exit div1_assign_conditional \n " color=yellow style=filled] -57 [label="57: Start div1_assign_conditional\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] +57 [label="57: Start div1_assign_conditional\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 43]\n " color=yellow style=filled] 57 -> 59 ; -56 [label="56: Return Stmt \n n$0=_fun_assign_conditional(0:int ) [line 50]\n *&return:int =(1 / n$0) [line 50]\n REMOVE_TEMPS(n$0); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] +56 [label="56: Return Stmt \n n$0=_fun_assign_conditional(0:int ) [line 41]\n *&return:int =(1 / n$0) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 56 -> 55 ; 55 [label="55: Exit div0_assign_conditional \n " color=yellow style=filled] -54 [label="54: Start div0_assign_conditional\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 49]\n " color=yellow style=filled] +54 [label="54: Start div0_assign_conditional\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 41]\n " color=yellow style=filled] 54 -> 56 ; -53 [label="53: Return Stmt \n n$0=_fun_choose_rvalue(0:int ) [line 46]\n *&return:int =(1 / n$0) [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +53 [label="53: Return Stmt \n n$0=_fun_choose_rvalue(0:int ) [line 39]\n *&return:int =(1 / n$0) [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 53 -> 52 ; 52 [label="52: Exit div1_choose_rvalue \n " color=yellow style=filled] -51 [label="51: Start div1_choose_rvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 45]\n " color=yellow style=filled] +51 [label="51: Start div1_choose_rvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 39]\n " color=yellow style=filled] 51 -> 53 ; -50 [label="50: Return Stmt \n n$0=_fun_choose_rvalue(1:int ) [line 42]\n *&return:int =(1 / n$0) [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +50 [label="50: Return Stmt \n n$0=_fun_choose_rvalue(1:int ) [line 37]\n *&return:int =(1 / n$0) [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 50 -> 49 ; 49 [label="49: Exit div0_choose_rvalue \n " color=yellow style=filled] -48 [label="48: Start div0_choose_rvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 41]\n " color=yellow style=filled] +48 [label="48: Start div0_choose_rvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 37]\n " color=yellow style=filled] 48 -> 50 ; -47 [label="47: Return Stmt \n n$0=_fun_choose_lvalue(0:int ) [line 38]\n *&return:int =(1 / n$0) [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +47 [label="47: Return Stmt \n n$0=_fun_choose_lvalue(0:int ) [line 35]\n *&return:int =(1 / n$0) [line 35]\n REMOVE_TEMPS(n$0); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 47 -> 46 ; 46 [label="46: Exit div1_choose_lvalue \n " color=yellow style=filled] -45 [label="45: Start div1_choose_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 37]\n " color=yellow style=filled] +45 [label="45: Start div1_choose_lvalue\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 35]\n " color=yellow style=filled] 45 -> 47 ; -44 [label="44: Return Stmt \n n$0=_fun_choose_lvalue(1:int ) [line 34]\n *&return:int =(1 / n$0) [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] +44 [label="44: Return Stmt \n n$0=_fun_choose_lvalue(1:int ) [line 33]\n *&return:int =(1 / n$0) [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 44 -> 43 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp index 553613181..30a73443d 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp @@ -9,14 +9,13 @@ class X { int f; -public: + + public: X(int a, int b = 0); int div() { return 1 / f; } }; -X::X(int a, int b) { - f = a + b; -} +X::X(int a, int b) { f = a + b; } void test() { X x1(0); diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp.dot index 434e7b092..2cd285cee 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_default_arg.cpp.dot @@ -1,20 +1,20 @@ digraph iCFG { -11 [label="11: DeclStmt \n _fun_X_X(&x1:class X *,0:int ,0:int ) [line 22]\n " shape="box"] +11 [label="11: DeclStmt \n _fun_X_X(&x1:class X *,0:int ,0:int ) [line 21]\n " shape="box"] 11 -> 10 ; -10 [label="10: DeclStmt \n _fun_X_X(&x2:class X *,1:int ,0:int ) [line 23]\n " shape="box"] +10 [label="10: DeclStmt \n _fun_X_X(&x2:class X *,1:int ,0:int ) [line 22]\n " shape="box"] 10 -> 9 ; -9 [label="9: DeclStmt \n _fun_X_X(&x3:class X *,0:int ,1:int ) [line 24]\n NULLIFY(&x1,false); [line 24]\n NULLIFY(&x2,false); [line 24]\n NULLIFY(&x3,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +9 [label="9: DeclStmt \n _fun_X_X(&x3:class X *,0:int ,1:int ) [line 23]\n NULLIFY(&x1,false); [line 23]\n NULLIFY(&x2,false); [line 23]\n NULLIFY(&x3,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit test \n " color=yellow style=filled] -7 [label="7: Start test\nFormals: \nLocals: x3:class X x2:class X x1:class X \n DECLARE_LOCALS(&return,&x3,&x2,&x1); [line 21]\n " color=yellow style=filled] +7 [label="7: Start test\nFormals: \nLocals: x3:class X x2:class X x1:class X \n DECLARE_LOCALS(&return,&x3,&x2,&x1); [line 20]\n " color=yellow style=filled] 7 -> 11 ; @@ -25,18 +25,18 @@ digraph iCFG { 5 [label="5: Exit 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 17]\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 18]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&this:class X * [line 14]\n n$1=*n$0.f:int [line 14]\n *&return:int =(1 / n$1) [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&this,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +3 [label="3: 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 REMOVE_TEMPS(n$0,n$1); [line 15]\n NULLIFY(&this,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit X_div \n " color=yellow style=filled] -1 [label="1: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +1 [label="1: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp index 795c6df50..b578c89b1 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp @@ -9,8 +9,7 @@ struct A { int f; - A(int f) : f(f) { - } + A(int f) : f(f) {} }; struct B : public A { @@ -20,50 +19,42 @@ struct B : public A { }; int f2; T t; - B(int a) : - A(a), - f2(a), - t(a) { - } - - B(int a, int b) : - B(a+b) { - f2 = b; - } + B(int a) : A(a), f2(a), t(a) {} + B(int a, int b) : B(a + b) { f2 = b; } }; int f2_div0() { B b(0); - return 1/b.f2; + return 1 / b.f2; } int f_div0() { B b(0); - return 1/b.f; + return 1 / b.f; } int t_div0() { B b(0); - return 1/b.t.v; + return 1 / b.t.v; } int delegate_constr_f_div0() { B b(-1, 1); - int v = 1/b.f2; - return 1/b.f; + int v = 1 / b.f2; + return 1 / b.f; } int delegate_constr_f2_div0() { B b(-1, 0); - int v = 1/b.f; - return 1/b.f2; + int v = 1 / b.f; + return 1 / b.f2; } int f_f2_div1() { B b(1); - int v = 1/b.f; - int v2 = 1/b.f2; - int v3 = 1/b.t.v; + int v = 1 / b.f; + int v2 = 1 / b.f2; + int v3 = 1 / b.t.v; return v + v2; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp.dot index f434435e4..fc71c64ae 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp.dot @@ -1,156 +1,156 @@ digraph iCFG { -44 [label="44: DeclStmt \n _fun_B_B(&b:class B *,1:int ) [line 64]\n " shape="box"] +44 [label="44: DeclStmt \n _fun_B_B(&b:class B *,1:int ) [line 55]\n " shape="box"] 44 -> 43 ; -43 [label="43: DeclStmt \n n$4=*&b.f:int [line 65]\n *&v:int =(1 / n$4) [line 65]\n REMOVE_TEMPS(n$4); [line 65]\n " shape="box"] +43 [label="43: DeclStmt \n n$4=*&b.f:int [line 56]\n *&v:int =(1 / n$4) [line 56]\n REMOVE_TEMPS(n$4); [line 56]\n " shape="box"] 43 -> 42 ; -42 [label="42: DeclStmt \n n$3=*&b.f2:int [line 66]\n *&v2:int =(1 / n$3) [line 66]\n REMOVE_TEMPS(n$3); [line 66]\n " shape="box"] +42 [label="42: DeclStmt \n n$3=*&b.f2:int [line 57]\n *&v2:int =(1 / n$3) [line 57]\n REMOVE_TEMPS(n$3); [line 57]\n " shape="box"] 42 -> 41 ; -41 [label="41: DeclStmt \n n$2=*&b.t.v:int [line 67]\n *&v3:int =(1 / n$2) [line 67]\n REMOVE_TEMPS(n$2); [line 67]\n NULLIFY(&v3,false); [line 67]\n " shape="box"] +41 [label="41: DeclStmt \n n$2=*&b.t.v:int [line 58]\n *&v3:int =(1 / n$2) [line 58]\n REMOVE_TEMPS(n$2); [line 58]\n NULLIFY(&v3,false); [line 58]\n " shape="box"] 41 -> 40 ; -40 [label="40: Return Stmt \n n$0=*&v:int [line 68]\n n$1=*&v2:int [line 68]\n *&return:int =(n$0 + n$1) [line 68]\n REMOVE_TEMPS(n$0,n$1); [line 68]\n NULLIFY(&v,false); [line 68]\n NULLIFY(&v2,false); [line 68]\n NULLIFY(&b,false); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"] +40 [label="40: Return Stmt \n n$0=*&v:int [line 59]\n n$1=*&v2:int [line 59]\n *&return:int =(n$0 + n$1) [line 59]\n REMOVE_TEMPS(n$0,n$1); [line 59]\n NULLIFY(&v,false); [line 59]\n NULLIFY(&v2,false); [line 59]\n NULLIFY(&b,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] 40 -> 39 ; 39 [label="39: Exit f_f2_div1 \n " color=yellow style=filled] -38 [label="38: Start f_f2_div1\nFormals: \nLocals: v3:int v2:int v:int b:class B \n DECLARE_LOCALS(&return,&v3,&v2,&v,&b); [line 63]\n NULLIFY(&v,false); [line 63]\n NULLIFY(&v2,false); [line 63]\n NULLIFY(&v3,false); [line 63]\n " color=yellow style=filled] +38 [label="38: Start f_f2_div1\nFormals: \nLocals: v3:int v2:int v:int b:class B \n DECLARE_LOCALS(&return,&v3,&v2,&v,&b); [line 54]\n NULLIFY(&v,false); [line 54]\n NULLIFY(&v2,false); [line 54]\n NULLIFY(&v3,false); [line 54]\n " color=yellow style=filled] 38 -> 44 ; -37 [label="37: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,0:int ) [line 58]\n " shape="box"] +37 [label="37: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,0:int ) [line 49]\n " shape="box"] 37 -> 36 ; -36 [label="36: DeclStmt \n n$1=*&b.f:int [line 59]\n *&v:int =(1 / n$1) [line 59]\n REMOVE_TEMPS(n$1); [line 59]\n NULLIFY(&v,false); [line 59]\n " shape="box"] +36 [label="36: DeclStmt \n n$1=*&b.f:int [line 50]\n *&v:int =(1 / n$1) [line 50]\n REMOVE_TEMPS(n$1); [line 50]\n NULLIFY(&v,false); [line 50]\n " shape="box"] 36 -> 35 ; -35 [label="35: Return Stmt \n n$0=*&b.f2:int [line 60]\n *&return:int =(1 / n$0) [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n NULLIFY(&b,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] +35 [label="35: Return Stmt \n n$0=*&b.f2:int [line 51]\n *&return:int =(1 / n$0) [line 51]\n REMOVE_TEMPS(n$0); [line 51]\n NULLIFY(&b,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 35 -> 34 ; 34 [label="34: Exit delegate_constr_f2_div0 \n " color=yellow style=filled] -33 [label="33: Start delegate_constr_f2_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 57]\n NULLIFY(&v,false); [line 57]\n " color=yellow style=filled] +33 [label="33: Start delegate_constr_f2_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 48]\n NULLIFY(&v,false); [line 48]\n " color=yellow style=filled] 33 -> 37 ; -32 [label="32: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,1:int ) [line 52]\n " shape="box"] +32 [label="32: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,1:int ) [line 43]\n " shape="box"] 32 -> 31 ; -31 [label="31: DeclStmt \n n$1=*&b.f2:int [line 53]\n *&v:int =(1 / n$1) [line 53]\n REMOVE_TEMPS(n$1); [line 53]\n NULLIFY(&v,false); [line 53]\n " shape="box"] +31 [label="31: DeclStmt \n n$1=*&b.f2:int [line 44]\n *&v:int =(1 / n$1) [line 44]\n REMOVE_TEMPS(n$1); [line 44]\n NULLIFY(&v,false); [line 44]\n " shape="box"] 31 -> 30 ; -30 [label="30: Return Stmt \n n$0=*&b.f:int [line 54]\n *&return:int =(1 / n$0) [line 54]\n REMOVE_TEMPS(n$0); [line 54]\n NULLIFY(&b,false); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +30 [label="30: Return Stmt \n n$0=*&b.f:int [line 45]\n *&return:int =(1 / n$0) [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n NULLIFY(&b,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 30 -> 29 ; 29 [label="29: Exit delegate_constr_f_div0 \n " color=yellow style=filled] -28 [label="28: Start delegate_constr_f_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 51]\n NULLIFY(&v,false); [line 51]\n " color=yellow style=filled] +28 [label="28: Start delegate_constr_f_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 42]\n NULLIFY(&v,false); [line 42]\n " color=yellow style=filled] 28 -> 32 ; -27 [label="27: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 47]\n " shape="box"] +27 [label="27: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 38]\n " shape="box"] 27 -> 26 ; -26 [label="26: Return Stmt \n n$0=*&b.t.v:int [line 48]\n *&return:int =(1 / n$0) [line 48]\n REMOVE_TEMPS(n$0); [line 48]\n NULLIFY(&b,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +26 [label="26: Return Stmt \n n$0=*&b.t.v:int [line 39]\n *&return:int =(1 / n$0) [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n NULLIFY(&b,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 26 -> 25 ; 25 [label="25: Exit t_div0 \n " color=yellow style=filled] -24 [label="24: Start t_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 46]\n " color=yellow style=filled] +24 [label="24: Start t_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 37]\n " color=yellow style=filled] 24 -> 27 ; -23 [label="23: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 42]\n " shape="box"] +23 [label="23: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 33]\n " shape="box"] 23 -> 22 ; -22 [label="22: Return Stmt \n n$0=*&b.f:int [line 43]\n *&return:int =(1 / n$0) [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&b,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +22 [label="22: Return Stmt \n n$0=*&b.f:int [line 34]\n *&return:int =(1 / n$0) [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n NULLIFY(&b,false); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] 22 -> 21 ; 21 [label="21: Exit f_div0 \n " color=yellow style=filled] -20 [label="20: Start f_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 41]\n " color=yellow style=filled] +20 [label="20: Start f_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 32]\n " color=yellow style=filled] 20 -> 23 ; -19 [label="19: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 37]\n " shape="box"] +19 [label="19: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 28]\n " shape="box"] 19 -> 18 ; -18 [label="18: Return Stmt \n n$0=*&b.f2:int [line 38]\n *&return:int =(1 / n$0) [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n NULLIFY(&b,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&b.f2:int [line 29]\n *&return:int =(1 / n$0) [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n NULLIFY(&b,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit f2_div0 \n " color=yellow style=filled] -16 [label="16: Start f2_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 36]\n " color=yellow style=filled] +16 [label="16: Start f2_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 27]\n " color=yellow style=filled] 16 -> 19 ; -15 [label="15: Constructor Init \n n$2=*&this:class B * [line 30]\n n$3=*&a:int [line 30]\n n$4=*&b:int [line 30]\n _fun_B_B(n$2:class B *,(n$3 + n$4):int ) [line 30]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 30]\n NULLIFY(&a,false); [line 30]\n " shape="box"] +15 [label="15: Constructor Init \n n$2=*&this:class B * [line 24]\n n$3=*&a:int [line 24]\n n$4=*&b:int [line 24]\n _fun_B_B(n$2:class B *,(n$3 + n$4):int ) [line 24]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 24]\n NULLIFY(&a,false); [line 24]\n " shape="box"] 15 -> 14 ; -14 [label="14: BinaryOperatorStmt: Assign \n n$0=*&this:class B * [line 31]\n n$1=*&b:int [line 31]\n *n$0.f2:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n NULLIFY(&b,false); [line 31]\n NULLIFY(&this,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] +14 [label="14: BinaryOperatorStmt: Assign \n n$0=*&this:class B * [line 24]\n n$1=*&b:int [line 24]\n *n$0.f2:int =n$1 [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n NULLIFY(&b,false); [line 24]\n NULLIFY(&this,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 14 -> 13 ; 13 [label="13: Exit B_B \n " color=yellow style=filled] -12 [label="12: Start B_B\nFormals: this:class B * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] +12 [label="12: Start B_B\nFormals: this:class B * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 12 -> 15 ; -11 [label="11: Constructor Init \n n$4=*&this:class B * [line 24]\n n$5=*&a:int [line 24]\n _fun_A_A(n$4:class B *,n$5:int ) [line 24]\n REMOVE_TEMPS(n$4,n$5); [line 24]\n " shape="box"] +11 [label="11: Constructor Init \n n$4=*&this:class B * [line 22]\n n$5=*&a:int [line 22]\n _fun_A_A(n$4:class B *,n$5:int ) [line 22]\n REMOVE_TEMPS(n$4,n$5); [line 22]\n " shape="box"] 11 -> 10 ; -10 [label="10: Constructor Init \n n$2=*&this:class B * [line 25]\n n$3=*&a:int [line 25]\n *n$2.f2:int =n$3 [line 25]\n REMOVE_TEMPS(n$2,n$3); [line 25]\n " shape="box"] +10 [label="10: Constructor Init \n n$2=*&this:class B * [line 22]\n n$3=*&a:int [line 22]\n *n$2.f2:int =n$3 [line 22]\n REMOVE_TEMPS(n$2,n$3); [line 22]\n " shape="box"] 10 -> 9 ; -9 [label="9: Constructor Init \n n$0=*&this:class B * [line 26]\n n$1=*&a:int [line 26]\n _fun_B::T_T(n$0.t:class B::T *,n$1:int ) [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&a,false); [line 26]\n NULLIFY(&this,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +9 [label="9: Constructor Init \n n$0=*&this:class B * [line 22]\n n$1=*&a:int [line 22]\n _fun_B::T_T(n$0.t:class B::T *,n$1:int ) [line 22]\n REMOVE_TEMPS(n$0,n$1); [line 22]\n NULLIFY(&a,false); [line 22]\n NULLIFY(&this,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit B_B \n " color=yellow style=filled] -7 [label="7: Start B_B\nFormals: this:class B * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] +7 [label="7: Start B_B\nFormals: this:class B * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] 7 -> 11 ; -6 [label="6: Constructor Init \n n$0=*&this:class B::T * [line 19]\n n$1=*&v:int [line 19]\n *n$0.v:int =n$1 [line 19]\n REMOVE_TEMPS(n$0,n$1); [line 19]\n NULLIFY(&this,false); [line 19]\n NULLIFY(&v,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +6 [label="6: Constructor Init \n n$0=*&this:class B::T * [line 18]\n n$1=*&v:int [line 18]\n *n$0.v:int =n$1 [line 18]\n REMOVE_TEMPS(n$0,n$1); [line 18]\n NULLIFY(&this,false); [line 18]\n NULLIFY(&v,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit B::T_T \n " color=yellow style=filled] -4 [label="4: Start B::T_T\nFormals: this:class B::T * v:int \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] +4 [label="4: Start B::T_T\nFormals: this:class B::T * v:int \nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 4 -> 6 ; 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 d8c418a9e..76b0a6c87 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_with_body.cpp @@ -10,10 +10,9 @@ class X { int f; void init() { f = 0; } -public: - X() { - init(); - } + + public: + X() { init(); } X(int a, int b); 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 13b6764bc..0c59bbbf8 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,76 +1,76 @@ digraph iCFG { -26 [label="26: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:int ) [line 40]\n " shape="box"] +26 [label="26: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:int ) [line 39]\n " shape="box"] 26 -> 25 ; -25 [label="25: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n NULLIFY(&x,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] +25 [label="25: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 40]\n REMOVE_TEMPS(n$0); [line 40]\n NULLIFY(&x,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] 25 -> 24 ; 24 [label="24: Exit test_div1 \n " color=yellow style=filled] -23 [label="23: Start test_div1\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 39]\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 -> 26 ; -22 [label="22: DeclStmt \n _fun_X_X(&x:class X *) [line 35]\n " shape="box"] +22 [label="22: DeclStmt \n _fun_X_X(&x:class X *) [line 34]\n " shape="box"] 22 -> 21 ; -21 [label="21: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] +21 [label="21: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 35]\n REMOVE_TEMPS(n$0); [line 35]\n NULLIFY(&x,false); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit 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 34]\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 -> 22 ; -18 [label="18: DeclStmt \n _fun_X_X(&x:class X *,-2:int ,2:int ) [line 30]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_X_X(&x:class X *,-2:int ,2:int ) [line 29]\n " shape="box"] 18 -> 17 ; -17 [label="17: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n NULLIFY(&x,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] +17 [label="17: Call _fun_X_div \n n$0=_fun_X_div(&x:class X &) [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n NULLIFY(&x,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit test_div0 \n " color=yellow style=filled] -15 [label="15: Start test_div0\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 29]\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 -> 18 ; -14 [label="14: DeclStmt \n n$3=*&a:int [line 24]\n n$4=*&b:int [line 24]\n *&c:int =(n$3 + n$4) [line 24]\n REMOVE_TEMPS(n$3,n$4); [line 24]\n NULLIFY(&a,false); [line 24]\n NULLIFY(&b,false); [line 24]\n " shape="box"] +14 [label="14: DeclStmt \n n$3=*&a:int [line 23]\n n$4=*&b:int [line 23]\n *&c:int =(n$3 + n$4) [line 23]\n REMOVE_TEMPS(n$3,n$4); [line 23]\n NULLIFY(&a,false); [line 23]\n NULLIFY(&b,false); [line 23]\n " shape="box"] 14 -> 13 ; -13 [label="13: Call _fun_X_init \n n$2=*&this:class X * [line 25]\n _fun_X_init(n$2:class X *) [line 25]\n REMOVE_TEMPS(n$2); [line 25]\n " shape="box"] +13 [label="13: Call _fun_X_init \n n$2=*&this:class X * [line 24]\n _fun_X_init(n$2:class X *) [line 24]\n REMOVE_TEMPS(n$2); [line 24]\n " shape="box"] 13 -> 12 ; -12 [label="12: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 26]\n n$1=*&c:int [line 26]\n *n$0.f:int =n$1 [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&c,false); [line 26]\n NULLIFY(&this,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 25]\n NULLIFY(&c,false); [line 25]\n NULLIFY(&this,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit 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 23]\n NULLIFY(&c,false); [line 23]\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 NULLIFY(&c,false); [line 22]\n " color=yellow style=filled] 10 -> 14 ; -9 [label="9: Return Stmt \n n$0=*&this:class X * [line 20]\n n$1=*n$0.f:int [line 20]\n *&return:int =(1 / n$1) [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&this,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 19]\n NULLIFY(&this,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit X_div \n " color=yellow style=filled] -7 [label="7: Start X_div\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\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 -> 9 ; @@ -81,7 +81,7 @@ digraph iCFG { 5 [label="5: Exit 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 X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 4 -> 6 ; 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 b76ebe23a..c73ee6c36 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp @@ -19,9 +19,9 @@ struct X { struct Y { int f; Y() = default; - Y(const Y &y) = default; + Y(const Y& y) = default; // move constructor with different behavior than copy constructor - Y(const Y &&y) : f(y.f - 1) {} + Y(const Y&& y) : f(y.f - 1) {} }; X getX(int f) { @@ -43,10 +43,7 @@ int copyX_div0() { return 1 / x2.f; } -int moveX_div0() { - return 1 / getX(0).f; -} - +int moveX_div0() { return 1 / getX(0).f; } int copyY_div0() { Y y1; @@ -55,12 +52,10 @@ int copyY_div0() { return 1 / y2.f; } -int moveY_div0() { - return 1 / getY(1).f; -} +int moveY_div0() { return 1 / getY(1).f; } int moveY_moveY_copyY_div0() { - Y y1 = getY(2); //move constructor in getY and in assignment + Y y1 = getY(2); // move constructor in getY and in assignment Y y2 = y1; return 1 / y2.f; } 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 e9e5d7b0d..d7c5f1bc3 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,120 +1,120 @@ digraph iCFG { -65 [label="65: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 78]\n " shape="box"] +65 [label="65: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 73]\n " shape="box"] 65 -> 64 ; -64 [label="64: BinaryOperatorStmt: Assign \n *&y1.f:int =1 [line 79]\n " shape="box"] +64 [label="64: BinaryOperatorStmt: Assign \n *&y1.f:int =1 [line 74]\n " shape="box"] 64 -> 63 ; -63 [label="63: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 80]\n " shape="box"] +63 [label="63: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 75]\n " shape="box"] 63 -> 62 ; -62 [label="62: DeclStmt \n n$5=*&y2.f:int [line 81]\n *&d1:int =(1 / n$5) [line 81]\n REMOVE_TEMPS(n$5); [line 81]\n " shape="box"] +62 [label="62: DeclStmt \n n$5=*&y2.f:int [line 76]\n *&d1:int =(1 / n$5) [line 76]\n REMOVE_TEMPS(n$5); [line 76]\n " shape="box"] 62 -> 61 ; -61 [label="61: DeclStmt \n _fun_getY(2:int ,&__temp_return_n$3:class Y *) [line 82]\n n$4=*&__temp_return_n$3.f:int [line 82]\n *&d2:int =(1 / n$4) [line 82]\n REMOVE_TEMPS(n$4); [line 82]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_getY(2:int ,&__temp_return_n$3:class Y *) [line 77]\n n$4=*&__temp_return_n$3.f:int [line 77]\n *&d2:int =(1 / n$4) [line 77]\n REMOVE_TEMPS(n$4); [line 77]\n " shape="box"] 61 -> 60 ; -60 [label="60: Return Stmt \n n$0=*&d1:int [line 83]\n n$1=*&d2:int [line 83]\n *&return:int =(n$0 + n$1) [line 83]\n REMOVE_TEMPS(n$0,n$1); [line 83]\n NULLIFY(&d1,false); [line 83]\n NULLIFY(&d2,false); [line 83]\n NULLIFY(&__temp_return_n$3,false); [line 83]\n NULLIFY(&y1,false); [line 83]\n NULLIFY(&y2,false); [line 83]\n APPLY_ABSTRACTION; [line 83]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 78]\n NULLIFY(&d1,false); [line 78]\n NULLIFY(&d2,false); [line 78]\n NULLIFY(&__temp_return_n$3,false); [line 78]\n NULLIFY(&y1,false); [line 78]\n NULLIFY(&y2,false); [line 78]\n APPLY_ABSTRACTION; [line 78]\n " shape="box"] 60 -> 59 ; 59 [label="59: Exit copyY_moveY_div1 \n " color=yellow style=filled] -58 [label="58: Start copyY_moveY_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class Y d1:int y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&y2,&y1); [line 77]\n NULLIFY(&d1,false); [line 77]\n NULLIFY(&d2,false); [line 77]\n " color=yellow style=filled] +58 [label="58: Start copyY_moveY_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class Y d1:int y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&y2,&y1); [line 72]\n NULLIFY(&d1,false); [line 72]\n NULLIFY(&d2,false); [line 72]\n " color=yellow style=filled] 58 -> 65 ; -57 [label="57: DeclStmt \n _fun_X_X(&x1:class X *) [line 69]\n " shape="box"] +57 [label="57: DeclStmt \n _fun_X_X(&x1:class X *) [line 64]\n " shape="box"] 57 -> 56 ; -56 [label="56: BinaryOperatorStmt: Assign \n *&x1.f:int =1 [line 70]\n " shape="box"] +56 [label="56: BinaryOperatorStmt: Assign \n *&x1.f:int =1 [line 65]\n " shape="box"] 56 -> 55 ; -55 [label="55: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 71]\n " shape="box"] +55 [label="55: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 66]\n " shape="box"] 55 -> 54 ; -54 [label="54: DeclStmt \n n$5=*&x2.f:int [line 72]\n *&d1:int =(1 / n$5) [line 72]\n REMOVE_TEMPS(n$5); [line 72]\n " shape="box"] +54 [label="54: DeclStmt \n n$5=*&x2.f:int [line 67]\n *&d1:int =(1 / n$5) [line 67]\n REMOVE_TEMPS(n$5); [line 67]\n " shape="box"] 54 -> 53 ; -53 [label="53: DeclStmt \n _fun_getX(1:int ,&__temp_return_n$3:class X *) [line 73]\n n$4=*&__temp_return_n$3.f:int [line 73]\n *&d2:int =(1 / n$4) [line 73]\n REMOVE_TEMPS(n$4); [line 73]\n " shape="box"] +53 [label="53: DeclStmt \n _fun_getX(1:int ,&__temp_return_n$3:class X *) [line 68]\n n$4=*&__temp_return_n$3.f:int [line 68]\n *&d2:int =(1 / n$4) [line 68]\n REMOVE_TEMPS(n$4); [line 68]\n " shape="box"] 53 -> 52 ; -52 [label="52: Return Stmt \n n$0=*&d1:int [line 74]\n n$1=*&d2:int [line 74]\n *&return:int =(n$0 + n$1) [line 74]\n REMOVE_TEMPS(n$0,n$1); [line 74]\n NULLIFY(&d1,false); [line 74]\n NULLIFY(&d2,false); [line 74]\n NULLIFY(&__temp_return_n$3,false); [line 74]\n NULLIFY(&x1,false); [line 74]\n NULLIFY(&x2,false); [line 74]\n APPLY_ABSTRACTION; [line 74]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 69]\n NULLIFY(&d1,false); [line 69]\n NULLIFY(&d2,false); [line 69]\n NULLIFY(&__temp_return_n$3,false); [line 69]\n NULLIFY(&x1,false); [line 69]\n NULLIFY(&x2,false); [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="box"] 52 -> 51 ; 51 [label="51: Exit copyX_moveX_div1 \n " color=yellow style=filled] -50 [label="50: Start copyX_moveX_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class X d1:int x2:class X x1:class X \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&x2,&x1); [line 68]\n NULLIFY(&d1,false); [line 68]\n NULLIFY(&d2,false); [line 68]\n " color=yellow style=filled] +50 [label="50: Start copyX_moveX_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class X d1:int x2:class X x1:class X \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&x2,&x1); [line 63]\n NULLIFY(&d1,false); [line 63]\n NULLIFY(&d2,false); [line 63]\n " color=yellow style=filled] 50 -> 57 ; -49 [label="49: DeclStmt \n _fun_getY(2:int ,&SIL_materialize_temp__n$1:class Y *) [line 63]\n _fun_Y_Y(&y1:class Y *,&SIL_materialize_temp__n$1:class Y &) [line 63]\n " shape="box"] +49 [label="49: DeclStmt \n _fun_getY(2:int ,&SIL_materialize_temp__n$1:class Y *) [line 58]\n _fun_Y_Y(&y1:class Y *,&SIL_materialize_temp__n$1:class Y &) [line 58]\n " shape="box"] 49 -> 48 ; -48 [label="48: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 64]\n " shape="box"] +48 [label="48: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 59]\n " shape="box"] 48 -> 47 ; -47 [label="47: Return Stmt \n n$0=*&y2.f:int [line 65]\n *&return:int =(1 / n$0) [line 65]\n REMOVE_TEMPS(n$0); [line 65]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 65]\n NULLIFY(&y1,false); [line 65]\n NULLIFY(&y2,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] +47 [label="47: Return Stmt \n n$0=*&y2.f:int [line 60]\n *&return:int =(1 / n$0) [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 60]\n NULLIFY(&y1,false); [line 60]\n NULLIFY(&y2,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] 47 -> 46 ; 46 [label="46: Exit 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 SIL_materialize_temp__n$1:class Y \n DECLARE_LOCALS(&return,&y2,&y1,&SIL_materialize_temp__n$1); [line 62]\n " color=yellow style=filled] +45 [label="45: Start moveY_moveY_copyY_div0\nFormals: \nLocals: y2:class Y y1:class Y SIL_materialize_temp__n$1:class Y \n DECLARE_LOCALS(&return,&y2,&y1,&SIL_materialize_temp__n$1); [line 57]\n " color=yellow style=filled] 45 -> 49 ; -44 [label="44: Return Stmt \n _fun_getY(1:int ,&__temp_return_n$1:class Y *) [line 59]\n n$2=*&__temp_return_n$1.f:int [line 59]\n *&return:int =(1 / n$2) [line 59]\n REMOVE_TEMPS(n$2); [line 59]\n NULLIFY(&__temp_return_n$1,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] +44 [label="44: Return Stmt \n _fun_getY(1:int ,&__temp_return_n$1:class Y *) [line 55]\n n$2=*&__temp_return_n$1.f:int [line 55]\n *&return:int =(1 / n$2) [line 55]\n REMOVE_TEMPS(n$2); [line 55]\n NULLIFY(&__temp_return_n$1,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] 44 -> 43 ; 43 [label="43: Exit moveY_div0 \n " color=yellow style=filled] -42 [label="42: Start moveY_div0\nFormals: \nLocals: __temp_return_n$1:class Y \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 58]\n " color=yellow style=filled] +42 [label="42: Start moveY_div0\nFormals: \nLocals: __temp_return_n$1:class Y \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 55]\n " color=yellow style=filled] 42 -> 44 ; -41 [label="41: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 52]\n " shape="box"] +41 [label="41: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 49]\n " shape="box"] 41 -> 40 ; -40 [label="40: BinaryOperatorStmt: Assign \n *&y1.f:int =0 [line 53]\n " shape="box"] +40 [label="40: BinaryOperatorStmt: Assign \n *&y1.f:int =0 [line 50]\n " shape="box"] 40 -> 39 ; -39 [label="39: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 54]\n " shape="box"] +39 [label="39: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 51]\n " shape="box"] 39 -> 38 ; -38 [label="38: Return Stmt \n n$0=*&y2.f:int [line 55]\n *&return:int =(1 / n$0) [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n NULLIFY(&y1,false); [line 55]\n NULLIFY(&y2,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +38 [label="38: Return Stmt \n n$0=*&y2.f:int [line 52]\n *&return:int =(1 / n$0) [line 52]\n REMOVE_TEMPS(n$0); [line 52]\n NULLIFY(&y1,false); [line 52]\n NULLIFY(&y2,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] 38 -> 37 ; 37 [label="37: Exit 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 51]\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 -> 41 ; -35 [label="35: Return Stmt \n _fun_getX(0:int ,&__temp_return_n$1:class X *) [line 47]\n n$2=*&__temp_return_n$1.f:int [line 47]\n *&return:int =(1 / n$2) [line 47]\n REMOVE_TEMPS(n$2); [line 47]\n NULLIFY(&__temp_return_n$1,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +35 [label="35: Return Stmt \n _fun_getX(0:int ,&__temp_return_n$1:class X *) [line 46]\n n$2=*&__temp_return_n$1.f:int [line 46]\n *&return:int =(1 / n$2) [line 46]\n REMOVE_TEMPS(n$2); [line 46]\n NULLIFY(&__temp_return_n$1,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 35 -> 34 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp index c4e0f2005..3fc58761f 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp @@ -13,7 +13,7 @@ struct X { // copy constructor without init list X(const X& x) { f = x.f; } int f; - int div() { return 1/f; } + int div() { return 1 / f; } }; int div(int f) { return 1 / f; } @@ -21,37 +21,23 @@ int div(int f) { return 1 / f; } // passing by value doesn't work // int divX(X x) { return 1 / x.f; } -X getX(int a, int b) { return X(a,b); } +X getX(int a, int b) { return X(a, b); } int assign_temp_div0() { X x = X(0, 1); return x.div(); } -int temp_field_div0() { - return div(X(0,1).f); -} +int temp_field_div0() { return div(X(0, 1).f); } -int temp_field2_div0() { - return div(X(0).f); -} +int temp_field2_div0() { return div(X(0).f); } -int temp_method_div0() { - return X(0,1).div(); -} +int temp_method_div0() { return X(0, 1).div(); } -int getX_field_div0() { - return div(getX(0,1).f); -} +int getX_field_div0() { return div(getX(0, 1).f); } -int getX_method_div0() { - return getX(0,1).div(); -} +int getX_method_div0() { return getX(0, 1).div(); } -int temp_field_div1() { - return div(X(1,0).f); -} +int temp_field_div1() { return div(X(1, 0).f); } -int getX_field_div1() { - return div(getX(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 ee4c44fde..72d1747ab 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/constructors/temp_object.cpp.dot @@ -1,71 +1,71 @@ digraph iCFG { -43 [label="43: Return Stmt \n _fun_getX(1:int ,0:int ,&__temp_return_n$1:class X *) [line 56]\n n$2=*&__temp_return_n$1.f:int [line 56]\n n$3=_fun_div(n$2:int ) [line 56]\n *&return:int =n$3 [line 56]\n REMOVE_TEMPS(n$2,n$3); [line 56]\n NULLIFY(&__temp_return_n$1,false); [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] +43 [label="43: Return Stmt \n _fun_getX(1:int ,0:int ,&__temp_return_n$1:class X *) [line 43]\n n$2=*&__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 REMOVE_TEMPS(n$2,n$3); [line 43]\n NULLIFY(&__temp_return_n$1,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 43 -> 42 ; 42 [label="42: Exit getX_field_div1 \n " color=yellow style=filled] -41 [label="41: Start getX_field_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 55]\n " color=yellow style=filled] +41 [label="41: Start getX_field_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 43]\n " color=yellow style=filled] 41 -> 43 ; -40 [label="40: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,1:int ,0:int ) [line 52]\n n$1=*&__temp_construct_n$0.f:int [line 52]\n n$2=_fun_div(n$1:int ) [line 52]\n *&return:int =n$2 [line 52]\n REMOVE_TEMPS(n$1,n$2); [line 52]\n NULLIFY(&__temp_construct_n$0,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] +40 [label="40: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,1:int ,0:int ) [line 41]\n n$1=*&__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 REMOVE_TEMPS(n$1,n$2); [line 41]\n NULLIFY(&__temp_construct_n$0,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 40 -> 39 ; 39 [label="39: Exit temp_field_div1 \n " color=yellow style=filled] -38 [label="38: Start temp_field_div1\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 51]\n " color=yellow style=filled] +38 [label="38: Start temp_field_div1\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 41]\n " color=yellow style=filled] 38 -> 40 ; -37 [label="37: Return Stmt \n _fun_getX(0:int ,1:int ,&__temp_return_n$1:class X *) [line 48]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 48]\n *&return:int =n$2 [line 48]\n REMOVE_TEMPS(n$2); [line 48]\n NULLIFY(&__temp_return_n$1,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +37 [label="37: Return Stmt \n _fun_getX(0:int ,1:int ,&__temp_return_n$1:class X *) [line 39]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 39]\n *&return:int =n$2 [line 39]\n REMOVE_TEMPS(n$2); [line 39]\n NULLIFY(&__temp_return_n$1,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 37 -> 36 ; 36 [label="36: Exit getX_method_div0 \n " color=yellow style=filled] -35 [label="35: Start getX_method_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 47]\n " color=yellow style=filled] +35 [label="35: Start getX_method_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 39]\n " color=yellow style=filled] 35 -> 37 ; -34 [label="34: Return Stmt \n _fun_getX(0:int ,1:int ,&__temp_return_n$1:class X *) [line 44]\n n$2=*&__temp_return_n$1.f:int [line 44]\n n$3=_fun_div(n$2:int ) [line 44]\n *&return:int =n$3 [line 44]\n REMOVE_TEMPS(n$2,n$3); [line 44]\n NULLIFY(&__temp_return_n$1,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] +34 [label="34: Return Stmt \n _fun_getX(0:int ,1:int ,&__temp_return_n$1:class X *) [line 37]\n n$2=*&__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 REMOVE_TEMPS(n$2,n$3); [line 37]\n NULLIFY(&__temp_return_n$1,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 34 -> 33 ; 33 [label="33: Exit getX_field_div0 \n " color=yellow style=filled] -32 [label="32: Start getX_field_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 43]\n " color=yellow style=filled] +32 [label="32: Start getX_field_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 37]\n " color=yellow style=filled] 32 -> 34 ; -31 [label="31: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ,1:int ) [line 40]\n n$1=_fun_X_div(&__temp_construct_n$0:class X &) [line 40]\n *&return:int =n$1 [line 40]\n REMOVE_TEMPS(n$1); [line 40]\n NULLIFY(&__temp_construct_n$0,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] +31 [label="31: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ,1:int ) [line 35]\n n$1=_fun_X_div(&__temp_construct_n$0:class X &) [line 35]\n *&return:int =n$1 [line 35]\n REMOVE_TEMPS(n$1); [line 35]\n NULLIFY(&__temp_construct_n$0,false); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 31 -> 30 ; 30 [label="30: Exit temp_method_div0 \n " color=yellow style=filled] -29 [label="29: Start temp_method_div0\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 39]\n " color=yellow style=filled] +29 [label="29: Start temp_method_div0\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 35]\n " color=yellow style=filled] 29 -> 31 ; -28 [label="28: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ) [line 36]\n n$1=*&__temp_construct_n$0.f:int [line 36]\n n$2=_fun_div(n$1:int ) [line 36]\n *&return:int =n$2 [line 36]\n REMOVE_TEMPS(n$1,n$2); [line 36]\n NULLIFY(&__temp_construct_n$0,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] +28 [label="28: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ) [line 33]\n n$1=*&__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 REMOVE_TEMPS(n$1,n$2); [line 33]\n NULLIFY(&__temp_construct_n$0,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 28 -> 27 ; 27 [label="27: Exit temp_field2_div0 \n " color=yellow style=filled] -26 [label="26: Start temp_field2_div0\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 35]\n " color=yellow style=filled] +26 [label="26: Start temp_field2_div0\nFormals: \nLocals: __temp_construct_n$0:class X \n DECLARE_LOCALS(&return,&__temp_construct_n$0); [line 33]\n " color=yellow style=filled] 26 -> 28 ; -25 [label="25: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ,1:int ) [line 32]\n n$1=*&__temp_construct_n$0.f:int [line 32]\n n$2=_fun_div(n$1:int ) [line 32]\n *&return:int =n$2 [line 32]\n REMOVE_TEMPS(n$1,n$2); [line 32]\n NULLIFY(&__temp_construct_n$0,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +25 [label="25: Return Stmt \n _fun_X_X(&__temp_construct_n$0:class X *,0:int ,1:int ) [line 31]\n n$1=*&__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 REMOVE_TEMPS(n$1,n$2); [line 31]\n NULLIFY(&__temp_construct_n$0,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 25 -> 24 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp b/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp index 8aff42e99..7bbbf2f16 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp @@ -11,10 +11,6 @@ struct X { ~X() {} }; -void deleteX(X *x) { - delete x; -} +void deleteX(X* x) { delete x; } -void deleteInt(int *x) { - delete x; -} +void deleteInt(int* x) { delete x; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp.dot index 228e06d85..0a4104c95 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/destructors/call_on_delete.cpp.dot @@ -1,16 +1,16 @@ digraph iCFG { -8 [label="8: Call delete \n n$0=*&x:int * [line 19]\n _fun___delete(n$0:int *) [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n NULLIFY(&x,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +8 [label="8: Call delete \n n$0=*&x:int * [line 16]\n _fun___delete(n$0:int *) [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&x,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 8 -> 7 ; 7 [label="7: Exit deleteInt \n " color=yellow style=filled] -6 [label="6: Start deleteInt\nFormals: x:int *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] +6 [label="6: Start deleteInt\nFormals: x:int *\nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: Call delete \n n$0=*&x:class X * [line 15]\n _fun_X_~X(n$0:class X *) [line 15]\n _fun___delete(n$0:class X *) [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&x,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +5 [label="5: Call delete \n n$0=*&x:class X * [line 14]\n _fun_X_~X(n$0:class X *) [line 14]\n _fun___delete(n$0:class X *) [line 14]\n REMOVE_TEMPS(n$0); [line 14]\n NULLIFY(&x,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 5 -> 4 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp b/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp index 9e7cbbf6c..f80c2bf59 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp @@ -9,9 +9,7 @@ struct A { int f; - ~A() { - f = 0; - } + ~A() { f = 0; } }; struct B { @@ -19,6 +17,4 @@ struct B { ~B(); }; -B::~B() { - f = 1; -} +B::~B() { f = 1; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp.dot index 13c218382..204df8e48 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/destructors/simple_decl.cpp.dot @@ -1,16 +1,16 @@ digraph iCFG { -6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class B * [line 23]\n *n$0.f:int =1 [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&this,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$0=*&this:class B * [line 20]\n *n$0.f:int =1 [line 20]\n REMOVE_TEMPS(n$0); [line 20]\n NULLIFY(&this,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit B_~B \n " color=yellow style=filled] -4 [label="4: Start B_~B\nFormals: this:class B *\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] +4 [label="4: Start B_~B\nFormals: this:class B *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class A * [line 13]\n *n$0.f:int =0 [line 13]\n REMOVE_TEMPS(n$0); [line 13]\n NULLIFY(&this,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class A * [line 12]\n *n$0.f:int =0 [line 12]\n REMOVE_TEMPS(n$0); [line 12]\n NULLIFY(&this,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/include_header/header.h b/infer/tests/codetoanalyze/cpp/frontend/include_header/header.h index 5754b2a41..bf3198bef 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/include_header/header.h +++ b/infer/tests/codetoanalyze/cpp/frontend/include_header/header.h @@ -11,12 +11,14 @@ struct A { int div0() { return 1 / 0; } }; -template +template struct B { int div0() { return 1 / 0; } }; int div0_fun() { return 1 / 0; } -template -int div0_templ() { return 1 / 0; } +template +int div0_templ() { + return 1 / 0; +} diff --git a/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp b/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp index e2ca0d271..a06d74dfb 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp @@ -20,10 +20,6 @@ void div0_B_A() { b.div0(); } -void div0_templ_int() { - div0_templ(); -} +void div0_templ_int() { div0_templ(); } -int div0_templ_A() { - div0_templ(); -} +int div0_templ_A() { div0_templ(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp.dot index 065e7afde..fdd1bb736 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/include_header/include_templ.cpp.dot @@ -1,16 +1,16 @@ digraph iCFG { -36 [label="36: Call _fun_div0_templ \n n$0=_fun_div0_templ() [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +36 [label="36: Call _fun_div0_templ \n n$0=_fun_div0_templ() [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 36 -> 35 ; 35 [label="35: Exit div0_templ_A \n " color=yellow style=filled] -34 [label="34: Start div0_templ_A\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] +34 [label="34: Start div0_templ_A\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 34 -> 36 ; -33 [label="33: Call _fun_div0_templ \n n$0=_fun_div0_templ() [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +33 [label="33: Call _fun_div0_templ \n n$0=_fun_div0_templ() [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 33 -> 32 ; @@ -51,7 +51,7 @@ digraph iCFG { 23 -> 26 ; -22 [label="22: Return Stmt \n *&return:int =(1 / 0) [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +22 [label="22: Return Stmt \n *&return:int =(1 / 0) [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 22 -> 21 ; @@ -62,7 +62,7 @@ digraph iCFG { 20 -> 22 ; -19 [label="19: Return Stmt \n *&return:int =(1 / 0) [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +19 [label="19: Return Stmt \n *&return:int =(1 / 0) [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 19 -> 18 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp b/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp index fc99c1301..2e5d0d716 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp @@ -8,16 +8,10 @@ */ class A { -public: - int meth_with_self(int self, int b) { - return self + b; - } + public: + int meth_with_self(int self, int b) { return self + b; } }; -int fun_with_self(int self) { - return self; -} +int fun_with_self(int self) { return self; } -int test(A *a) { - return a->meth_with_self(1, 2) + fun_with_self(10); -} +int test(A* a) { return a->meth_with_self(1, 2) + fun_with_self(10); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp.dot index 1727fd0fe..78fc18d42 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/keywords/self_parameter.cpp.dot @@ -1,27 +1,27 @@ digraph iCFG { -9 [label="9: Return Stmt \n n$0=*&a:class A * [line 22]\n n$1=_fun_A_meth_with_self(n$0:class A *,1:int ,2:int ) [line 22]\n n$2=_fun_fun_with_self(10:int ) [line 22]\n *&return:int =(n$1 + n$2) [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n NULLIFY(&a,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +9 [label="9: Return Stmt \n n$0=*&a:class A * [line 17]\n n$1=_fun_A_meth_with_self(n$0:class A *,1:int ,2:int ) [line 17]\n n$2=_fun_fun_with_self(10:int ) [line 17]\n *&return:int =(n$1 + n$2) [line 17]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 17]\n NULLIFY(&a,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit test \n " color=yellow style=filled] -7 [label="7: Start test\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +7 [label="7: Start test\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Return Stmt \n n$0=*&self:int [line 18]\n *&return:int =n$0 [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&self,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&self:int [line 15]\n *&return:int =n$0 [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&self,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit fun_with_self \n " color=yellow style=filled] -4 [label="4: Start fun_with_self\nFormals: self:int \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +4 [label="4: Start fun_with_self\nFormals: self:int \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&self:int [line 13]\n n$1=*&b:int [line 13]\n *&return:int =(n$0 + n$1) [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n NULLIFY(&b,false); [line 13]\n NULLIFY(&self,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&self:int [line 12]\n n$1=*&b:int [line 12]\n *&return:int =(n$0 + n$1) [line 12]\n REMOVE_TEMPS(n$0,n$1); [line 12]\n NULLIFY(&b,false); [line 12]\n NULLIFY(&self,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp b/infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp index fac69c5c7..46c9ee91e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/literals/nullptr.cpp @@ -7,4 +7,4 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int* getPtr() {return nullptr;} +int* getPtr() { return nullptr; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp b/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp index 0faa0cd89..ffc1acc17 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp @@ -7,12 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -enum ENUM { - val1, - val2 -}; +enum ENUM { val1, val2 }; -template T get() { +template +T get() { return T(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp.dot index cc75cfad5..ab2ddcca7 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/literals/scalar_value_init.cpp.dot @@ -1,87 +1,87 @@ digraph iCFG { -23 [label="23: DeclStmt \n n$3=_fun_get() [line 20]\n *&i:int =n$3 [line 20]\n REMOVE_TEMPS(n$3); [line 20]\n NULLIFY(&i,false); [line 20]\n " shape="box"] +23 [label="23: DeclStmt \n n$3=_fun_get() [line 18]\n *&i:int =n$3 [line 18]\n REMOVE_TEMPS(n$3); [line 18]\n NULLIFY(&i,false); [line 18]\n " shape="box"] 23 -> 22 ; -22 [label="22: DeclStmt \n n$2=_fun_get() [line 21]\n *&f:float =n$2 [line 21]\n REMOVE_TEMPS(n$2); [line 21]\n NULLIFY(&f,false); [line 21]\n " shape="box"] +22 [label="22: DeclStmt \n n$2=_fun_get() [line 19]\n *&f:float =n$2 [line 19]\n REMOVE_TEMPS(n$2); [line 19]\n NULLIFY(&f,false); [line 19]\n " shape="box"] 22 -> 21 ; -21 [label="21: DeclStmt \n n$1=_fun_get() [line 22]\n *&fp:float *=n$1 [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n NULLIFY(&fp,false); [line 22]\n " shape="box"] +21 [label="21: DeclStmt \n n$1=_fun_get() [line 20]\n *&fp:float *=n$1 [line 20]\n REMOVE_TEMPS(n$1); [line 20]\n NULLIFY(&fp,false); [line 20]\n " shape="box"] 21 -> 20 ; -20 [label="20: Call _fun_get \n _fun_get() [line 23]\n " shape="box"] +20 [label="20: Call _fun_get \n _fun_get() [line 21]\n " shape="box"] 20 -> 19 ; -19 [label="19: DeclStmt \n n$0=_fun_get() [line 24]\n *&x:int =n$0 [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n NULLIFY(&x,false); [line 24]\n " shape="box"] +19 [label="19: DeclStmt \n n$0=_fun_get() [line 22]\n *&x:int =n$0 [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&x,false); [line 22]\n " shape="box"] 19 -> 18 ; -18 [label="18: DeclStmt \n *&f2:float =0.000000 [line 25]\n NULLIFY(&f2,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +18 [label="18: DeclStmt \n *&f2:float =0.000000 [line 23]\n NULLIFY(&f2,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit test \n " color=yellow style=filled] -16 [label="16: Start test\nFormals: \nLocals: f2:float x:int fp:float * f:float i:int \n DECLARE_LOCALS(&return,&f2,&x,&fp,&f,&i); [line 19]\n NULLIFY(&f,false); [line 19]\n NULLIFY(&f2,false); [line 19]\n NULLIFY(&fp,false); [line 19]\n NULLIFY(&i,false); [line 19]\n NULLIFY(&x,false); [line 19]\n " color=yellow style=filled] +16 [label="16: Start test\nFormals: \nLocals: f2:float x:int fp:float * f:float i:int \n DECLARE_LOCALS(&return,&f2,&x,&fp,&f,&i); [line 17]\n NULLIFY(&f,false); [line 17]\n NULLIFY(&f2,false); [line 17]\n NULLIFY(&fp,false); [line 17]\n NULLIFY(&i,false); [line 17]\n NULLIFY(&x,false); [line 17]\n " color=yellow style=filled] 16 -> 23 ; -15 [label="15: Return Stmt \n *&return:int =0 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +15 [label="15: Return Stmt \n *&return:int =0 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit get \n " color=yellow style=filled] -13 [label="13: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +13 [label="13: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Return Stmt \n *&return:void =-1 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +12 [label="12: Return Stmt \n *&return:void =-1 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit get \n " color=yellow style=filled] -10 [label="10: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +10 [label="10: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 10 -> 12 ; -9 [label="9: Return Stmt \n *&return:float *=null [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +9 [label="9: Return Stmt \n *&return:float *=null [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit get \n " color=yellow style=filled] -7 [label="7: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +7 [label="7: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Return Stmt \n *&return:float =0.000000 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +6 [label="6: Return Stmt \n *&return:float =0.000000 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit get \n " color=yellow style=filled] -4 [label="4: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +4 [label="4: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit get \n " color=yellow style=filled] -1 [label="1: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +1 [label="1: Start get\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp b/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp index 5439f0fa8..4a99d7f67 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp @@ -7,27 +7,34 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - // iterator struct iterator { - int val; - iterator operator++() { val += 1; return *this; } - int operator*() { return val; } // this should return type of values stored in vec + int val; + iterator operator++() { + val += 1; + return *this; + } + int operator*() { + return val; + } // this should return type of values stored in vec }; bool operator!=(iterator i1, iterator i2) { return i1.val != i2.val; } struct vec { - vec(int size) { begin_.val = 0; end_.val = size; } - iterator begin() { return begin_; } - iterator end() { return end_; } - - iterator begin_; - iterator end_; + vec(int size) { + begin_.val = 0; + end_.val = size; + } + iterator begin() { return begin_; } + iterator end() { return end_; } + + iterator begin_; + iterator end_; }; void test() { - vec vector(10); - for (int value : vector) { - int temp = value * value + 10; - } + vec vector(10); + for (int value : vector) { + int temp = value * value + 10; + } } diff --git a/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp.dot index ec2954b9d..5aa30e451 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/loops/foreach1.cpp.dot @@ -1,42 +1,42 @@ digraph iCFG { -43 [label="43: DeclStmt \n _fun_vec_vec(&vector:class vec *,10:int ) [line 29]\n " shape="box"] +43 [label="43: DeclStmt \n _fun_vec_vec(&vector:class vec *,10:int ) [line 36]\n " shape="box"] 43 -> 42 ; -42 [label="42: DeclStmt \n *&__range:class vec &=&vector [line 30]\n " shape="box"] +42 [label="42: DeclStmt \n *&__range:class vec &=&vector [line 37]\n " shape="box"] 42 -> 35 ; -41 [label="41: DeclStmt \n n$13=_fun_iterator_operator*(&__begin:class iterator &) [line 30]\n *&value:int =n$13 [line 30]\n REMOVE_TEMPS(n$13); [line 30]\n " shape="box"] +41 [label="41: DeclStmt \n n$13=_fun_iterator_operator*(&__begin:class iterator &) [line 37]\n *&value:int =n$13 [line 37]\n REMOVE_TEMPS(n$13); [line 37]\n " shape="box"] 41 -> 40 ; -40 [label="40: DeclStmt \n n$11=*&value:int [line 31]\n n$12=*&value:int [line 31]\n *&temp:int =((n$11 * n$12) + 10) [line 31]\n REMOVE_TEMPS(n$11,n$12); [line 31]\n NULLIFY(&temp,false); [line 31]\n NULLIFY(&value,false); [line 31]\n " shape="box"] +40 [label="40: DeclStmt \n n$11=*&value:int [line 38]\n n$12=*&value:int [line 38]\n *&temp:int =((n$11 * n$12) + 10) [line 38]\n REMOVE_TEMPS(n$11,n$12); [line 38]\n NULLIFY(&temp,false); [line 38]\n NULLIFY(&value,false); [line 38]\n " shape="box"] 40 -> 36 ; -39 [label="39: Prune (false branch) \n PRUNE((n$10 == 0), false); [line 30]\n REMOVE_TEMPS(n$10); [line 30]\n NULLIFY(&SIL_materialize_temp__n$0,false); [line 30]\n NULLIFY(&SIL_materialize_temp__n$3,false); [line 30]\n NULLIFY(&__begin,false); [line 30]\n NULLIFY(&__end,false); [line 30]\n NULLIFY(&__temp_construct_n$8,false); [line 30]\n NULLIFY(&__temp_construct_n$9,false); [line 30]\n NULLIFY(&__temp_return_n$7,false); [line 30]\n NULLIFY(&vector,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="invhouse"] +39 [label="39: Prune (false branch) \n PRUNE((n$10 == 0), false); [line 37]\n REMOVE_TEMPS(n$10); [line 37]\n NULLIFY(&SIL_materialize_temp__n$0,false); [line 37]\n NULLIFY(&SIL_materialize_temp__n$3,false); [line 37]\n NULLIFY(&__begin,false); [line 37]\n NULLIFY(&__end,false); [line 37]\n NULLIFY(&__temp_construct_n$8,false); [line 37]\n NULLIFY(&__temp_construct_n$9,false); [line 37]\n NULLIFY(&__temp_return_n$7,false); [line 37]\n NULLIFY(&vector,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="invhouse"] 39 -> 32 ; -38 [label="38: Prune (true branch) \n PRUNE((n$10 != 0), true); [line 30]\n REMOVE_TEMPS(n$10); [line 30]\n " shape="invhouse"] +38 [label="38: Prune (true branch) \n PRUNE((n$10 != 0), true); [line 37]\n REMOVE_TEMPS(n$10); [line 37]\n " shape="invhouse"] 38 -> 41 ; -37 [label="37: Call _fun_operator!= \n _fun_iterator_iterator(&__temp_construct_n$8:class iterator *,&__begin:class iterator &) [line 30]\n _fun_iterator_iterator(&__temp_construct_n$9:class iterator *,&__end:class iterator &) [line 30]\n n$10=_fun_operator!=(&__temp_construct_n$8:class iterator ,&__temp_construct_n$9:class iterator ) [line 30]\n " shape="box"] +37 [label="37: Call _fun_operator!= \n _fun_iterator_iterator(&__temp_construct_n$8:class iterator *,&__begin:class iterator &) [line 37]\n _fun_iterator_iterator(&__temp_construct_n$9:class iterator *,&__end:class iterator &) [line 37]\n n$10=_fun_operator!=(&__temp_construct_n$8:class iterator ,&__temp_construct_n$9:class iterator ) [line 37]\n " shape="box"] 37 -> 38 ; 37 -> 39 ; -36 [label="36: Call _fun_iterator_operator++ \n _fun_iterator_operator++(&__begin:class iterator &,&__temp_return_n$7:class iterator *) [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +36 [label="36: Call _fun_iterator_operator++ \n _fun_iterator_operator++(&__begin:class iterator &,&__temp_return_n$7:class iterator *) [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 36 -> 33 ; -35 [label="35: DeclStmt \n n$4=*&__range:class vec & [line 30]\n _fun_vec_begin(n$4:class vec &,&SIL_materialize_temp__n$3:class iterator *) [line 30]\n _fun_iterator_iterator(&__begin:class iterator *,&SIL_materialize_temp__n$3:class iterator &) [line 30]\n REMOVE_TEMPS(n$4); [line 30]\n " shape="box"] +35 [label="35: DeclStmt \n n$4=*&__range:class vec & [line 37]\n _fun_vec_begin(n$4:class vec &,&SIL_materialize_temp__n$3:class iterator *) [line 37]\n _fun_iterator_iterator(&__begin:class iterator *,&SIL_materialize_temp__n$3:class iterator &) [line 37]\n REMOVE_TEMPS(n$4); [line 37]\n " shape="box"] 35 -> 34 ; -34 [label="34: DeclStmt \n n$1=*&__range:class vec & [line 30]\n _fun_vec_end(n$1:class vec &,&SIL_materialize_temp__n$0:class iterator *) [line 30]\n _fun_iterator_iterator(&__end:class iterator *,&SIL_materialize_temp__n$0:class iterator &) [line 30]\n REMOVE_TEMPS(n$1); [line 30]\n NULLIFY(&__range,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +34 [label="34: DeclStmt \n n$1=*&__range:class vec & [line 37]\n _fun_vec_end(n$1:class vec &,&SIL_materialize_temp__n$0:class iterator *) [line 37]\n _fun_iterator_iterator(&__end:class iterator *,&SIL_materialize_temp__n$0:class iterator &) [line 37]\n REMOVE_TEMPS(n$1); [line 37]\n NULLIFY(&__range,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 34 -> 33 ; @@ -47,103 +47,103 @@ digraph iCFG { 32 [label="32: Exit test \n " color=yellow style=filled] -31 [label="31: Start test\nFormals: \nLocals: __end:class iterator SIL_materialize_temp__n$0:class iterator __begin:class iterator SIL_materialize_temp__n$3:class iterator __temp_return_n$7:class iterator __temp_construct_n$8:class iterator __temp_construct_n$9:class iterator temp:int value:int __range:class vec & vector:class vec \n DECLARE_LOCALS(&return,&__end,&SIL_materialize_temp__n$0,&__begin,&SIL_materialize_temp__n$3,&__temp_return_n$7,&__temp_construct_n$8,&__temp_construct_n$9,&temp,&value,&__range,&vector); [line 28]\n NULLIFY(&__range,false); [line 28]\n NULLIFY(&temp,false); [line 28]\n NULLIFY(&value,false); [line 28]\n " color=yellow style=filled] +31 [label="31: Start test\nFormals: \nLocals: __end:class iterator SIL_materialize_temp__n$0:class iterator __begin:class iterator SIL_materialize_temp__n$3:class iterator __temp_return_n$7:class iterator __temp_construct_n$8:class iterator __temp_construct_n$9:class iterator temp:int value:int __range:class vec & vector:class vec \n DECLARE_LOCALS(&return,&__end,&SIL_materialize_temp__n$0,&__begin,&SIL_materialize_temp__n$3,&__temp_return_n$7,&__temp_construct_n$8,&__temp_construct_n$9,&temp,&value,&__range,&vector); [line 35]\n NULLIFY(&__range,false); [line 35]\n NULLIFY(&temp,false); [line 35]\n NULLIFY(&value,false); [line 35]\n " color=yellow style=filled] 31 -> 43 ; -30 [label="30: Return Stmt \n n$0=*&__return_param:class iterator * [line 22]\n n$1=*&this:class vec * [line 22]\n _fun_iterator_iterator(n$0:class iterator *,n$1.end_:class iterator &) [line 22]\n REMOVE_TEMPS(n$0,n$1); [line 22]\n NULLIFY(&__return_param,false); [line 22]\n NULLIFY(&this,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +30 [label="30: Return Stmt \n n$0=*&__return_param:class iterator * [line 29]\n n$1=*&this:class vec * [line 29]\n _fun_iterator_iterator(n$0:class iterator *,n$1.end_:class iterator &) [line 29]\n REMOVE_TEMPS(n$0,n$1); [line 29]\n NULLIFY(&__return_param,false); [line 29]\n NULLIFY(&this,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 30 -> 29 ; 29 [label="29: Exit vec_end \n " color=yellow style=filled] -28 [label="28: Start vec_end\nFormals: this:class vec * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled] +28 [label="28: Start vec_end\nFormals: this:class vec * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] 28 -> 30 ; -27 [label="27: Return Stmt \n n$0=*&__return_param:class iterator * [line 21]\n n$1=*&this:class vec * [line 21]\n _fun_iterator_iterator(n$0:class iterator *,n$1.begin_:class iterator &) [line 21]\n REMOVE_TEMPS(n$0,n$1); [line 21]\n NULLIFY(&__return_param,false); [line 21]\n NULLIFY(&this,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +27 [label="27: Return Stmt \n n$0=*&__return_param:class iterator * [line 28]\n n$1=*&this:class vec * [line 28]\n _fun_iterator_iterator(n$0:class iterator *,n$1.begin_:class iterator &) [line 28]\n REMOVE_TEMPS(n$0,n$1); [line 28]\n NULLIFY(&__return_param,false); [line 28]\n NULLIFY(&this,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit vec_begin \n " color=yellow style=filled] -25 [label="25: Start vec_begin\nFormals: this:class vec * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +25 [label="25: Start vec_begin\nFormals: this:class vec * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 25 -> 27 ; -24 [label="24: Constructor Init \n n$4=*&this:class vec * [line 20]\n _fun_iterator_iterator(n$4.begin_:class iterator *) [line 20]\n REMOVE_TEMPS(n$4); [line 20]\n " shape="box"] +24 [label="24: Constructor Init \n n$4=*&this:class vec * [line 24]\n _fun_iterator_iterator(n$4.begin_:class iterator *) [line 24]\n REMOVE_TEMPS(n$4); [line 24]\n " shape="box"] 24 -> 23 ; -23 [label="23: Constructor Init \n n$3=*&this:class vec * [line 20]\n _fun_iterator_iterator(n$3.end_:class iterator *) [line 20]\n REMOVE_TEMPS(n$3); [line 20]\n " shape="box"] +23 [label="23: Constructor Init \n n$3=*&this:class vec * [line 24]\n _fun_iterator_iterator(n$3.end_:class iterator *) [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n " shape="box"] 23 -> 22 ; -22 [label="22: BinaryOperatorStmt: Assign \n n$2=*&this:class vec * [line 20]\n *n$2.begin_.val:int =0 [line 20]\n REMOVE_TEMPS(n$2); [line 20]\n " shape="box"] +22 [label="22: BinaryOperatorStmt: Assign \n n$2=*&this:class vec * [line 25]\n *n$2.begin_.val:int =0 [line 25]\n REMOVE_TEMPS(n$2); [line 25]\n " shape="box"] 22 -> 21 ; -21 [label="21: BinaryOperatorStmt: Assign \n n$0=*&this:class vec * [line 20]\n n$1=*&size:int [line 20]\n *n$0.end_.val:int =n$1 [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&size,false); [line 20]\n NULLIFY(&this,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +21 [label="21: BinaryOperatorStmt: Assign \n n$0=*&this:class vec * [line 26]\n n$1=*&size:int [line 26]\n *n$0.end_.val:int =n$1 [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&size,false); [line 26]\n NULLIFY(&this,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit vec_vec \n " color=yellow style=filled] -19 [label="19: Start vec_vec\nFormals: this:class vec * size:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] +19 [label="19: Start vec_vec\nFormals: this:class vec * size:int \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 19 -> 24 ; -18 [label="18: Return Stmt \n n$0=*&i1.val:int [line 17]\n n$1=*&i2.val:int [line 17]\n *&return:_Bool =(n$0 != n$1) [line 17]\n REMOVE_TEMPS(n$0,n$1); [line 17]\n NULLIFY(&i1,false); [line 17]\n NULLIFY(&i2,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&i1.val:int [line 21]\n n$1=*&i2.val:int [line 21]\n *&return:_Bool =(n$0 != n$1) [line 21]\n REMOVE_TEMPS(n$0,n$1); [line 21]\n NULLIFY(&i1,false); [line 21]\n NULLIFY(&i2,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit operator!= \n " color=yellow style=filled] -16 [label="16: Start operator!=\nFormals: i1:class iterator i2:class iterator \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +16 [label="16: Start operator!=\nFormals: i1:class iterator i2:class iterator \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 16 -> 18 ; -15 [label="15: Constructor Init \n n$0=*&this:class iterator * [line 12]\n n$1=*&__param_0:class iterator & [line 12]\n n$2=*n$1.val:int [line 12]\n *n$0.val:int =n$2 [line 12]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 12]\n NULLIFY(&__param_0,false); [line 12]\n NULLIFY(&this,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] +15 [label="15: Constructor Init \n n$0=*&this:class iterator * [line 11]\n n$1=*&__param_0:class iterator & [line 11]\n n$2=*n$1.val:int [line 11]\n *n$0.val:int =n$2 [line 11]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 11]\n NULLIFY(&__param_0,false); [line 11]\n NULLIFY(&this,false); [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit iterator_iterator \n " color=yellow style=filled] -13 [label="13: Start iterator_iterator\nFormals: this:class iterator * __param_0:class iterator &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +13 [label="13: Start iterator_iterator\nFormals: this:class iterator * __param_0:class iterator &\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Constructor Init \n n$0=*&this:class iterator * [line 12]\n n$1=*&__param_0:class iterator & [line 12]\n n$2=*n$1.val:int [line 12]\n *n$0.val:int =n$2 [line 12]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 12]\n NULLIFY(&__param_0,false); [line 12]\n NULLIFY(&this,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"] +12 [label="12: Constructor Init \n n$0=*&this:class iterator * [line 11]\n n$1=*&__param_0:class iterator & [line 11]\n n$2=*n$1.val:int [line 11]\n *n$0.val:int =n$2 [line 11]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 11]\n NULLIFY(&__param_0,false); [line 11]\n NULLIFY(&this,false); [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit iterator_iterator \n " color=yellow style=filled] -10 [label="10: Start iterator_iterator\nFormals: this:class iterator * __param_0:class iterator &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] +10 [label="10: Start iterator_iterator\nFormals: this:class iterator * __param_0:class iterator &\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled] 10 -> 12 ; 9 [label="9: Exit iterator_iterator \n " color=yellow style=filled] -8 [label="8: Start iterator_iterator\nFormals: this:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n NULLIFY(&this,false); [line 12]\n " color=yellow style=filled] +8 [label="8: Start iterator_iterator\nFormals: this:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n NULLIFY(&this,false); [line 11]\n " color=yellow style=filled] 8 -> 9 ; -7 [label="7: Return Stmt \n n$0=*&this:class iterator * [line 15]\n n$1=*n$0.val:int [line 15]\n *&return:int =n$1 [line 15]\n REMOVE_TEMPS(n$0,n$1); [line 15]\n NULLIFY(&this,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +7 [label="7: Return Stmt \n n$0=*&this:class iterator * [line 18]\n n$1=*n$0.val:int [line 18]\n *&return:int =n$1 [line 18]\n REMOVE_TEMPS(n$0,n$1); [line 18]\n NULLIFY(&this,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 7 -> 6 ; 6 [label="6: Exit iterator_operator* \n " color=yellow style=filled] -5 [label="5: Start iterator_operator*\nFormals: this:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n " color=yellow style=filled] +5 [label="5: Start iterator_operator*\nFormals: this:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 5 -> 7 ; @@ -151,14 +151,14 @@ digraph iCFG { 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&__return_param:class iterator * [line 14]\n n$1=*&this:class iterator * [line 14]\n _fun_iterator_iterator(n$0:class iterator *,n$1:class iterator &) [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&__return_param,false); [line 14]\n NULLIFY(&this,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&__return_param:class iterator * [line 15]\n n$1=*&this:class iterator * [line 15]\n _fun_iterator_iterator(n$0:class iterator *,n$1:class iterator &) [line 15]\n REMOVE_TEMPS(n$0,n$1); [line 15]\n NULLIFY(&__return_param,false); [line 15]\n NULLIFY(&this,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit iterator_operator++ \n " color=yellow style=filled] -1 [label="1: Start iterator_operator++\nFormals: this:class iterator * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +1 [label="1: Start iterator_operator++\nFormals: this:class iterator * __return_param:class iterator *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] 1 -> 4 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp index b8c52c0e7..1f9bb3c37 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp @@ -12,13 +12,19 @@ struct X { operator bool() { return b_; } int f_; bool b_; - X(int f, bool b) { f_ = f; b_ = b; } - X(const X& x) { f_ = x.f_; b_ = x.b_; } + X(int f, bool b) { + f_ = f; + b_ = b; + } + X(const X& x) { + f_ = x.f_; + b_ = x.b_; + } }; struct Y { // operator returning struct type - operator X() { return X(f,b); } + operator X() { return X(f, b); } int f; int b; }; 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 062517076..2fa95b85a 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/conversion_operator.cpp.dot @@ -1,25 +1,25 @@ digraph iCFG { -61 [label="61: DeclStmt \n _fun_X_X(&x:class X *,1:int ,1:_Bool ) [line 56]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_X_X(&x:class X *,1:int ,1:_Bool ) [line 62]\n " shape="box"] 61 -> 56 ; -60 [label="60: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 58]\n *&v:int =n$3 [line 58]\n REMOVE_TEMPS(n$3); [line 58]\n " shape="box"] +60 [label="60: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 64]\n *&v:int =n$3 [line 64]\n REMOVE_TEMPS(n$3); [line 64]\n " shape="box"] 60 -> 59 ; -59 [label="59: Return Stmt \n n$2=*&v:int [line 59]\n *&return:int =(1 / n$2) [line 59]\n REMOVE_TEMPS(n$2); [line 59]\n NULLIFY(&v,false); [line 59]\n NULLIFY(&x,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] +59 [label="59: Return Stmt \n n$2=*&v:int [line 65]\n *&return:int =(1 / n$2) [line 65]\n REMOVE_TEMPS(n$2); [line 65]\n NULLIFY(&v,false); [line 65]\n NULLIFY(&x,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] 59 -> 53 ; -58 [label="58: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 57]\n REMOVE_TEMPS(n$1); [line 57]\n " shape="invhouse"] +58 [label="58: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 63]\n REMOVE_TEMPS(n$1); [line 63]\n " shape="invhouse"] 58 -> 55 ; -57 [label="57: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 57]\n REMOVE_TEMPS(n$1); [line 57]\n " shape="invhouse"] +57 [label="57: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 63]\n REMOVE_TEMPS(n$1); [line 63]\n " shape="invhouse"] 57 -> 60 ; -56 [label="56: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 57]\n " shape="box"] +56 [label="56: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 63]\n " shape="box"] 56 -> 57 ; @@ -28,38 +28,38 @@ digraph iCFG { 55 -> 54 ; -54 [label="54: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 61]\n *&return:int =n$0 [line 61]\n REMOVE_TEMPS(n$0); [line 61]\n NULLIFY(&x,false); [line 61]\n APPLY_ABSTRACTION; [line 61]\n " shape="box"] +54 [label="54: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 67]\n *&return:int =n$0 [line 67]\n REMOVE_TEMPS(n$0); [line 67]\n NULLIFY(&x,false); [line 67]\n APPLY_ABSTRACTION; [line 67]\n " shape="box"] 54 -> 53 ; 53 [label="53: Exit 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 55]\n NULLIFY(&v,false); [line 55]\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 NULLIFY(&v,false); [line 61]\n " color=yellow style=filled] 52 -> 61 ; -51 [label="51: DeclStmt \n _fun_X_X(&x:class X *,0:int ,0:_Bool ) [line 47]\n " shape="box"] +51 [label="51: DeclStmt \n _fun_X_X(&x:class X *,0:int ,0:_Bool ) [line 53]\n " shape="box"] 51 -> 46 ; -50 [label="50: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 49]\n *&v:int =n$3 [line 49]\n REMOVE_TEMPS(n$3); [line 49]\n " shape="box"] +50 [label="50: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 55]\n *&v:int =n$3 [line 55]\n REMOVE_TEMPS(n$3); [line 55]\n " shape="box"] 50 -> 49 ; -49 [label="49: Return Stmt \n n$2=*&v:int [line 50]\n *&return:int =(1 / n$2) [line 50]\n REMOVE_TEMPS(n$2); [line 50]\n NULLIFY(&v,false); [line 50]\n NULLIFY(&x,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] +49 [label="49: Return Stmt \n n$2=*&v:int [line 56]\n *&return:int =(1 / n$2) [line 56]\n REMOVE_TEMPS(n$2); [line 56]\n NULLIFY(&v,false); [line 56]\n NULLIFY(&x,false); [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] 49 -> 43 ; -48 [label="48: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 48]\n REMOVE_TEMPS(n$1); [line 48]\n " shape="invhouse"] +48 [label="48: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 54]\n REMOVE_TEMPS(n$1); [line 54]\n " shape="invhouse"] 48 -> 45 ; -47 [label="47: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 48]\n REMOVE_TEMPS(n$1); [line 48]\n " shape="invhouse"] +47 [label="47: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 54]\n REMOVE_TEMPS(n$1); [line 54]\n " shape="invhouse"] 47 -> 50 ; -46 [label="46: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 48]\n " shape="box"] +46 [label="46: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 54]\n " shape="box"] 46 -> 47 ; @@ -68,46 +68,46 @@ digraph iCFG { 45 -> 44 ; -44 [label="44: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 52]\n *&return:int =n$0 [line 52]\n REMOVE_TEMPS(n$0); [line 52]\n NULLIFY(&x,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] +44 [label="44: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 58]\n *&return:int =n$0 [line 58]\n REMOVE_TEMPS(n$0); [line 58]\n NULLIFY(&x,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 44 -> 43 ; 43 [label="43: Exit 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 46]\n NULLIFY(&v,false); [line 46]\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 NULLIFY(&v,false); [line 52]\n " color=yellow style=filled] 42 -> 51 ; -41 [label="41: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 36]\n " shape="box"] +41 [label="41: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 42]\n " shape="box"] 41 -> 40 ; -40 [label="40: BinaryOperatorStmt: Assign \n *&y.f:int =0 [line 37]\n " shape="box"] +40 [label="40: BinaryOperatorStmt: Assign \n *&y.f:int =0 [line 43]\n " shape="box"] 40 -> 39 ; -39 [label="39: BinaryOperatorStmt: Assign \n *&y.b:int =1 [line 38]\n " shape="box"] +39 [label="39: BinaryOperatorStmt: Assign \n *&y.b:int =1 [line 44]\n " shape="box"] 39 -> 34 ; -38 [label="38: DeclStmt \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$10:class X *) [line 40]\n _fun_X_X(&__temp_construct_n$9:class X *,&SIL_materialize_temp__n$10:class X &) [line 40]\n n$12=_fun_X_operator int(&__temp_construct_n$9:class X &) [line 40]\n *&v:int =n$12 [line 40]\n REMOVE_TEMPS(n$12); [line 40]\n " shape="box"] +38 [label="38: DeclStmt \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$10:class X *) [line 46]\n _fun_X_X(&__temp_construct_n$9:class X *,&SIL_materialize_temp__n$10:class X &) [line 46]\n n$12=_fun_X_operator int(&__temp_construct_n$9:class X &) [line 46]\n *&v:int =n$12 [line 46]\n REMOVE_TEMPS(n$12); [line 46]\n " shape="box"] 38 -> 37 ; -37 [label="37: Return Stmt \n n$8=*&v:int [line 41]\n *&return:int =(1 / n$8) [line 41]\n REMOVE_TEMPS(n$8); [line 41]\n NULLIFY(&v,false); [line 41]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 41]\n NULLIFY(&SIL_materialize_temp__n$10,false); [line 41]\n NULLIFY(&SIL_materialize_temp__n$5,false); [line 41]\n NULLIFY(&__temp_construct_n$0,false); [line 41]\n NULLIFY(&__temp_construct_n$4,false); [line 41]\n NULLIFY(&__temp_construct_n$9,false); [line 41]\n NULLIFY(&y,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] +37 [label="37: Return Stmt \n n$8=*&v:int [line 47]\n *&return:int =(1 / n$8) [line 47]\n REMOVE_TEMPS(n$8); [line 47]\n NULLIFY(&v,false); [line 47]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 47]\n NULLIFY(&SIL_materialize_temp__n$10,false); [line 47]\n NULLIFY(&SIL_materialize_temp__n$5,false); [line 47]\n NULLIFY(&__temp_construct_n$0,false); [line 47]\n NULLIFY(&__temp_construct_n$4,false); [line 47]\n NULLIFY(&__temp_construct_n$9,false); [line 47]\n NULLIFY(&y,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] 37 -> 31 ; -36 [label="36: Prune (false branch) \n PRUNE((n$7 == 0), false); [line 39]\n REMOVE_TEMPS(n$7); [line 39]\n " shape="invhouse"] +36 [label="36: Prune (false branch) \n PRUNE((n$7 == 0), false); [line 45]\n REMOVE_TEMPS(n$7); [line 45]\n " shape="invhouse"] 36 -> 33 ; -35 [label="35: Prune (true branch) \n PRUNE((n$7 != 0), true); [line 39]\n REMOVE_TEMPS(n$7); [line 39]\n " shape="invhouse"] +35 [label="35: Prune (true branch) \n PRUNE((n$7 != 0), true); [line 45]\n REMOVE_TEMPS(n$7); [line 45]\n " shape="invhouse"] 35 -> 38 ; -34 [label="34: Call _fun_X_operator bool \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$5:class X *) [line 39]\n _fun_X_X(&__temp_construct_n$4:class X *,&SIL_materialize_temp__n$5:class X &) [line 39]\n n$7=_fun_X_operator bool(&__temp_construct_n$4:class X &) [line 39]\n " shape="box"] +34 [label="34: Call _fun_X_operator bool \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$5:class X *) [line 45]\n _fun_X_X(&__temp_construct_n$4:class X *,&SIL_materialize_temp__n$5:class X &) [line 45]\n n$7=_fun_X_operator bool(&__temp_construct_n$4:class X &) [line 45]\n " shape="box"] 34 -> 35 ; @@ -116,38 +116,38 @@ digraph iCFG { 33 -> 32 ; -32 [label="32: Return Stmt \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$1:class X *) [line 43]\n _fun_X_X(&__temp_construct_n$0:class X *,&SIL_materialize_temp__n$1:class X &) [line 43]\n n$3=_fun_X_operator int(&__temp_construct_n$0:class X &) [line 43]\n *&return:int =n$3 [line 43]\n REMOVE_TEMPS(n$3); [line 43]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 43]\n NULLIFY(&SIL_materialize_temp__n$10,false); [line 43]\n NULLIFY(&SIL_materialize_temp__n$5,false); [line 43]\n NULLIFY(&__temp_construct_n$0,false); [line 43]\n NULLIFY(&__temp_construct_n$4,false); [line 43]\n NULLIFY(&__temp_construct_n$9,false); [line 43]\n NULLIFY(&y,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +32 [label="32: Return Stmt \n _fun_Y_operator X(&y:class Y &,&SIL_materialize_temp__n$1:class X *) [line 49]\n _fun_X_X(&__temp_construct_n$0:class X *,&SIL_materialize_temp__n$1:class X &) [line 49]\n n$3=_fun_X_operator int(&__temp_construct_n$0:class X &) [line 49]\n *&return:int =n$3 [line 49]\n REMOVE_TEMPS(n$3); [line 49]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 49]\n NULLIFY(&SIL_materialize_temp__n$10,false); [line 49]\n NULLIFY(&SIL_materialize_temp__n$5,false); [line 49]\n NULLIFY(&__temp_construct_n$0,false); [line 49]\n NULLIFY(&__temp_construct_n$4,false); [line 49]\n NULLIFY(&__temp_construct_n$9,false); [line 49]\n NULLIFY(&y,false); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] 32 -> 31 ; 31 [label="31: Exit y_branch_div0 \n " color=yellow style=filled] -30 [label="30: Start y_branch_div0\nFormals: \nLocals: __temp_construct_n$0:class X SIL_materialize_temp__n$1:class X __temp_construct_n$4:class X SIL_materialize_temp__n$5:class X v:int __temp_construct_n$9:class X SIL_materialize_temp__n$10:class X y:class Y \n DECLARE_LOCALS(&return,&__temp_construct_n$0,&SIL_materialize_temp__n$1,&__temp_construct_n$4,&SIL_materialize_temp__n$5,&v,&__temp_construct_n$9,&SIL_materialize_temp__n$10,&y); [line 35]\n NULLIFY(&v,false); [line 35]\n " color=yellow style=filled] +30 [label="30: Start y_branch_div0\nFormals: \nLocals: __temp_construct_n$0:class X SIL_materialize_temp__n$1:class X __temp_construct_n$4:class X SIL_materialize_temp__n$5:class X v:int __temp_construct_n$9:class X SIL_materialize_temp__n$10:class X y:class Y \n DECLARE_LOCALS(&return,&__temp_construct_n$0,&SIL_materialize_temp__n$1,&__temp_construct_n$4,&SIL_materialize_temp__n$5,&v,&__temp_construct_n$9,&SIL_materialize_temp__n$10,&y); [line 41]\n NULLIFY(&v,false); [line 41]\n " color=yellow style=filled] 30 -> 41 ; -29 [label="29: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:_Bool ) [line 27]\n " shape="box"] +29 [label="29: DeclStmt \n _fun_X_X(&x:class X *,0:int ,1:_Bool ) [line 33]\n " shape="box"] 29 -> 24 ; -28 [label="28: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 29]\n *&v:int =n$3 [line 29]\n REMOVE_TEMPS(n$3); [line 29]\n " shape="box"] +28 [label="28: DeclStmt \n n$3=_fun_X_operator int(&x:class X &) [line 35]\n *&v:int =n$3 [line 35]\n REMOVE_TEMPS(n$3); [line 35]\n " shape="box"] 28 -> 27 ; -27 [label="27: Return Stmt \n n$2=*&v:int [line 30]\n *&return:int =(1 / n$2) [line 30]\n REMOVE_TEMPS(n$2); [line 30]\n NULLIFY(&v,false); [line 30]\n NULLIFY(&x,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +27 [label="27: Return Stmt \n n$2=*&v:int [line 36]\n *&return:int =(1 / n$2) [line 36]\n REMOVE_TEMPS(n$2); [line 36]\n NULLIFY(&v,false); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 27 -> 21 ; -26 [label="26: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 28]\n REMOVE_TEMPS(n$1); [line 28]\n " shape="invhouse"] +26 [label="26: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 34]\n REMOVE_TEMPS(n$1); [line 34]\n " shape="invhouse"] 26 -> 23 ; -25 [label="25: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 28]\n REMOVE_TEMPS(n$1); [line 28]\n " shape="invhouse"] +25 [label="25: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 34]\n REMOVE_TEMPS(n$1); [line 34]\n " shape="invhouse"] 25 -> 28 ; -24 [label="24: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 28]\n " shape="box"] +24 [label="24: Call _fun_X_operator bool \n n$1=_fun_X_operator bool(&x:class X &) [line 34]\n " shape="box"] 24 -> 25 ; @@ -156,55 +156,55 @@ digraph iCFG { 23 -> 22 ; -22 [label="22: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 32]\n *&return:int =n$0 [line 32]\n REMOVE_TEMPS(n$0); [line 32]\n NULLIFY(&x,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +22 [label="22: Return Stmt \n n$0=_fun_X_operator int(&x:class X &) [line 38]\n *&return:int =n$0 [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n NULLIFY(&x,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] 22 -> 21 ; 21 [label="21: Exit 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 26]\n NULLIFY(&v,false); [line 26]\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 NULLIFY(&v,false); [line 32]\n " color=yellow style=filled] 20 -> 29 ; 19 [label="19: Exit Y_Y \n " color=yellow style=filled] -18 [label="18: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&this,false); [line 19]\n " color=yellow style=filled] +18 [label="18: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n NULLIFY(&this,false); [line 25]\n " color=yellow style=filled] 18 -> 19 ; -17 [label="17: Return Stmt \n n$0=*&__return_param:class X * [line 21]\n n$2=*&this:class Y * [line 21]\n n$3=*n$2.f:int [line 21]\n n$4=*&this:class Y * [line 21]\n n$5=*n$4.b:int [line 21]\n _fun_X_X(&SIL_materialize_temp__n$1:class X *,n$3:int ,n$5:_Bool ) [line 21]\n _fun_X_X(n$0:class X *,&SIL_materialize_temp__n$1:class X &) [line 21]\n REMOVE_TEMPS(n$0,n$2,n$3,n$4,n$5); [line 21]\n NULLIFY(&__return_param,false); [line 21]\n NULLIFY(&this,false); [line 21]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +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(&SIL_materialize_temp__n$1:class X *,n$3:int ,n$5:_Bool ) [line 27]\n _fun_X_X(n$0:class X *,&SIL_materialize_temp__n$1:class X &) [line 27]\n REMOVE_TEMPS(n$0,n$2,n$3,n$4,n$5); [line 27]\n NULLIFY(&__return_param,false); [line 27]\n NULLIFY(&this,false); [line 27]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit Y_operator X \n " color=yellow style=filled] -15 [label="15: Start Y_operator X\nFormals: this:class Y * __return_param:class X *\nLocals: SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&SIL_materialize_temp__n$1); [line 21]\n " color=yellow style=filled] +15 [label="15: Start Y_operator X\nFormals: this:class Y * __return_param:class X *\nLocals: SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&SIL_materialize_temp__n$1); [line 27]\n " color=yellow style=filled] 15 -> 17 ; -14 [label="14: BinaryOperatorStmt: Assign \n n$3=*&this:class X * [line 16]\n n$4=*&x:class X & [line 16]\n n$5=*n$4.f_:int [line 16]\n *n$3.f_:int =n$5 [line 16]\n REMOVE_TEMPS(n$3,n$4,n$5); [line 16]\n " shape="box"] +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 REMOVE_TEMPS(n$3,n$4,n$5); [line 20]\n " shape="box"] 14 -> 13 ; -13 [label="13: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 16]\n n$1=*&x:class X & [line 16]\n n$2=*n$1.b_:_Bool [line 16]\n *n$0.b_:_Bool =n$2 [line 16]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 16]\n NULLIFY(&this,false); [line 16]\n NULLIFY(&x,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1,n$2); [line 21]\n NULLIFY(&this,false); [line 21]\n NULLIFY(&x,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit 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 16]\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 -> 14 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$2=*&this:class X * [line 15]\n n$3=*&f:int [line 15]\n *n$2.f_:int =n$3 [line 15]\n REMOVE_TEMPS(n$2,n$3); [line 15]\n NULLIFY(&f,false); [line 15]\n " shape="box"] +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 REMOVE_TEMPS(n$2,n$3); [line 16]\n NULLIFY(&f,false); [line 16]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&this:class X * [line 15]\n n$1=*&b:_Bool [line 15]\n *n$0.b_:_Bool =n$1 [line 15]\n REMOVE_TEMPS(n$0,n$1); [line 15]\n NULLIFY(&b,false); [line 15]\n NULLIFY(&this,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 17]\n NULLIFY(&b,false); [line 17]\n NULLIFY(&this,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 9 -> 8 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/default_parameters.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/default_parameters.cpp index 3322b55b5..2935a6c25 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/default_parameters.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/default_parameters.cpp @@ -8,14 +8,14 @@ */ class A { - public: + public: // default parameters - int fun_default(int a, int b = 10, int c = 20) {return a+b+c;} + int fun_default(int a, int b = 10, int c = 20) { return a + b + c; } }; void call_method_with_default_parameters() { - A *a_ptr; - a_ptr->fun_default(1,2,3); - a_ptr->fun_default(1,2); + A* a_ptr; + a_ptr->fun_default(1, 2, 3); + a_ptr->fun_default(1, 2); a_ptr->fun_default(1); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp index ae5986e24..86fef2cf0 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp @@ -8,8 +8,9 @@ */ class A { -int field; -public: + int field; + + public: void init(int val) { field = val; } int method(); }; @@ -20,6 +21,6 @@ int A::method() { } void test() { - A *a_ptr; + A* a_ptr; a_ptr->method(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp.dot index 04b1aca2f..91aab6957 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/dereference_this.cpp.dot @@ -1,38 +1,38 @@ digraph iCFG { -10 [label="10: Call _fun_A_method \n n$0=*&a_ptr:class A * [line 24]\n n$1=_fun_A_method(n$0:class A *) [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n NULLIFY(&a_ptr,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +10 [label="10: Call _fun_A_method \n n$0=*&a_ptr:class A * [line 25]\n n$1=_fun_A_method(n$0:class A *) [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n NULLIFY(&a_ptr,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 10 -> 9 ; 9 [label="9: Exit test \n " color=yellow style=filled] -8 [label="8: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 22]\n " color=yellow style=filled] +8 [label="8: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 23]\n " color=yellow style=filled] 8 -> 10 ; -7 [label="7: Call _fun_A_init \n n$2=*&this:class A * [line 18]\n _fun_A_init(n$2:class A *,10:int ) [line 18]\n REMOVE_TEMPS(n$2); [line 18]\n " shape="box"] +7 [label="7: Call _fun_A_init \n n$2=*&this:class A * [line 19]\n _fun_A_init(n$2:class A *,10:int ) [line 19]\n REMOVE_TEMPS(n$2); [line 19]\n " shape="box"] 7 -> 6 ; -6 [label="6: Return Stmt \n n$0=*&this:class A * [line 19]\n n$1=*n$0.field:int [line 19]\n *&return:int =n$1 [line 19]\n REMOVE_TEMPS(n$0,n$1); [line 19]\n NULLIFY(&this,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&this:class A * [line 20]\n n$1=*n$0.field:int [line 20]\n *&return:int =n$1 [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&this,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit A_method \n " color=yellow style=filled] -4 [label="4: Start A_method\nFormals: this:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] +4 [label="4: Start A_method\nFormals: this:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 4 -> 7 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class A * [line 13]\n n$1=*&val:int [line 13]\n *n$0.field:int =n$1 [line 13]\n REMOVE_TEMPS(n$0,n$1); [line 13]\n NULLIFY(&this,false); [line 13]\n NULLIFY(&val,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&this:class A * [line 14]\n n$1=*&val:int [line 14]\n *n$0.field:int =n$1 [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&this,false); [line 14]\n NULLIFY(&val,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit A_init \n " color=yellow style=filled] -1 [label="1: Start A_init\nFormals: this:class A * val:int \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled] +1 [label="1: Start A_init\nFormals: this:class A * val:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp index a12391d5f..3584c810b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp @@ -9,15 +9,18 @@ class A { struct AIn { - int fun() { return 1;} + int fun() { return 1; } }; - AIn *in; + AIn* in; // inline definition - int fun() { int c = 10; return c+1;} + int fun() { + int c = 10; + return c + 1; + } }; void test_call() { - A *a_ptr; + A* a_ptr; a_ptr->fun(); a_ptr->in->fun(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp.dot index 16a91a45f..53b960dc6 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/inline_method.cpp.dot @@ -1,24 +1,24 @@ digraph iCFG { -11 [label="11: Call _fun_A_fun \n n$3=*&a_ptr:class A * [line 21]\n n$4=_fun_A_fun(n$3:class A *) [line 21]\n REMOVE_TEMPS(n$3,n$4); [line 21]\n " shape="box"] +11 [label="11: Call _fun_A_fun \n n$3=*&a_ptr:class A * [line 24]\n n$4=_fun_A_fun(n$3:class A *) [line 24]\n REMOVE_TEMPS(n$3,n$4); [line 24]\n " shape="box"] 11 -> 10 ; -10 [label="10: Call _fun_A::AIn_fun \n n$0=*&a_ptr:class A * [line 22]\n n$1=*n$0.in:class A::AIn * [line 22]\n n$2=_fun_A::AIn_fun(n$1:class A::AIn *) [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n NULLIFY(&a_ptr,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +10 [label="10: Call _fun_A::AIn_fun \n n$0=*&a_ptr:class A * [line 25]\n n$1=*n$0.in:class A::AIn * [line 25]\n n$2=_fun_A::AIn_fun(n$1:class A::AIn *) [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 25]\n NULLIFY(&a_ptr,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 10 -> 9 ; 9 [label="9: Exit test_call \n " color=yellow style=filled] -8 [label="8: Start test_call\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 19]\n " color=yellow style=filled] +8 [label="8: Start test_call\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 22]\n " color=yellow style=filled] 8 -> 11 ; -7 [label="7: DeclStmt \n *&c:int =10 [line 16]\n " shape="box"] +7 [label="7: DeclStmt \n *&c:int =10 [line 17]\n " shape="box"] 7 -> 6 ; -6 [label="6: Return Stmt \n n$0=*&c:int [line 16]\n *&return:int =(n$0 + 1) [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&c,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&c:int [line 18]\n *&return:int =(n$0 + 1) [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&c,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 6 -> 5 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp index 739646792..85902d972 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp @@ -12,17 +12,13 @@ class A { int fun(int a, int b, int c); }; -int A::fun(int a, int b, int c) { - return a + b + c; -} +int A::fun(int a, int b, int c) { return a + b + c; } -int A::fun(int a, int b) { - return a - b; -} +int A::fun(int a, int b) { return a - b; } void test() { - A *a_ptr; + A* a_ptr; // calling methods - a_ptr->fun(1,2); - a_ptr->fun(1,2,3); + a_ptr->fun(1, 2); + a_ptr->fun(1, 2, 3); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp.dot index c6e87bd13..9d27f26ce 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/overloading.cpp.dot @@ -1,31 +1,31 @@ digraph iCFG { -10 [label="10: Call _fun_A_fun \n n$2=*&a_ptr:class A * [line 26]\n n$3=_fun_A_fun(n$2:class A *,1:int ,2:int ) [line 26]\n REMOVE_TEMPS(n$2,n$3); [line 26]\n " shape="box"] +10 [label="10: Call _fun_A_fun \n n$2=*&a_ptr:class A * [line 22]\n n$3=_fun_A_fun(n$2:class A *,1:int ,2:int ) [line 22]\n REMOVE_TEMPS(n$2,n$3); [line 22]\n " shape="box"] 10 -> 9 ; -9 [label="9: Call _fun_A_fun \n n$0=*&a_ptr:class A * [line 27]\n n$1=_fun_A_fun(n$0:class A *,1:int ,2:int ,3:int ) [line 27]\n REMOVE_TEMPS(n$0,n$1); [line 27]\n NULLIFY(&a_ptr,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +9 [label="9: Call _fun_A_fun \n n$0=*&a_ptr:class A * [line 23]\n n$1=_fun_A_fun(n$0:class A *,1:int ,2:int ,3:int ) [line 23]\n REMOVE_TEMPS(n$0,n$1); [line 23]\n NULLIFY(&a_ptr,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit test \n " color=yellow style=filled] -7 [label="7: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 23]\n " color=yellow style=filled] +7 [label="7: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 19]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: Return Stmt \n n$0=*&a:int [line 20]\n n$1=*&b:int [line 20]\n *&return:int =(n$0 - n$1) [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&a,false); [line 20]\n NULLIFY(&b,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&a:int [line 17]\n n$1=*&b:int [line 17]\n *&return:int =(n$0 - n$1) [line 17]\n REMOVE_TEMPS(n$0,n$1); [line 17]\n NULLIFY(&a,false); [line 17]\n NULLIFY(&b,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit A_fun \n " color=yellow style=filled] -4 [label="4: Start A_fun\nFormals: this:class A * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&this,false); [line 19]\n " color=yellow style=filled] +4 [label="4: Start A_fun\nFormals: this:class A * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n NULLIFY(&this,false); [line 17]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&a:int [line 16]\n n$1=*&b:int [line 16]\n n$2=*&c:int [line 16]\n *&return:int =((n$0 + n$1) + n$2) [line 16]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 16]\n NULLIFY(&a,false); [line 16]\n NULLIFY(&b,false); [line 16]\n NULLIFY(&c,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&a:int [line 15]\n n$1=*&b:int [line 15]\n n$2=*&c:int [line 15]\n *&return:int =((n$0 + n$1) + n$2) [line 15]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 15]\n NULLIFY(&a,false); [line 15]\n NULLIFY(&b,false); [line 15]\n NULLIFY(&c,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/return_struct.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/return_struct.cpp index fd57b809a..570e3d6cf 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/return_struct.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/return_struct.cpp @@ -18,7 +18,7 @@ struct A { } }; -int test(A *a) { +int test(A* a) { X x = a->get(1); return 1 / x.f; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp b/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp index 6305a8245..ba7507fb0 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp @@ -8,17 +8,15 @@ */ class A { -public: + public: static int fun(int); }; -int A::fun(int a) { return 1 / a;} +int A::fun(int a) { return 1 / a; } -void div0_class() { - A::fun(0); -} +void div0_class() { A::fun(0); } -void div0_instance(A *a) { +void div0_instance(A* a) { /* this will call static method as well */ a->fun(0); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp.dot index e2f092732..8abe4432e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/methods/static.cpp.dot @@ -1,16 +1,16 @@ digraph iCFG { -9 [label="9: Call _fun_A_fun \n n$0=*&a:class A * [line 23]\n n$1=_fun_A_fun(0:int ) [line 23]\n REMOVE_TEMPS(n$0,n$1); [line 23]\n NULLIFY(&a,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +9 [label="9: Call _fun_A_fun \n n$0=*&a:class A * [line 21]\n n$1=_fun_A_fun(0:int ) [line 21]\n REMOVE_TEMPS(n$0,n$1); [line 21]\n NULLIFY(&a,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit div0_instance \n " color=yellow style=filled] -7 [label="7: Start div0_instance\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +7 [label="7: Start div0_instance\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Call _fun_A_fun \n n$0=_fun_A_fun(0:int ) [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +6 [label="6: Call _fun_A_fun \n n$0=_fun_A_fun(0:int ) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 6 -> 5 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp b/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp index 54de8beb4..7f7ff9928 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp @@ -8,12 +8,12 @@ */ namespace f1 { - int get() { return 1;} - int get0() { return 0;} +int get() { return 1; } +int get0() { return 0; } } namespace f2 { - int get() { return -1;} +int get() { return -1; } } int div0_using() { @@ -21,6 +21,4 @@ int div0_using() { return 1 / get0(); } -int div0_namespace_resolution() { - return 1 / (f1::get() + f2::get()); -} +int div0_namespace_resolution() { return 1 / (f1::get() + f2::get()); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp.dot index cce454012..f39203a2f 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/function.cpp.dot @@ -1,5 +1,5 @@ digraph iCFG { -15 [label="15: Return Stmt \n n$0=_fun_f1::get() [line 25]\n n$1=_fun_f2::get() [line 25]\n *&return:int =(1 / (n$0 + n$1)) [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +15 [label="15: Return Stmt \n n$0=_fun_f1::get() [line 24]\n n$1=_fun_f2::get() [line 24]\n *&return:int =(1 / (n$0 + n$1)) [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 15 -> 14 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp b/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp index 679cc7c25..d03f4e475 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp @@ -13,7 +13,6 @@ int val; struct A { static int v; }; - } namespace f2 { @@ -24,7 +23,7 @@ struct B { static int v; }; -struct C : public B { }; +struct C : public B {}; int div0_namepace_res() { f1::val = 1; @@ -33,12 +32,12 @@ int div0_namepace_res() { } int div0_static_field() { - B::v= 1; + B::v = 1; f1::A::v = -2; return 1 / (f1::A::v + B::v + 1); } -int div0_static_field_member_access(f1::A *a, C *b) { +int div0_static_field_member_access(f1::A* a, C* b) { a->v = 1; b->v = -2; return 1 / (f1::A::v + B::v + 1); diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp.dot index 4710f4ef1..018e93eae 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/global_variable.cpp.dot @@ -1,58 +1,58 @@ digraph iCFG { -15 [label="15: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int =1 [line 42]\n " shape="box"] +15 [label="15: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int =1 [line 41]\n " shape="box"] 15 -> 14 ; -14 [label="14: BinaryOperatorStmt: Assign \n *&#GB$B::v:int =-2 [line 43]\n " shape="box"] +14 [label="14: BinaryOperatorStmt: Assign \n *&#GB$B::v:int =-2 [line 42]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 44]\n n$1=*&#GB$B::v:int [line 44]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 44]\n REMOVE_TEMPS(n$0,n$1); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] +13 [label="13: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 43]\n n$1=*&#GB$B::v:int [line 43]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 43]\n REMOVE_TEMPS(n$0,n$1); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit div0_static_field_member_access \n " color=yellow style=filled] -11 [label="11: Start div0_static_field_member_access\nFormals: a:class f1::A * b:class C *\nLocals: \n DECLARE_LOCALS(&return); [line 41]\n NULLIFY(&a,false); [line 41]\n NULLIFY(&b,false); [line 41]\n " color=yellow style=filled] +11 [label="11: Start div0_static_field_member_access\nFormals: a:class f1::A * b:class C *\nLocals: \n DECLARE_LOCALS(&return); [line 40]\n NULLIFY(&a,false); [line 40]\n NULLIFY(&b,false); [line 40]\n " color=yellow style=filled] 11 -> 15 ; -10 [label="10: BinaryOperatorStmt: Assign \n *&#GB$B::v:int =1 [line 36]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n *&#GB$B::v:int =1 [line 35]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int =-2 [line 37]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n *&#GB$f1::A::v:int =-2 [line 36]\n " shape="box"] 9 -> 8 ; -8 [label="8: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 38]\n n$1=*&#GB$B::v:int [line 38]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 38]\n REMOVE_TEMPS(n$0,n$1); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +8 [label="8: Return Stmt \n n$0=*&#GB$f1::A::v:int [line 37]\n n$1=*&#GB$B::v:int [line 37]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 37]\n REMOVE_TEMPS(n$0,n$1); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 8 -> 7 ; 7 [label="7: Exit div0_static_field \n " color=yellow style=filled] -6 [label="6: Start div0_static_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 35]\n " color=yellow style=filled] +6 [label="6: Start div0_static_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 6 -> 10 ; -5 [label="5: BinaryOperatorStmt: Assign \n *&#GB$f1::val:int =1 [line 30]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: Assign \n *&#GB$f1::val:int =1 [line 29]\n " shape="box"] 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n *&#GB$f2::val:int =-2 [line 31]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n *&#GB$f2::val:int =-2 [line 30]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&#GB$f1::val:int [line 32]\n n$1=*&#GB$f2::val:int [line 32]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 32]\n REMOVE_TEMPS(n$0,n$1); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$f1::val:int [line 31]\n n$1=*&#GB$f2::val:int [line 31]\n *&return:int =(1 / ((n$0 + n$1) + 1)) [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit div0_namepace_res \n " color=yellow style=filled] -1 [label="1: Start div0_namepace_res\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] +1 [label="1: Start div0_namepace_res\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 1 -> 5 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp index 3564a02e3..96f5edd67 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp @@ -7,53 +7,53 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - using namespace std; -namespace foo -{ - typedef struct { int a; int b;} my_record; - int value() { return 5; } - - class Rectangle { - int width, height; - public: - void set_values (int,int); - int area (void); - } ; +namespace foo { +typedef struct { + int a; + int b; +} my_record; +int value() { return 5; } + +class Rectangle { + int width, height; + + public: + void set_values(int, int); + int area(void); +}; } -namespace bar -{ - const double pi = 3.1416; - double value() { return 2*pi; } +namespace bar { +const double pi = 3.1416; +double value() { return 2 * pi; } - class Rectangle { - int width, height; - public: - void set_values (int,int); - int area (void); - } rect; +class Rectangle { + int width, height; + public: + void set_values(int, int); + int area(void); +} rect; } -int main () { - - int i; - double j; +int main() { - foo::my_record x; + int i; + double j; - bar::Rectangle rect1; - rect1.set_values (3,4); + foo::my_record x; - foo::Rectangle rect2; - rect2.set_values (7,10); + bar::Rectangle rect1; + rect1.set_values(3, 4); + foo::Rectangle rect2; + rect2.set_values(7, 10); - x.a = 10; - i = foo::value(); - i = bar::value(); - j = bar::pi; - return 0; + x.a = 10; + i = foo::value(); + i = bar::value(); + j = bar::pi; + return 0; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot index 89a6173b2..9e0104088 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/namespace/namespace.cpp.dot @@ -1,21 +1,21 @@ digraph iCFG { -24 [label="24: DeclStmt \n _fun_foo::my_record_(&x:class foo::my_record *) [line 45]\n " shape="box"] +24 [label="24: DeclStmt \n _fun_foo::my_record_(&x:class foo::my_record *) [line 46]\n " shape="box"] 24 -> 23 ; -23 [label="23: DeclStmt \n _fun_bar::Rectangle_Rectangle(&rect1:class bar::Rectangle *) [line 47]\n " shape="box"] +23 [label="23: DeclStmt \n _fun_bar::Rectangle_Rectangle(&rect1:class bar::Rectangle *) [line 48]\n " shape="box"] 23 -> 22 ; -22 [label="22: Call _fun_bar::Rectangle_set_values \n _fun_bar::Rectangle_set_values(&rect1:class bar::Rectangle &,3:int ,4:int ) [line 48]\n " shape="box"] +22 [label="22: Call _fun_bar::Rectangle_set_values \n _fun_bar::Rectangle_set_values(&rect1:class bar::Rectangle &,3:int ,4:int ) [line 49]\n " shape="box"] 22 -> 21 ; -21 [label="21: DeclStmt \n _fun_foo::Rectangle_Rectangle(&rect2:class foo::Rectangle *) [line 50]\n " shape="box"] +21 [label="21: DeclStmt \n _fun_foo::Rectangle_Rectangle(&rect2:class foo::Rectangle *) [line 51]\n " shape="box"] 21 -> 20 ; -20 [label="20: Call _fun_foo::Rectangle_set_values \n _fun_foo::Rectangle_set_values(&rect2:class foo::Rectangle &,7:int ,10:int ) [line 51]\n " shape="box"] +20 [label="20: Call _fun_foo::Rectangle_set_values \n _fun_foo::Rectangle_set_values(&rect2:class foo::Rectangle &,7:int ,10:int ) [line 52]\n " shape="box"] 20 -> 19 ; @@ -42,50 +42,50 @@ digraph iCFG { 14 [label="14: Exit main \n " color=yellow style=filled] -13 [label="13: Start main\nFormals: \nLocals: rect2:class foo::Rectangle rect1:class bar::Rectangle x:class foo::my_record j:double i:int \n DECLARE_LOCALS(&return,&rect2,&rect1,&x,&j,&i); [line 40]\n NULLIFY(&i,false); [line 40]\n NULLIFY(&j,false); [line 40]\n " color=yellow style=filled] +13 [label="13: Start main\nFormals: \nLocals: rect2:class foo::Rectangle rect1:class bar::Rectangle x:class foo::my_record j:double i:int \n DECLARE_LOCALS(&return,&rect2,&rect1,&x,&j,&i); [line 41]\n NULLIFY(&i,false); [line 41]\n NULLIFY(&j,false); [line 41]\n " color=yellow style=filled] 13 -> 24 ; 12 [label="12: Exit bar::Rectangle_Rectangle \n " color=yellow style=filled] -11 [label="11: Start bar::Rectangle_Rectangle\nFormals: this:class bar::Rectangle *\nLocals: \n DECLARE_LOCALS(&return); [line 31]\n NULLIFY(&this,false); [line 31]\n " color=yellow style=filled] +11 [label="11: Start bar::Rectangle_Rectangle\nFormals: this:class bar::Rectangle *\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n NULLIFY(&this,false); [line 32]\n " color=yellow style=filled] 11 -> 12 ; -10 [label="10: Return Stmt \n n$0=*&#GB$bar::pi:double [line 29]\n *&return:double =(2 * n$0) [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] +10 [label="10: Return Stmt \n n$0=*&#GB$bar::pi:double [line 30]\n *&return:double =(2 * n$0) [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 10 -> 9 ; 9 [label="9: Exit bar::value \n " color=yellow style=filled] -8 [label="8: Start bar::value\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] +8 [label="8: Start bar::value\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 8 -> 10 ; 7 [label="7: Exit foo::Rectangle_Rectangle \n " color=yellow style=filled] -6 [label="6: Start foo::Rectangle_Rectangle\nFormals: this:class foo::Rectangle *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n NULLIFY(&this,false); [line 18]\n " color=yellow style=filled] +6 [label="6: Start foo::Rectangle_Rectangle\nFormals: this:class foo::Rectangle *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&this,false); [line 19]\n " color=yellow style=filled] 6 -> 7 ; -5 [label="5: Return Stmt \n *&return:int =5 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +5 [label="5: Return Stmt \n *&return:int =5 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 5 -> 4 ; 4 [label="4: Exit foo::value \n " color=yellow style=filled] -3 [label="3: Start foo::value\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] +3 [label="3: Start foo::value\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled] 3 -> 5 ; 2 [label="2: Exit foo::my_record_ \n " color=yellow style=filled] -1 [label="1: Start foo::my_record_\nFormals: this:class foo::my_record *\nLocals: \n DECLARE_LOCALS(&return); [line 15]\n NULLIFY(&this,false); [line 15]\n " color=yellow style=filled] +1 [label="1: Start foo::my_record_\nFormals: this:class foo::my_record *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n NULLIFY(&this,false); [line 13]\n " color=yellow style=filled] 1 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp index 502056d91..e0585e970 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp @@ -9,7 +9,7 @@ int simple_init_div1() { if (int a = 1) { - return 1/a; + return 1 / a; } } @@ -17,7 +17,7 @@ int simple_init_div0() { if (int a = 0) { return a; } else { - return 1/a; + return 1 / a; } } @@ -31,9 +31,7 @@ int simple_inif_elseif_div0() { } } -int get1() { - return 1; -} +int get1() { return 1; } int function_call_init_div0() { if (int a = get1()) { @@ -52,11 +50,11 @@ int reference_init_div0() { if (int& a = r) { a = 0; } - return 1/r; + return 1 / r; } int simple_init_null_deref() { - if (int *p = nullptr) { + if (int* p = nullptr) { return 1; } else { return *p; diff --git a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp.dot index 3708ee741..2559898e3 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_if.cpp.dot @@ -1,54 +1,54 @@ digraph iCFG { -67 [label="67: Return Stmt \n n$1=*&p:int * [line 62]\n n$2=*n$1:int [line 62]\n *&return:int =n$2 [line 62]\n REMOVE_TEMPS(n$1,n$2); [line 62]\n NULLIFY(&p,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +67 [label="67: Return Stmt \n n$1=*&p:int * [line 60]\n n$2=*n$1:int [line 60]\n *&return:int =n$2 [line 60]\n REMOVE_TEMPS(n$1,n$2); [line 60]\n NULLIFY(&p,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] 67 -> 61 ; -66 [label="66: Return Stmt \n NULLIFY(&p,false); [line 60]\n *&return:int =1 [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] +66 [label="66: Return Stmt \n NULLIFY(&p,false); [line 58]\n *&return:int =1 [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 66 -> 61 ; -65 [label="65: DeclStmt \n *&p:int *=null [line 59]\n " shape="box"] +65 [label="65: DeclStmt \n *&p:int *=null [line 57]\n " shape="box"] 65 -> 63 ; 65 -> 64 ; -64 [label="64: Prune (false branch) \n n$0=*&p:int * [line 59]\n PRUNE((n$0 == 0), false); [line 59]\n REMOVE_TEMPS(n$0); [line 59]\n " shape="invhouse"] +64 [label="64: Prune (false branch) \n n$0=*&p:int * [line 57]\n PRUNE((n$0 == 0), false); [line 57]\n REMOVE_TEMPS(n$0); [line 57]\n " shape="invhouse"] 64 -> 67 ; -63 [label="63: Prune (true branch) \n n$0=*&p:int * [line 59]\n PRUNE((n$0 != 0), true); [line 59]\n REMOVE_TEMPS(n$0); [line 59]\n " shape="invhouse"] +63 [label="63: Prune (true branch) \n n$0=*&p:int * [line 57]\n PRUNE((n$0 != 0), true); [line 57]\n REMOVE_TEMPS(n$0); [line 57]\n " shape="invhouse"] 63 -> 66 ; -62 [label="62: + \n NULLIFY(&p,false); [line 59]\n " ] +62 [label="62: + \n NULLIFY(&p,false); [line 57]\n " ] 62 -> 61 ; 61 [label="61: Exit simple_init_null_deref \n " color=yellow style=filled] -60 [label="60: Start simple_init_null_deref\nFormals: \nLocals: p:int * \n DECLARE_LOCALS(&return,&p); [line 58]\n NULLIFY(&p,false); [line 58]\n " color=yellow style=filled] +60 [label="60: Start simple_init_null_deref\nFormals: \nLocals: p:int * \n DECLARE_LOCALS(&return,&p); [line 56]\n NULLIFY(&p,false); [line 56]\n " color=yellow style=filled] 60 -> 65 ; -59 [label="59: DeclStmt \n *&r:int =1 [line 51]\n " shape="box"] +59 [label="59: DeclStmt \n *&r:int =1 [line 49]\n " shape="box"] 59 -> 57 ; -58 [label="58: BinaryOperatorStmt: Assign \n n$3=*&a:int & [line 53]\n *n$3:int =0 [line 53]\n REMOVE_TEMPS(n$3); [line 53]\n NULLIFY(&a,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] +58 [label="58: BinaryOperatorStmt: Assign \n n$3=*&a:int & [line 51]\n *n$3:int =0 [line 51]\n REMOVE_TEMPS(n$3); [line 51]\n NULLIFY(&a,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 58 -> 54 ; -57 [label="57: DeclStmt \n *&a:int &=&r [line 52]\n " shape="box"] +57 [label="57: DeclStmt \n *&a:int &=&r [line 50]\n " shape="box"] 57 -> 55 ; 57 -> 56 ; -56 [label="56: Prune (false branch) \n n$1=*&a:int & [line 52]\n n$2=*n$1:int [line 52]\n PRUNE((n$2 == 0), false); [line 52]\n REMOVE_TEMPS(n$1,n$2); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="invhouse"] +56 [label="56: Prune (false branch) \n n$1=*&a:int & [line 50]\n n$2=*n$1:int [line 50]\n PRUNE((n$2 == 0), false); [line 50]\n REMOVE_TEMPS(n$1,n$2); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="invhouse"] 56 -> 54 ; -55 [label="55: Prune (true branch) \n n$1=*&a:int & [line 52]\n n$2=*n$1:int [line 52]\n PRUNE((n$2 != 0), true); [line 52]\n REMOVE_TEMPS(n$1,n$2); [line 52]\n " shape="invhouse"] +55 [label="55: Prune (true branch) \n n$1=*&a:int & [line 50]\n n$2=*n$1:int [line 50]\n PRUNE((n$2 != 0), true); [line 50]\n REMOVE_TEMPS(n$1,n$2); [line 50]\n " shape="invhouse"] 55 -> 58 ; @@ -56,39 +56,39 @@ digraph iCFG { 54 -> 53 ; -53 [label="53: Return Stmt \n NULLIFY(&a,false); [line 55]\n n$0=*&r:int [line 55]\n *&return:int =(1 / n$0) [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n NULLIFY(&r,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +53 [label="53: Return Stmt \n NULLIFY(&a,false); [line 53]\n n$0=*&r:int [line 53]\n *&return:int =(1 / n$0) [line 53]\n REMOVE_TEMPS(n$0); [line 53]\n NULLIFY(&r,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] 53 -> 52 ; 52 [label="52: Exit reference_init_div0 \n " color=yellow style=filled] -51 [label="51: Start reference_init_div0\nFormals: \nLocals: a:int & r:int \n DECLARE_LOCALS(&return,&a,&r); [line 50]\n NULLIFY(&a,false); [line 50]\n " color=yellow style=filled] +51 [label="51: Start reference_init_div0\nFormals: \nLocals: a:int & r:int \n DECLARE_LOCALS(&return,&a,&r); [line 48]\n NULLIFY(&a,false); [line 48]\n " color=yellow style=filled] 51 -> 59 ; -50 [label="50: Return Stmt \n n$2=*&a:int [line 46]\n *&return:int =(1 / (n$2 - 1)) [line 46]\n REMOVE_TEMPS(n$2); [line 46]\n NULLIFY(&a,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +50 [label="50: Return Stmt \n n$2=*&a:int [line 44]\n *&return:int =(1 / (n$2 - 1)) [line 44]\n REMOVE_TEMPS(n$2); [line 44]\n NULLIFY(&a,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 50 -> 40 ; -49 [label="49: DeclStmt \n n$1=*&SIL_temp_conditional___44:int [line 45]\n NULLIFY(&SIL_temp_conditional___44,true); [line 45]\n *&a:int =n$1 [line 45]\n REMOVE_TEMPS(n$1); [line 45]\n " shape="box"] +49 [label="49: DeclStmt \n n$1=*&SIL_temp_conditional___44:int [line 43]\n NULLIFY(&SIL_temp_conditional___44,true); [line 43]\n *&a:int =n$1 [line 43]\n REMOVE_TEMPS(n$1); [line 43]\n " shape="box"] 49 -> 42 ; 49 -> 43 ; -48 [label="48: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 45]\n *&SIL_temp_conditional___44:int =0 [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] +48 [label="48: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 43]\n *&SIL_temp_conditional___44:int =0 [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 48 -> 44 ; -47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 45]\n *&SIL_temp_conditional___44:int =1 [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] +47 [label="47: ConditinalStmt Branch \n DECLARE_LOCALS(&SIL_temp_conditional___44); [line 43]\n *&SIL_temp_conditional___44:int =1 [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 47 -> 44 ; -46 [label="46: Prune (false branch) \n PRUNE((1 == 0), false); [line 45]\n " shape="invhouse"] +46 [label="46: Prune (false branch) \n PRUNE((1 == 0), false); [line 43]\n " shape="invhouse"] 46 -> 48 ; -45 [label="45: Prune (true branch) \n PRUNE((1 != 0), true); [line 45]\n " shape="invhouse"] +45 [label="45: Prune (true branch) \n PRUNE((1 != 0), true); [line 43]\n " shape="invhouse"] 45 -> 47 ; @@ -96,55 +96,55 @@ digraph iCFG { 44 -> 49 ; -43 [label="43: Prune (false branch) \n n$0=*&a:int [line 45]\n PRUNE((n$0 == 0), false); [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n " shape="invhouse"] +43 [label="43: Prune (false branch) \n n$0=*&a:int [line 43]\n PRUNE((n$0 == 0), false); [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n " shape="invhouse"] 43 -> 41 ; -42 [label="42: Prune (true branch) \n n$0=*&a:int [line 45]\n PRUNE((n$0 != 0), true); [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n " shape="invhouse"] +42 [label="42: Prune (true branch) \n n$0=*&a:int [line 43]\n PRUNE((n$0 != 0), true); [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n " shape="invhouse"] 42 -> 50 ; -41 [label="41: + \n NULLIFY(&a,false); [line 45]\n " ] +41 [label="41: + \n NULLIFY(&a,false); [line 43]\n " ] 41 -> 40 ; 40 [label="40: Exit conditional_init_div0 \n " color=yellow style=filled] -39 [label="39: Start conditional_init_div0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 44]\n NULLIFY(&a,false); [line 44]\n " color=yellow style=filled] +39 [label="39: Start conditional_init_div0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 42]\n NULLIFY(&a,false); [line 42]\n " color=yellow style=filled] 39 -> 45 ; 39 -> 46 ; -38 [label="38: Return Stmt \n n$2=*&a:int [line 40]\n *&return:int =(1 / (n$2 - 1)) [line 40]\n REMOVE_TEMPS(n$2); [line 40]\n NULLIFY(&a,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] +38 [label="38: Return Stmt \n n$2=*&a:int [line 38]\n *&return:int =(1 / (n$2 - 1)) [line 38]\n REMOVE_TEMPS(n$2); [line 38]\n NULLIFY(&a,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] 38 -> 33 ; -37 [label="37: DeclStmt \n n$1=_fun_get1() [line 39]\n *&a:int =n$1 [line 39]\n REMOVE_TEMPS(n$1); [line 39]\n " shape="box"] +37 [label="37: DeclStmt \n n$1=_fun_get1() [line 37]\n *&a:int =n$1 [line 37]\n REMOVE_TEMPS(n$1); [line 37]\n " shape="box"] 37 -> 35 ; 37 -> 36 ; -36 [label="36: Prune (false branch) \n n$0=*&a:int [line 39]\n PRUNE((n$0 == 0), false); [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n " shape="invhouse"] +36 [label="36: Prune (false branch) \n n$0=*&a:int [line 37]\n PRUNE((n$0 == 0), false); [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n " shape="invhouse"] 36 -> 34 ; -35 [label="35: Prune (true branch) \n n$0=*&a:int [line 39]\n PRUNE((n$0 != 0), true); [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n " shape="invhouse"] +35 [label="35: Prune (true branch) \n n$0=*&a:int [line 37]\n PRUNE((n$0 != 0), true); [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n " shape="invhouse"] 35 -> 38 ; -34 [label="34: + \n NULLIFY(&a,false); [line 39]\n " ] +34 [label="34: + \n NULLIFY(&a,false); [line 37]\n " ] 34 -> 33 ; 33 [label="33: Exit function_call_init_div0 \n " color=yellow style=filled] -32 [label="32: Start function_call_init_div0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 38]\n NULLIFY(&a,false); [line 38]\n " color=yellow style=filled] +32 [label="32: Start function_call_init_div0\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 36]\n NULLIFY(&a,false); [line 36]\n " color=yellow style=filled] 32 -> 37 ; -31 [label="31: Return Stmt \n *&return:int =1 [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] +31 [label="31: Return Stmt \n *&return:int =1 [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] 31 -> 30 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_switch.cpp b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_switch.cpp index f79390051..6cd3d030b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_switch.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_switch.cpp @@ -11,10 +11,10 @@ int get(int a) { switch (int x = a) { case 0: case 1: - return 0; + return 0; case 2: - return 1; + return 1; default: - return x; + return x; } } diff --git a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_while.cpp b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_while.cpp index 9dd82c6fd..e1fe7bf45 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_while.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/nestedoperators/var_decl_inside_while.cpp @@ -10,7 +10,7 @@ int simple_assignment() { int x = 10; int result = 0; - while(int a = x) { + while (int a = x) { result += a; x -= 1; } @@ -20,7 +20,7 @@ int simple_assignment() { int conditional_assignment() { int x = 10; int result = 0; - while(int a = x > 0 ? x : 0) { + while (int a = x > 0 ? x : 0) { result += a; x -= 1; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/increment.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/increment.cpp index 623a1796d..020d8e47b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/increment.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/increment.cpp @@ -9,13 +9,13 @@ void using_value() { int v = 3; - int &r = ++v; - int &q = --v; + int& r = ++v; + int& q = --v; } void using_ref() { int v = 3; - int &vr = v; - int &r = ++vr; - int &q = --vr; + int& vr = v; + int& r = ++vr; + int& q = --vr; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/init.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/init.cpp index 1b5757144..16cc19f0b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/init.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/init.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -void init_from_ref(int &par) { +void init_from_ref(int& par) { int v = par; int& d = par; int* p = ∥ @@ -19,7 +19,7 @@ void init_from_val(int par) { int* p = ∥ } -void init_from_ptr(int *par) { +void init_from_ptr(int* par) { int v = *par; int& d = *par; int* p = par; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/member_access.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/member_access.cpp index 8f49a5b68..4457cde1b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/member_access.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/member_access.cpp @@ -9,7 +9,7 @@ struct X { int f; - int call() {return f;} + int call() { return f; } }; void access_ref(X& x) { diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/member_access_from_return.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/member_access_from_return.cpp index 177623c16..4b297044b 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/member_access_from_return.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/member_access_from_return.cpp @@ -9,12 +9,12 @@ struct X { int f; - int call() {return f;} + int call() { return f; } }; X global; -X * get_ptr() {return &global;} -X& get_ref() {return global;} +X* get_ptr() { return &global; } +X& get_ref() { return global; } void test_ref() { int f = get_ref().f; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp index dd3053b4e..75161353e 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp @@ -9,22 +9,22 @@ void normal() { int a = 3; - int &ref_from_val = a; - int &ref_from_ref = ref_from_val; + int& ref_from_val = a; + int& ref_from_ref = ref_from_val; } void nested() { int a = 3; - int &ref_from_val = a = 4; - int &ref_from_ref = ref_from_val = 6; + int& ref_from_val = a = 4; + int& ref_from_ref = ref_from_val = 6; } - void crazy_nested() { int a = 3; int b = a; - // a will refer to same object as ref_from_val and ref_from_ref, but different than b + // a will refer to same object as ref_from_val and ref_from_ref, but different + // than b int& ref_from_val = a = b = 4; int& ref_from_ref = ref_from_val = b = 5; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp.dot index d93fb7609..be8daf242 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/nested_assignment.cpp.dot @@ -1,9 +1,9 @@ digraph iCFG { -16 [label="16: DeclStmt \n *&a:int =3 [line 24]\n " shape="box"] +16 [label="16: DeclStmt \n *&a:int =3 [line 23]\n " shape="box"] 16 -> 15 ; -15 [label="15: DeclStmt \n n$3=*&a:int [line 25]\n *&b:int =n$3 [line 25]\n REMOVE_TEMPS(n$3); [line 25]\n NULLIFY(&b,false); [line 25]\n " shape="box"] +15 [label="15: DeclStmt \n n$3=*&a:int [line 24]\n *&b:int =n$3 [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n NULLIFY(&b,false); [line 24]\n " shape="box"] 15 -> 14 ; @@ -18,7 +18,7 @@ digraph iCFG { 12 [label="12: Exit crazy_nested \n " color=yellow style=filled] -11 [label="11: Start crazy_nested\nFormals: \nLocals: ref_from_ref:int & ref_from_val:int & b:int a:int \n DECLARE_LOCALS(&return,&ref_from_ref,&ref_from_val,&b,&a); [line 23]\n NULLIFY(&b,false); [line 23]\n NULLIFY(&ref_from_ref,false); [line 23]\n NULLIFY(&ref_from_val,false); [line 23]\n " color=yellow style=filled] +11 [label="11: Start crazy_nested\nFormals: \nLocals: ref_from_ref:int & ref_from_val:int & b:int a:int \n DECLARE_LOCALS(&return,&ref_from_ref,&ref_from_val,&b,&a); [line 22]\n NULLIFY(&b,false); [line 22]\n NULLIFY(&ref_from_ref,false); [line 22]\n NULLIFY(&ref_from_val,false); [line 22]\n " color=yellow style=filled] 11 -> 16 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp index 7a3581dca..776f73180 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp @@ -11,60 +11,48 @@ struct X { int f; void nonzero() { f = 1; } void zero() { f = 0; } - int div() { return 1/f; } + int div() { return 1 / f; } }; -void zero_ptr(X *x) { - x->zero(); -} +void zero_ptr(X* x) { x->zero(); } -void nonzero_ptr(X *x) { - x->nonzero(); -} +void nonzero_ptr(X* x) { x->nonzero(); } -void set_field_ptr(X *x, int val) { - x->f = val; -} +void set_field_ptr(X* x, int val) { x->f = val; } -void zero_ref(X &x) { - x.zero(); -} +void zero_ref(X& x) { x.zero(); } -void nonzero_ref(X &x) { - x.nonzero(); -} +void nonzero_ref(X& x) { x.nonzero(); } -void set_field_ref(X &x, int val) { - x.f = val; -} +void set_field_ref(X& x, int val) { x.f = val; } X global; -X* get_global_ptr() { return &global;} -X& get_global_ref() { return global;} +X* get_global_ptr() { return &global; } +X& get_global_ref() { return global; } -int method_div0_ptr(X *x) { +int method_div0_ptr(X* x) { if (x) { zero_ptr(x); return x->div(); } } -int method_div1_ptr(X *x) { +int method_div1_ptr(X* x) { if (x) { nonzero_ptr(x); return x->div(); } } -int field_div0_ptr(X *x) { - if(x) { +int field_div0_ptr(X* x) { + if (x) { set_field_ptr(x, 0); return x->div(); } } -int field_div1_ptr(X *x) { - if(x) { +int field_div1_ptr(X* x) { + if (x) { set_field_ptr(x, 1); return x->div(); } @@ -94,22 +82,22 @@ int get_global_ptr_div1_field() { get_global_ptr()->div(); } -int method_div0_ref(X &x) { +int method_div0_ref(X& x) { zero_ref(x); return x.div(); } -int method_div1_ref(X &x) { +int method_div1_ref(X& x) { nonzero_ref(x); return x.div(); } -int field_div0_ref(X &x) { +int field_div0_ref(X& x) { set_field_ref(x, 0); return x.div(); } -int field_div1_ref(X &x) { +int field_div1_ref(X& x) { set_field_ref(x, 1); return x.div(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp.dot index 2a5ca16d6..27d256383 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_struct_e2e.cpp.dot @@ -1,406 +1,406 @@ digraph iCFG { -119 [label="119: Call _fun_X_zero \n n$3=_fun_get_global_ref() [line 136]\n _fun_X_zero(n$3:class X &) [line 136]\n REMOVE_TEMPS(n$3); [line 136]\n " shape="box"] +119 [label="119: Call _fun_X_zero \n n$3=_fun_get_global_ref() [line 124]\n _fun_X_zero(n$3:class X &) [line 124]\n REMOVE_TEMPS(n$3); [line 124]\n " shape="box"] 119 -> 118 ; -118 [label="118: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ref() [line 137]\n *n$2.f:int =1 [line 137]\n REMOVE_TEMPS(n$2); [line 137]\n " shape="box"] +118 [label="118: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ref() [line 125]\n *n$2.f:int =1 [line 125]\n REMOVE_TEMPS(n$2); [line 125]\n " shape="box"] 118 -> 117 ; -117 [label="117: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 138]\n n$1=_fun_X_div(n$0:class X &) [line 138]\n REMOVE_TEMPS(n$0,n$1); [line 138]\n APPLY_ABSTRACTION; [line 138]\n " shape="box"] +117 [label="117: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 126]\n n$1=_fun_X_div(n$0:class X &) [line 126]\n REMOVE_TEMPS(n$0,n$1); [line 126]\n APPLY_ABSTRACTION; [line 126]\n " shape="box"] 117 -> 116 ; 116 [label="116: Exit get_global_ref_div1_field \n " color=yellow style=filled] -115 [label="115: Start get_global_ref_div1_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 135]\n " color=yellow style=filled] +115 [label="115: Start get_global_ref_div1_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 123]\n " color=yellow style=filled] 115 -> 119 ; -114 [label="114: Call _fun_X_nonzero \n n$3=_fun_get_global_ref() [line 130]\n _fun_X_nonzero(n$3:class X &) [line 130]\n REMOVE_TEMPS(n$3); [line 130]\n " shape="box"] +114 [label="114: Call _fun_X_nonzero \n n$3=_fun_get_global_ref() [line 118]\n _fun_X_nonzero(n$3:class X &) [line 118]\n REMOVE_TEMPS(n$3); [line 118]\n " shape="box"] 114 -> 113 ; -113 [label="113: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ref() [line 131]\n *n$2.f:int =0 [line 131]\n REMOVE_TEMPS(n$2); [line 131]\n " shape="box"] +113 [label="113: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ref() [line 119]\n *n$2.f:int =0 [line 119]\n REMOVE_TEMPS(n$2); [line 119]\n " shape="box"] 113 -> 112 ; -112 [label="112: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 132]\n n$1=_fun_X_div(n$0:class X &) [line 132]\n REMOVE_TEMPS(n$0,n$1); [line 132]\n APPLY_ABSTRACTION; [line 132]\n " shape="box"] +112 [label="112: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 120]\n n$1=_fun_X_div(n$0:class X &) [line 120]\n REMOVE_TEMPS(n$0,n$1); [line 120]\n APPLY_ABSTRACTION; [line 120]\n " shape="box"] 112 -> 111 ; 111 [label="111: Exit get_global_ref_div0_field \n " color=yellow style=filled] -110 [label="110: Start get_global_ref_div0_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 129]\n " color=yellow style=filled] +110 [label="110: Start get_global_ref_div0_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 117]\n " color=yellow style=filled] 110 -> 114 ; -109 [label="109: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ref() [line 124]\n *n$3.f:int =0 [line 124]\n REMOVE_TEMPS(n$3); [line 124]\n " shape="box"] +109 [label="109: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ref() [line 112]\n *n$3.f:int =0 [line 112]\n REMOVE_TEMPS(n$3); [line 112]\n " shape="box"] 109 -> 108 ; -108 [label="108: Call _fun_X_nonzero \n n$2=_fun_get_global_ref() [line 125]\n _fun_X_nonzero(n$2:class X &) [line 125]\n REMOVE_TEMPS(n$2); [line 125]\n " shape="box"] +108 [label="108: Call _fun_X_nonzero \n n$2=_fun_get_global_ref() [line 113]\n _fun_X_nonzero(n$2:class X &) [line 113]\n REMOVE_TEMPS(n$2); [line 113]\n " shape="box"] 108 -> 107 ; -107 [label="107: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 126]\n n$1=_fun_X_div(n$0:class X &) [line 126]\n REMOVE_TEMPS(n$0,n$1); [line 126]\n APPLY_ABSTRACTION; [line 126]\n " shape="box"] +107 [label="107: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 114]\n n$1=_fun_X_div(n$0:class X &) [line 114]\n REMOVE_TEMPS(n$0,n$1); [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="box"] 107 -> 106 ; 106 [label="106: Exit get_global_ref_div1_method \n " color=yellow style=filled] -105 [label="105: Start get_global_ref_div1_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 123]\n " color=yellow style=filled] +105 [label="105: Start get_global_ref_div1_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 111]\n " color=yellow style=filled] 105 -> 109 ; -104 [label="104: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ref() [line 118]\n *n$3.f:int =1 [line 118]\n REMOVE_TEMPS(n$3); [line 118]\n " shape="box"] +104 [label="104: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ref() [line 106]\n *n$3.f:int =1 [line 106]\n REMOVE_TEMPS(n$3); [line 106]\n " shape="box"] 104 -> 103 ; -103 [label="103: Call _fun_X_zero \n n$2=_fun_get_global_ref() [line 119]\n _fun_X_zero(n$2:class X &) [line 119]\n REMOVE_TEMPS(n$2); [line 119]\n " shape="box"] +103 [label="103: Call _fun_X_zero \n n$2=_fun_get_global_ref() [line 107]\n _fun_X_zero(n$2:class X &) [line 107]\n REMOVE_TEMPS(n$2); [line 107]\n " shape="box"] 103 -> 102 ; -102 [label="102: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 120]\n n$1=_fun_X_div(n$0:class X &) [line 120]\n REMOVE_TEMPS(n$0,n$1); [line 120]\n APPLY_ABSTRACTION; [line 120]\n " shape="box"] +102 [label="102: Call _fun_X_div \n n$0=_fun_get_global_ref() [line 108]\n n$1=_fun_X_div(n$0:class X &) [line 108]\n REMOVE_TEMPS(n$0,n$1); [line 108]\n APPLY_ABSTRACTION; [line 108]\n " shape="box"] 102 -> 101 ; 101 [label="101: Exit get_global_ref_div0_method \n " color=yellow style=filled] -100 [label="100: Start get_global_ref_div0_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 117]\n " color=yellow style=filled] +100 [label="100: Start get_global_ref_div0_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 105]\n " color=yellow style=filled] 100 -> 104 ; -99 [label="99: Call _fun_set_field_ref \n n$2=*&x:class X & [line 113]\n _fun_set_field_ref(n$2:class X &,1:int ) [line 113]\n REMOVE_TEMPS(n$2); [line 113]\n " shape="box"] +99 [label="99: Call _fun_set_field_ref \n n$2=*&x:class X & [line 101]\n _fun_set_field_ref(n$2:class X &,1:int ) [line 101]\n REMOVE_TEMPS(n$2); [line 101]\n " shape="box"] 99 -> 98 ; -98 [label="98: Return Stmt \n n$0=*&x:class X & [line 114]\n n$1=_fun_X_div(n$0:class X &) [line 114]\n *&return:int =n$1 [line 114]\n REMOVE_TEMPS(n$0,n$1); [line 114]\n NULLIFY(&x,false); [line 114]\n APPLY_ABSTRACTION; [line 114]\n " shape="box"] +98 [label="98: Return Stmt \n n$0=*&x:class X & [line 102]\n n$1=_fun_X_div(n$0:class X &) [line 102]\n *&return:int =n$1 [line 102]\n REMOVE_TEMPS(n$0,n$1); [line 102]\n NULLIFY(&x,false); [line 102]\n APPLY_ABSTRACTION; [line 102]\n " shape="box"] 98 -> 97 ; 97 [label="97: Exit field_div1_ref \n " color=yellow style=filled] -96 [label="96: Start field_div1_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 112]\n " color=yellow style=filled] +96 [label="96: Start field_div1_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 100]\n " color=yellow style=filled] 96 -> 99 ; -95 [label="95: Call _fun_set_field_ref \n n$2=*&x:class X & [line 108]\n _fun_set_field_ref(n$2:class X &,0:int ) [line 108]\n REMOVE_TEMPS(n$2); [line 108]\n " shape="box"] +95 [label="95: Call _fun_set_field_ref \n n$2=*&x:class X & [line 96]\n _fun_set_field_ref(n$2:class X &,0:int ) [line 96]\n REMOVE_TEMPS(n$2); [line 96]\n " shape="box"] 95 -> 94 ; -94 [label="94: Return Stmt \n n$0=*&x:class X & [line 109]\n n$1=_fun_X_div(n$0:class X &) [line 109]\n *&return:int =n$1 [line 109]\n REMOVE_TEMPS(n$0,n$1); [line 109]\n NULLIFY(&x,false); [line 109]\n APPLY_ABSTRACTION; [line 109]\n " shape="box"] +94 [label="94: Return Stmt \n n$0=*&x:class X & [line 97]\n n$1=_fun_X_div(n$0:class X &) [line 97]\n *&return:int =n$1 [line 97]\n REMOVE_TEMPS(n$0,n$1); [line 97]\n NULLIFY(&x,false); [line 97]\n APPLY_ABSTRACTION; [line 97]\n " shape="box"] 94 -> 93 ; 93 [label="93: Exit field_div0_ref \n " color=yellow style=filled] -92 [label="92: Start field_div0_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 107]\n " color=yellow style=filled] +92 [label="92: Start field_div0_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 95]\n " color=yellow style=filled] 92 -> 95 ; -91 [label="91: Call _fun_nonzero_ref \n n$2=*&x:class X & [line 103]\n _fun_nonzero_ref(n$2:class X &) [line 103]\n REMOVE_TEMPS(n$2); [line 103]\n " shape="box"] +91 [label="91: Call _fun_nonzero_ref \n n$2=*&x:class X & [line 91]\n _fun_nonzero_ref(n$2:class X &) [line 91]\n REMOVE_TEMPS(n$2); [line 91]\n " shape="box"] 91 -> 90 ; -90 [label="90: Return Stmt \n n$0=*&x:class X & [line 104]\n n$1=_fun_X_div(n$0:class X &) [line 104]\n *&return:int =n$1 [line 104]\n REMOVE_TEMPS(n$0,n$1); [line 104]\n NULLIFY(&x,false); [line 104]\n APPLY_ABSTRACTION; [line 104]\n " shape="box"] +90 [label="90: Return Stmt \n n$0=*&x:class X & [line 92]\n n$1=_fun_X_div(n$0:class X &) [line 92]\n *&return:int =n$1 [line 92]\n REMOVE_TEMPS(n$0,n$1); [line 92]\n NULLIFY(&x,false); [line 92]\n APPLY_ABSTRACTION; [line 92]\n " shape="box"] 90 -> 89 ; 89 [label="89: Exit method_div1_ref \n " color=yellow style=filled] -88 [label="88: Start method_div1_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 102]\n " color=yellow style=filled] +88 [label="88: Start method_div1_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 90]\n " color=yellow style=filled] 88 -> 91 ; -87 [label="87: Call _fun_zero_ref \n n$2=*&x:class X & [line 98]\n _fun_zero_ref(n$2:class X &) [line 98]\n REMOVE_TEMPS(n$2); [line 98]\n " shape="box"] +87 [label="87: Call _fun_zero_ref \n n$2=*&x:class X & [line 86]\n _fun_zero_ref(n$2:class X &) [line 86]\n REMOVE_TEMPS(n$2); [line 86]\n " shape="box"] 87 -> 86 ; -86 [label="86: Return Stmt \n n$0=*&x:class X & [line 99]\n n$1=_fun_X_div(n$0:class X &) [line 99]\n *&return:int =n$1 [line 99]\n REMOVE_TEMPS(n$0,n$1); [line 99]\n NULLIFY(&x,false); [line 99]\n APPLY_ABSTRACTION; [line 99]\n " shape="box"] +86 [label="86: Return Stmt \n n$0=*&x:class X & [line 87]\n n$1=_fun_X_div(n$0:class X &) [line 87]\n *&return:int =n$1 [line 87]\n REMOVE_TEMPS(n$0,n$1); [line 87]\n NULLIFY(&x,false); [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 86 -> 85 ; 85 [label="85: Exit method_div0_ref \n " color=yellow style=filled] -84 [label="84: Start method_div0_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 97]\n " color=yellow style=filled] +84 [label="84: Start method_div0_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 85]\n " color=yellow style=filled] 84 -> 87 ; -83 [label="83: Call _fun_X_zero \n n$3=_fun_get_global_ptr() [line 92]\n _fun_X_zero(n$3:class X *) [line 92]\n REMOVE_TEMPS(n$3); [line 92]\n " shape="box"] +83 [label="83: Call _fun_X_zero \n n$3=_fun_get_global_ptr() [line 80]\n _fun_X_zero(n$3:class X *) [line 80]\n REMOVE_TEMPS(n$3); [line 80]\n " shape="box"] 83 -> 82 ; -82 [label="82: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ptr() [line 93]\n *n$2.f:int =1 [line 93]\n REMOVE_TEMPS(n$2); [line 93]\n " shape="box"] +82 [label="82: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ptr() [line 81]\n *n$2.f:int =1 [line 81]\n REMOVE_TEMPS(n$2); [line 81]\n " shape="box"] 82 -> 81 ; -81 [label="81: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 94]\n n$1=_fun_X_div(n$0:class X *) [line 94]\n REMOVE_TEMPS(n$0,n$1); [line 94]\n APPLY_ABSTRACTION; [line 94]\n " shape="box"] +81 [label="81: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 82]\n n$1=_fun_X_div(n$0:class X *) [line 82]\n REMOVE_TEMPS(n$0,n$1); [line 82]\n APPLY_ABSTRACTION; [line 82]\n " shape="box"] 81 -> 80 ; 80 [label="80: Exit get_global_ptr_div1_field \n " color=yellow style=filled] -79 [label="79: Start get_global_ptr_div1_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 91]\n " color=yellow style=filled] +79 [label="79: Start get_global_ptr_div1_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 79]\n " color=yellow style=filled] 79 -> 83 ; -78 [label="78: Call _fun_X_nonzero \n n$3=_fun_get_global_ptr() [line 86]\n _fun_X_nonzero(n$3:class X *) [line 86]\n REMOVE_TEMPS(n$3); [line 86]\n " shape="box"] +78 [label="78: Call _fun_X_nonzero \n n$3=_fun_get_global_ptr() [line 74]\n _fun_X_nonzero(n$3:class X *) [line 74]\n REMOVE_TEMPS(n$3); [line 74]\n " shape="box"] 78 -> 77 ; -77 [label="77: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ptr() [line 87]\n *n$2.f:int =0 [line 87]\n REMOVE_TEMPS(n$2); [line 87]\n " shape="box"] +77 [label="77: BinaryOperatorStmt: Assign \n n$2=_fun_get_global_ptr() [line 75]\n *n$2.f:int =0 [line 75]\n REMOVE_TEMPS(n$2); [line 75]\n " shape="box"] 77 -> 76 ; -76 [label="76: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 88]\n n$1=_fun_X_div(n$0:class X *) [line 88]\n REMOVE_TEMPS(n$0,n$1); [line 88]\n APPLY_ABSTRACTION; [line 88]\n " shape="box"] +76 [label="76: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 76]\n n$1=_fun_X_div(n$0:class X *) [line 76]\n REMOVE_TEMPS(n$0,n$1); [line 76]\n APPLY_ABSTRACTION; [line 76]\n " shape="box"] 76 -> 75 ; 75 [label="75: Exit get_global_ptr_div0_field \n " color=yellow style=filled] -74 [label="74: Start get_global_ptr_div0_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 85]\n " color=yellow style=filled] +74 [label="74: Start get_global_ptr_div0_field\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 73]\n " color=yellow style=filled] 74 -> 78 ; -73 [label="73: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ptr() [line 80]\n *n$3.f:int =0 [line 80]\n REMOVE_TEMPS(n$3); [line 80]\n " shape="box"] +73 [label="73: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ptr() [line 68]\n *n$3.f:int =0 [line 68]\n REMOVE_TEMPS(n$3); [line 68]\n " shape="box"] 73 -> 72 ; -72 [label="72: Call _fun_X_nonzero \n n$2=_fun_get_global_ptr() [line 81]\n _fun_X_nonzero(n$2:class X *) [line 81]\n REMOVE_TEMPS(n$2); [line 81]\n " shape="box"] +72 [label="72: Call _fun_X_nonzero \n n$2=_fun_get_global_ptr() [line 69]\n _fun_X_nonzero(n$2:class X *) [line 69]\n REMOVE_TEMPS(n$2); [line 69]\n " shape="box"] 72 -> 71 ; -71 [label="71: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 82]\n n$1=_fun_X_div(n$0:class X *) [line 82]\n REMOVE_TEMPS(n$0,n$1); [line 82]\n APPLY_ABSTRACTION; [line 82]\n " shape="box"] +71 [label="71: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 70]\n n$1=_fun_X_div(n$0:class X *) [line 70]\n REMOVE_TEMPS(n$0,n$1); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 71 -> 70 ; 70 [label="70: Exit get_global_ptr_div1_method \n " color=yellow style=filled] -69 [label="69: Start get_global_ptr_div1_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 79]\n " color=yellow style=filled] +69 [label="69: Start get_global_ptr_div1_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 67]\n " color=yellow style=filled] 69 -> 73 ; -68 [label="68: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ptr() [line 74]\n *n$3.f:int =1 [line 74]\n REMOVE_TEMPS(n$3); [line 74]\n " shape="box"] +68 [label="68: BinaryOperatorStmt: Assign \n n$3=_fun_get_global_ptr() [line 62]\n *n$3.f:int =1 [line 62]\n REMOVE_TEMPS(n$3); [line 62]\n " shape="box"] 68 -> 67 ; -67 [label="67: Call _fun_X_zero \n n$2=_fun_get_global_ptr() [line 75]\n _fun_X_zero(n$2:class X *) [line 75]\n REMOVE_TEMPS(n$2); [line 75]\n " shape="box"] +67 [label="67: Call _fun_X_zero \n n$2=_fun_get_global_ptr() [line 63]\n _fun_X_zero(n$2:class X *) [line 63]\n REMOVE_TEMPS(n$2); [line 63]\n " shape="box"] 67 -> 66 ; -66 [label="66: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 76]\n n$1=_fun_X_div(n$0:class X *) [line 76]\n REMOVE_TEMPS(n$0,n$1); [line 76]\n APPLY_ABSTRACTION; [line 76]\n " shape="box"] +66 [label="66: Call _fun_X_div \n n$0=_fun_get_global_ptr() [line 64]\n n$1=_fun_X_div(n$0:class X *) [line 64]\n REMOVE_TEMPS(n$0,n$1); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"] 66 -> 65 ; 65 [label="65: Exit get_global_ptr_div0_method \n " color=yellow style=filled] -64 [label="64: Start get_global_ptr_div0_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 73]\n " color=yellow style=filled] +64 [label="64: Start get_global_ptr_div0_method\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 61]\n " color=yellow style=filled] 64 -> 68 ; -63 [label="63: Call _fun_set_field_ptr \n n$3=*&x:class X * [line 68]\n _fun_set_field_ptr(n$3:class X *,1:int ) [line 68]\n REMOVE_TEMPS(n$3); [line 68]\n " shape="box"] +63 [label="63: Call _fun_set_field_ptr \n n$3=*&x:class X * [line 56]\n _fun_set_field_ptr(n$3:class X *,1:int ) [line 56]\n REMOVE_TEMPS(n$3); [line 56]\n " shape="box"] 63 -> 62 ; -62 [label="62: Return Stmt \n n$1=*&x:class X * [line 69]\n n$2=_fun_X_div(n$1:class X *) [line 69]\n *&return:int =n$2 [line 69]\n REMOVE_TEMPS(n$1,n$2); [line 69]\n NULLIFY(&x,false); [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="box"] +62 [label="62: Return Stmt \n n$1=*&x:class X * [line 57]\n n$2=_fun_X_div(n$1:class X *) [line 57]\n *&return:int =n$2 [line 57]\n REMOVE_TEMPS(n$1,n$2); [line 57]\n NULLIFY(&x,false); [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] 62 -> 58 ; -61 [label="61: Prune (false branch) \n n$0=*&x:class X * [line 67]\n PRUNE((n$0 == 0), false); [line 67]\n REMOVE_TEMPS(n$0); [line 67]\n " shape="invhouse"] +61 [label="61: Prune (false branch) \n n$0=*&x:class X * [line 55]\n PRUNE((n$0 == 0), false); [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n " shape="invhouse"] 61 -> 59 ; -60 [label="60: Prune (true branch) \n n$0=*&x:class X * [line 67]\n PRUNE((n$0 != 0), true); [line 67]\n REMOVE_TEMPS(n$0); [line 67]\n " shape="invhouse"] +60 [label="60: Prune (true branch) \n n$0=*&x:class X * [line 55]\n PRUNE((n$0 != 0), true); [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n " shape="invhouse"] 60 -> 63 ; -59 [label="59: + \n NULLIFY(&x,false); [line 67]\n " ] +59 [label="59: + \n NULLIFY(&x,false); [line 55]\n " ] 59 -> 58 ; 58 [label="58: Exit field_div1_ptr \n " color=yellow style=filled] -57 [label="57: Start field_div1_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n " color=yellow style=filled] +57 [label="57: Start field_div1_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] 57 -> 60 ; 57 -> 61 ; -56 [label="56: Call _fun_set_field_ptr \n n$3=*&x:class X * [line 61]\n _fun_set_field_ptr(n$3:class X *,0:int ) [line 61]\n REMOVE_TEMPS(n$3); [line 61]\n " shape="box"] +56 [label="56: Call _fun_set_field_ptr \n n$3=*&x:class X * [line 49]\n _fun_set_field_ptr(n$3:class X *,0:int ) [line 49]\n REMOVE_TEMPS(n$3); [line 49]\n " shape="box"] 56 -> 55 ; -55 [label="55: Return Stmt \n n$1=*&x:class X * [line 62]\n n$2=_fun_X_div(n$1:class X *) [line 62]\n *&return:int =n$2 [line 62]\n REMOVE_TEMPS(n$1,n$2); [line 62]\n NULLIFY(&x,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +55 [label="55: Return Stmt \n n$1=*&x:class X * [line 50]\n n$2=_fun_X_div(n$1:class X *) [line 50]\n *&return:int =n$2 [line 50]\n REMOVE_TEMPS(n$1,n$2); [line 50]\n NULLIFY(&x,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] 55 -> 51 ; -54 [label="54: Prune (false branch) \n n$0=*&x:class X * [line 60]\n PRUNE((n$0 == 0), false); [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n " shape="invhouse"] +54 [label="54: Prune (false branch) \n n$0=*&x:class X * [line 48]\n PRUNE((n$0 == 0), false); [line 48]\n REMOVE_TEMPS(n$0); [line 48]\n " shape="invhouse"] 54 -> 52 ; -53 [label="53: Prune (true branch) \n n$0=*&x:class X * [line 60]\n PRUNE((n$0 != 0), true); [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n " shape="invhouse"] +53 [label="53: Prune (true branch) \n n$0=*&x:class X * [line 48]\n PRUNE((n$0 != 0), true); [line 48]\n REMOVE_TEMPS(n$0); [line 48]\n " shape="invhouse"] 53 -> 56 ; -52 [label="52: + \n NULLIFY(&x,false); [line 60]\n " ] +52 [label="52: + \n NULLIFY(&x,false); [line 48]\n " ] 52 -> 51 ; 51 [label="51: Exit field_div0_ptr \n " color=yellow style=filled] -50 [label="50: Start field_div0_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 59]\n " color=yellow style=filled] +50 [label="50: Start field_div0_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 47]\n " color=yellow style=filled] 50 -> 53 ; 50 -> 54 ; -49 [label="49: Call _fun_nonzero_ptr \n n$3=*&x:class X * [line 54]\n _fun_nonzero_ptr(n$3:class X *) [line 54]\n REMOVE_TEMPS(n$3); [line 54]\n " shape="box"] +49 [label="49: Call _fun_nonzero_ptr \n n$3=*&x:class X * [line 42]\n _fun_nonzero_ptr(n$3:class X *) [line 42]\n REMOVE_TEMPS(n$3); [line 42]\n " shape="box"] 49 -> 48 ; -48 [label="48: Return Stmt \n n$1=*&x:class X * [line 55]\n n$2=_fun_X_div(n$1:class X *) [line 55]\n *&return:int =n$2 [line 55]\n REMOVE_TEMPS(n$1,n$2); [line 55]\n NULLIFY(&x,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +48 [label="48: Return Stmt \n n$1=*&x:class X * [line 43]\n n$2=_fun_X_div(n$1:class X *) [line 43]\n *&return:int =n$2 [line 43]\n REMOVE_TEMPS(n$1,n$2); [line 43]\n NULLIFY(&x,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 48 -> 44 ; -47 [label="47: Prune (false branch) \n n$0=*&x:class X * [line 53]\n PRUNE((n$0 == 0), false); [line 53]\n REMOVE_TEMPS(n$0); [line 53]\n " shape="invhouse"] +47 [label="47: Prune (false branch) \n n$0=*&x:class X * [line 41]\n PRUNE((n$0 == 0), false); [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n " shape="invhouse"] 47 -> 45 ; -46 [label="46: Prune (true branch) \n n$0=*&x:class X * [line 53]\n PRUNE((n$0 != 0), true); [line 53]\n REMOVE_TEMPS(n$0); [line 53]\n " shape="invhouse"] +46 [label="46: Prune (true branch) \n n$0=*&x:class X * [line 41]\n PRUNE((n$0 != 0), true); [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n " shape="invhouse"] 46 -> 49 ; -45 [label="45: + \n NULLIFY(&x,false); [line 53]\n " ] +45 [label="45: + \n NULLIFY(&x,false); [line 41]\n " ] 45 -> 44 ; 44 [label="44: Exit method_div1_ptr \n " color=yellow style=filled] -43 [label="43: Start method_div1_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 52]\n " color=yellow style=filled] +43 [label="43: Start method_div1_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] 43 -> 46 ; 43 -> 47 ; -42 [label="42: Call _fun_zero_ptr \n n$3=*&x:class X * [line 47]\n _fun_zero_ptr(n$3:class X *) [line 47]\n REMOVE_TEMPS(n$3); [line 47]\n " shape="box"] +42 [label="42: Call _fun_zero_ptr \n n$3=*&x:class X * [line 35]\n _fun_zero_ptr(n$3:class X *) [line 35]\n REMOVE_TEMPS(n$3); [line 35]\n " shape="box"] 42 -> 41 ; -41 [label="41: Return Stmt \n n$1=*&x:class X * [line 48]\n n$2=_fun_X_div(n$1:class X *) [line 48]\n *&return:int =n$2 [line 48]\n REMOVE_TEMPS(n$1,n$2); [line 48]\n NULLIFY(&x,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +41 [label="41: Return Stmt \n n$1=*&x:class X * [line 36]\n n$2=_fun_X_div(n$1:class X *) [line 36]\n *&return:int =n$2 [line 36]\n REMOVE_TEMPS(n$1,n$2); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 41 -> 37 ; -40 [label="40: Prune (false branch) \n n$0=*&x:class X * [line 46]\n PRUNE((n$0 == 0), false); [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n " shape="invhouse"] +40 [label="40: Prune (false branch) \n n$0=*&x:class X * [line 34]\n PRUNE((n$0 == 0), false); [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n " shape="invhouse"] 40 -> 38 ; -39 [label="39: Prune (true branch) \n n$0=*&x:class X * [line 46]\n PRUNE((n$0 != 0), true); [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n " shape="invhouse"] +39 [label="39: Prune (true branch) \n n$0=*&x:class X * [line 34]\n PRUNE((n$0 != 0), true); [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n " shape="invhouse"] 39 -> 42 ; -38 [label="38: + \n NULLIFY(&x,false); [line 46]\n " ] +38 [label="38: + \n NULLIFY(&x,false); [line 34]\n " ] 38 -> 37 ; 37 [label="37: Exit method_div0_ptr \n " color=yellow style=filled] -36 [label="36: Start method_div0_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 45]\n " color=yellow style=filled] +36 [label="36: Start method_div0_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 33]\n " color=yellow style=filled] 36 -> 39 ; 36 -> 40 ; -35 [label="35: Return Stmt \n *&return:class X &=&#GB$global [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +35 [label="35: Return Stmt \n *&return:class X &=&#GB$global [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 35 -> 34 ; 34 [label="34: Exit get_global_ref \n " color=yellow style=filled] -33 [label="33: Start get_global_ref\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 43]\n " color=yellow style=filled] +33 [label="33: Start get_global_ref\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 31]\n " color=yellow style=filled] 33 -> 35 ; -32 [label="32: Return Stmt \n *&return:class X *=&#GB$global [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +32 [label="32: Return Stmt \n *&return:class X *=&#GB$global [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 32 -> 31 ; 31 [label="31: Exit get_global_ptr \n " color=yellow style=filled] -30 [label="30: Start get_global_ptr\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] +30 [label="30: Start get_global_ptr\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 30 -> 32 ; -29 [label="29: BinaryOperatorStmt: Assign \n n$0=*&x:class X & [line 38]\n n$1=*&val:int [line 38]\n *n$0.f:int =n$1 [line 38]\n REMOVE_TEMPS(n$0,n$1); [line 38]\n NULLIFY(&val,false); [line 38]\n NULLIFY(&x,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +29 [label="29: BinaryOperatorStmt: Assign \n n$0=*&x:class X & [line 27]\n n$1=*&val:int [line 27]\n *n$0.f:int =n$1 [line 27]\n REMOVE_TEMPS(n$0,n$1); [line 27]\n NULLIFY(&val,false); [line 27]\n NULLIFY(&x,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 29 -> 28 ; 28 [label="28: Exit set_field_ref \n " color=yellow style=filled] -27 [label="27: Start set_field_ref\nFormals: x:class X & val:int \nLocals: \n DECLARE_LOCALS(&return); [line 37]\n " color=yellow style=filled] +27 [label="27: Start set_field_ref\nFormals: x:class X & val:int \nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] 27 -> 29 ; -26 [label="26: Call _fun_X_nonzero \n n$0=*&x:class X & [line 34]\n _fun_X_nonzero(n$0:class X &) [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n NULLIFY(&x,false); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] +26 [label="26: Call _fun_X_nonzero \n n$0=*&x:class X & [line 25]\n _fun_X_nonzero(n$0:class X &) [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n NULLIFY(&x,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 26 -> 25 ; 25 [label="25: Exit nonzero_ref \n " color=yellow style=filled] -24 [label="24: Start nonzero_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 33]\n " color=yellow style=filled] +24 [label="24: Start nonzero_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 24 -> 26 ; -23 [label="23: Call _fun_X_zero \n n$0=*&x:class X & [line 30]\n _fun_X_zero(n$0:class X &) [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n NULLIFY(&x,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +23 [label="23: Call _fun_X_zero \n n$0=*&x:class X & [line 23]\n _fun_X_zero(n$0:class X &) [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 23 -> 22 ; 22 [label="22: Exit zero_ref \n " color=yellow style=filled] -21 [label="21: Start zero_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] +21 [label="21: Start zero_ref\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] 21 -> 23 ; -20 [label="20: BinaryOperatorStmt: Assign \n n$0=*&x:class X * [line 26]\n n$1=*&val:int [line 26]\n *n$0.f:int =n$1 [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&val,false); [line 26]\n NULLIFY(&x,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +20 [label="20: BinaryOperatorStmt: Assign \n n$0=*&x:class X * [line 21]\n n$1=*&val:int [line 21]\n *n$0.f:int =n$1 [line 21]\n REMOVE_TEMPS(n$0,n$1); [line 21]\n NULLIFY(&val,false); [line 21]\n NULLIFY(&x,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 20 -> 19 ; 19 [label="19: Exit set_field_ptr \n " color=yellow style=filled] -18 [label="18: Start set_field_ptr\nFormals: x:class X * val:int \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +18 [label="18: Start set_field_ptr\nFormals: x:class X * val:int \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] 18 -> 20 ; -17 [label="17: Call _fun_X_nonzero \n n$0=*&x:class X * [line 22]\n _fun_X_nonzero(n$0:class X *) [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&x,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +17 [label="17: Call _fun_X_nonzero \n n$0=*&x:class X * [line 19]\n _fun_X_nonzero(n$0:class X *) [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n NULLIFY(&x,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit nonzero_ptr \n " color=yellow style=filled] -15 [label="15: Start nonzero_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +15 [label="15: Start nonzero_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled] 15 -> 17 ; -14 [label="14: Call _fun_X_zero \n n$0=*&x:class X * [line 18]\n _fun_X_zero(n$0:class X *) [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&x,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +14 [label="14: Call _fun_X_zero \n n$0=*&x:class X * [line 17]\n _fun_X_zero(n$0:class X *) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n NULLIFY(&x,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 14 -> 13 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_type_e2e.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_type_e2e.cpp index 358c96a76..162bde98a 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/reference_type_e2e.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/reference_type_e2e.cpp @@ -14,56 +14,56 @@ int ptr_div0() { int a = 2; int* p = &a; *p = 0; - return 1/a; + return 1 / a; } int ptr_div0_function() { int a = 2; zero_ptr(&a); - return 1/a; + return 1 / a; } int ptr_div0_function_temp_var() { int a = 2; - int *r = &a; + int* r = &a; zero_ptr(r); - return 1/a; + return 1 / a; } int ref_div0() { int a = 2; int& r = a; r = 0; - return 1/a; + return 1 / a; } int ref_div0_function() { int a = 2; zero_ref(a); - return 1/a; + return 1 / a; } int ref_div0_function_temp_var() { int a = 2; - int &r = a; + int& r = a; zero_ref(r); - return 1/a; + return 1 / a; } int ref_div0_nested_assignment() { int a = 2; int b = 3; - int &r1 = a; - int &r2 = r1 = b = 1; + int& r1 = a; + int& r2 = r1 = b = 1; r2 = 0; - return 1/a; + return 1 / a; } int ref_div1_nested_assignment() { int a = 2; int b = 3; - int &r1 = a; - int &r2 = r1 = b = 1; + int& r1 = a; + int& r2 = r1 = b = 1; r2 = 0; - return 1/b; + return 1 / b; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp index be3f080ad..a9a57ed08 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp @@ -14,9 +14,7 @@ int div0_init_expr() { return div(a); } -int div0_function_param_cast() { - return div(0); -} +int div0_function_param_cast() { return div(0); } // to compare with cfgs when no MaterializeTemporaryExpr is produced int div0_no_const_ref() { diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp.dot index 8f34bab3e..ae1a992d9 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/temporary_lvalue.cpp.dot @@ -1,20 +1,20 @@ digraph iCFG { -14 [label="14: DeclStmt \n *&a:int =0 [line 23]\n " shape="box"] +14 [label="14: DeclStmt \n *&a:int =0 [line 21]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$0=_fun_div(&a:int &) [line 24]\n *&return:int =n$0 [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n NULLIFY(&a,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +13 [label="13: Return Stmt \n n$0=_fun_div(&a:int &) [line 22]\n *&return:int =n$0 [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&a,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit div0_no_const_ref \n " color=yellow style=filled] -11 [label="11: Start div0_no_const_ref\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 22]\n " color=yellow style=filled] +11 [label="11: Start div0_no_const_ref\nFormals: \nLocals: a:int \n DECLARE_LOCALS(&return,&a); [line 20]\n " color=yellow style=filled] 11 -> 14 ; -10 [label="10: Return Stmt \n *&SIL_materialize_temp__n$0:int =0 [line 18]\n n$1=_fun_div(&SIL_materialize_temp__n$0:int &) [line 18]\n *&return:int =n$1 [line 18]\n REMOVE_TEMPS(n$1); [line 18]\n NULLIFY(&SIL_materialize_temp__n$0,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] +10 [label="10: Return Stmt \n *&SIL_materialize_temp__n$0:int =0 [line 17]\n n$1=_fun_div(&SIL_materialize_temp__n$0:int &) [line 17]\n *&return:int =n$1 [line 17]\n REMOVE_TEMPS(n$1); [line 17]\n NULLIFY(&SIL_materialize_temp__n$0,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 10 -> 9 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/reference/unbox.cpp b/infer/tests/codetoanalyze/cpp/frontend/reference/unbox.cpp index 797e1a983..3d1b635c2 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/reference/unbox.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/reference/unbox.cpp @@ -7,9 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int fun_p(int *p) { return *p;} -int fun_v(int p) { return p;} -int fun_r(int &p) { return p;} +int fun_p(int* p) { return *p; } +int fun_v(int p) { return p; } +int fun_r(int& p) { return p; } // cfgs should look similar for unbox_ref and unbox_ptr @@ -26,7 +26,7 @@ void unbox_ref() { // test conversions from int* to {int*, int, int&) void unbox_ptr() { int a = 3; - int *p = &a; + int* p = &a; fun_p(p); fun_v(*p); diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp index e47051d48..714584f1c 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp @@ -18,7 +18,7 @@ struct Choose2 { int extra(int a) { return 1 / a; } }; -template +template struct ExecStore { T f; int call_div(int a) { @@ -27,24 +27,15 @@ struct ExecStore { } }; +int choose1_div0(ExecStore& s) { return s.call_div(0); } -int choose1_div0(ExecStore &s) { - return s.call_div(0); -} - -int choose1_div1(ExecStore &s) { - return s.call_div(1); -} +int choose1_div1(ExecStore& s) { return s.call_div(1); } -int choose2_div0_no_report(ExecStore &s) { +int choose2_div0_no_report(ExecStore& s) { // error is already reported for ExecStore::call_div() return s.call_div(1); } -int choose2_div0_extra(ExecStore &s) { - return s.f.extra(0); -} +int choose2_div0_extra(ExecStore& s) { return s.f.extra(0); } -int choose2_div1_extra(ExecStore &s) { - return s.f.extra(1); -} +int choose2_div1_extra(ExecStore& s) { return s.f.extra(1); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp.dot index 3a11c0b4c..c49a9b5ee 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/class_template_instantiate.cpp.dot @@ -1,56 +1,56 @@ digraph iCFG { -30 [label="30: Return Stmt \n n$0=*&s:class ExecStore & [line 49]\n n$1=_fun_Choose2_extra(n$0.f:class Choose2 &,1:int ) [line 49]\n *&return:int =n$1 [line 49]\n REMOVE_TEMPS(n$0,n$1); [line 49]\n NULLIFY(&s,false); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +30 [label="30: Return Stmt \n n$0=*&s:class ExecStore & [line 41]\n n$1=_fun_Choose2_extra(n$0.f:class Choose2 &,1:int ) [line 41]\n *&return:int =n$1 [line 41]\n REMOVE_TEMPS(n$0,n$1); [line 41]\n NULLIFY(&s,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 30 -> 29 ; 29 [label="29: Exit choose2_div1_extra \n " color=yellow style=filled] -28 [label="28: Start choose2_div1_extra\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 48]\n " color=yellow style=filled] +28 [label="28: Start choose2_div1_extra\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 41]\n " color=yellow style=filled] 28 -> 30 ; -27 [label="27: Return Stmt \n n$0=*&s:class ExecStore & [line 45]\n n$1=_fun_Choose2_extra(n$0.f:class Choose2 &,0:int ) [line 45]\n *&return:int =n$1 [line 45]\n REMOVE_TEMPS(n$0,n$1); [line 45]\n NULLIFY(&s,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] +27 [label="27: Return Stmt \n n$0=*&s:class ExecStore & [line 39]\n n$1=_fun_Choose2_extra(n$0.f:class Choose2 &,0:int ) [line 39]\n *&return:int =n$1 [line 39]\n REMOVE_TEMPS(n$0,n$1); [line 39]\n NULLIFY(&s,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit choose2_div0_extra \n " color=yellow style=filled] -25 [label="25: Start choose2_div0_extra\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 44]\n " color=yellow style=filled] +25 [label="25: Start choose2_div0_extra\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 39]\n " color=yellow style=filled] 25 -> 27 ; -24 [label="24: Return Stmt \n n$0=*&s:class ExecStore & [line 41]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,1:int ) [line 41]\n *&return:int =n$1 [line 41]\n REMOVE_TEMPS(n$0,n$1); [line 41]\n NULLIFY(&s,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] +24 [label="24: Return Stmt \n n$0=*&s:class ExecStore & [line 36]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,1:int ) [line 36]\n *&return:int =n$1 [line 36]\n REMOVE_TEMPS(n$0,n$1); [line 36]\n NULLIFY(&s,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 24 -> 23 ; 23 [label="23: Exit choose2_div0_no_report \n " color=yellow style=filled] -22 [label="22: Start choose2_div0_no_report\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 39]\n " color=yellow style=filled] +22 [label="22: Start choose2_div0_no_report\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 22 -> 24 ; -21 [label="21: Return Stmt \n n$0=*&s:class ExecStore & [line 36]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,1:int ) [line 36]\n *&return:int =n$1 [line 36]\n REMOVE_TEMPS(n$0,n$1); [line 36]\n NULLIFY(&s,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&s:class ExecStore & [line 32]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,1:int ) [line 32]\n *&return:int =n$1 [line 32]\n REMOVE_TEMPS(n$0,n$1); [line 32]\n NULLIFY(&s,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit choose1_div1 \n " color=yellow style=filled] -19 [label="19: Start choose1_div1\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 35]\n " color=yellow style=filled] +19 [label="19: Start choose1_div1\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] 19 -> 21 ; -18 [label="18: Return Stmt \n n$0=*&s:class ExecStore & [line 32]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,0:int ) [line 32]\n *&return:int =n$1 [line 32]\n REMOVE_TEMPS(n$0,n$1); [line 32]\n NULLIFY(&s,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&s:class ExecStore & [line 30]\n n$1=_fun_ExecStore_call_div(n$0:class ExecStore &,0:int ) [line 30]\n *&return:int =n$1 [line 30]\n REMOVE_TEMPS(n$0,n$1); [line 30]\n NULLIFY(&s,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit choose1_div0 \n " color=yellow style=filled] -16 [label="16: Start choose1_div0\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 31]\n " color=yellow style=filled] +16 [label="16: Start choose1_div0\nFormals: s:class ExecStore &\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 16 -> 18 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp index 0a7d92d03..0ae6337f1 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/function.cpp @@ -19,24 +19,24 @@ struct X3 { int get() { return 0; } }; -template -int getVal(T &x) { +template +int getVal(T& x) { return x.getVal(); } // explicit specialization -template<> -int getVal(X3 &x) { +template <> +int getVal(X3& x) { return x.get(); } -template +template int createAndGetVal() { T x; return getVal(x); } -template +template int createAndDiv() { return 1 / createAndGetVal(); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp index b2a53579a..2ad343adf 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp @@ -20,14 +20,18 @@ struct X3 { }; struct Getter { - template - int get(S &s) { return s.get(); } + template + int get(S& s) { + return s.get(); + } }; -template +template struct GetterTempl { - template - int get(T &t, S &s) { return t.get() + s.get(); } + template + int get(T& t, S& s) { + return t.get() + s.get(); + } }; int div0_getter() { diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot index cb3af7ba7..b049327c2 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/method.cpp.dot @@ -1,188 +1,188 @@ digraph iCFG { -73 [label="73: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 66]\n " shape="box"] +73 [label="73: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 70]\n " shape="box"] 73 -> 72 ; -72 [label="72: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 67]\n " shape="box"] +72 [label="72: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 71]\n " shape="box"] 72 -> 71 ; -71 [label="71: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x1:class X1 &,&x1:class X1 &) [line 68]\n *&return:int =(1 / n$0) [line 68]\n REMOVE_TEMPS(n$0); [line 68]\n NULLIFY(&g,false); [line 68]\n NULLIFY(&x1,false); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"] +71 [label="71: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x1:class X1 &,&x1:class X1 &) [line 72]\n *&return:int =(1 / n$0) [line 72]\n REMOVE_TEMPS(n$0); [line 72]\n NULLIFY(&g,false); [line 72]\n NULLIFY(&x1,false); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="box"] 71 -> 70 ; 70 [label="70: Exit div1_getter_templ2 \n " color=yellow style=filled] -69 [label="69: Start div1_getter_templ2\nFormals: \nLocals: g:class GetterTempl x1:class X1 \n DECLARE_LOCALS(&return,&g,&x1); [line 65]\n " color=yellow style=filled] +69 [label="69: Start div1_getter_templ2\nFormals: \nLocals: g:class GetterTempl x1:class X1 \n DECLARE_LOCALS(&return,&g,&x1); [line 69]\n " color=yellow style=filled] 69 -> 73 ; -68 [label="68: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 59]\n " shape="box"] +68 [label="68: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 63]\n " shape="box"] 68 -> 67 ; -67 [label="67: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 60]\n " shape="box"] +67 [label="67: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 64]\n " shape="box"] 67 -> 66 ; -66 [label="66: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 61]\n " shape="box"] +66 [label="66: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 65]\n " shape="box"] 66 -> 65 ; -65 [label="65: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x2:class X2 &,&x1:class X1 &) [line 62]\n *&return:int =(1 / n$0) [line 62]\n REMOVE_TEMPS(n$0); [line 62]\n NULLIFY(&g,false); [line 62]\n NULLIFY(&x1,false); [line 62]\n NULLIFY(&x2,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +65 [label="65: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x2:class X2 &,&x1:class X1 &) [line 66]\n *&return:int =(1 / n$0) [line 66]\n REMOVE_TEMPS(n$0); [line 66]\n NULLIFY(&g,false); [line 66]\n NULLIFY(&x1,false); [line 66]\n NULLIFY(&x2,false); [line 66]\n APPLY_ABSTRACTION; [line 66]\n " shape="box"] 65 -> 64 ; 64 [label="64: Exit div1_getter_templ \n " color=yellow style=filled] -63 [label="63: Start div1_getter_templ\nFormals: \nLocals: g:class GetterTempl x2:class X2 x1:class X1 \n DECLARE_LOCALS(&return,&g,&x2,&x1); [line 58]\n " color=yellow style=filled] +63 [label="63: Start div1_getter_templ\nFormals: \nLocals: g:class GetterTempl x2:class X2 x1:class X1 \n DECLARE_LOCALS(&return,&g,&x2,&x1); [line 62]\n " color=yellow style=filled] 63 -> 68 ; -62 [label="62: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 53]\n " shape="box"] +62 [label="62: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 57]\n " shape="box"] 62 -> 61 ; -61 [label="61: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 54]\n " shape="box"] +61 [label="61: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 58]\n " shape="box"] 61 -> 60 ; -60 [label="60: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x2:class X2 &,&x2:class X2 &) [line 55]\n *&return:int =(1 / n$0) [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n NULLIFY(&g,false); [line 55]\n NULLIFY(&x2,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +60 [label="60: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x2:class X2 &,&x2:class X2 &) [line 59]\n *&return:int =(1 / n$0) [line 59]\n REMOVE_TEMPS(n$0); [line 59]\n NULLIFY(&g,false); [line 59]\n NULLIFY(&x2,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] 60 -> 59 ; 59 [label="59: Exit div0_getter_templ2 \n " color=yellow style=filled] -58 [label="58: Start div0_getter_templ2\nFormals: \nLocals: g:class GetterTempl x2:class X2 \n DECLARE_LOCALS(&return,&g,&x2); [line 52]\n " color=yellow style=filled] +58 [label="58: Start div0_getter_templ2\nFormals: \nLocals: g:class GetterTempl x2:class X2 \n DECLARE_LOCALS(&return,&g,&x2); [line 56]\n " color=yellow style=filled] 58 -> 62 ; -57 [label="57: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 46]\n " shape="box"] +57 [label="57: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 50]\n " shape="box"] 57 -> 56 ; -56 [label="56: DeclStmt \n _fun_X3_X3(&x3:class X3 *) [line 47]\n " shape="box"] +56 [label="56: DeclStmt \n _fun_X3_X3(&x3:class X3 *) [line 51]\n " shape="box"] 56 -> 55 ; -55 [label="55: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 48]\n " shape="box"] +55 [label="55: DeclStmt \n _fun_GetterTempl_GetterTempl(&g:class GetterTempl *) [line 52]\n " shape="box"] 55 -> 54 ; -54 [label="54: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x3:class X3 &,&x2:class X2 &) [line 49]\n *&return:int =(1 / n$0) [line 49]\n REMOVE_TEMPS(n$0); [line 49]\n NULLIFY(&g,false); [line 49]\n NULLIFY(&x2,false); [line 49]\n NULLIFY(&x3,false); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +54 [label="54: Return Stmt \n n$0=_fun_GetterTempl_get(&g:class GetterTempl &,&x3:class X3 &,&x2:class X2 &) [line 53]\n *&return:int =(1 / n$0) [line 53]\n REMOVE_TEMPS(n$0); [line 53]\n NULLIFY(&g,false); [line 53]\n NULLIFY(&x2,false); [line 53]\n NULLIFY(&x3,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] 54 -> 53 ; 53 [label="53: Exit 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 45]\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 -> 57 ; -51 [label="51: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 40]\n " shape="box"] +51 [label="51: DeclStmt \n _fun_X1_X1(&x1:class X1 *) [line 44]\n " shape="box"] 51 -> 50 ; -50 [label="50: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 41]\n " shape="box"] +50 [label="50: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 45]\n " shape="box"] 50 -> 49 ; -49 [label="49: Return Stmt \n n$0=_fun_Getter_get(&g:class Getter &,&x1:class X1 &) [line 42]\n *&return:int =(1 / n$0) [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n NULLIFY(&g,false); [line 42]\n NULLIFY(&x1,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +49 [label="49: Return Stmt \n n$0=_fun_Getter_get(&g:class Getter &,&x1:class X1 &) [line 46]\n *&return:int =(1 / n$0) [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n NULLIFY(&g,false); [line 46]\n NULLIFY(&x1,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 49 -> 48 ; 48 [label="48: Exit 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 39]\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 -> 51 ; -46 [label="46: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 34]\n " shape="box"] +46 [label="46: DeclStmt \n _fun_X2_X2(&x2:class X2 *) [line 38]\n " shape="box"] 46 -> 45 ; -45 [label="45: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 35]\n " shape="box"] +45 [label="45: DeclStmt \n _fun_Getter_Getter(&g:class Getter *) [line 39]\n " shape="box"] 45 -> 44 ; -44 [label="44: Return Stmt \n n$0=_fun_Getter_get(&g:class Getter &,&x2:class X2 &) [line 36]\n *&return:int =(1 / n$0) [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&g,false); [line 36]\n NULLIFY(&x2,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] +44 [label="44: Return Stmt \n n$0=_fun_Getter_get(&g:class Getter &,&x2:class X2 &) [line 40]\n *&return:int =(1 / n$0) [line 40]\n REMOVE_TEMPS(n$0); [line 40]\n NULLIFY(&g,false); [line 40]\n NULLIFY(&x2,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] 44 -> 43 ; 43 [label="43: Exit 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 33]\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 -> 46 ; 41 [label="41: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] -40 [label="40: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n NULLIFY(&this,false); [line 28]\n " color=yellow style=filled] +40 [label="40: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n NULLIFY(&this,false); [line 30]\n " color=yellow style=filled] 40 -> 41 ; -39 [label="39: Return Stmt \n n$0=*&t:class X1 & [line 30]\n n$1=_fun_X1_get(n$0:class X1 &) [line 30]\n n$2=*&s:class X1 & [line 30]\n n$3=_fun_X1_get(n$2:class X1 &) [line 30]\n *&return:int =(n$1 + n$3) [line 30]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 30]\n NULLIFY(&s,false); [line 30]\n NULLIFY(&t,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +39 [label="39: Return Stmt \n n$0=*&t:class X1 & [line 33]\n n$1=_fun_X1_get(n$0:class X1 &) [line 33]\n n$2=*&s:class X1 & [line 33]\n n$3=_fun_X1_get(n$2:class X1 &) [line 33]\n *&return:int =(n$1 + n$3) [line 33]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 33]\n NULLIFY(&s,false); [line 33]\n NULLIFY(&t,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 39 -> 38 ; 38 [label="38: Exit 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 30]\n NULLIFY(&this,false); [line 30]\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 NULLIFY(&this,false); [line 32]\n " color=yellow style=filled] 37 -> 39 ; 36 [label="36: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] -35 [label="35: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n NULLIFY(&this,false); [line 28]\n " color=yellow style=filled] +35 [label="35: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n NULLIFY(&this,false); [line 30]\n " color=yellow style=filled] 35 -> 36 ; -34 [label="34: Return Stmt \n n$0=*&t:class X2 & [line 30]\n n$1=_fun_X2_get(n$0:class X2 &) [line 30]\n n$2=*&s:class X1 & [line 30]\n n$3=_fun_X1_get(n$2:class X1 &) [line 30]\n *&return:int =(n$1 + n$3) [line 30]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 30]\n NULLIFY(&s,false); [line 30]\n NULLIFY(&t,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +34 [label="34: Return Stmt \n n$0=*&t:class X2 & [line 33]\n n$1=_fun_X2_get(n$0:class X2 &) [line 33]\n n$2=*&s:class X1 & [line 33]\n n$3=_fun_X1_get(n$2:class X1 &) [line 33]\n *&return:int =(n$1 + n$3) [line 33]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 33]\n NULLIFY(&s,false); [line 33]\n NULLIFY(&t,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 34 -> 33 ; 33 [label="33: Exit 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 30]\n NULLIFY(&this,false); [line 30]\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 NULLIFY(&this,false); [line 32]\n " color=yellow style=filled] 32 -> 34 ; -31 [label="31: Return Stmt \n n$0=*&t:class X2 & [line 30]\n n$1=_fun_X2_get(n$0:class X2 &) [line 30]\n n$2=*&s:class X2 & [line 30]\n n$3=_fun_X2_get(n$2:class X2 &) [line 30]\n *&return:int =(n$1 + n$3) [line 30]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 30]\n NULLIFY(&s,false); [line 30]\n NULLIFY(&t,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +31 [label="31: Return Stmt \n n$0=*&t:class X2 & [line 33]\n n$1=_fun_X2_get(n$0:class X2 &) [line 33]\n n$2=*&s:class X2 & [line 33]\n n$3=_fun_X2_get(n$2:class X2 &) [line 33]\n *&return:int =(n$1 + n$3) [line 33]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 33]\n NULLIFY(&s,false); [line 33]\n NULLIFY(&t,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 31 -> 30 ; 30 [label="30: Exit 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 30]\n NULLIFY(&this,false); [line 30]\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 NULLIFY(&this,false); [line 32]\n " color=yellow style=filled] 29 -> 31 ; 28 [label="28: Exit GetterTempl_GetterTempl \n " color=yellow style=filled] -27 [label="27: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n NULLIFY(&this,false); [line 28]\n " color=yellow style=filled] +27 [label="27: Start GetterTempl_GetterTempl\nFormals: this:class GetterTempl *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n NULLIFY(&this,false); [line 30]\n " color=yellow style=filled] 27 -> 28 ; -26 [label="26: Return Stmt \n n$0=*&t:class X3 & [line 30]\n n$1=_fun_X3_get(n$0:class X3 &) [line 30]\n n$2=*&s:class X2 & [line 30]\n n$3=_fun_X2_get(n$2:class X2 &) [line 30]\n *&return:int =(n$1 + n$3) [line 30]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 30]\n NULLIFY(&s,false); [line 30]\n NULLIFY(&t,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +26 [label="26: Return Stmt \n n$0=*&t:class X3 & [line 33]\n n$1=_fun_X3_get(n$0:class X3 &) [line 33]\n n$2=*&s:class X2 & [line 33]\n n$3=_fun_X2_get(n$2:class X2 &) [line 33]\n *&return:int =(n$1 + n$3) [line 33]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 33]\n NULLIFY(&s,false); [line 33]\n NULLIFY(&t,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 26 -> 25 ; 25 [label="25: Exit 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 30]\n NULLIFY(&this,false); [line 30]\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 NULLIFY(&this,false); [line 32]\n " color=yellow style=filled] 24 -> 26 ; @@ -193,7 +193,7 @@ digraph iCFG { 22 -> 23 ; -21 [label="21: Return Stmt \n n$0=*&s:class X1 & [line 24]\n n$1=_fun_X1_get(n$0:class X1 &) [line 24]\n *&return:int =n$1 [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n NULLIFY(&s,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&s:class X1 & [line 25]\n n$1=_fun_X1_get(n$0:class X1 &) [line 25]\n *&return:int =n$1 [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n NULLIFY(&s,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 21 -> 20 ; @@ -204,7 +204,7 @@ digraph iCFG { 19 -> 21 ; -18 [label="18: Return Stmt \n n$0=*&s:class X2 & [line 24]\n n$1=_fun_X2_get(n$0:class X2 &) [line 24]\n *&return:int =n$1 [line 24]\n REMOVE_TEMPS(n$0,n$1); [line 24]\n NULLIFY(&s,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +18 [label="18: Return Stmt \n n$0=*&s:class X2 & [line 25]\n n$1=_fun_X2_get(n$0:class X2 &) [line 25]\n *&return:int =n$1 [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n NULLIFY(&s,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 18 -> 17 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/templates/simple.cpp b/infer/tests/codetoanalyze/cpp/frontend/templates/simple.cpp index 43afb9f74..8ba5b8c1d 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/templates/simple.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/templates/simple.cpp @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -template +template struct Container { T field; }; @@ -16,12 +16,12 @@ struct X { int field; }; -int div0_template_field(Container &v) { +int div0_template_field(Container& v) { v.field = 0; return 1 / v.field; } -int div0_struct_field(X &v) { +int div0_struct_field(X& v) { v.field = 0; return 1 / v.field; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp index e9f98b767..0fac2fd59 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp @@ -12,6 +12,4 @@ void stat_cast() { long long la = static_cast(a); } -void functional_cast() { - int a = int(2 + 3.4); -} +void functional_cast() { int a = int(2 + 3.4); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp.dot index 8be61c3e9..565bb4a70 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/casts.cpp.dot @@ -1,5 +1,5 @@ digraph iCFG { -6 [label="6: DeclStmt \n *&a:int =(2 + 3.400000) [line 16]\n NULLIFY(&a,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +6 [label="6: DeclStmt \n *&a:int =(2 + 3.400000) [line 15]\n NULLIFY(&a,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 6 -> 5 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp index e05d0e7ed..823238583 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp @@ -7,19 +7,13 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int fun_default(int a = 3, int b = 5) { - return a + b; -} +int fun_default(int a = 3, int b = 5) { return a + b; } int fun_default_decl(int a, int b = 5); // note that b is default param, but function was declared earlier -int fun_default_decl(int a, int b) { - return a + b; -} +int fun_default_decl(int a, int b) { return a + b; } -int fun_ignore_param(int a, int, int) { - return a; -} +int fun_ignore_param(int a, int, int) { return a; } void test() { fun_default(1, 2); @@ -27,9 +21,7 @@ void test() { fun_default(); fun_default_decl(6); - fun_default_decl(6,6); + fun_default_decl(6, 6); } -void test2() { - fun_ignore_param(1, 1, 1); -} +void test2() { fun_ignore_param(1, 1, 1); } diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp.dot index 6424e635b..901a601a6 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/functions.cpp.dot @@ -1,65 +1,65 @@ digraph iCFG { -19 [label="19: Call _fun_fun_ignore_param \n n$0=_fun_fun_ignore_param(1:int ,1:int ,1:int ) [line 34]\n REMOVE_TEMPS(n$0); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"] +19 [label="19: Call _fun_fun_ignore_param \n n$0=_fun_fun_ignore_param(1:int ,1:int ,1:int ) [line 27]\n REMOVE_TEMPS(n$0); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 19 -> 18 ; 18 [label="18: Exit test2 \n " color=yellow style=filled] -17 [label="17: Start test2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 33]\n " color=yellow style=filled] +17 [label="17: Start test2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] 17 -> 19 ; -16 [label="16: Call _fun_fun_default \n n$4=_fun_fun_default(1:int ,2:int ) [line 25]\n REMOVE_TEMPS(n$4); [line 25]\n " shape="box"] +16 [label="16: Call _fun_fun_default \n n$4=_fun_fun_default(1:int ,2:int ) [line 19]\n REMOVE_TEMPS(n$4); [line 19]\n " shape="box"] 16 -> 15 ; -15 [label="15: Call _fun_fun_default \n n$3=_fun_fun_default(1:int ,5:int ) [line 26]\n REMOVE_TEMPS(n$3); [line 26]\n " shape="box"] +15 [label="15: Call _fun_fun_default \n n$3=_fun_fun_default(1:int ,5:int ) [line 20]\n REMOVE_TEMPS(n$3); [line 20]\n " shape="box"] 15 -> 14 ; -14 [label="14: Call _fun_fun_default \n n$2=_fun_fun_default(3:int ,5:int ) [line 27]\n REMOVE_TEMPS(n$2); [line 27]\n " shape="box"] +14 [label="14: Call _fun_fun_default \n n$2=_fun_fun_default(3:int ,5:int ) [line 21]\n REMOVE_TEMPS(n$2); [line 21]\n " shape="box"] 14 -> 13 ; -13 [label="13: Call _fun_fun_default_decl \n n$1=_fun_fun_default_decl(6:int ,5:int ) [line 29]\n REMOVE_TEMPS(n$1); [line 29]\n " shape="box"] +13 [label="13: Call _fun_fun_default_decl \n n$1=_fun_fun_default_decl(6:int ,5:int ) [line 23]\n REMOVE_TEMPS(n$1); [line 23]\n " shape="box"] 13 -> 12 ; -12 [label="12: Call _fun_fun_default_decl \n n$0=_fun_fun_default_decl(6:int ,6:int ) [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +12 [label="12: Call _fun_fun_default_decl \n n$0=_fun_fun_default_decl(6:int ,6:int ) [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit test \n " color=yellow style=filled] -10 [label="10: Start test\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +10 [label="10: Start test\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 18]\n " color=yellow style=filled] 10 -> 16 ; -9 [label="9: Return Stmt \n n$0=*&a:int [line 21]\n *&return:int =n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n NULLIFY(&a,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +9 [label="9: Return Stmt \n n$0=*&a:int [line 16]\n *&return:int =n$0 [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&a,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit fun_ignore_param \n " color=yellow style=filled] -7 [label="7: Start fun_ignore_param\nFormals: a:int __param_1:int __param_2:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&__param_1,false); [line 20]\n NULLIFY(&__param_2,false); [line 20]\n " color=yellow style=filled] +7 [label="7: Start fun_ignore_param\nFormals: a:int __param_1:int __param_2:int \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n NULLIFY(&__param_1,false); [line 16]\n NULLIFY(&__param_2,false); [line 16]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Return Stmt \n n$0=*&a:int [line 17]\n n$1=*&b:int [line 17]\n *&return:int =(n$0 + n$1) [line 17]\n REMOVE_TEMPS(n$0,n$1); [line 17]\n NULLIFY(&a,false); [line 17]\n NULLIFY(&b,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&a:int [line 14]\n n$1=*&b:int [line 14]\n *&return:int =(n$0 + n$1) [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&a,false); [line 14]\n NULLIFY(&b,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit fun_default_decl \n " color=yellow style=filled] -4 [label="4: Start fun_default_decl\nFormals: a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 16]\n " color=yellow style=filled] +4 [label="4: Start fun_default_decl\nFormals: a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&a:int [line 11]\n n$1=*&b:int [line 11]\n *&return:int =(n$0 + n$1) [line 11]\n REMOVE_TEMPS(n$0,n$1); [line 11]\n NULLIFY(&a,false); [line 11]\n NULLIFY(&b,false); [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&a:int [line 10]\n n$1=*&b:int [line 10]\n *&return:int =(n$0 + n$1) [line 10]\n REMOVE_TEMPS(n$0,n$1); [line 10]\n NULLIFY(&a,false); [line 10]\n NULLIFY(&b,false); [line 10]\n APPLY_ABSTRACTION; [line 10]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp index 6c12ab83b..6e727b3b3 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/inheritance.cpp @@ -8,20 +8,20 @@ */ class Base { -public: - int fun() { return 1;} + public: + int fun() { return 1; } int fun_redefine() { return 10; } // note that they are not virtual }; class Sub : public Base { -public: + public: int fun_redefine() { return 20; } }; void call_static_methods() { - Base *b = new Base; - Base *s1 = new Sub; // note the type of s1 - Sub *s2 = new Sub; + Base* b = new Base; + Base* s1 = new Sub; // note the type of s1 + Sub* s2 = new Sub; b->fun(); s1->fun(); diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/inheritance_field.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/inheritance_field.cpp index 600b027be..e2c18a649 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/inheritance_field.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/inheritance_field.cpp @@ -34,25 +34,25 @@ int div0_s(Sub s) { return 1 / s.s; } -int div0_cast(Sub *s) { +int div0_cast(Sub* s) { s->b1 = 0; - Base1 *b = s; + Base1* b = s; return 1 / b->b1; } int div0_cast_ref(Sub s) { s.b1 = 0; - Base1 &b = s; + Base1& b = s; return 1 / b.b1; } -int div0_b1_s(Sub *s) { +int div0_b1_s(Sub* s) { s->b1 = 1; s->s = 1; return 1 / (s->b1 - s->s); } -int div0_s_b1(Sub *s) { +int div0_s_b1(Sub* s) { s->b1 = 1; s->s = 1; return 1 / (s->b1 - s->s); @@ -63,8 +63,8 @@ int div1_b1(Sub s) { return 1 / s.b1; } -int div1_cast(Sub *s) { +int div1_cast(Sub* s) { s->b1 = 1; - Base1 *b = s; + Base1* b = s; return 1 / b->b1; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp index 911e68508..b846c4dd7 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp @@ -12,42 +12,34 @@ struct X { int operator[](int x) { return x; } }; -struct Y : public X { - -}; +struct Y : public X {}; // operator that is a function -int operator*(const X& x1, int v) { - return v; -} +int operator*(const X& x1, int v) { return v; } -int div0_method_op(X &x) { +int div0_method_op(X& x) { // call method operator int v = x[0]; return 1 / v; } -int div0_method_op_ptr(X *x) { - return 1 / (*x)[0]; -} +int div0_method_op_ptr(X* x) { return 1 / (*x)[0]; } -int div0_function_op(X &x) { +int div0_function_op(X& x) { // call function operator int v = x * 0; return 1 / v; } -int div0_method(X &x) { +int div0_method(X& x) { // call method operator as a method int v = x.operator[](0); return 1 / v; } -int div0_inheritted_op(Y &y) { +int div0_inheritted_op(Y& y) { // call operator of superclass return 1 / y[0]; } -int div1_method_op(X &x) { - return 1 / x[1]; -} +int div1_method_op(X& x) { return 1 / x[1]; } diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp.dot b/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp.dot index 0d0553938..fde6fa884 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/operator_overload.cpp.dot @@ -1,90 +1,90 @@ digraph iCFG { -27 [label="27: Return Stmt \n n$0=*&x:class X & [line 52]\n n$1=_fun_X_operator[](n$0:class X &,1:int ) [line 52]\n *&return:int =(1 / n$1) [line 52]\n REMOVE_TEMPS(n$0,n$1); [line 52]\n NULLIFY(&x,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] +27 [label="27: Return Stmt \n n$0=*&x:class X & [line 45]\n n$1=_fun_X_operator[](n$0:class X &,1:int ) [line 45]\n *&return:int =(1 / n$1) [line 45]\n REMOVE_TEMPS(n$0,n$1); [line 45]\n NULLIFY(&x,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit div1_method_op \n " color=yellow style=filled] -25 [label="25: Start div1_method_op\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 51]\n " color=yellow style=filled] +25 [label="25: Start div1_method_op\nFormals: x:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 45]\n " color=yellow style=filled] 25 -> 27 ; -24 [label="24: Return Stmt \n n$0=*&y:class Y & [line 48]\n n$1=_fun_X_operator[](n$0:class Y &,0:int ) [line 48]\n *&return:int =(1 / n$1) [line 48]\n REMOVE_TEMPS(n$0,n$1); [line 48]\n NULLIFY(&y,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +24 [label="24: Return Stmt \n n$0=*&y:class Y & [line 42]\n n$1=_fun_X_operator[](n$0:class Y &,0:int ) [line 42]\n *&return:int =(1 / n$1) [line 42]\n REMOVE_TEMPS(n$0,n$1); [line 42]\n NULLIFY(&y,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 24 -> 23 ; 23 [label="23: Exit div0_inheritted_op \n " color=yellow style=filled] -22 [label="22: Start div0_inheritted_op\nFormals: y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 46]\n " color=yellow style=filled] +22 [label="22: Start div0_inheritted_op\nFormals: y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] 22 -> 24 ; -21 [label="21: DeclStmt \n n$1=*&x:class X & [line 42]\n n$2=_fun_X_operator[](n$1:class X &,0:int ) [line 42]\n *&v:int =n$2 [line 42]\n REMOVE_TEMPS(n$1,n$2); [line 42]\n NULLIFY(&x,false); [line 42]\n " shape="box"] +21 [label="21: DeclStmt \n n$1=*&x:class X & [line 36]\n n$2=_fun_X_operator[](n$1:class X &,0:int ) [line 36]\n *&v:int =n$2 [line 36]\n REMOVE_TEMPS(n$1,n$2); [line 36]\n NULLIFY(&x,false); [line 36]\n " shape="box"] 21 -> 20 ; -20 [label="20: Return Stmt \n n$0=*&v:int [line 43]\n *&return:int =(1 / n$0) [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&v,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +20 [label="20: Return Stmt \n n$0=*&v:int [line 37]\n *&return:int =(1 / n$0) [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n NULLIFY(&v,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 20 -> 19 ; 19 [label="19: Exit div0_method \n " color=yellow style=filled] -18 [label="18: Start div0_method\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 40]\n NULLIFY(&v,false); [line 40]\n " color=yellow style=filled] +18 [label="18: Start div0_method\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 34]\n NULLIFY(&v,false); [line 34]\n " color=yellow style=filled] 18 -> 21 ; -17 [label="17: DeclStmt \n n$1=*&x:class X & [line 36]\n n$2=_fun_operator*(n$1:class X &,0:int ) [line 36]\n *&v:int =n$2 [line 36]\n REMOVE_TEMPS(n$1,n$2); [line 36]\n NULLIFY(&x,false); [line 36]\n " shape="box"] +17 [label="17: DeclStmt \n n$1=*&x:class X & [line 30]\n n$2=_fun_operator*(n$1:class X &,0:int ) [line 30]\n *&v:int =n$2 [line 30]\n REMOVE_TEMPS(n$1,n$2); [line 30]\n NULLIFY(&x,false); [line 30]\n " shape="box"] 17 -> 16 ; -16 [label="16: Return Stmt \n n$0=*&v:int [line 37]\n *&return:int =(1 / n$0) [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n NULLIFY(&v,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +16 [label="16: Return Stmt \n n$0=*&v:int [line 31]\n *&return:int =(1 / n$0) [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n NULLIFY(&v,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 16 -> 15 ; 15 [label="15: Exit div0_function_op \n " color=yellow style=filled] -14 [label="14: Start div0_function_op\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 34]\n NULLIFY(&v,false); [line 34]\n " color=yellow style=filled] +14 [label="14: Start div0_function_op\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 28]\n NULLIFY(&v,false); [line 28]\n " color=yellow style=filled] 14 -> 17 ; -13 [label="13: Return Stmt \n n$0=*&x:class X * [line 31]\n n$1=_fun_X_operator[](n$0:class X &,0:int ) [line 31]\n *&return:int =(1 / n$1) [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n NULLIFY(&x,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] +13 [label="13: Return Stmt \n n$0=*&x:class X * [line 26]\n n$1=_fun_X_operator[](n$0:class X &,0:int ) [line 26]\n *&return:int =(1 / n$1) [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&x,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit div0_method_op_ptr \n " color=yellow style=filled] -11 [label="11: Start div0_method_op_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] +11 [label="11: Start div0_method_op_ptr\nFormals: x:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: DeclStmt \n n$1=*&x:class X & [line 26]\n n$2=_fun_X_operator[](n$1:class X &,0:int ) [line 26]\n *&v:int =n$2 [line 26]\n REMOVE_TEMPS(n$1,n$2); [line 26]\n NULLIFY(&x,false); [line 26]\n " shape="box"] +10 [label="10: DeclStmt \n n$1=*&x:class X & [line 22]\n n$2=_fun_X_operator[](n$1:class X &,0:int ) [line 22]\n *&v:int =n$2 [line 22]\n REMOVE_TEMPS(n$1,n$2); [line 22]\n NULLIFY(&x,false); [line 22]\n " shape="box"] 10 -> 9 ; -9 [label="9: Return Stmt \n n$0=*&v:int [line 27]\n *&return:int =(1 / n$0) [line 27]\n REMOVE_TEMPS(n$0); [line 27]\n NULLIFY(&v,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +9 [label="9: Return Stmt \n n$0=*&v:int [line 23]\n *&return:int =(1 / n$0) [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&v,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit div0_method_op \n " color=yellow style=filled] -7 [label="7: Start div0_method_op\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 24]\n NULLIFY(&v,false); [line 24]\n " color=yellow style=filled] +7 [label="7: Start div0_method_op\nFormals: x:class X &\nLocals: v:int \n DECLARE_LOCALS(&return,&v); [line 20]\n NULLIFY(&v,false); [line 20]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: Return Stmt \n n$0=*&v:int [line 21]\n *&return:int =n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n NULLIFY(&v,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&v:int [line 18]\n *&return:int =n$0 [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&v,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit operator* \n " color=yellow style=filled] -4 [label="4: Start operator*\nFormals: x1:class X & v:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&x1,false); [line 20]\n " color=yellow style=filled] +4 [label="4: Start operator*\nFormals: x1:class X & v:int \nLocals: \n DECLARE_LOCALS(&return); [line 18]\n NULLIFY(&x1,false); [line 18]\n " color=yellow style=filled] 4 -> 6 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp index 05b03edaa..4c8d5953d 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp @@ -16,7 +16,6 @@ struct X { int skip(); // this should be skip in the backend }; - X get(int a) { X x; x.f = a; @@ -33,19 +32,13 @@ int get_field_div0() { return 1 / get(0).f; } -int get_method_div0() { - return get(0).div(); -} +int get_method_div0() { return get(0).div(); } int get_div1() { X x = get(1); return 1 / x.f; } -int get_field_div1() { - return 1 / get(1).f; -} +int get_field_div1() { return 1 / get(1).f; } -int get_method_div1() { - return get(1).div(); -} +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 f4fa886c0..b3a9dc46a 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/frontend/types/return_struct.cpp.dot @@ -1,98 +1,98 @@ digraph iCFG { -35 [label="35: Return Stmt \n _fun_get(1:int ,&__temp_return_n$1:class X *) [line 50]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 50]\n *&return:int =n$2 [line 50]\n REMOVE_TEMPS(n$2); [line 50]\n NULLIFY(&__temp_return_n$1,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] +35 [label="35: Return Stmt \n _fun_get(1:int ,&__temp_return_n$1:class X *) [line 44]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 44]\n *&return:int =n$2 [line 44]\n REMOVE_TEMPS(n$2); [line 44]\n NULLIFY(&__temp_return_n$1,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 35 -> 34 ; 34 [label="34: Exit get_method_div1 \n " color=yellow style=filled] -33 [label="33: Start get_method_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 49]\n " color=yellow style=filled] +33 [label="33: Start get_method_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 44]\n " color=yellow style=filled] 33 -> 35 ; -32 [label="32: Return Stmt \n _fun_get(1:int ,&__temp_return_n$1:class X *) [line 46]\n n$2=*&__temp_return_n$1.f:int [line 46]\n *&return:int =(1 / n$2) [line 46]\n REMOVE_TEMPS(n$2); [line 46]\n NULLIFY(&__temp_return_n$1,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +32 [label="32: Return Stmt \n _fun_get(1:int ,&__temp_return_n$1:class X *) [line 42]\n n$2=*&__temp_return_n$1.f:int [line 42]\n *&return:int =(1 / n$2) [line 42]\n REMOVE_TEMPS(n$2); [line 42]\n NULLIFY(&__temp_return_n$1,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 32 -> 31 ; 31 [label="31: Exit get_field_div1 \n " color=yellow style=filled] -30 [label="30: Start get_field_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 45]\n " color=yellow style=filled] +30 [label="30: Start get_field_div1\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 42]\n " color=yellow style=filled] 30 -> 32 ; -29 [label="29: DeclStmt \n _fun_get(1:int ,&SIL_materialize_temp__n$1:class X *) [line 41]\n _fun_X_X(&x:class X *,&SIL_materialize_temp__n$1:class X &) [line 41]\n " shape="box"] +29 [label="29: DeclStmt \n _fun_get(1:int ,&SIL_materialize_temp__n$1:class X *) [line 38]\n _fun_X_X(&x:class X *,&SIL_materialize_temp__n$1:class X &) [line 38]\n " shape="box"] 29 -> 28 ; -28 [label="28: Return Stmt \n n$0=*&x.f:int [line 42]\n *&return:int =(1 / n$0) [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 42]\n NULLIFY(&x,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] +28 [label="28: Return Stmt \n n$0=*&x.f:int [line 39]\n *&return:int =(1 / n$0) [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 39]\n NULLIFY(&x,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 28 -> 27 ; 27 [label="27: Exit get_div1 \n " color=yellow style=filled] -26 [label="26: Start get_div1\nFormals: \nLocals: x:class X SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 40]\n " color=yellow style=filled] +26 [label="26: Start get_div1\nFormals: \nLocals: x:class X SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 37]\n " color=yellow style=filled] 26 -> 29 ; -25 [label="25: Return Stmt \n _fun_get(0:int ,&__temp_return_n$1:class X *) [line 37]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 37]\n *&return:int =n$2 [line 37]\n REMOVE_TEMPS(n$2); [line 37]\n NULLIFY(&__temp_return_n$1,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +25 [label="25: Return Stmt \n _fun_get(0:int ,&__temp_return_n$1:class X *) [line 35]\n n$2=_fun_X_div(&__temp_return_n$1:class X &) [line 35]\n *&return:int =n$2 [line 35]\n REMOVE_TEMPS(n$2); [line 35]\n NULLIFY(&__temp_return_n$1,false); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 25 -> 24 ; 24 [label="24: Exit get_method_div0 \n " color=yellow style=filled] -23 [label="23: Start get_method_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 36]\n " color=yellow style=filled] +23 [label="23: Start get_method_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 35]\n " color=yellow style=filled] 23 -> 25 ; -22 [label="22: Call _fun_X_skip \n _fun_get(0:int ,&__temp_return_n$4:class X *) [line 32]\n n$5=_fun_X_skip(&__temp_return_n$4:class X &) [line 32]\n REMOVE_TEMPS(n$5); [line 32]\n " shape="box"] +22 [label="22: Call _fun_X_skip \n _fun_get(0:int ,&__temp_return_n$4:class X *) [line 31]\n n$5=_fun_X_skip(&__temp_return_n$4:class X &) [line 31]\n REMOVE_TEMPS(n$5); [line 31]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n _fun_get(0:int ,&__temp_return_n$1:class X *) [line 33]\n n$2=*&__temp_return_n$1.f:int [line 33]\n *&return:int =(1 / n$2) [line 33]\n REMOVE_TEMPS(n$2); [line 33]\n NULLIFY(&__temp_return_n$1,false); [line 33]\n NULLIFY(&__temp_return_n$4,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +21 [label="21: Return Stmt \n _fun_get(0:int ,&__temp_return_n$1:class X *) [line 32]\n n$2=*&__temp_return_n$1.f:int [line 32]\n *&return:int =(1 / n$2) [line 32]\n REMOVE_TEMPS(n$2); [line 32]\n NULLIFY(&__temp_return_n$1,false); [line 32]\n NULLIFY(&__temp_return_n$4,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit get_field_div0 \n " color=yellow style=filled] -19 [label="19: Start get_field_div0\nFormals: \nLocals: __temp_return_n$1:class X __temp_return_n$4:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1,&__temp_return_n$4); [line 31]\n " color=yellow style=filled] +19 [label="19: Start get_field_div0\nFormals: \nLocals: __temp_return_n$1:class X __temp_return_n$4:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1,&__temp_return_n$4); [line 30]\n " color=yellow style=filled] 19 -> 22 ; -18 [label="18: DeclStmt \n _fun_get(0:int ,&SIL_materialize_temp__n$1:class X *) [line 27]\n _fun_X_X(&x:class X *,&SIL_materialize_temp__n$1:class X &) [line 27]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_get(0:int ,&SIL_materialize_temp__n$1:class X *) [line 26]\n _fun_X_X(&x:class X *,&SIL_materialize_temp__n$1:class X &) [line 26]\n " shape="box"] 18 -> 17 ; -17 [label="17: Return Stmt \n n$0=*&x.f:int [line 28]\n *&return:int =(1 / n$0) [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 28]\n NULLIFY(&x,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +17 [label="17: Return Stmt \n n$0=*&x.f:int [line 27]\n *&return:int =(1 / n$0) [line 27]\n REMOVE_TEMPS(n$0); [line 27]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 27]\n NULLIFY(&x,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit get_div0 \n " color=yellow style=filled] -15 [label="15: Start get_div0\nFormals: \nLocals: x:class X SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 26]\n " color=yellow style=filled] +15 [label="15: Start get_div0\nFormals: \nLocals: x:class X SIL_materialize_temp__n$1:class X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 25]\n " color=yellow style=filled] 15 -> 18 ; -14 [label="14: DeclStmt \n _fun_X_X(&x:class X *) [line 21]\n " shape="box"] +14 [label="14: DeclStmt \n _fun_X_X(&x:class X *) [line 20]\n " shape="box"] 14 -> 13 ; -13 [label="13: BinaryOperatorStmt: Assign \n n$1=*&a:int [line 22]\n *&x.f:int =n$1 [line 22]\n REMOVE_TEMPS(n$1); [line 22]\n NULLIFY(&a,false); [line 22]\n " shape="box"] +13 [label="13: BinaryOperatorStmt: Assign \n n$1=*&a:int [line 21]\n *&x.f:int =n$1 [line 21]\n REMOVE_TEMPS(n$1); [line 21]\n NULLIFY(&a,false); [line 21]\n " shape="box"] 13 -> 12 ; -12 [label="12: Return Stmt \n n$0=*&__return_param:class X * [line 23]\n _fun_X_X(n$0:class X *,&x:class X &) [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&__return_param,false); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +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 REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&__return_param,false); [line 22]\n NULLIFY(&x,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit 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 20]\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 -> 14 ; diff --git a/infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp b/infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp index c320e8232..0a17ce6ae 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct.cpp @@ -8,23 +8,23 @@ */ struct X_struct { -int a; -int b; + int a; + int b; }; class X_class { -public: -int a; -int b; + public: + int a; + int b; }; void test() { // use pointers until c++ constructors are translated - X_struct *xs; + X_struct* xs; xs->a = 10; xs->b = 20; - X_class *xc; + X_class* xc; xc->a = 10; xc->b = 20; } 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 0680f91c5..ead4ff884 100644 --- a/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp +++ b/infer/tests/codetoanalyze/cpp/frontend/types/struct_forward_declare.cpp @@ -17,13 +17,11 @@ struct X; struct X { int f; int getF() { return f; } - Y *y; - Z *z; + Y* y; + Z* z; }; -void fun_with_Z(Z *z1) { - Z *z2 = z1; -} +void fun_with_Z(Z* z1) { Z* z2 = z1; } struct Z { int f; @@ -39,7 +37,7 @@ int X_div0() { return 1 / x.getF(); } -int X_ptr_div0(X *x) { +int X_ptr_div0(X* x) { x->f = 0; return 1 / x->getF(); } @@ -60,7 +58,7 @@ int Z_div0() { return 1 / z.getF(); } -int Z_ptr_div0(Z *z) { +int Z_ptr_div0(Z* z) { // internal implementation details, subject to change: // Z * will by Sil.Tptr (Sil.Tvar Z) type and // will get expanded by clang frontend 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 aab3dd494..78311e532 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,60 +1,60 @@ digraph iCFG { -41 [label="41: BinaryOperatorStmt: Assign \n n$2=*&z:class Z * [line 67]\n *n$2.f:int =0 [line 67]\n REMOVE_TEMPS(n$2); [line 67]\n " shape="box"] +41 [label="41: BinaryOperatorStmt: Assign \n n$2=*&z:class Z * [line 65]\n *n$2.f:int =0 [line 65]\n REMOVE_TEMPS(n$2); [line 65]\n " shape="box"] 41 -> 40 ; -40 [label="40: Return Stmt \n n$0=*&z:class Z * [line 68]\n n$1=_fun_Z_getF(n$0:class Z *) [line 68]\n *&return:int =(1 / n$1) [line 68]\n REMOVE_TEMPS(n$0,n$1); [line 68]\n NULLIFY(&z,false); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"] +40 [label="40: Return Stmt \n n$0=*&z:class Z * [line 66]\n n$1=_fun_Z_getF(n$0:class Z *) [line 66]\n *&return:int =(1 / n$1) [line 66]\n REMOVE_TEMPS(n$0,n$1); [line 66]\n NULLIFY(&z,false); [line 66]\n APPLY_ABSTRACTION; [line 66]\n " shape="box"] 40 -> 39 ; 39 [label="39: Exit 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 63]\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 -> 41 ; -37 [label="37: DeclStmt \n _fun_Z_Z(&z:class Z *) [line 58]\n " shape="box"] +37 [label="37: DeclStmt \n _fun_Z_Z(&z:class Z *) [line 56]\n " shape="box"] 37 -> 36 ; -36 [label="36: BinaryOperatorStmt: Assign \n *&z.f:int =0 [line 59]\n " shape="box"] +36 [label="36: BinaryOperatorStmt: Assign \n *&z.f:int =0 [line 57]\n " shape="box"] 36 -> 35 ; -35 [label="35: Return Stmt \n n$0=_fun_Z_getF(&z:class Z &) [line 60]\n *&return:int =(1 / n$0) [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n NULLIFY(&z,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] +35 [label="35: Return Stmt \n n$0=_fun_Z_getF(&z:class Z &) [line 58]\n *&return:int =(1 / n$0) [line 58]\n REMOVE_TEMPS(n$0); [line 58]\n NULLIFY(&z,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 35 -> 34 ; 34 [label="34: Exit Z_div0 \n " color=yellow style=filled] -33 [label="33: Start Z_div0\nFormals: \nLocals: z:class Z \n DECLARE_LOCALS(&return,&z); [line 57]\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 -> 37 ; -32 [label="32: DeclStmt \n _fun_X_X(&x:class X *) [line 48]\n " shape="box"] +32 [label="32: DeclStmt \n _fun_X_X(&x:class X *) [line 46]\n " shape="box"] 32 -> 31 ; -31 [label="31: BinaryOperatorStmt: Assign \n *&x.y:class Y *=null [line 49]\n " shape="box"] +31 [label="31: BinaryOperatorStmt: Assign \n *&x.y:class Y *=null [line 47]\n " shape="box"] 31 -> 30 ; -30 [label="30: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 50]\n " shape="box"] +30 [label="30: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 48]\n " shape="box"] 30 -> 27 ; 30 -> 28 ; -29 [label="29: Return Stmt \n *&return:int =1 [line 52]\n NULLIFY(&x,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] +29 [label="29: Return Stmt \n *&return:int =1 [line 50]\n NULLIFY(&x,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] 29 -> 24 ; -28 [label="28: Prune (false branch) \n n$1=*&x.y:class Y * [line 51]\n PRUNE((n$1 == 0), false); [line 51]\n REMOVE_TEMPS(n$1); [line 51]\n " shape="invhouse"] +28 [label="28: Prune (false branch) \n n$1=*&x.y:class Y * [line 49]\n PRUNE((n$1 == 0), false); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n " shape="invhouse"] 28 -> 26 ; -27 [label="27: Prune (true branch) \n n$1=*&x.y:class Y * [line 51]\n PRUNE((n$1 != 0), true); [line 51]\n REMOVE_TEMPS(n$1); [line 51]\n " shape="invhouse"] +27 [label="27: Prune (true branch) \n n$1=*&x.y:class Y * [line 49]\n PRUNE((n$1 != 0), true); [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n " shape="invhouse"] 27 -> 29 ; @@ -62,70 +62,70 @@ digraph iCFG { 26 -> 25 ; -25 [label="25: Return Stmt \n n$0=_fun_X_getF(&x:class X &) [line 54]\n *&return:int =(1 / n$0) [line 54]\n REMOVE_TEMPS(n$0); [line 54]\n NULLIFY(&x,false); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +25 [label="25: Return Stmt \n n$0=_fun_X_getF(&x:class X &) [line 52]\n *&return:int =(1 / n$0) [line 52]\n REMOVE_TEMPS(n$0); [line 52]\n NULLIFY(&x,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] 25 -> 24 ; 24 [label="24: Exit 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 47]\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 -> 32 ; -22 [label="22: BinaryOperatorStmt: Assign \n n$2=*&x:class X * [line 43]\n *n$2.f:int =0 [line 43]\n REMOVE_TEMPS(n$2); [line 43]\n " shape="box"] +22 [label="22: BinaryOperatorStmt: Assign \n n$2=*&x:class X * [line 41]\n *n$2.f:int =0 [line 41]\n REMOVE_TEMPS(n$2); [line 41]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n n$0=*&x:class X * [line 44]\n n$1=_fun_X_getF(n$0:class X *) [line 44]\n *&return:int =(1 / n$1) [line 44]\n REMOVE_TEMPS(n$0,n$1); [line 44]\n NULLIFY(&x,false); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] +21 [label="21: Return Stmt \n n$0=*&x:class X * [line 42]\n n$1=_fun_X_getF(n$0:class X *) [line 42]\n *&return:int =(1 / n$1) [line 42]\n REMOVE_TEMPS(n$0,n$1); [line 42]\n NULLIFY(&x,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit 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 42]\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 -> 22 ; -18 [label="18: DeclStmt \n _fun_X_X(&x:class X *) [line 37]\n " shape="box"] +18 [label="18: DeclStmt \n _fun_X_X(&x:class X *) [line 35]\n " shape="box"] 18 -> 17 ; -17 [label="17: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 38]\n " shape="box"] +17 [label="17: BinaryOperatorStmt: Assign \n *&x.f:int =0 [line 36]\n " shape="box"] 17 -> 16 ; -16 [label="16: Return Stmt \n n$0=_fun_X_getF(&x:class X &) [line 39]\n *&return:int =(1 / n$0) [line 39]\n REMOVE_TEMPS(n$0); [line 39]\n NULLIFY(&x,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] +16 [label="16: Return Stmt \n n$0=_fun_X_getF(&x:class X &) [line 37]\n *&return:int =(1 / n$0) [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n NULLIFY(&x,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 16 -> 15 ; 15 [label="15: Exit X_div0 \n " color=yellow style=filled] -14 [label="14: Start X_div0\nFormals: \nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 36]\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 -> 18 ; 13 [label="13: Exit Z_Z \n " color=yellow style=filled] -12 [label="12: Start Z_Z\nFormals: this:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n NULLIFY(&this,false); [line 28]\n " color=yellow style=filled] +12 [label="12: Start Z_Z\nFormals: this:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 26]\n NULLIFY(&this,false); [line 26]\n " color=yellow style=filled] 12 -> 13 ; -11 [label="11: Return Stmt \n n$0=*&this:class Z * [line 30]\n n$1=*n$0.f:int [line 30]\n *&return:int =n$1 [line 30]\n REMOVE_TEMPS(n$0,n$1); [line 30]\n NULLIFY(&this,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +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 REMOVE_TEMPS(n$0,n$1); [line 28]\n NULLIFY(&this,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] 11 -> 10 ; 10 [label="10: Exit Z_getF \n " color=yellow style=filled] -9 [label="9: Start Z_getF\nFormals: this:class Z *\nLocals: \n DECLARE_LOCALS(&return); [line 30]\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 -> 11 ; -8 [label="8: DeclStmt \n n$0=*&z1:class Z * [line 25]\n *&z2:class Z *=n$0 [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n NULLIFY(&z1,false); [line 25]\n NULLIFY(&z2,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +8 [label="8: DeclStmt \n n$0=*&z1:class Z * [line 24]\n *&z2:class Z *=n$0 [line 24]\n REMOVE_TEMPS(n$0); [line 24]\n NULLIFY(&z1,false); [line 24]\n NULLIFY(&z2,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 8 -> 7 ; diff --git a/infer/tests/codetoanalyze/llvm/interproc.c b/infer/tests/codetoanalyze/llvm/interproc.c index 3365c14d1..536fbf0ca 100644 --- a/infer/tests/codetoanalyze/llvm/interproc.c +++ b/infer/tests/codetoanalyze/llvm/interproc.c @@ -7,11 +7,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int *always_null(void) { - return 0; -} +int* always_null(void) { return 0; } void foo(void) { - int *p = always_null(); - *p = 42; + int* p = always_null(); + *p = 42; } diff --git a/infer/tests/codetoanalyze/llvm/null_deref.c b/infer/tests/codetoanalyze/llvm/null_deref.c index b35c6c3a7..1cd256222 100644 --- a/infer/tests/codetoanalyze/llvm/null_deref.c +++ b/infer/tests/codetoanalyze/llvm/null_deref.c @@ -8,6 +8,6 @@ */ void foo(void) { - int *p = 0; - *p = 42; + int* p = 0; + *p = 42; } diff --git a/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/badpointer.m b/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/badpointer.m index d1a118afa..42c34b488 100644 --- a/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/badpointer.m +++ b/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/badpointer.m @@ -11,47 +11,45 @@ void bad1() { - NSNumber *n2; - int i; - - if (!n2) { - i = 0; - } else { - i = 1; - } + NSNumber* n2; + int i; + + if (!n2) { + i = 0; + } else { + i = 1; + } } - -void bad2(NSArray *a, NSNumber *n) { - int i = 0; - for (; !n; ) { - i = n.intValue; - } +void bad2(NSArray* a, NSNumber* n) { + int i = 0; + for (; !n;) { + i = n.intValue; + } } -void bad3(NSArray *a, NSNumber *n) { - int i = 0; - while (!n) { - i = n.intValue; - } +void bad3(NSArray* a, NSNumber* n) { + int i = 0; + while (!n) { + i = n.intValue; + } } - -void good1(NSArray *a) { - int i = 0; - for (NSNumber *n in a) { - i = n.intValue; - } +void good1(NSArray* a) { + int i = 0; + for (NSNumber* n in a) { + i = n.intValue; + } } -void good2 () { +void good2() { - NSNumber *n2; - int i; + NSNumber* n2; + int i; - if (n2 != nil) { - i = 1; - } else { - i = 0; - } + if (n2 != nil) { + i = 1; + } else { + i = 0; + } } diff --git a/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/nsnumber.m b/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/nsnumber.m index 0ae9b3894..356a67456 100644 --- a/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/nsnumber.m +++ b/infer/tests/codetoanalyze/objc/errors/bad_ptr_comparisons/nsnumber.m @@ -9,44 +9,42 @@ #import -void bad1(NSNumber * isNum) { +void bad1(NSNumber* isNum) { if (isNum) { } } -void bad2(NSNumber * isNum) { +void bad2(NSNumber* isNum) { if (!isNum) { } } - -void ok1(NSNumber * isNum) { +void ok1(NSNumber* isNum) { if (isNum != nil) { } } -void ok2(NSNumber * isNum) { +void ok2(NSNumber* isNum) { if (nil != isNum) { } } -void ok3(NSNumber * isNum) { +void ok3(NSNumber* isNum) { if (nil == isNum) { } } - -void ok4(NSNumber * isNum) { +void ok4(NSNumber* isNum) { if (isNum == nil) { } } -void accessor_ok1(NSNumber * num) { +void accessor_ok1(NSNumber* num) { if (![num boolValue]) { } } -void accessor_ok2(NSNumber * num) { +void accessor_ok2(NSNumber* num) { if ([num boolValue]) { } } diff --git a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.dot b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.dot index d4f68dcdf..ea392e410 100644 --- a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.dot +++ b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.dot @@ -1,12 +1,12 @@ digraph iCFG { -6 [label="6: Call _fun_NSLog \n n$1=_fun_NSString_stringWithUTF8String:(\"BTaking vacations\":char *) [line 20]\n _fun_NSLog(n$1:struct objc_object *) [line 20]\n REMOVE_TEMPS(n$1); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +6 [label="6: Call _fun_NSLog \n n$1=_fun_NSString_stringWithUTF8String:(\"BTaking vacations\":char *) [line 19]\n _fun_NSLog(n$1:struct objc_object *) [line 19]\n REMOVE_TEMPS(n$1); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit EOCPerson_takeVacationFromWork \n " color=yellow style=filled] -4 [label="4: Start EOCPerson_takeVacationFromWork\nFormals: self:class EOCPerson *\nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&self,false); [line 19]\n " color=yellow style=filled] +4 [label="4: Start EOCPerson_takeVacationFromWork\nFormals: self:class EOCPerson *\nLocals: \n DECLARE_LOCALS(&return); [line 18]\n NULLIFY(&self,false); [line 18]\n " color=yellow style=filled] 4 -> 6 ; diff --git a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.h b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.h index 88b6e9698..a2e7b469b 100644 --- a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.h +++ b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.h @@ -8,16 +8,15 @@ */ // Splitting EOCPerson into categories -#import #import +#import @interface EOCPerson : NSObject -@property (nonatomic, copy, readonly) NSString *firstName; -@property (nonatomic, copy, readonly) NSString *lastName; -@property (nonatomic, strong, readonly) NSArray *friends; +@property(nonatomic, copy, readonly) NSString* firstName; +@property(nonatomic, copy, readonly) NSString* lastName; +@property(nonatomic, strong, readonly) NSArray* friends; -- (id)initWithFirstName:(NSString*)firstName - andLastName:(NSString*)lastName; +- (id)initWithFirstName:(NSString*)firstName andLastName:(NSString*)lastName; @end @interface EOCPerson (Friendship) diff --git a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.m b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.m index a49d436f1..381bf8e6c 100644 --- a/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.m +++ b/infer/tests/codetoanalyze/objc/errors/category_procdesc/EOCPerson.m @@ -12,11 +12,10 @@ @implementation EOCPerson (Work) - (void)performDaysWork { - NSLog(@"Performing days at work"); + NSLog(@"Performing days at work"); } - -- (void)takeVacationFromWork{ - NSLog(@"BTaking vacations"); +- (void)takeVacationFromWork { + NSLog(@"BTaking vacations"); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.c b/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.c index 5c5a11587..d625bbe57 100644 --- a/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.c +++ b/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.c @@ -9,10 +9,9 @@ #import "EOCPerson.h" - int main() { - EOCPerson *person = [[EOCPerson alloc] init]; - [person performDaysWork]; - int *x = malloc(sizeof(int)); - return 0; + EOCPerson* person = [[EOCPerson alloc] init]; + [person performDaysWork]; + int* x = malloc(sizeof(int)); + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.dot b/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.dot index 085d65464..97c086921 100644 --- a/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.dot +++ b/infer/tests/codetoanalyze/objc/errors/category_procdesc/main.dot @@ -1,24 +1,24 @@ digraph iCFG { -6 [label="6: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class EOCPerson ):unsigned long ) [line 14]\n n$3=_fun_NSObject_init(n$2:class EOCPerson *) virtual [line 14]\n *&person:class EOCPerson *=n$3 [line 14]\n REMOVE_TEMPS(n$2,n$3); [line 14]\n " shape="box"] +6 [label="6: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class EOCPerson ):unsigned long ) [line 13]\n n$3=_fun_NSObject_init(n$2:class EOCPerson *) virtual [line 13]\n *&person:class EOCPerson *=n$3 [line 13]\n REMOVE_TEMPS(n$2,n$3); [line 13]\n " shape="box"] 6 -> 5 ; -5 [label="5: Message Call: performDaysWork \n n$1=*&person:class EOCPerson * [line 15]\n _fun_EOCPerson_performDaysWork(n$1:class EOCPerson *) virtual [line 15]\n REMOVE_TEMPS(n$1); [line 15]\n NULLIFY(&person,false); [line 15]\n " shape="box"] +5 [label="5: Message Call: performDaysWork \n n$1=*&person:class EOCPerson * [line 14]\n _fun_EOCPerson_performDaysWork(n$1:class EOCPerson *) virtual [line 14]\n REMOVE_TEMPS(n$1); [line 14]\n NULLIFY(&person,false); [line 14]\n " shape="box"] 5 -> 4 ; -4 [label="4: DeclStmt \n n$0=_fun_malloc_no_fail(sizeof(int ):int ) [line 16]\n *&x:int *=n$0 [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&x,false); [line 16]\n " shape="box"] +4 [label="4: DeclStmt \n n$0=_fun_malloc_no_fail(sizeof(int ):int ) [line 15]\n *&x:int *=n$0 [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&x,false); [line 15]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit main \n " color=yellow style=filled] -1 [label="1: Start main\nFormals: \nLocals: x:int * person:class EOCPerson * \n DECLARE_LOCALS(&return,&x,&person); [line 13]\n NULLIFY(&person,false); [line 13]\n NULLIFY(&x,false); [line 13]\n " color=yellow style=filled] +1 [label="1: Start main\nFormals: \nLocals: x:int * person:class EOCPerson * \n DECLARE_LOCALS(&return,&x,&person); [line 12]\n NULLIFY(&person,false); [line 12]\n NULLIFY(&x,false); [line 12]\n " color=yellow style=filled] 1 -> 6 ; diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/A.h b/infer/tests/codetoanalyze/objc/errors/field_superclass/A.h index fb296c088..07d35db59 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/A.h +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/A.h @@ -7,12 +7,13 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - #import @interface A : NSObject { - @public int x; - @public A *a; + @public + int x; + @public + A* a; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/B.h b/infer/tests/codetoanalyze/objc/errors/field_superclass/B.h index 4642a162b..e4ffe32fa 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/B.h +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/B.h @@ -7,7 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - #import "A.h" @interface B : A diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/SubtypingExample.m b/infer/tests/codetoanalyze/objc/errors/field_superclass/SubtypingExample.m index 0a1455a1c..87c19eb59 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/SubtypingExample.m +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/SubtypingExample.m @@ -11,77 +11,75 @@ @interface Person : NSObject -{ - NSString *personName; - int personAge; + { + NSString* personName; + int personAge; } -- (id)initWithName:(NSString *)name andAge:(int)age; +- (id)initWithName:(NSString*)name andAge:(int)age; -- (void) setAge:(int) age; +- (void)setAge:(int)age; -- (int) getAge; +- (int)getAge; @end @implementation Person -- (id)initWithName:(NSString *)name andAge:(int)age{ - personName = name; - personAge = age; - return self; +- (id)initWithName:(NSString*)name andAge:(int)age { + personName = name; + personAge = age; + return self; } -- (void) setAge:(int) age { - self->personAge = age; +- (void)setAge:(int)age { + self->personAge = age; } -- (int) getAge { - return self->personAge; +- (int)getAge { + return self->personAge; } @end @interface Employee : Person -{ - NSString *employeeEducation; + { + NSString* employeeEducation; } -- (id)initWithName:(NSString *)name andAge:(int)age - andEducation:(NSString *)education; +- (id)initWithName:(NSString*)name + andAge:(int)age + andEducation:(NSString*)education; -- (void) setEmployeeEducation:(NSString*) employeeEducation; +- (void)setEmployeeEducation:(NSString*)employeeEducation; @end - @implementation Employee -- (id)initWithName:(NSString *)name andAge:(int)age - andEducation: (NSString *)education -{ - if (self = [super initWithName:name andAge:age]) { - employeeEducation = education; - } - int x = 1/0; - return self; +- (id)initWithName:(NSString*)name + andAge:(int)age + andEducation:(NSString*)education { + if (self = [super initWithName:name andAge:age]) { + employeeEducation = education; + } + int x = 1 / 0; + return self; } -- (void) setEmployeeEducation:(NSString*) employeeEducation { - self->employeeEducation = employeeEducation; +- (void)setEmployeeEducation:(NSString*)employeeEducation { + self->employeeEducation = employeeEducation; } @end int testFields() { - Employee* employee = [Employee new]; - [employee setEmployeeEducation:@"Master"]; - [employee setAge:29]; - [employee setEmployeeEducation:@"PhD"]; - return [employee getAge]; + Employee* employee = [Employee new]; + [employee setEmployeeEducation:@"Master"]; + [employee setAge:29]; + [employee setEmployeeEducation:@"PhD"]; + return [employee getAge]; } -int test() { - return 1/(testFields() - 29); -} +int test() { return 1 / (testFields() - 29); } diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.dot b/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.dot index 6937d2eff..c822e3ce0 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.dot +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.dot @@ -1,39 +1,39 @@ digraph iCFG { -12 [label="12: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 45]\n n$2=_fun_NSObject_init(n$1:class A *) virtual [line 45]\n *&a:struct objc_object *=n$2 [line 45]\n REMOVE_TEMPS(n$1,n$2); [line 45]\n NULLIFY(&a,false); [line 45]\n " shape="box"] +12 [label="12: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 42]\n n$2=_fun_NSObject_init(n$1:class A *) virtual [line 42]\n *&a:struct objc_object *=n$2 [line 42]\n REMOVE_TEMPS(n$1,n$2); [line 42]\n NULLIFY(&a,false); [line 42]\n " shape="box"] 12 -> 11 ; -11 [label="11: Release the autorelease pool \n n$0=_fun___objc_release_autorelease_pool() [line 44]\n REMOVE_TEMPS(n$0); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] +11 [label="11: Release the autorelease pool \n n$0=_fun___objc_release_autorelease_pool() [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 11 -> 10 ; 10 [label="10: Exit main \n " color=yellow style=filled] -9 [label="9: Start main\nFormals: argc:int argv:char **\nLocals: a:struct objc_object * \n DECLARE_LOCALS(&return,&a); [line 43]\n NULLIFY(&a,false); [line 43]\n NULLIFY(&argc,false); [line 43]\n NULLIFY(&argv,false); [line 43]\n " color=yellow style=filled] +9 [label="9: Start main\nFormals: argc:int argv:char **\nLocals: a:struct objc_object * \n DECLARE_LOCALS(&return,&a); [line 40]\n NULLIFY(&a,false); [line 40]\n NULLIFY(&argc,false); [line 40]\n NULLIFY(&argv,false); [line 40]\n " color=yellow style=filled] 9 -> 12 ; -8 [label="8: BinaryOperatorStmt: Assign \n n$2=*&self:class A * [line 36]\n n$3=_fun_B_init(n$2:class A *) [line 36]\n *&self:class A *=n$3 [line 36]\n REMOVE_TEMPS(n$2,n$3); [line 36]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n n$2=*&self:class A * [line 33]\n n$3=_fun_B_init(n$2:class A *) [line 33]\n *&self:class A *=n$3 [line 33]\n REMOVE_TEMPS(n$2,n$3); [line 33]\n " shape="box"] 8 -> 7 ; -7 [label="7: BinaryOperatorStmt: Assign \n n$1=*&self:class A * [line 37]\n *n$1.a:int =4 [line 37]\n REMOVE_TEMPS(n$1); [line 37]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$1=*&self:class A * [line 34]\n *n$1.a:int =4 [line 34]\n REMOVE_TEMPS(n$1); [line 34]\n " shape="box"] 7 -> 6 ; -6 [label="6: Return Stmt \n n$0=*&self:class A * [line 38]\n *&return:struct objc_object *=n$0 [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n NULLIFY(&self,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=*&self:class A * [line 35]\n *&return:struct objc_object *=n$0 [line 35]\n REMOVE_TEMPS(n$0); [line 35]\n NULLIFY(&self,false); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit A_init \n " color=yellow style=filled] -4 [label="4: Start A_init\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] +4 [label="4: Start A_init\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] 4 -> 8 ; -3 [label="3: Return Stmt \n *&return:struct objc_object *=0 [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:struct objc_object *=0 [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.m b/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.m index aad02de01..dd74cc5db 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.m +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/SuperExample.m @@ -15,9 +15,8 @@ @implementation B -- (instancetype) init -{ - return nil; +- (instancetype)init { + return nil; } @end @@ -26,22 +25,20 @@ @end -@implementation A -{ - int a; +@implementation A { + int a; } -- (instancetype) init -{ - self = [super init]; - self->a = 4; - return self; +- (instancetype)init { + self = [super init]; + self->a = 4; + return self; } @end -int main(int argc, char *argv[]) { - @autoreleasepool { - __unused id a = [A new]; - } +int main(int argc, char* argv[]) { + @autoreleasepool { + __unused id a = [A new]; + } } diff --git a/infer/tests/codetoanalyze/objc/errors/field_superclass/field.c b/infer/tests/codetoanalyze/objc/errors/field_superclass/field.c index 456775aa5..8cc84a92f 100644 --- a/infer/tests/codetoanalyze/objc/errors/field_superclass/field.c +++ b/infer/tests/codetoanalyze/objc/errors/field_superclass/field.c @@ -9,10 +9,9 @@ #include "B.h" - int main() { - B *b = [B alloc]; - b->x = 5; - b->a = b; // create cycle --> leak - return 0; + B* b = [B alloc]; + b->x = 5; + b->a = b; // create cycle --> leak + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/ArcExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/ArcExample.m index cf9dc2014..e0c571683 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/ArcExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/ArcExample.m @@ -11,23 +11,23 @@ #import @interface A : NSObject { - int x; + int x; } -@property A *son; +@property A* son; @end @implementation A /* autorelease is added */ --(NSString*) getS{ - NSString *s = [NSString alloc]; - return s; +- (NSString*)getS { + NSString* s = [NSString alloc]; + return s; } /* autorelease is not added */ --(NSString*) newS{ - NSString *s = [NSString alloc]; - return s; +- (NSString*)newS { + NSString* s = [NSString alloc]; + return s; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/AutoreleaseExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/AutoreleaseExample.m index f122df579..710e6d03d 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/AutoreleaseExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/AutoreleaseExample.m @@ -7,59 +7,59 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#import #import #import -#import @interface A : NSObject { - int x; + int x; } -@property A *son; +@property A* son; @end @implementation A --(NSString*) main{ - NSString *s = [NSString alloc]; - return [s autorelease]; +- (NSString*)main { + NSString* s = [NSString alloc]; + return [s autorelease]; } @end A* createA() { - A *s1 = [[A alloc] init]; - return [s1 autorelease]; + A* s1 = [[A alloc] init]; + return [s1 autorelease]; } int test1() { - A *s1 = nil; - A *s2 = nil; - A *s3 = nil; - @autoreleasepool { - s1 = createA(); - [s1 retain]; - s2 = createA(); - s3 = createA(); - } - return 0; + A* s1 = nil; + A* s2 = nil; + A* s3 = nil; + @autoreleasepool { + s1 = createA(); + [s1 retain]; + s2 = createA(); + s3 = createA(); + } + return 0; } int test2() { - A *s1 = nil; - A *s2 = nil; - A *s3 = nil; - @autoreleasepool { - s1 = createA(); - s2 = createA(); - s3 = createA(); - } - return 0; + A* s1 = nil; + A* s2 = nil; + A* s3 = nil; + @autoreleasepool { + s1 = createA(); + s2 = createA(); + s3 = createA(); + } + return 0; } void test3() { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSString *string = [[NSString alloc] autorelease]; - //use the string - [pool release]; - NSString* c = string; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSString* string = [[NSString alloc] autorelease]; + // use the string + [pool release]; + NSString* c = string; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CADisplayLinkRetainCycle.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CADisplayLinkRetainCycle.m index 9141f3846..51ebacae8 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CADisplayLinkRetainCycle.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CADisplayLinkRetainCycle.m @@ -10,49 +10,44 @@ #import #import - @interface A : NSObject -@property (nonatomic, strong) CADisplayLink *displayLink; +@property(nonatomic, strong) CADisplayLink* displayLink; -- (void) bla; -- (void) invalidate; +- (void)bla; +- (void)invalidate; @end @implementation A - init { - _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(bla)]; - - return self; + _displayLink = + [CADisplayLink displayLinkWithTarget:self selector:@selector(bla)]; + return self; } -- (void) bla {}; - -- (void) invalidate { - // unregister displayLink target - [_displayLink invalidate]; +- (void)bla{}; +- (void)invalidate { + // unregister displayLink target + [_displayLink invalidate]; }; -- (void) dealloc { - [self dealloc]; +- (void)dealloc { + [self dealloc]; } @end - void testCycle() { - A* a = [[A alloc] init]; - A* b = a; - + A* a = [[A alloc] init]; + A* b = a; } void testNoCycle() { - A* a = [[A alloc] init]; - [a invalidate]; //break the cycle - [a dealloc]; - + A* a = [[A alloc] init]; + [a invalidate]; // break the cycle + [a dealloc]; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.dot b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.dot index 4515c965b..25e57cde1 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.dot +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.dot @@ -1,162 +1,162 @@ digraph iCFG { -48 [label="48: DeclStmt \n n$35=_fun_FBColorCreateWithGray(0.000000:double ,0.300000:double ) [line 95]\n *&borderColor:struct CGColor *=n$35 [line 95]\n REMOVE_TEMPS(n$35); [line 95]\n " shape="box"] +48 [label="48: DeclStmt \n n$35=_fun_FBColorCreateWithGray(0.000000:double ,0.300000:double ) [line 86]\n *&borderColor:struct CGColor *=n$35 [line 86]\n REMOVE_TEMPS(n$35); [line 86]\n " shape="box"] 48 -> 47 ; -47 [label="47: Call _fun_CGColorRelease \n n$34=*&borderColor:struct CGColor * [line 96]\n _fun_CGColorRelease(n$34:struct CGColor *) [line 96]\n REMOVE_TEMPS(n$34); [line 96]\n NULLIFY(&borderColor,false); [line 96]\n APPLY_ABSTRACTION; [line 96]\n " shape="box"] +47 [label="47: Call _fun_CGColorRelease \n n$34=*&borderColor:struct CGColor * [line 87]\n _fun_CGColorRelease(n$34:struct CGColor *) [line 87]\n REMOVE_TEMPS(n$34); [line 87]\n NULLIFY(&borderColor,false); [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 47 -> 46 ; 46 [label="46: Exit MemoryLeakExample_testFBColorCreateWithGray \n " color=yellow style=filled] -45 [label="45: Start MemoryLeakExample_testFBColorCreateWithGray\nFormals: self:class MemoryLeakExample *\nLocals: borderColor:struct CGColor * \n DECLARE_LOCALS(&return,&borderColor); [line 93]\n NULLIFY(&borderColor,false); [line 93]\n NULLIFY(&self,false); [line 93]\n " color=yellow style=filled] +45 [label="45: Start MemoryLeakExample_testFBColorCreateWithGray\nFormals: self:class MemoryLeakExample *\nLocals: borderColor:struct CGColor * \n DECLARE_LOCALS(&return,&borderColor); [line 85]\n NULLIFY(&borderColor,false); [line 85]\n NULLIFY(&self,false); [line 85]\n " color=yellow style=filled] 45 -> 48 ; -44 [label="44: DeclStmt \n n$33=_fun_CGBitmapContextCreateImage(0:struct CGContext *) [line 87]\n *&newImage:struct CGImage *=n$33 [line 87]\n REMOVE_TEMPS(n$33); [line 87]\n " shape="box"] +44 [label="44: DeclStmt \n n$33=_fun_CGBitmapContextCreateImage(0:struct CGContext *) [line 79]\n *&newImage:struct CGImage *=n$33 [line 79]\n REMOVE_TEMPS(n$33); [line 79]\n " shape="box"] 44 -> 43 ; -43 [label="43: Call _fun_CGImageRelease \n n$32=*&newImage:struct CGImage * [line 88]\n _fun_CGImageRelease(n$32:struct CGImage *) [line 88]\n REMOVE_TEMPS(n$32); [line 88]\n NULLIFY(&newImage,false); [line 88]\n APPLY_ABSTRACTION; [line 88]\n " shape="box"] +43 [label="43: Call _fun_CGImageRelease \n n$32=*&newImage:struct CGImage * [line 80]\n _fun_CGImageRelease(n$32:struct CGImage *) [line 80]\n REMOVE_TEMPS(n$32); [line 80]\n NULLIFY(&newImage,false); [line 80]\n APPLY_ABSTRACTION; [line 80]\n " shape="box"] 43 -> 42 ; 42 [label="42: Exit MemoryLeakExample_testImageRefRelease \n " color=yellow style=filled] -41 [label="41: Start MemoryLeakExample_testImageRefRelease\nFormals: \nLocals: newImage:struct CGImage * \n DECLARE_LOCALS(&return,&newImage); [line 85]\n NULLIFY(&newImage,false); [line 85]\n " color=yellow style=filled] +41 [label="41: Start MemoryLeakExample_testImageRefRelease\nFormals: \nLocals: newImage:struct CGImage * \n DECLARE_LOCALS(&return,&newImage); [line 78]\n NULLIFY(&newImage,false); [line 78]\n " color=yellow style=filled] 41 -> 44 ; -40 [label="40: DeclStmt \n n$31=_fun_SecTrustCopyPublicKey(0:struct __SecTrust *) [line 81]\n *&allowedPublicKey:struct __SecKey *=n$31 [line 81]\n REMOVE_TEMPS(n$31); [line 81]\n " shape="box"] +40 [label="40: DeclStmt \n n$31=_fun_SecTrustCopyPublicKey(0:struct __SecTrust *) [line 74]\n *&allowedPublicKey:struct __SecKey *=n$31 [line 74]\n REMOVE_TEMPS(n$31); [line 74]\n " shape="box"] 40 -> 39 ; -39 [label="39: Call _fun___objc_release_cf \n n$30=*&allowedPublicKey:struct __SecKey * [line 82]\n _fun___objc_release_cf(1:_Bool ,n$30:void *) [line 82]\n REMOVE_TEMPS(n$30); [line 82]\n NULLIFY(&allowedPublicKey,false); [line 82]\n APPLY_ABSTRACTION; [line 82]\n " shape="box"] +39 [label="39: Call _fun___objc_release_cf \n n$30=*&allowedPublicKey:struct __SecKey * [line 75]\n _fun___objc_release_cf(1:_Bool ,n$30:void *) [line 75]\n REMOVE_TEMPS(n$30); [line 75]\n NULLIFY(&allowedPublicKey,false); [line 75]\n APPLY_ABSTRACTION; [line 75]\n " shape="box"] 39 -> 38 ; 38 [label="38: Exit MemoryLeakExample_test2NoLeak \n " color=yellow style=filled] -37 [label="37: Start MemoryLeakExample_test2NoLeak\nFormals: \nLocals: allowedPublicKey:struct __SecKey * \n DECLARE_LOCALS(&return,&allowedPublicKey); [line 79]\n NULLIFY(&allowedPublicKey,false); [line 79]\n " color=yellow style=filled] +37 [label="37: Start MemoryLeakExample_test2NoLeak\nFormals: \nLocals: allowedPublicKey:struct __SecKey * \n DECLARE_LOCALS(&return,&allowedPublicKey); [line 73]\n NULLIFY(&allowedPublicKey,false); [line 73]\n " color=yellow style=filled] 37 -> 40 ; -36 [label="36: DeclStmt \n n$28=*&trust:struct __SecTrust * [line 76]\n n$29=_fun_SecTrustCopyPublicKey(n$28:struct __SecTrust *) [line 76]\n *&allowedPublicKey:struct __SecKey *=n$29 [line 76]\n REMOVE_TEMPS(n$28,n$29); [line 76]\n NULLIFY(&allowedPublicKey,false); [line 76]\n NULLIFY(&trust,false); [line 76]\n APPLY_ABSTRACTION; [line 76]\n " shape="box"] +36 [label="36: DeclStmt \n n$28=*&trust:struct __SecTrust * [line 70]\n n$29=_fun_SecTrustCopyPublicKey(n$28:struct __SecTrust *) [line 70]\n *&allowedPublicKey:struct __SecKey *=n$29 [line 70]\n REMOVE_TEMPS(n$28,n$29); [line 70]\n NULLIFY(&allowedPublicKey,false); [line 70]\n NULLIFY(&trust,false); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 36 -> 35 ; 35 [label="35: Exit MemoryLeakExample_test2: \n " color=yellow style=filled] -34 [label="34: Start MemoryLeakExample_test2:\nFormals: trust:struct __SecTrust *\nLocals: allowedPublicKey:struct __SecKey * \n DECLARE_LOCALS(&return,&allowedPublicKey); [line 74]\n NULLIFY(&allowedPublicKey,false); [line 74]\n " color=yellow style=filled] +34 [label="34: Start MemoryLeakExample_test2:\nFormals: trust:struct __SecTrust *\nLocals: allowedPublicKey:struct __SecKey * \n DECLARE_LOCALS(&return,&allowedPublicKey); [line 69]\n NULLIFY(&allowedPublicKey,false); [line 69]\n " color=yellow style=filled] 34 -> 36 ; -33 [label="33: DeclStmt \n n$26=*&rect:struct CGRect [line 67]\n n$27=_fun_CGRectGetHeight(n$26:struct CGRect ) [line 67]\n *&lineThickness:double =(0.200000 * n$27) [line 67]\n REMOVE_TEMPS(n$26,n$27); [line 67]\n NULLIFY(&rect,false); [line 67]\n NULLIFY(&lineThickness,false); [line 67]\n " shape="box"] +33 [label="33: DeclStmt \n n$26=*&rect:struct CGRect [line 62]\n n$27=_fun_CGRectGetHeight(n$26:struct CGRect ) [line 62]\n *&lineThickness:double =(0.200000 * n$27) [line 62]\n REMOVE_TEMPS(n$26,n$27); [line 62]\n NULLIFY(&rect,false); [line 62]\n NULLIFY(&lineThickness,false); [line 62]\n " shape="box"] 33 -> 32 ; -32 [label="32: DeclStmt \n n$25=_fun_CGPathCreateMutable() [line 70]\n *&path1:struct CGPath *=n$25 [line 70]\n REMOVE_TEMPS(n$25); [line 70]\n " shape="box"] +32 [label="32: DeclStmt \n n$25=_fun_CGPathCreateMutable() [line 65]\n *&path1:struct CGPath *=n$25 [line 65]\n REMOVE_TEMPS(n$25); [line 65]\n " shape="box"] 32 -> 31 ; -31 [label="31: Call _fun___objc_release_cf \n n$24=*&path1:struct CGPath * [line 71]\n _fun___objc_release_cf(1:_Bool ,n$24:void *) [line 71]\n REMOVE_TEMPS(n$24); [line 71]\n NULLIFY(&path1,false); [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="box"] +31 [label="31: Call _fun___objc_release_cf \n n$24=*&path1:struct CGPath * [line 66]\n _fun___objc_release_cf(1:_Bool ,n$24:void *) [line 66]\n REMOVE_TEMPS(n$24); [line 66]\n NULLIFY(&path1,false); [line 66]\n APPLY_ABSTRACTION; [line 66]\n " shape="box"] 31 -> 30 ; 30 [label="30: Exit MemoryLeakExample_createCloseCrossGlyphNoLeak: \n " color=yellow style=filled] -29 [label="29: Start MemoryLeakExample_createCloseCrossGlyphNoLeak:\nFormals: rect:struct CGRect \nLocals: path1:struct CGPath * lineThickness:double \n DECLARE_LOCALS(&return,&path1,&lineThickness); [line 65]\n NULLIFY(&lineThickness,false); [line 65]\n NULLIFY(&path1,false); [line 65]\n " color=yellow style=filled] +29 [label="29: Start MemoryLeakExample_createCloseCrossGlyphNoLeak:\nFormals: rect:struct CGRect \nLocals: path1:struct CGPath * lineThickness:double \n DECLARE_LOCALS(&return,&path1,&lineThickness); [line 61]\n NULLIFY(&lineThickness,false); [line 61]\n NULLIFY(&path1,false); [line 61]\n " color=yellow style=filled] 29 -> 33 ; -28 [label="28: DeclStmt \n n$22=*&rect:struct CGRect [line 59]\n n$23=_fun_CGRectGetHeight(n$22:struct CGRect ) [line 59]\n *&lineThickness:double =(0.200000 * n$23) [line 59]\n REMOVE_TEMPS(n$22,n$23); [line 59]\n NULLIFY(&rect,false); [line 59]\n NULLIFY(&lineThickness,false); [line 59]\n " shape="box"] +28 [label="28: DeclStmt \n n$22=*&rect:struct CGRect [line 55]\n n$23=_fun_CGRectGetHeight(n$22:struct CGRect ) [line 55]\n *&lineThickness:double =(0.200000 * n$23) [line 55]\n REMOVE_TEMPS(n$22,n$23); [line 55]\n NULLIFY(&rect,false); [line 55]\n NULLIFY(&lineThickness,false); [line 55]\n " shape="box"] 28 -> 27 ; -27 [label="27: DeclStmt \n n$21=_fun_CGPathCreateMutable() [line 62]\n *&path1:struct CGPath *=n$21 [line 62]\n REMOVE_TEMPS(n$21); [line 62]\n NULLIFY(&path1,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +27 [label="27: DeclStmt \n n$21=_fun_CGPathCreateMutable() [line 58]\n *&path1:struct CGPath *=n$21 [line 58]\n REMOVE_TEMPS(n$21); [line 58]\n NULLIFY(&path1,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit MemoryLeakExample_createCloseCrossGlyph: \n " color=yellow style=filled] -25 [label="25: Start MemoryLeakExample_createCloseCrossGlyph:\nFormals: rect:struct CGRect \nLocals: path1:struct CGPath * lineThickness:double \n DECLARE_LOCALS(&return,&path1,&lineThickness); [line 57]\n NULLIFY(&lineThickness,false); [line 57]\n NULLIFY(&path1,false); [line 57]\n " color=yellow style=filled] +25 [label="25: Start MemoryLeakExample_createCloseCrossGlyph:\nFormals: rect:struct CGRect \nLocals: path1:struct CGPath * lineThickness:double \n DECLARE_LOCALS(&return,&path1,&lineThickness); [line 54]\n NULLIFY(&lineThickness,false); [line 54]\n NULLIFY(&path1,false); [line 54]\n " color=yellow style=filled] 25 -> 28 ; -24 [label="24: DeclStmt \n n$20=_fun_CTFramesetterCreateWithAttributedString(0:struct __CFAttributedString *) [line 53]\n *&framesetter:struct __CTFramesetter *=n$20 [line 53]\n REMOVE_TEMPS(n$20); [line 53]\n " shape="box"] +24 [label="24: DeclStmt \n n$20=_fun_CTFramesetterCreateWithAttributedString(0:struct __CFAttributedString *) [line 50]\n *&framesetter:struct __CTFramesetter *=n$20 [line 50]\n REMOVE_TEMPS(n$20); [line 50]\n " shape="box"] 24 -> 23 ; -23 [label="23: Call _fun___objc_release_cf \n n$19=*&framesetter:struct __CTFramesetter * [line 54]\n _fun___objc_release_cf(1:_Bool ,n$19:void *) [line 54]\n REMOVE_TEMPS(n$19); [line 54]\n NULLIFY(&framesetter,false); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +23 [label="23: Call _fun___objc_release_cf \n n$19=*&framesetter:struct __CTFramesetter * [line 51]\n _fun___objc_release_cf(1:_Bool ,n$19:void *) [line 51]\n REMOVE_TEMPS(n$19); [line 51]\n NULLIFY(&framesetter,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 23 -> 22 ; 22 [label="22: Exit MemoryLeakExample_test1NoLeak \n " color=yellow style=filled] -21 [label="21: Start MemoryLeakExample_test1NoLeak\nFormals: \nLocals: framesetter:struct __CTFramesetter * \n DECLARE_LOCALS(&return,&framesetter); [line 51]\n NULLIFY(&framesetter,false); [line 51]\n " color=yellow style=filled] +21 [label="21: Start MemoryLeakExample_test1NoLeak\nFormals: \nLocals: framesetter:struct __CTFramesetter * \n DECLARE_LOCALS(&return,&framesetter); [line 49]\n NULLIFY(&framesetter,false); [line 49]\n " color=yellow style=filled] 21 -> 24 ; -20 [label="20: DeclStmt \n n$17=*&str:struct __CFAttributedString * [line 48]\n n$18=_fun_CTFramesetterCreateWithAttributedString(n$17:struct __CFAttributedString *) [line 48]\n *&framesetter:struct __CTFramesetter *=n$18 [line 48]\n REMOVE_TEMPS(n$17,n$18); [line 48]\n NULLIFY(&framesetter,false); [line 48]\n NULLIFY(&str,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +20 [label="20: DeclStmt \n n$17=*&str:struct __CFAttributedString * [line 46]\n n$18=_fun_CTFramesetterCreateWithAttributedString(n$17:struct __CFAttributedString *) [line 46]\n *&framesetter:struct __CTFramesetter *=n$18 [line 46]\n REMOVE_TEMPS(n$17,n$18); [line 46]\n NULLIFY(&framesetter,false); [line 46]\n NULLIFY(&str,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 20 -> 19 ; 19 [label="19: Exit MemoryLeakExample_test1: \n " color=yellow style=filled] -18 [label="18: Start MemoryLeakExample_test1:\nFormals: str:struct __CFAttributedString *\nLocals: framesetter:struct __CTFramesetter * \n DECLARE_LOCALS(&return,&framesetter); [line 46]\n NULLIFY(&framesetter,false); [line 46]\n " color=yellow style=filled] +18 [label="18: Start MemoryLeakExample_test1:\nFormals: str:struct __CFAttributedString *\nLocals: framesetter:struct __CTFramesetter * \n DECLARE_LOCALS(&return,&framesetter); [line 45]\n NULLIFY(&framesetter,false); [line 45]\n " color=yellow style=filled] 18 -> 20 ; -17 [label="17: DeclStmt \n n$16=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 42]\n *&maString:struct __CFAttributedString *=n$16 [line 42]\n REMOVE_TEMPS(n$16); [line 42]\n " shape="box"] +17 [label="17: DeclStmt \n n$16=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 41]\n *&maString:struct __CFAttributedString *=n$16 [line 41]\n REMOVE_TEMPS(n$16); [line 41]\n " shape="box"] 17 -> 16 ; -16 [label="16: Call _fun___objc_release_cf \n n$15=*&maString:struct __CFAttributedString * [line 43]\n _fun___objc_release_cf(1:_Bool ,n$15:void *) [line 43]\n REMOVE_TEMPS(n$15); [line 43]\n NULLIFY(&maString,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +16 [label="16: Call _fun___objc_release_cf \n n$15=*&maString:struct __CFAttributedString * [line 42]\n _fun___objc_release_cf(1:_Bool ,n$15:void *) [line 42]\n REMOVE_TEMPS(n$15); [line 42]\n NULLIFY(&maString,false); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 16 -> 15 ; 15 [label="15: Exit MemoryLeakExample_measureFrameSizeForTextNoLeak \n " color=yellow style=filled] -14 [label="14: Start MemoryLeakExample_measureFrameSizeForTextNoLeak\nFormals: \nLocals: maString:struct __CFAttributedString * \n DECLARE_LOCALS(&return,&maString); [line 40]\n NULLIFY(&maString,false); [line 40]\n " color=yellow style=filled] +14 [label="14: Start MemoryLeakExample_measureFrameSizeForTextNoLeak\nFormals: \nLocals: maString:struct __CFAttributedString * \n DECLARE_LOCALS(&return,&maString); [line 39]\n NULLIFY(&maString,false); [line 39]\n " color=yellow style=filled] 14 -> 17 ; -13 [label="13: DeclStmt \n n$14=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 37]\n *&maString:struct __CFAttributedString *=n$14 [line 37]\n REMOVE_TEMPS(n$14); [line 37]\n NULLIFY(&maString,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +13 [label="13: DeclStmt \n n$14=_fun_CFAttributedStringCreateMutable(0:struct __CFAllocator *,0:long ) [line 36]\n *&maString:struct __CFAttributedString *=n$14 [line 36]\n REMOVE_TEMPS(n$14); [line 36]\n NULLIFY(&maString,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit MemoryLeakExample_measureFrameSizeForText \n " color=yellow style=filled] -11 [label="11: Start MemoryLeakExample_measureFrameSizeForText\nFormals: \nLocals: maString:struct __CFAttributedString * \n DECLARE_LOCALS(&return,&maString); [line 35]\n NULLIFY(&maString,false); [line 35]\n " color=yellow style=filled] +11 [label="11: Start MemoryLeakExample_measureFrameSizeForText\nFormals: \nLocals: maString:struct __CFAttributedString * \n DECLARE_LOCALS(&return,&maString); [line 34]\n NULLIFY(&maString,false); [line 34]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: DeclStmt \n n$10=*&self:class MemoryLeakExample * [line 31]\n n$11=_fun_MemoryLeakExample_backgroundCoveringView(n$10:class MemoryLeakExample *) [line 31]\n n$12=_fun_UIView_bounds(n$11:class UIView *) [line 31]\n n$13=_fun_CGPathCreateWithRect(n$12:struct CGRect ,0:struct CGAffineTransform *) [line 31]\n *&shadowPath:struct CGPath *=n$13 [line 31]\n REMOVE_TEMPS(n$10,n$11,n$12,n$13); [line 31]\n " shape="box"] +10 [label="10: DeclStmt \n n$10=*&self:class MemoryLeakExample * [line 30]\n n$11=_fun_MemoryLeakExample_backgroundCoveringView(n$10:class MemoryLeakExample *) [line 30]\n n$12=_fun_UIView_bounds(n$11:class UIView *) [line 30]\n n$13=_fun_CGPathCreateWithRect(n$12:struct CGRect ,0:struct CGAffineTransform *) [line 30]\n *&shadowPath:struct CGPath *=n$13 [line 30]\n REMOVE_TEMPS(n$10,n$11,n$12,n$13); [line 30]\n " shape="box"] 10 -> 9 ; -9 [label="9: Message Call: setShadowPath: \n n$6=*&self:class MemoryLeakExample * [line 32]\n n$7=_fun_MemoryLeakExample_backgroundCoveringView(n$6:class MemoryLeakExample *) [line 32]\n n$8=_fun_UIView_layer(n$7:class UIView *) [line 32]\n n$9=*&shadowPath:struct CGPath * [line 32]\n _fun_CALayer_setShadowPath:(n$8:class CALayer *,n$9:struct CGPath *) [line 32]\n REMOVE_TEMPS(n$6,n$7,n$8,n$9); [line 32]\n NULLIFY(&self,false); [line 32]\n NULLIFY(&shadowPath,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +9 [label="9: Message Call: setShadowPath: \n n$6=*&self:class MemoryLeakExample * [line 31]\n n$7=_fun_MemoryLeakExample_backgroundCoveringView(n$6:class MemoryLeakExample *) [line 31]\n n$8=_fun_UIView_layer(n$7:class UIView *) [line 31]\n n$9=*&shadowPath:struct CGPath * [line 31]\n _fun_CALayer_setShadowPath:(n$8:class CALayer *,n$9:struct CGPath *) [line 31]\n REMOVE_TEMPS(n$6,n$7,n$8,n$9); [line 31]\n NULLIFY(&self,false); [line 31]\n NULLIFY(&shadowPath,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit MemoryLeakExample_test \n " color=yellow style=filled] -7 [label="7: Start MemoryLeakExample_test\nFormals: self:class MemoryLeakExample *\nLocals: shadowPath:struct CGPath * \n DECLARE_LOCALS(&return,&shadowPath); [line 29]\n NULLIFY(&shadowPath,false); [line 29]\n " color=yellow style=filled] +7 [label="7: Start MemoryLeakExample_test\nFormals: self:class MemoryLeakExample *\nLocals: shadowPath:struct CGPath * \n DECLARE_LOCALS(&return,&shadowPath); [line 28]\n NULLIFY(&shadowPath,false); [line 28]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(class UIView ):unsigned long ) [line 21]\n *&attachmentContainerView:class UIView *=n$5 [line 21]\n REMOVE_TEMPS(n$5); [line 21]\n " shape="box"] +6 [label="6: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(class UIView ):unsigned long ) [line 20]\n *&attachmentContainerView:class UIView *=n$5 [line 20]\n REMOVE_TEMPS(n$5); [line 20]\n " shape="box"] 6 -> 5 ; diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.h b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.h index 21d6cf36e..0669aae46 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.h +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.h @@ -12,7 +12,7 @@ @interface MemoryLeakExample : NSObject -@property UIView *backgroundCoveringView; -@property UIView *attachmentContainerView; +@property UIView* backgroundCoveringView; +@property UIView* attachmentContainerView; @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.m index 96b5cd31c..30077ad0c 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/MemoryLeakExample.m @@ -8,92 +8,83 @@ */ #import "MemoryLeakExample.h" -#import #import #import +#import @implementation MemoryLeakExample -//For now it doesn't contain memory leak by default. Later, if we remove -//CFRelease, there should be a leak. -- (void)layoutSubviews -{ - UIView *attachmentContainerView = [UIView alloc]; - CGPathRef shadowPath = CGPathCreateWithRect(attachmentContainerView.bounds, NULL); - //self.attachmentContainerView.layer.shadowPath = shadowPath; - CGPathRelease(shadowPath); - [attachmentContainerView release]; - +// For now it doesn't contain memory leak by default. Later, if we remove +// CFRelease, there should be a leak. +- (void)layoutSubviews { + UIView* attachmentContainerView = [UIView alloc]; + CGPathRef shadowPath = + CGPathCreateWithRect(attachmentContainerView.bounds, NULL); + // self.attachmentContainerView.layer.shadowPath = shadowPath; + CGPathRelease(shadowPath); + [attachmentContainerView release]; } -- (void)test -{ - CGPathRef shadowPath = CGPathCreateWithRect(self.backgroundCoveringView.bounds, NULL); - self.backgroundCoveringView.layer.shadowPath = shadowPath; +- (void)test { + CGPathRef shadowPath = + CGPathCreateWithRect(self.backgroundCoveringView.bounds, NULL); + self.backgroundCoveringView.layer.shadowPath = shadowPath; } -+ (void)measureFrameSizeForText -{ - CFMutableAttributedStringRef maString = CFAttributedStringCreateMutable(nil, 0); ++ (void)measureFrameSizeForText { + CFMutableAttributedStringRef maString = + CFAttributedStringCreateMutable(nil, 0); } -+ (void)measureFrameSizeForTextNoLeak -{ - CFMutableAttributedStringRef maString = CFAttributedStringCreateMutable(nil, 0); ++ (void)measureFrameSizeForTextNoLeak { + CFMutableAttributedStringRef maString = + CFAttributedStringCreateMutable(nil, 0); CFRelease(maString); } -+ (void)test1: (CFAttributedStringRef) str - { ++ (void)test1:(CFAttributedStringRef)str { CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(str); - } +} - + (void)test1NoLeak - { - CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(nil); - CFRelease(framesetter); - } ++ (void)test1NoLeak { + CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(nil); + CFRelease(framesetter); +} -+ (void) createCloseCrossGlyph:(CGRect) rect -{ - CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); ++ (void)createCloseCrossGlyph:(CGRect)rect { + CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); - // One rectangle - CGMutablePathRef path1 = CGPathCreateMutable(); + // One rectangle + CGMutablePathRef path1 = CGPathCreateMutable(); } -+ (void) createCloseCrossGlyphNoLeak:(CGRect) rect -{ - CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); ++ (void)createCloseCrossGlyphNoLeak:(CGRect)rect { + CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); - // One rectangle - CGMutablePathRef path1 = CGPathCreateMutable(); - CFRelease(path1); + // One rectangle + CGMutablePathRef path1 = CGPathCreateMutable(); + CFRelease(path1); } -+ (void) test2: (SecTrustRef) trust -{ - SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(trust); ++ (void)test2:(SecTrustRef)trust { + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(trust); } -+ (void) test2NoLeak -{ - SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(nil); - CFRelease(allowedPublicKey); ++ (void)test2NoLeak { + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(nil); + CFRelease(allowedPublicKey); } -+ (void) testImageRefRelease -{ - CGImageRef newImage = CGBitmapContextCreateImage(nil); - CGImageRelease(newImage); ++ (void)testImageRefRelease { + CGImageRef newImage = CGBitmapContextCreateImage(nil); + CGImageRelease(newImage); } CGColorRef FBColorCreateWithGray(CGFloat gray, CGFloat a); -- (id)testFBColorCreateWithGray -{ - CGColorRef borderColor = FBColorCreateWithGray(0.0, 0.3); - CGColorRelease(borderColor); +- (id)testFBColorCreateWithGray { + CGColorRef borderColor = FBColorCreateWithGray(0.0, 0.3); + CGColorRelease(borderColor); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m index 69b0eba82..82b5a4e44 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSMakeCollectableExample.m @@ -15,14 +15,13 @@ @implementation E -- (CFReadStreamRef) readStream { - return nil; +- (CFReadStreamRef)readStream { + return nil; } -- (void) handleStreamError -{ - NSError *underlyingError = NSMakeCollectable( - [(NSError*)CFReadStreamCopyError((CFReadStreamRef)[self readStream]) autorelease]); +- (void)handleStreamError { + NSError* underlyingError = NSMakeCollectable([(NSError*)CFReadStreamCopyError( + (CFReadStreamRef)[self readStream]) autorelease]); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m index 4f1d0b8e6..19e232555 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/NSStringInitWithBytesNoCopyExample.m @@ -16,54 +16,51 @@ @implementation A -NSString *FBCreateURLQueryStringBodyEscaping(NSDictionary *parameters, NSString* s) -{ - if (s) { - char *resultBuffer = (char *)malloc(5 * sizeof(char)); +NSString* FBCreateURLQueryStringBodyEscaping(NSDictionary* parameters, + NSString* s) { + if (s) { + char* resultBuffer = (char*)malloc(5 * sizeof(char)); - NSString *resultString = - [s initWithBytesNoCopy:resultBuffer - length:5 - encoding:NSUTF8StringEncoding - freeWhenDone:YES]; - } - return s; + NSString* resultString = [s initWithBytesNoCopy:resultBuffer + length:5 + encoding:NSUTF8StringEncoding + freeWhenDone:YES]; + } + return s; } -+ (NSData *)randomBytes:(NSUInteger)numOfBytes -{ - uint8_t *buffer = malloc(numOfBytes); - NSData* data = [NSData dataWithBytesNoCopy:buffer length:numOfBytes]; - if (data) { - return data; - } - else { - free(buffer); - return nil; - } ++ (NSData*)randomBytes:(NSUInteger)numOfBytes { + uint8_t* buffer = malloc(numOfBytes); + NSData* data = [NSData dataWithBytesNoCopy:buffer length:numOfBytes]; + if (data) { + return data; + } else { + free(buffer); + return nil; + } } -- (NSData *)macForIV:(NSData *)IV -{ - uint8_t *result = malloc(10); - return [NSData dataWithBytesNoCopy:result length:10]; +- (NSData*)macForIV:(NSData*)IV { + uint8_t* result = malloc(10); + return [NSData dataWithBytesNoCopy:result length:10]; } -- (NSString *)hexStringValue { - size_t hexLen = 2 * 10 * sizeof(char); - char *outString = (char *)malloc(hexLen + 1); - NSString *result = (__bridge_transfer NSString *) - CFStringCreateWithBytesNoCopy(NULL /* default allocator */, - (const UInt8 *)outString /* sizeof(char) should always be sizeof(UInt8) on iOS */, - hexLen, - kCFStringEncodingASCII /* hex is ASCII */, - false /* no bom */, - NULL /* default deallocator -- system takes ownership of bytes */); - if (result == nil) { - // On error creating string, we're responsible for freeing outString. - free(outString); - } - return result; +- (NSString*)hexStringValue { + size_t hexLen = 2 * 10 * sizeof(char); + char* outString = (char*)malloc(hexLen + 1); + NSString* result = (__bridge_transfer NSString*)CFStringCreateWithBytesNoCopy( + NULL /* default allocator */, + (const UInt8*) + outString /* sizeof(char) should always be sizeof(UInt8) on iOS */, + hexLen, + kCFStringEncodingASCII /* hex is ASCII */, + false /* no bom */, + NULL /* default deallocator -- system takes ownership of bytes */); + if (result == nil) { + // On error creating string, we're responsible for freeing outString. + free(outString); + } + return result; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainCycleStaticVar.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainCycleStaticVar.m index af2b81c80..139597f39 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainCycleStaticVar.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainCycleStaticVar.m @@ -9,41 +9,41 @@ #import -typedef void (^MyHandler) (NSString *name); +typedef void (^MyHandler)(NSString* name); @interface C : NSObject -@property (nonatomic, strong) MyHandler handler; +@property(nonatomic, strong) MyHandler handler; -@property (nonatomic, strong) NSString *name; -@property (nonatomic,strong) C *bla1; -@property (nonatomic,strong) C *bla2; +@property(nonatomic, strong) NSString* name; +@property(nonatomic, strong) C* bla1; +@property(nonatomic, strong) C* bla2; @end @implementation C -- (void) foo { - static dispatch_once_t once; - static C* sharedInstance1; - dispatch_once(&once, ^{ - sharedInstance1 = [[C alloc] init]; - }); - static C* sharedInstance2; - dispatch_once(&once, ^{ - sharedInstance2 = [[C alloc] init]; - }); - - _bla1 = sharedInstance1; - _bla2 = sharedInstance2; - sharedInstance2.handler = ^(NSString* s){ - _name = sharedInstance2.name; - }; +- (void)foo { + static dispatch_once_t once; + static C* sharedInstance1; + dispatch_once(&once, ^{ + sharedInstance1 = [[C alloc] init]; + }); + static C* sharedInstance2; + dispatch_once(&once, ^{ + sharedInstance2 = [[C alloc] init]; + }); + + _bla1 = sharedInstance1; + _bla2 = sharedInstance2; + sharedInstance2.handler = ^(NSString* s) { + _name = sharedInstance2.name; + }; } @end int main() { - C *c = [[C alloc] init]; - [c foo]; - return 0; + C* c = [[C alloc] init]; + [c foo]; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample.m index b38c6f78a..a419560bc 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample.m @@ -18,7 +18,7 @@ @end void test() { - A *a = [[A alloc] init]; - [a retain]; - [a release]; + A* a = [[A alloc] init]; + [a retain]; + [a release]; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot index 11507f728..7e4af8274 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot @@ -1,123 +1,123 @@ digraph iCFG { -32 [label="32: Call _fun___objc_release \n n$1=*&a:class A * [line 70]\n _fun___objc_release(n$1:class A *) [line 70]\n REMOVE_TEMPS(n$1); [line 70]\n NULLIFY(&a,false); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] +32 [label="32: Call _fun___objc_release \n n$1=*&a:class A * [line 65]\n _fun___objc_release(n$1:class A *) [line 65]\n REMOVE_TEMPS(n$1); [line 65]\n NULLIFY(&a,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] 32 -> 29 ; -31 [label="31: Prune (false branch) \n n$0=*&a:class A * [line 69]\n PRUNE((n$0 == 0), false); [line 69]\n REMOVE_TEMPS(n$0); [line 69]\n APPLY_ABSTRACTION; [line 69]\n " shape="invhouse"] +31 [label="31: Prune (false branch) \n n$0=*&a:class A * [line 64]\n PRUNE((n$0 == 0), false); [line 64]\n REMOVE_TEMPS(n$0); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="invhouse"] 31 -> 29 ; -30 [label="30: Prune (true branch) \n n$0=*&a:class A * [line 69]\n PRUNE((n$0 != 0), true); [line 69]\n REMOVE_TEMPS(n$0); [line 69]\n " shape="invhouse"] +30 [label="30: Prune (true branch) \n n$0=*&a:class A * [line 64]\n PRUNE((n$0 != 0), true); [line 64]\n REMOVE_TEMPS(n$0); [line 64]\n " shape="invhouse"] 30 -> 32 ; -29 [label="29: + \n NULLIFY(&a,false); [line 69]\n " ] +29 [label="29: + \n NULLIFY(&a,false); [line 64]\n " ] 29 -> 28 ; 28 [label="28: Exit test7 \n " color=yellow style=filled] -27 [label="27: Start test7\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 68]\n " color=yellow style=filled] +27 [label="27: Start test7\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 63]\n " color=yellow style=filled] 27 -> 30 ; 27 -> 31 ; -26 [label="26: DeclStmt \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 62]\n n$4=_fun_NSObject_init(n$3:class A *) virtual [line 62]\n *&a:class A *=n$4 [line 62]\n REMOVE_TEMPS(n$3,n$4); [line 62]\n " shape="box"] +26 [label="26: DeclStmt \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 57]\n n$4=_fun_NSObject_init(n$3:class A *) virtual [line 57]\n *&a:class A *=n$4 [line 57]\n REMOVE_TEMPS(n$3,n$4); [line 57]\n " shape="box"] 26 -> 25 ; -25 [label="25: Message Call: retain \n n$1=*&a:class A * [line 63]\n n$2=_fun___objc_retain(n$1:class A *) [line 63]\n REMOVE_TEMPS(n$1,n$2); [line 63]\n " shape="box"] +25 [label="25: Message Call: retain \n n$1=*&a:class A * [line 58]\n n$2=_fun___objc_retain(n$1:class A *) [line 58]\n REMOVE_TEMPS(n$1,n$2); [line 58]\n " shape="box"] 25 -> 24 ; -24 [label="24: Message Call: release \n n$0=*&a:class A * [line 64]\n _fun___objc_release(n$0:class A *) [line 64]\n REMOVE_TEMPS(n$0); [line 64]\n NULLIFY(&a,false); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"] +24 [label="24: Message Call: release \n n$0=*&a:class A * [line 59]\n _fun___objc_release(n$0:class A *) [line 59]\n REMOVE_TEMPS(n$0); [line 59]\n NULLIFY(&a,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] 24 -> 23 ; 23 [label="23: Exit test6 \n " color=yellow style=filled] -22 [label="22: Start test6\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 61]\n NULLIFY(&a,false); [line 61]\n " color=yellow style=filled] +22 [label="22: Start test6\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 56]\n NULLIFY(&a,false); [line 56]\n " color=yellow style=filled] 22 -> 26 ; -21 [label="21: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 55]\n n$2=_fun_NSObject_init(n$1:class A *) virtual [line 55]\n *&a:class A *=n$2 [line 55]\n REMOVE_TEMPS(n$1,n$2); [line 55]\n " shape="box"] +21 [label="21: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 51]\n n$2=_fun_NSObject_init(n$1:class A *) virtual [line 51]\n *&a:class A *=n$2 [line 51]\n REMOVE_TEMPS(n$1,n$2); [line 51]\n " shape="box"] 21 -> 20 ; -20 [label="20: Message Call: release \n n$0=*&a:class A * [line 56]\n _fun___objc_release(n$0:class A *) [line 56]\n REMOVE_TEMPS(n$0); [line 56]\n NULLIFY(&a,false); [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] +20 [label="20: Message Call: release \n n$0=*&a:class A * [line 52]\n _fun___objc_release(n$0:class A *) [line 52]\n REMOVE_TEMPS(n$0); [line 52]\n NULLIFY(&a,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] 20 -> 19 ; 19 [label="19: Exit test5 \n " color=yellow style=filled] -18 [label="18: Start test5\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 54]\n NULLIFY(&a,false); [line 54]\n " color=yellow style=filled] +18 [label="18: Start test5\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 50]\n NULLIFY(&a,false); [line 50]\n " color=yellow style=filled] 18 -> 21 ; -17 [label="17: DeclStmt \n n$1=_fun_test() [line 49]\n *&b:class A *=n$1 [line 49]\n REMOVE_TEMPS(n$1); [line 49]\n " shape="box"] +17 [label="17: DeclStmt \n n$1=_fun_test() [line 45]\n *&b:class A *=n$1 [line 45]\n REMOVE_TEMPS(n$1); [line 45]\n " shape="box"] 17 -> 16 ; -16 [label="16: Message Call: release \n n$0=*&b:class A * [line 50]\n _fun___objc_release(n$0:class A *) [line 50]\n REMOVE_TEMPS(n$0); [line 50]\n NULLIFY(&b,false); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] +16 [label="16: Message Call: release \n n$0=*&b:class A * [line 46]\n _fun___objc_release(n$0:class A *) [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n NULLIFY(&b,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 16 -> 15 ; 15 [label="15: Exit test4 \n " color=yellow style=filled] -14 [label="14: Start test4\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 47]\n NULLIFY(&b,false); [line 47]\n " color=yellow style=filled] +14 [label="14: Start test4\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 43]\n NULLIFY(&b,false); [line 43]\n " color=yellow style=filled] 14 -> 17 ; -13 [label="13: DeclStmt \n n$0=_fun_test() [line 43]\n *&b:class A *=n$0 [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&b,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +13 [label="13: DeclStmt \n n$0=_fun_test() [line 40]\n *&b:class A *=n$0 [line 40]\n REMOVE_TEMPS(n$0); [line 40]\n NULLIFY(&b,false); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit test3 \n " color=yellow style=filled] -11 [label="11: Start test3\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 41]\n NULLIFY(&b,false); [line 41]\n " color=yellow style=filled] +11 [label="11: Start test3\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 40]\n NULLIFY(&b,false); [line 40]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: DeclStmt \n n$1=_fun_test() [line 36]\n *&b:class A *=n$1 [line 36]\n REMOVE_TEMPS(n$1); [line 36]\n " shape="box"] +10 [label="10: DeclStmt \n n$1=_fun_test() [line 35]\n *&b:class A *=n$1 [line 35]\n REMOVE_TEMPS(n$1); [line 35]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&b:class A * [line 37]\n *&#GB$g:class A *=n$0 [line 37]\n REMOVE_TEMPS(n$0); [line 37]\n NULLIFY(&b,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n n$0=*&b:class A * [line 36]\n *&#GB$g:class A *=n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&b,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit test2 \n " color=yellow style=filled] -7 [label="7: Start test2\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 34]\n NULLIFY(&b,false); [line 34]\n " color=yellow style=filled] +7 [label="7: Start test2\nFormals: \nLocals: b:class A * \n DECLARE_LOCALS(&return,&b); [line 33]\n NULLIFY(&b,false); [line 33]\n " color=yellow style=filled] 7 -> 10 ; -6 [label="6: DeclStmt \n n$4=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 26]\n n$5=_fun_NSObject_init(n$4:class A *) virtual [line 26]\n *&a:class A *=n$5 [line 26]\n REMOVE_TEMPS(n$4,n$5); [line 26]\n " shape="box"] +6 [label="6: DeclStmt \n n$4=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 25]\n n$5=_fun_NSObject_init(n$4:class A *) virtual [line 25]\n *&a:class A *=n$5 [line 25]\n REMOVE_TEMPS(n$4,n$5); [line 25]\n " shape="box"] 6 -> 5 ; -5 [label="5: Message Call: retain \n n$2=*&a:class A * [line 27]\n n$3=_fun___objc_retain(n$2:class A *) [line 27]\n REMOVE_TEMPS(n$2,n$3); [line 27]\n " shape="box"] +5 [label="5: Message Call: retain \n n$2=*&a:class A * [line 26]\n n$3=_fun___objc_retain(n$2:class A *) [line 26]\n REMOVE_TEMPS(n$2,n$3); [line 26]\n " shape="box"] 5 -> 4 ; -4 [label="4: Message Call: release \n n$1=*&a:class A * [line 28]\n _fun___objc_release(n$1:class A *) [line 28]\n REMOVE_TEMPS(n$1); [line 28]\n " shape="box"] +4 [label="4: Message Call: release \n n$1=*&a:class A * [line 27]\n _fun___objc_release(n$1:class A *) [line 27]\n REMOVE_TEMPS(n$1); [line 27]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&a:class A * [line 30]\n *&return:class A *=n$0 [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n NULLIFY(&a,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&a:class A * [line 29]\n *&return:class A *=n$0 [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n NULLIFY(&a,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit test \n " color=yellow style=filled] -1 [label="1: Start test\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 25]\n NULLIFY(&a,false); [line 25]\n " color=yellow style=filled] +1 [label="1: Start test\nFormals: \nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 24]\n NULLIFY(&a,false); [line 24]\n " color=yellow style=filled] 1 -> 6 ; diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m index f931863fb..690f07341 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m @@ -20,52 +20,47 @@ void __objc_release(A*); // infer builtin A* g; - // no leak A* test() { - A *a = [[A alloc] init]; - [a retain]; - [a release]; + A* a = [[A alloc] init]; + [a retain]; + [a release]; - return a; + return a; } // no leak void test2() { - A* b=test(); - g=b; + A* b = test(); + g = b; } // leak -void test3() { - - A* b=test(); -} +void test3() { A* b = test(); } // no leak void test4() { - A* b=test(); - [b release]; + A* b = test(); + [b release]; } // No leak void test5() { - A *a = [[A alloc] init]; - [a release]; - + A* a = [[A alloc] init]; + [a release]; } // leak void test6() { - A *a = [[A alloc] init]; - [a retain]; - [a release]; + A* a = [[A alloc] init]; + [a retain]; + [a release]; } // Creates specs -void test7 (A *a) { - if (a) - __objc_release(a); +void test7(A* a) { + if (a) + __objc_release(a); } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExampleBucketing.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExampleBucketing.m index 7e5ea9e42..ef696b79e 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExampleBucketing.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExampleBucketing.m @@ -18,6 +18,4 @@ @end // no leak in bucketing cf mode -void test() { - A *a = [[A alloc] init]; -} +void test() { A* a = [[A alloc] init]; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.dot b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.dot index 567feba2d..e0769049a 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.dot +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.dot @@ -1,72 +1,72 @@ digraph iCFG { -19 [label="19: Return Stmt \n n$0=_fun___builtin___CFStringMakeConstantString(\"Icon\":char *) [line 43]\n n$1=_fun_CTFontCreateWithName(n$0:struct __CFString *,17.000000:double ,0:struct CGAffineTransform *) [line 43]\n n$2=_fun___objc_cast(n$1:void *,sizeof(void ):unsigned long ) [line 43]\n *&return:struct __CTFont *=n$2 [line 43]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +19 [label="19: Return Stmt \n n$0=_fun___builtin___CFStringMakeConstantString(\"Icon\":char *) [line 41]\n n$1=_fun_CTFontCreateWithName(n$0:struct __CFString *,17.000000:double ,0:struct CGAffineTransform *) [line 41]\n n$2=_fun___objc_cast(n$1:void *,sizeof(void ):unsigned long ) [line 41]\n *&return:struct __CTFont *=n$2 [line 41]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 19 -> 18 ; 18 [label="18: Exit cfautorelease_test \n " color=yellow style=filled] -17 [label="17: Start cfautorelease_test\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 42]\n " color=yellow style=filled] +17 [label="17: Start cfautorelease_test\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] 17 -> 19 ; -16 [label="16: DeclStmt \n n$8=_fun_CFHTTPMessageCopyAllHeaderFields(0:struct __CFHTTPMessage *) [line 38]\n *&ref:struct __CFDictionary *=n$8 [line 38]\n REMOVE_TEMPS(n$8); [line 38]\n " shape="box"] +16 [label="16: DeclStmt \n n$8=_fun_CFHTTPMessageCopyAllHeaderFields(0:struct __CFHTTPMessage *) [line 36]\n *&ref:struct __CFDictionary *=n$8 [line 36]\n REMOVE_TEMPS(n$8); [line 36]\n " shape="box"] 16 -> 15 ; -15 [label="15: Call _fun_CFBridgingRelease \n n$6=*&ref:struct __CFDictionary * [line 39]\n n$7=_fun___objc_cast(n$6:void *,sizeof(struct objc_object ):unsigned long ) [line 39]\n REMOVE_TEMPS(n$6,n$7); [line 39]\n NULLIFY(&ref,false); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] +15 [label="15: Call _fun_CFBridgingRelease \n n$6=*&ref:struct __CFDictionary * [line 37]\n n$7=_fun___objc_cast(n$6:void *,sizeof(struct objc_object ):unsigned long ) [line 37]\n REMOVE_TEMPS(n$6,n$7); [line 37]\n NULLIFY(&ref,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit TollBridgeExample__readHTTPHeader \n " color=yellow style=filled] -13 [label="13: Start TollBridgeExample__readHTTPHeader\nFormals: self:class TollBridgeExample *\nLocals: ref:struct __CFDictionary * \n DECLARE_LOCALS(&return,&ref); [line 36]\n NULLIFY(&ref,false); [line 36]\n NULLIFY(&self,false); [line 36]\n " color=yellow style=filled] +13 [label="13: Start TollBridgeExample__readHTTPHeader\nFormals: self:class TollBridgeExample *\nLocals: ref:struct __CFDictionary * \n DECLARE_LOCALS(&return,&ref); [line 34]\n NULLIFY(&ref,false); [line 34]\n NULLIFY(&self,false); [line 34]\n " color=yellow style=filled] 13 -> 16 ; -12 [label="12: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(class NSLocale ):unsigned long ) [line 32]\n *&observer:struct objc_object *=n$5 [line 32]\n REMOVE_TEMPS(n$5); [line 32]\n " shape="box"] +12 [label="12: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(class NSLocale ):unsigned long ) [line 30]\n *&observer:struct objc_object *=n$5 [line 30]\n REMOVE_TEMPS(n$5); [line 30]\n " shape="box"] 12 -> 11 ; -11 [label="11: DeclStmt \n n$4=*&observer:struct objc_object * [line 33]\n *&a:struct __CFLocale *=n$4 [line 33]\n REMOVE_TEMPS(n$4); [line 33]\n NULLIFY(&a,false); [line 33]\n NULLIFY(&observer,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +11 [label="11: DeclStmt \n n$4=*&observer:struct objc_object * [line 31]\n *&a:struct __CFLocale *=n$4 [line 31]\n REMOVE_TEMPS(n$4); [line 31]\n NULLIFY(&a,false); [line 31]\n NULLIFY(&observer,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 11 -> 10 ; 10 [label="10: Exit TollBridgeExample_brideRetained \n " color=yellow style=filled] -9 [label="9: Start TollBridgeExample_brideRetained\nFormals: self:class TollBridgeExample *\nLocals: a:struct __CFLocale * observer:struct objc_object * \n DECLARE_LOCALS(&return,&a,&observer); [line 31]\n NULLIFY(&a,false); [line 31]\n NULLIFY(&observer,false); [line 31]\n NULLIFY(&self,false); [line 31]\n " color=yellow style=filled] +9 [label="9: Start TollBridgeExample_brideRetained\nFormals: self:class TollBridgeExample *\nLocals: a:struct __CFLocale * observer:struct objc_object * \n DECLARE_LOCALS(&return,&a,&observer); [line 29]\n NULLIFY(&a,false); [line 29]\n NULLIFY(&observer,false); [line 29]\n NULLIFY(&self,false); [line 29]\n " color=yellow style=filled] 9 -> 12 ; -8 [label="8: DeclStmt \n n$3=_fun_CFLocaleCreate(0:struct __CFAllocator *,0:struct __CFString *) [line 26]\n *&nameRef:struct __CFLocale *=n$3 [line 26]\n REMOVE_TEMPS(n$3); [line 26]\n " shape="box"] +8 [label="8: DeclStmt \n n$3=_fun_CFLocaleCreate(0:struct __CFAllocator *,0:struct __CFString *) [line 25]\n *&nameRef:struct __CFLocale *=n$3 [line 25]\n REMOVE_TEMPS(n$3); [line 25]\n " shape="box"] 8 -> 7 ; -7 [label="7: DeclStmt \n n$2=*&nameRef:struct __CFLocale * [line 27]\n *&a:class NSLocale *=(struct __CFLocale *)n$2 [line 27]\n REMOVE_TEMPS(n$2); [line 27]\n NULLIFY(&a,false); [line 27]\n NULLIFY(&nameRef,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +7 [label="7: DeclStmt \n n$2=*&nameRef:struct __CFLocale * [line 26]\n *&a:class NSLocale *=(struct __CFLocale *)n$2 [line 26]\n REMOVE_TEMPS(n$2); [line 26]\n NULLIFY(&a,false); [line 26]\n NULLIFY(&nameRef,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 7 -> 6 ; 6 [label="6: Exit TollBridgeExample_bridge \n " color=yellow style=filled] -5 [label="5: Start TollBridgeExample_bridge\nFormals: self:class TollBridgeExample *\nLocals: a:class NSLocale * nameRef:struct __CFLocale * \n DECLARE_LOCALS(&return,&a,&nameRef); [line 25]\n NULLIFY(&a,false); [line 25]\n NULLIFY(&nameRef,false); [line 25]\n NULLIFY(&self,false); [line 25]\n " color=yellow style=filled] +5 [label="5: Start TollBridgeExample_bridge\nFormals: self:class TollBridgeExample *\nLocals: a:class NSLocale * nameRef:struct __CFLocale * \n DECLARE_LOCALS(&return,&a,&nameRef); [line 24]\n NULLIFY(&a,false); [line 24]\n NULLIFY(&nameRef,false); [line 24]\n NULLIFY(&self,false); [line 24]\n " color=yellow style=filled] 5 -> 8 ; -4 [label="4: DeclStmt \n n$1=_fun_CFLocaleCreate(0:struct __CFAllocator *,0:struct __CFString *) [line 21]\n *&nameRef:struct __CFLocale *=n$1 [line 21]\n REMOVE_TEMPS(n$1); [line 21]\n " shape="box"] +4 [label="4: DeclStmt \n n$1=_fun_CFLocaleCreate(0:struct __CFAllocator *,0:struct __CFString *) [line 20]\n *&nameRef:struct __CFLocale *=n$1 [line 20]\n REMOVE_TEMPS(n$1); [line 20]\n " shape="box"] 4 -> 3 ; -3 [label="3: DeclStmt \n n$0=*&nameRef:struct __CFLocale * [line 22]\n *&a:class NSLocale *=(struct __CFLocale *)n$0 [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&a,false); [line 22]\n NULLIFY(&nameRef,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +3 [label="3: DeclStmt \n n$0=*&nameRef:struct __CFLocale * [line 21]\n *&a:class NSLocale *=(struct __CFLocale *)n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n NULLIFY(&a,false); [line 21]\n NULLIFY(&nameRef,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit TollBridgeExample_bridgeTransfer \n " color=yellow style=filled] -1 [label="1: Start TollBridgeExample_bridgeTransfer\nFormals: self:class TollBridgeExample *\nLocals: a:class NSLocale * nameRef:struct __CFLocale * \n DECLARE_LOCALS(&return,&a,&nameRef); [line 20]\n NULLIFY(&a,false); [line 20]\n NULLIFY(&nameRef,false); [line 20]\n NULLIFY(&self,false); [line 20]\n " color=yellow style=filled] +1 [label="1: Start TollBridgeExample_bridgeTransfer\nFormals: self:class TollBridgeExample *\nLocals: a:class NSLocale * nameRef:struct __CFLocale * \n DECLARE_LOCALS(&return,&a,&nameRef); [line 19]\n NULLIFY(&a,false); [line 19]\n NULLIFY(&nameRef,false); [line 19]\n NULLIFY(&self,false); [line 19]\n " color=yellow style=filled] 1 -> 4 ; diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.m index c59ad84d2..9ce9d887f 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/TollBridgeExample.m @@ -7,9 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import - +#import @interface TollBridgeExample : NSObject @@ -18,29 +17,28 @@ @implementation TollBridgeExample - (void)bridgeTransfer { - CFLocaleRef nameRef = CFLocaleCreate (NULL, NULL); - NSLocale *a = (__bridge_transfer NSLocale *)nameRef; + CFLocaleRef nameRef = CFLocaleCreate(NULL, NULL); + NSLocale* a = (__bridge_transfer NSLocale*)nameRef; } - (void)bridge { - CFLocaleRef nameRef = CFLocaleCreate (NULL, NULL); - NSLocale *a = (__bridge NSLocale *)nameRef; + CFLocaleRef nameRef = CFLocaleCreate(NULL, NULL); + NSLocale* a = (__bridge NSLocale*)nameRef; } - - (void)brideRetained { - id observer = [NSLocale alloc]; - CFLocaleRef a = (__bridge_retained CFLocaleRef)observer; + id observer = [NSLocale alloc]; + CFLocaleRef a = (__bridge_retained CFLocaleRef)observer; } - (void)_readHTTPHeader; { - CFDictionaryRef ref = CFHTTPMessageCopyAllHeaderFields(NULL); - CFBridgingRelease(ref); + CFDictionaryRef ref = CFHTTPMessageCopyAllHeaderFields(NULL); + CFBridgingRelease(ref); } CTFontRef cfautorelease_test() { - return CFAutorelease(CTFontCreateWithName(CFSTR("Icon"), 17.0, NULL)); + return CFAutorelease(CTFontCreateWithName(CFSTR("Icon"), 17.0, NULL)); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/arc_methods.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/arc_methods.m index 0e85dbd1a..98415d2bf 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/arc_methods.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/arc_methods.m @@ -11,37 +11,37 @@ @interface A : NSObject -+(A*) newA; ++ (A*)newA; -+(A*) someA; ++ (A*)someA; @end @implementation A -+ (A*) newA { - A* a =[[A alloc] init]; - return a; ++ (A*)newA { + A* a = [[A alloc] init]; + return a; } -+ (A*) someA { - A *a = [[A alloc] init]; ++ (A*)someA { + A* a = [[A alloc] init]; - return a; + return a; } @end -int main () { +int main() { - // A * __weak aWeakRef =0; -// A * __strong a1 =0; -// A * __unsafe_unretained anUnsafeUnretRef =0; -// A * __autoreleasing anAutoRelRef =0; + // A * __weak aWeakRef =0; + // A * __strong a1 =0; + // A * __unsafe_unretained anUnsafeUnretRef =0; + // A * __autoreleasing anAutoRelRef =0; - A *a1=[A newA]; - A *aa = a1; - A *a2 = [A someA]; - A *ab = a2; - return 0; + A* a1 = [A newA]; + A* aa = a1; + A* a2 = [A someA]; + A* ab = a2; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle.m index 7d9f70342..6beb8f8c7 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle.m @@ -14,71 +14,69 @@ @interface AA : NSObject -@property (nonatomic, strong) BB* b; +@property(nonatomic, strong) BB* b; @end - @interface BBStrong : NSObject -@property (nonatomic, strong) AA* a; +@property(nonatomic, strong) AA* a; @end - @interface BBUnsafeUnretained : NSObject -@property (nonatomic, unsafe_unretained) AA* a; +@property(nonatomic, unsafe_unretained) AA* a; @end @interface BBWeak : NSObject -@property (nonatomic, weak) AA* a; +@property(nonatomic, weak) AA* a; @end @interface BBAssign : NSObject -@property (nonatomic, assign) AA* a; +@property(nonatomic, assign) AA* a; @end int strongcycle() { - AA* a_obj =[AA alloc]; - BBStrong* b_obj = [BBStrong alloc]; + AA* a_obj = [AA alloc]; + BBStrong* b_obj = [BBStrong alloc]; - a_obj.b=b_obj; - b_obj.a=a_obj; //Retain cycle + a_obj.b = b_obj; + b_obj.a = a_obj; // Retain cycle - return 0; + return 0; } int unsafeunreainedcycle() { - AA* a_obj =[AA alloc]; - BBUnsafeUnretained* b_obj = [BBUnsafeUnretained alloc]; + AA* a_obj = [AA alloc]; + BBUnsafeUnretained* b_obj = [BBUnsafeUnretained alloc]; - a_obj.b=b_obj; - b_obj.a=a_obj; //Not a retain cycle + a_obj.b = b_obj; + b_obj.a = a_obj; // Not a retain cycle - return 0; + return 0; } int weakcycle() { - AA* a_obj =[AA alloc]; - BBWeak* b_obj = [BBWeak alloc]; + AA* a_obj = [AA alloc]; + BBWeak* b_obj = [BBWeak alloc]; - a_obj.b=b_obj; - b_obj.a=a_obj; //Not a retain cycle + a_obj.b = b_obj; + b_obj.a = a_obj; // Not a retain cycle - return 0; + return 0; } int assigncycle() { - AA* a_obj =[AA alloc]; - BBAssign* b_obj = [BBAssign alloc]; + AA* a_obj = [AA alloc]; + BBAssign* b_obj = [BBAssign alloc]; - a_obj.b=b_obj; - b_obj.a=a_obj; //Not a retain cycle + a_obj.b = b_obj; + b_obj.a = a_obj; // Not a retain cycle - return 0; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle2.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle2.m index c0ae814a0..4aaec373d 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle2.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/retain_cycle2.m @@ -15,123 +15,120 @@ @interface Parent : NSObject --(void) setChild: (Child *) c; +- (void)setChild:(Child*)c; @end @implementation Parent { - Child *child; + Child* child; } --(void) setChild: (Child *) c { +- (void)setChild:(Child*)c { - self->child =c; + self->child = c; } @end @interface ParentW : NSObject --(void) setChild: (ChildW *) c; +- (void)setChild:(ChildW*)c; @end @implementation ParentW { - ChildW *child; + ChildW* child; } --(void) setChild: (ChildW *) c { +- (void)setChild:(ChildW*)c { - self->child =c; + self->child = c; } @end @interface ParentUU : NSObject --(void) setChild: (ChildUU *) c; +- (void)setChild:(ChildUU*)c; @end @implementation ParentUU { - ChildUU *child; + ChildUU* child; } --(void) setChild: (ChildUU *) c { +- (void)setChild:(ChildUU*)c { - self->child =c; + self->child = c; } @end - @interface Child : NSObject --(void) setParent: (Parent *) p; +- (void)setParent:(Parent*)p; @end @implementation Child { - Parent *parent; + Parent* parent; } --(void) setParent: (Parent *) p { - self->parent =p; +- (void)setParent:(Parent*)p { + self->parent = p; } @end - @interface ChildW : NSObject --(void) setParent: (ParentW *) p; +- (void)setParent:(ParentW*)p; @end @implementation ChildW { - ParentW __weak *parent; + ParentW __weak* parent; } --(void) setParent: (ParentW *) p { - self->parent =p; +- (void)setParent:(ParentW*)p { + self->parent = p; } @end +@interface ChildUU : NSObject -@interface ChildUU: NSObject - --(void) setParent: (ParentUU *) p; +- (void)setParent:(ParentUU*)p; @end @implementation ChildUU { - ParentUU __unsafe_unretained *parent; + ParentUU __unsafe_unretained* parent; } --(void) setParent: (ParentUU *) p { - self->parent =p; +- (void)setParent:(ParentUU*)p { + self->parent = p; } @end void strongcycle() { - Parent *parent = [[Parent alloc] init]; - Child *child = [[Child alloc] init]; - [parent setChild:child]; - [child setParent: parent]; + Parent* parent = [[Parent alloc] init]; + Child* child = [[Child alloc] init]; + [parent setChild:child]; + [child setParent:parent]; } void weakcycle() { - ParentW *parent = [[ParentW alloc] init]; - ChildW *child = [[ChildW alloc] init]; - [parent setChild:child]; - [child setParent: parent]; + ParentW* parent = [[ParentW alloc] init]; + ChildW* child = [[ChildW alloc] init]; + [parent setChild:child]; + [child setParent:parent]; } void unsafeunretainedcycle() { - ParentUU *parent = [[ParentUU alloc] init]; - ChildUU *child = [[ChildUU alloc] init]; - [parent setChild:child]; - [child setParent: parent]; + ParentUU* parent = [[ParentUU alloc] init]; + ChildUU* child = [[ChildUU alloc] init]; + [parent setChild:child]; + [child setParent:parent]; } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/Fraction.m b/infer/tests/codetoanalyze/objc/errors/npe/Fraction.m index 34dadcc04..c38f0587d 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/Fraction.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/Fraction.m @@ -40,26 +40,25 @@ } @end - -Fraction *Fraction_create() { - Fraction *f = NULL; +Fraction* Fraction_create() { + Fraction* f = NULL; return f; } int null_deref_objc_class() { - Fraction *fraction = Fraction_create(); - [fraction setNumerator: 5]; + Fraction* fraction = Fraction_create(); + [fraction setNumerator:5]; return 0; } void test_virtual_call() { - id *fraction = [Fraction alloc]; - // virtual call: the type of fraction is obtained from the allocation - [fraction setNumerator: 5]; - if ([fraction getNumerator] != 4) { - // unreachable - int *x = NULL; - *x = 0; - } - [fraction release]; + id* fraction = [Fraction alloc]; + // virtual call: the type of fraction is obtained from the allocation + [fraction setNumerator:5]; + if ([fraction getNumerator] != 4) { + // unreachable + int* x = NULL; + *x = 0; + } + [fraction release]; } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.h b/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.h index 35ac699ed..67dd12f00 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.h +++ b/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.h @@ -12,7 +12,7 @@ @interface NullDeref : NSObject -@property UIView *backgroundCoveringView; -@property UIView *attachmentContainerView; +@property UIView* backgroundCoveringView; +@property UIView* attachmentContainerView; @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.m b/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.m index 47c9a00b6..b7c725ed7 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/NPD_core_foundation.m @@ -8,46 +8,40 @@ */ #import "NPD_core_foundation.h" -#import #import #import +#import @implementation NullDeref -//For now it doesn't contain memory leak by default. Later, if we remove -//CFRelease, there should be a leak. -- (void)layoutSubviews -{ - UIView *attachmentContainerView = [UIView alloc]; - CGPathRef shadowPath = CGPathCreateWithRect(attachmentContainerView.bounds, NULL); - CFRelease(shadowPath); - [attachmentContainerView release]; - +// For now it doesn't contain memory leak by default. Later, if we remove +// CFRelease, there should be a leak. +- (void)layoutSubviews { + UIView* attachmentContainerView = [UIView alloc]; + CGPathRef shadowPath = + CGPathCreateWithRect(attachmentContainerView.bounds, NULL); + CFRelease(shadowPath); + [attachmentContainerView release]; } - -+ (void)measureFrameSizeForTextNoLeak -{ - CFMutableAttributedStringRef maString = CFAttributedStringCreateMutable(nil, 0); - if (maString) CFRelease(maString); ++ (void)measureFrameSizeForTextNoLeak { + CFMutableAttributedStringRef maString = + CFAttributedStringCreateMutable(nil, 0); + if (maString) + CFRelease(maString); } ++ (void)createCloseCrossGlyphNoLeak:(CGRect)rect { + CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); -+ (void) createCloseCrossGlyphNoLeak:(CGRect) rect -{ - CGFloat lineThickness = 0.20f * CGRectGetHeight(rect); - - // One rectangle - CGMutablePathRef path1 = CGPathCreateMutable(); - CFRelease(path1); + // One rectangle + CGMutablePathRef path1 = CGPathCreateMutable(); + CFRelease(path1); } - -+ (void) test2 -{ - SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(nil); - CFRelease(allowedPublicKey); ++ (void)test2 { + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(nil); + CFRelease(allowedPublicKey); } - @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.dot b/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.dot index 1caf09242..43914ef0e 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.dot +++ b/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.dot @@ -3,7 +3,7 @@ digraph iCFG { 13 -> 12 ; -12 [label="12: Call n$0 \n n$0=*&callback:_fn_ (*) [line 47]\n n$0(0:class NSError *,0:struct objc_object *) [line 47]\n REMOVE_TEMPS(n$0); [line 47]\n NULLIFY(&callback,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +12 [label="12: Call n$0 \n n$0=*&callback:_fn_ (*) [line 46]\n n$0(0:class NSError *,0:struct objc_object *) [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n NULLIFY(&callback,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 12 -> 11 ; @@ -14,7 +14,7 @@ digraph iCFG { 10 -> 13 ; -9 [label="9: Call _fun___infer_assume \n n$5=*&a:class A * [line 37]\n n$6=_fun___infer_assume((n$5 != 0):class A *) [line 37]\n REMOVE_TEMPS(n$5,n$6); [line 37]\n " shape="box"] +9 [label="9: Call _fun___infer_assume \n n$5=*&a:class A * [line 38]\n n$6=_fun___infer_assume((n$5 != 0):class A *) [line 38]\n REMOVE_TEMPS(n$5,n$6); [line 38]\n " shape="box"] 9 -> 8 ; @@ -33,18 +33,18 @@ digraph iCFG { 5 [label="5: Exit C_initWithCoder:and: \n " color=yellow style=filled] -4 [label="4: Start C_initWithCoder:and:\nFormals: self:class C * aDecoder:class NSString * a:class A *\nLocals: y:int a1:class A * \n DECLARE_LOCALS(&return,&y,&a1); [line 37]\n NULLIFY(&a1,false); [line 37]\n NULLIFY(&aDecoder,false); [line 37]\n NULLIFY(&y,false); [line 37]\n " color=yellow style=filled] +4 [label="4: Start C_initWithCoder:and:\nFormals: self:class C * aDecoder:class NSString * a:class A *\nLocals: y:int a1:class A * \n DECLARE_LOCALS(&return,&y,&a1); [line 38]\n NULLIFY(&a1,false); [line 38]\n NULLIFY(&aDecoder,false); [line 38]\n NULLIFY(&y,false); [line 38]\n " color=yellow style=filled] 4 -> 9 ; -3 [label="3: Return Stmt \n n$0=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 25]\n n$1=_fun_NSObject_init(n$0:class A *) virtual [line 25]\n *&return:class A *=n$1 [line 25]\n n$2=_fun___set_autorelease_attribute(n$1:class A *) [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 26]\n n$1=_fun_NSObject_init(n$0:class A *) virtual [line 26]\n *&return:class A *=n$1 [line 26]\n n$2=_fun___set_autorelease_attribute(n$1:class A *) [line 26]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit A_getA \n " color=yellow style=filled] -1 [label="1: Start A_getA\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n NULLIFY(&self,false); [line 24]\n " color=yellow style=filled] +1 [label="1: Start A_getA\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n NULLIFY(&self,false); [line 25]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m b/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m index f22b1bb50..dc7ffc16c 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/Nonnull_attribute_example.m @@ -12,37 +12,35 @@ void __infer_assume(int cond); @interface A : NSObject { - @public int x; + @public + int x; } --(A*) getA; +- (A*)getA; @end @implementation A --(A*) getA { - return [A new]; +- (A*)getA { + return [A new]; } @end @interface C : NSObject -@property (copy, nonnull) NSString *name; +@property(copy, nonnull) NSString* name; @end @implementation C -- (instancetype)initWithCoder:(NSString*)aDecoder and:( A* __nonnull)a -{ - A* a1 = [a getA]; - int y = a1->x; - return self; +- (instancetype)initWithCoder:(NSString*)aDecoder and:(A* __nonnull)a { + A* a1 = [a getA]; + int y = a1->x; + return self; } @end -void test(void (^ __nonnull callback)(NSError *, id)) { - callback(NULL, NULL); -} +void test(void (^__nonnull callback)(NSError*, id)) { callback(NULL, NULL); } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/Npe_with_equal_names.m b/infer/tests/codetoanalyze/objc/errors/npe/Npe_with_equal_names.m index 378603da4..1ee88b101 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/Npe_with_equal_names.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/Npe_with_equal_names.m @@ -10,34 +10,35 @@ #import @interface A : NSObject { - @public int x; + @public + int x; } -+(A*) meth; ++ (A*)meth; -@property (nonatomic, readonly) A* meth; +@property(nonatomic, readonly) A* meth; @end @implementation A -+(A*) meth { - return [A new]; ++ (A*)meth { + return [A new]; } --(A*) meth { - return nil; +- (A*)meth { + return nil; } @end int test() { - A* para = [A new]; - A *a = [para meth]; - return a->x; + A* para = [A new]; + A* a = [para meth]; + return a->x; } int test2(A* para) { - A *a = [A meth]; - return a->x; + A* a = [A meth]; + return a->x; } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/ObjCMethodCallInCondition.m b/infer/tests/codetoanalyze/objc/errors/npe/ObjCMethodCallInCondition.m index 69358418f..5578d48d3 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/ObjCMethodCallInCondition.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/ObjCMethodCallInCondition.m @@ -7,35 +7,33 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import +#import @interface A : NSObject -@property (nonatomic) A* child; +@property(nonatomic) A* child; -@property (nonatomic) A* url; +@property(nonatomic) A* url; @end @implementation A -- (void)testLength:(NSData *)imageData -{ - unsigned char *pixels = (unsigned char *)[imageData bytes]; +- (void)testLength:(NSData*)imageData { + unsigned char* pixels = (unsigned char*)[imageData bytes]; - if (imageData.length > 0) { - pixels[0] = 255; - } + if (imageData.length > 0) { + pixels[0] = 255; + } } -A* testUrl(A* context) -{ - if (context.url) { - A* entityMemObject = context.child; - return entityMemObject->_child; - } - return nil; +A* testUrl(A* context) { + if (context.url) { + A* entityMemObject = context.child; + return entityMemObject->_child; + } + return nil; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/UpdateDict.m b/infer/tests/codetoanalyze/objc/errors/npe/UpdateDict.m index 39fc01ccf..2a0b51972 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/UpdateDict.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/UpdateDict.m @@ -9,66 +9,89 @@ #import - void update_dict_with_null() { - NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"Matt", @"firstName", @"Galloway", @"lastName", - @28, @"age", nil]; - mDict[@"firstName"] = nil; + NSMutableDictionary* mDict = + [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Matt", + @"firstName", + @"Galloway", + @"lastName", + @28, + @"age", + nil]; + mDict[@"firstName"] = nil; } void update_dict_with_key_null() { - NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"Matt", @"firstName", @"Galloway", @"lastName", - @28, @"age", nil]; - id key = nil; - mDict[key] = @"Dulma"; + NSMutableDictionary* mDict = + [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Matt", + @"firstName", + @"Galloway", + @"lastName", + @28, + @"age", + nil]; + id key = nil; + mDict[key] = @"Dulma"; } void update_dict_without_null() { - NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"Matt", @"firstName", @"Galloway", @"lastName", - @28, @"age", nil]; - mDict[@"firstName"] = @"Dulma"; + NSMutableDictionary* mDict = + [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Matt", + @"firstName", + @"Galloway", + @"lastName", + @28, + @"age", + nil]; + mDict[@"firstName"] = @"Dulma"; } void update_array_with_null() { - NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; - NSUInteger idx = 0; - id newObject = nil; - array[idx] = newObject; + NSMutableArray* array = + [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; + NSUInteger idx = 0; + id newObject = nil; + array[idx] = newObject; } void update_array_without_null() { - NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; - NSUInteger idx = 0; - id newObject = @"Dino"; - array[idx] = newObject; + NSMutableArray* array = + [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; + NSUInteger idx = 0; + id newObject = @"Dino"; + array[idx] = newObject; } void add_nil_to_array() { - NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; - id str = nil; - [array addObject:str]; + NSMutableArray* array = + [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; + id str = nil; + [array addObject:str]; } void insert_nil_in_array() { - NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; - id str = nil; - [array insertObject:str atIndex:0]; + NSMutableArray* array = + [NSMutableArray arrayWithObjects:@"Dulma", @"Rodriguez", nil]; + id str = nil; + [array insertObject:str atIndex:0]; } void add_nil_in_dict() { - NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"Matt", @"firstName", @"Galloway", @"lastName", - @28, @"age", nil]; - id str = nil; - [mDict setObject:str forKey:@"firstName"]; + NSMutableDictionary* mDict = + [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Matt", + @"firstName", + @"Galloway", + @"lastName", + @28, + @"age", + nil]; + id str = nil; + [mDict setObject:str forKey:@"firstName"]; } -void no_npe_for_undef_values (NSDictionary* response){ - NSMutableDictionary *fileInfo = [response mutableCopy]; - fileInfo[@"type"] = @"BLA"; - NSMutableDictionary *d = [NSMutableDictionary dictionary]; - d[@"fds"] = fileInfo; +void no_npe_for_undef_values(NSDictionary* response) { + NSMutableDictionary* fileInfo = [response mutableCopy]; + fileInfo[@"type"] = @"BLA"; + NSMutableDictionary* d = [NSMutableDictionary dictionary]; + d[@"fds"] = fileInfo; } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/block.m b/infer/tests/codetoanalyze/objc/errors/npe/block.m index d85b35219..8d338f62b 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/block.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/block.m @@ -12,84 +12,72 @@ @interface A : NSObject @end - @implementation A { - void (^_block_field)(void); + void (^_block_field)(void); } - -- (void)doSomethingThenCallback:( void(^)(void) ) my_block -{ - // null dereference, segfault - my_block(); - +- (void)doSomethingThenCallback:(void (^)(void))my_block { + // null dereference, segfault + my_block(); } +- (void)foo { -- (void) foo { - - void (^my_block)(void)=^() {}; - my_block = NULL; - my_block(); // Null deref - + void (^my_block)(void) = ^() { + }; + my_block = NULL; + my_block(); // Null deref } - -- foo2: ( void(^)(void) ) my_block { +- foo2:(void (^)(void))my_block { // ok to call this block! - if(my_block != nil) { + if (my_block != nil) { my_block(); + } } -} - - -- (void) foo3: ( void(^)(void) ) my_block { - - my_block = NULL; - my_block(); //Null deref +- (void)foo3:(void (^)(void))my_block { + my_block = NULL; + my_block(); // Null deref } -- (void) foo4: ( void(^)(void) ) my_block_param { - - void (^my_block)(void)=^() {}; - my_block = NULL; - my_block_param = my_block; - my_block_param(); //Null deref +- (void)foo4:(void (^)(void))my_block_param { + void (^my_block)(void) = ^() { + }; + my_block = NULL; + my_block_param = my_block; + my_block_param(); // Null deref } -- (void) foo5: ( void(^)(void) ) my_block_param { - - void (^my_block)(void)=^() {}; - my_block_param = my_block; - my_block_param(); //No error here +- (void)foo5:(void (^)(void))my_block_param { + void (^my_block)(void) = ^() { + }; + my_block_param = my_block; + my_block_param(); // No error here } +- (void)foo6:(BOOL)a block_param:(void (^)(void))block_param { -- (void) foo6: (BOOL)a block_param: ( void (^)(void)) block_param { - - void (^my_block)(void)=^() { - if (block_param) - block_param(); //No error here + void (^my_block)(void) = ^() { + if (block_param) + block_param(); // No error here - }; - - if (a){ - [self foo2: ^() { - my_block(); // No error here - }]; - } + }; + if (a) { + [self foo2:^() { + my_block(); // No error here + }]; + } } -- (void) foo7 { - - _block_field(); // Ivar not nullable +- (void)foo7 { + _block_field(); // Ivar not nullable } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/blockenum.m b/infer/tests/codetoanalyze/objc/errors/npe/blockenum.m index 2277c41e0..244bafdf3 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/blockenum.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/blockenum.m @@ -10,57 +10,55 @@ #import @interface B : NSObject -+ foo:(id) obj; ++ foo:(id)obj; @end @implementation B -+ (B*) foo:(id) obj -{ - return obj; ++ (B*)foo:(id)obj { + return obj; } @end - @interface A : NSObject -- (NSMutableArray *) allResultsList: (NSArray *) allResults; +- (NSMutableArray*)allResultsList:(NSArray*)allResults; @end - @implementation A // From a diff -- (NSMutableArray *) allResultsList: (NSArray *) allResults { - NSMutableArray *resultsList = [[NSMutableArray alloc] init]; - [allResults enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - id *result = [B foo:obj]; - if (result != nil) { - [resultsList addObject:result]; - } - }]; - return resultsList; +- (NSMutableArray*)allResultsList:(NSArray*)allResults { + NSMutableArray* resultsList = [[NSMutableArray alloc] init]; + [allResults enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) { + id* result = [B foo:obj]; + if (result != nil) { + [resultsList addObject:result]; + } + }]; + return resultsList; } // How that code is translated in INFER -- (void) foo1: (NSArray*) a { - NSArray *objects = a; - NSMutableArray *resultsList = [[NSMutableArray alloc] init]; - void (^enumerateObjectsUsingBlock)(id, NSUInteger, BOOL* ) = +- (void)foo1:(NSArray*)a { + NSArray* objects = a; + NSMutableArray* resultsList = [[NSMutableArray alloc] init]; + void (^enumerateObjectsUsingBlock)(id, NSUInteger, BOOL*) = ^(id obj, NSUInteger idx, BOOL* stop) { - id *result = [B foo:obj]; + id* result = [B foo:obj]; if (result != nil) { - [resultsList addObject:result]; + [resultsList addObject:result]; } - }; - BOOL *stop = malloc(sizeof(BOOL)); - *stop = NO; - for (NSUInteger idx = 0; idx < objects.count; idx++) { - id object = objects[idx]; - enumerateObjectsUsingBlock(object, idx, stop); - if ( *stop == YES) break; - } - free(stop); + }; + BOOL* stop = malloc(sizeof(BOOL)); + *stop = NO; + for (NSUInteger idx = 0; idx < objects.count; idx++) { + id object = objects[idx]; + enumerateObjectsUsingBlock(object, idx, stop); + if (*stop == YES) + break; + } + free(stop); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/nil_in_array_literal.m b/infer/tests/codetoanalyze/objc/errors/npe/nil_in_array_literal.m index 2e239c7b4..934af3287 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/nil_in_array_literal.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/nil_in_array_literal.m @@ -10,50 +10,49 @@ #import @interface A : NSObject { - } @end @implementation A --(void) noProblem { - NSArray *foo = @[@"aaa", @"bbb"]; +- (void)noProblem { + NSArray* foo = @[ @"aaa", @"bbb" ]; // check that array literals create valid objects - NSArray *foofoo = @[foo]; + NSArray* foofoo = @[ foo ]; } --(void) nilInArrayLiteral0 { - NSString *str = nil; +- (void)nilInArrayLiteral0 { + NSString* str = nil; // nil argument in array literal crashes - NSArray *foo = @[str]; + NSArray* foo = @[ str ]; } --(void) nilInArrayLiteral1 { - NSString *str = nil; +- (void)nilInArrayLiteral1 { + NSString* str = nil; // nil argument in array literal crashes - NSArray *foo = @[str, @"bbb"]; + NSArray* foo = @[ str, @"bbb" ]; } --(void) nilInArrayLiteral2 { - NSString *str = nil; +- (void)nilInArrayLiteral2 { + NSString* str = nil; // nil argument in array literal crashes - NSArray *foo = @[@"aaa", str, @"bbb"]; + NSArray* foo = @[ @"aaa", str, @"bbb" ]; } --(void) nilInArrayLiteral3 { - NSString *str = nil; +- (void)nilInArrayLiteral3 { + NSString* str = nil; // nil argument in array literal crashes - NSArray *foo = @[@"aaa", @"bbb", str]; + NSArray* foo = @[ @"aaa", @"bbb", str ]; } @end int main() { - A *a = [A alloc]; + A* a = [A alloc]; [a noProblem]; [a nilInArrayLiteral0]; return 0; diff --git a/infer/tests/codetoanalyze/objc/errors/npe/nil_in_dictionary_literal.m b/infer/tests/codetoanalyze/objc/errors/npe/nil_in_dictionary_literal.m index f1d657f94..51b4a6f5c 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/nil_in_dictionary_literal.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/nil_in_dictionary_literal.m @@ -10,78 +10,93 @@ #import @interface A : NSObject { - } @end @implementation A --(void) noProblem { - NSDictionary *foo = @{@"aaa":@"a value", @"bbb":@"b value"}; +- (void)noProblem { + NSDictionary* foo = @{ @"aaa" : @"a value", @"bbb" : @"b value" }; // check that dictionary literals create valid objects - NSArray *foofoo = @[foo]; + NSArray* foofoo = @[ foo ]; } --(void) nilInDictionaryLiteralKey0 { - NSString *str = nil; +- (void)nilInDictionaryLiteralKey0 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{str: @"a value"}; + NSDictionary* foo = @{ str : @"a value" }; } --(void) nilInDictionaryLiteralValue0 { - NSString *str = nil; +- (void)nilInDictionaryLiteralValue0 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa": str}; + NSDictionary* foo = @{ @"aaa" : str }; } --(void) nilInDictionaryLiteralKey1 { - NSString *str = nil; +- (void)nilInDictionaryLiteralKey1 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{str: @"a value", @"bbb":@"b value"}; + NSDictionary* foo = @{ str : @"a value", @"bbb" : @"b value" }; } --(void) nilInDictionaryLiteralValue1 { - NSString *str = nil; +- (void)nilInDictionaryLiteralValue1 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa": str, @"bbb":@"b value"}; + NSDictionary* foo = @{ @"aaa" : str, @"bbb" : @"b value" }; } --(void) nilInDictionaryLiteralKey2 { - NSString *str = nil; +- (void)nilInDictionaryLiteralKey2 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa":@"a value", str:@"b value", @"ccc":@"c value"}; + NSDictionary* foo = @{ + @"aaa" : @"a value", + str : @"b value", + @"ccc" : @"c value" + }; } --(void) nilInDictionaryLiteralValue2 { - NSString *str = nil; +- (void)nilInDictionaryLiteralValue2 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa":@"a value", @"bbb":str, @"ccc":@"c value"}; + NSDictionary* foo = @{ + @"aaa" : @"a value", + @"bbb" : str, + @"ccc" : @"c value" + }; } --(void) nilInDictionaryLiteralKey3 { - NSString *str = nil; +- (void)nilInDictionaryLiteralKey3 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa":@"a value", @"bbb":@"b value", str:@"c value"}; + NSDictionary* foo = @{ + @"aaa" : @"a value", + @"bbb" : @"b value", + str : @"c value" + }; } --(void) nilInDictionaryLiteralValue3 { - NSString *str = nil; +- (void)nilInDictionaryLiteralValue3 { + NSString* str = nil; // nil argument in dictionary literal crashes - NSDictionary *foo = @{@"aaa":@"a value", @"bbb":@"b value", @"ccc":str}; + NSDictionary* foo = @{ + @"aaa" : @"a value", + @"bbb" : @"b value", + @"ccc" : str + }; } @end int main() { - A *a = [A alloc]; + A* a = [A alloc]; [a noProblem]; [a nilInDictionaryLiteralKey0]; return 0; diff --git a/infer/tests/codetoanalyze/objc/errors/npe/nil_param.m b/infer/tests/codetoanalyze/objc/errors/npe/nil_param.m index eb6dfc197..a27b67356 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/nil_param.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/nil_param.m @@ -16,23 +16,21 @@ @implementation A --(void) test2 { +- (void)test2 { self->x = 1; } --(void) test1:(A*) other { - - [other test2]; - +- (void)test1:(A*)other { + [other test2]; } @end -int main () { +int main() { - A* a=[A alloc]; - [a test1: nil]; - [a release]; - return 0; + A* a = [A alloc]; + [a test1:nil]; + [a release]; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.dot b/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.dot index b922e0dd5..ca1a7e105 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.dot +++ b/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.dot @@ -1,13 +1,13 @@ digraph iCFG { -5 [label="5: DeclStmt \n n$2=_fun_malloc_no_fail(sizeof(struct Person ):struct Person ) [line 26]\n *&person:struct Person *=n$2 [line 26]\n REMOVE_TEMPS(n$2); [line 26]\n " shape="box"] +5 [label="5: DeclStmt \n n$2=_fun_malloc_no_fail(sizeof(struct Person ):struct Person ) [line 25]\n *&person:struct Person *=n$2 [line 25]\n REMOVE_TEMPS(n$2); [line 25]\n " shape="box"] 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n n$1=*&person:struct Person * [line 27]\n *n$1.x:int =10 [line 27]\n REMOVE_TEMPS(n$1); [line 27]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n n$1=*&person:struct Person * [line 26]\n *n$1.x:int =10 [line 26]\n REMOVE_TEMPS(n$1); [line 26]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&person:struct Person * [line 28]\n *&return:struct Person *=n$0 [line 28]\n REMOVE_TEMPS(n$0); [line 28]\n NULLIFY(&person,false); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&person:struct Person * [line 27]\n *&return:struct Person *=n$0 [line 27]\n REMOVE_TEMPS(n$0); [line 27]\n NULLIFY(&person,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.m b/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.m index 3a1c84dfa..e8aba7a4e 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/npe_malloc.m @@ -11,8 +11,8 @@ #import struct Person { - int x; - int y; + int x; + int y; }; @interface C : NSObject @@ -21,11 +21,10 @@ struct Person { @implementation C -- (struct Person*) test -{ - struct Person* person = (struct Person *)malloc(sizeof(struct Person)); - person->x = 10; - return person; +- (struct Person*)test { + struct Person* person = (struct Person*)malloc(sizeof(struct Person)); + person->x = 10; + return person; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/npe_self.m b/infer/tests/codetoanalyze/objc/errors/npe/npe_self.m index eca6e2742..17368809e 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/npe_self.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/npe_self.m @@ -10,41 +10,41 @@ #import #import - @interface C : NSObject { - int x; - C* _currentCompositionState; + int x; + C* _currentCompositionState; } -@property (nonatomic, copy, readonly) NSString *JSON; +@property(nonatomic, copy, readonly) NSString* JSON; @end @implementation C - (id)init { - self = [super init]; - self->x = 10; - return self; + self = [super init]; + self->x = 10; + return self; } -- (void)captureManagerSessionDidStart -{ - __weak C *weakSelf = self; - C *strongSelf = weakSelf; - int x = strongSelf->x; +- (void)captureManagerSessionDidStart { + __weak C* weakSelf = self; + C* strongSelf = weakSelf; + int x = strongSelf->x; } -- (int)test -{ - if (_currentCompositionState != nil) {} - return _currentCompositionState->x; +- (int)test { + if (_currentCompositionState != nil) { + } + return _currentCompositionState->x; } - (BOOL)isEqual:(id)object { - if (object == self) return YES; - if (![object isKindOfClass:[self class]]) return NO; - C *other = (C *)object; - return ([_JSON isEqualToString:other->_JSON]); + if (object == self) + return YES; + if (![object isKindOfClass:[self class]]) + return NO; + C* other = (C*)object; + return ([_JSON isEqualToString:other->_JSON]); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/null_returned_by_method.m b/infer/tests/codetoanalyze/objc/errors/npe/null_returned_by_method.m index 9c9c2b0fc..f2ecb5a91 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/null_returned_by_method.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/null_returned_by_method.m @@ -14,15 +14,15 @@ @end @implementation A { - int x; + int x; } --(A*)test { - return nil; +- (A*)test { + return nil; } --(int)test1 { - return [self test]->x; +- (int)test1 { + return [self test]->x; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/npe/nullable.m b/infer/tests/codetoanalyze/objc/errors/npe/nullable.m index 6c707b739..68f5d5f1f 100644 --- a/infer/tests/codetoanalyze/objc/errors/npe/nullable.m +++ b/infer/tests/codetoanalyze/objc/errors/npe/nullable.m @@ -10,7 +10,8 @@ #import @interface A : NSObject { - @public int fld; + @public + int fld; } @end @@ -19,34 +20,26 @@ @property int prop; -- (void) method; +- (void)method; @end +int derefNullableParamDirect(A* __nullable param) { return param->fld; } -int derefNullableParamDirect(A * __nullable param) { - return param->fld; -} - -int derefNullableParamIndirect(A * __nullable param) { +int derefNullableParamIndirect(A* __nullable param) { A* local = param; return local->fld; } -A * derefNullableParamOk(A * __nullable param) { - if (!param) param = [A new]; +A* derefNullableParamOk(A* __nullable param) { + if (!param) + param = [A new]; param->fld = 7; return param; } -int readNullableParamPropertyOk(B * __nullable param) { - return param.prop; -} +int readNullableParamPropertyOk(B* __nullable param) { return param.prop; } -void writeNullableParamPropertyOk(B * __nullable param) { - param.prop = 7; -} +void writeNullableParamPropertyOk(B* __nullable param) { param.prop = 7; } -void methodCallOnNullableParamOk(B * __nullable param) { - [param method]; -} +void methodCallOnNullableParamOk(B* __nullable param) { [param method]; } diff --git a/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.h b/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.h index 4a54e22f2..3c10b4aa4 100644 --- a/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.h +++ b/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.h @@ -11,6 +11,6 @@ @interface MethodCall : NSObject -- (int)plusX :(int)x andY: (int)y; +- (int)plusX:(int)x andY:(int)y; @end diff --git a/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.m b/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.m index cb6802a55..8446230b3 100644 --- a/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.m +++ b/infer/tests/codetoanalyze/objc/errors/procdescs/MethodCall.m @@ -11,8 +11,8 @@ @implementation MethodCall -- (int)plusX : (int)x andY : (int)y { - return x+y; +- (int)plusX:(int)x andY:(int)y { + return x + y; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/procdescs/main.c b/infer/tests/codetoanalyze/objc/errors/procdescs/main.c index 215c33782..49cf56262 100644 --- a/infer/tests/codetoanalyze/objc/errors/procdescs/main.c +++ b/infer/tests/codetoanalyze/objc/errors/procdescs/main.c @@ -11,15 +11,15 @@ #include int main() { - MethodCall *call = [MethodCall alloc]; - int n = [call plusX : 1 andY: 3]; - int *x = malloc(sizeof(int)); - return n; + MethodCall* call = [MethodCall alloc]; + int n = [call plusX:1 andY:3]; + int* x = malloc(sizeof(int)); + return n; } int call_nslog() { - MethodCall *call = [MethodCall alloc]; + MethodCall* call = [MethodCall alloc]; NSLog(@"%s", "printing"); - int *x = malloc(sizeof(int)); + int* x = malloc(sizeof(int)); return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/property/ExplicitIvarName.m b/infer/tests/codetoanalyze/objc/errors/property/ExplicitIvarName.m index 5d5d67bcc..6487969c7 100644 --- a/infer/tests/codetoanalyze/objc/errors/property/ExplicitIvarName.m +++ b/infer/tests/codetoanalyze/objc/errors/property/ExplicitIvarName.m @@ -11,13 +11,13 @@ @interface A : NSObject -@property (nonatomic) int x; +@property(nonatomic) int x; @end @interface B : NSObject -@property (nonatomic) int y; +@property(nonatomic) int y; @end @@ -25,23 +25,24 @@ @synthesize x; - --(int) test { - int* p = 0; - self->x = 5; - if (self.x == 5) { // If NPE is found, means that getter is using the correct ivar name x - //rather than the default _x - return *p; - }; +- (int)test { + int* p = 0; + self->x = 5; + if (self.x == 5) { // If NPE is found, means that getter is using the correct + // ivar name x + // rather than the default _x + return *p; + }; } --(int) testDefaultName { - int* p = 0; - B *b = [[B alloc] init]; - b.y = 5; - if (b.y == 5) { // If NPE is found, means that getter is using default name _y that is - // added to the tenv, so there is no Missing_fld beforehand. - return *p; - }; +- (int)testDefaultName { + int* p = 0; + B* b = [[B alloc] init]; + b.y = 5; + if (b.y == 5) { // If NPE is found, means that getter is using default name _y + // that is + // added to the tenv, so there is no Missing_fld beforehand. + return *p; + }; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/property/main.c b/infer/tests/codetoanalyze/objc/errors/property/main.c index 711c429df..a9fee8d58 100644 --- a/infer/tests/codetoanalyze/objc/errors/property/main.c +++ b/infer/tests/codetoanalyze/objc/errors/property/main.c @@ -11,8 +11,8 @@ #include int main() { - IvarExample *i = [IvarExample alloc]; - int a = i.aProperty; - int *x = malloc(sizeof(int)); - return 0; + IvarExample* i = [IvarExample alloc]; + int a = i.aProperty; + int* x = malloc(sizeof(int)); + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/Bicycle.m b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/Bicycle.m index 8d54cb2fc..96660db2c 100644 --- a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/Bicycle.m +++ b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/Bicycle.m @@ -13,23 +13,23 @@ @implementation Bicycle - (void)signalStop { - NSLog(@"Bending left arm downwards"); + NSLog(@"Bending left arm downwards"); } - (void)signalLeftTurn { - NSLog(@"Extending left arm outwards"); + NSLog(@"Extending left arm outwards"); } - (void)signalRightTurn { - NSLog(@"Bending left arm upwards"); + NSLog(@"Bending left arm upwards"); } - (void)startPedaling { - NSLog(@"Here we go!"); + NSLog(@"Here we go!"); } - (void)removeFrontWheel { - NSLog(@"Front wheel is off." - "Should probably replace that before pedaling..."); + NSLog(@"Front wheel is off." + "Should probably replace that before pedaling..."); } - (void)lockToStructure:(id)theStructure { - NSLog(@"Locked to structure. Don't forget the combination!"); + NSLog(@"Locked to structure. Don't forget the combination!"); } @end diff --git a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/StreetVehicle.h b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/StreetVehicle.h index 86fdd196d..86e60aabb 100644 --- a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/StreetVehicle.h +++ b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/StreetVehicle.h @@ -9,12 +9,10 @@ #import -@protocol StreetVehicle - +@protocol StreetVehicle - (void)signalStop; - (void)signalLeftTurn; - (void)signalRightTurn; - @end diff --git a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.c b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.c index 71866d9dd..1197a67ed 100644 --- a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.c +++ b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.c @@ -9,12 +9,11 @@ #include "Bicycle.h" - int main() { - Bicycle *bike = [Bicycle alloc]; + Bicycle* bike = [Bicycle alloc]; - [bike signalStop]; + [bike signalStop]; - return 0; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.dot b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.dot index dfcb39bf8..228edb403 100644 --- a/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.dot +++ b/infer/tests/codetoanalyze/objc/errors/protocol_procdesc/main.dot @@ -1,20 +1,20 @@ digraph iCFG { -5 [label="5: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class Bicycle ):unsigned long ) [line 15]\n *&bike:class Bicycle *=n$1 [line 15]\n REMOVE_TEMPS(n$1); [line 15]\n " shape="box"] +5 [label="5: DeclStmt \n n$1=_fun___objc_alloc_no_fail(sizeof(class Bicycle ):unsigned long ) [line 14]\n *&bike:class Bicycle *=n$1 [line 14]\n REMOVE_TEMPS(n$1); [line 14]\n " shape="box"] 5 -> 4 ; -4 [label="4: Message Call: signalStop \n n$0=*&bike:class Bicycle * [line 17]\n _fun_Bicycle_signalStop(n$0:class Bicycle *) virtual [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n NULLIFY(&bike,false); [line 17]\n " shape="box"] +4 [label="4: Message Call: signalStop \n n$0=*&bike:class Bicycle * [line 16]\n _fun_Bicycle_signalStop(n$0:class Bicycle *) virtual [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&bike,false); [line 16]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit main \n " color=yellow style=filled] -1 [label="1: Start main\nFormals: \nLocals: bike:class Bicycle * \n DECLARE_LOCALS(&return,&bike); [line 13]\n NULLIFY(&bike,false); [line 13]\n " color=yellow style=filled] +1 [label="1: Start main\nFormals: \nLocals: bike:class Bicycle * \n DECLARE_LOCALS(&return,&bike); [line 12]\n NULLIFY(&bike,false); [line 12]\n " color=yellow style=filled] 1 -> 5 ; diff --git a/infer/tests/codetoanalyze/objc/errors/resource_leaks/ResourceLeakExample.m b/infer/tests/codetoanalyze/objc/errors/resource_leaks/ResourceLeakExample.m index b02c1c5e5..fdb5a7bbe 100644 --- a/infer/tests/codetoanalyze/objc/errors/resource_leaks/ResourceLeakExample.m +++ b/infer/tests/codetoanalyze/objc/errors/resource_leaks/ResourceLeakExample.m @@ -12,44 +12,38 @@ @implementation NSFileHandle (A) -- (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode { - int fd = -1; - if (path) { - int flags = O_WRONLY | O_APPEND | O_CREAT; - fd = open([path fileSystemRepresentation], flags, mode); - } - if (fd == -1) return nil; - if (self) { - return [[self initWithFileDescriptor:fd - closeOnDealloc:YES] autorelease]; - } - else { - close(fd); - return self; - } +- (id)fileHandleForLoggingAtPath:(NSString*)path mode:(mode_t)mode { + int fd = -1; + if (path) { + int flags = O_WRONLY | O_APPEND | O_CREAT; + fd = open([path fileSystemRepresentation], flags, mode); + } + if (fd == -1) + return nil; + if (self) { + return [[self initWithFileDescriptor:fd closeOnDealloc:YES] autorelease]; + } else { + close(fd); + return self; + } } -- (id)newOutput:(out NSError**)error -{ - int fileDescriptor = open("file.txt", - O_WRONLY | O_CREAT, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - if (fileDescriptor == -1) - { - if (error) - *error = [NSError errorWithDomain:NSPOSIXErrorDomain - code:errno - userInfo:nil]; - return nil; - } +- (id)newOutput:(out NSError**)error { + int fileDescriptor = open( + "file.txt", O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + if (fileDescriptor == -1) { + if (error) + *error = + [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; + return nil; + } else { + if (self) + return [self initWithFileDescriptor:fileDescriptor]; else { - if (self) - return [self initWithFileDescriptor:fileDescriptor]; - else { - close(fileDescriptor); - return nil; - } + close(fileDescriptor); + return nil; } + } } @end diff --git a/infer/tests/codetoanalyze/objc/errors/returnstmt/return_npe_test.m b/infer/tests/codetoanalyze/objc/errors/returnstmt/return_npe_test.m index 773cad680..b20a70f67 100644 --- a/infer/tests/codetoanalyze/objc/errors/returnstmt/return_npe_test.m +++ b/infer/tests/codetoanalyze/objc/errors/returnstmt/return_npe_test.m @@ -10,8 +10,8 @@ #import @interface ContainerClass : NSObject { -@public - int containedValue; + @public + int containedValue; } @end @@ -26,16 +26,16 @@ @implementation MyClass -- (void) aMethod: (ContainerClass*) c { - int i = 0; - if (c == nil) { - return; - } +- (void)aMethod:(ContainerClass*)c { + int i = 0; + if (c == nil) { + return; + } - if(i == 0) { - // here c cannot be nil, because of the previous if - i = c->containedValue; - } + if (i == 0) { + // here c cannot be nil, because of the previous if + i = c->containedValue; + } } @end diff --git a/infer/tests/codetoanalyze/objc/errors/subtyping/KindOfClassExample.m b/infer/tests/codetoanalyze/objc/errors/subtyping/KindOfClassExample.m index 307a23b56..59911d148 100644 --- a/infer/tests/codetoanalyze/objc/errors/subtyping/KindOfClassExample.m +++ b/infer/tests/codetoanalyze/objc/errors/subtyping/KindOfClassExample.m @@ -9,22 +9,20 @@ #import - @interface Base : NSObject -+(int) returnsZero1: (Base*) b; ++ (int)returnsZero1:(Base*)b; @end @implementation Base -+(int) returnsZero1: (Base*) b { - if ([b isKindOfClass:[self class]]) { - return 0; - } - else { - return 1; - } ++ (int)returnsZero1:(Base*)b { + if ([b isKindOfClass:[self class]]) { + return 0; + } else { + return 1; + } } @end @@ -38,30 +36,28 @@ @end int returnsZero2(Base* b) { - if ([b isKindOfClass:[Derived class]]) { - return 1; - } - else { - return 0; - } + if ([b isKindOfClass:[Derived class]]) { + return 1; + } else { + return 0; + } } int shouldThrowDivideByZero1() { - Base* base = [[Base alloc] init]; - return 1/[Base returnsZero1:base]; + Base* base = [[Base alloc] init]; + return 1 / [Base returnsZero1:base]; } int shouldThrowDivideByZero2() { - Base* base = [[Base alloc] init]; - return 1/returnsZero2(base); + Base* base = [[Base alloc] init]; + return 1 / returnsZero2(base); } int shouldThrowDivideByZero3() { - Base* b = [[Derived alloc] init]; - if ([b isKindOfClass:[Derived class]]) { - return 1/0; - } - else { - return 0; - } + Base* b = [[Derived alloc] init]; + if ([b isKindOfClass:[Derived class]]) { + return 1 / 0; + } else { + return 0; + } } diff --git a/infer/tests/codetoanalyze/objc/errors/taint/viewController.m b/infer/tests/codetoanalyze/objc/errors/taint/viewController.m index 8c0c90bfd..4594d80ca 100644 --- a/infer/tests/codetoanalyze/objc/errors/taint/viewController.m +++ b/infer/tests/codetoanalyze/objc/errors/taint/viewController.m @@ -10,70 +10,65 @@ #import #import -BOOL ExampleSanitizer(NSURL * u, int f) -{ - if (f) __set_untaint_attribute(u); - return f; +BOOL ExampleSanitizer(NSURL* u, int f) { + if (f) + __set_untaint_attribute(u); + return f; } @interface ExampleViewController : NSObject -- (void)loadURL:(NSURL *)URL - trackingCodes:(NSArray *)trackingCodes; +- (void)loadURL:(NSURL*)URL trackingCodes:(NSArray*)trackingCodes; @end @implementation ExampleViewController -- (void)loadURL:(NSURL *)URL - trackingCodes: (NSArray *)trackingCodes -{ - // Require untainted URL -}; +- (void)loadURL:(NSURL*)URL + trackingCodes:(NSArray*)trackingCodes{ + // Require untainted URL + }; @end @interface B : NSObject -- (void) another_url_pass: (NSURL *) u; +- (void)another_url_pass:(NSURL*)u; @end @implementation B -- (void) another_url_pass: (NSURL *) u -{ - ExampleViewController *vc = [[ExampleViewController alloc] init]; - [vc loadURL:u trackingCodes:nil]; +- (void)another_url_pass:(NSURL*)u { + ExampleViewController* vc = [[ExampleViewController alloc] init]; + [vc loadURL:u trackingCodes:nil]; } @end @interface A : NSObject -- (void) pass_url_arond:(NSURL *) u; +- (void)pass_url_arond:(NSURL*)u; @end @implementation A -- (void) pass_url_arond: (NSURL *) u -{ - B* b = [[B alloc] init]; - [b another_url_pass:u]; +- (void)pass_url_arond:(NSURL*)u { + B* b = [[B alloc] init]; + [b another_url_pass:u]; } @end @interface ExampleDelegate : NSObject -- (BOOL)application: (UIApplication *)application - openURL: (NSURL *)URL - sourceApplication: (NSString *)sourceApplication - annotation: (id)annotation; +- (BOOL)application:(UIApplication*)application + openURL:(NSURL*)URL + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation; @end @implementation ExampleDelegate -- (BOOL)application: (UIApplication *)application - openURL: (NSURL *)URL - sourceApplication: (NSString *)sourceApplication - annotation: (id)annotation -{ - // Assume tainted URL; - A* a = [[A alloc] init]; - if (!ExampleSanitizer(URL, 0 )) { - [a pass_url_arond:URL]; // report taint - } - if (!ExampleSanitizer(URL, 1 )) { - [a pass_url_arond:URL]; // No taint - } - return YES; +- (BOOL)application:(UIApplication*)application + openURL:(NSURL*)URL + sourceApplication:(NSString*)sourceApplication + annotation:(id)annotation { + // Assume tainted URL; + A* a = [[A alloc] init]; + if (!ExampleSanitizer(URL, 0)) { + [a pass_url_arond:URL]; // report taint + } + if (!ExampleSanitizer(URL, 1)) { + [a pass_url_arond:URL]; // No taint + } + return YES; } @end diff --git a/infer/tests/codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m b/infer/tests/codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m index f2abf1412..152b605cc 100644 --- a/infer/tests/codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m +++ b/infer/tests/codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m @@ -10,27 +10,27 @@ #import @interface A : NSObject { - } @end @implementation A --(void) noProblem { - NSArray *foo = [NSArray arrayWithObjects: @"aaa", @"bbb", nil]; +- (void)noProblem { + NSArray* foo = [NSArray arrayWithObjects:@"aaa", @"bbb", nil]; } --(void) nilInArrayWithObjects { - NSString *str = nil; +- (void)nilInArrayWithObjects { + NSString* str = nil; - // nil argument in arrayWithObjects terminates the list of arguments prematurely - NSArray *foo = [NSArray arrayWithObjects: @"aaa", str, @"bbb", nil]; + // nil argument in arrayWithObjects terminates the list of arguments + // prematurely + NSArray* foo = [NSArray arrayWithObjects:@"aaa", str, @"bbb", nil]; } @end int main() { - A *a = [A alloc]; + A* a = [A alloc]; [a noProblem]; [a nilInArrayWithObjects]; return 0; diff --git a/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.m b/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.m index 4648f19e0..f501a9604 100644 --- a/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.m +++ b/infer/tests/codetoanalyze/objc/frontend/assertions/NSAssert_example.m @@ -16,23 +16,23 @@ @implementation A - (int)addTarget:(A*)target { - NSAssert(target != nil, @"target must not be nil"); - return target.x; + NSAssert(target != nil, @"target must not be nil"); + return target.x; } - (int)initWithRequest:(A*)a { - NSAssert1(a != nil, @"target must not be nil %s", "a"); - return a.x; + NSAssert1(a != nil, @"target must not be nil %s", "a"); + return a.x; } @end int test1(A* target) { - NSCAssert(target != nil, @"target must not be nil"); - return target.x; + NSCAssert(target != nil, @"target must not be nil"); + return target.x; } int test2(A* target) { - NSCParameterAssert(target); - return target.x; + NSCParameterAssert(target); + return target.x; } diff --git a/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.dot b/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.dot index f21e41917..d1fb4ab88 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.dot @@ -30,11 +30,11 @@ digraph iCFG { 12 -> 7 ; -11 [label="11: Return Stmt \n NULLIFY(&p,false); [line 27]\n n$3=*&x:int [line 27]\n *&return:int =n$3 [line 27]\n REMOVE_TEMPS(n$3); [line 27]\n NULLIFY(&__objc_anonymous_block_BlockVar_navigateToURLInBackground______1,true); [line 27]\n NULLIFY(&x,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +11 [label="11: Return Stmt \n NULLIFY(&p,false); [line 29]\n n$3=*&x:int [line 29]\n *&return:int =n$3 [line 29]\n REMOVE_TEMPS(n$3); [line 29]\n NULLIFY(&__objc_anonymous_block_BlockVar_navigateToURLInBackground______1,true); [line 29]\n NULLIFY(&x,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 11 -> 5 ; -10 [label="10: Return Stmt \n NULLIFY(&x,false); [line 26]\n n$1=*&p:int * [line 26]\n n$2=*n$1:int [line 26]\n *&return:int =n$2 [line 26]\n REMOVE_TEMPS(n$1,n$2); [line 26]\n NULLIFY(&__objc_anonymous_block_BlockVar_navigateToURLInBackground______1,true); [line 26]\n NULLIFY(&p,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +10 [label="10: Return Stmt \n NULLIFY(&x,false); [line 27]\n n$1=*&p:int * [line 27]\n n$2=*n$1:int [line 27]\n *&return:int =n$2 [line 27]\n REMOVE_TEMPS(n$1,n$2); [line 27]\n NULLIFY(&__objc_anonymous_block_BlockVar_navigateToURLInBackground______1,true); [line 27]\n NULLIFY(&p,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 10 -> 5 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.m b/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.m index df5dc1a69..d8770d655 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/BlockVar.m @@ -12,18 +12,20 @@ @implementation BlockVar + (int)test { - return 5; + return 5; } + (int)navigateToURLInBackground { - int (^addBlock)(int a, int b) = ^(int a, int b){ - NSError *error = nil; - int res = [self test]; - return a + b + res; - }; - int x = addBlock(1, 2); - int *p = 0; - if (x == 8) return *p; - else return x; + int (^addBlock)(int a, int b) = ^(int a, int b) { + NSError* error = nil; + int res = [self test]; + return a + b + res; + }; + int x = addBlock(1, 2); + int* p = 0; + if (x == 8) + return *p; + else + return x; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block-it.dot b/infer/tests/codetoanalyze/objc/frontend/block/block-it.dot index 9b1c6ab52..248791575 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block-it.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/block-it.dot @@ -1,65 +1,65 @@ digraph iCFG { -52 [label="52: DeclStmt \n n$44=_fun___objc_alloc_no_fail(sizeof(class NSArray ):unsigned long ) [line 38]\n n$45=_fun_NSArray_init(n$44:class NSArray *) virtual [line 38]\n *&a:class NSArray *=n$45 [line 38]\n REMOVE_TEMPS(n$44,n$45); [line 38]\n " shape="box"] +52 [label="52: DeclStmt \n n$44=_fun___objc_alloc_no_fail(sizeof(class NSArray ):unsigned long ) [line 34]\n n$45=_fun_NSArray_init(n$44:class NSArray *) virtual [line 34]\n *&a:class NSArray *=n$45 [line 34]\n REMOVE_TEMPS(n$44,n$45); [line 34]\n " shape="box"] 52 -> 51 ; -51 [label="51: DeclStmt \n n$43=*&a:class NSArray * [line 40]\n *&objects:class NSArray *=n$43 [line 40]\n REMOVE_TEMPS(n$43); [line 40]\n NULLIFY(&a,false); [line 40]\n " shape="box"] +51 [label="51: DeclStmt \n n$43=*&a:class NSArray * [line 36]\n *&objects:class NSArray *=n$43 [line 36]\n REMOVE_TEMPS(n$43); [line 36]\n NULLIFY(&a,false); [line 36]\n " shape="box"] 51 -> 50 ; -50 [label="50: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_MyBlock_array_trans______2); [line 43]\n n$42=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_MyBlock_array_trans______2 ):unsigned long ) [line 43]\n *&__objc_anonymous_block_MyBlock_array_trans______2:class __objc_anonymous_block_MyBlock_array_trans______2 =n$42 [line 43]\n *&enumerateObjectsUsingBlock:_fn_ (*)=(_fun___objc_anonymous_block_MyBlock_array_trans______2) [line 43]\n REMOVE_TEMPS(n$42); [line 43]\n " shape="box"] +50 [label="50: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_MyBlock_array_trans______2); [line 40]\n n$42=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_MyBlock_array_trans______2 ):unsigned long ) [line 40]\n *&__objc_anonymous_block_MyBlock_array_trans______2:class __objc_anonymous_block_MyBlock_array_trans______2 =n$42 [line 40]\n *&enumerateObjectsUsingBlock:_fn_ (*)=(_fun___objc_anonymous_block_MyBlock_array_trans______2) [line 40]\n REMOVE_TEMPS(n$42); [line 40]\n " shape="box"] 50 -> 43 ; -49 [label="49: BinaryOperatorStmt: Assign \n NULLIFY(&ShouldStop,false); [line 48]\n n$41=*&stop:_Bool * [line 48]\n *n$41:_Bool =1 [line 48]\n REMOVE_TEMPS(n$41); [line 48]\n NULLIFY(&stop,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +49 [label="49: BinaryOperatorStmt: Assign \n NULLIFY(&ShouldStop,false); [line 45]\n n$41=*&stop:_Bool * [line 45]\n *n$41:_Bool =1 [line 45]\n REMOVE_TEMPS(n$41); [line 45]\n NULLIFY(&stop,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 49 -> 46 ; -48 [label="48: Prune (false branch) \n n$40=*&ShouldStop:int [line 47]\n PRUNE((n$40 == 0), false); [line 47]\n REMOVE_TEMPS(n$40); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="invhouse"] +48 [label="48: Prune (false branch) \n n$40=*&ShouldStop:int [line 44]\n PRUNE((n$40 == 0), false); [line 44]\n REMOVE_TEMPS(n$40); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="invhouse"] 48 -> 46 ; -47 [label="47: Prune (true branch) \n n$40=*&ShouldStop:int [line 47]\n PRUNE((n$40 != 0), true); [line 47]\n REMOVE_TEMPS(n$40); [line 47]\n " shape="invhouse"] +47 [label="47: Prune (true branch) \n n$40=*&ShouldStop:int [line 44]\n PRUNE((n$40 != 0), true); [line 44]\n REMOVE_TEMPS(n$40); [line 44]\n " shape="invhouse"] 47 -> 49 ; -46 [label="46: + \n NULLIFY(&ShouldStop,false); [line 47]\n NULLIFY(&stop,false); [line 47]\n " ] +46 [label="46: + \n NULLIFY(&ShouldStop,false); [line 44]\n NULLIFY(&stop,false); [line 44]\n " ] 46 -> 45 ; 45 [label="45: Exit __objc_anonymous_block_MyBlock_array_trans______2 \n " color=yellow style=filled] -44 [label="44: Start __objc_anonymous_block_MyBlock_array_trans______2\nFormals: object:struct objc_object * idx:unsigned long stop:_Bool *\nLocals: ShouldStop:int \n DECLARE_LOCALS(&return,&ShouldStop); [line 43]\n NULLIFY(&idx,false); [line 43]\n NULLIFY(&object,false); [line 43]\n " color=yellow style=filled] +44 [label="44: Start __objc_anonymous_block_MyBlock_array_trans______2\nFormals: object:struct objc_object * idx:unsigned long stop:_Bool *\nLocals: ShouldStop:int \n DECLARE_LOCALS(&return,&ShouldStop); [line 40]\n NULLIFY(&idx,false); [line 40]\n NULLIFY(&object,false); [line 40]\n " color=yellow style=filled] 44 -> 47 ; 44 -> 48 ; -43 [label="43: DeclStmt \n n$39=_fun_malloc_no_fail(sizeof(_Bool ):_Bool ) [line 51]\n *&stop:_Bool *=n$39 [line 51]\n REMOVE_TEMPS(n$39); [line 51]\n " shape="box"] +43 [label="43: DeclStmt \n n$39=_fun_malloc_no_fail(sizeof(_Bool ):_Bool ) [line 48]\n *&stop:_Bool *=n$39 [line 48]\n REMOVE_TEMPS(n$39); [line 48]\n " shape="box"] 43 -> 42 ; -42 [label="42: BinaryOperatorStmt: Assign \n n$38=*&stop:_Bool * [line 52]\n *n$38:_Bool =0 [line 52]\n REMOVE_TEMPS(n$38); [line 52]\n " shape="box"] +42 [label="42: BinaryOperatorStmt: Assign \n n$38=*&stop:_Bool * [line 49]\n *n$38:_Bool =0 [line 49]\n REMOVE_TEMPS(n$38); [line 49]\n " shape="box"] 42 -> 31 ; -41 [label="41: DeclStmt \n n$35=*&objects:class NSArray * [line 57]\n n$36=*&idx:unsigned long [line 57]\n n$37=_fun_NSArray_objectAtIndexedSubscript:(n$35:class NSArray *,n$36:unsigned long ) virtual [line 57]\n *&object:struct objc_object *=n$37 [line 57]\n REMOVE_TEMPS(n$35,n$36,n$37); [line 57]\n " shape="box"] +41 [label="41: DeclStmt \n n$35=*&objects:class NSArray * [line 53]\n n$36=*&idx:unsigned long [line 53]\n n$37=_fun_NSArray_objectAtIndexedSubscript:(n$35:class NSArray *,n$36:unsigned long ) virtual [line 53]\n *&object:struct objc_object *=n$37 [line 53]\n REMOVE_TEMPS(n$35,n$36,n$37); [line 53]\n " shape="box"] 41 -> 40 ; -40 [label="40: Call n$31 \n n$31=*&enumerateObjectsUsingBlock:_fn_ (*) [line 58]\n n$32=*&object:struct objc_object * [line 58]\n n$33=*&idx:unsigned long [line 58]\n n$34=*&stop:_Bool * [line 58]\n n$31(n$32:struct objc_object *,n$33:unsigned long ,n$34:_Bool *) [line 58]\n REMOVE_TEMPS(n$31,n$32,n$33,n$34); [line 58]\n NULLIFY(&object,false); [line 58]\n " shape="box"] +40 [label="40: Call n$31 \n n$31=*&enumerateObjectsUsingBlock:_fn_ (*) [line 54]\n n$32=*&object:struct objc_object * [line 54]\n n$33=*&idx:unsigned long [line 54]\n n$34=*&stop:_Bool * [line 54]\n n$31(n$32:struct objc_object *,n$33:unsigned long ,n$34:_Bool *) [line 54]\n REMOVE_TEMPS(n$31,n$32,n$33,n$34); [line 54]\n NULLIFY(&object,false); [line 54]\n " shape="box"] 40 -> 37 ; -39 [label="39: Prune (false branch) \n PRUNE(((n$30 == 1) == 0), false); [line 59]\n REMOVE_TEMPS(n$29,n$30); [line 59]\n " shape="invhouse"] +39 [label="39: Prune (false branch) \n PRUNE(((n$30 == 1) == 0), false); [line 55]\n REMOVE_TEMPS(n$29,n$30); [line 55]\n " shape="invhouse"] 39 -> 36 ; -38 [label="38: Prune (true branch) \n PRUNE(((n$30 == 1) != 0), true); [line 59]\n REMOVE_TEMPS(n$29,n$30); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="invhouse"] +38 [label="38: Prune (true branch) \n PRUNE(((n$30 == 1) != 0), true); [line 55]\n REMOVE_TEMPS(n$29,n$30); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="invhouse"] 38 -> 29 ; -37 [label="37: BinaryOperatorStmt: EQ \n n$29=*&stop:_Bool * [line 59]\n n$30=*n$29:_Bool [line 59]\n " shape="box"] +37 [label="37: BinaryOperatorStmt: EQ \n n$29=*&stop:_Bool * [line 55]\n n$30=*n$29:_Bool [line 55]\n " shape="box"] 37 -> 38 ; @@ -68,24 +68,24 @@ digraph iCFG { 36 -> 32 ; -35 [label="35: Prune (false branch) \n PRUNE(((n$26 < n$28) == 0), false); [line 54]\n REMOVE_TEMPS(n$26,n$27,n$28); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="invhouse"] +35 [label="35: Prune (false branch) \n PRUNE(((n$26 < n$28) == 0), false); [line 51]\n REMOVE_TEMPS(n$26,n$27,n$28); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="invhouse"] 35 -> 29 ; -34 [label="34: Prune (true branch) \n PRUNE(((n$26 < n$28) != 0), true); [line 54]\n REMOVE_TEMPS(n$26,n$27,n$28); [line 54]\n " shape="invhouse"] +34 [label="34: Prune (true branch) \n PRUNE(((n$26 < n$28) != 0), true); [line 51]\n REMOVE_TEMPS(n$26,n$27,n$28); [line 51]\n " shape="invhouse"] 34 -> 41 ; -33 [label="33: BinaryOperatorStmt: LT \n n$26=*&idx:unsigned long [line 54]\n n$27=*&objects:class NSArray * [line 54]\n n$28=_fun_NSArray_count(n$27:class NSArray *) [line 54]\n " shape="box"] +33 [label="33: BinaryOperatorStmt: LT \n n$26=*&idx:unsigned long [line 51]\n n$27=*&objects:class NSArray * [line 51]\n n$28=_fun_NSArray_count(n$27:class NSArray *) [line 51]\n " shape="box"] 33 -> 34 ; 33 -> 35 ; -32 [label="32: UnaryOperator \n n$25=*&idx:unsigned long [line 54]\n *&idx:unsigned long =(n$25 + 1) [line 54]\n REMOVE_TEMPS(n$25); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +32 [label="32: UnaryOperator \n n$25=*&idx:unsigned long [line 51]\n *&idx:unsigned long =(n$25 + 1) [line 51]\n REMOVE_TEMPS(n$25); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 32 -> 30 ; -31 [label="31: DeclStmt \n *&idx:unsigned long =0 [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +31 [label="31: DeclStmt \n *&idx:unsigned long =0 [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] 31 -> 30 ; @@ -93,78 +93,78 @@ digraph iCFG { 30 -> 33 ; -29 [label="29: Call _fun_free \n NULLIFY(&enumerateObjectsUsingBlock,false); [line 61]\n NULLIFY(&idx,false); [line 61]\n NULLIFY(&objects,false); [line 61]\n n$24=*&stop:_Bool * [line 61]\n _fun_free(n$24:void *) [line 61]\n REMOVE_TEMPS(n$24); [line 61]\n NULLIFY(&__objc_anonymous_block_MyBlock_array_trans______2,true); [line 61]\n NULLIFY(&stop,false); [line 61]\n APPLY_ABSTRACTION; [line 61]\n " shape="box"] +29 [label="29: Call _fun_free \n NULLIFY(&enumerateObjectsUsingBlock,false); [line 58]\n NULLIFY(&idx,false); [line 58]\n NULLIFY(&objects,false); [line 58]\n n$24=*&stop:_Bool * [line 58]\n _fun_free(n$24:void *) [line 58]\n REMOVE_TEMPS(n$24); [line 58]\n NULLIFY(&__objc_anonymous_block_MyBlock_array_trans______2,true); [line 58]\n NULLIFY(&stop,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 29 -> 28 ; 28 [label="28: Exit MyBlock_array_trans \n " color=yellow style=filled] -27 [label="27: Start MyBlock_array_trans\nFormals: self:class MyBlock *\nLocals: idx:unsigned long object:struct objc_object * stop:_Bool * enumerateObjectsUsingBlock:_fn_ (*) objects:class NSArray * a:class NSArray * \n DECLARE_LOCALS(&return,&idx,&object,&stop,&enumerateObjectsUsingBlock,&objects,&a); [line 36]\n NULLIFY(&a,false); [line 36]\n NULLIFY(&enumerateObjectsUsingBlock,false); [line 36]\n NULLIFY(&idx,false); [line 36]\n NULLIFY(&object,false); [line 36]\n NULLIFY(&objects,false); [line 36]\n NULLIFY(&self,false); [line 36]\n NULLIFY(&stop,false); [line 36]\n " color=yellow style=filled] +27 [label="27: Start MyBlock_array_trans\nFormals: self:class MyBlock *\nLocals: idx:unsigned long object:struct objc_object * stop:_Bool * enumerateObjectsUsingBlock:_fn_ (*) objects:class NSArray * a:class NSArray * \n DECLARE_LOCALS(&return,&idx,&object,&stop,&enumerateObjectsUsingBlock,&objects,&a); [line 32]\n NULLIFY(&a,false); [line 32]\n NULLIFY(&enumerateObjectsUsingBlock,false); [line 32]\n NULLIFY(&idx,false); [line 32]\n NULLIFY(&object,false); [line 32]\n NULLIFY(&objects,false); [line 32]\n NULLIFY(&self,false); [line 32]\n NULLIFY(&stop,false); [line 32]\n " color=yellow style=filled] 27 -> 52 ; -26 [label="26: DeclStmt \n n$22=_fun___objc_alloc_no_fail(sizeof(class NSArray ):unsigned long ) [line 22]\n n$23=_fun_NSArray_init(n$22:class NSArray *) virtual [line 22]\n *&a:class NSArray *=n$23 [line 22]\n REMOVE_TEMPS(n$22,n$23); [line 22]\n " shape="box"] +26 [label="26: DeclStmt \n n$22=_fun___objc_alloc_no_fail(sizeof(class NSArray ):unsigned long ) [line 20]\n n$23=_fun_NSArray_init(n$22:class NSArray *) virtual [line 20]\n *&a:class NSArray *=n$23 [line 20]\n REMOVE_TEMPS(n$22,n$23); [line 20]\n " shape="box"] 26 -> 25 ; -25 [label="25: DeclStmt \n n$21=*&a:class NSArray * [line 23]\n *&objects:class NSArray *=n$21 [line 23]\n REMOVE_TEMPS(n$21); [line 23]\n NULLIFY(&a,false); [line 23]\n " shape="box"] +25 [label="25: DeclStmt \n n$21=*&a:class NSArray * [line 21]\n *&objects:class NSArray *=n$21 [line 21]\n REMOVE_TEMPS(n$21); [line 21]\n NULLIFY(&a,false); [line 21]\n " shape="box"] 25 -> 24 ; -24 [label="24: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_MyBlock_array______1); [line 23]\n n$20=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_MyBlock_array______1 ):unsigned long ) [line 23]\n *&__objc_anonymous_block_MyBlock_array______1:class __objc_anonymous_block_MyBlock_array______1 =n$20 [line 23]\n *&infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*)=(_fun___objc_anonymous_block_MyBlock_array______1) [line 23]\n REMOVE_TEMPS(n$20); [line 23]\n " shape="box"] +24 [label="24: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_MyBlock_array______1); [line 21]\n n$20=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_MyBlock_array______1 ):unsigned long ) [line 21]\n *&__objc_anonymous_block_MyBlock_array______1:class __objc_anonymous_block_MyBlock_array______1 =n$20 [line 21]\n *&infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*)=(_fun___objc_anonymous_block_MyBlock_array______1) [line 21]\n REMOVE_TEMPS(n$20); [line 21]\n " shape="box"] 24 -> 17 ; -23 [label="23: BinaryOperatorStmt: Assign \n NULLIFY(&ShouldStop,false); [line 30]\n n$19=*&stop:_Bool * [line 30]\n *n$19:_Bool =1 [line 30]\n REMOVE_TEMPS(n$19); [line 30]\n NULLIFY(&stop,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +23 [label="23: BinaryOperatorStmt: Assign \n NULLIFY(&ShouldStop,false); [line 27]\n n$19=*&stop:_Bool * [line 27]\n *n$19:_Bool =1 [line 27]\n REMOVE_TEMPS(n$19); [line 27]\n NULLIFY(&stop,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 23 -> 20 ; -22 [label="22: Prune (false branch) \n n$18=*&ShouldStop:int [line 28]\n PRUNE((n$18 == 0), false); [line 28]\n REMOVE_TEMPS(n$18); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="invhouse"] +22 [label="22: Prune (false branch) \n n$18=*&ShouldStop:int [line 26]\n PRUNE((n$18 == 0), false); [line 26]\n REMOVE_TEMPS(n$18); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="invhouse"] 22 -> 20 ; -21 [label="21: Prune (true branch) \n n$18=*&ShouldStop:int [line 28]\n PRUNE((n$18 != 0), true); [line 28]\n REMOVE_TEMPS(n$18); [line 28]\n " shape="invhouse"] +21 [label="21: Prune (true branch) \n n$18=*&ShouldStop:int [line 26]\n PRUNE((n$18 != 0), true); [line 26]\n REMOVE_TEMPS(n$18); [line 26]\n " shape="invhouse"] 21 -> 23 ; -20 [label="20: + \n NULLIFY(&ShouldStop,false); [line 28]\n NULLIFY(&stop,false); [line 28]\n " ] +20 [label="20: + \n NULLIFY(&ShouldStop,false); [line 26]\n NULLIFY(&stop,false); [line 26]\n " ] 20 -> 19 ; 19 [label="19: Exit __objc_anonymous_block_MyBlock_array______1 \n " color=yellow style=filled] -18 [label="18: Start __objc_anonymous_block_MyBlock_array______1\nFormals: object:struct objc_object * idx:unsigned long stop:_Bool *\nLocals: ShouldStop:int \n DECLARE_LOCALS(&return,&ShouldStop); [line 23]\n NULLIFY(&idx,false); [line 23]\n NULLIFY(&object,false); [line 23]\n " color=yellow style=filled] +18 [label="18: Start __objc_anonymous_block_MyBlock_array______1\nFormals: object:struct objc_object * idx:unsigned long stop:_Bool *\nLocals: ShouldStop:int \n DECLARE_LOCALS(&return,&ShouldStop); [line 21]\n NULLIFY(&idx,false); [line 21]\n NULLIFY(&object,false); [line 21]\n " color=yellow style=filled] 18 -> 21 ; 18 -> 22 ; -17 [label="17: DeclStmt \n n$17=_fun_malloc_no_fail(sizeof(signed char ):signed char ) [line 23]\n *&stop:_Bool *=n$17 [line 23]\n REMOVE_TEMPS(n$17); [line 23]\n " shape="box"] +17 [label="17: DeclStmt \n n$17=_fun_malloc_no_fail(sizeof(signed char ):signed char ) [line 21]\n *&stop:_Bool *=n$17 [line 21]\n REMOVE_TEMPS(n$17); [line 21]\n " shape="box"] 17 -> 16 ; -16 [label="16: BinaryOperatorStmt: Assign \n n$16=*&stop:_Bool * [line 23]\n *n$16:void =0 [line 23]\n REMOVE_TEMPS(n$16); [line 23]\n " shape="box"] +16 [label="16: BinaryOperatorStmt: Assign \n n$16=*&stop:_Bool * [line 21]\n *n$16:void =0 [line 21]\n REMOVE_TEMPS(n$16); [line 21]\n " shape="box"] 16 -> 5 ; -15 [label="15: DeclStmt \n n$13=*&objects:class NSArray * [line 23]\n n$14=*&idx:unsigned long [line 23]\n n$15=_fun_NSArray_objectAtIndexedSubscript:(n$13:class NSArray *,n$14:unsigned long ) virtual [line 23]\n *&object:struct objc_object *=n$15 [line 23]\n REMOVE_TEMPS(n$13,n$14,n$15); [line 23]\n NULLIFY(&object,false); [line 23]\n " shape="box"] +15 [label="15: DeclStmt \n n$13=*&objects:class NSArray * [line 21]\n n$14=*&idx:unsigned long [line 21]\n n$15=_fun_NSArray_objectAtIndexedSubscript:(n$13:class NSArray *,n$14:unsigned long ) virtual [line 21]\n *&object:struct objc_object *=n$15 [line 21]\n REMOVE_TEMPS(n$13,n$14,n$15); [line 21]\n NULLIFY(&object,false); [line 21]\n " shape="box"] 15 -> 14 ; -14 [label="14: Call n$8 \n n$8=*&infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*) [line 23]\n n$9=*&object:struct objc_object * [line 23]\n n$10=*&idx:unsigned long [line 23]\n n$11=*&stop:_Bool * [line 23]\n n$12=n$8(n$9:struct objc_object *,n$10:unsigned long ,n$11:_Bool *) [line 23]\n REMOVE_TEMPS(n$8,n$9,n$10,n$11,n$12); [line 23]\n " shape="box"] +14 [label="14: Call n$8 \n n$8=*&infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*) [line 21]\n n$9=*&object:struct objc_object * [line 21]\n n$10=*&idx:unsigned long [line 21]\n n$11=*&stop:_Bool * [line 21]\n n$12=n$8(n$9:struct objc_object *,n$10:unsigned long ,n$11:_Bool *) [line 21]\n REMOVE_TEMPS(n$8,n$9,n$10,n$11,n$12); [line 21]\n " shape="box"] 14 -> 11 ; -13 [label="13: Prune (false branch) \n n$7=*n$6:signed char [line 23]\n PRUNE((n$7 == 0), false); [line 23]\n REMOVE_TEMPS(n$6,n$7); [line 23]\n " shape="invhouse"] +13 [label="13: Prune (false branch) \n n$7=*n$6:signed char [line 21]\n PRUNE((n$7 == 0), false); [line 21]\n REMOVE_TEMPS(n$6,n$7); [line 21]\n " shape="invhouse"] 13 -> 10 ; -12 [label="12: Prune (true branch) \n n$7=*n$6:signed char [line 23]\n PRUNE((n$7 != 0), true); [line 23]\n REMOVE_TEMPS(n$6,n$7); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="invhouse"] +12 [label="12: Prune (true branch) \n n$7=*n$6:signed char [line 21]\n PRUNE((n$7 != 0), true); [line 21]\n REMOVE_TEMPS(n$6,n$7); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="invhouse"] 12 -> 3 ; -11 [label="11: UnaryOperator \n n$6=*&stop:_Bool * [line 23]\n " shape="box"] +11 [label="11: UnaryOperator \n n$6=*&stop:_Bool * [line 21]\n " shape="box"] 11 -> 12 ; @@ -173,24 +173,24 @@ digraph iCFG { 10 -> 6 ; -9 [label="9: Prune (false branch) \n PRUNE(((n$3 < n$5) == 0), false); [line 23]\n REMOVE_TEMPS(n$3,n$4,n$5); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="invhouse"] +9 [label="9: Prune (false branch) \n PRUNE(((n$3 < n$5) == 0), false); [line 21]\n REMOVE_TEMPS(n$3,n$4,n$5); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="invhouse"] 9 -> 3 ; -8 [label="8: Prune (true branch) \n PRUNE(((n$3 < n$5) != 0), true); [line 23]\n REMOVE_TEMPS(n$3,n$4,n$5); [line 23]\n " shape="invhouse"] +8 [label="8: Prune (true branch) \n PRUNE(((n$3 < n$5) != 0), true); [line 21]\n REMOVE_TEMPS(n$3,n$4,n$5); [line 21]\n " shape="invhouse"] 8 -> 15 ; -7 [label="7: BinaryOperatorStmt: LT \n n$3=*&idx:unsigned long [line 23]\n n$4=*&objects:class NSArray * [line 23]\n n$5=_fun_NSArray_count(n$4:class NSArray *) virtual [line 23]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: LT \n n$3=*&idx:unsigned long [line 21]\n n$4=*&objects:class NSArray * [line 21]\n n$5=_fun_NSArray_count(n$4:class NSArray *) virtual [line 21]\n " shape="box"] 7 -> 8 ; 7 -> 9 ; -6 [label="6: UnaryOperator \n n$2=*&idx:unsigned long [line 23]\n *&idx:unsigned long =(n$2 + 1) [line 23]\n REMOVE_TEMPS(n$2); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +6 [label="6: UnaryOperator \n n$2=*&idx:unsigned long [line 21]\n *&idx:unsigned long =(n$2 + 1) [line 21]\n REMOVE_TEMPS(n$2); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 6 -> 4 ; -5 [label="5: DeclStmt \n *&idx:unsigned long =0 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +5 [label="5: DeclStmt \n *&idx:unsigned long =0 [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 5 -> 4 ; @@ -198,14 +198,14 @@ digraph iCFG { 4 -> 7 ; -3 [label="3: Call _fun_free \n NULLIFY(&idx,false); [line 23]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 23]\n NULLIFY(&objects,false); [line 23]\n n$0=*&stop:_Bool * [line 23]\n n$1=_fun_free(n$0:void *) [line 23]\n NULLIFY(&object,true); [line 23]\n NULLIFY(&idx,true); [line 23]\n NULLIFY(&stop,true); [line 23]\n NULLIFY(&objects,true); [line 23]\n REMOVE_TEMPS(n$0,n$1); [line 23]\n NULLIFY(&__objc_anonymous_block_MyBlock_array______1,true); [line 23]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,true); [line 23]\n NULLIFY(&idx,false); [line 23]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 23]\n NULLIFY(&objects,false); [line 23]\n NULLIFY(&stop,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +3 [label="3: Call _fun_free \n NULLIFY(&idx,false); [line 21]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 21]\n NULLIFY(&objects,false); [line 21]\n n$0=*&stop:_Bool * [line 21]\n n$1=_fun_free(n$0:void *) [line 21]\n NULLIFY(&object,true); [line 21]\n NULLIFY(&idx,true); [line 21]\n NULLIFY(&stop,true); [line 21]\n NULLIFY(&objects,true); [line 21]\n REMOVE_TEMPS(n$0,n$1); [line 21]\n NULLIFY(&__objc_anonymous_block_MyBlock_array______1,true); [line 21]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,true); [line 21]\n NULLIFY(&idx,false); [line 21]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 21]\n NULLIFY(&objects,false); [line 21]\n NULLIFY(&stop,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit MyBlock_array \n " color=yellow style=filled] -1 [label="1: Start MyBlock_array\nFormals: self:class MyBlock *\nLocals: idx:unsigned long object:struct objc_object * stop:_Bool * infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*) objects:class NSArray * a:class NSArray * \n DECLARE_LOCALS(&return,&idx,&object,&stop,&infer___objc_anonymous_block_MyBlock_array______1,&objects,&a); [line 20]\n NULLIFY(&a,false); [line 20]\n NULLIFY(&idx,false); [line 20]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 20]\n NULLIFY(&object,false); [line 20]\n NULLIFY(&objects,false); [line 20]\n NULLIFY(&self,false); [line 20]\n NULLIFY(&stop,false); [line 20]\n " color=yellow style=filled] +1 [label="1: Start MyBlock_array\nFormals: self:class MyBlock *\nLocals: idx:unsigned long object:struct objc_object * stop:_Bool * infer___objc_anonymous_block_MyBlock_array______1:_fn_ (*) objects:class NSArray * a:class NSArray * \n DECLARE_LOCALS(&return,&idx,&object,&stop,&infer___objc_anonymous_block_MyBlock_array______1,&objects,&a); [line 18]\n NULLIFY(&a,false); [line 18]\n NULLIFY(&idx,false); [line 18]\n NULLIFY(&infer___objc_anonymous_block_MyBlock_array______1,false); [line 18]\n NULLIFY(&object,false); [line 18]\n NULLIFY(&objects,false); [line 18]\n NULLIFY(&self,false); [line 18]\n NULLIFY(&stop,false); [line 18]\n " color=yellow style=filled] 1 -> 26 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block-it.m b/infer/tests/codetoanalyze/objc/frontend/block/block-it.m index 2242b3ed6..a00753ba9 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block-it.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/block-it.m @@ -15,51 +15,47 @@ @implementation MyBlock - - --(void) array { - - NSArray *a = [[NSArray alloc] init]; - [a enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) { - int ShouldStop; - /* - ... do something here... - */ - if (ShouldStop - ) { - *stop= YES; - }; - }]; +- (void)array { + + NSArray* a = [[NSArray alloc] init]; + [a enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL* stop) { + int ShouldStop; + /* + ... do something here... + */ + if (ShouldStop) { + *stop = YES; + }; + }]; } +- (void)array_trans { --(void) array_trans { + NSArray* a = [[NSArray alloc] init]; -NSArray *a = [[NSArray alloc] init]; + NSArray* objects = a; - NSArray *objects = a; - - // The call to the iterator in the above function is translated as: - void (^enumerateObjectsUsingBlock)(id, NSUInteger, BOOL *)= ^(id object, NSUInteger idx, BOOL* stop) { + // The call to the iterator in the above function is translated as: + void (^enumerateObjectsUsingBlock)(id, NSUInteger, BOOL*) = + ^(id object, NSUInteger idx, BOOL* stop) { int ShouldStop; if (ShouldStop) { - *stop= YES; + *stop = YES; }; - }; - BOOL *stop = malloc(sizeof(BOOL)); - *stop = NO; - - for (NSUInteger idx=0; idx 24 ; 24 [label="24: Exit main \n " color=yellow style=filled] -23 [label="23: Start main\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 50]\n " color=yellow style=filled] +23 [label="23: Start main\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 46]\n " color=yellow style=filled] 23 -> 25 ; @@ -18,72 +18,72 @@ digraph iCFG { 21 -> 20 ; -20 [label="20: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_main1______2); [line 19]\n n$27=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_main1______2 ):unsigned long ) [line 19]\n *&__objc_anonymous_block_main1______2:class __objc_anonymous_block_main1______2 =n$27 [line 19]\n n$28=*&x:int [line 19]\n *n$27.x:int =n$28 [line 19]\n n$11=*&x:int [line 19]\n *&addblock:_fn_ (*)=(_fun___objc_anonymous_block_main1______2,n$11) [line 19]\n REMOVE_TEMPS(n$27,n$28,n$11); [line 19]\n " shape="box"] +20 [label="20: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_main1______2); [line 18]\n n$27=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_main1______2 ):unsigned long ) [line 18]\n *&__objc_anonymous_block_main1______2:class __objc_anonymous_block_main1______2 =n$27 [line 18]\n n$28=*&x:int [line 18]\n *n$27.x:int =n$28 [line 18]\n n$11=*&x:int [line 18]\n *&addblock:_fn_ (*)=(_fun___objc_anonymous_block_main1______2,n$11) [line 18]\n REMOVE_TEMPS(n$27,n$28,n$11); [line 18]\n " shape="box"] 20 -> 10 ; -19 [label="19: DeclStmt \n *&bla:int =3 [line 23]\n " shape="box"] +19 [label="19: DeclStmt \n *&bla:int =3 [line 22]\n " shape="box"] 19 -> 18 ; -18 [label="18: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block___objc_anonymous_block_main1______2______3); [line 25]\n n$23=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block___objc_anonymous_block_main1______2______3 ):unsigned long ) [line 25]\n *&__objc_anonymous_block___objc_anonymous_block_main1______2______3:class __objc_anonymous_block___objc_anonymous_block_main1______2______3 =n$23 [line 25]\n n$24=*&x:int [line 25]\n n$25=*&bla:int [line 25]\n n$26=*&#GB$main1_s:int [line 25]\n *n$23.bla:int =n$24 [line 25]\n *n$23.main1_s:int =n$25 [line 25]\n *n$23.x:int =n$26 [line 25]\n n$17=*&x:int [line 25]\n n$18=*&bla:int [line 25]\n *&addblock2:_fn_ (*)=(_fun___objc_anonymous_block___objc_anonymous_block_main1______2______3,n$17,n$18) [line 25]\n REMOVE_TEMPS(n$23,n$24,n$25,n$26,n$17,n$18); [line 25]\n " shape="box"] +18 [label="18: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block___objc_anonymous_block_main1______2______3); [line 24]\n n$23=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block___objc_anonymous_block_main1______2______3 ):unsigned long ) [line 24]\n *&__objc_anonymous_block___objc_anonymous_block_main1______2______3:class __objc_anonymous_block___objc_anonymous_block_main1______2______3 =n$23 [line 24]\n n$24=*&x:int [line 24]\n n$25=*&bla:int [line 24]\n n$26=*&#GB$main1_s:int [line 24]\n *n$23.bla:int =n$24 [line 24]\n *n$23.main1_s:int =n$25 [line 24]\n *n$23.x:int =n$26 [line 24]\n n$17=*&x:int [line 24]\n n$18=*&bla:int [line 24]\n *&addblock2:_fn_ (*)=(_fun___objc_anonymous_block___objc_anonymous_block_main1______2______3,n$17,n$18) [line 24]\n REMOVE_TEMPS(n$23,n$24,n$25,n$26,n$17,n$18); [line 24]\n " shape="box"] 18 -> 14 ; -17 [label="17: Return Stmt \n n$19=*&z:int [line 26]\n n$20=*&#GB$main1_s:int [line 26]\n n$21=*&x:int [line 26]\n n$22=*&bla:int [line 26]\n *&return:int =(((n$19 + n$20) + n$21) + n$22) [line 26]\n REMOVE_TEMPS(n$19,n$20,n$21,n$22); [line 26]\n NULLIFY(&z,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +17 [label="17: Return Stmt \n n$19=*&z:int [line 25]\n n$20=*&#GB$main1_s:int [line 25]\n n$21=*&x:int [line 25]\n n$22=*&bla:int [line 25]\n *&return:int =(((n$19 + n$20) + n$21) + n$22) [line 25]\n REMOVE_TEMPS(n$19,n$20,n$21,n$22); [line 25]\n NULLIFY(&z,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit __objc_anonymous_block___objc_anonymous_block_main1______2______3 \n " color=yellow style=filled] -15 [label="15: Start __objc_anonymous_block___objc_anonymous_block_main1______2______3\nFormals: x:int bla:int z:int \nLocals: \nCaptured: x:int bla:int \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +15 [label="15: Start __objc_anonymous_block___objc_anonymous_block_main1______2______3\nFormals: x:int bla:int z:int \nLocals: \nCaptured: x:int bla:int \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 15 -> 17 ; -14 [label="14: BinaryOperatorStmt: Assign \n n$15=*&addblock2:_fn_ (*) [line 29]\n n$16=n$15(1:int ) [line 29]\n *&add2:int =n$16 [line 29]\n REMOVE_TEMPS(n$15,n$16); [line 29]\n NULLIFY(&addblock2,false); [line 29]\n " shape="box"] +14 [label="14: BinaryOperatorStmt: Assign \n n$15=*&addblock2:_fn_ (*) [line 28]\n n$16=n$15(1:int ) [line 28]\n *&add2:int =n$16 [line 28]\n REMOVE_TEMPS(n$15,n$16); [line 28]\n NULLIFY(&addblock2,false); [line 28]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$12=*&c:int [line 30]\n n$13=*&add2:int [line 30]\n n$14=*&bla:int [line 30]\n *&return:int =((n$12 + n$13) + n$14) [line 30]\n REMOVE_TEMPS(n$12,n$13,n$14); [line 30]\n NULLIFY(&__objc_anonymous_block___objc_anonymous_block_main1______2______3,true); [line 30]\n NULLIFY(&add2,false); [line 30]\n NULLIFY(&c,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +13 [label="13: Return Stmt \n n$12=*&c:int [line 29]\n n$13=*&add2:int [line 29]\n n$14=*&bla:int [line 29]\n *&return:int =((n$12 + n$13) + n$14) [line 29]\n REMOVE_TEMPS(n$12,n$13,n$14); [line 29]\n NULLIFY(&__objc_anonymous_block___objc_anonymous_block_main1______2______3,true); [line 29]\n NULLIFY(&add2,false); [line 29]\n NULLIFY(&c,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit __objc_anonymous_block_main1______2 \n " color=yellow style=filled] -11 [label="11: Start __objc_anonymous_block_main1______2\nFormals: x:int c:int d:int \nLocals: bla:int add2:int addblock2:_fn_ (*)\nCaptured: x:int \n DECLARE_LOCALS(&return,&bla,&add2,&addblock2); [line 19]\n NULLIFY(&add2,false); [line 19]\n NULLIFY(&addblock2,false); [line 19]\n NULLIFY(&d,false); [line 19]\n " color=yellow style=filled] +11 [label="11: Start __objc_anonymous_block_main1______2\nFormals: x:int c:int d:int \nLocals: bla:int add2:int addblock2:_fn_ (*)\nCaptured: x:int \n DECLARE_LOCALS(&return,&bla,&add2,&addblock2); [line 18]\n NULLIFY(&add2,false); [line 18]\n NULLIFY(&addblock2,false); [line 18]\n NULLIFY(&d,false); [line 18]\n " color=yellow style=filled] 11 -> 19 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$9=*&addblock:_fn_ (*) [line 33]\n n$10=n$9(1:int ,2:int ) [line 33]\n *&add1:int =n$10 [line 33]\n REMOVE_TEMPS(n$9,n$10); [line 33]\n NULLIFY(&addblock,false); [line 33]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n n$9=*&addblock:_fn_ (*) [line 32]\n n$10=n$9(1:int ,2:int ) [line 32]\n *&add1:int =n$10 [line 32]\n REMOVE_TEMPS(n$9,n$10); [line 32]\n NULLIFY(&addblock,false); [line 32]\n " shape="box"] 10 -> 9 ; -9 [label="9: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_main1______1); [line 36]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_main1______1 ):unsigned long ) [line 36]\n *&__objc_anonymous_block_main1______1:class __objc_anonymous_block_main1______1 =n$7 [line 36]\n n$8=*&#GB$main1_s:int [line 36]\n *n$7.main1_s:int =n$8 [line 36]\n *&addblock:_fn_ (*)=(_fun___objc_anonymous_block_main1______1) [line 36]\n REMOVE_TEMPS(n$7,n$8); [line 36]\n " shape="box"] +9 [label="9: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_main1______1); [line 34]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_main1______1 ):unsigned long ) [line 34]\n *&__objc_anonymous_block_main1______1:class __objc_anonymous_block_main1______1 =n$7 [line 34]\n n$8=*&#GB$main1_s:int [line 34]\n *n$7.main1_s:int =n$8 [line 34]\n *&addblock:_fn_ (*)=(_fun___objc_anonymous_block_main1______1) [line 34]\n REMOVE_TEMPS(n$7,n$8); [line 34]\n " shape="box"] 9 -> 5 ; -8 [label="8: Return Stmt \n n$5=*&e:int [line 37]\n n$6=*&#GB$main1_s:int [line 37]\n *&return:int =(n$5 - n$6) [line 37]\n REMOVE_TEMPS(n$5,n$6); [line 37]\n NULLIFY(&e,false); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +8 [label="8: Return Stmt \n n$5=*&e:int [line 35]\n n$6=*&#GB$main1_s:int [line 35]\n *&return:int =(n$5 - n$6) [line 35]\n REMOVE_TEMPS(n$5,n$6); [line 35]\n NULLIFY(&e,false); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 8 -> 7 ; 7 [label="7: Exit __objc_anonymous_block_main1______1 \n " color=yellow style=filled] -6 [label="6: Start __objc_anonymous_block_main1______1\nFormals: e:int f:int \nLocals: \n DECLARE_LOCALS(&return); [line 36]\n NULLIFY(&f,false); [line 36]\n " color=yellow style=filled] +6 [label="6: Start __objc_anonymous_block_main1______1\nFormals: e:int f:int \nLocals: \n DECLARE_LOCALS(&return); [line 34]\n NULLIFY(&f,false); [line 34]\n " color=yellow style=filled] 6 -> 8 ; -5 [label="5: BinaryOperatorStmt: Assign \n n$3=*&addblock:_fn_ (*) [line 41]\n n$4=n$3(3:int ,2:int ) [line 41]\n *&add2:int =n$4 [line 41]\n REMOVE_TEMPS(n$3,n$4); [line 41]\n NULLIFY(&addblock,false); [line 41]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: Assign \n n$3=*&addblock:_fn_ (*) [line 38]\n n$4=n$3(3:int ,2:int ) [line 38]\n *&add2:int =n$4 [line 38]\n REMOVE_TEMPS(n$3,n$4); [line 38]\n NULLIFY(&addblock,false); [line 38]\n " shape="box"] 5 -> 4 ; -4 [label="4: BinaryOperatorStmt: Assign \n n$1=*&add1:int [line 44]\n n$2=*&add2:int [line 44]\n *&y:int =(n$1 / n$2) [line 44]\n REMOVE_TEMPS(n$1,n$2); [line 44]\n NULLIFY(&add1,false); [line 44]\n NULLIFY(&add2,false); [line 44]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: Assign \n n$1=*&add1:int [line 41]\n n$2=*&add2:int [line 41]\n *&y:int =(n$1 / n$2) [line 41]\n REMOVE_TEMPS(n$1,n$2); [line 41]\n NULLIFY(&add1,false); [line 41]\n NULLIFY(&add2,false); [line 41]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&y:int [line 46]\n *&return:int =n$0 [line 46]\n REMOVE_TEMPS(n$0); [line 46]\n NULLIFY(&__objc_anonymous_block_main1______1,true); [line 46]\n NULLIFY(&__objc_anonymous_block_main1______2,true); [line 46]\n NULLIFY(&y,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&y:int [line 43]\n *&return:int =n$0 [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&__objc_anonymous_block_main1______1,true); [line 43]\n NULLIFY(&__objc_anonymous_block_main1______2,true); [line 43]\n NULLIFY(&y,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block.m b/infer/tests/codetoanalyze/objc/frontend/block/block.m index 84f67ad79..907d11c1f 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/block.m @@ -7,46 +7,40 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main1 (int y) { +int main1(int y) { - static int s = 3; - int x =7; + static int s = 3; + int x = 7; - int add1, add2; - int (^addblock)(int a, int b); + int add1, add2; + int (^addblock)(int a, int b); + addblock = ^(int c, int d) { - addblock=^(int c,int d){ + int (^addblock2)(int a); + int add2; + int bla = 3; - int (^addblock2)(int a); - int add2; - int bla =3; - - addblock2=^(int z){ - return z+s+x+bla; - }; - - add2 = addblock2(1); - return c+add2+bla; + addblock2 = ^(int z) { + return z + s + x + bla; }; - add1 = addblock(1,2); - + add2 = addblock2(1); + return c + add2 + bla; + }; - addblock=^(int e,int f){ - return e-s; - }; + add1 = addblock(1, 2); + addblock = ^(int e, int f) { + return e - s; + }; - add2 = addblock(3,2); + add2 = addblock(3, 2); - // Here we should get a division by zero - y=add1/add2; + // Here we should get a division by zero + y = add1 / add2; - return y; + return y; } - -int main () { - return main1(4); -} +int main() { return main1(4); } diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.dot b/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.dot index fce6fe554..80ef3a163 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.dot @@ -1,36 +1,36 @@ digraph iCFG { -16 [label="16: BinaryOperatorStmt: Assign \n *&#GB$g:int =7 [line 23]\n " shape="box"] +16 [label="16: BinaryOperatorStmt: Assign \n *&#GB$g:int =7 [line 22]\n " shape="box"] 16 -> 15 ; -15 [label="15: DeclStmt \n *&z:int =3 [line 25]\n " shape="box"] +15 [label="15: DeclStmt \n *&z:int =3 [line 24]\n " shape="box"] 15 -> 14 ; -14 [label="14: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_My_manager_m______1); [line 26]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_My_manager_m______1 ):unsigned long ) [line 26]\n *&__objc_anonymous_block_My_manager_m______1:class __objc_anonymous_block_My_manager_m______1 =n$7 [line 26]\n n$8=*&z:int [line 26]\n n$9=*&#GB$g:int [line 26]\n *n$7.g:int =n$8 [line 26]\n *n$7.z:int =n$9 [line 26]\n n$5=*&z:int [line 26]\n *&b:_fn_ (*)=(_fun___objc_anonymous_block_My_manager_m______1,n$5) [line 26]\n REMOVE_TEMPS(n$7,n$8,n$9,n$5); [line 26]\n " shape="box"] +14 [label="14: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_My_manager_m______1); [line 25]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_My_manager_m______1 ):unsigned long ) [line 25]\n *&__objc_anonymous_block_My_manager_m______1:class __objc_anonymous_block_My_manager_m______1 =n$7 [line 25]\n n$8=*&z:int [line 25]\n n$9=*&#GB$g:int [line 25]\n *n$7.g:int =n$8 [line 25]\n *n$7.z:int =n$9 [line 25]\n n$5=*&z:int [line 25]\n *&b:_fn_ (*)=(_fun___objc_anonymous_block_My_manager_m______1,n$5) [line 25]\n REMOVE_TEMPS(n$7,n$8,n$9,n$5); [line 25]\n " shape="box"] 14 -> 10 ; -13 [label="13: BinaryOperatorStmt: Assign \n n$6=*&z:int [line 27]\n *&#GB$g:int =(n$6 + 3) [line 27]\n REMOVE_TEMPS(n$6); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +13 [label="13: BinaryOperatorStmt: Assign \n n$6=*&z:int [line 26]\n *&#GB$g:int =(n$6 + 3) [line 26]\n REMOVE_TEMPS(n$6); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit __objc_anonymous_block_My_manager_m______1 \n " color=yellow style=filled] -11 [label="11: Start __objc_anonymous_block_My_manager_m______1\nFormals: z:int \nLocals: \nCaptured: z:int \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] +11 [label="11: Start __objc_anonymous_block_My_manager_m______1\nFormals: z:int \nLocals: \nCaptured: z:int \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 11 -> 13 ; -10 [label="10: Call n$4 \n n$4=*&b:_fn_ (*) [line 29]\n n$4() [line 29]\n REMOVE_TEMPS(n$4); [line 29]\n NULLIFY(&b,false); [line 29]\n " shape="box"] +10 [label="10: Call n$4 \n n$4=*&b:_fn_ (*) [line 28]\n n$4() [line 28]\n REMOVE_TEMPS(n$4); [line 28]\n NULLIFY(&b,false); [line 28]\n " shape="box"] 10 -> 9 ; -9 [label="9: DeclStmt \n *&p:int *=0 [line 30]\n " shape="box"] +9 [label="9: DeclStmt \n *&p:int *=0 [line 29]\n " shape="box"] 9 -> 4 ; -8 [label="8: Return Stmt \n NULLIFY(&p,false); [line 32]\n n$3=*&z:int [line 32]\n *&return:int =n$3 [line 32]\n REMOVE_TEMPS(n$3); [line 32]\n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +8 [label="8: Return Stmt \n NULLIFY(&p,false); [line 33]\n n$3=*&z:int [line 33]\n *&return:int =n$3 [line 33]\n REMOVE_TEMPS(n$3); [line 33]\n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] 8 -> 2 ; @@ -38,20 +38,20 @@ digraph iCFG { 7 -> 2 ; -6 [label="6: Prune (false branch) \n PRUNE(((n$0 == 6) == 0), false); [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n " shape="invhouse"] +6 [label="6: Prune (false branch) \n PRUNE(((n$0 == 6) == 0), false); [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n " shape="invhouse"] 6 -> 8 ; -5 [label="5: Prune (true branch) \n PRUNE(((n$0 == 6) != 0), true); [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n " shape="invhouse"] +5 [label="5: Prune (true branch) \n PRUNE(((n$0 == 6) != 0), true); [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n " shape="invhouse"] 5 -> 7 ; -4 [label="4: BinaryOperatorStmt: EQ \n n$0=*&#GB$g:int [line 31]\n " shape="box"] +4 [label="4: BinaryOperatorStmt: EQ \n n$0=*&#GB$g:int [line 30]\n " shape="box"] 4 -> 5 ; 4 -> 6 ; -3 [label="3: + \n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 31]\n NULLIFY(&b,false); [line 31]\n NULLIFY(&p,false); [line 31]\n NULLIFY(&self,false); [line 31]\n " ] +3 [label="3: + \n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 30]\n NULLIFY(&b,false); [line 30]\n NULLIFY(&p,false); [line 30]\n NULLIFY(&self,false); [line 30]\n " ] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.m b/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.m index af8ac8afa..9586a2a33 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/block_no_args.m @@ -11,24 +11,25 @@ int g; -@interface My_manager :NSObject -- (int) m; +@interface My_manager : NSObject +- (int)m; @end @implementation My_manager -- (int) m -{ - g = 7; - void (^b)(); - int z = 3; - b = ^( ){ - g = z + 3; - }; - b(); - int *p = 0; - if (g == 6) return *p; - else return z; +- (int)m { + g = 7; + void (^b)(); + int z = 3; + b = ^() { + g = z + 3; + }; + b(); + int* p = 0; + if (g == 6) + return *p; + else + return z; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block_release.dot b/infer/tests/codetoanalyze/objc/frontend/block/block_release.dot index 48111ac53..dae1249c2 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block_release.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/block_release.dot @@ -1,17 +1,17 @@ digraph iCFG { -18 [label="18: DeclStmt \n *&z:int =3 [line 23]\n " shape="box"] +18 [label="18: DeclStmt \n *&z:int =3 [line 22]\n " shape="box"] 18 -> 17 ; -17 [label="17: DeclStmt \n n$12=_fun_CGBitmapContextCreate(0:void *,0:unsigned long ,0:unsigned long ,8:unsigned long ,0:unsigned long ,0:struct CGColorSpace *,0:unsigned int ) [line 24]\n *&context:struct CGContext *=n$12 [line 24]\n REMOVE_TEMPS(n$12); [line 24]\n " shape="box"] +17 [label="17: DeclStmt \n n$12=_fun_CGBitmapContextCreate(0:void *,0:unsigned long ,0:unsigned long ,8:unsigned long ,0:unsigned long ,0:struct CGColorSpace *,0:unsigned int ) [line 23]\n *&context:struct CGContext *=n$12 [line 23]\n REMOVE_TEMPS(n$12); [line 23]\n " shape="box"] 17 -> 16 ; -16 [label="16: DeclStmt \n n$10=*&context:struct CGContext * [line 25]\n n$11=_fun_CGBitmapContextCreateImage(n$10:struct CGContext *) [line 25]\n *&newImage:struct CGImage *=n$11 [line 25]\n REMOVE_TEMPS(n$10,n$11); [line 25]\n " shape="box"] +16 [label="16: DeclStmt \n n$10=*&context:struct CGContext * [line 24]\n n$11=_fun_CGBitmapContextCreateImage(n$10:struct CGContext *) [line 24]\n *&newImage:struct CGImage *=n$11 [line 24]\n REMOVE_TEMPS(n$10,n$11); [line 24]\n " shape="box"] 16 -> 15 ; -15 [label="15: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_My_manager_m______1); [line 26]\n n$8=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_My_manager_m______1 ):unsigned long ) [line 26]\n *&__objc_anonymous_block_My_manager_m______1:class __objc_anonymous_block_My_manager_m______1 =n$8 [line 26]\n n$9=*&newImage:struct CGImage * [line 26]\n *n$8.newImage:struct CGImage *=n$9 [line 26]\n n$5=*&newImage:struct CGImage * [line 26]\n *&b:_fn_ (*)=(_fun___objc_anonymous_block_My_manager_m______1,n$5) [line 26]\n REMOVE_TEMPS(n$8,n$9,n$5); [line 26]\n " shape="box"] +15 [label="15: BinaryOperatorStmt: Assign \n DECLARE_LOCALS(&__objc_anonymous_block_My_manager_m______1); [line 25]\n n$8=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_My_manager_m______1 ):unsigned long ) [line 25]\n *&__objc_anonymous_block_My_manager_m______1:class __objc_anonymous_block_My_manager_m______1 =n$8 [line 25]\n n$9=*&newImage:struct CGImage * [line 25]\n *n$8.newImage:struct CGImage *=n$9 [line 25]\n n$5=*&newImage:struct CGImage * [line 25]\n *&b:_fn_ (*)=(_fun___objc_anonymous_block_My_manager_m______1,n$5) [line 25]\n REMOVE_TEMPS(n$8,n$9,n$5); [line 25]\n " shape="box"] 15 -> 8 ; @@ -19,11 +19,11 @@ digraph iCFG { 14 -> 11 ; -13 [label="13: Prune (false branch) \n n$6=*&newImage:struct CGImage * [line 27]\n PRUNE((n$6 == 0), false); [line 27]\n REMOVE_TEMPS(n$6); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="invhouse"] +13 [label="13: Prune (false branch) \n n$6=*&newImage:struct CGImage * [line 26]\n PRUNE((n$6 == 0), false); [line 26]\n REMOVE_TEMPS(n$6); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="invhouse"] 13 -> 11 ; -12 [label="12: Prune (true branch) \n n$6=*&newImage:struct CGImage * [line 27]\n PRUNE((n$6 != 0), true); [line 27]\n REMOVE_TEMPS(n$6); [line 27]\n " shape="invhouse"] +12 [label="12: Prune (true branch) \n n$6=*&newImage:struct CGImage * [line 26]\n PRUNE((n$6 != 0), true); [line 26]\n REMOVE_TEMPS(n$6); [line 26]\n " shape="invhouse"] 12 -> 14 ; @@ -34,7 +34,7 @@ digraph iCFG { 10 [label="10: Exit __objc_anonymous_block_My_manager_m______1 \n " color=yellow style=filled] -9 [label="9: Start __objc_anonymous_block_My_manager_m______1\nFormals: newImage:struct CGImage * a:int \nLocals: \nCaptured: newImage:struct CGImage * \n DECLARE_LOCALS(&return); [line 26]\n NULLIFY(&a,false); [line 26]\n " color=yellow style=filled] +9 [label="9: Start __objc_anonymous_block_My_manager_m______1\nFormals: newImage:struct CGImage * a:int \nLocals: \nCaptured: newImage:struct CGImage * \n DECLARE_LOCALS(&return); [line 25]\n NULLIFY(&a,false); [line 25]\n " color=yellow style=filled] 9 -> 12 ; @@ -44,7 +44,7 @@ digraph iCFG { 8 -> 5 ; 8 -> 6 ; -7 [label="7: Call _fun_CGContextRelease \n n$2=*&context:struct CGContext * [line 30]\n _fun_CGContextRelease(n$2:struct CGContext *) [line 30]\n REMOVE_TEMPS(n$2); [line 30]\n NULLIFY(&context,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +7 [label="7: Call _fun_CGContextRelease \n n$2=*&context:struct CGContext * [line 31]\n _fun_CGContextRelease(n$2:struct CGContext *) [line 31]\n REMOVE_TEMPS(n$2); [line 31]\n NULLIFY(&context,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 7 -> 4 ; @@ -60,7 +60,7 @@ digraph iCFG { 4 -> 3 ; -3 [label="3: Return Stmt \n NULLIFY(&context,false); [line 31]\n n$0=*&z:int [line 31]\n *&return:int =n$0 [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 31]\n NULLIFY(&z,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] +3 [label="3: Return Stmt \n NULLIFY(&context,false); [line 32]\n n$0=*&z:int [line 32]\n *&return:int =n$0 [line 32]\n REMOVE_TEMPS(n$0); [line 32]\n NULLIFY(&__objc_anonymous_block_My_manager_m______1,true); [line 32]\n NULLIFY(&z,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/block_release.m b/infer/tests/codetoanalyze/objc/frontend/block/block_release.m index b56d451de..fac89f398 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/block_release.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/block_release.m @@ -10,27 +10,26 @@ #import #import -@interface My_manager :NSObject -- (int) my_mehtod; +@interface My_manager : NSObject +- (int)my_mehtod; @end @implementation My_manager -- (int) m -{ - void (^b)(int a); - int z = 3; - CGContextRef context = CGBitmapContextCreate(NULL, 0, 0, 8, 0, 0, 0); - CGImageRef newImage = CGBitmapContextCreateImage(context); - b = ^(int a) { - if (newImage) CGImageRelease(newImage); - }; - b(z); - if (context) CGContextRelease(context); - return z; +- (int)m { + void (^b)(int a); + int z = 3; + CGContextRef context = CGBitmapContextCreate(NULL, 0, 0, 8, 0, 0, 0); + CGImageRef newImage = CGBitmapContextCreateImage(context); + b = ^(int a) { + if (newImage) + CGImageRelease(newImage); + }; + b(z); + if (context) + CGContextRelease(context); + return z; } - - @end diff --git a/infer/tests/codetoanalyze/objc/frontend/block/dispatch.dot b/infer/tests/codetoanalyze/objc/frontend/block/dispatch.dot index d1928e548..5535ea56a 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/dispatch.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/dispatch.dot @@ -1,9 +1,9 @@ digraph iCFG { -26 [label="26: DeclStmt \n n$3=_fun_A_sharedInstance() [line 45]\n *&b:class A *=n$3 [line 45]\n REMOVE_TEMPS(n$3); [line 45]\n " shape="box"] +26 [label="26: DeclStmt \n n$3=_fun_A_sharedInstance() [line 43]\n *&b:class A *=n$3 [line 43]\n REMOVE_TEMPS(n$3); [line 43]\n " shape="box"] 26 -> 25 ; -25 [label="25: DeclStmt \n *&p:int *=0 [line 46]\n " shape="box"] +25 [label="25: DeclStmt \n *&p:int *=0 [line 44]\n " shape="box"] 25 -> 20 ; @@ -11,84 +11,84 @@ digraph iCFG { 24 -> 18 ; -23 [label="23: Return Stmt \n n$1=*&p:int * [line 47]\n n$2=*n$1:int [line 47]\n *&return:int =n$2 [line 47]\n REMOVE_TEMPS(n$1,n$2); [line 47]\n NULLIFY(&p,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +23 [label="23: Return Stmt \n n$1=*&p:int * [line 46]\n n$2=*n$1:int [line 46]\n *&return:int =n$2 [line 46]\n REMOVE_TEMPS(n$1,n$2); [line 46]\n NULLIFY(&p,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] 23 -> 18 ; -22 [label="22: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 47]\n REMOVE_TEMPS(n$0); [line 47]\n " shape="invhouse"] +22 [label="22: Prune (false branch) \n PRUNE(((n$0 == 0) == 0), false); [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n " shape="invhouse"] 22 -> 24 ; -21 [label="21: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 47]\n REMOVE_TEMPS(n$0); [line 47]\n " shape="invhouse"] +21 [label="21: Prune (true branch) \n PRUNE(((n$0 == 0) != 0), true); [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n " shape="invhouse"] 21 -> 23 ; -20 [label="20: BinaryOperatorStmt: EQ \n n$0=*&b:class A * [line 47]\n NULLIFY(&b,false); [line 47]\n " shape="box"] +20 [label="20: BinaryOperatorStmt: EQ \n n$0=*&b:class A * [line 45]\n NULLIFY(&b,false); [line 45]\n " shape="box"] 20 -> 21 ; 20 -> 22 ; -19 [label="19: + \n NULLIFY(&b,false); [line 47]\n NULLIFY(&p,false); [line 47]\n " ] +19 [label="19: + \n NULLIFY(&b,false); [line 45]\n NULLIFY(&p,false); [line 45]\n " ] 19 -> 18 ; 18 [label="18: Exit main \n " color=yellow style=filled] -17 [label="17: Start main\nFormals: \nLocals: p:int * b:class A * \n DECLARE_LOCALS(&return,&p,&b); [line 44]\n NULLIFY(&b,false); [line 44]\n NULLIFY(&p,false); [line 44]\n " color=yellow style=filled] +17 [label="17: Start main\nFormals: \nLocals: p:int * b:class A * \n DECLARE_LOCALS(&return,&p,&b); [line 42]\n NULLIFY(&b,false); [line 42]\n NULLIFY(&p,false); [line 42]\n " color=yellow style=filled] 17 -> 26 ; -16 [label="16: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_trans______2); [line 36]\n n$11=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_trans______2 ):unsigned long ) [line 36]\n *&__objc_anonymous_block_A_trans______2:class __objc_anonymous_block_A_trans______2 =n$11 [line 36]\n n$12=*&#GB$A_trans_sharedInstance:struct objc_object * [line 36]\n *n$11.A_trans_sharedInstance:struct objc_object *=n$12 [line 36]\n *&dummy_block:_fn_ (*)=(_fun___objc_anonymous_block_A_trans______2) [line 36]\n REMOVE_TEMPS(n$11,n$12); [line 36]\n " shape="box"] +16 [label="16: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_trans______2); [line 34]\n n$11=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_trans______2 ):unsigned long ) [line 34]\n *&__objc_anonymous_block_A_trans______2:class __objc_anonymous_block_A_trans______2 =n$11 [line 34]\n n$12=*&#GB$A_trans_sharedInstance:struct objc_object * [line 34]\n *n$11.A_trans_sharedInstance:struct objc_object *=n$12 [line 34]\n *&dummy_block:_fn_ (*)=(_fun___objc_anonymous_block_A_trans______2) [line 34]\n REMOVE_TEMPS(n$11,n$12); [line 34]\n " shape="box"] 16 -> 12 ; -15 [label="15: BinaryOperatorStmt: Assign \n n$9=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 37]\n n$10=_fun_A_init(n$9:class A *) virtual [line 37]\n *&#GB$A_trans_sharedInstance:struct objc_object *=n$10 [line 37]\n REMOVE_TEMPS(n$9,n$10); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +15 [label="15: BinaryOperatorStmt: Assign \n n$9=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 35]\n n$10=_fun_A_init(n$9:class A *) virtual [line 35]\n *&#GB$A_trans_sharedInstance:struct objc_object *=n$10 [line 35]\n REMOVE_TEMPS(n$9,n$10); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit __objc_anonymous_block_A_trans______2 \n " color=yellow style=filled] -13 [label="13: Start __objc_anonymous_block_A_trans______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 36]\n " color=yellow style=filled] +13 [label="13: Start __objc_anonymous_block_A_trans______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 34]\n " color=yellow style=filled] 13 -> 15 ; -12 [label="12: Call n$8 \n n$8=*&dummy_block:_fn_ (*) [line 39]\n n$8() [line 39]\n REMOVE_TEMPS(n$8); [line 39]\n NULLIFY(&dummy_block,false); [line 39]\n " shape="box"] +12 [label="12: Call n$8 \n n$8=*&dummy_block:_fn_ (*) [line 37]\n n$8() [line 37]\n REMOVE_TEMPS(n$8); [line 37]\n NULLIFY(&dummy_block,false); [line 37]\n " shape="box"] 12 -> 11 ; -11 [label="11: Return Stmt \n n$7=*&#GB$A_trans_sharedInstance:struct objc_object * [line 40]\n *&return:struct objc_object *=n$7 [line 40]\n REMOVE_TEMPS(n$7); [line 40]\n NULLIFY(&__objc_anonymous_block_A_trans______2,true); [line 40]\n APPLY_ABSTRACTION; [line 40]\n " shape="box"] +11 [label="11: Return Stmt \n n$7=*&#GB$A_trans_sharedInstance:struct objc_object * [line 38]\n *&return:struct objc_object *=n$7 [line 38]\n REMOVE_TEMPS(n$7); [line 38]\n NULLIFY(&__objc_anonymous_block_A_trans______2,true); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] 11 -> 10 ; 10 [label="10: Exit A_trans \n " color=yellow style=filled] -9 [label="9: Start A_trans\nFormals: \nLocals: dummy_block:_fn_ (*) \n DECLARE_LOCALS(&return,&dummy_block); [line 33]\n NULLIFY(&dummy_block,false); [line 33]\n " color=yellow style=filled] +9 [label="9: Start A_trans\nFormals: \nLocals: dummy_block:_fn_ (*) \n DECLARE_LOCALS(&return,&dummy_block); [line 32]\n NULLIFY(&dummy_block,false); [line 32]\n " color=yellow style=filled] 9 -> 16 ; -8 [label="8: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_sharedInstance______1); [line 27]\n n$5=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_sharedInstance______1 ):unsigned long ) [line 27]\n *&__objc_anonymous_block_A_sharedInstance______1:class __objc_anonymous_block_A_sharedInstance______1 =n$5 [line 27]\n n$6=*&#GB$A_sharedInstance_sharedInstance:struct objc_object * [line 27]\n *n$5.A_sharedInstance_sharedInstance:struct objc_object *=n$6 [line 27]\n *&infer___objc_anonymous_block_A_sharedInstance______1:_fn_ (*)=(_fun___objc_anonymous_block_A_sharedInstance______1) [line 27]\n REMOVE_TEMPS(n$5,n$6); [line 27]\n " shape="box"] +8 [label="8: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_sharedInstance______1); [line 26]\n n$5=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_sharedInstance______1 ):unsigned long ) [line 26]\n *&__objc_anonymous_block_A_sharedInstance______1:class __objc_anonymous_block_A_sharedInstance______1 =n$5 [line 26]\n n$6=*&#GB$A_sharedInstance_sharedInstance:struct objc_object * [line 26]\n *n$5.A_sharedInstance_sharedInstance:struct objc_object *=n$6 [line 26]\n *&infer___objc_anonymous_block_A_sharedInstance______1:_fn_ (*)=(_fun___objc_anonymous_block_A_sharedInstance______1) [line 26]\n REMOVE_TEMPS(n$5,n$6); [line 26]\n " shape="box"] 8 -> 4 ; -7 [label="7: BinaryOperatorStmt: Assign \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 28]\n n$4=_fun_A_init(n$3:class A *) virtual [line 28]\n *&#GB$A_sharedInstance_sharedInstance:struct objc_object *=n$4 [line 28]\n REMOVE_TEMPS(n$3,n$4); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 27]\n n$4=_fun_A_init(n$3:class A *) virtual [line 27]\n *&#GB$A_sharedInstance_sharedInstance:struct objc_object *=n$4 [line 27]\n REMOVE_TEMPS(n$3,n$4); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 7 -> 6 ; 6 [label="6: Exit __objc_anonymous_block_A_sharedInstance______1 \n " color=yellow style=filled] -5 [label="5: Start __objc_anonymous_block_A_sharedInstance______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 27]\n " color=yellow style=filled] +5 [label="5: Start __objc_anonymous_block_A_sharedInstance______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 26]\n " color=yellow style=filled] 5 -> 7 ; -4 [label="4: Call n$1 \n n$1=*&infer___objc_anonymous_block_A_sharedInstance______1:_fn_ (*) [line 27]\n n$2=n$1() [line 27]\n REMOVE_TEMPS(n$1,n$2); [line 27]\n NULLIFY(&infer___objc_anonymous_block_A_sharedInstance______1,false); [line 27]\n " shape="box"] +4 [label="4: Call n$1 \n n$1=*&infer___objc_anonymous_block_A_sharedInstance______1:_fn_ (*) [line 26]\n n$2=n$1() [line 26]\n REMOVE_TEMPS(n$1,n$2); [line 26]\n NULLIFY(&infer___objc_anonymous_block_A_sharedInstance______1,false); [line 26]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&#GB$A_sharedInstance_sharedInstance:struct objc_object * [line 30]\n *&return:struct objc_object *=n$0 [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n NULLIFY(&__objc_anonymous_block_A_sharedInstance______1,true); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$A_sharedInstance_sharedInstance:struct objc_object * [line 29]\n *&return:struct objc_object *=n$0 [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n NULLIFY(&__objc_anonymous_block_A_sharedInstance______1,true); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/dispatch.m b/infer/tests/codetoanalyze/objc/frontend/block/dispatch.m index 77273e337..6579c1593 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/dispatch.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/dispatch.m @@ -20,30 +20,30 @@ @implementation A { } -+ (instancetype)sharedInstance -{ - static dispatch_once_t once; - static id sharedInstance; - dispatch_once(&once, ^{ - sharedInstance = [[self alloc] init]; - }); - return sharedInstance; ++ (instancetype)sharedInstance { + static dispatch_once_t once; + static id sharedInstance; + dispatch_once(&once, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; } -+ (instancetype)trans -{ - static id sharedInstance; - void (^dummy_block)() = ^{ - sharedInstance = [[self alloc] init]; - }; - dummy_block(); - return sharedInstance; ++ (instancetype)trans { + static id sharedInstance; + void (^dummy_block)() = ^{ + sharedInstance = [[self alloc] init]; + }; + dummy_block(); + return sharedInstance; } @end -int main () { - A *b = [A sharedInstance]; - int *p = 0; - if (b == 0) return *p; - else return 0; +int main() { + A* b = [A sharedInstance]; + int* p = 0; + if (b == 0) + return *p; + else + return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.dot b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.dot index 27be0d0a6..5f638b1e5 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.dot @@ -1,191 +1,191 @@ digraph iCFG { -60 [label="60: DeclStmt \n *&#GB$A_dispatch_barrier_example_a:class A *=0 [line 69]\n " shape="box"] +60 [label="60: DeclStmt \n *&#GB$A_dispatch_barrier_example_a:class A *=0 [line 72]\n " shape="box"] 60 -> 59 ; -59 [label="59: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_barrier_example______6); [line 70]\n n$52=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_barrier_example______6 ):unsigned long ) [line 70]\n *&__objc_anonymous_block_A_dispatch_barrier_example______6:class __objc_anonymous_block_A_dispatch_barrier_example______6 =n$52 [line 70]\n n$53=*&#GB$A_dispatch_barrier_example_a:class A * [line 70]\n *n$52.A_dispatch_barrier_example_a:class A *=n$53 [line 70]\n *&infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_barrier_example______6) [line 70]\n REMOVE_TEMPS(n$52,n$53); [line 70]\n " shape="box"] +59 [label="59: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_barrier_example______6); [line 73]\n n$52=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_barrier_example______6 ):unsigned long ) [line 73]\n *&__objc_anonymous_block_A_dispatch_barrier_example______6:class __objc_anonymous_block_A_dispatch_barrier_example______6 =n$52 [line 73]\n n$53=*&#GB$A_dispatch_barrier_example_a:class A * [line 73]\n *n$52.A_dispatch_barrier_example_a:class A *=n$53 [line 73]\n *&infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_barrier_example______6) [line 73]\n REMOVE_TEMPS(n$52,n$53); [line 73]\n " shape="box"] 59 -> 54 ; -58 [label="58: BinaryOperatorStmt: Assign \n n$50=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 71]\n n$51=_fun_NSObject_init(n$50:class A *) virtual [line 71]\n *&#GB$A_dispatch_barrier_example_a:class A *=n$51 [line 71]\n REMOVE_TEMPS(n$50,n$51); [line 71]\n " shape="box"] +58 [label="58: BinaryOperatorStmt: Assign \n n$50=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 74]\n n$51=_fun_NSObject_init(n$50:class A *) virtual [line 74]\n *&#GB$A_dispatch_barrier_example_a:class A *=n$51 [line 74]\n REMOVE_TEMPS(n$50,n$51); [line 74]\n " shape="box"] 58 -> 57 ; -57 [label="57: BinaryOperatorStmt: Assign \n n$49=*&#GB$A_dispatch_barrier_example_a:class A * [line 72]\n *n$49.x:int =10 [line 72]\n REMOVE_TEMPS(n$49); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="box"] +57 [label="57: BinaryOperatorStmt: Assign \n n$49=*&#GB$A_dispatch_barrier_example_a:class A * [line 75]\n *n$49.x:int =10 [line 75]\n REMOVE_TEMPS(n$49); [line 75]\n APPLY_ABSTRACTION; [line 75]\n " shape="box"] 57 -> 56 ; 56 [label="56: Exit __objc_anonymous_block_A_dispatch_barrier_example______6 \n " color=yellow style=filled] -55 [label="55: Start __objc_anonymous_block_A_dispatch_barrier_example______6\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 70]\n " color=yellow style=filled] +55 [label="55: Start __objc_anonymous_block_A_dispatch_barrier_example______6\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 73]\n " color=yellow style=filled] 55 -> 58 ; -54 [label="54: Call n$47 \n n$47=*&infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*) [line 70]\n n$48=n$47() [line 70]\n REMOVE_TEMPS(n$47,n$48); [line 70]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_barrier_example______6,false); [line 70]\n " shape="box"] +54 [label="54: Call n$47 \n n$47=*&infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*) [line 73]\n n$48=n$47() [line 73]\n REMOVE_TEMPS(n$47,n$48); [line 73]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_barrier_example______6,false); [line 73]\n " shape="box"] 54 -> 53 ; -53 [label="53: Return Stmt \n n$45=*&#GB$A_dispatch_barrier_example_a:class A * [line 74]\n n$46=*n$45.x:int [line 74]\n *&return:int =n$46 [line 74]\n REMOVE_TEMPS(n$45,n$46); [line 74]\n NULLIFY(&__objc_anonymous_block_A_dispatch_barrier_example______6,true); [line 74]\n APPLY_ABSTRACTION; [line 74]\n " shape="box"] +53 [label="53: Return Stmt \n n$45=*&#GB$A_dispatch_barrier_example_a:class A * [line 77]\n n$46=*n$45.x:int [line 77]\n *&return:int =n$46 [line 77]\n REMOVE_TEMPS(n$45,n$46); [line 77]\n NULLIFY(&__objc_anonymous_block_A_dispatch_barrier_example______6,true); [line 77]\n APPLY_ABSTRACTION; [line 77]\n " shape="box"] 53 -> 52 ; 52 [label="52: Exit A_dispatch_barrier_example \n " color=yellow style=filled] -51 [label="51: Start A_dispatch_barrier_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_barrier_example______6); [line 68]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_barrier_example______6,false); [line 68]\n " color=yellow style=filled] +51 [label="51: Start A_dispatch_barrier_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_barrier_example______6:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_barrier_example______6); [line 71]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_barrier_example______6,false); [line 71]\n " color=yellow style=filled] 51 -> 60 ; -50 [label="50: DeclStmt \n *&#GB$A_dispatch_group_notify_example_a:class A *=0 [line 60]\n " shape="box"] +50 [label="50: DeclStmt \n *&#GB$A_dispatch_group_notify_example_a:class A *=0 [line 63]\n " shape="box"] 50 -> 49 ; -49 [label="49: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_group_notify_example______5); [line 61]\n n$43=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_group_notify_example______5 ):unsigned long ) [line 61]\n *&__objc_anonymous_block_A_dispatch_group_notify_example______5:class __objc_anonymous_block_A_dispatch_group_notify_example______5 =n$43 [line 61]\n n$44=*&#GB$A_dispatch_group_notify_example_a:class A * [line 61]\n *n$43.A_dispatch_group_notify_example_a:class A *=n$44 [line 61]\n *&infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_group_notify_example______5) [line 61]\n REMOVE_TEMPS(n$43,n$44); [line 61]\n " shape="box"] +49 [label="49: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_group_notify_example______5); [line 64]\n n$43=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_group_notify_example______5 ):unsigned long ) [line 64]\n *&__objc_anonymous_block_A_dispatch_group_notify_example______5:class __objc_anonymous_block_A_dispatch_group_notify_example______5 =n$43 [line 64]\n n$44=*&#GB$A_dispatch_group_notify_example_a:class A * [line 64]\n *n$43.A_dispatch_group_notify_example_a:class A *=n$44 [line 64]\n *&infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_group_notify_example______5) [line 64]\n REMOVE_TEMPS(n$43,n$44); [line 64]\n " shape="box"] 49 -> 44 ; -48 [label="48: BinaryOperatorStmt: Assign \n n$41=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 62]\n n$42=_fun_NSObject_init(n$41:class A *) virtual [line 62]\n *&#GB$A_dispatch_group_notify_example_a:class A *=n$42 [line 62]\n REMOVE_TEMPS(n$41,n$42); [line 62]\n " shape="box"] +48 [label="48: BinaryOperatorStmt: Assign \n n$41=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 65]\n n$42=_fun_NSObject_init(n$41:class A *) virtual [line 65]\n *&#GB$A_dispatch_group_notify_example_a:class A *=n$42 [line 65]\n REMOVE_TEMPS(n$41,n$42); [line 65]\n " shape="box"] 48 -> 47 ; -47 [label="47: BinaryOperatorStmt: Assign \n n$40=*&#GB$A_dispatch_group_notify_example_a:class A * [line 63]\n *n$40.x:int =10 [line 63]\n REMOVE_TEMPS(n$40); [line 63]\n APPLY_ABSTRACTION; [line 63]\n " shape="box"] +47 [label="47: BinaryOperatorStmt: Assign \n n$40=*&#GB$A_dispatch_group_notify_example_a:class A * [line 66]\n *n$40.x:int =10 [line 66]\n REMOVE_TEMPS(n$40); [line 66]\n APPLY_ABSTRACTION; [line 66]\n " shape="box"] 47 -> 46 ; 46 [label="46: Exit __objc_anonymous_block_A_dispatch_group_notify_example______5 \n " color=yellow style=filled] -45 [label="45: Start __objc_anonymous_block_A_dispatch_group_notify_example______5\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 61]\n " color=yellow style=filled] +45 [label="45: Start __objc_anonymous_block_A_dispatch_group_notify_example______5\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 64]\n " color=yellow style=filled] 45 -> 48 ; -44 [label="44: Call n$38 \n n$38=*&infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*) [line 61]\n n$39=n$38() [line 61]\n REMOVE_TEMPS(n$38,n$39); [line 61]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_notify_example______5,false); [line 61]\n " shape="box"] +44 [label="44: Call n$38 \n n$38=*&infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*) [line 64]\n n$39=n$38() [line 64]\n REMOVE_TEMPS(n$38,n$39); [line 64]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_notify_example______5,false); [line 64]\n " shape="box"] 44 -> 43 ; -43 [label="43: Return Stmt \n n$36=*&#GB$A_dispatch_group_notify_example_a:class A * [line 65]\n n$37=*n$36.x:int [line 65]\n *&return:int =n$37 [line 65]\n REMOVE_TEMPS(n$36,n$37); [line 65]\n NULLIFY(&__objc_anonymous_block_A_dispatch_group_notify_example______5,true); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"] +43 [label="43: Return Stmt \n n$36=*&#GB$A_dispatch_group_notify_example_a:class A * [line 68]\n n$37=*n$36.x:int [line 68]\n *&return:int =n$37 [line 68]\n REMOVE_TEMPS(n$36,n$37); [line 68]\n NULLIFY(&__objc_anonymous_block_A_dispatch_group_notify_example______5,true); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"] 43 -> 42 ; 42 [label="42: Exit A_dispatch_group_notify_example \n " color=yellow style=filled] -41 [label="41: Start A_dispatch_group_notify_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_group_notify_example______5); [line 59]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_notify_example______5,false); [line 59]\n " color=yellow style=filled] +41 [label="41: Start A_dispatch_group_notify_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_group_notify_example______5:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_group_notify_example______5); [line 62]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_notify_example______5,false); [line 62]\n " color=yellow style=filled] 41 -> 50 ; -40 [label="40: DeclStmt \n *&#GB$A_dispatch_group_example_a:class A *=0 [line 51]\n " shape="box"] +40 [label="40: DeclStmt \n *&#GB$A_dispatch_group_example_a:class A *=0 [line 54]\n " shape="box"] 40 -> 39 ; -39 [label="39: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_group_example______4); [line 52]\n n$34=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_group_example______4 ):unsigned long ) [line 52]\n *&__objc_anonymous_block_A_dispatch_group_example______4:class __objc_anonymous_block_A_dispatch_group_example______4 =n$34 [line 52]\n n$35=*&#GB$A_dispatch_group_example_a:class A * [line 52]\n *n$34.A_dispatch_group_example_a:class A *=n$35 [line 52]\n *&infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_group_example______4) [line 52]\n REMOVE_TEMPS(n$34,n$35); [line 52]\n " shape="box"] +39 [label="39: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_group_example______4); [line 55]\n n$34=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_group_example______4 ):unsigned long ) [line 55]\n *&__objc_anonymous_block_A_dispatch_group_example______4:class __objc_anonymous_block_A_dispatch_group_example______4 =n$34 [line 55]\n n$35=*&#GB$A_dispatch_group_example_a:class A * [line 55]\n *n$34.A_dispatch_group_example_a:class A *=n$35 [line 55]\n *&infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_group_example______4) [line 55]\n REMOVE_TEMPS(n$34,n$35); [line 55]\n " shape="box"] 39 -> 34 ; -38 [label="38: BinaryOperatorStmt: Assign \n n$32=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 53]\n n$33=_fun_NSObject_init(n$32:class A *) virtual [line 53]\n *&#GB$A_dispatch_group_example_a:class A *=n$33 [line 53]\n REMOVE_TEMPS(n$32,n$33); [line 53]\n " shape="box"] +38 [label="38: BinaryOperatorStmt: Assign \n n$32=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 56]\n n$33=_fun_NSObject_init(n$32:class A *) virtual [line 56]\n *&#GB$A_dispatch_group_example_a:class A *=n$33 [line 56]\n REMOVE_TEMPS(n$32,n$33); [line 56]\n " shape="box"] 38 -> 37 ; -37 [label="37: BinaryOperatorStmt: Assign \n n$31=*&#GB$A_dispatch_group_example_a:class A * [line 54]\n *n$31.x:int =10 [line 54]\n REMOVE_TEMPS(n$31); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] +37 [label="37: BinaryOperatorStmt: Assign \n n$31=*&#GB$A_dispatch_group_example_a:class A * [line 57]\n *n$31.x:int =10 [line 57]\n REMOVE_TEMPS(n$31); [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] 37 -> 36 ; 36 [label="36: Exit __objc_anonymous_block_A_dispatch_group_example______4 \n " color=yellow style=filled] -35 [label="35: Start __objc_anonymous_block_A_dispatch_group_example______4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 52]\n " color=yellow style=filled] +35 [label="35: Start __objc_anonymous_block_A_dispatch_group_example______4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 55]\n " color=yellow style=filled] 35 -> 38 ; -34 [label="34: Call n$29 \n n$29=*&infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*) [line 52]\n n$30=n$29() [line 52]\n REMOVE_TEMPS(n$29,n$30); [line 52]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_example______4,false); [line 52]\n " shape="box"] +34 [label="34: Call n$29 \n n$29=*&infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*) [line 55]\n n$30=n$29() [line 55]\n REMOVE_TEMPS(n$29,n$30); [line 55]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_example______4,false); [line 55]\n " shape="box"] 34 -> 33 ; -33 [label="33: Return Stmt \n n$27=*&#GB$A_dispatch_group_example_a:class A * [line 56]\n n$28=*n$27.x:int [line 56]\n *&return:int =n$28 [line 56]\n REMOVE_TEMPS(n$27,n$28); [line 56]\n NULLIFY(&__objc_anonymous_block_A_dispatch_group_example______4,true); [line 56]\n APPLY_ABSTRACTION; [line 56]\n " shape="box"] +33 [label="33: Return Stmt \n n$27=*&#GB$A_dispatch_group_example_a:class A * [line 59]\n n$28=*n$27.x:int [line 59]\n *&return:int =n$28 [line 59]\n REMOVE_TEMPS(n$27,n$28); [line 59]\n NULLIFY(&__objc_anonymous_block_A_dispatch_group_example______4,true); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] 33 -> 32 ; 32 [label="32: Exit A_dispatch_group_example \n " color=yellow style=filled] -31 [label="31: Start A_dispatch_group_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_group_example______4); [line 50]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_example______4,false); [line 50]\n " color=yellow style=filled] +31 [label="31: Start A_dispatch_group_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_group_example______4:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_group_example______4); [line 53]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_group_example______4,false); [line 53]\n " color=yellow style=filled] 31 -> 40 ; -30 [label="30: DeclStmt \n *&#GB$A_dispatch_after_example_a:class A *=0 [line 41]\n " shape="box"] +30 [label="30: DeclStmt \n *&#GB$A_dispatch_after_example_a:class A *=0 [line 43]\n " shape="box"] 30 -> 29 ; -29 [label="29: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_after_example______3); [line 43]\n n$25=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_after_example______3 ):unsigned long ) [line 43]\n *&__objc_anonymous_block_A_dispatch_after_example______3:class __objc_anonymous_block_A_dispatch_after_example______3 =n$25 [line 43]\n n$26=*&#GB$A_dispatch_after_example_a:class A * [line 43]\n *n$25.A_dispatch_after_example_a:class A *=n$26 [line 43]\n *&infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_after_example______3) [line 42]\n REMOVE_TEMPS(n$25,n$26); [line 42]\n " shape="box"] +29 [label="29: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_after_example______3); [line 46]\n n$25=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_after_example______3 ):unsigned long ) [line 46]\n *&__objc_anonymous_block_A_dispatch_after_example______3:class __objc_anonymous_block_A_dispatch_after_example______3 =n$25 [line 46]\n n$26=*&#GB$A_dispatch_after_example_a:class A * [line 46]\n *n$25.A_dispatch_after_example_a:class A *=n$26 [line 46]\n *&infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_after_example______3) [line 44]\n REMOVE_TEMPS(n$25,n$26); [line 44]\n " shape="box"] 29 -> 24 ; -28 [label="28: BinaryOperatorStmt: Assign \n n$23=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 44]\n n$24=_fun_NSObject_init(n$23:class A *) virtual [line 44]\n *&#GB$A_dispatch_after_example_a:class A *=n$24 [line 44]\n REMOVE_TEMPS(n$23,n$24); [line 44]\n " shape="box"] +28 [label="28: BinaryOperatorStmt: Assign \n n$23=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 47]\n n$24=_fun_NSObject_init(n$23:class A *) virtual [line 47]\n *&#GB$A_dispatch_after_example_a:class A *=n$24 [line 47]\n REMOVE_TEMPS(n$23,n$24); [line 47]\n " shape="box"] 28 -> 27 ; -27 [label="27: BinaryOperatorStmt: Assign \n n$22=*&#GB$A_dispatch_after_example_a:class A * [line 45]\n *n$22.x:int =10 [line 45]\n REMOVE_TEMPS(n$22); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] +27 [label="27: BinaryOperatorStmt: Assign \n n$22=*&#GB$A_dispatch_after_example_a:class A * [line 48]\n *n$22.x:int =10 [line 48]\n REMOVE_TEMPS(n$22); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit __objc_anonymous_block_A_dispatch_after_example______3 \n " color=yellow style=filled] -25 [label="25: Start __objc_anonymous_block_A_dispatch_after_example______3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 43]\n " color=yellow style=filled] +25 [label="25: Start __objc_anonymous_block_A_dispatch_after_example______3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 46]\n " color=yellow style=filled] 25 -> 28 ; -24 [label="24: Call n$20 \n n$20=*&infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*) [line 42]\n n$21=n$20() [line 42]\n REMOVE_TEMPS(n$20,n$21); [line 42]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_after_example______3,false); [line 42]\n " shape="box"] +24 [label="24: Call n$20 \n n$20=*&infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*) [line 44]\n n$21=n$20() [line 44]\n REMOVE_TEMPS(n$20,n$21); [line 44]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_after_example______3,false); [line 44]\n " shape="box"] 24 -> 23 ; -23 [label="23: Return Stmt \n n$18=*&#GB$A_dispatch_after_example_a:class A * [line 47]\n n$19=*n$18.x:int [line 47]\n *&return:int =n$19 [line 47]\n REMOVE_TEMPS(n$18,n$19); [line 47]\n NULLIFY(&__objc_anonymous_block_A_dispatch_after_example______3,true); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] +23 [label="23: Return Stmt \n n$18=*&#GB$A_dispatch_after_example_a:class A * [line 50]\n n$19=*n$18.x:int [line 50]\n *&return:int =n$19 [line 50]\n REMOVE_TEMPS(n$18,n$19); [line 50]\n NULLIFY(&__objc_anonymous_block_A_dispatch_after_example______3,true); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] 23 -> 22 ; 22 [label="22: Exit A_dispatch_after_example \n " color=yellow style=filled] -21 [label="21: Start A_dispatch_after_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_after_example______3); [line 40]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_after_example______3,false); [line 40]\n " color=yellow style=filled] +21 [label="21: Start A_dispatch_after_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_after_example______3:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_after_example______3); [line 42]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_after_example______3,false); [line 42]\n " color=yellow style=filled] 21 -> 30 ; -20 [label="20: DeclStmt \n *&#GB$A_dispatch_async_example_a:class A *=0 [line 32]\n " shape="box"] +20 [label="20: DeclStmt \n *&#GB$A_dispatch_async_example_a:class A *=0 [line 33]\n " shape="box"] 20 -> 19 ; -19 [label="19: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_async_example______2); [line 33]\n n$16=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_async_example______2 ):unsigned long ) [line 33]\n *&__objc_anonymous_block_A_dispatch_async_example______2:class __objc_anonymous_block_A_dispatch_async_example______2 =n$16 [line 33]\n n$17=*&#GB$A_dispatch_async_example_a:class A * [line 33]\n *n$16.A_dispatch_async_example_a:class A *=n$17 [line 33]\n *&infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_async_example______2) [line 33]\n REMOVE_TEMPS(n$16,n$17); [line 33]\n " shape="box"] +19 [label="19: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_async_example______2); [line 35]\n n$16=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_async_example______2 ):unsigned long ) [line 35]\n *&__objc_anonymous_block_A_dispatch_async_example______2:class __objc_anonymous_block_A_dispatch_async_example______2 =n$16 [line 35]\n n$17=*&#GB$A_dispatch_async_example_a:class A * [line 35]\n *n$16.A_dispatch_async_example_a:class A *=n$17 [line 35]\n *&infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_async_example______2) [line 34]\n REMOVE_TEMPS(n$16,n$17); [line 34]\n " shape="box"] 19 -> 14 ; -18 [label="18: BinaryOperatorStmt: Assign \n n$14=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 34]\n n$15=_fun_NSObject_init(n$14:class A *) virtual [line 34]\n *&#GB$A_dispatch_async_example_a:class A *=n$15 [line 34]\n REMOVE_TEMPS(n$14,n$15); [line 34]\n " shape="box"] +18 [label="18: BinaryOperatorStmt: Assign \n n$14=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 36]\n n$15=_fun_NSObject_init(n$14:class A *) virtual [line 36]\n *&#GB$A_dispatch_async_example_a:class A *=n$15 [line 36]\n REMOVE_TEMPS(n$14,n$15); [line 36]\n " shape="box"] 18 -> 17 ; -17 [label="17: BinaryOperatorStmt: Assign \n n$13=*&#GB$A_dispatch_async_example_a:class A * [line 35]\n *n$13.x:int =10 [line 35]\n REMOVE_TEMPS(n$13); [line 35]\n APPLY_ABSTRACTION; [line 35]\n " shape="box"] +17 [label="17: BinaryOperatorStmt: Assign \n n$13=*&#GB$A_dispatch_async_example_a:class A * [line 37]\n *n$13.x:int =10 [line 37]\n REMOVE_TEMPS(n$13); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit __objc_anonymous_block_A_dispatch_async_example______2 \n " color=yellow style=filled] -15 [label="15: Start __objc_anonymous_block_A_dispatch_async_example______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 33]\n " color=yellow style=filled] +15 [label="15: Start __objc_anonymous_block_A_dispatch_async_example______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 35]\n " color=yellow style=filled] 15 -> 18 ; -14 [label="14: Call n$11 \n n$11=*&infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*) [line 33]\n n$12=n$11() [line 33]\n REMOVE_TEMPS(n$11,n$12); [line 33]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_async_example______2,false); [line 33]\n " shape="box"] +14 [label="14: Call n$11 \n n$11=*&infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*) [line 34]\n n$12=n$11() [line 34]\n REMOVE_TEMPS(n$11,n$12); [line 34]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_async_example______2,false); [line 34]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$9=*&#GB$A_dispatch_async_example_a:class A * [line 37]\n n$10=*n$9.x:int [line 37]\n *&return:int =n$10 [line 37]\n REMOVE_TEMPS(n$9,n$10); [line 37]\n NULLIFY(&__objc_anonymous_block_A_dispatch_async_example______2,true); [line 37]\n APPLY_ABSTRACTION; [line 37]\n " shape="box"] +13 [label="13: Return Stmt \n n$9=*&#GB$A_dispatch_async_example_a:class A * [line 39]\n n$10=*n$9.x:int [line 39]\n *&return:int =n$10 [line 39]\n REMOVE_TEMPS(n$9,n$10); [line 39]\n NULLIFY(&__objc_anonymous_block_A_dispatch_async_example______2,true); [line 39]\n APPLY_ABSTRACTION; [line 39]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit A_dispatch_async_example \n " color=yellow style=filled] -11 [label="11: Start A_dispatch_async_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_async_example______2); [line 31]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_async_example______2,false); [line 31]\n " color=yellow style=filled] +11 [label="11: Start A_dispatch_async_example\nFormals: \nLocals: infer___objc_anonymous_block_A_dispatch_async_example______2:_fn_ (*) \n DECLARE_LOCALS(&return,&infer___objc_anonymous_block_A_dispatch_async_example______2); [line 32]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_async_example______2,false); [line 32]\n " color=yellow style=filled] 11 -> 20 ; @@ -193,30 +193,30 @@ digraph iCFG { 10 -> 9 ; -9 [label="9: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_once_example______1); [line 24]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_once_example______1 ):unsigned long ) [line 24]\n *&__objc_anonymous_block_A_dispatch_once_example______1:class __objc_anonymous_block_A_dispatch_once_example______1 =n$7 [line 24]\n n$8=*&#GB$A_dispatch_once_example_a:class A * [line 24]\n *n$7.A_dispatch_once_example_a:class A *=n$8 [line 24]\n *&infer___objc_anonymous_block_A_dispatch_once_example______1:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_once_example______1) [line 24]\n REMOVE_TEMPS(n$7,n$8); [line 24]\n " shape="box"] +9 [label="9: DeclStmt \n DECLARE_LOCALS(&__objc_anonymous_block_A_dispatch_once_example______1); [line 25]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_dispatch_once_example______1 ):unsigned long ) [line 25]\n *&__objc_anonymous_block_A_dispatch_once_example______1:class __objc_anonymous_block_A_dispatch_once_example______1 =n$7 [line 25]\n n$8=*&#GB$A_dispatch_once_example_a:class A * [line 25]\n *n$7.A_dispatch_once_example_a:class A *=n$8 [line 25]\n *&infer___objc_anonymous_block_A_dispatch_once_example______1:_fn_ (*)=(_fun___objc_anonymous_block_A_dispatch_once_example______1) [line 25]\n REMOVE_TEMPS(n$7,n$8); [line 25]\n " shape="box"] 9 -> 4 ; -8 [label="8: BinaryOperatorStmt: Assign \n n$5=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 25]\n n$6=_fun_NSObject_init(n$5:class A *) virtual [line 25]\n *&#GB$A_dispatch_once_example_a:class A *=n$6 [line 25]\n REMOVE_TEMPS(n$5,n$6); [line 25]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n n$5=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 26]\n n$6=_fun_NSObject_init(n$5:class A *) virtual [line 26]\n *&#GB$A_dispatch_once_example_a:class A *=n$6 [line 26]\n REMOVE_TEMPS(n$5,n$6); [line 26]\n " shape="box"] 8 -> 7 ; -7 [label="7: BinaryOperatorStmt: Assign \n n$4=*&#GB$A_dispatch_once_example_a:class A * [line 26]\n *n$4.x:int =10 [line 26]\n REMOVE_TEMPS(n$4); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +7 [label="7: BinaryOperatorStmt: Assign \n n$4=*&#GB$A_dispatch_once_example_a:class A * [line 27]\n *n$4.x:int =10 [line 27]\n REMOVE_TEMPS(n$4); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"] 7 -> 6 ; 6 [label="6: Exit __objc_anonymous_block_A_dispatch_once_example______1 \n " color=yellow style=filled] -5 [label="5: Start __objc_anonymous_block_A_dispatch_once_example______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] +5 [label="5: Start __objc_anonymous_block_A_dispatch_once_example______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] 5 -> 8 ; -4 [label="4: Call n$2 \n n$2=*&infer___objc_anonymous_block_A_dispatch_once_example______1:_fn_ (*) [line 24]\n n$3=n$2() [line 24]\n REMOVE_TEMPS(n$2,n$3); [line 24]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_once_example______1,false); [line 24]\n " shape="box"] +4 [label="4: Call n$2 \n n$2=*&infer___objc_anonymous_block_A_dispatch_once_example______1:_fn_ (*) [line 25]\n n$3=n$2() [line 25]\n REMOVE_TEMPS(n$2,n$3); [line 25]\n NULLIFY(&infer___objc_anonymous_block_A_dispatch_once_example______1,false); [line 25]\n " shape="box"] 4 -> 3 ; -3 [label="3: Return Stmt \n n$0=*&#GB$A_dispatch_once_example_a:class A * [line 28]\n n$1=*n$0.x:int [line 28]\n *&return:int =n$1 [line 28]\n REMOVE_TEMPS(n$0,n$1); [line 28]\n NULLIFY(&__objc_anonymous_block_A_dispatch_once_example______1,true); [line 28]\n APPLY_ABSTRACTION; [line 28]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$A_dispatch_once_example_a:class A * [line 29]\n n$1=*n$0.x:int [line 29]\n *&return:int =n$1 [line 29]\n REMOVE_TEMPS(n$0,n$1); [line 29]\n NULLIFY(&__objc_anonymous_block_A_dispatch_once_example______1,true); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.m b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.m index 91c4330f4..9e3b4fc9a 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_examples.m @@ -10,68 +10,71 @@ #import @interface A : NSObject { - int x; + int x; } @end @implementation A -+ (int)dispatch_once_example -{ static A* a = nil; - //dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{ - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_once_example { + static A* a = nil; + // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, + // 0),^{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } -+ (int)dispatch_async_example -{ static A* a = nil; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_async_example { + static A* a = nil; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), + ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } -+ (int)dispatch_after_example -{ static A* a = nil; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), - dispatch_get_main_queue(), ^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_after_example { + static A* a = nil; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), + dispatch_get_main_queue(), + ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } -+ (int)dispatch_group_example -{ static A* a = nil; - dispatch_group_async(NULL, dispatch_get_main_queue(), ^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_group_example { + static A* a = nil; + dispatch_group_async(NULL, dispatch_get_main_queue(), ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } -+ (int)dispatch_group_notify_example -{ static A* a = nil; - dispatch_group_async(NULL, dispatch_get_main_queue(), ^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_group_notify_example { + static A* a = nil; + dispatch_group_async(NULL, dispatch_get_main_queue(), ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } -+ (int)dispatch_barrier_example -{ static A* a = nil; - dispatch_barrier_async(dispatch_get_main_queue(), ^{ - a = [[A alloc] init]; - a->x = 10; - }); - return a->x; ++ (int)dispatch_barrier_example { + static A* a = nil; + dispatch_barrier_async(dispatch_get_main_queue(), ^{ + a = [[A alloc] init]; + a->x = 10; + }); + return a->x; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_in_macro.m b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_in_macro.m index 00789df9f..079e4063f 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/dispatch_in_macro.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/dispatch_in_macro.m @@ -9,14 +9,14 @@ #import +#define INITIALIZE_AND_RETURN_STATIC(...) \ + ({ \ + static __typeof__(__VA_ARGS__) static_storage; \ + static dispatch_once_t once_token; \ + dispatch_once(&once_token, ^{ \ + static_storage = (__VA_ARGS__); \ + }); \ + static_storage; \ + }) -#define INITIALIZE_AND_RETURN_STATIC(...) ({ \ -static __typeof__(__VA_ARGS__) static_storage; \ -static dispatch_once_t once_token; \ -dispatch_once(&once_token, ^{ static_storage = (__VA_ARGS__); }); \ -static_storage; \ -}) - -id test() { - return INITIALIZE_AND_RETURN_STATIC([NSObject new]); -} +id test() { return INITIALIZE_AND_RETURN_STATIC([NSObject new]); } diff --git a/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.dot b/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.dot index f00840b45..775d5a713 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.dot @@ -1,72 +1,72 @@ digraph iCFG { -19 [label="19: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 68]\n *&a:class A *=n$2 [line 68]\n REMOVE_TEMPS(n$2); [line 68]\n " shape="box"] +19 [label="19: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 63]\n *&a:class A *=n$2 [line 63]\n REMOVE_TEMPS(n$2); [line 63]\n " shape="box"] 19 -> 18 ; -18 [label="18: BinaryOperatorStmt: Assign \n n$0=*&a:class A * [line 70]\n n$1=_fun_foo(n$0:class A *) [line 70]\n *&a:class A *=n$1 [line 70]\n REMOVE_TEMPS(n$0,n$1); [line 70]\n NULLIFY(&a,false); [line 70]\n " shape="box"] +18 [label="18: BinaryOperatorStmt: Assign \n n$0=*&a:class A * [line 65]\n n$1=_fun_foo(n$0:class A *) [line 65]\n *&a:class A *=n$1 [line 65]\n REMOVE_TEMPS(n$0,n$1); [line 65]\n NULLIFY(&a,false); [line 65]\n " shape="box"] 18 -> 17 ; -17 [label="17: Return Stmt \n *&return:int =0 [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="box"] +17 [label="17: Return Stmt \n *&return:int =0 [line 67]\n APPLY_ABSTRACTION; [line 67]\n " shape="box"] 17 -> 16 ; 16 [label="16: Exit main \n " color=yellow style=filled] -15 [label="15: Start main\nFormals: argc:int argv:char **\nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 66]\n NULLIFY(&a,false); [line 66]\n NULLIFY(&argc,false); [line 66]\n NULLIFY(&argv,false); [line 66]\n " color=yellow style=filled] +15 [label="15: Start main\nFormals: argc:int argv:char **\nLocals: a:class A * \n DECLARE_LOCALS(&return,&a); [line 61]\n NULLIFY(&a,false); [line 61]\n NULLIFY(&argc,false); [line 61]\n NULLIFY(&argv,false); [line 61]\n " color=yellow style=filled] 15 -> 19 ; -14 [label="14: Message Call: capture \n n$1=*&a:class A * [line 60]\n _fun_A_capture(n$1:class A *) virtual [line 60]\n REMOVE_TEMPS(n$1); [line 60]\n " shape="box"] +14 [label="14: Message Call: capture \n n$1=*&a:class A * [line 56]\n _fun_A_capture(n$1:class A *) virtual [line 56]\n REMOVE_TEMPS(n$1); [line 56]\n " shape="box"] 14 -> 13 ; -13 [label="13: Return Stmt \n n$0=*&a:class A * [line 62]\n *&return:class A *=n$0 [line 62]\n REMOVE_TEMPS(n$0); [line 62]\n NULLIFY(&a,false); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] +13 [label="13: Return Stmt \n n$0=*&a:class A * [line 58]\n *&return:class A *=n$0 [line 58]\n REMOVE_TEMPS(n$0); [line 58]\n NULLIFY(&a,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 13 -> 12 ; 12 [label="12: Exit foo \n " color=yellow style=filled] -11 [label="11: Start foo\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 58]\n " color=yellow style=filled] +11 [label="11: Start foo\nFormals: a:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] 11 -> 14 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$8=*&self:class A * [line 50]\n n$9=_fun___objc_alloc_no_fail(sizeof(class B ):unsigned long ) [line 50]\n *n$8._b:class B *=n$9 [line 50]\n REMOVE_TEMPS(n$8,n$9); [line 50]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n n$8=*&self:class A * [line 46]\n n$9=_fun___objc_alloc_no_fail(sizeof(class B ):unsigned long ) [line 46]\n *n$8._b:class B *=n$9 [line 46]\n REMOVE_TEMPS(n$8,n$9); [line 46]\n " shape="box"] 10 -> 9 ; -9 [label="9: Message Call: sHandler: \n n$0=*&self:class A * [line 51]\n n$1=*n$0._b:class B * [line 51]\n DECLARE_LOCALS(&__objc_anonymous_block_A_capture______1); [line 51]\n n$5=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_capture______1 ):unsigned long ) [line 51]\n *&__objc_anonymous_block_A_capture______1:class __objc_anonymous_block_A_capture______1 =n$5 [line 51]\n n$6=*&self:class A * [line 51]\n *n$5.self:class A *=n$6 [line 51]\n n$2=*&self:class A * [line 51]\n n$7=*&__objc_anonymous_block_A_capture______1:_fn_ (*) [line 51]\n _fun_B_sHandler:(n$1:class B *,n$7:_fn_ (*),n$2:_fn_ (*)) virtual [line 51]\n REMOVE_TEMPS(n$0,n$1,n$5,n$6,n$2,n$7); [line 51]\n NULLIFY(&__objc_anonymous_block_A_capture______1,true); [line 51]\n NULLIFY(&self,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"] +9 [label="9: Message Call: sHandler: \n n$0=*&self:class A * [line 47]\n n$1=*n$0._b:class B * [line 47]\n DECLARE_LOCALS(&__objc_anonymous_block_A_capture______1); [line 47]\n n$5=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_capture______1 ):unsigned long ) [line 47]\n *&__objc_anonymous_block_A_capture______1:class __objc_anonymous_block_A_capture______1 =n$5 [line 47]\n n$6=*&self:class A * [line 47]\n *n$5.self:class A *=n$6 [line 47]\n n$2=*&self:class A * [line 47]\n n$7=*&__objc_anonymous_block_A_capture______1:_fn_ (*) [line 47]\n _fun_B_sHandler:(n$1:class B *,n$7:_fn_ (*),n$2:_fn_ (*)) virtual [line 47]\n REMOVE_TEMPS(n$0,n$1,n$5,n$6,n$2,n$7); [line 47]\n NULLIFY(&__objc_anonymous_block_A_capture______1,true); [line 47]\n NULLIFY(&self,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] 9 -> 5 ; -8 [label="8: BinaryOperatorStmt: Assign \n n$3=*&self:class A * [line 52]\n n$4=*&d:class D * [line 52]\n *n$3._data:class D *=n$4 [line 52]\n REMOVE_TEMPS(n$3,n$4); [line 52]\n NULLIFY(&d,false); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n n$3=*&self:class A * [line 48]\n n$4=*&d:class D * [line 48]\n *n$3._data:class D *=n$4 [line 48]\n REMOVE_TEMPS(n$3,n$4); [line 48]\n NULLIFY(&d,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] 8 -> 7 ; 7 [label="7: Exit __objc_anonymous_block_A_capture______1 \n " color=yellow style=filled] -6 [label="6: Start __objc_anonymous_block_A_capture______1\nFormals: self:class A * d:class D *\nLocals: \nCaptured: self:class A * \n DECLARE_LOCALS(&return); [line 51]\n " color=yellow style=filled] +6 [label="6: Start __objc_anonymous_block_A_capture______1\nFormals: self:class A * d:class D *\nLocals: \nCaptured: self:class A * \n DECLARE_LOCALS(&return); [line 47]\n " color=yellow style=filled] 6 -> 8 ; 5 [label="5: Exit A_capture \n " color=yellow style=filled] -4 [label="4: Start A_capture\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 48]\n " color=yellow style=filled] +4 [label="4: Start A_capture\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 45]\n " color=yellow style=filled] 4 -> 10 ; -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:class B * [line 32]\n n$1=*&h:_fn_ (*) [line 32]\n *n$0._h:_fn_ (*)=n$1 [line 32]\n REMOVE_TEMPS(n$0,n$1); [line 32]\n NULLIFY(&h,false); [line 32]\n NULLIFY(&self,false); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:class B * [line 30]\n n$1=*&h:_fn_ (*) [line 30]\n *n$0._h:_fn_ (*)=n$1 [line 30]\n REMOVE_TEMPS(n$0,n$1); [line 30]\n NULLIFY(&h,false); [line 30]\n NULLIFY(&self,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit B_sHandler: \n " color=yellow style=filled] -1 [label="1: Start B_sHandler:\nFormals: self:class B * h:_fn_ (*)\nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] +1 [label="1: Start B_sHandler:\nFormals: self:class B * h:_fn_ (*)\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.m b/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.m index 654863623..5c83e62ec 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/retain_cycle.m @@ -13,61 +13,56 @@ @end - typedef void (^MyHandler)(D* data); - @interface B : NSObject -- (void)sHandler: (MyHandler) h; +- (void)sHandler:(MyHandler)h; @end @implementation B { - D* _d; - MyHandler _h; + D* _d; + MyHandler _h; } - (void)sHandler:(MyHandler)h { - self->_h=h; + self->_h = h; } @end - @interface A : NSObject - (void)capture; @end @implementation A { - B* _b; - D* _data; + B* _b; + D* _data; } -- (void)capture -{ - _b=[B alloc]; - [_b sHandler:^(D *d){ - _data=d; - }]; +- (void)capture { + _b = [B alloc]; + [_b sHandler:^(D* d) { + _data = d; + }]; } @end A* foo(A* a) { - [a capture]; + [a capture]; - return a; + return a; }; +int main(int argc, const char* argv[]) { -int main(int argc, const char * argv[]) { - - A* a = [A alloc]; + A* a = [A alloc]; - a=foo(a); + a = foo(a); - return 0; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/block/static.dot b/infer/tests/codetoanalyze/objc/frontend/block/static.dot index 40700eba0..4dcaf712d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/static.dot +++ b/infer/tests/codetoanalyze/objc/frontend/block/static.dot @@ -1,109 +1,109 @@ digraph iCFG { -31 [label="31: Return Stmt \n *&return:int =0 [line 73]\n APPLY_ABSTRACTION; [line 73]\n " shape="box"] +31 [label="31: Return Stmt \n *&return:int =0 [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"] 31 -> 30 ; 30 [label="30: Exit main \n " color=yellow style=filled] -29 [label="29: Start main\nFormals: argc:int argv:char **\nLocals: \n DECLARE_LOCALS(&return); [line 71]\n NULLIFY(&argc,false); [line 71]\n NULLIFY(&argv,false); [line 71]\n " color=yellow style=filled] +29 [label="29: Start main\nFormals: argc:int argv:char **\nLocals: \n DECLARE_LOCALS(&return); [line 60]\n NULLIFY(&argc,false); [line 60]\n NULLIFY(&argv,false); [line 60]\n " color=yellow style=filled] 29 -> 31 ; -28 [label="28: Call (_fun___objc_anonymous_block_A_test3______4) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test3______4); [line 59]\n n$17=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test3______4 ):unsigned long ) [line 59]\n *&__objc_anonymous_block_A_test3______4:class __objc_anonymous_block_A_test3______4 =n$17 [line 59]\n n$18=*&#GB$A_test3_i:int [line 59]\n *n$17.A_test3_i:int =n$18 [line 59]\n (_fun___objc_anonymous_block_A_test3______4)() [line 59]\n REMOVE_TEMPS(n$17,n$18); [line 59]\n " shape="box"] +28 [label="28: Call (_fun___objc_anonymous_block_A_test3______4) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test3______4); [line 50]\n n$17=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test3______4 ):unsigned long ) [line 50]\n *&__objc_anonymous_block_A_test3______4:class __objc_anonymous_block_A_test3______4 =n$17 [line 50]\n n$18=*&#GB$A_test3_i:int [line 50]\n *n$17.A_test3_i:int =n$18 [line 50]\n (_fun___objc_anonymous_block_A_test3______4)() [line 50]\n REMOVE_TEMPS(n$17,n$18); [line 50]\n " shape="box"] 28 -> 24 ; -27 [label="27: UnaryOperator \n n$16=*&#GB$A_test3_i:int [line 61]\n *&#GB$A_test3_i:int =(n$16 + 1) [line 61]\n REMOVE_TEMPS(n$16); [line 61]\n APPLY_ABSTRACTION; [line 61]\n " shape="box"] +27 [label="27: UnaryOperator \n n$16=*&#GB$A_test3_i:int [line 52]\n *&#GB$A_test3_i:int =(n$16 + 1) [line 52]\n REMOVE_TEMPS(n$16); [line 52]\n APPLY_ABSTRACTION; [line 52]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit __objc_anonymous_block_A_test3______4 \n " color=yellow style=filled] -25 [label="25: Start __objc_anonymous_block_A_test3______4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 59]\n " color=yellow style=filled] +25 [label="25: Start __objc_anonymous_block_A_test3______4\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 50]\n " color=yellow style=filled] 25 -> 27 ; -24 [label="24: Return Stmt \n n$15=*&#GB$A_test3_i:int [line 64]\n *&return:int =n$15 [line 64]\n REMOVE_TEMPS(n$15); [line 64]\n NULLIFY(&__objc_anonymous_block_A_test3______4,true); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"] +24 [label="24: Return Stmt \n n$15=*&#GB$A_test3_i:int [line 55]\n *&return:int =n$15 [line 55]\n REMOVE_TEMPS(n$15); [line 55]\n NULLIFY(&__objc_anonymous_block_A_test3______4,true); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] 24 -> 23 ; 23 [label="23: Exit A_test3 \n " color=yellow style=filled] -22 [label="22: Start A_test3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 55]\n " color=yellow style=filled] +22 [label="22: Start A_test3\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 47]\n " color=yellow style=filled] 22 -> 28 ; -21 [label="21: BinaryOperatorStmt: Assign \n n$13=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 43]\n n$14=_fun_A_init(n$13:class A *) virtual [line 43]\n *&#GB$A_test2_sharedInstance:struct objc_object *=n$14 [line 43]\n REMOVE_TEMPS(n$13,n$14); [line 43]\n " shape="box"] +21 [label="21: BinaryOperatorStmt: Assign \n n$13=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 38]\n n$14=_fun_A_init(n$13:class A *) virtual [line 38]\n *&#GB$A_test2_sharedInstance:struct objc_object *=n$14 [line 38]\n REMOVE_TEMPS(n$13,n$14); [line 38]\n " shape="box"] 21 -> 20 ; -20 [label="20: Call (_fun___objc_anonymous_block_A_test2______3) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test2______3); [line 44]\n n$11=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test2______3 ):unsigned long ) [line 44]\n *&__objc_anonymous_block_A_test2______3:class __objc_anonymous_block_A_test2______3 =n$11 [line 44]\n n$12=*&#GB$A_test2_sharedInstance:struct objc_object * [line 44]\n *n$11.A_test2_sharedInstance:struct objc_object *=n$12 [line 44]\n (_fun___objc_anonymous_block_A_test2______3)() [line 44]\n REMOVE_TEMPS(n$11,n$12); [line 44]\n " shape="box"] +20 [label="20: Call (_fun___objc_anonymous_block_A_test2______3) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test2______3); [line 39]\n n$11=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test2______3 ):unsigned long ) [line 39]\n *&__objc_anonymous_block_A_test2______3:class __objc_anonymous_block_A_test2______3 =n$11 [line 39]\n n$12=*&#GB$A_test2_sharedInstance:struct objc_object * [line 39]\n *n$11.A_test2_sharedInstance:struct objc_object *=n$12 [line 39]\n (_fun___objc_anonymous_block_A_test2______3)() [line 39]\n REMOVE_TEMPS(n$11,n$12); [line 39]\n " shape="box"] 20 -> 16 ; -19 [label="19: DeclStmt \n n$10=*&#GB$A_test2_sharedInstance:struct objc_object * [line 46]\n *&p:struct objc_object *=n$10 [line 46]\n REMOVE_TEMPS(n$10); [line 46]\n NULLIFY(&p,false); [line 46]\n APPLY_ABSTRACTION; [line 46]\n " shape="box"] +19 [label="19: DeclStmt \n n$10=*&#GB$A_test2_sharedInstance:struct objc_object * [line 41]\n *&p:struct objc_object *=n$10 [line 41]\n REMOVE_TEMPS(n$10); [line 41]\n NULLIFY(&p,false); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"] 19 -> 18 ; 18 [label="18: Exit __objc_anonymous_block_A_test2______3 \n " color=yellow style=filled] -17 [label="17: Start __objc_anonymous_block_A_test2______3\nFormals: \nLocals: p:struct objc_object * \n DECLARE_LOCALS(&return,&p); [line 44]\n NULLIFY(&p,false); [line 44]\n " color=yellow style=filled] +17 [label="17: Start __objc_anonymous_block_A_test2______3\nFormals: \nLocals: p:struct objc_object * \n DECLARE_LOCALS(&return,&p); [line 39]\n NULLIFY(&p,false); [line 39]\n " color=yellow style=filled] 17 -> 19 ; -16 [label="16: Return Stmt \n n$9=*&#GB$A_test2_sharedInstance:struct objc_object * [line 49]\n *&return:struct objc_object *=n$9 [line 49]\n REMOVE_TEMPS(n$9); [line 49]\n NULLIFY(&__objc_anonymous_block_A_test2______3,true); [line 49]\n APPLY_ABSTRACTION; [line 49]\n " shape="box"] +16 [label="16: Return Stmt \n n$9=*&#GB$A_test2_sharedInstance:struct objc_object * [line 44]\n *&return:struct objc_object *=n$9 [line 44]\n REMOVE_TEMPS(n$9); [line 44]\n NULLIFY(&__objc_anonymous_block_A_test2______3,true); [line 44]\n APPLY_ABSTRACTION; [line 44]\n " shape="box"] 16 -> 15 ; 15 [label="15: Exit A_test2 \n " color=yellow style=filled] -14 [label="14: Start A_test2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled] +14 [label="14: Start A_test2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 36]\n " color=yellow style=filled] 14 -> 21 ; -13 [label="13: Call (_fun___objc_anonymous_block_A_test_leak______2) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test_leak______2); [line 32]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test_leak______2 ):unsigned long ) [line 32]\n *&__objc_anonymous_block_A_test_leak______2:class __objc_anonymous_block_A_test_leak______2 =n$7 [line 32]\n n$8=*&#GB$A_test_leak_sharedInstance:struct objc_object * [line 32]\n *n$7.A_test_leak_sharedInstance:struct objc_object *=n$8 [line 32]\n (_fun___objc_anonymous_block_A_test_leak______2)() [line 32]\n REMOVE_TEMPS(n$7,n$8); [line 32]\n NULLIFY(&__objc_anonymous_block_A_test_leak______2,true); [line 32]\n APPLY_ABSTRACTION; [line 32]\n " shape="box"] +13 [label="13: Call (_fun___objc_anonymous_block_A_test_leak______2) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test_leak______2); [line 30]\n n$7=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test_leak______2 ):unsigned long ) [line 30]\n *&__objc_anonymous_block_A_test_leak______2:class __objc_anonymous_block_A_test_leak______2 =n$7 [line 30]\n n$8=*&#GB$A_test_leak_sharedInstance:struct objc_object * [line 30]\n *n$7.A_test_leak_sharedInstance:struct objc_object *=n$8 [line 30]\n (_fun___objc_anonymous_block_A_test_leak______2)() [line 30]\n REMOVE_TEMPS(n$7,n$8); [line 30]\n NULLIFY(&__objc_anonymous_block_A_test_leak______2,true); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 13 -> 9 ; -12 [label="12: BinaryOperatorStmt: Assign \n n$5=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 33]\n n$6=_fun_A_init(n$5:class A *) virtual [line 33]\n *&#GB$A_test_leak_sharedInstance:struct objc_object *=n$6 [line 33]\n REMOVE_TEMPS(n$5,n$6); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +12 [label="12: BinaryOperatorStmt: Assign \n n$5=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 31]\n n$6=_fun_A_init(n$5:class A *) virtual [line 31]\n *&#GB$A_test_leak_sharedInstance:struct objc_object *=n$6 [line 31]\n REMOVE_TEMPS(n$5,n$6); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit __objc_anonymous_block_A_test_leak______2 \n " color=yellow style=filled] -10 [label="10: Start __objc_anonymous_block_A_test_leak______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +10 [label="10: Start __objc_anonymous_block_A_test_leak______2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 30]\n " color=yellow style=filled] 10 -> 12 ; 9 [label="9: Exit A_test_leak \n " color=yellow style=filled] -8 [label="8: Start A_test_leak\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] +8 [label="8: Start A_test_leak\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled] 8 -> 13 ; -7 [label="7: Call (_fun___objc_anonymous_block_A_test______1) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test______1); [line 21]\n n$3=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test______1 ):unsigned long ) [line 21]\n *&__objc_anonymous_block_A_test______1:class __objc_anonymous_block_A_test______1 =n$3 [line 21]\n n$4=*&#GB$A_test_sharedInstance:struct objc_object * [line 21]\n *n$3.A_test_sharedInstance:struct objc_object *=n$4 [line 21]\n (_fun___objc_anonymous_block_A_test______1)() [line 21]\n REMOVE_TEMPS(n$3,n$4); [line 21]\n " shape="box"] +7 [label="7: Call (_fun___objc_anonymous_block_A_test______1) \n DECLARE_LOCALS(&__objc_anonymous_block_A_test______1); [line 20]\n n$3=_fun___objc_alloc_no_fail(sizeof(class __objc_anonymous_block_A_test______1 ):unsigned long ) [line 20]\n *&__objc_anonymous_block_A_test______1:class __objc_anonymous_block_A_test______1 =n$3 [line 20]\n n$4=*&#GB$A_test_sharedInstance:struct objc_object * [line 20]\n *n$3.A_test_sharedInstance:struct objc_object *=n$4 [line 20]\n (_fun___objc_anonymous_block_A_test______1)() [line 20]\n REMOVE_TEMPS(n$3,n$4); [line 20]\n " shape="box"] 7 -> 3 ; -6 [label="6: BinaryOperatorStmt: Assign \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 22]\n n$2=_fun_A_init(n$1:class A *) virtual [line 22]\n *&#GB$A_test_sharedInstance:struct objc_object *=n$2 [line 22]\n REMOVE_TEMPS(n$1,n$2); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 21]\n n$2=_fun_A_init(n$1:class A *) virtual [line 21]\n *&#GB$A_test_sharedInstance:struct objc_object *=n$2 [line 21]\n REMOVE_TEMPS(n$1,n$2); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit __objc_anonymous_block_A_test______1 \n " color=yellow style=filled] -4 [label="4: Start __objc_anonymous_block_A_test______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +4 [label="4: Start __objc_anonymous_block_A_test______1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&#GB$A_test_sharedInstance:struct objc_object * [line 26]\n *&return:struct objc_object *=n$0 [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n NULLIFY(&__objc_anonymous_block_A_test______1,true); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$A_test_sharedInstance:struct objc_object * [line 25]\n *&return:struct objc_object *=n$0 [line 25]\n REMOVE_TEMPS(n$0); [line 25]\n NULLIFY(&__objc_anonymous_block_A_test______1,true); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/block/static.m b/infer/tests/codetoanalyze/objc/frontend/block/static.m index fe1a47ac1..4eb159ceb 100644 --- a/infer/tests/codetoanalyze/objc/frontend/block/static.m +++ b/infer/tests/codetoanalyze/objc/frontend/block/static.m @@ -15,60 +15,46 @@ @implementation A -+ (instancetype)test -{ - static id sharedInstance; - ^{ - sharedInstance = [[self alloc] init]; - //return sharedInstance; - }(); - - return sharedInstance; -} - -+ (void)test_leak -{ - static id sharedInstance; - ^{ - sharedInstance = [[self alloc] init]; - //return sharedInstance; - }(); ++ (instancetype)test { + static id sharedInstance; + ^{ + sharedInstance = [[self alloc] init]; + // return sharedInstance; + }(); + return sharedInstance; } - -+ (instancetype)test2 -{ - static id sharedInstance; ++ (void)test_leak { + static id sharedInstance; + ^{ sharedInstance = [[self alloc] init]; - ^{ - //NSLog(@"Passing from block...\n"); - id p = sharedInstance; - }(); - - return sharedInstance; + // return sharedInstance; + }(); } ++ (instancetype)test2 { + static id sharedInstance; + sharedInstance = [[self alloc] init]; + ^{ + // NSLog(@"Passing from block...\n"); + id p = sharedInstance; + }(); + return sharedInstance; +} ++ (int)test3 { + static int i; -+ (int)test3 -{ - static int i; - - ^{ - // NSLog(@"Passing from block...\n"); - i++; - }(); + ^{ + // NSLog(@"Passing from block...\n"); + i++; + }(); - return i; + return i; } - @end - -int main(int argc, const char * argv[]) { - - return 0; -} +int main(int argc, const char* argv[]) { return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m index 9666b51bd..e8c59e174 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.m @@ -14,33 +14,34 @@ - (NSNumber*)getIntExp { int x = 4; int y = 5; - NSNumber *n = [NSNumber numberWithInt: x+y]; - return @(x+y); + NSNumber* n = [NSNumber numberWithInt:x + y]; + return @(x + y); } - (NSNumber*)getInt { - NSNumber *n = [NSNumber numberWithInt: 5]; + NSNumber* n = [NSNumber numberWithInt:5]; return @5; } - (NSNumber*)getFloat { - NSNumber *n = [NSNumber numberWithFloat: 1.5f]; + NSNumber* n = [NSNumber numberWithFloat:1.5f]; return @1.5f; } - (NSNumber*)getDouble { - NSNumber *n = [NSNumber numberWithDouble: 1.5]; + NSNumber* n = [NSNumber numberWithDouble:1.5]; return @1.5; } - (NSNumber*)getBool { - NSNumber *n = [NSNumber numberWithBool: YES]; + NSNumber* n = [NSNumber numberWithBool:YES]; return @YES; } -- (NSString*)getS{ - NSString *s = @(strdup("hello world")) ; - return [NSString stringWithUTF8String: "hello world"];; +- (NSString*)getS { + NSString* s = @(strdup("hello world")); + return [NSString stringWithUTF8String:"hello world"]; + ; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/array.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/array.dot index 76749b048..b223aa303 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/array.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/array.dot @@ -1,33 +1,33 @@ digraph iCFG { -12 [label="12: DeclStmt \n n$9=_fun_NSString_stringWithUTF8String:(\"Mercedes-Benz\":char *) [line 18]\n n$10=_fun_NSString_stringWithUTF8String:(\"BMW\":char *) [line 18]\n n$11=_fun_NSString_stringWithUTF8String:(\"Porsche\":char *) [line 18]\n n$12=_fun_NSString_stringWithUTF8String:(\"Opel\":char *) [line 19]\n n$13=_fun_NSString_stringWithUTF8String:(\"Volkswagen\":char *) [line 19]\n n$14=_fun_NSString_stringWithUTF8String:(\"Audi\":char *) [line 19]\n n$15=_fun_NSArray_arrayWithObjects:count:(n$9:struct objc_object *,n$10:struct objc_object *,n$11:struct objc_object *,n$12:struct objc_object *,n$13:struct objc_object *,n$14:struct objc_object *,0:struct objc_object *) [line 18]\n *&germanCars:class NSArray *=n$15 [line 18]\n REMOVE_TEMPS(n$9,n$10,n$11,n$12,n$13,n$14,n$15); [line 18]\n " shape="box"] +12 [label="12: DeclStmt \n n$9=_fun_NSString_stringWithUTF8String:(\"Mercedes-Benz\":char *) [line 17]\n n$10=_fun_NSString_stringWithUTF8String:(\"BMW\":char *) [line 18]\n n$11=_fun_NSString_stringWithUTF8String:(\"Porsche\":char *) [line 19]\n n$12=_fun_NSString_stringWithUTF8String:(\"Opel\":char *) [line 20]\n n$13=_fun_NSString_stringWithUTF8String:(\"Volkswagen\":char *) [line 21]\n n$14=_fun_NSString_stringWithUTF8String:(\"Audi\":char *) [line 22]\n n$15=_fun_NSArray_arrayWithObjects:count:(n$9:struct objc_object *,n$10:struct objc_object *,n$11:struct objc_object *,n$12:struct objc_object *,n$13:struct objc_object *,n$14:struct objc_object *,0:struct objc_object *) [line 16]\n *&germanCars:class NSArray *=n$15 [line 16]\n REMOVE_TEMPS(n$9,n$10,n$11,n$12,n$13,n$14,n$15); [line 16]\n " shape="box"] 12 -> 11 ; -11 [label="11: BinaryOperatorStmt: Assign \n n$7=*&germanCars:class NSArray * [line 20]\n n$8=_fun_NSArray_objectAtIndexedSubscript:(n$7:class NSArray *,3:unsigned long ) virtual [line 20]\n *&s:class NSString *=n$8 [line 20]\n REMOVE_TEMPS(n$7,n$8); [line 20]\n NULLIFY(&s,false); [line 20]\n " shape="box"] +11 [label="11: BinaryOperatorStmt: Assign \n n$7=*&germanCars:class NSArray * [line 24]\n n$8=_fun_NSArray_objectAtIndexedSubscript:(n$7:class NSArray *,3:unsigned long ) virtual [line 24]\n *&s:class NSString *=n$8 [line 24]\n REMOVE_TEMPS(n$7,n$8); [line 24]\n NULLIFY(&s,false); [line 24]\n " shape="box"] 11 -> 10 ; -10 [label="10: BinaryOperatorStmt: Assign \n n$5=*&germanCars:class NSArray * [line 22]\n n$6=_fun_NSArray_nextObject(n$5:class NSArray *) virtual [line 22]\n *&item:class NSString *=n$6 [line 22]\n REMOVE_TEMPS(n$5,n$6); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +10 [label="10: BinaryOperatorStmt: Assign \n n$5=*&germanCars:class NSArray * [line 26]\n n$6=_fun_NSArray_nextObject(n$5:class NSArray *) virtual [line 26]\n *&item:class NSString *=n$6 [line 26]\n REMOVE_TEMPS(n$5,n$6); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 10 -> 4 ; -9 [label="9: Call _fun_NSLog \n n$3=_fun_NSString_stringWithUTF8String:(\"%@\":char *) [line 23]\n n$4=*&item:class NSString * [line 23]\n _fun_NSLog(n$3:struct objc_object *,n$4:class NSString *) [line 23]\n REMOVE_TEMPS(n$3,n$4); [line 23]\n NULLIFY(&item,false); [line 23]\n " shape="box"] +9 [label="9: Call _fun_NSLog \n n$3=_fun_NSString_stringWithUTF8String:(\"%@\":char *) [line 27]\n n$4=*&item:class NSString * [line 27]\n _fun_NSLog(n$3:struct objc_object *,n$4:class NSString *) [line 27]\n REMOVE_TEMPS(n$3,n$4); [line 27]\n NULLIFY(&item,false); [line 27]\n " shape="box"] 9 -> 8 ; -8 [label="8: BinaryOperatorStmt: Assign \n n$1=*&germanCars:class NSArray * [line 22]\n n$2=_fun_NSArray_nextObject(n$1:class NSArray *) virtual [line 22]\n *&item:class NSString *=n$2 [line 22]\n REMOVE_TEMPS(n$1,n$2); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +8 [label="8: BinaryOperatorStmt: Assign \n n$1=*&germanCars:class NSArray * [line 26]\n n$2=_fun_NSArray_nextObject(n$1:class NSArray *) virtual [line 26]\n *&item:class NSString *=n$2 [line 26]\n REMOVE_TEMPS(n$1,n$2); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 8 -> 4 ; -7 [label="7: Prune (false branch) \n PRUNE(((n$0 != 0) == 0), false); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] +7 [label="7: Prune (false branch) \n PRUNE(((n$0 != 0) == 0), false); [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n " shape="invhouse"] 7 -> 3 ; -6 [label="6: Prune (true branch) \n PRUNE(((n$0 != 0) != 0), true); [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n " shape="invhouse"] +6 [label="6: Prune (true branch) \n PRUNE(((n$0 != 0) != 0), true); [line 26]\n REMOVE_TEMPS(n$0); [line 26]\n " shape="invhouse"] 6 -> 9 ; -5 [label="5: BinaryOperatorStmt: NE \n n$0=*&item:class NSString * [line 22]\n " shape="box"] +5 [label="5: BinaryOperatorStmt: NE \n n$0=*&item:class NSString * [line 26]\n " shape="box"] 5 -> 6 ; @@ -36,14 +36,14 @@ digraph iCFG { 4 -> 5 ; -3 [label="3: Return Stmt \n NULLIFY(&germanCars,false); [line 26]\n NULLIFY(&item,false); [line 26]\n *&return:int =0 [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +3 [label="3: Return Stmt \n NULLIFY(&germanCars,false); [line 30]\n NULLIFY(&item,false); [line 30]\n *&return:int =0 [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit main \n " color=yellow style=filled] -1 [label="1: Start main\nFormals: \nLocals: item:class NSString * germanCars:class NSArray * s:class NSString * \n DECLARE_LOCALS(&return,&item,&germanCars,&s); [line 14]\n NULLIFY(&germanCars,false); [line 14]\n NULLIFY(&item,false); [line 14]\n NULLIFY(&s,false); [line 14]\n " color=yellow style=filled] +1 [label="1: Start main\nFormals: \nLocals: item:class NSString * germanCars:class NSArray * s:class NSString * \n DECLARE_LOCALS(&return,&item,&germanCars,&s); [line 12]\n NULLIFY(&germanCars,false); [line 12]\n NULLIFY(&item,false); [line 12]\n NULLIFY(&s,false); [line 12]\n " color=yellow style=filled] 1 -> 12 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/array.m b/infer/tests/codetoanalyze/objc/frontend/boxing/array.m index 6b8e83b4f..aa644b87d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/array.m +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/array.m @@ -7,22 +7,25 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import - - +#import int main() { - NSString *s; + NSString* s; - NSArray *germanCars = @[@"Mercedes-Benz", @"BMW", @"Porsche", - @"Opel", @"Volkswagen", @"Audi"]; + NSArray* germanCars = @[ + @"Mercedes-Benz", + @"BMW", + @"Porsche", + @"Opel", + @"Volkswagen", + @"Audi" + ]; s = germanCars[3]; - for (NSString *item in germanCars) { + for (NSString* item in germanCars) { NSLog(@"%@", item); } return 0; - } diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/array_literal.c b/infer/tests/codetoanalyze/objc/frontend/boxing/array_literal.c index 0e706ddfa..6f7304e72 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/array_literal.c +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/array_literal.c @@ -10,6 +10,6 @@ #import NSArray* get_array() { - NSArray *animals = [NSArray arrayWithObjects:@"cat", @"dog", nil]; - return @[@"cat", @"dog"]; + NSArray* animals = [NSArray arrayWithObjects:@"cat", @"dog", nil]; + return @[ @"cat", @"dog" ]; } diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.c b/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.c index 1a27dc526..78f9770fe 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.c +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.c @@ -7,18 +7,20 @@ * of patent rights can be found in the PATENTS file in the same directory. */ - - #import NSDictionary* get_array1() { - return [NSDictionary dictionaryWithObjectsAndKeys: - @"Matt", @"firstName", @"Galloway", @"lastName", - @28, @"age", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:@"Matt", + @"firstName", + @"Galloway", + @"lastName", + @28, + @"age", + nil]; } NSDictionary* get_array2() { - return @{@"firstName" : @"Matt", @"lastName" : @"Galloway", @"age" : @28}; + return @{ @"firstName" : @"Matt", @"lastName" : @"Galloway", @"age" : @28 }; } diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.dot index be0dbab1d..39b4a2e1f 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/dict_literal.dot @@ -1,23 +1,23 @@ digraph iCFG { -6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 23]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 23]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 23]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 23]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 23]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 23]\n n$6=_fun_NSDictionary___objc_dictionary_literal:(n$0:struct objc_object *,n$1:struct objc_object *,n$2:struct objc_object *,n$3:struct objc_object *,n$4:struct objc_object *,n$5:struct objc_object *,0:struct objc_object *) [line 23]\n *&return:class NSDictionary *=n$6 [line 23]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 25]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 25]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 25]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 25]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 25]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 25]\n n$6=_fun_NSDictionary___objc_dictionary_literal:(n$0:struct objc_object *,n$1:struct objc_object *,n$2:struct objc_object *,n$3:struct objc_object *,n$4:struct objc_object *,n$5:struct objc_object *,0:struct objc_object *) [line 25]\n *&return:class NSDictionary *=n$6 [line 25]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit get_array2 \n " color=yellow style=filled] -4 [label="4: Start get_array2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n " color=yellow style=filled] +4 [label="4: Start get_array2\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 17]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 17]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 17]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 17]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 18]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 18]\n n$6=_fun_NSDictionary_dictionaryWithObjectsAndKeys:(n$0:struct objc_object *,n$1:class NSString *,n$2:class NSString *,n$3:class NSString *,n$4:class NSNumber *,n$5:class NSString *,0:void *) [line 16]\n *&return:class NSDictionary *=n$6 [line 16]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Matt\":char *) [line 14]\n n$1=_fun_NSString_stringWithUTF8String:(\"firstName\":char *) [line 15]\n n$2=_fun_NSString_stringWithUTF8String:(\"Galloway\":char *) [line 16]\n n$3=_fun_NSString_stringWithUTF8String:(\"lastName\":char *) [line 17]\n n$4=_fun_NSNumber_numberWithInt:(28:int ) [line 18]\n n$5=_fun_NSString_stringWithUTF8String:(\"age\":char *) [line 19]\n n$6=_fun_NSDictionary_dictionaryWithObjectsAndKeys:(n$0:struct objc_object *,n$1:class NSString *,n$2:class NSString *,n$3:class NSString *,n$4:class NSNumber *,n$5:class NSString *,0:void *) [line 14]\n *&return:class NSDictionary *=n$6 [line 14]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit get_array1 \n " color=yellow style=filled] -1 [label="1: Start get_array1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +1 [label="1: Start get_array1\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c index 005dd1ea1..e7b6275d2 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.c @@ -11,10 +11,7 @@ NSString* get_string1() { - return [NSString stringWithUTF8String: "Hello World!" ]; + return [NSString stringWithUTF8String:"Hello World!"]; } -NSString* get_string2() { - - return @"Hello World!"; -} +NSString* get_string2() { return @"Hello World!"; } diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.dot index de9466ace..277a15461 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/string_literal.dot @@ -1,5 +1,5 @@ digraph iCFG { -6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Hello World!\":char *) [line 19]\n *&return:class NSString *=n$0 [line 19]\n REMOVE_TEMPS(n$0); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"] +6 [label="6: Return Stmt \n n$0=_fun_NSString_stringWithUTF8String:(\"Hello World!\":char *) [line 17]\n *&return:class NSString *=n$0 [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"] 6 -> 5 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.m b/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.m index e5e6e2f8a..e9936a03d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.m +++ b/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.m @@ -11,17 +11,17 @@ @interface A : NSObject --(int) test4:(int) x; +- (int)test4:(int)x; @end @implementation A --(int) test4:(int) x { - return x; +- (int)test4:(int)x { + return x; } --(int) test5:(BOOL) b { - return [self test4 : (b ? b : 1)]; +- (int)test5:(BOOL)b { + return [self test4:(b ? b : 1)]; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.dot b/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.dot index 10b92b0fa..e15622739 100644 --- a/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.dot +++ b/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.dot @@ -1,44 +1,44 @@ digraph iCFG { -11 [label="11: DeclStmt \n n$7=_fun___objc_alloc_no_fail(sizeof(class NSString ):unsigned long ) [line 31]\n *&s:class NSString *=n$7 [line 31]\n REMOVE_TEMPS(n$7); [line 31]\n " shape="box"] +11 [label="11: DeclStmt \n n$7=_fun___objc_alloc_no_fail(sizeof(class NSString ):unsigned long ) [line 28]\n *&s:class NSString *=n$7 [line 28]\n REMOVE_TEMPS(n$7); [line 28]\n " shape="box"] 11 -> 8 ; 11 -> 9 ; -10 [label="10: Return Stmt \n NULLIFY(&s,false); [line 33]\n n$4=_fun_NSString_stringWithUTF8String:(\"Something is not right exception\":char *) [line 33]\n n$5=_fun_NSString_stringWithUTF8String:(\"Can't perform this operation because of this or that\":char *) [line 34]\n n$6=_fun_NSException_exceptionWithName:reason:userInfo:(n$4:class NSString *,n$5:class NSString *,0:class NSDictionary *) [line 33]\n *&return:void =n$6 [line 33]\n REMOVE_TEMPS(n$4,n$5,n$6); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +10 [label="10: Return Stmt \n NULLIFY(&s,false); [line 30]\n n$4=_fun_NSString_stringWithUTF8String:(\"Something is not right exception\":char *) [line 31]\n n$5=_fun_NSString_stringWithUTF8String:(\"Can't perform this operation because of this or that\":char *) [line 33]\n n$6=_fun_NSException_exceptionWithName:reason:userInfo:(n$4:class NSString *,n$5:class NSString *,0:class NSDictionary *) [line 30]\n *&return:void =n$6 [line 30]\n REMOVE_TEMPS(n$4,n$5,n$6); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"] 10 -> 6 ; -9 [label="9: Prune (false branch) \n n$3=*&s:class NSString * [line 32]\n PRUNE((n$3 == 0), false); [line 32]\n REMOVE_TEMPS(n$3); [line 32]\n " shape="invhouse"] +9 [label="9: Prune (false branch) \n n$3=*&s:class NSString * [line 29]\n PRUNE((n$3 == 0), false); [line 29]\n REMOVE_TEMPS(n$3); [line 29]\n " shape="invhouse"] 9 -> 7 ; -8 [label="8: Prune (true branch) \n n$3=*&s:class NSString * [line 32]\n PRUNE((n$3 != 0), true); [line 32]\n REMOVE_TEMPS(n$3); [line 32]\n " shape="invhouse"] +8 [label="8: Prune (true branch) \n n$3=*&s:class NSString * [line 29]\n PRUNE((n$3 != 0), true); [line 29]\n REMOVE_TEMPS(n$3); [line 29]\n " shape="invhouse"] 8 -> 10 ; -7 [label="7: + \n NULLIFY(&s,false); [line 32]\n " ] +7 [label="7: + \n NULLIFY(&s,false); [line 29]\n " ] 7 -> 6 ; 6 [label="6: Exit ExceptionExample_test1 \n " color=yellow style=filled] -5 [label="5: Start ExceptionExample_test1\nFormals: self:class ExceptionExample *\nLocals: s:class NSString * \n DECLARE_LOCALS(&return,&s); [line 30]\n NULLIFY(&s,false); [line 30]\n NULLIFY(&self,false); [line 30]\n " color=yellow style=filled] +5 [label="5: Start ExceptionExample_test1\nFormals: self:class ExceptionExample *\nLocals: s:class NSString * \n DECLARE_LOCALS(&return,&s); [line 27]\n NULLIFY(&s,false); [line 27]\n NULLIFY(&self,false); [line 27]\n " color=yellow style=filled] 5 -> 11 ; -4 [label="4: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class NSString ):unsigned long ) [line 21]\n *&s:class NSString *=n$2 [line 21]\n REMOVE_TEMPS(n$2); [line 21]\n NULLIFY(&s,false); [line 21]\n " shape="box"] +4 [label="4: DeclStmt \n n$2=_fun___objc_alloc_no_fail(sizeof(class NSString ):unsigned long ) [line 20]\n *&s:class NSString *=n$2 [line 20]\n REMOVE_TEMPS(n$2); [line 20]\n NULLIFY(&s,false); [line 20]\n " shape="box"] 4 -> 3 ; -3 [label="3: Message Call: description \n n$0=*&self:class ExceptionExample * [line 26]\n n$1=_fun_ExceptionExample_description(n$0:class ExceptionExample *) [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&self,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"] +3 [label="3: Message Call: description \n n$0=*&self:class ExceptionExample * [line 23]\n n$1=_fun_ExceptionExample_description(n$0:class ExceptionExample *) [line 23]\n REMOVE_TEMPS(n$0,n$1); [line 23]\n NULLIFY(&self,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit ExceptionExample_test \n " color=yellow style=filled] -1 [label="1: Start ExceptionExample_test\nFormals: self:class ExceptionExample *\nLocals: s:class NSString * \n DECLARE_LOCALS(&return,&s); [line 19]\n NULLIFY(&s,false); [line 19]\n " color=yellow style=filled] +1 [label="1: Start ExceptionExample_test\nFormals: self:class ExceptionExample *\nLocals: s:class NSString * \n DECLARE_LOCALS(&return,&s); [line 18]\n NULLIFY(&s,false); [line 18]\n " color=yellow style=filled] 1 -> 4 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.m b/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.m index 7c6d7e88e..9c6bef3f1 100644 --- a/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.m +++ b/infer/tests/codetoanalyze/objc/frontend/exceptions/ExceptionExample.m @@ -13,28 +13,26 @@ @end - @implementation ExceptionExample --(void) test { - @try { - NSString *s = [NSString alloc]; - } - @catch (NSException *exception) { - } - @finally { - [self description]; - } +- (void)test { + @try { + NSString* s = [NSString alloc]; + } @catch (NSException* exception) { + } @finally { + [self description]; + } } --(void) test1 { - NSString *s = [NSString alloc]; - if (s) { - @throw [NSException exceptionWithName:@"Something is not right exception" - reason:@"Can't perform this operation because of this or that" - userInfo:nil]; - } - +- (void)test1 { + NSString* s = [NSString alloc]; + if (s) { + @throw [NSException + exceptionWithName:@"Something is not right exception" + reason: + @"Can't perform this operation because of this or that" + userInfo:nil]; + } } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m b/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m index 4a3797752..094112117 100644 --- a/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m +++ b/infer/tests/codetoanalyze/objc/frontend/fast_enumeration/Fast_enumeration.m @@ -14,21 +14,21 @@ @implementation A -- (int) fast_loop: (NSArray *) items { - int size = 0; - for (NSArray* item in items) { - size += [item count]; - } - return size; +- (int)fast_loop:(NSArray*)items { + int size = 0; + for (NSArray* item in items) { + size += [item count]; + } + return size; } -- (int) while_loop: (NSArray*) items { - int size = 0; - NSArray* item = nil; - while (item = [items nextObject]) { - size += [item count]; - } - return size; +- (int)while_loop:(NSArray*)items { + int size = 0; + NSArray* item = nil; + while (item = [items nextObject]) { + size += [item count]; + } + return size; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/predefined_expr/PredefinedExprExample.m b/infer/tests/codetoanalyze/objc/frontend/predefined_expr/PredefinedExprExample.m index e6a9ecf5c..69130b71f 100644 --- a/infer/tests/codetoanalyze/objc/frontend/predefined_expr/PredefinedExprExample.m +++ b/infer/tests/codetoanalyze/objc/frontend/predefined_expr/PredefinedExprExample.m @@ -15,16 +15,16 @@ @implementation A -- (void) testPrettyFunction { - NSLog(@"%s", __PRETTY_FUNCTION__); +- (void)testPrettyFunction { + NSLog(@"%s", __PRETTY_FUNCTION__); } -- (void) testFunction { - NSLog(@"%s", __FUNCTION__); +- (void)testFunction { + NSLog(@"%s", __FUNCTION__); } -- (void) testFunct { - NSLog(@"%s", __func__); +- (void)testFunct { + NSLog(@"%s", __func__); } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyAttributes.m b/infer/tests/codetoanalyze/objc/frontend/property/PropertyAttributes.m index 4e789c4df..411d5f199 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyAttributes.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyAttributes.m @@ -11,32 +11,32 @@ @interface A : NSObject -@property (nonatomic, copy) A *child; +@property(nonatomic, copy) A* child; -@property (nonatomic, retain) A *name; +@property(nonatomic, retain) A* name; -@property (nonatomic, unsafe_unretained) A *last_name; +@property(nonatomic, unsafe_unretained) A* last_name; -- (A*) copy; +- (A*)copy; @end @implementation A -- (A*) copy { - A *other = [[A alloc] init]; - if (other) { - other->_name = self->_name; - other->_last_name = self->_last_name; - other->_child = self->_child; - } - return other; +- (A*)copy { + A* other = [[A alloc] init]; + if (other) { + other->_name = self->_name; + other->_last_name = self->_last_name; + other->_child = self->_child; + } + return other; } @end int test(A* a2) { - A *a = [[A alloc] init]; + A* a = [[A alloc] init]; a.last_name = a2; [a release]; return 0; diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.m b/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.m index cfecd3261..cd40efc8b 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.m @@ -11,12 +11,10 @@ @interface ASDisplayNode : NSObject -@property (atomic, getter=isOpaque) BOOL opaque; +@property(atomic, getter=isOpaque) BOOL opaque; @end - @implementation ASDisplayNode - @end diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.dot b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.dot index 19f8877e6..180f1661b 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.dot +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.dot @@ -1,5 +1,5 @@ digraph iCFG { -3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:class PropertyImplSetter * [line 16]\n *n$0._maximumFileSize:int =0 [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&self,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"] +3 [label="3: BinaryOperatorStmt: Assign \n n$0=*&self:class PropertyImplSetter * [line 15]\n *n$0._maximumFileSize:int =0 [line 15]\n REMOVE_TEMPS(n$0); [line 15]\n NULLIFY(&self,false); [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.h b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.h index 58dbef82b..86c9aacdb 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.h +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.h @@ -11,6 +11,6 @@ @interface PropertyImplSetter : NSObject -@property (nonatomic) int maximumFileSize; +@property(nonatomic) int maximumFileSize; @end diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.m b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.m index d3dbca5f8..6c8d76480 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyImplSetter.m @@ -11,9 +11,8 @@ @implementation PropertyImplSetter -- (void)setMaximumFileSize:(int)newMaximumFileSize -{ - _maximumFileSize = 0; +- (void)setMaximumFileSize:(int)newMaximumFileSize { + _maximumFileSize = 0; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/property/Property_getter.m b/infer/tests/codetoanalyze/objc/frontend/property/Property_getter.m index a09806b92..d8f0ebc7c 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/Property_getter.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/Property_getter.m @@ -16,7 +16,7 @@ @implementation A - (int)addTarget:(A*)target { - return target.x; + return target.x; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/property/aclass.m b/infer/tests/codetoanalyze/objc/frontend/property/aclass.m index a3c5cc8c1..0c0c20b86 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/aclass.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/aclass.m @@ -10,10 +10,9 @@ #import @interface AClass : NSObject - @property (nonatomic, strong) NSObject* aDynValue; +@property(nonatomic, strong) NSObject* aDynValue; @end - @implementation AClass @dynamic aDynValue; diff --git a/infer/tests/codetoanalyze/objc/frontend/property/main_car.m b/infer/tests/codetoanalyze/objc/frontend/property/main_car.m index 475b21318..981d1430b 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/main_car.m +++ b/infer/tests/codetoanalyze/objc/frontend/property/main_car.m @@ -10,8 +10,8 @@ #import "Car.h" int main() { - Car *honda = [[Car alloc] init]; - honda.running = YES; - NSLog(@"%d", honda.running); + Car* honda = [[Car alloc] init]; + honda.running = YES; + NSLog(@"%d", honda.running); return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/MyProtocol.h b/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/MyProtocol.h index f449ebd6c..065e8b1c3 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/MyProtocol.h +++ b/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/MyProtocol.h @@ -9,7 +9,7 @@ #import -@protocol MyProtocol +@protocol MyProtocol @property int numberOfFiles; diff --git a/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/Test.h b/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/Test.h index 1251df592..ddaec15c5 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/Test.h +++ b/infer/tests/codetoanalyze/objc/frontend/property_in_protocol/Test.h @@ -7,13 +7,12 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import #import "MyProtocol.h" +#import @interface Test : NSObject { - int numberOfFiles; - + int numberOfFiles; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.dot b/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.dot index c5038b7e9..3e8646cac 100644 --- a/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.dot +++ b/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.dot @@ -1,17 +1,17 @@ digraph iCFG { -7 [label="7: Return Stmt \n APPLY_ABSTRACTION; [line 27]\n " shape="box"] +7 [label="7: Return Stmt \n APPLY_ABSTRACTION; [line 26]\n " shape="box"] 7 -> 2 ; -6 [label="6: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n " shape="invhouse"] +6 [label="6: Prune (false branch) \n PRUNE((n$1 == 0), false); [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n " shape="invhouse"] 6 -> 3 ; -5 [label="5: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n " shape="invhouse"] +5 [label="5: Prune (true branch) \n PRUNE((n$1 != 0), true); [line 25]\n REMOVE_TEMPS(n$0,n$1); [line 25]\n " shape="invhouse"] 5 -> 7 ; -4 [label="4: Message Call: conformsToProtocol: \n n$0=*&self:class Bla * [line 26]\n n$1=_fun_Bla_conformsToProtocol:(n$0:class Bla *,\"Foo\":class Protocol *) virtual [line 26]\n NULLIFY(&self,false); [line 26]\n " shape="box"] +4 [label="4: Message Call: conformsToProtocol: \n n$0=*&self:class Bla * [line 25]\n n$1=_fun_Bla_conformsToProtocol:(n$0:class Bla *,\"Foo\":class Protocol *) virtual [line 25]\n NULLIFY(&self,false); [line 25]\n " shape="box"] 4 -> 5 ; @@ -23,7 +23,7 @@ digraph iCFG { 2 [label="2: Exit Bla_fooMethod \n " color=yellow style=filled] -1 [label="1: Start Bla_fooMethod\nFormals: self:class Bla *\nLocals: \n DECLARE_LOCALS(&return); [line 25]\n " color=yellow style=filled] +1 [label="1: Start Bla_fooMethod\nFormals: self:class Bla *\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled] 1 -> 4 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.m b/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.m index 4a49c297f..081b3138e 100644 --- a/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.m +++ b/infer/tests/codetoanalyze/objc/frontend/protocol/protocol.m @@ -7,20 +7,19 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import +#import @protocol Foo - (void)fooMethod; - @property (retain) NSString *foo; +@property(retain) NSString* foo; @end - -@interface Bla: NSObject +@interface Bla : NSObject - (void)fooMethod; @end -@implementation Bla: NSObject +@implementation Bla : NSObject - (void)fooMethod { if ([self conformsToProtocol:@protocol(Foo)]) { diff --git a/infer/tests/codetoanalyze/objc/frontend/returnstmt/void_return.m b/infer/tests/codetoanalyze/objc/frontend/returnstmt/void_return.m index 19a7d1910..28a818341 100644 --- a/infer/tests/codetoanalyze/objc/frontend/returnstmt/void_return.m +++ b/infer/tests/codetoanalyze/objc/frontend/returnstmt/void_return.m @@ -15,16 +15,16 @@ @implementation MyClass -- (void) aMethod { - int i = 0; - int j = 0; - if (i == 0) { - return; - } +- (void)aMethod { + int i = 0; + int j = 0; + if (i == 0) { + return; + } - if(j == 0) { - i++; - } + if (j == 0) { + i++; + } } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot index caad30080..4a786f36d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot +++ b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot @@ -1,183 +1,183 @@ digraph iCFG { -51 [label="51: Return Stmt \n *&return:int =0 [line 99]\n APPLY_ABSTRACTION; [line 99]\n " shape="box"] +51 [label="51: Return Stmt \n *&return:int =0 [line 98]\n APPLY_ABSTRACTION; [line 98]\n " shape="box"] 51 -> 45 ; -50 [label="50: Return Stmt \n *&return:int =1 [line 98]\n APPLY_ABSTRACTION; [line 98]\n " shape="box"] +50 [label="50: Return Stmt \n *&return:int =1 [line 96]\n APPLY_ABSTRACTION; [line 96]\n " shape="box"] 50 -> 45 ; -49 [label="49: Prune (false branch) \n PRUNE(((sizeof(class A ) != n$15) == 0), false); [line 98]\n REMOVE_TEMPS(n$15); [line 98]\n " shape="invhouse"] +49 [label="49: Prune (false branch) \n PRUNE(((sizeof(class A ) != n$15) == 0), false); [line 95]\n REMOVE_TEMPS(n$15); [line 95]\n " shape="invhouse"] 49 -> 51 ; -48 [label="48: Prune (true branch) \n PRUNE(((sizeof(class A ) != n$15) != 0), true); [line 98]\n REMOVE_TEMPS(n$15); [line 98]\n " shape="invhouse"] +48 [label="48: Prune (true branch) \n PRUNE(((sizeof(class A ) != n$15) != 0), true); [line 95]\n REMOVE_TEMPS(n$15); [line 95]\n " shape="invhouse"] 48 -> 50 ; -47 [label="47: BinaryOperatorStmt: NE \n n$15=*&c:struct objc_class * [line 98]\n NULLIFY(&c,false); [line 98]\n " shape="box"] +47 [label="47: BinaryOperatorStmt: NE \n n$15=*&c:struct objc_class * [line 95]\n NULLIFY(&c,false); [line 95]\n " shape="box"] 47 -> 48 ; 47 -> 49 ; -46 [label="46: + \n NULLIFY(&c,false); [line 98]\n " ] +46 [label="46: + \n NULLIFY(&c,false); [line 95]\n " ] 46 -> 45 ; 45 [label="45: Exit A_used_in_binary_op: \n " color=yellow style=filled] -44 [label="44: Start A_used_in_binary_op:\nFormals: c:struct objc_class *\nLocals: \n DECLARE_LOCALS(&return); [line 96]\n " color=yellow style=filled] +44 [label="44: Start A_used_in_binary_op:\nFormals: c:struct objc_class *\nLocals: \n DECLARE_LOCALS(&return); [line 94]\n " color=yellow style=filled] 44 -> 47 ; -43 [label="43: Return Stmt \n n$14=_fun_NSStringFromClass(sizeof(class A ):unsigned long ) [line 93]\n *&return:class NSString *=n$14 [line 93]\n REMOVE_TEMPS(n$14); [line 93]\n APPLY_ABSTRACTION; [line 93]\n " shape="box"] +43 [label="43: Return Stmt \n n$14=_fun_NSStringFromClass(sizeof(class A ):unsigned long ) [line 91]\n *&return:class NSString *=n$14 [line 91]\n REMOVE_TEMPS(n$14); [line 91]\n APPLY_ABSTRACTION; [line 91]\n " shape="box"] 43 -> 42 ; 42 [label="42: Exit A_loggerName \n " color=yellow style=filled] -41 [label="41: Start A_loggerName\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 91]\n NULLIFY(&self,false); [line 91]\n " color=yellow style=filled] +41 [label="41: Start A_loggerName\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 90]\n NULLIFY(&self,false); [line 90]\n " color=yellow style=filled] 41 -> 43 ; -40 [label="40: Message Call: init \n n$11=*&self:class A * [line 88]\n n$12=_fun_NSObject_init(n$11:class A *) [line 88]\n REMOVE_TEMPS(n$11,n$12); [line 88]\n NULLIFY(&self,false); [line 88]\n APPLY_ABSTRACTION; [line 88]\n " shape="box"] +40 [label="40: Message Call: init \n n$11=*&self:class A * [line 87]\n n$12=_fun_NSObject_init(n$11:class A *) [line 87]\n REMOVE_TEMPS(n$11,n$12); [line 87]\n NULLIFY(&self,false); [line 87]\n APPLY_ABSTRACTION; [line 87]\n " shape="box"] 40 -> 39 ; 39 [label="39: Exit A_init \n " color=yellow style=filled] -38 [label="38: Start A_init\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 87]\n " color=yellow style=filled] +38 [label="38: Start A_init\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 86]\n " color=yellow style=filled] 38 -> 40 ; -37 [label="37: Message Call: test_class \n _fun_C_test_class() [line 84]\n APPLY_ABSTRACTION; [line 84]\n " shape="box"] +37 [label="37: Message Call: test_class \n _fun_C_test_class() [line 83]\n APPLY_ABSTRACTION; [line 83]\n " shape="box"] 37 -> 36 ; 36 [label="36: Exit A_calling_super \n " color=yellow style=filled] -35 [label="35: Start A_calling_super\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 83]\n " color=yellow style=filled] +35 [label="35: Start A_calling_super\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 82]\n " color=yellow style=filled] 35 -> 37 ; -34 [label="34: Return Stmt \n n$8=*&object:class B * [line 80]\n n$10=_fun_B_isC:(n$8:class B *,sizeof(class A ):unsigned long ) virtual [line 80]\n *&return:_Bool =n$10 [line 80]\n REMOVE_TEMPS(n$8,n$10); [line 80]\n NULLIFY(&object,false); [line 80]\n APPLY_ABSTRACTION; [line 80]\n " shape="box"] +34 [label="34: Return Stmt \n n$8=*&object:class B * [line 79]\n n$10=_fun_B_isC:(n$8:class B *,sizeof(class A ):unsigned long ) virtual [line 79]\n *&return:_Bool =n$10 [line 79]\n REMOVE_TEMPS(n$8,n$10); [line 79]\n NULLIFY(&object,false); [line 79]\n APPLY_ABSTRACTION; [line 79]\n " shape="box"] 34 -> 33 ; 33 [label="33: Exit A_use_class_in_other_ways: \n " color=yellow style=filled] -32 [label="32: Start A_use_class_in_other_ways:\nFormals: self:class A * object:class B *\nLocals: \n DECLARE_LOCALS(&return); [line 79]\n NULLIFY(&self,false); [line 79]\n " color=yellow style=filled] +32 [label="32: Start A_use_class_in_other_ways:\nFormals: self:class A * object:class B *\nLocals: \n DECLARE_LOCALS(&return); [line 78]\n NULLIFY(&self,false); [line 78]\n " color=yellow style=filled] 32 -> 34 ; -31 [label="31: DeclStmt \n n$6=_fun___objc_alloc_no_fail(sizeof(class B ):unsigned long ) [line 75]\n n$7=_fun_NSObject_init(n$6:class B *) virtual [line 75]\n *&b:class B *=n$7 [line 75]\n REMOVE_TEMPS(n$6,n$7); [line 75]\n NULLIFY(&b,false); [line 75]\n " shape="box"] +31 [label="31: DeclStmt \n n$6=_fun___objc_alloc_no_fail(sizeof(class B ):unsigned long ) [line 74]\n n$7=_fun_NSObject_init(n$6:class B *) virtual [line 74]\n *&b:class B *=n$7 [line 74]\n REMOVE_TEMPS(n$6,n$7); [line 74]\n NULLIFY(&b,false); [line 74]\n " shape="box"] 31 -> 30 ; -30 [label="30: Message Call: b_m \n _fun_B_b_m() [line 76]\n APPLY_ABSTRACTION; [line 76]\n " shape="box"] +30 [label="30: Message Call: b_m \n _fun_B_b_m() [line 75]\n APPLY_ABSTRACTION; [line 75]\n " shape="box"] 30 -> 29 ; 29 [label="29: Exit A_t \n " color=yellow style=filled] -28 [label="28: Start A_t\nFormals: self:class A *\nLocals: b:class B * \n DECLARE_LOCALS(&return,&b); [line 74]\n NULLIFY(&b,false); [line 74]\n NULLIFY(&self,false); [line 74]\n " color=yellow style=filled] +28 [label="28: Start A_t\nFormals: self:class A *\nLocals: b:class B * \n DECLARE_LOCALS(&return,&b); [line 73]\n NULLIFY(&b,false); [line 73]\n NULLIFY(&self,false); [line 73]\n " color=yellow style=filled] 28 -> 31 ; -27 [label="27: Message Call: test_class \n _fun_A_test_class() [line 71]\n APPLY_ABSTRACTION; [line 71]\n " shape="box"] +27 [label="27: Message Call: test_class \n _fun_A_test_class() [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 27 -> 26 ; 26 [label="26: Exit A_call_class_instance_with_class_name \n " color=yellow style=filled] -25 [label="25: Start A_call_class_instance_with_class_name\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 70]\n NULLIFY(&self,false); [line 70]\n " color=yellow style=filled] +25 [label="25: Start A_call_class_instance_with_class_name\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 69]\n NULLIFY(&self,false); [line 69]\n " color=yellow style=filled] 25 -> 27 ; -24 [label="24: Message Call: test_class \n _fun_A_test_class() [line 67]\n APPLY_ABSTRACTION; [line 67]\n " shape="box"] +24 [label="24: Message Call: test_class \n _fun_A_test_class() [line 66]\n APPLY_ABSTRACTION; [line 66]\n " shape="box"] 24 -> 23 ; 23 [label="23: Exit A_call_class_instance \n " color=yellow style=filled] -22 [label="22: Start A_call_class_instance\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 66]\n NULLIFY(&self,false); [line 66]\n " color=yellow style=filled] +22 [label="22: Start A_call_class_instance\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 65]\n NULLIFY(&self,false); [line 65]\n " color=yellow style=filled] 22 -> 24 ; -21 [label="21: Call alloc \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 63]\n REMOVE_TEMPS(n$3); [line 63]\n APPLY_ABSTRACTION; [line 63]\n " shape="box"] +21 [label="21: Call alloc \n n$3=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 62]\n REMOVE_TEMPS(n$3); [line 62]\n APPLY_ABSTRACTION; [line 62]\n " shape="box"] 21 -> 20 ; 20 [label="20: Exit A_call_alloc_instance \n " color=yellow style=filled] -19 [label="19: Start A_call_alloc_instance\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 62]\n NULLIFY(&self,false); [line 62]\n " color=yellow style=filled] +19 [label="19: Start A_call_alloc_instance\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 61]\n NULLIFY(&self,false); [line 61]\n " color=yellow style=filled] 19 -> 21 ; -18 [label="18: Call alloc \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 59]\n REMOVE_TEMPS(n$1); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"] +18 [label="18: Call alloc \n n$1=_fun___objc_alloc_no_fail(sizeof(class A ):unsigned long ) [line 58]\n REMOVE_TEMPS(n$1); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"] 18 -> 17 ; 17 [label="17: Exit A_call_alloc_class \n " color=yellow style=filled] -16 [label="16: Start A_call_alloc_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 58]\n " color=yellow style=filled] +16 [label="16: Start A_call_alloc_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 57]\n " color=yellow style=filled] 16 -> 18 ; -15 [label="15: Message Call: test_class \n _fun_A_test_class() [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"] +15 [label="15: Message Call: test_class \n _fun_A_test_class() [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit A_call_test_class \n " color=yellow style=filled] -13 [label="13: Start A_call_test_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 54]\n " color=yellow style=filled] +13 [label="13: Start A_call_test_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 53]\n " color=yellow style=filled] 13 -> 15 ; 12 [label="12: Exit A_test_class \n " color=yellow style=filled] -11 [label="11: Start A_test_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 51]\n " color=yellow style=filled] +11 [label="11: Start A_test_class\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 50]\n " color=yellow style=filled] 11 -> 12 ; -10 [label="10: Message Call: test \n n$0=*&self:class A * [line 48]\n _fun_A_test(n$0:class A *) virtual [line 48]\n REMOVE_TEMPS(n$0); [line 48]\n NULLIFY(&self,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] +10 [label="10: Message Call: test \n n$0=*&self:class A * [line 47]\n _fun_A_test(n$0:class A *) virtual [line 47]\n REMOVE_TEMPS(n$0); [line 47]\n NULLIFY(&self,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"] 10 -> 9 ; 9 [label="9: Exit A_call_test \n " color=yellow style=filled] -8 [label="8: Start A_call_test\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 47]\n " color=yellow style=filled] +8 [label="8: Start A_call_test\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 46]\n " color=yellow style=filled] 8 -> 10 ; 7 [label="7: Exit A_test \n " color=yellow style=filled] -6 [label="6: Start A_test\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 42]\n NULLIFY(&self,false); [line 42]\n " color=yellow style=filled] +6 [label="6: Start A_test\nFormals: self:class A *\nLocals: \n DECLARE_LOCALS(&return); [line 43]\n NULLIFY(&self,false); [line 43]\n " color=yellow style=filled] 6 -> 7 ; -5 [label="5: Return Stmt \n *&return:_Bool =1 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +5 [label="5: Return Stmt \n *&return:_Bool =1 [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 5 -> 4 ; 4 [label="4: Exit B_isC: \n " color=yellow style=filled] -3 [label="3: Start B_isC:\nFormals: self:class B * aClass:struct objc_class *\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n NULLIFY(&aClass,false); [line 22]\n NULLIFY(&self,false); [line 22]\n " color=yellow style=filled] +3 [label="3: Start B_isC:\nFormals: self:class B * aClass:struct objc_class *\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n NULLIFY(&aClass,false); [line 23]\n NULLIFY(&self,false); [line 23]\n " color=yellow style=filled] 3 -> 5 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.m b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.m index 00198a2fb..9b13c1c49 100644 --- a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.m +++ b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.m @@ -17,19 +17,20 @@ @implementation B : NSObject -+(void) b_m {} ++ (void)b_m { +} - (BOOL)isC:(Class)aClass { - return TRUE; + return TRUE; } @end @interface C : NSObject --(void) test; +- (void)test; -+(void) test_class; ++ (void)test_class; @end @@ -39,63 +40,61 @@ @implementation A --(void) test { - +- (void)test { } - --(void) call_test { - [self test]; +- (void)call_test { + [self test]; } -+(void) test_class { ++ (void)test_class { } -+(void) call_test_class { - [self test_class]; ++ (void)call_test_class { + [self test_class]; } -+(void) call_alloc_class { - [self alloc]; ++ (void)call_alloc_class { + [self alloc]; } --(void) call_alloc_instance { - [[self class] alloc]; +- (void)call_alloc_instance { + [[self class] alloc]; } --(void) call_class_instance { - [[self class] test_class]; +- (void)call_class_instance { + [[self class] test_class]; } --(void) call_class_instance_with_class_name { - [A test_class]; +- (void)call_class_instance_with_class_name { + [A test_class]; } --(void) t { - B *b = [B new]; - [[b class] b_m]; +- (void)t { + B* b = [B new]; + [[b class] b_m]; } --(BOOL) use_class_in_other_ways:(B*) object { - return [object isC:[self class]]; +- (BOOL)use_class_in_other_ways:(B*)object { + return [object isC:[self class]]; } -+(void) calling_super { - [super test_class]; ++ (void)calling_super { + [super test_class]; } --(void) init { - [super init]; +- (void)init { + [super init]; } -- (NSString *)loggerName -{ - return NSStringFromClass([self class]); +- (NSString*)loggerName { + return NSStringFromClass([self class]); } -+ (int)used_in_binary_op:(Class) c -{ - if (self != c) {return 1;} - else return 0; ++ (int)used_in_binary_op:(Class)c { + if (self != c) { + return 1; + } else + return 0; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/self_static/static.m b/infer/tests/codetoanalyze/objc/frontend/self_static/static.m index 727af819e..1cad34c80 100644 --- a/infer/tests/codetoanalyze/objc/frontend/self_static/static.m +++ b/infer/tests/codetoanalyze/objc/frontend/self_static/static.m @@ -13,27 +13,27 @@ + (void)aClassMethod; - (void)anInstanceMethod; + (void)aClassMethod2; -- (int) getX; +- (int)getX; @end @implementation MyClass + (void)aClassMethod { - MyClass *myClass = [self alloc]; + MyClass* myClass = [self alloc]; } - (void)anInstanceMethod { - [MyClass aClassMethod]; + [MyClass aClassMethod]; } + (void)aClassMethod2 { - [self aClassMethod]; + [self aClassMethod]; } -- (int) getX { - return 0; +- (int)getX { + return 0; } - (void)anInstanceMethod2 { - [self getX]; + [self getX]; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.dot b/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.dot index 667f0b00e..d51309e85 100644 --- a/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.dot +++ b/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.dot @@ -1,5 +1,5 @@ digraph iCFG { -3 [label="3: Return Stmt \n *&return:int =0 [line 15]\n APPLY_ABSTRACTION; [line 15]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.m b/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.m index 1dee1acee..9d3f71bf1 100644 --- a/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.m +++ b/infer/tests/codetoanalyze/objc/frontend/strings/global_string_literal.m @@ -9,8 +9,6 @@ #import -NSString *lastName = @"Rodriguez"; +NSString* lastName = @"Rodriguez"; -int main () { - return 0; -} +int main() { return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/strings/string_literal.m b/infer/tests/codetoanalyze/objc/frontend/strings/string_literal.m index ec2ac291a..7737e1abb 100644 --- a/infer/tests/codetoanalyze/objc/frontend/strings/string_literal.m +++ b/infer/tests/codetoanalyze/objc/frontend/strings/string_literal.m @@ -9,7 +9,7 @@ #import -int main () { - NSString *lastName = @"Rodriguez"; +int main() { + NSString* lastName = @"Rodriguez"; return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/subclass/A.h b/infer/tests/codetoanalyze/objc/frontend/subclass/A.h index 101132ada..769880aaf 100644 --- a/infer/tests/codetoanalyze/objc/frontend/subclass/A.h +++ b/infer/tests/codetoanalyze/objc/frontend/subclass/A.h @@ -10,7 +10,7 @@ #import @interface A : NSObject { - int x; + int x; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/subclass/A.m b/infer/tests/codetoanalyze/objc/frontend/subclass/A.m index 52c87275e..67d6d6752 100644 --- a/infer/tests/codetoanalyze/objc/frontend/subclass/A.m +++ b/infer/tests/codetoanalyze/objc/frontend/subclass/A.m @@ -11,12 +11,11 @@ @implementation A --(instancetype) init -{ - if ([super self]) { - self->x = 10; - } - return self; +- (instancetype)init { + if ([super self]) { + self->x = 10; + } + return self; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/subclass/MyClass.h b/infer/tests/codetoanalyze/objc/frontend/subclass/MyClass.h index 91f536725..f071d734a 100644 --- a/infer/tests/codetoanalyze/objc/frontend/subclass/MyClass.h +++ b/infer/tests/codetoanalyze/objc/frontend/subclass/MyClass.h @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import +#import @interface MyClass : NSObject { } diff --git a/infer/tests/codetoanalyze/objc/frontend/subclass/MySubClass.m b/infer/tests/codetoanalyze/objc/frontend/subclass/MySubClass.m index d39cf6346..bb23490f3 100644 --- a/infer/tests/codetoanalyze/objc/frontend/subclass/MySubClass.m +++ b/infer/tests/codetoanalyze/objc/frontend/subclass/MySubClass.m @@ -14,7 +14,7 @@ - (int)myNumber { -int subclassNumber = [super myNumber] + 1; + int subclassNumber = [super myNumber] + 1; return subclassNumber; } diff --git a/infer/tests/codetoanalyze/objc/frontend/subclass/main.c b/infer/tests/codetoanalyze/objc/frontend/subclass/main.c index 75e70b03d..82d19029b 100644 --- a/infer/tests/codetoanalyze/objc/frontend/subclass/main.c +++ b/infer/tests/codetoanalyze/objc/frontend/subclass/main.c @@ -10,6 +10,6 @@ #import "A.h" int main() { - A* a = [[A alloc] init]; - return 0; + A* a = [[A alloc] init]; + return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/types/attributes.dot b/infer/tests/codetoanalyze/objc/frontend/types/attributes.dot index 53beff468..9869dc102 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/attributes.dot +++ b/infer/tests/codetoanalyze/objc/frontend/types/attributes.dot @@ -43,7 +43,7 @@ digraph iCFG { 4 -> 3 ; -3 [label="3: Return Stmt \n *&return:int =0 [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"] +3 [label="3: Return Stmt \n *&return:int =0 [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/types/attributes.m b/infer/tests/codetoanalyze/objc/frontend/types/attributes.m index 17ad5bf81..f660c3a05 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/attributes.m +++ b/infer/tests/codetoanalyze/objc/frontend/types/attributes.m @@ -17,28 +17,27 @@ @end -int main () { - - A * __weak aWeakRef =0; - A * __strong aStrongRef =0; - A * __unsafe_unretained anUnsafeUnretRef =0; - A * __autoreleasing anAutoRelRef =0; - A * aStdRef =0; - - // interaction with __strong - aStrongRef=[A alloc]; - // counter =1 - aStdRef =aStrongRef; - // counter = 2 - aStrongRef=0; - // counter =1 - aWeakRef = aStdRef; - // counter =1 - anAutoRelRef = aStdRef; - //counter=2 - anUnsafeUnretRef = aStdRef; - //counter=2 - - - return 0; +int main() { + + A* __weak aWeakRef = 0; + A* __strong aStrongRef = 0; + A* __unsafe_unretained anUnsafeUnretRef = 0; + A* __autoreleasing anAutoRelRef = 0; + A* aStdRef = 0; + + // interaction with __strong + aStrongRef = [A alloc]; + // counter =1 + aStdRef = aStrongRef; + // counter = 2 + aStrongRef = 0; + // counter =1 + aWeakRef = aStdRef; + // counter =1 + anAutoRelRef = aStdRef; + // counter=2 + anUnsafeUnretRef = aStdRef; + // counter=2 + + return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/types/testloop.dot b/infer/tests/codetoanalyze/objc/frontend/types/testloop.dot index 188eb2556..cd5582ab9 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/testloop.dot +++ b/infer/tests/codetoanalyze/objc/frontend/types/testloop.dot @@ -1,12 +1,12 @@ digraph iCFG { -3 [label="3: Return Stmt \n n$0=*&#GB$__iPhoneVideoAdLayout:struct FBVideoAdLayout [line 50]\n *&return:struct FBVideoAdLayout =n$0 [line 50]\n REMOVE_TEMPS(n$0); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$__iPhoneVideoAdLayout:struct FBVideoAdLayout [line 45]\n *&return:struct FBVideoAdLayout =n$0 [line 45]\n REMOVE_TEMPS(n$0); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit FBScrollViewDelegateProxy_layoutToUse \n " color=yellow style=filled] -1 [label="1: Start FBScrollViewDelegateProxy_layoutToUse\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 48]\n " color=yellow style=filled] +1 [label="1: Start FBScrollViewDelegateProxy_layoutToUse\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 44]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/types/testloop.m b/infer/tests/codetoanalyze/objc/frontend/types/testloop.m index 6450b7723..4cc7b9ea9 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/testloop.m +++ b/infer/tests/codetoanalyze/objc/frontend/types/testloop.m @@ -14,19 +14,16 @@ @implementation FBScrollViewDelegateProxy -typedef struct -{ - float placeHolderWidth; - float placeHolderHeight; - float contentLeftSidePadding; - float contentRightSidePadding; - float additionalPlaceholderOffset; - float contentGap; +typedef struct { + float placeHolderWidth; + float placeHolderHeight; + float contentLeftSidePadding; + float contentRightSidePadding; + float additionalPlaceholderOffset; + float contentGap; } FBVideoAdLayout; - -static const FBVideoAdLayout __iPadVideoAdLayout = -{ +static const FBVideoAdLayout __iPadVideoAdLayout = { .placeHolderWidth = 554, .placeHolderHeight = 350, .contentLeftSidePadding = 140, @@ -35,8 +32,7 @@ static const FBVideoAdLayout __iPadVideoAdLayout = .contentGap = 11, }; -static const FBVideoAdLayout __iPhoneVideoAdLayout = -{ +static const FBVideoAdLayout __iPhoneVideoAdLayout = { .placeHolderWidth = 244, .placeHolderHeight = 175, .contentLeftSidePadding = 20, @@ -45,9 +41,8 @@ static const FBVideoAdLayout __iPhoneVideoAdLayout = .contentGap = 7, }; -+ (FBVideoAdLayout)layoutToUse -{ - return __iPhoneVideoAdLayout; ++ (FBVideoAdLayout)layoutToUse { + return __iPhoneVideoAdLayout; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/types/void_call.dot b/infer/tests/codetoanalyze/objc/frontend/types/void_call.dot index 2ff96e7d6..0c8c61964 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/void_call.dot +++ b/infer/tests/codetoanalyze/objc/frontend/types/void_call.dot @@ -1,34 +1,34 @@ digraph iCFG { -24 [label="24: DeclStmt \n *&x:int =1 [line 43]\n " shape="box"] +24 [label="24: DeclStmt \n *&x:int =1 [line 35]\n " shape="box"] 24 -> 23 ; -23 [label="23: Call _fun_foo1 \n n$9=*&x:int [line 44]\n _fun_foo1(n$9:int ) [line 44]\n REMOVE_TEMPS(n$9); [line 44]\n " shape="box"] +23 [label="23: Call _fun_foo1 \n n$9=*&x:int [line 36]\n _fun_foo1(n$9:int ) [line 36]\n REMOVE_TEMPS(n$9); [line 36]\n " shape="box"] 23 -> 22 ; -22 [label="22: BinaryOperatorStmt: Assign \n n$7=*&x:int [line 46]\n n$8=_fun_bar1(n$7:int ) [line 46]\n *&x:int =n$8 [line 46]\n REMOVE_TEMPS(n$7,n$8); [line 46]\n " shape="box"] +22 [label="22: BinaryOperatorStmt: Assign \n n$7=*&x:int [line 38]\n n$8=_fun_bar1(n$7:int ) [line 38]\n *&x:int =n$8 [line 38]\n REMOVE_TEMPS(n$7,n$8); [line 38]\n " shape="box"] 22 -> 21 ; -21 [label="21: DeclStmt \n n$6=_fun___objc_alloc_no_fail(sizeof(class AClass ):unsigned long ) [line 48]\n *&o:class AClass *=n$6 [line 48]\n REMOVE_TEMPS(n$6); [line 48]\n " shape="box"] +21 [label="21: DeclStmt \n n$6=_fun___objc_alloc_no_fail(sizeof(class AClass ):unsigned long ) [line 40]\n *&o:class AClass *=n$6 [line 40]\n REMOVE_TEMPS(n$6); [line 40]\n " shape="box"] 21 -> 17 ; 21 -> 18 ; -20 [label="20: Message Call: foo: \n n$4=*&o:class AClass * [line 52]\n n$5=*&x:int [line 52]\n _fun_AClass_foo:(n$4:class AClass *,n$5:int ) virtual [line 52]\n REMOVE_TEMPS(n$4,n$5); [line 52]\n " shape="box"] +20 [label="20: Message Call: foo: \n n$4=*&o:class AClass * [line 44]\n n$5=*&x:int [line 44]\n _fun_AClass_foo:(n$4:class AClass *,n$5:int ) virtual [line 44]\n REMOVE_TEMPS(n$4,n$5); [line 44]\n " shape="box"] 20 -> 19 ; -19 [label="19: BinaryOperatorStmt: Assign \n n$1=*&o:class AClass * [line 53]\n n$2=*&x:int [line 53]\n n$3=_fun_AClass_bar:(n$1:class AClass *,n$2:int ) virtual [line 53]\n *&x:int =n$3 [line 53]\n REMOVE_TEMPS(n$1,n$2,n$3); [line 53]\n NULLIFY(&o,false); [line 53]\n NULLIFY(&x,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"] +19 [label="19: BinaryOperatorStmt: Assign \n n$1=*&o:class AClass * [line 45]\n n$2=*&x:int [line 45]\n n$3=_fun_AClass_bar:(n$1:class AClass *,n$2:int ) virtual [line 45]\n *&x:int =n$3 [line 45]\n REMOVE_TEMPS(n$1,n$2,n$3); [line 45]\n NULLIFY(&o,false); [line 45]\n NULLIFY(&x,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"] 19 -> 16 ; -18 [label="18: Prune (false branch) \n n$0=*&o:class AClass * [line 50]\n PRUNE((n$0 == 0), false); [line 50]\n REMOVE_TEMPS(n$0); [line 50]\n APPLY_ABSTRACTION; [line 50]\n " shape="invhouse"] +18 [label="18: Prune (false branch) \n n$0=*&o:class AClass * [line 42]\n PRUNE((n$0 == 0), false); [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n APPLY_ABSTRACTION; [line 42]\n " shape="invhouse"] 18 -> 16 ; -17 [label="17: Prune (true branch) \n n$0=*&o:class AClass * [line 50]\n PRUNE((n$0 != 0), true); [line 50]\n REMOVE_TEMPS(n$0); [line 50]\n " shape="invhouse"] +17 [label="17: Prune (true branch) \n n$0=*&o:class AClass * [line 42]\n PRUNE((n$0 != 0), true); [line 42]\n REMOVE_TEMPS(n$0); [line 42]\n " shape="invhouse"] 17 -> 20 ; @@ -36,58 +36,58 @@ digraph iCFG { 16 -> 15 ; -15 [label="15: Return Stmt \n NULLIFY(&o,false); [line 57]\n NULLIFY(&x,false); [line 57]\n *&return:int =0 [line 57]\n APPLY_ABSTRACTION; [line 57]\n " shape="box"] +15 [label="15: Return Stmt \n NULLIFY(&o,false); [line 48]\n NULLIFY(&x,false); [line 48]\n *&return:int =0 [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"] 15 -> 14 ; 14 [label="14: Exit main \n " color=yellow style=filled] -13 [label="13: Start main\nFormals: \nLocals: o:class AClass * x:int \n DECLARE_LOCALS(&return,&o,&x); [line 41]\n NULLIFY(&o,false); [line 41]\n NULLIFY(&x,false); [line 41]\n " color=yellow style=filled] +13 [label="13: Start main\nFormals: \nLocals: o:class AClass * x:int \n DECLARE_LOCALS(&return,&o,&x); [line 33]\n NULLIFY(&o,false); [line 33]\n NULLIFY(&x,false); [line 33]\n " color=yellow style=filled] 13 -> 24 ; -12 [label="12: Return Stmt \n n$0=*&a:int [line 38]\n *&a:int =(n$0 + 1) [line 38]\n *&return:int =n$0 [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n NULLIFY(&a,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +12 [label="12: Return Stmt \n n$0=*&a:int [line 31]\n *&a:int =(n$0 + 1) [line 31]\n *&return:int =n$0 [line 31]\n REMOVE_TEMPS(n$0); [line 31]\n NULLIFY(&a,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"] 12 -> 11 ; 11 [label="11: Exit bar1 \n " color=yellow style=filled] -10 [label="10: Start bar1\nFormals: a:int \nLocals: \n DECLARE_LOCALS(&return); [line 36]\n " color=yellow style=filled] +10 [label="10: Start bar1\nFormals: a:int \nLocals: \n DECLARE_LOCALS(&return); [line 31]\n " color=yellow style=filled] 10 -> 12 ; -9 [label="9: UnaryOperator \n n$0=*&a:int [line 33]\n *&a:int =(n$0 + 1) [line 33]\n REMOVE_TEMPS(n$0); [line 33]\n NULLIFY(&a,false); [line 33]\n APPLY_ABSTRACTION; [line 33]\n " shape="box"] +9 [label="9: UnaryOperator \n n$0=*&a:int [line 29]\n *&a:int =(n$0 + 1) [line 29]\n REMOVE_TEMPS(n$0); [line 29]\n NULLIFY(&a,false); [line 29]\n APPLY_ABSTRACTION; [line 29]\n " shape="box"] 9 -> 8 ; 8 [label="8: Exit foo1 \n " color=yellow style=filled] -7 [label="7: Start foo1\nFormals: a:int \nLocals: \n DECLARE_LOCALS(&return); [line 32]\n " color=yellow style=filled] +7 [label="7: Start foo1\nFormals: a:int \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled] 7 -> 9 ; -6 [label="6: Return Stmt \n n$1=*&a:int [line 25]\n *&a:int =(n$1 + 1) [line 25]\n *&return:int =n$1 [line 25]\n REMOVE_TEMPS(n$1); [line 25]\n NULLIFY(&a,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"] +6 [label="6: Return Stmt \n n$1=*&a:int [line 24]\n *&a:int =(n$1 + 1) [line 24]\n *&return:int =n$1 [line 24]\n REMOVE_TEMPS(n$1); [line 24]\n NULLIFY(&a,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit AClass_bar: \n " color=yellow style=filled] -4 [label="4: Start AClass_bar:\nFormals: self:class AClass * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 24]\n NULLIFY(&self,false); [line 24]\n " color=yellow style=filled] +4 [label="4: Start AClass_bar:\nFormals: self:class AClass * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n NULLIFY(&self,false); [line 23]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: UnaryOperator \n n$0=*&a:int [line 22]\n *&a:int =(n$0 + 1) [line 22]\n REMOVE_TEMPS(n$0); [line 22]\n NULLIFY(&a,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"] +3 [label="3: UnaryOperator \n n$0=*&a:int [line 21]\n *&a:int =(n$0 + 1) [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n NULLIFY(&a,false); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit AClass_foo: \n " color=yellow style=filled] -1 [label="1: Start AClass_foo:\nFormals: self:class AClass * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 21]\n NULLIFY(&self,false); [line 21]\n " color=yellow style=filled] +1 [label="1: Start AClass_foo:\nFormals: self:class AClass * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&self,false); [line 20]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/types/void_call.m b/infer/tests/codetoanalyze/objc/frontend/types/void_call.m index cdbe3e704..eba2f370c 100644 --- a/infer/tests/codetoanalyze/objc/frontend/types/void_call.m +++ b/infer/tests/codetoanalyze/objc/frontend/types/void_call.m @@ -11,49 +11,39 @@ @interface AClass : NSObject { } -- (void) foo: (int)a; -- (int) bar: (int)a; +- (void)foo:(int)a; +- (int)bar:(int)a; @end - @implementation AClass -- (void) foo: (int)a { - a++; +- (void)foo:(int)a { + a++; } -- (int) bar: (int)a { - return a++; +- (int)bar:(int)a { + return a++; } @end +void foo1(int a) { a++; } - -void foo1(int a) { - a++; -} - -int bar1(int a) { - - return a++; -} +int bar1(int a) { return a++; } int main() { - int x=1; - foo1(x); - - x=bar1(x); - - AClass* o =[AClass alloc]; + int x = 1; + foo1(x); - if (o) { + x = bar1(x); - [o foo:x]; - x=[o bar:x]; + AClass* o = [AClass alloc]; - } + if (o) { - return 0; + [o foo:x]; + x = [o bar:x]; + } + return 0; } diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.dot b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.dot index de69338c6..4b4f2490d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.dot +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.dot @@ -1,12 +1,12 @@ digraph iCFG { -3 [label="3: Return Stmt \n n$0=*&#GB$aVariable:class NSObject * [line 23]\n *&return:class NSObject *=n$0 [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$aVariable:class NSObject * [line 21]\n *&return:class NSObject *=n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit AClass_sharedInstance \n " color=yellow style=filled] -1 [label="1: Start AClass_sharedInstance\nFormals: self:class AClass *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n NULLIFY(&self,false); [line 21]\n " color=yellow style=filled] +1 [label="1: Start AClass_sharedInstance\nFormals: self:class AClass *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&self,false); [line 20]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.m b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.m index f471167f1..7c42108ff 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.m +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass.m @@ -11,16 +11,14 @@ @interface AClass : NSObject { } - - (NSObject *)sharedInstance; +- (NSObject*)sharedInstance; @end - @implementation AClass -static NSObject *aVariable; +static NSObject* aVariable; -- (NSObject *)sharedInstance -{ - return aVariable; +- (NSObject*)sharedInstance { + return aVariable; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.dot b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.dot index de69338c6..4b4f2490d 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.dot +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.dot @@ -1,12 +1,12 @@ digraph iCFG { -3 [label="3: Return Stmt \n n$0=*&#GB$aVariable:class NSObject * [line 23]\n *&return:class NSObject *=n$0 [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&#GB$aVariable:class NSObject * [line 21]\n *&return:class NSObject *=n$0 [line 21]\n REMOVE_TEMPS(n$0); [line 21]\n APPLY_ABSTRACTION; [line 21]\n " shape="box"] 3 -> 2 ; 2 [label="2: Exit AClass_sharedInstance \n " color=yellow style=filled] -1 [label="1: Start AClass_sharedInstance\nFormals: self:class AClass *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n NULLIFY(&self,false); [line 21]\n " color=yellow style=filled] +1 [label="1: Start AClass_sharedInstance\nFormals: self:class AClass *\nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&self,false); [line 20]\n " color=yellow style=filled] 1 -> 3 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.m b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.m index cba1bdcef..811e46785 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.m +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/aclass_2.m @@ -11,16 +11,14 @@ @interface AClass : NSObject { } - - (NSObject *)sharedInstance; +- (NSObject*)sharedInstance; @end - @implementation AClass -NSObject *aVariable; +NSObject* aVariable; -- (NSObject *)sharedInstance -{ - return aVariable; +- (NSObject*)sharedInstance { + return aVariable; } @end diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/initlist.m b/infer/tests/codetoanalyze/objc/frontend/vardecl/initlist.m index 9e87d3ec0..ef700ad71 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/initlist.m +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/initlist.m @@ -11,7 +11,7 @@ int main() { int z; - int a[2][3] = {{z+1, 2, 3}, {5,6,7}}; + int a[2][3] = {{z + 1, 2, 3}, {5, 6, 7}}; } @interface C : NSObject @@ -19,7 +19,7 @@ int main() { @end int test() { - C *c1 = [C alloc]; - C *c2 = [C alloc]; + C* c1 = [C alloc]; + C* c2 = [C alloc]; C* a[3] = {[c1 init], c1, c2}; } diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.dot b/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.dot index 7fc359dc4..59da92c21 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.dot +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.dot @@ -1,9 +1,9 @@ digraph iCFG { -4 [label="4: DeclStmt \n *&a:int =0 [line 11]\n " shape="box"] +4 [label="4: DeclStmt \n *&a:int =0 [line 10]\n " shape="box"] 4 -> 3 ; -3 [label="3: DeclStmt \n n$0=*&a:int [line 11]\n *&b:int =(n$0 + 2) [line 11]\n REMOVE_TEMPS(n$0); [line 11]\n NULLIFY(&a,false); [line 11]\n NULLIFY(&b,false); [line 11]\n APPLY_ABSTRACTION; [line 11]\n " shape="box"] +3 [label="3: DeclStmt \n n$0=*&a:int [line 10]\n *&b:int =(n$0 + 2) [line 10]\n REMOVE_TEMPS(n$0); [line 10]\n NULLIFY(&a,false); [line 10]\n NULLIFY(&b,false); [line 10]\n APPLY_ABSTRACTION; [line 10]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.m b/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.m index 140c52f5d..5a6038134 100644 --- a/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.m +++ b/infer/tests/codetoanalyze/objc/frontend/vardecl/last_af.m @@ -7,6 +7,4 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -int main() { - int a = 0, b = a + 2; -} +int main() { int a = 0, b = a + 2; } diff --git a/infer/tests/codetoanalyze/objc/warnings/ParameterNotNullableExample.m b/infer/tests/codetoanalyze/objc/warnings/ParameterNotNullableExample.m index 3d4255b54..8539ceec0 100644 --- a/infer/tests/codetoanalyze/objc/warnings/ParameterNotNullableExample.m +++ b/infer/tests/codetoanalyze/objc/warnings/ParameterNotNullableExample.m @@ -9,59 +9,51 @@ #import -typedef struct { - int queue; -} FBAudioRecordState; +typedef struct { int queue; } FBAudioRecordState; @interface FBAudioRecorder : NSObject -@property (nonatomic, assign) id delegate; -@property (nonatomic, assign) FBAudioRecordState *recordState; -@property (nonatomic, assign) FBAudioRecorder *recorder; +@property(nonatomic, assign) id delegate; +@property(nonatomic, assign) FBAudioRecordState* recordState; +@property(nonatomic, assign) FBAudioRecorder* recorder; @end - @implementation FBAudioRecorder { - int x; + int x; } --(int) FBAudioInputCallbackSimple:(FBAudioRecorder *)rec -{ - FBAudioRecordState *recordState = rec.recordState; - return recordState->queue; +- (int)FBAudioInputCallbackSimple:(FBAudioRecorder*)rec { + FBAudioRecordState* recordState = rec.recordState; + return recordState->queue; } --(int) FBAudioInputCallbackSimpleAliasing:(FBAudioRecorder *)userdata -{ - FBAudioRecorder *recorder = userdata; - FBAudioRecordState *recordState = recorder.recordState; - return recordState->queue; +- (int)FBAudioInputCallbackSimpleAliasing:(FBAudioRecorder*)userdata { + FBAudioRecorder* recorder = userdata; + FBAudioRecordState* recordState = recorder.recordState; + return recordState->queue; } --(int) FBAudioInputCallbackField -{ - FBAudioRecordState *recordState = _recorder->_recorder.recordState; - return recordState->queue; +- (int)FBAudioInputCallbackField { + FBAudioRecordState* recordState = _recorder->_recorder.recordState; + return recordState->queue; } --(int) FBAudioInputCallbackChain:(FBAudioRecorder *)rec -{ - FBAudioRecordState *recordState = rec.recorder.recordState; - return recordState->queue; +- (int)FBAudioInputCallbackChain:(FBAudioRecorder*)rec { + FBAudioRecordState* recordState = rec.recorder.recordState; + return recordState->queue; } --(int) test -{ - FBAudioRecorder *rec = nil; - FBAudioRecordState *recordState = rec.recordState; - return recordState->queue; +- (int)test { + FBAudioRecorder* rec = nil; + FBAudioRecordState* recordState = rec.recordState; + return recordState->queue; } --(instancetype) init { - self = [super init]; - self->x = 0; - return self; +- (instancetype)init { + self = [super init]; + self->x = 0; + return self; } @end diff --git a/infer/tests/codetoanalyze/objc/warnings/atomic_prop.m b/infer/tests/codetoanalyze/objc/warnings/atomic_prop.m index 37fb64ea4..9b4929be2 100644 --- a/infer/tests/codetoanalyze/objc/warnings/atomic_prop.m +++ b/infer/tests/codetoanalyze/objc/warnings/atomic_prop.m @@ -9,109 +9,94 @@ #import -@interface B : NSObject +@interface B : NSObject -- (void) foo; +- (void)foo; @end @implementation B --(void) foo { -}; +- (void)foo{}; @end +@interface A : NSObject -@interface A : NSObject +@property(nonatomic) int* p; +@property int* q; // atomic by default +@property(atomic, assign) float f; -@property (nonatomic) int *p; -@property int *q; // atomic by default -@property (atomic, assign) float f; +@property B* b; -@property B *b; - -- (void) write_p: (int)i; -- (int) read_p; -- (void) write_q: (int)i; -- (int) read_q; -- (void) write_f: (int)i; -- (int) read_f; +- (void)write_p:(int)i; +- (int)read_p; +- (void)write_q:(int)i; +- (int)read_q; +- (void)write_f:(int)i; +- (int)read_f; @end - @implementation A @synthesize b; -- (A*) init -{ - _p = 0; // Good access - _q = 0; // Good access - _f = 0; // Good access +- (A*)init { + _p = 0; // Good access + _q = 0; // Good access + _f = 0; // Good access } -- (A*) new -{ - _p = 0; // Good access - _q = 0; // Good access - _f = 0; // Good access +- (A*) new { + _p = 0; // Good access + _q = 0; // Good access + _f = 0; // Good access } -- (A*) initWithBla: (int) d -{ - _p = d; // Good access - _q = d; // Good access - _f = d; // Good access +- (A*)initWithBla:(int)d { + _p = d; // Good access + _q = d; // Good access + _f = d; // Good access } -- (A*) initWith: (int) e -{ - _p = e; // Good access - _q = e; // Good access - _f = e; // Good access +- (A*)initWith:(int)e { + _p = e; // Good access + _q = e; // Good access + _f = e; // Good access } -- (void) dealloc -{ - _q = 0; // Good access +- (void)dealloc { + _q = 0; // Good access } -- (void) writeP: (int)i -{ - _p = i; // Good access +- (void)writeP:(int)i { + _p = i; // Good access } -- (int) readP -{ - return _p; // Good access +- (int)readP { + return _p; // Good access } -- (void) writeQ: (int)i -{ - _q = i; // Bad access +- (void)writeQ:(int)i { + _q = i; // Bad access } -- (int) readQ -{ - return _q; // Bad access +- (int)readQ { + return _q; // Bad access } -- (void) writeF: (float) j -{ - self.f = j; // Good access +- (void)writeF:(float)j { + self.f = j; // Good access } -- (int) readF -{ - return self.f; // Good access +- (int)readF { + return self.f; // Good access } -- (void) bla -{ - if (b) { // bad access - [b foo]; //bad access - } +- (void)bla { + if (b) { // bad access + [b foo]; // bad access + } } @end diff --git a/infer/tests/codetoanalyze/objc/warnings/strong_delegate.m b/infer/tests/codetoanalyze/objc/warnings/strong_delegate.m index c4368eac6..49c6b3883 100644 --- a/infer/tests/codetoanalyze/objc/warnings/strong_delegate.m +++ b/infer/tests/codetoanalyze/objc/warnings/strong_delegate.m @@ -10,27 +10,27 @@ #import @interface A : NSObject -- (void) bla; +- (void)bla; -@property (nonatomic,strong) id delegated; +@property(nonatomic, strong) id delegated; -@property (nonatomic,strong) id delegation; +@property(nonatomic, strong) id delegation; -@property (nonatomic,strong) id delegate; +@property(nonatomic, strong) id delegate; -@property (nonatomic,strong) id fileDelegate; +@property(nonatomic, strong) id fileDelegate; -@property (nonatomic,strong) id delegateFile; +@property(nonatomic, strong) id delegateFile; -@property (nonatomic,strong) id OneDelegateFile; +@property(nonatomic, strong) id OneDelegateFile; @end @implementation A { - BOOL _b; + BOOL _b; } -- (void) bla { +- (void)bla { } @end diff --git a/infer/tests/codetoanalyze/objcpp/errors/blocks/block.mm b/infer/tests/codetoanalyze/objcpp/errors/blocks/block.mm index 1a0eb48d7..edf49ec85 100644 --- a/infer/tests/codetoanalyze/objcpp/errors/blocks/block.mm +++ b/infer/tests/codetoanalyze/objcpp/errors/blocks/block.mm @@ -7,43 +7,39 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -#import +#import #include @interface A : NSObject -- (int) foo: (int &) y; +- (int)foo:(int&)y; @end @implementation A -- (int) foo: (int &) y -{ - dispatch_async(dispatch_get_main_queue(), ^{ - int a = y; // Error - return ; - }); - return 1; +- (int)foo:(int&)y { + dispatch_async(dispatch_get_main_queue(), ^{ + int a = y; // Error + return; + }); + return 1; } -- (int) foo2: (int &) y -{ - const int copied_y = y; - dispatch_async(dispatch_get_main_queue(), ^{ - int a = copied_y; // OK - return ; - }); - return 1; +- (int)foo2:(int&)y { + const int copied_y = y; + dispatch_async(dispatch_get_main_queue(), ^{ + int a = copied_y; // OK + return; + }); + return 1; } -- (int) foo3: (int &) y param2: (int &) z -{ - dispatch_async(dispatch_get_main_queue(), ^{ - int a = y; // Error - int b = z; // Error - return ; - }); - return 1; +- (int)foo3:(int&)y param2:(int&)z { + dispatch_async(dispatch_get_main_queue(), ^{ + int a = y; // Error + int b = z; // Error + return; + }); + return 1; } - @end diff --git a/infer/tests/codetoanalyze/objcpp/frontend/funcoverloading/af_test.mm b/infer/tests/codetoanalyze/objcpp/frontend/funcoverloading/af_test.mm index 9ac7ef74e..9891a2347 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/funcoverloading/af_test.mm +++ b/infer/tests/codetoanalyze/objcpp/frontend/funcoverloading/af_test.mm @@ -9,12 +9,6 @@ #import -int POPSelectValueType(id obj) -{ - return 1; -} +int POPSelectValueType(id obj) { return 1; } -int POPSelectValueType(int v) -{ - return v; -} +int POPSelectValueType(int v) { return v; } diff --git a/infer/tests/endtoend/c/NullDereferenceTest.java b/infer/tests/endtoend/c/NullDereferenceTest.java index 1d4deada6..4745578c2 100644 --- a/infer/tests/endtoend/c/NullDereferenceTest.java +++ b/infer/tests/endtoend/c/NullDereferenceTest.java @@ -65,7 +65,7 @@ public class NullDereferenceTest { @Test public void whenInferRunsOnSimpleNpe_interprocThenCorrectLineIsReported() throws InterruptedException, IOException, InferException { - int[] lines = {20, 34}; + int[] lines = {20, 32}; assertThat( "Results should contain null pointer dereference error", inferResults,