]> granicus.if.org Git - clang/commit
[analyzer] Don't treat calls to system headers as escaping in CheckObjCDealloc.
authorDevin Coughlin <dcoughlin@apple.com>
Mon, 29 Feb 2016 21:44:08 +0000 (21:44 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Mon, 29 Feb 2016 21:44:08 +0000 (21:44 +0000)
commit2d53cf1e66d20cc73a1d4f7bf28016f8ab497959
tree0b5fce2055cb28e5930089c79dd4f7cf93b3db9f
parent9c5efc9808b7e456857497166d38c0f8663716bc
[analyzer] Don't treat calls to system headers as escaping in CheckObjCDealloc.

This prevents false negatives when a -dealloc method, for example, removes itself as
as an observer with [[NSNotificationCenter defaultCenter] removeObserver:self]. It is
unlikely that passing 'self' to a system header method will release 'self''s instance
variables, so this is unlikely to produce false positives.

A challenge here is that while CheckObjCDealloc no longer treats these calls as
escaping, the rest of the analyzer still does. In particular, this means that loads
from the same instance variable before and after a call to a system header will
result in different symbols being loaded by the region store. To account for this,
the checker now treats different ivar symbols with the same instance and ivar decl as
the same for the purpose of release checking and more eagerly removes a release
requirement when an instance variable is assumed to be nil. This was not needed before
because when an ivar escaped its release requirement was always removed -- now the
requirement is not removed for calls to system headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262261 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
test/Analysis/DeallocMissingRelease.m
test/Analysis/Inputs/system-header-simulator-for-objc-dealloc.h [new file with mode: 0644]