Reviewed By: dulmarod Differential Revision: D8690918 fbshipit-source-id: 436c17emaster
parent
60b74766d5
commit
1ee0390f3c
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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/NSObject.h>
|
||||
|
||||
@interface A : NSObject
|
||||
@property(assign) id delegate;
|
||||
@end
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 "A.h"
|
||||
|
||||
@implementation A
|
||||
- (void)implOnlyFn:(int)v {
|
||||
}
|
||||
@end
|
||||
|
||||
bool predA() {
|
||||
A* a = [A new];
|
||||
[a implOnlyFn:1];
|
||||
return (a.delegate ? 0 : 0);
|
||||
}
|
||||
|
||||
// NULL_DEREFERECE is (correctly) reported on only one of the branches
|
||||
int badOnlyOneNDA() {
|
||||
int x, *p1 = 0, *p2 = 0;
|
||||
if (predA())
|
||||
x = *p1;
|
||||
else
|
||||
x = *p2;
|
||||
return x;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#import "A.h"
|
||||
|
||||
bool predB() {
|
||||
A* a = [A new];
|
||||
// implOnlyFn added in A.m (is valid but missing from the tenv for B.m)
|
||||
[a implOnlyFn:1];
|
||||
// Missing_fld reported here causing the spec to be missing
|
||||
return (a.delegate ? 0 : 0);
|
||||
}
|
||||
|
||||
// NULL_DEREFERENCE is reported on both branches since fB() lacks a spec
|
||||
int badOnlyOneNDB() {
|
||||
int x, *p1 = 0, *p2 = 0;
|
||||
if (predB())
|
||||
x = *p1;
|
||||
else
|
||||
x = *p2;
|
||||
return x;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
# 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.
|
||||
|
||||
TESTS_DIR = ../..
|
||||
ROOT_DIR = $(TESTS_DIR)/../..
|
||||
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
|
||||
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
|
||||
|
||||
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))
|
@ -0,0 +1,3 @@
|
||||
build_systems/codetoanalyze/objc_missing_fld/A.m, badOnlyOneNDA, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure badOnlyOneNDA(),start of procedure predA(),start of procedure implOnlyFn:,return from a call to A_implOnlyFn:,Executing synthesized getter delegate,Condition is true,return from a call to predA,Taking false branch]
|
||||
build_systems/codetoanalyze/objc_missing_fld/B.m, badOnlyOneNDB, 3, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure badOnlyOneNDB(),Taking true branch]
|
||||
build_systems/codetoanalyze/objc_missing_fld/B.m, badOnlyOneNDB, 5, NULL_DEREFERENCE, no_bucket, ERROR, [start of procedure badOnlyOneNDB(),Taking false branch]
|
Loading…
Reference in new issue