forked from OSchip/llvm-project
Some refactoring of recent code. No functionality change.
llvm-svn: 66041
This commit is contained in:
parent
c2371eadd6
commit
4f4de6c27f
|
@ -1768,8 +1768,9 @@ public:
|
||||||
|
|
||||||
// Helper method for ActOnClassMethod/ActOnInstanceMethod.
|
// Helper method for ActOnClassMethod/ActOnInstanceMethod.
|
||||||
// Will search "local" class/category implementations for a method decl.
|
// Will search "local" class/category implementations for a method decl.
|
||||||
|
// Will also search in class's root looking for instance method.
|
||||||
// Returns 0 if no method is found.
|
// Returns 0 if no method is found.
|
||||||
ObjCMethodDecl *LookupPrivateMethod(Selector Sel, ObjCInterfaceDecl *CDecl);
|
ObjCMethodDecl *LookupPrivateOrRootMethod(Selector Sel, ObjCInterfaceDecl *CDecl);
|
||||||
|
|
||||||
// ActOnClassMessage - used for both unary and keyword messages.
|
// ActOnClassMessage - used for both unary and keyword messages.
|
||||||
// ArgExprs is optional - if it is present, the number of expressions
|
// ArgExprs is optional - if it is present, the number of expressions
|
||||||
|
|
|
@ -211,8 +211,9 @@ bool Sema::isSelfExpr(Expr *RExpr) {
|
||||||
|
|
||||||
// Helper method for ActOnClassMethod/ActOnInstanceMethod.
|
// Helper method for ActOnClassMethod/ActOnInstanceMethod.
|
||||||
// Will search "local" class/category implementations for a method decl.
|
// Will search "local" class/category implementations for a method decl.
|
||||||
|
// If failed, then we search in class's root for an instance method.
|
||||||
// Returns 0 if no method is found.
|
// Returns 0 if no method is found.
|
||||||
ObjCMethodDecl *Sema::LookupPrivateMethod(Selector Sel,
|
ObjCMethodDecl *Sema::LookupPrivateOrRootMethod(Selector Sel,
|
||||||
ObjCInterfaceDecl *ClassDecl) {
|
ObjCInterfaceDecl *ClassDecl) {
|
||||||
ObjCMethodDecl *Method = 0;
|
ObjCMethodDecl *Method = 0;
|
||||||
|
|
||||||
|
@ -227,6 +228,15 @@ ObjCMethodDecl *Sema::LookupPrivateMethod(Selector Sel,
|
||||||
Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
|
Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Before we give up, check if the selector is an instance method.
|
||||||
|
// But only in the root. This matches gcc's behaviour and what the
|
||||||
|
// runtime expects.
|
||||||
|
if (!Method) {
|
||||||
|
ObjCInterfaceDecl *Root = ClassDecl;
|
||||||
|
while (Root->getSuperClass())
|
||||||
|
Root = Root->getSuperClass();
|
||||||
|
Method = Root->lookupInstanceMethod(Sel);
|
||||||
|
}
|
||||||
return Method;
|
return Method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,17 +321,7 @@ Sema::ExprResult Sema::ActOnClassMessage(
|
||||||
|
|
||||||
// If we have an implementation in scope, check "private" methods.
|
// If we have an implementation in scope, check "private" methods.
|
||||||
if (!Method)
|
if (!Method)
|
||||||
Method = LookupPrivateMethod(Sel, ClassDecl);
|
Method = LookupPrivateOrRootMethod(Sel, ClassDecl);
|
||||||
|
|
||||||
// Before we give up, check if the selector is an instance method.
|
|
||||||
// But only in the root. This matches gcc's behaviour and what the
|
|
||||||
// runtime expects.
|
|
||||||
if (!Method) {
|
|
||||||
ObjCInterfaceDecl *Root = ClassDecl;
|
|
||||||
while (Root->getSuperClass())
|
|
||||||
Root = Root->getSuperClass();
|
|
||||||
Method = Root->lookupInstanceMethod(Sel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
|
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
|
||||||
return true;
|
return true;
|
||||||
|
@ -405,16 +405,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
|
||||||
Method = ClassDecl->lookupClassMethod(Sel);
|
Method = ClassDecl->lookupClassMethod(Sel);
|
||||||
|
|
||||||
if (!Method)
|
if (!Method)
|
||||||
Method = LookupPrivateMethod(Sel, ClassDecl);
|
Method = LookupPrivateOrRootMethod(Sel, ClassDecl);
|
||||||
// Before we give up, check if the selector is an instance method.
|
|
||||||
// But only in the root. This matches gcc's behaviour and what the
|
|
||||||
// runtime expects.
|
|
||||||
if (!Method) {
|
|
||||||
ObjCInterfaceDecl *Root = ClassDecl;
|
|
||||||
while (Root->getSuperClass())
|
|
||||||
Root = Root->getSuperClass();
|
|
||||||
Method = Root->lookupInstanceMethod(Sel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
|
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue