From c0ac7d688ee6d6d2ae11e478f62f691fb37e8039 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 15 Dec 2011 05:27:12 +0000 Subject: Move the definition-specific data of ObjCInterfaceDecl into a separately-allocated DefinitionData structure, which we manage the same way as CXXRecordDecl::DefinitionData. This prepares the way for making ObjCInterfaceDecls redeclarable, to more accurately model forward declarations of Objective-C classes and eliminate the mutation of ObjCInterfaceDecl that causes us serious trouble in the AST reader. Note that ObjCInterfaceDecl's accessors are fairly robust against being applied to forward declarations, because Clang (and Sema in particular) doesn't perform RequireCompleteType/hasDefinition() checks everywhere it has to. Each of these overly-robust cases is marked with a FIXME, which we can tackle over time. llvm-svn: 146644 --- clang/lib/Sema/SemaExprObjC.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'clang/lib/Sema/SemaExprObjC.cpp') diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index fbae96071e3..20c3b754313 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -512,6 +512,9 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel, ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel, ObjCInterfaceDecl *ClassDecl) { + if (!ClassDecl->hasDefinition()) + return 0; + ObjCMethodDecl *Method = 0; while (ClassDecl && !Method) { // If we have implementations in scope, check "private" methods. @@ -1339,12 +1342,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, return ExprError(); forwardClass = OCIType->getInterfaceDecl(); + Method = 0; + } else { + Method = ClassDecl->lookupInstanceMethod(Sel); } - - // FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be - // faster than the following method (which can do *many* linear searches). - // The idea is to add class info to MethodPool. - Method = ClassDecl->lookupInstanceMethod(Sel); if (!Method) // Search protocol qualifiers. -- cgit v1.2.3