Fixed a problem in our local Clang's method for

performing Objective-C instance variable lookup.
Previously, it only completed the derived class
that was the beginning of the search.  Now, as
it walks up the superclass chain looking for the
ivar, it completes each superclass in turn.

Also added a testcase covering this issue.

llvm-svn: 147621
This commit is contained in:
Sean Callanan 2012-01-05 22:35:40 +00:00
parent de30e523b4
commit 3c88eae154
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,19 @@
Index: lib/AST/DeclObjC.cpp
===================================================================
--- lib/AST/DeclObjC.cpp (revision 146622)
+++ lib/AST/DeclObjC.cpp (working copy)
@@ -244,11 +244,11 @@
ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID,
ObjCInterfaceDecl *&clsDeclared) {
- if (ExternallyCompleted)
- LoadExternalDefinition();
-
ObjCInterfaceDecl* ClassDecl = this;
while (ClassDecl != NULL) {
+ if (ClassDecl->ExternallyCompleted)
+ ClassDecl->LoadExternalDefinition();
+
if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(ID)) {
clsDeclared = ClassDecl;
return I;

View File

@ -165,6 +165,10 @@ class FoundationTestCase(TestBase):
substrs = ["(MyString) *self",
"(NSString *) str",
"(NSDate *) date"])
# isa should be accessible.
self.expect("expression self->isa", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ["(Class)"])
# This should fail expectedly.
self.expect("expression self->non_existent_member",