[PATCH] [ObjC] New warning: circular containers

Alexey Denisov 1101.debian at gmail.com
Mon Mar 2 13:28:08 PST 2015


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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8014.21034.patch
Type: text/x-patch
Size: 24074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150302/bbaf38d3/attachment.bin>


More information about the cfe-commits mailing list