[cfe-commits] r109866 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/synth-provisional-ivars.m
Fariborz Jahanian
fjahanian at apple.com
Fri Jul 30 09:59:05 PDT 2010
Author: fjahanian
Date: Fri Jul 30 11:59:05 2010
New Revision: 109866
URL: http://llvm.org/viewvc/llvm-project?rev=109866&view=rev
Log:
Tighten the rules when deciding if an ivar must be
auto-synthesized (nonfragile-abi2 specific).
Fixes radar 8251648.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/synth-provisional-ivars.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=109866&r1=109865&r2=109866&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jul 30 11:59:05 2010
@@ -1005,8 +1005,8 @@
}
static ObjCPropertyDecl *OkToSynthesizeProvisionalIvar(Sema &SemaRef,
- IdentifierInfo *II,
- SourceLocation NameLoc) {
+ IdentifierInfo *II,
+ SourceLocation NameLoc) {
ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl();
ObjCInterfaceDecl *IDecl = CurMeth->getClassInterface();
if (!IDecl)
@@ -1024,9 +1024,21 @@
}
static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef,
+ LookupResult &Lookup,
IdentifierInfo *II,
SourceLocation NameLoc) {
ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl();
+ bool LookForIvars;
+ if (Lookup.empty())
+ LookForIvars = true;
+ else if (CurMeth->isClassMethod())
+ LookForIvars = false;
+ else
+ LookForIvars = (Lookup.isSingleResult() &&
+ Lookup.getFoundDecl()->isDefinedOutsideFunctionOrMethod());
+ if (!LookForIvars)
+ return 0;
+
ObjCInterfaceDecl *IDecl = CurMeth->getClassInterface();
if (!IDecl)
return 0;
@@ -1122,7 +1134,7 @@
if (Ex) return Owned(Ex);
// Synthesize ivars lazily
if (getLangOptions().ObjCNonFragileABI2) {
- if (SynthesizeProvisionalIvar(*this, II, NameLoc))
+ if (SynthesizeProvisionalIvar(*this, R, II, NameLoc))
return ActOnIdExpression(S, SS, Id, HasTrailingLParen,
isAddressOfOperand);
}
Modified: cfe/trunk/test/SemaObjC/synth-provisional-ivars.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/synth-provisional-ivars.m?rev=109866&r1=109865&r2=109866&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/synth-provisional-ivars.m (original)
+++ cfe/trunk/test/SemaObjC/synth-provisional-ivars.m Fri Jul 30 11:59:05 2010
@@ -43,3 +43,8 @@
- (int) Meth { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}}
@end
+ at implementation I(r8251648)
+- (int) Meth1: (int) bar {
+ return bar; // expected-warning {{local declaration of 'bar' hides instance variable}}
+}
+ at end
More information about the cfe-commits
mailing list