Reviewed By: dulmarod Differential Revision: D4699748 fbshipit-source-id: 39f7c05master
parent
4a62c44a3e
commit
df543b900b
@ -0,0 +1,19 @@
|
|||||||
|
# Copyright (c) 2016 - 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 = linters
|
||||||
|
CLANG_OPTIONS = -x objective-c -fobjc-arc -c
|
||||||
|
INFER_OPTIONS = --linters-def-file linters_example.al --no-filtering --debug-exceptions --project-root $(TESTS_DIR) --no-failures-allowed
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
|
||||||
|
SOURCES = \
|
||||||
|
$(wildcard *.m) \
|
||||||
|
$(wildcard */*.m) \
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/clang.make
|
@ -0,0 +1,4 @@
|
|||||||
|
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 26, SUBCLASSING_TEST_EXAMPLE, []
|
||||||
|
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 41, SUBCLASSING_TEST_EXAMPLE, []
|
||||||
|
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 47, SUBCLASSING_TEST_EXAMPLE, []
|
||||||
|
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 53, SUBCLASSING_TEST_EXAMPLE, []
|
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
// Check that class A is not subclassed.
|
||||||
|
DEFINE-CHECKER SUBCLASSING_TEST_EXAMPLE = {
|
||||||
|
|
||||||
|
SET report_when =
|
||||||
|
is_class(A) HOLDS-IN-SOME-SUPERCLASS-OF ObjCInterfaceDecl;
|
||||||
|
|
||||||
|
SET message = "This is subclassing A. Class A should not be subclassed.";
|
||||||
|
|
||||||
|
};
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
- (int)foo:(int)foo_par;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation A
|
||||||
|
|
||||||
|
- (int)foo:(int)foo_par {
|
||||||
|
|
||||||
|
return foo_par;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface B : A // Error: A subclass
|
||||||
|
|
||||||
|
- (void)bar;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation B
|
||||||
|
|
||||||
|
- (void)bar {
|
||||||
|
A* a = [[A alloc] init];
|
||||||
|
[a foo:5];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface C : B // Error: C subclass of B subclass of A
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation C
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface D : C // Error: D subclass of C ... subclass of A
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation D
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface E : D // Error: E subclass of D ... subclass of A
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation E
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface F : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation F
|
||||||
|
@end
|
Loading…
Reference in new issue