From e2c08e4085a16255d2dcaeebc8150d69e1cf2bb3 Mon Sep 17 00:00:00 2001 From: Martin Trojer Date: Mon, 10 Sep 2018 06:40:41 -0700 Subject: [PATCH] Decouple objc tests from xcode-select Reviewed By: jvillard Differential Revision: D9359621 fbshipit-source-id: e490dac4a --- Makefile | 9 ++++++--- Makefile.autoconf.in | 2 ++ configure.ac | 10 ++++++++++ infer/models/Makefile | 6 +++--- infer/models/objc/src/Makefile | 8 +++++--- infer/models/objcpp/src/Makefile | 8 +++++--- .../objc_retain_cycles/ViewController.m | 1 + .../build_systems/objc_getters_setters/Makefile | 4 +++- .../build_systems/objc_missing_fld/Makefile | 6 ++++-- .../build_systems/objc_retain_cycles/Makefile | 6 ++++-- .../objc_retain_cycles_weak/Makefile | 4 +++- .../objc_retain_cycles_weak/issues.exp | 4 ++-- infer/tests/codetoanalyze/objc/errors/Makefile | 9 ++------- .../codetoanalyze/objc/frontend/arc/Makefile | 11 ++--------- .../codetoanalyze/objc/frontend/noarc/Makefile | 10 ++-------- .../tests/codetoanalyze/objc/ioslints/Makefile | 9 ++------- .../objc/linters-def-folder/Makefile | 3 ++- .../objc/linters-for-test-only/Makefile | 3 ++- infer/tests/codetoanalyze/objc/linters/Makefile | 5 +++-- .../registered_observer/ViewController.m | 5 +++-- .../registered_observer/ViewController2.m | 5 +++-- .../registered_observer/ViewController3.m | 4 ++-- .../tests/codetoanalyze/objc/liveness/Makefile | 3 ++- .../tests/codetoanalyze/objc/nullable/Makefile | 3 ++- .../tests/codetoanalyze/objc/quandary/Makefile | 9 ++------- infer/tests/codetoanalyze/objc/uninit/Makefile | 3 ++- infer/tests/codetoanalyze/objc/uninit/uninit.m | 4 +++- .../tests/codetoanalyze/objcpp/errors/Makefile | 3 ++- .../codetoanalyze/objcpp/frontend/Makefile | 9 ++------- .../objcpp/linters-for-test-only/Makefile | 3 ++- .../tests/codetoanalyze/objcpp/linters/Makefile | 5 +++-- .../liveness/CoreFoundationExample.mm} | 0 .../codetoanalyze/objcpp/liveness/Makefile | 3 ++- .../codetoanalyze/objcpp/nullable/Makefile | 3 ++- infer/tests/objc.make | 17 +++++++++++++++++ 35 files changed, 112 insertions(+), 85 deletions(-) rename infer/tests/codetoanalyze/{objc/liveness/CoreFoundationExample.m => objcpp/liveness/CoreFoundationExample.mm} (100%) create mode 100644 infer/tests/objc.make diff --git a/Makefile b/Makefile index 1143d3288..764ce8945 100644 --- a/Makefile +++ b/Makefile @@ -62,16 +62,19 @@ endif ifneq ($(PYTHON_lxml),no) BUILD_SYSTEMS_TESTS += results_xml endif -ifneq ($(XCODE_SELECT),no) -BUILD_SYSTEMS_TESTS += xcodebuild_no_xcpretty objc_getters_setters objc_missing_fld +ifeq ($(HAS_OBJC),yes) +BUILD_SYSTEMS_TESTS += objc_getters_setters objc_missing_fld objc_retain_cycles objc_retain_cycles_weak DIRECT_TESTS += \ objc_frontend objc_errors objc_linters objc_ioslints objcpp_errors objcpp_nullable \ objcpp_frontend objcpp_linters objc_linters-for-test-only objcpp_linters-for-test-only \ objc_linters-def-folder objc_nullable objc_liveness objcpp_liveness objc_uninit +ifneq ($(XCODE_SELECT),no) +BUILD_SYSTEMS_TESTS += xcodebuild_no_xcpretty +endif ifneq ($(XCPRETTY),no) BUILD_SYSTEMS_TESTS += xcodebuild endif -endif # XCODE_SELECT +endif # HAS_OBJC endif # BUILD_C_ANALYZERS ifeq ($(BUILD_JAVA_ANALYZERS),yes) diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index 716ebff6c..4325959ba 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -71,6 +71,8 @@ SHASUM = @SHASUM@ USER_JAVA_HOME = @USER_JAVA_HOME@ UTOP = @UTOP@ XCODE_SELECT = @XCODE_SELECT@ +XCODE_BASE = @XCODE_BASE@ +HAS_OBJC = @HAS_OBJC@ XCPRETTY = @XCPRETTY@ ifneq (,$(findstring s,$(MAKEFLAGS))) diff --git a/configure.ac b/configure.ac index 4bad225f9..a42bc7066 100644 --- a/configure.ac +++ b/configure.ac @@ -118,7 +118,17 @@ AC_CHECK_TOOL([PYTHON27], [python2.7], [no]) AC_ASSERT_PROG([python2.7], [$PYTHON27]) AC_CHECK_TOOL([XCODE_SELECT], [xcode-select], [no]) +AS_IF([test "x$XCODE_SELECT" != "xno"], [XCODE_SELECT_OUT=`xcode-select -p`]) +AS_IF( + [test "x$XCODE_BASE" != "x"], + [AC_CHECK_FILE($XCODE_BASE,[HAS_OBJC=yes],[HAS_OBJC=no])], + [test "x$XCODE_SELECT" != "xno"], + [XCODE_BASE=$XCODE_SELECT_OUT HAS_OBJC=yes], + [HAS_OBJC=no]) + +AC_SUBST([XCODE_BASE]) +AC_SUBST([HAS_OBJC]) # prefer clang over gcc because the plugins makes use of # clang-specific #pragma's diff --git a/infer/models/Makefile b/infer/models/Makefile index b22417312..4352864d8 100644 --- a/infer/models/Makefile +++ b/infer/models/Makefile @@ -32,7 +32,7 @@ $(MODELS_RESULTS_FILE): $(MAKEFILE_LIST) $(CLANG_DEPS_NO_MODELS) ifeq ($(BUILD_C_ANALYZERS),yes) $(QUIET)$(MAKE) -C $(C_MODELS_DIR) clean $(QUIET)$(MAKE) -C $(CPP_MODELS_DIR) clean -ifneq (no, $(XCODE_SELECT)) +ifeq (yes, $(HAS_OBJC)) $(QUIET)$(MAKE) -C $(OBJC_MODELS_DIR) clean $(QUIET)$(MAKE) -C $(OBJCPP_MODELS_DIR) clean endif @@ -40,7 +40,7 @@ endif $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(C_MODELS_DIR) all) $(QUIET)$(call silent_on_success,Capturing C++ models,\ $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(CPP_MODELS_DIR) all) -ifneq (no, $(XCODE_SELECT)) +ifeq (yes, $(HAS_OBJC)) $(QUIET)$(call silent_on_success,Capturing ObjCPP models,\ $(INFER_BIN) capture $(MODELS_INFER_OPTIONS) --continue -- $(MAKE) -C $(OBJCPP_MODELS_DIR) all) $(QUIET)$(call silent_on_success,Capturing ObjC models,\ @@ -68,7 +68,7 @@ clean: clean_specs $(QUIET)$(MAKE) -C $(JAVA_MODELS_DIR) clean $(QUIET)$(MAKE) -C $(C_MODELS_DIR) clean $(QUIET)$(MAKE) -C $(CPP_MODELS_DIR) clean -ifneq (no, $(XCODE_SELECT)) +ifeq (yes, $(HAS_OBJC)) $(QUIET)$(MAKE) -C $(OBJC_MODELS_DIR) clean $(QUIET)$(MAKE) -C $(OBJCPP_MODELS_DIR) clean endif diff --git a/infer/models/objc/src/Makefile b/infer/models/objc/src/Makefile index 5f70aa26b..fe9254fce 100644 --- a/infer/models/objc/src/Makefile +++ b/infer/models/objc/src/Makefile @@ -11,9 +11,11 @@ C_SOURCES=$(shell find . -name "*.c") OBJECTS=$(M_SOURCES:.m=.o) $(C_SOURCES:.c=.o) # let infer override CC by letting the shell resolve its location according to PATH CC=clang -XCODE_PATH=$(shell $(XCODE_SELECT) -p) -IPHONE_SIMULATOR_PATH=$(XCODE_PATH)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -CFLAGS += -Wno-deprecated-objc-isa-usage --target=x86_64-apple-darwin14 -x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) + +IPHONESIMULATOR_ISYSROOT = $(XCODE_BASE)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk +OBJC_TARGET = x86_64-apple-darwin14 + +CFLAGS += -Wno-deprecated-objc-isa-usage --target=$(OBJC_TARGET) -x objective-c -c -mios-simulator-version-min=8.2 -isysroot $(IPHONESIMULATOR_ISYSROOT) all: $(OBJECTS) diff --git a/infer/models/objcpp/src/Makefile b/infer/models/objcpp/src/Makefile index fefb9a171..a5dc964ad 100644 --- a/infer/models/objcpp/src/Makefile +++ b/infer/models/objcpp/src/Makefile @@ -12,9 +12,11 @@ C_SOURCES=$(shell find -L . -name "*.c") OBJECTS=$(patsubst %.m,%_cxx.o, $(M_SOURCES)) $(patsubst %.c,%_cxx.o, $(C_SOURCES)) $(patsubst %.mm,%.o, $(MM_SOURCES)) # let infer override CC by letting the shell resolve its location according to PATH CXX=clang++ -XCODE_PATH=$(shell $(XCODE_SELECT) -p) -IPHONE_SIMULATOR_PATH=$(XCODE_PATH)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -CXXFLAGS += -Wno-deprecated-objc-isa-usage --target=x86_64-apple-darwin14 -x objective-c++ -c -mios-simulator-version-min=8.2 -isysroot $(IPHONE_SIMULATOR_PATH) + +IPHONESIMULATOR_ISYSROOT = $(XCODE_BASE)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk +OBJC_TARGET = x86_64-apple-darwin14 + +CXXFLAGS += -Wno-deprecated-objc-isa-usage --target=$(OBJC_TARGET) -x objective-c++ -c -mios-simulator-version-min=8.2 -isysroot $(IPHONESIMULATOR_ISYSROOT) all: $(OBJECTS) diff --git a/infer/tests/build_systems/codetoanalyze/objc_retain_cycles/ViewController.m b/infer/tests/build_systems/codetoanalyze/objc_retain_cycles/ViewController.m index 8c3261da2..c18798b18 100644 --- a/infer/tests/build_systems/codetoanalyze/objc_retain_cycles/ViewController.m +++ b/infer/tests/build_systems/codetoanalyze/objc_retain_cycles/ViewController.m @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ #import "ViewController.h" +#import "View.h" @implementation ViewController { View* _hostingView; diff --git a/infer/tests/build_systems/objc_getters_setters/Makefile b/infer/tests/build_systems/objc_getters_setters/Makefile index 5d9f0961e..b787fd301 100644 --- a/infer/tests/build_systems/objc_getters_setters/Makefile +++ b/infer/tests/build_systems/objc_getters_setters/Makefile @@ -10,12 +10,14 @@ CODETOANALYZE_DIR = ../codetoanalyze/objc_getters_setters ANALYZER = checkers SOURCES = $(CODETOANALYZE_DIR)/A.m $(CODETOANALYZE_DIR)/B.m OBJECTS = $(CODETOANALYZE_DIR)/A.o $(CODETOANALYZE_DIR)/B.o +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --biabduction-only --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests include $(TESTS_DIR)/infer.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST) $(QUIET)$(REMOVE_DIR) buck-out && \ $(call silent_on_success,Testing analysis with Objective-C getters and setters,\ - $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang -c $(SOURCES)) + $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/build_systems/objc_missing_fld/Makefile b/infer/tests/build_systems/objc_missing_fld/Makefile index b192a3ba7..58a601df8 100644 --- a/infer/tests/build_systems/objc_missing_fld/Makefile +++ b/infer/tests/build_systems/objc_missing_fld/Makefile @@ -10,12 +10,14 @@ CODETOANALYZE_DIR = ../codetoanalyze/objc_missing_fld ANALYZER = checkers SOURCES = $(CODETOANALYZE_DIR)/A.m $(CODETOANALYZE_DIR)/B.m OBJECTS = $(CODETOANALYZE_DIR)/A.o $(CODETOANALYZE_DIR)/B.o +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --biabduction-only --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests include $(TESTS_DIR)/infer.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST) $(QUIET)$(REMOVE_DIR) buck-out && \ - $(call silent_on_success,Testing analysis with Objective-C getters and setters,\ - $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang -c $(SOURCES)) + $(call silent_on_success,Testing analysis with Objective-C Missing_fld,\ + $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/build_systems/objc_retain_cycles/Makefile b/infer/tests/build_systems/objc_retain_cycles/Makefile index 080c7e884..926def385 100644 --- a/infer/tests/build_systems/objc_retain_cycles/Makefile +++ b/infer/tests/build_systems/objc_retain_cycles/Makefile @@ -10,12 +10,14 @@ CODETOANALYZE_DIR = ../codetoanalyze/objc_retain_cycles ANALYZER = checkers SOURCES = $(CODETOANALYZE_DIR)/View.m $(CODETOANALYZE_DIR)/ViewController.m $(CODETOANALYZE_DIR)/Caller.m OBJECTS = $(CODETOANALYZE_DIR)/View.o $(CODETOANALYZE_DIR)/ViewController.o $(CODETOANALYZE_DIR)/Caller.o +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --biabduction-only --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests include $(TESTS_DIR)/infer.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST) $(QUIET)$(REMOVE_DIR) buck-out && \ - $(call silent_on_success,Testing analysis with Objective-C getters and setters,\ - $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang -c -fobjc-arc $(SOURCES)) + $(call silent_on_success,Testing analysis with Objective-C Retain cycles,\ + $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang $(CLANG_OPTIONS) -fobjc-arc $(SOURCES)) diff --git a/infer/tests/build_systems/objc_retain_cycles_weak/Makefile b/infer/tests/build_systems/objc_retain_cycles_weak/Makefile index 8bcbd7287..2043d012c 100644 --- a/infer/tests/build_systems/objc_retain_cycles_weak/Makefile +++ b/infer/tests/build_systems/objc_retain_cycles_weak/Makefile @@ -10,12 +10,14 @@ CODETOANALYZE_DIR = ../codetoanalyze/objc_retain_cycles_weak ANALYZER = checkers SOURCES = $(CODETOANALYZE_DIR)/TimeSpent.m $(CODETOANALYZE_DIR)/AnalyticsTimeSpent.m $(CODETOANALYZE_DIR)/ListAdapter.m OBJECTS = $(CODETOANALYZE_DIR)/TimeSpent.o $(CODETOANALYZE_DIR)/AnalyticsTimeSpent.o $(CODETOANALYZE_DIR)/ListAdapter.o +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc INFER_OPTIONS = --biabduction-only --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests include $(TESTS_DIR)/infer.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(MAKEFILE_LIST) $(QUIET)$(REMOVE_DIR) buck-out && \ $(call silent_on_success,Testing analysis with Objective-C retain cycles on weak properties,\ - $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang -c -fobjc-arc $(SOURCES)) + $(INFER_BIN) $(INFER_OPTIONS) --results-dir $(CURDIR)/infer-out -- clang $(CLANG_OPTIONS) $(SOURCES)) diff --git a/infer/tests/build_systems/objc_retain_cycles_weak/issues.exp b/infer/tests/build_systems/objc_retain_cycles_weak/issues.exp index 37778805a..155d548c2 100644 --- a/infer/tests/build_systems/objc_retain_cycles_weak/issues.exp +++ b/infer/tests/build_systems/objc_retain_cycles_weak/issues.exp @@ -1,2 +1,2 @@ -build_systems/codetoanalyze/objc_retain_cycles_weak/TimeSpent.m, TimeSpent_init_bad, 2, RETAIN_CYCLE, ERROR, [start of procedure init_bad,Condition is true] -build_systems/codetoanalyze/objc_retain_cycles_weak/TimeSpent.m, retain_cycle_weak_bad, 4, RETAIN_CYCLE, ERROR, [start of procedure retain_cycle_weak_bad(),start of procedure init,start of procedure initWithDelegate:,return from a call to AnalyticsTimeSpent_initWithDelegate:,return from a call to TimeSpent_init,start of procedure initWithStrongDelegate:,return from a call to AnalyticsTimeSpent_initWithStrongDelegate:] +build_systems/codetoanalyze/objc_retain_cycles_weak/TimeSpent.m, TimeSpent_init_bad, 2, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure init_bad,Taking true branch,start of procedure setDataSourceStrong:,return from a call to ListAdapter_setDataSourceStrong:] +build_systems/codetoanalyze/objc_retain_cycles_weak/TimeSpent.m, retain_cycle_weak_bad, 4, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure retain_cycle_weak_bad(),start of procedure init,start of procedure initWithDelegate:,Executing synthesized setter setDelegate:,return from a call to AnalyticsTimeSpent_initWithDelegate:,return from a call to TimeSpent_init,start of procedure initWithStrongDelegate:,return from a call to AnalyticsTimeSpent_initWithStrongDelegate:,start of procedure setAnalyticsTimeSpent:,return from a call to TimeSpent_setAnalyticsTimeSpent:] diff --git a/infer/tests/codetoanalyze/objc/errors/Makefile b/infer/tests/codetoanalyze/objc/errors/Makefile index eb3e0ed70..fb8d266ca 100644 --- a/infer/tests/codetoanalyze/objc/errors/Makefile +++ b/infer/tests/codetoanalyze/objc/errors/Makefile @@ -5,14 +5,8 @@ TESTS_DIR = ../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - ANALYZER = checkers -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) CLEAN_EXTRA = infer-out-arc infer-out-all infer-out-all infer-out-arc \ issues.exp.test.all issues.exp.test.arc issues.exp.test.default @@ -116,6 +110,7 @@ SOURCES_ARC = \ variadic_methods/premature_nil_termination.m \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make OBJECTS_ARC = $(foreach source,$(SOURCES_ARC),$(basename $(source)).o) OBJECTS_BUCKET_ALL = $(foreach source,$(SOURCES_BUCKET_ALL),$(basename $(source)).o) diff --git a/infer/tests/codetoanalyze/objc/frontend/arc/Makefile b/infer/tests/codetoanalyze/objc/frontend/arc/Makefile index af023546a..d97ce3f23 100644 --- a/infer/tests/codetoanalyze/objc/frontend/arc/Makefile +++ b/infer/tests/codetoanalyze/objc/frontend/arc/Makefile @@ -5,15 +5,7 @@ TESTS_DIR = ../../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = \ - /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ - -fobjc-arc +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc SOURCES = \ ../predefined_expr/PredefinedExprExample.m \ @@ -28,3 +20,4 @@ SOURCES = \ ../shared/npe/Nonnull_attribute_example.m \ include $(TESTS_DIR)/clang-frontend.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile b/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile index b23ef338f..f30e0aa10 100644 --- a/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile +++ b/infer/tests/codetoanalyze/objc/frontend/noarc/Makefile @@ -5,14 +5,7 @@ TESTS_DIR = ../../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = \ - /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) SOURCES = \ ../block/retain_cycle.m \ @@ -68,3 +61,4 @@ SOURCES = \ ../shared/annotations/nonnull_annotations.m \ include $(TESTS_DIR)/clang-frontend.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/ioslints/Makefile b/infer/tests/codetoanalyze/objc/ioslints/Makefile index 091778aa9..9be39545c 100644 --- a/infer/tests/codetoanalyze/objc/ioslints/Makefile +++ b/infer/tests/codetoanalyze/objc/ioslints/Makefile @@ -5,13 +5,7 @@ TESTS_DIR = ../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -fobjc-arc -c \ +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc ANALYZER = linters INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \ @@ -26,3 +20,4 @@ SOURCES = \ $(wildcard */*.m) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/linters-def-folder/Makefile b/infer/tests/codetoanalyze/objc/linters-def-folder/Makefile index ad2cd8942..a75becdc8 100644 --- a/infer/tests/codetoanalyze/objc/linters-def-folder/Makefile +++ b/infer/tests/codetoanalyze/objc/linters-def-folder/Makefile @@ -6,10 +6,11 @@ TESTS_DIR = ../../.. ANALYZER = linters -CLANG_OPTIONS = -c -fobjc-arc +CLANG_OPTIONS = -c -fobjc-arc $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --linters-def-folder checks --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = file.m include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/linters-for-test-only/Makefile b/infer/tests/codetoanalyze/objc/linters-for-test-only/Makefile index 2b6f72194..0614a2146 100644 --- a/infer/tests/codetoanalyze/objc/linters-for-test-only/Makefile +++ b/infer/tests/codetoanalyze/objc/linters-for-test-only/Makefile @@ -6,7 +6,7 @@ TESTS_DIR = ../../.. ANALYZER = linters -CLANG_OPTIONS = -fobjc-arc -c +CLANG_OPTIONS = -fobjc-arc -c $(IOS_CLANG_OPTIONS) INFER_OPTIONS = --cxx --linters-def-file al_definitions/linters_example.al --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests @@ -17,3 +17,4 @@ SOURCES = \ $(wildcard *.c) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/linters/Makefile b/infer/tests/codetoanalyze/objc/linters/Makefile index 27129c3f9..e2a0ac9a5 100644 --- a/infer/tests/codetoanalyze/objc/linters/Makefile +++ b/infer/tests/codetoanalyze/objc/linters/Makefile @@ -6,9 +6,9 @@ TESTS_DIR = ../../.. ANALYZER = linters -CLANG_OPTIONS = -x objective-c -fobjc-arc -c +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) -fobjc-arc INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \ ---linters-doc-url "ASSIGN_POINTER_WARNING:www.example.com" + --linters-doc-url "ASSIGN_POINTER_WARNING:www.example.com" INFERPRINT_OPTIONS = --issues-tests SOURCES = \ @@ -16,3 +16,4 @@ SOURCES = \ $(wildcard */*.m) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m index ca656ac8e..e7e1c1d88 100644 --- a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m +++ b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController.m @@ -5,8 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -#import -@interface ViewController : NSViewController +#import + +@interface ViewController : NSObject @end @implementation ViewController diff --git a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m index 19ba08f2a..2805e87dd 100644 --- a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m +++ b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController2.m @@ -5,8 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -#import -@interface ViewController : NSViewController +#import + +@interface ViewController : NSObject @end @implementation ViewController diff --git a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m index 78ef77aab..8d3bdc70e 100644 --- a/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m +++ b/infer/tests/codetoanalyze/objc/linters/registered_observer/ViewController3.m @@ -5,9 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -#import +#import -@interface ViewControllerError : NSViewController +@interface ViewControllerError : NSObject @end @implementation ViewControllerError diff --git a/infer/tests/codetoanalyze/objc/liveness/Makefile b/infer/tests/codetoanalyze/objc/liveness/Makefile index 9cf0a015c..7902d11a8 100644 --- a/infer/tests/codetoanalyze/objc/liveness/Makefile +++ b/infer/tests/codetoanalyze/objc/liveness/Makefile @@ -6,12 +6,13 @@ TESTS_DIR = ../../.. ANALYZER = checkers -CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c +CLANG_OPTIONS = -fobjc-arc -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --liveness-only --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.m) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/objc/nullable/Makefile b/infer/tests/codetoanalyze/objc/nullable/Makefile index 768546430..e221f627e 100644 --- a/infer/tests/codetoanalyze/objc/nullable/Makefile +++ b/infer/tests/codetoanalyze/objc/nullable/Makefile @@ -6,12 +6,13 @@ TESTS_DIR = ../../.. ANALYZER = checkers -CLANG_OPTIONS = -c +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --debug-exceptions --no-default-checkers --suggest-nullable --check-nullable --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.m) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/objc/quandary/Makefile b/infer/tests/codetoanalyze/objc/quandary/Makefile index 32ebebcd4..e36cbe3ff 100644 --- a/infer/tests/codetoanalyze/objc/quandary/Makefile +++ b/infer/tests/codetoanalyze/objc/quandary/Makefile @@ -5,13 +5,7 @@ TESTS_DIR = ../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - -CLANG_OPTIONS = -x objective-c \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) ANALYZER = quandary INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --iphoneos-target-sdk-version 8.0 @@ -21,3 +15,4 @@ SOURCES = \ $(wildcard *.m) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/uninit/Makefile b/infer/tests/codetoanalyze/objc/uninit/Makefile index e29d1d06c..3096460e3 100644 --- a/infer/tests/codetoanalyze/objc/uninit/Makefile +++ b/infer/tests/codetoanalyze/objc/uninit/Makefile @@ -7,12 +7,13 @@ TESTS_DIR = ../../.. ANALYZER = checkers # see explanations in cpp/errors/Makefile for the custom isystem -CLANG_OPTIONS = -x objective-c -c +CLANG_OPTIONS = -c $(OBJC_CLANG_OPTIONS) INFER_OPTIONS = --uninit-only --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.m) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/objc/uninit/uninit.m b/infer/tests/codetoanalyze/objc/uninit/uninit.m index 624e5f42f..796484db8 100644 --- a/infer/tests/codetoanalyze/objc/uninit/uninit.m +++ b/infer/tests/codetoanalyze/objc/uninit/uninit.m @@ -4,7 +4,9 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -#include +#import +#import +#import @interface A : NSObject diff --git a/infer/tests/codetoanalyze/objcpp/errors/Makefile b/infer/tests/codetoanalyze/objcpp/errors/Makefile index 5fee7141b..363beece7 100644 --- a/infer/tests/codetoanalyze/objcpp/errors/Makefile +++ b/infer/tests/codetoanalyze/objcpp/errors/Makefile @@ -6,10 +6,11 @@ TESTS_DIR = ../../.. ANALYZER = checkers -CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c +CLANG_OPTIONS = -c $(OBJCPP_CLANG_OPTIONS) -fobjc-arc INFER_OPTIONS = --biabduction-only --no-filtering --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.mm) $(wildcard */*.mm) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objcpp/frontend/Makefile b/infer/tests/codetoanalyze/objcpp/frontend/Makefile index bd7ed5cd8..64fc87c3c 100644 --- a/infer/tests/codetoanalyze/objcpp/frontend/Makefile +++ b/infer/tests/codetoanalyze/objcpp/frontend/Makefile @@ -5,13 +5,7 @@ TESTS_DIR=../../.. -IPHONESIMULATOR_ISYSROOT_SUFFIX = /Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk - -XCODEROOT = $(shell $(XCODE_SELECT) -p) - -CLANG_OPTIONS = -x objective-c++ -std=c++11 \ - -isysroot $(XCODEROOT)$(IPHONESIMULATOR_ISYSROOT_SUFFIX) \ - -mios-simulator-version-min=8.2 --target=x86_64-apple-darwin14 -c \ +CLANG_OPTIONS = -c $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = @@ -19,3 +13,4 @@ SOURCES = \ $(wildcard */*.mm) \ include $(TESTS_DIR)/clang-frontend.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objcpp/linters-for-test-only/Makefile b/infer/tests/codetoanalyze/objcpp/linters-for-test-only/Makefile index 49fb730d6..3a0091daf 100644 --- a/infer/tests/codetoanalyze/objcpp/linters-for-test-only/Makefile +++ b/infer/tests/codetoanalyze/objcpp/linters-for-test-only/Makefile @@ -6,7 +6,7 @@ TESTS_DIR = ../../.. ANALYZER = linters -CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c +CLANG_OPTIONS = -fobjc-arc -c $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = --cxx --linters-def-file linters_example.al --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests @@ -17,3 +17,4 @@ SOURCES = \ $(wildcard *.c) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objcpp/linters/Makefile b/infer/tests/codetoanalyze/objcpp/linters/Makefile index 0c2fe5df9..03a4cd434 100644 --- a/infer/tests/codetoanalyze/objcpp/linters/Makefile +++ b/infer/tests/codetoanalyze/objcpp/linters/Makefile @@ -6,9 +6,9 @@ TESTS_DIR = ../../.. ANALYZER = linters -CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c +CLANG_OPTIONS = -c -fobjc-arc $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \ ---enable-issue-type GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL + --enable-issue-type GLOBAL_VARIABLE_INITIALIZED_WITH_FUNCTION_OR_METHOD_CALL INFERPRINT_OPTIONS = --issues-tests SOURCES = \ @@ -16,3 +16,4 @@ SOURCES = \ $(wildcard */*.mm) \ include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make diff --git a/infer/tests/codetoanalyze/objc/liveness/CoreFoundationExample.m b/infer/tests/codetoanalyze/objcpp/liveness/CoreFoundationExample.mm similarity index 100% rename from infer/tests/codetoanalyze/objc/liveness/CoreFoundationExample.m rename to infer/tests/codetoanalyze/objcpp/liveness/CoreFoundationExample.mm diff --git a/infer/tests/codetoanalyze/objcpp/liveness/Makefile b/infer/tests/codetoanalyze/objcpp/liveness/Makefile index d325c2a27..535e90a20 100644 --- a/infer/tests/codetoanalyze/objcpp/liveness/Makefile +++ b/infer/tests/codetoanalyze/objcpp/liveness/Makefile @@ -6,12 +6,13 @@ TESTS_DIR = ../../.. ANALYZER = checkers -CLANG_OPTIONS = -x objective-c++ -std=c++11 -fobjc-arc -c +CLANG_OPTIONS = -fobjc-arc -c $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = --liveness-only --debug-exceptions --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.mm) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/codetoanalyze/objcpp/nullable/Makefile b/infer/tests/codetoanalyze/objcpp/nullable/Makefile index 5bd27238f..f826e2828 100644 --- a/infer/tests/codetoanalyze/objcpp/nullable/Makefile +++ b/infer/tests/codetoanalyze/objcpp/nullable/Makefile @@ -6,12 +6,13 @@ TESTS_DIR = ../../.. ANALYZER = checkers -CLANG_OPTIONS = -c +CLANG_OPTIONS = -c $(OBJCPP_CLANG_OPTIONS) INFER_OPTIONS = --debug-exceptions --no-default-checkers --suggest-nullable --check-nullable --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --issues-tests SOURCES = $(wildcard *.mm) include $(TESTS_DIR)/clang.make +include $(TESTS_DIR)/objc.make infer-out/report.json: $(MAKEFILE_LIST) diff --git a/infer/tests/objc.make b/infer/tests/objc.make new file mode 100644 index 000000000..2c4016bf6 --- /dev/null +++ b/infer/tests/objc.make @@ -0,0 +1,17 @@ +# Copyright (c) 2018-present, Facebook, Inc. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +IPHONESIMULATOR_ISYSROOT = $(XCODE_BASE)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk + +OBJC_TARGET = x86_64-apple-darwin14 + +IOS_SIMULATOR_VERSION = 8.2 + +IOS_CLANG_OPTIONS = -isysroot $(IPHONESIMULATOR_ISYSROOT) \ + -target $(OBJC_TARGET) -mios-simulator-version-min=$(IOS_SIMULATOR_VERSION) + +OBJC_CLANG_OPTIONS = $(IOS_CLANG_OPTIONS) -x objective-c + +OBJCPP_CLANG_OPTIONS = $(IOS_CLANG_OPTIONS) -x objective-c++ -std=c++11