aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-06-19 22:51:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-06-19 22:51:22 +0000
commitdd3284b17829adfd542ecf4a7b4423dce1d7502b (patch)
tree9d89f395d1e98387dd39bc7477cb2ad3ff7b5e1c /lib/Sema/SemaObjCProperty.cpp
parentfc685ace387734599c475426b1a8efdb491054b8 (diff)
objective-c: warn when autosynthesizing a property which has same
name as an existing ivar since this is common source of error when people remove @synthesize to take advantage of autosynthesis. // rdar://11671080 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--lib/Sema/SemaObjCProperty.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index 84dc9cae23..20dbf58c98 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -755,6 +755,22 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
}
if (!Ivar) {
+ if (AtLoc.isInvalid()) {
+ // Check when default synthesizing a property that there is
+ // an ivar matching property name and issue warning; since this
+ // is the most common case of not using an ivar used for backing
+ // property in non-default synthesis case.
+ ObjCInterfaceDecl *ClassDeclared=0;
+ ObjCIvarDecl *originalIvar =
+ IDecl->lookupInstanceVariable(property->getIdentifier(),
+ ClassDeclared);
+ if (originalIvar) {
+ Diag(PropertyDiagLoc,
+ diag::warn_autosynthesis_property_ivar_match);
+ Diag(property->getLocation(), diag::note_property_declare);
+ Diag(originalIvar->getLocation(), diag::note_ivar_decl);
+ }
+ }
// In ARC, give the ivar a lifetime qualifier based on the
// property attributes.
if (getLangOpts().ObjCAutoRefCount &&