]> granicus.if.org Git - clang/commit
[analyzer] Model getters of known-@synthesized Objective-C properties.
authorJordan Rose <jordan_rose@apple.com>
Fri, 10 Jan 2014 20:06:06 +0000 (20:06 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 10 Jan 2014 20:06:06 +0000 (20:06 +0000)
commitf0708cabe777e551ebe7052407edcf85b39aa95f
treedb5df7c18bb80d4aec924a73e255279098c49ce5
parent33ab4d05a0f75b13d8c5d3a0e80ad9115716cae1
[analyzer] Model getters of known-@synthesized Objective-C properties.

...by synthesizing their body to be "return self->_prop;", with an extra
nudge to RetainCountChecker to still treat the value as +0 if we have no
other information.

This doesn't handle weak properties, but that's mostly correct anyway,
since they can go to nil at any time. This also doesn't apply to properties
whose implementations we can't see, since they may not be backed by an
ivar at all. And finally, this doesn't handle properties of C++ class type,
because we can't invoke the copy constructor. (Sema has actually done this
work already, but the AST it synthesizes is one the analyzer doesn't quite
handle -- it has an rvalue DeclRefExpr.)

Modeling setters is likely to be more difficult (since it requires
handling strong/copy), but not impossible.

<rdar://problem/11956898>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198953 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/AnalysisDeclContext.cpp
lib/Analysis/BodyFarm.cpp
lib/Analysis/BodyFarm.h
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
lib/StaticAnalyzer/Core/CallEvent.cpp
test/Analysis/properties.m
test/Analysis/properties.mm [new file with mode: 0644]