[PATCH] D25844: [Sema][ObjC] Warn about implicitly autoreleasing indirect parameters that are captured by blocks
Anatoly Shcherbinin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 3 02:58:52 PST 2021
Cy-4AH added a comment.
Hello!
What compiler do when call doStuff:
NSString * __strong fillMe;
NSString * __autoreleasing autorelesingFillMe = fillMe;
doStuff(&fillMe);
fillMe = autoreleasingFillMe;
Why it's not making the same thing in doStuff body?
Compiler generated code for yours example should be:
void doStuff(NSString **fillMeIn) {
__block NSString *fillMeInResult;
__block BOOL fillMeInResultHasChanged = NO;
[@[@"array"] enumerateObjectsUsingBlock:
^(id obj, NSUInteger idx, BOOL* stop) {
*stop = YES;
fillMeInResult = [@"wow" mutableCopy];
fillMeInResultHasChanged = YES;
}
];
if (fillMeInResultHasChanged) {
*fillMeIn = fillMeInResult;
}
}
Instead we got this warning and had to do the same stuff in every implementation
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D25844/new/
https://reviews.llvm.org/D25844
More information about the cfe-commits
mailing list