[PATCH] [ObjC] New warning: circular containers

jahanian fjahanian at apple.com
Tue Mar 3 11:02:50 PST 2015


Patch looks good with couple of minors.
Provide a note where receiver/argument has been declared.
Place CheckObjCCircularContainer(Result) right after checkRetainCycles(Result).

- Fariborz


On Mar 2, 2015, at 1:28 PM, Alexey Denisov <1101.debian at gmail.com> wrote:

> The patch adds new warning to prevent user from creating 'circular containers'.
> Mutable collections from NSFoundation allows user to add collection to itself, e.g.:
> 
> NSMutableArray *a = [NSMutableArray new];
> [a addObject:a];
> 
> The code above leads to really weird behaviour (crashes, 'endless' recursion) and retain cycles (collection retains itself) and it's really hard to debug and fix.
> This which is really hard to debug in a real application.
> 
> Patch checks the following collections: NSMutableArray, NSMutableDictionary, NSMutableSet, NSMutableOrderedSet, NSCountedSet.
> 
> P.S. any suggestions for better wordings and methods/warning names - are welcome.
> 
> http://reviews.llvm.org/D8014
> 
> Files:
>  include/clang/AST/NSAPI.h
>  include/clang/Basic/DiagnosticSemaKinds.td
>  include/clang/Sema/Sema.h
>  lib/AST/NSAPI.cpp
>  lib/Sema/SemaChecking.cpp
>  lib/Sema/SemaExprObjC.cpp
>  test/SemaObjC/circular-container.m
> 
> EMAIL PREFERENCES
>  http://reviews.llvm.org/settings/panel/emailpreferences/
> <D8014.21034.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150303/2253e5b8/attachment.html>


More information about the cfe-commits mailing list