Reviewed By: jberdine Differential Revision: D8833491 fbshipit-source-id: 699319454master
parent
34c2899a69
commit
4b69087ad5
@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2017-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.
|
||||
|
||||
MODELS_DIR = ../..
|
||||
include $(MODELS_DIR)/models-config.make
|
||||
|
||||
MM_SOURCES=$(wildcard *.mm)
|
||||
M_SOURCES=$(shell find -L . -name "*.m")
|
||||
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)
|
||||
|
||||
all: $(OBJECTS)
|
||||
|
||||
clean:
|
||||
$(QUIET)rm -rf $(OBJECTS)
|
||||
|
||||
%.o: %.mm
|
||||
$(CXX) $(CXXFLAGS) $< -o $@
|
||||
|
||||
%_cxx.o: %.m
|
||||
$(CXX) $(CXXFLAGS) $< -o $@
|
||||
|
||||
%_cxx.o: %.c
|
||||
$(CXX) $(CXXFLAGS) $< -o $@
|
||||
|
||||
.PHONY: all clean
|
@ -0,0 +1 @@
|
||||
../../objc/src
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface A : NSObject
|
||||
@property(strong) void (^block)(void);
|
||||
@end
|
||||
|
||||
@implementation A
|
||||
|
||||
+ (instancetype)autoUpdating {
|
||||
static A* a;
|
||||
dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
a = [self alloc];
|
||||
a.block = ^{
|
||||
};
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
static void dispatch_once2(dispatch_once_t* predicate, dispatch_block_t block);
|
||||
+ (instancetype)autoUpdating2 {
|
||||
static A* a;
|
||||
dispatch_once_t onceToken;
|
||||
dispatch_once2(&onceToken, ^{
|
||||
a = [self alloc];
|
||||
a.block = ^{
|
||||
};
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main() {
|
||||
A* a = [A autoUpdating];
|
||||
A* a2 = [A autoUpdating2];
|
||||
a.block();
|
||||
a2.block(); // NPE here since dispatch_once2 is skipped
|
||||
}
|
@ -1 +1,2 @@
|
||||
codetoanalyze/objcpp/errors/retain_cycles/RetainCycleWithStruct.mm, main_bad, 2, RETAIN_CYCLE, [start of procedure main_bad(),start of procedure tracer,start of procedure _State,return from a call to _State__State,start of procedure initWithAnimation:,Condition is true,return from a call to Tracer_initWithAnimation:,return from a call to Animation_tracer]
|
||||
codetoanalyze/objcpp/errors/c_functions.mm, main, 4, NULL_DEREFERENCE, B5, ERROR, [start of procedure main(),start of procedure autoUpdating,return from a call to A_autoUpdating,start of procedure autoUpdating2,Skipping dispatch_once2(): method has no implementation,return from a call to A_autoUpdating2,Executing synthesized getter block,start of procedure block,return from a call to objc_blockobjc_blockA_autoUpdating_1_2,Message block with receiver nil returns nil.]
|
||||
codetoanalyze/objcpp/errors/retain_cycles/RetainCycleWithStruct.mm, Animation_tracer, 2, RETAIN_CYCLE, no_bucket, ERROR, [start of procedure tracer,start of procedure _State,return from a call to _State__State,start of procedure initWithAnimation:,Taking true branch,return from a call to Tracer_initWithAnimation:]
|
||||
|
Loading…
Reference in new issue