[clang] Adding annotations for ObjC instance variables

Reviewed By: sblackshear

Differential Revision: D4649995

fbshipit-source-id: 668c2b8
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent c9bd0dae24
commit 15a0662149

@ -321,7 +321,8 @@ let module Struct = {
name
(
Pp.seq (
fun f (fld, t, _) => F.fprintf f "\n\t\t%a %a" (pp_full pe) t Ident.pp_fieldname fld
fun f (fld, t, a) =>
F.fprintf f "\n\t\t%a %a %a" (pp_full pe) t Ident.pp_fieldname fld Annot.Item.pp a
)
)
fields

@ -45,11 +45,12 @@ let build_sil_field type_ptr_to_sil_type tenv field_name type_ptr prop_attribute
let typ = type_ptr_to_sil_type tenv type_ptr in
let item_annotations = match prop_atts with
| [] ->
[({ Annot.class_name = Config.ivar_attributes; parameters = annotation_from_type typ },
true)]
({ Annot.class_name = Config.ivar_attributes; parameters = annotation_from_type typ },
true)
| _ ->
[({ Annot.class_name = Config.property_attributes; parameters = prop_atts },
true)] in
({ Annot.class_name = Config.property_attributes; parameters = prop_atts },
true) in
let item_annotations = item_annotations :: (CAst_utils.sil_annot_of_type type_ptr) in
fname, typ, item_annotations
(* Given a list of declarations in an interface returns a list of fields *)

@ -51,6 +51,7 @@ SOURCES_DEFAULT = \
shared/protocol_procdesc/Bicycle.m \
shared/protocol_procdesc/main.c \
shared/annotations/nullable_annotations.m \
shared/annotations/nullable_annotations_fields.m \
taint/sources.m \
taint/viewController.m \

@ -115,6 +115,7 @@ codetoanalyze/objc/errors/taint/sources.m, testNSHTTPCookie4, 5, TAINTED_VALUE_R
codetoanalyze/objc/errors/taint/viewController.m, ExampleDelegate_application:openURL:sourceApplication:annotation:, 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION, [start of procedure application:openURL:sourceApplication:annotation:,start of procedure init,return from a call to VCA_init,start of procedure ExampleSanitizer(),Condition is false,return from a call to ExampleSanitizer,Condition is false,Condition is true]
codetoanalyze/objc/shared/annotations/nullable_annotations.m, User_otherUserName, 2, NULL_DEREFERENCE, [start of procedure otherUserName]
codetoanalyze/objc/shared/annotations/nullable_annotations.m, npe_property_nullable, 3, NULL_DEREFERENCE, [start of procedure npe_property_nullable()]
codetoanalyze/objc/shared/annotations/nullable_annotations_fields.m, A_nullable_field, 3, NULL_DEREFERENCE, [start of procedure nullable_field]
codetoanalyze/objc/shared/block/block-it.m, MyBlock_array, 3, RETURN_VALUE_IGNORED, [start of procedure array,Condition is true]
codetoanalyze/objc/shared/block/block-it.m, __objc_anonymous_block_MyBlock_array______1, 5, UNINITIALIZED_VALUE, [start of procedure block,Condition is false]
codetoanalyze/objc/shared/block/block-it.m, __objc_anonymous_block_MyBlock_array_trans______2, 4, UNINITIALIZED_VALUE, [start of procedure block,Condition is false]

@ -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 <Foundation/NSObject.h>
@interface A : NSObject
@end
A* getA();
@implementation A {
int x;
A* _Nullable _child;
}
- (int)nullable_field {
A* a = getA();
A* child = a->_child;
return child->x;
}
@end
Loading…
Cancel
Save