diff --git a/infer/models/Makefile b/infer/models/Makefile index 23c67e207..47cf4d493 100644 --- a/infer/models/Makefile +++ b/infer/models/Makefile @@ -43,10 +43,10 @@ $(CPP_MODELS_FILE): $(CPP_MODELS_SOURCES) $(INFERANALYZE) $(INFERCLANG) make -C $(CPP_MODELS) install $(OBJC_MODELS_FILE): $(OBJC_MODELS_SOURCES) $(INFERANALYZE) $(INFERCLANG) -ifeq ($(PLATFORM), Darwin) +ifneq (, $(shell which xcode-select 2>&-)) make -C $(OBJC_MODELS) install else - @echo "Platform $(PLATFORM) not supported for objc models, skipping." + @echo "Xcode not installed or platform $(PLATFORM) not supported for objc models, skipping." endif clean: diff --git a/infer/models/objc/src/Makefile b/infer/models/objc/src/Makefile index 6c8d5510b..7d61a9d7c 100644 --- a/infer/models/objc/src/Makefile +++ b/infer/models/objc/src/Makefile @@ -5,7 +5,7 @@ C_OBJECTS=$(C_SOURCES:.c=.o) CC=clang XCODE_PATH=$(shell xcode-select -p) IPHONE_SIMULATOR_PATH=$(XCODE_PATH)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -FLAGS=-x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) +FLAGS=--target=x86_64-apple-darwin14 -x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) default: test @@ -23,8 +23,8 @@ clean: rm -rf $(M_OBJECTS) rm -rf $(C_OBJECTS) -.m.o: +%.o: %.m $(CC) $(FLAGS) $< -o $@ -.c.o: +%.o: %.c $(CC) $(FLAGS) $< -o $@ 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 c2fef7dd5..93ef4c969 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.dot @@ -1,5 +1,5 @@ digraph iCFG { -32 [label="32: Call _fun___objc_release \n n$23=*&a:class A * [line 70]\n n$24=_fun___objc_release(n$23:class A *) [line 70]\n REMOVE_TEMPS(n$23,n$24); [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$23=*&a:class A * [line 70]\n _fun___objc_release(n$23:class A *) [line 70]\n REMOVE_TEMPS(n$23); [line 70]\n NULLIFY(&a,false); [line 70]\n APPLY_ABSTRACTION; [line 70]\n " shape="box"] 32 -> 29 ; 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 cb32cf043..c7ce609ea 100644 --- a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/RetainReleaseExample2.m @@ -17,7 +17,7 @@ @end - +void __objc_release(A*); // infer builtin A* g; diff --git a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.dot b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.dot index 5a8b9b94d..7d424daa0 100644 --- a/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.dot +++ b/infer/tests/codetoanalyze/objc/frontend/boxing/Boxing.dot @@ -14,11 +14,11 @@ digraph iCFG { 23 -> 26 ; -22 [label="22: DeclStmt \n n$13=_fun_NSNumber_numberWithBool:(1:signed char ) [line 37]\n *&n:class NSNumber *=n$13 [line 37]\n REMOVE_TEMPS(n$13); [line 37]\n NULLIFY(&n,false); [line 37]\n " shape="box"] +22 [label="22: DeclStmt \n n$13=_fun_NSNumber_numberWithBool:(1:_Bool ) [line 37]\n *&n:class NSNumber *=n$13 [line 37]\n REMOVE_TEMPS(n$13); [line 37]\n NULLIFY(&n,false); [line 37]\n " shape="box"] 22 -> 21 ; -21 [label="21: Return Stmt \n n$12=_fun_NSNumber_numberWithBool:(1:signed char ) [line 38]\n *&return:class NSNumber *=n$12 [line 38]\n REMOVE_TEMPS(n$12); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] +21 [label="21: Return Stmt \n n$12=_fun_NSNumber_numberWithBool:(1:_Bool ) [line 38]\n *&return:class NSNumber *=n$12 [line 38]\n REMOVE_TEMPS(n$12); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"] 21 -> 20 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.dot b/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.dot index 5c66835ea..76768317f 100644 --- a/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.dot +++ b/infer/tests/codetoanalyze/objc/frontend/conditional_operation/ConditionalOperation.dot @@ -3,15 +3,15 @@ digraph iCFG { 11 -> 7 ; -10 [label="10: ConditinalStmt Branch \n n$4=*&b:signed char [line 24]\n DECLARE_LOCALS(&SIL_temp_conditional___7); [line 24]\n *&SIL_temp_conditional___7:int =n$4 [line 24]\n REMOVE_TEMPS(n$4); [line 24]\n NULLIFY(&b,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] +10 [label="10: ConditinalStmt Branch \n n$4=*&b:_Bool [line 24]\n DECLARE_LOCALS(&SIL_temp_conditional___7); [line 24]\n *&SIL_temp_conditional___7:int =n$4 [line 24]\n REMOVE_TEMPS(n$4); [line 24]\n NULLIFY(&b,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"] 10 -> 7 ; -9 [label="9: Prune (false branch) \n n$3=*&b:signed char [line 24]\n PRUNE((n$3 == 0), false); [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n " shape="invhouse"] +9 [label="9: Prune (false branch) \n n$3=*&b:_Bool [line 24]\n PRUNE((n$3 == 0), false); [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n " shape="invhouse"] 9 -> 11 ; -8 [label="8: Prune (true branch) \n n$3=*&b:signed char [line 24]\n PRUNE((n$3 != 0), true); [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n " shape="invhouse"] +8 [label="8: Prune (true branch) \n n$3=*&b:_Bool [line 24]\n PRUNE((n$3 != 0), true); [line 24]\n REMOVE_TEMPS(n$3); [line 24]\n " shape="invhouse"] 8 -> 10 ; @@ -26,7 +26,7 @@ digraph iCFG { 5 [label="5: Exit A_test5: \n " color=yellow style=filled] -4 [label="4: Start A_test5:\nFormals: self:class A * b:signed char \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] +4 [label="4: Start A_test5:\nFormals: self:class A * b:_Bool \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled] 4 -> 8 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.dot b/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.dot index aedc3dd87..fb13f7a32 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.dot +++ b/infer/tests/codetoanalyze/objc/frontend/property/PropertyCustomAccessor.dot @@ -1,16 +1,16 @@ digraph iCFG { -6 [label="6: BinaryOperatorStmt: Assign \n n$2=*&self:class ASDisplayNode * [line 14]\n n$3=*&opaque:signed char [line 14]\n *n$2._opaque:signed char =n$3 [line 14]\n REMOVE_TEMPS(n$2,n$3); [line 14]\n NULLIFY(&opaque,false); [line 14]\n NULLIFY(&self,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +6 [label="6: BinaryOperatorStmt: Assign \n n$2=*&self:class ASDisplayNode * [line 14]\n n$3=*&opaque:_Bool [line 14]\n *n$2._opaque:_Bool =n$3 [line 14]\n REMOVE_TEMPS(n$2,n$3); [line 14]\n NULLIFY(&opaque,false); [line 14]\n NULLIFY(&self,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 6 -> 5 ; 5 [label="5: Exit ASDisplayNode_setOpaque: \n " color=yellow style=filled] -4 [label="4: Start ASDisplayNode_setOpaque: (generated)\nFormals: self:class ASDisplayNode * opaque:signed char \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] +4 [label="4: Start ASDisplayNode_setOpaque: (generated)\nFormals: self:class ASDisplayNode * opaque:_Bool \nLocals: \n DECLARE_LOCALS(&return); [line 14]\n " color=yellow style=filled] 4 -> 6 ; -3 [label="3: Return Stmt \n n$0=*&self:class ASDisplayNode * [line 14]\n n$1=*n$0._opaque:signed char [line 14]\n *&return:signed char =n$1 [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&self,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] +3 [label="3: Return Stmt \n n$0=*&self:class ASDisplayNode * [line 14]\n n$1=*n$0._opaque:_Bool [line 14]\n *&return:_Bool =n$1 [line 14]\n REMOVE_TEMPS(n$0,n$1); [line 14]\n NULLIFY(&self,false); [line 14]\n APPLY_ABSTRACTION; [line 14]\n " shape="box"] 3 -> 2 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/property/main_car.dot b/infer/tests/codetoanalyze/objc/frontend/property/main_car.dot index b522297f7..178512e4a 100644 --- a/infer/tests/codetoanalyze/objc/frontend/property/main_car.dot +++ b/infer/tests/codetoanalyze/objc/frontend/property/main_car.dot @@ -3,7 +3,7 @@ digraph iCFG { 6 -> 5 ; -5 [label="5: Message Call: setRunning: \n n$3=*&honda:class Car * [line 14]\n _fun_Car_setRunning:(n$3:class Car *,1:signed char ) virtual [line 14]\n REMOVE_TEMPS(n$3); [line 14]\n " shape="box"] +5 [label="5: Message Call: setRunning: \n n$3=*&honda:class Car * [line 14]\n _fun_Car_setRunning:(n$3:class Car *,1:_Bool ) virtual [line 14]\n REMOVE_TEMPS(n$3); [line 14]\n " shape="box"] 5 -> 4 ; diff --git a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot index efb2293f5..c5218c66e 100644 --- a/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot +++ b/infer/tests/codetoanalyze/objc/frontend/self_static/Self.dot @@ -64,7 +64,7 @@ digraph iCFG { 35 -> 37 ; -34 [label="34: Return Stmt \n n$15=*&object:class B * [line 80]\n n$14=_fun_B_isC:(n$15:class B *,sizeof(class A ):unsigned long ) virtual [line 80]\n *&return:signed char =n$14 [line 80]\n REMOVE_TEMPS(n$14,n$15); [line 80]\n NULLIFY(&object,false); [line 80]\n APPLY_ABSTRACTION; [line 80]\n " shape="box"] +34 [label="34: Return Stmt \n n$15=*&object:class B * [line 80]\n n$14=_fun_B_isC:(n$15:class B *,sizeof(class A ):unsigned long ) virtual [line 80]\n *&return:_Bool =n$14 [line 80]\n REMOVE_TEMPS(n$14,n$15); [line 80]\n NULLIFY(&object,false); [line 80]\n APPLY_ABSTRACTION; [line 80]\n " shape="box"] 34 -> 33 ; @@ -170,7 +170,7 @@ digraph iCFG { 6 -> 7 ; -5 [label="5: Return Stmt \n *&return:signed char =1 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] +5 [label="5: Return Stmt \n *&return:_Bool =1 [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"] 5 -> 4 ; diff --git a/infer/tests/utils/InferRunner.java b/infer/tests/utils/InferRunner.java index 29fb551b6..f4303ccf9 100644 --- a/infer/tests/utils/InferRunner.java +++ b/infer/tests/utils/InferRunner.java @@ -52,7 +52,7 @@ public class InferRunner { "/dependencies/java/jackson/jackson-2.2.3.jar", }; - private static final String IOS_ISYSROOT_SUFFIX = + private static final String IPHONESIMULATOR_ISYSROOT_SUFFIX = "/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"; private static HashMap inferResultsMap = @@ -200,6 +200,7 @@ public class InferRunner { } ImmutableList clangCmd = new ImmutableList.Builder() .add("clang") + .add("--target=x86_64-apple-darwin14") .add("-x") .add(getClangLangOption(lang)) .add(getStdParam(lang)) @@ -279,39 +280,39 @@ public class InferRunner { public static ImmutableList createObjCInferCommandFrontend( TemporaryFolder folder, - String sourceFile) { + String sourceFile) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjC, false, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } public static ImmutableList createObjCInferCommandFrontendArc( TemporaryFolder folder, - String sourceFile) { + String sourceFile) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjC, false, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, true); } public static ImmutableList createObjCPPInferCommandFrontend( TemporaryFolder folder, - String sourceFile) { + String sourceFile) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjCPP, false, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } @@ -344,13 +345,13 @@ public class InferRunner { public static ImmutableList createObjCInferCommand( TemporaryFolder folder, - String sourceFile) { + String sourceFile) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjC, true, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } @@ -359,26 +360,26 @@ public class InferRunner { TemporaryFolder folder, String sourceFile, String ml_bucket, - boolean arc) { + boolean arc) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjC, true, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, ml_bucket, arc); } public static ImmutableList createObjCPPInferCommand( TemporaryFolder folder, - String sourceFile) { + String sourceFile) throws IOException, InterruptedException { return createClangInferCommand( folder, sourceFile, Language.ObjCPP, true, - null, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } @@ -391,7 +392,7 @@ public class InferRunner { sourceFile, Language.ObjC, false, - getXcodeRoot() + IOS_ISYSROOT_SUFFIX, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } @@ -404,7 +405,7 @@ public class InferRunner { sourceFile, Language.ObjC, true, - getXcodeRoot() + IOS_ISYSROOT_SUFFIX, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, null, false); } @@ -419,7 +420,7 @@ public class InferRunner { sourceFile, Language.ObjC, true, - getXcodeRoot() + IOS_ISYSROOT_SUFFIX, + getXcodeRoot() + IPHONESIMULATOR_ISYSROOT_SUFFIX, bucket, arc); } diff --git a/scripts/test.sh b/scripts/test.sh index 082bd537d..8d7e9f432 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -29,7 +29,7 @@ platform=`uname` if [ -e "$INFER_BIN/InferClang" ]; then TARGETS_TO_COMPILE+=('clang') TARGETS_TO_TEST+=('c' 'cpp') - if [ $platform == 'Darwin' ]; then + if command -v xcode-select > /dev/null; then TARGETS_TO_TEST+=('objc') fi fi