Reviewed By: jeremydubreil Differential Revision: D6173238 fbshipit-source-id: dc93a54master
parent
6047264e4a
commit
c98570f899
@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2017 - 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.
|
||||||
|
|
||||||
|
TESTS_DIR = ../../..
|
||||||
|
|
||||||
|
ANALYZER = checkers
|
||||||
|
# see explanations in cpp/errors/Makefile for the custom isystem
|
||||||
|
CLANG_OPTIONS = -x objective-c -c
|
||||||
|
INFER_OPTIONS = --uninit-only --debug-exceptions --project-root $(TESTS_DIR)
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
|
||||||
|
SOURCES = uninit_blocks.m
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/clang.make
|
||||||
|
|
||||||
|
infer-out/report.json: $(MAKEFILE_LIST)
|
@ -0,0 +1 @@
|
|||||||
|
codetoanalyze/objc/uninit/uninit_blocks.m, A_bad1, 5, UNINITIALIZED_VALUE, []
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - 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.
|
||||||
|
*/
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
|
@interface A : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
typedef void (^MyBlock)();
|
||||||
|
|
||||||
|
@interface C : NSObject
|
||||||
|
|
||||||
|
+ (void)use_block:(MyBlock)block;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation A
|
||||||
|
|
||||||
|
+ (int)ok1 {
|
||||||
|
__block int a;
|
||||||
|
[C use_block:^() {
|
||||||
|
a = 10;
|
||||||
|
}];
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
|
||||||
|
+ (int)bad1 {
|
||||||
|
int a;
|
||||||
|
[C use_block:^() {
|
||||||
|
int x = 0;
|
||||||
|
}];
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
|
||||||
|
+ (instancetype)ok2 {
|
||||||
|
static id sharedInstance;
|
||||||
|
^{
|
||||||
|
sharedInstance = [[self alloc] init];
|
||||||
|
}();
|
||||||
|
|
||||||
|
return sharedInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in new issue