[componentkit][const] Ignore NSError

Reviewed By: martinoluca

Differential Revision: D3912232

fbshipit-source-id: adc8a55
master
Ryan Rhee 8 years ago committed by Facebook Github Bot 3
parent 7a434adea8
commit 6475e358c4

@ -77,15 +77,21 @@ let mutable_local_vars_advice context decl =
let rec get_referenced_type (qual_type: Clang_ast_t.qual_type) : Clang_ast_t.decl option =
let typ_opt = Ast_utils.get_desugared_type qual_type.qt_type_ptr in
match (typ_opt : Clang_ast_t.c_type option) with
| Some ObjCInterfaceType (_, decl_ptr)
| Some RecordType (_, decl_ptr) -> Ast_utils.get_decl decl_ptr
| Some PointerType (_, inner_qual_type)
| Some ObjCObjectPointerType (_, inner_qual_type)
| Some LValueReferenceType (_, inner_qual_type) -> get_referenced_type inner_qual_type
| _ -> None in
let is_of_whitelisted_type qual_type =
let whitelist = ["CKComponentScope"; "FBTrackingNodeScope"; "FBTrackingCodeScope"] in
let cpp_whitelist = ["CKComponentScope"; "FBTrackingNodeScope"; "FBTrackingCodeScope"] in
let objc_whitelist = ["NSError"] in
match get_referenced_type qual_type with
| Some CXXRecordDecl (_, ndi, _, _, _, _, _, _) ->
IList.mem string_equal ndi.ni_name whitelist
IList.mem string_equal ndi.ni_name cpp_whitelist
| Some ObjCInterfaceDecl (_, ndi, _, _, _) ->
IList.mem string_equal ndi.ni_name objc_whitelist
| _ -> false in
match decl with

@ -60,9 +60,9 @@
const BOOL f = YES; // no error
// Pointer types
NSError* const error = nil; // no error
NSError* const* g = &error; // error
NSError* const* const h = &error; // no error
NSObject* const o1 = nil; // no error
NSObject* const* o2 = &o1; // error
NSObject* const* const o3 = &o1; // no error
return [super newWithComponent:[CKLabelComponent newWithLabelAttributes:{
.string = [@[ a, b, c, d ] componentsJoinedByString:@", "],
@ -93,5 +93,12 @@ class BarClass {
CKComponentScope& w3 = w1; // no error
// const CKComponentScope w4 = {.a = 3}; // Can't, lacks default ctor
const CKComponentScope w4(self); // no error
// Whitelisted Objc class
NSError* const e = nil; // no error
NSError** e1; // no error
NSError const** e2; // no error
NSError* const* e3 = &e; // no error
NSError* const* const e4 = &e; // no error
}
@end

Loading…
Cancel
Save