Пример #1
0
bool isObjCMethodDeclaredInSuperClass(clang::ObjCMethodDecl *decl)
{
    if (decl && !isObjCMethodDeclLocatedInInterfaceContainer(decl))
    {
        clang::Selector selector = decl->getSelector();
        clang::ObjCInterfaceDecl *interfaceDecl = decl->getClassInterface();
        if (interfaceDecl)
        {
            clang::ObjCInterfaceDecl *superInterface = interfaceDecl->getSuperClass();
            return superInterface && superInterface->lookupInstanceMethod(selector);
        }
    }
    return false;
}
Пример #2
0
bool isObjCMethodDeclaredInProtocol(clang::ObjCMethodDecl *decl)
{
    if (!decl || isObjCMethodDeclLocatedInInterfaceContainer(decl))
    {
        return false;
    }
    
    clang::Selector selector = decl->getSelector();
    clang::ObjCInterfaceDecl *interfaceDecl = decl->getClassInterface();
    if (interfaceDecl)
    {
        for (clang::ObjCProtocolList::iterator protocol = interfaceDecl->protocol_begin(),
            protocolEnd = interfaceDecl->protocol_end(); protocol != protocolEnd; protocol++)
        {
            clang::ObjCProtocolDecl *protocolDecl = (clang::ObjCProtocolDecl *)*protocol;
            if (protocolDecl->lookupInstanceMethod(selector))
            {
                return true;
            }
        }
    }

    return false;
}
 bool isObjCMethodDeclaration(DeclContext *context)
 {
     ObjCMethodDecl *decl = dyn_cast<ObjCMethodDecl>(context);
     return isObjCMethodDeclLocatedInInterfaceContainer(decl);
 }