]> granicus.if.org Git - clang/commit
New ObjC warning: circular containers.
authorAlex Denisov <1101.debian@gmail.com>
Wed, 4 Mar 2015 17:55:52 +0000 (17:55 +0000)
committerAlex Denisov <1101.debian@gmail.com>
Wed, 4 Mar 2015 17:55:52 +0000 (17:55 +0000)
commit5dc6c6cd87f3a86fe9d5ba9d1b3892252c7de248
treeb17f2233c307b5d34b4aa80e32ade7331e4f26ef
parent7a4bb7efcd280e94475501186889242e5ca16d36
New ObjC warning: circular containers.

This commit 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) if ARC enabled.

Patch checks the following collections:
  - NSMutableArray,
  - NSMutableDictionary,
  - NSMutableSet,
  - NSMutableOrderedSet,
  - NSCountedSet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231265 91177308-0d34-0410-b5e6-96231b3b80d8
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 [new file with mode: 0644]