From 6c82e824447aab6285f979ed2553254efe73c9ee Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Fri, 17 Feb 2017 09:23:01 -0800 Subject: [PATCH] [linters] Fix one more unavailable api false positive Reviewed By: akotulski Differential Revision: D4578891 fbshipit-source-id: c6443a1 --- infer/src/clang/cFrontend_checkers_main.ml | 4 +++- infer/tests/codetoanalyze/objc/ioslints/issues.exp | 10 +++++----- .../objc/ioslints/unavailable_api_allowed_cases.m | 10 ++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 9759d69dc..27b65c7fc 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -52,7 +52,9 @@ let rec get_responds_to_selector stmt = | BinaryOperator (_, [stmt1;stmt2], _, bo_info) when PVariant.(=) bo_info.Clang_ast_t.boi_kind `LAnd -> List.append (get_responds_to_selector stmt1) (get_responds_to_selector stmt2) - | ImplicitCastExpr (_, [stmt], _, _) -> + | ImplicitCastExpr (_, [stmt], _, _) + | ParenExpr (_, [stmt], _) + | ExprWithCleanups(_, [stmt], _, _) -> get_responds_to_selector stmt | _ -> [] diff --git a/infer/tests/codetoanalyze/objc/ioslints/issues.exp b/infer/tests/codetoanalyze/objc/ioslints/issues.exp index fa17cf753..2f4907f14 100644 --- a/infer/tests/codetoanalyze/objc/ioslints/issues.exp +++ b/infer/tests/codetoanalyze/objc/ioslints/issues.exp @@ -1,7 +1,7 @@ -codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_m2, 120, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] -codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_m3:, 128, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] -codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_uifont_without_respondstoselector:, 102, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] -codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_with_responds_to_selector_in_else:, 68, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] -codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_without_responds_to_selector:, 61, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] +codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_m2, 123, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] +codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_m3:, 131, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] +codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_uifont_without_respondstoselector:, 105, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] +codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_with_responds_to_selector_in_else:, 71, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] +codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m, Unavailable_api_allowed_cases_without_responds_to_selector:, 64, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] codetoanalyze/objc/ioslints/unavailable_api_in_supported_ios_sdk.m, OpenURLOptionsFromSourceApplication, 26, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] codetoanalyze/objc/ioslints/unavailable_api_in_supported_ios_sdk.m, Unavailable_api_in_supported_ios_sdk_test:and:, 19, UNAVAILABLE_API_IN_SUPPORTED_IOS_SDK, [] diff --git a/infer/tests/codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m b/infer/tests/codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m index 5848ba667..cbaaf859d 100644 --- a/infer/tests/codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m +++ b/infer/tests/codetoanalyze/objc/ioslints/unavailable_api_allowed_cases.m @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ #import +#import @interface Unavailable_api_allowed_cases : NSObject @@ -14,6 +15,8 @@ - (void)n NS_AVAILABLE(10_12, 10_0); +@property(nonatomic, strong) AVPlayer* player; + @end #define CK_AT_LEAST_IOS9 (kCFCoreFoundationVersionNumber >= 1223.1) @@ -185,4 +188,11 @@ } } +// no bug +- (void)playInReverse { + if ([self.player respondsToSelector:@selector(playImmediatelyAtRate:)]) { + [self.player playImmediatelyAtRate:-1.0]; + } +} + @end