[linters] Add option to blacklist the unavailable api check for some files

Reviewed By: jberdine

Differential Revision: D5236287

fbshipit-source-id: ef801ee
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent 03703e316c
commit 99a0f894b6

@ -1128,6 +1128,13 @@ and iphoneos_target_sdk_version =
~in_help:CLOpt.[Capture, manual_clang_linters]
"Specify the target SDK version to use for iphoneos"
and iphoneos_target_sdk_version_skip_path =
CLOpt.mk_string_list ~long:"iphoneos-target-sdk-version-skip-path"
~in_help:CLOpt.[Capture, manual_clang_linters]
~meta:"path prefix OCaml regex"
"To be used together with iphoneos-target-sdk-version, \
to disable that flag in a particular path (can be specified multiple times)"
and issues_fields =
CLOpt.mk_symbol_seq ~long:"issues-fields"
~in_help:CLOpt.[Report, manual_generic]
@ -1899,6 +1906,7 @@ and ignore_trivial_traces = !ignore_trivial_traces
and immutable_cast = !immutable_cast
and infer_cache = !infer_cache
and iphoneos_target_sdk_version = !iphoneos_target_sdk_version
and iphoneos_target_sdk_version_skip_path = !iphoneos_target_sdk_version_skip_path
and issues_fields = !issues_fields
and iterations = !iterations
and java_jar_compiler = !java_jar_compiler

@ -251,6 +251,7 @@ val ignore_trivial_traces : bool
val immutable_cast : bool
val infer_cache : string option
val iphoneos_target_sdk_version : string option
val iphoneos_target_sdk_version_skip_path : string list
val issues_fields : [`Issue_field_bug_class
| `Issue_field_kind
| `Issue_field_bug_type

@ -328,9 +328,19 @@ let is_class an re =
declaration_has_name an re
| _ -> false
let should_use_iphoneos_target_sdk_version (cxt : CLintersContext.context) =
let source_file = cxt.translation_unit_context.source_file in
not (List.exists
~f:(fun path -> ALVar.str_match_regex (SourceFile.to_rel_path source_file) path)
Config.iphoneos_target_sdk_version_skip_path)
let decl_unavailable_in_supported_ios_sdk (cxt : CLintersContext.context) an =
let config_iphoneos_target_sdk_version =
if should_use_iphoneos_target_sdk_version cxt then
Config.iphoneos_target_sdk_version
else None in
let allowed_os_versions =
match Config.iphoneos_target_sdk_version,
match config_iphoneos_target_sdk_version,
(cxt.if_context : CLintersContext.if_context option) with
| Some iphoneos_target_sdk_version, Some if_context ->
iphoneos_target_sdk_version :: if_context.ios_version_guard

@ -17,7 +17,9 @@ CLANG_OPTIONS = -x objective-c \
ANALYZER = linters
INFER_OPTIONS = --no-filtering --debug-exceptions --project-root $(TESTS_DIR) \
--iphoneos-target-sdk-version 8.0 --no-failures-allowed
--iphoneos-target-sdk-version 8.0 \
--iphoneos-target-sdk-version-skip-path "codetoanalyze/objc/ioslints/filter_out_unavailable_api\.m" \
--no-failures-allowed
INFERPRINT_OPTIONS = --issues-tests
SOURCES = \

@ -0,0 +1,27 @@
/*
* 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 <UIKit/UIKit.h>
@interface Filter_out_unavailable_api : NSObject
- (void)n NS_AVAILABLE(10_12, 10_0);
@end
@implementation Filter_out_unavailable_api
- (void)n {
}
// no bug
- (void)with_responds_to_selector:(Filter_out_unavailable_api*)a {
[a n];
}
@end
Loading…
Cancel
Save