[llvm-branch-commits] [cfe-branch] r101828 - in /cfe/branches/Apple/williamson: lib/Sema/SemaExprObjC.cpp lib/Sema/SemaLookup.cpp test/FixIt/typo.m
Daniel Dunbar
daniel at zuster.org
Mon Apr 19 16:08:26 PDT 2010
Author: ddunbar
Date: Mon Apr 19 18:08:26 2010
New Revision: 101828
URL: http://llvm.org/viewvc/llvm-project?rev=101828&view=rev
Log:
Merge in fixes for
<rdar://problem/7880396> Incorrect typo correction in Objective-C message send
--- Merging r101792 into '.':
U test/FixIt/typo.m
U lib/Sema/SemaLookup.cpp
--- Merging r101810 into '.':
U lib/Sema/SemaExprObjC.cpp
Modified:
cfe/branches/Apple/williamson/lib/Sema/SemaExprObjC.cpp
cfe/branches/Apple/williamson/lib/Sema/SemaLookup.cpp
cfe/branches/Apple/williamson/test/FixIt/typo.m
Modified: cfe/branches/Apple/williamson/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Sema/SemaExprObjC.cpp?rev=101828&r1=101827&r2=101828&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/branches/Apple/williamson/lib/Sema/SemaExprObjC.cpp Mon Apr 19 18:08:26 2010
@@ -505,6 +505,16 @@
switch (Result.getResultKind()) {
case LookupResult::NotFound:
+ // Normal name lookup didn't find anything. If we're in an
+ // Objective-C method, look for ivars. If we find one, we're done!
+ // FIXME: This is a hack. Ivar lookup should be part of normal lookup.
+ if (ObjCMethodDecl *Method = getCurMethodDecl()) {
+ ObjCInterfaceDecl *ClassDeclared;
+ if (Method->getClassInterface()->lookupInstanceVariable(Name,
+ ClassDeclared))
+ return ObjCInstanceMessage;
+ }
+
// Break out; we'll perform typo correction below.
break;
Modified: cfe/branches/Apple/williamson/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/Sema/SemaLookup.cpp?rev=101828&r1=101827&r2=101828&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/Sema/SemaLookup.cpp (original)
+++ cfe/branches/Apple/williamson/lib/Sema/SemaLookup.cpp Mon Apr 19 18:08:26 2010
@@ -2279,6 +2279,14 @@
LookupVisibleDecls(IFace->getSuperClass(), Result, QualifiedNameLookup,
true, Consumer, Visited);
}
+
+ // If there is an implementation, traverse it. We do this to find
+ // synthesized ivars.
+ if (IFace->getImplementation()) {
+ ShadowContextRAII Shadow(Visited);
+ LookupVisibleDecls(IFace->getImplementation(), Result,
+ QualifiedNameLookup, true, Consumer, Visited);
+ }
} else if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Ctx)) {
for (ObjCProtocolDecl::protocol_iterator I = Protocol->protocol_begin(),
E = Protocol->protocol_end(); I != E; ++I) {
@@ -2293,6 +2301,13 @@
LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer,
Visited);
}
+
+ // If there is an implementation, traverse it.
+ if (Category->getImplementation()) {
+ ShadowContextRAII Shadow(Visited);
+ LookupVisibleDecls(Category->getImplementation(), Result,
+ QualifiedNameLookup, true, Consumer, Visited);
+ }
}
}
Modified: cfe/branches/Apple/williamson/test/FixIt/typo.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/FixIt/typo.m?rev=101828&r1=101827&r2=101828&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/test/FixIt/typo.m (original)
+++ cfe/branches/Apple/williamson/test/FixIt/typo.m Mon Apr 19 18:08:26 2010
@@ -103,3 +103,37 @@
}
@end
+
+ at interface Ivar
+ at end
+
+ at protocol Proto
+ at property (retain) id ivar;
+ at end
+
+ at interface User <Proto>
+- (void)method;
+ at end
+
+ at implementation User
+ at synthesize ivar;
+
+- (void)method {
+ [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+ at end
+
+ at interface User2
+ at end
+
+ at interface User2 (Cat) < Proto>
+- (void)method;
+ at end
+
+ at implementation User2 (Cat)
+ at synthesize ivar;
+
+- (void)method {
+ [ivar method]; // Test that we don't correct 'ivar' to 'Ivar'
+}
+ at end
More information about the llvm-branch-commits
mailing list