[SelfInBlock] Fix a bug in exps_of_instr where some expressions were missed.

Summary: This fixes false positives in the SelfInBlock checker.

Reviewed By: jvillard

Differential Revision: D19789906

fbshipit-source-id: 82d4da346
master
Dulma Churchill 5 years ago committed by Facebook Github Bot
parent 682f8c5355
commit a864823f38

@ -126,8 +126,9 @@ let exps_of_instr = function
[e1; e2]
| Prune (cond, _, _, _) ->
[cond]
| Call ((id, _), e, _, _, _) ->
[e; Exp.Var id]
| Call ((id, _), e, exps, _, _) ->
let exps = List.map ~f:fst exps in
e :: Exp.Var id :: exps
| Metadata metadata ->
exps_of_instr_metadata metadata

@ -21,7 +21,9 @@
- (B*)process:(B*)obj;
@end
@implementation A
@implementation A {
int x;
}
- (B*)process:(B*)obj {
return obj;
@ -62,4 +64,23 @@
return resultsList;
}
- (NSMutableArray<B*>*)weak_in_block_inside_noescape_block_good:
(NSArray<B*>*)allResults {
NSMutableArray<B*>* resultsList = [[NSMutableArray alloc] init];
__weak __typeof(self) weakSelf = self;
[allResults enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
B* result = [self process:obj];
if (result != nil) {
[resultsList addObject:result];
}
[ArrayUtils enumerate:^(id obj, NSUInteger idx, BOOL* stop) {
__strong __typeof(weakSelf) strongSelf = weakSelf; // no bug here
if (strongSelf) {
int x = strongSelf->x;
}
}];
}];
return resultsList;
}
@end

Loading…
Cancel
Save