diff options
Diffstat (limited to 'lib/Index/Analyzer.cpp')
-rw-r--r-- | lib/Index/Analyzer.cpp | 79 |
1 files changed, 56 insertions, 23 deletions
diff --git a/lib/Index/Analyzer.cpp b/lib/Index/Analyzer.cpp index 7b414f2..1354fe6 100644 --- a/lib/Index/Analyzer.cpp +++ b/lib/Index/Analyzer.cpp @@ -153,9 +153,10 @@ public: ObjCInterfaceDecl *MsgD = 0; ObjCMessageExpr *Msg = cast<ObjCMessageExpr>(ASTLoc.AsStmt()); - if (Msg->getReceiver()) { + switch (Msg->getReceiverKind()) { + case ObjCMessageExpr::Instance: { const ObjCObjectPointerType *OPT = - Msg->getReceiver()->getType()->getAsObjCInterfacePointerType(); + Msg->getInstanceReceiver()->getType()->getAsObjCInterfacePointerType(); // Can be anything! Accept it as a possibility.. if (!OPT || OPT->isObjCIdType() || OPT->isObjCQualifiedIdType()) @@ -171,15 +172,34 @@ public: // Should be an instance method. if (!IsInstanceMethod) return false; + break; + } - } else { + case ObjCMessageExpr::Class: { + // Expecting class method. + if (IsInstanceMethod) + return false; + + MsgD = Msg->getClassReceiver()->getAs<ObjCInterfaceType>()->getDecl(); + break; + } + + case ObjCMessageExpr::SuperClass: // Expecting class method. if (IsInstanceMethod) return false; - MsgD = Msg->getClassInfo().Decl; - // FIXME: Case when we only have an identifier. - assert(MsgD && "Identifier only"); + MsgD = Msg->getSuperType()->getAs<ObjCInterfaceType>()->getDecl(); + break; + + case ObjCMessageExpr::SuperInstance: + // Expecting instance method. + if (!IsInstanceMethod) + return false; + + MsgD = Msg->getSuperType()->getAs<ObjCObjectPointerType>() + ->getInterfaceDecl(); + break; } assert(MsgD); @@ -248,31 +268,44 @@ public: ObjCInterfaceDecl *MsgD = 0; while (true) { - if (Msg->getReceiver() == 0) { - CanBeClassMethod = true; - MsgD = Msg->getClassInfo().Decl; - // FIXME: Case when we only have an identifier. - assert(MsgD && "Identifier only"); - break; - } + switch (Msg->getReceiverKind()) { + case ObjCMessageExpr::Instance: { + const ObjCObjectPointerType *OPT = + Msg->getInstanceReceiver()->getType() + ->getAsObjCInterfacePointerType(); + + if (!OPT || OPT->isObjCIdType() || OPT->isObjCQualifiedIdType()) { + CanBeInstanceMethod = CanBeClassMethod = true; + break; + } - const ObjCObjectPointerType *OPT = - Msg->getReceiver()->getType()->getAsObjCInterfacePointerType(); + if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) { + CanBeClassMethod = true; + break; + } - if (!OPT || OPT->isObjCIdType() || OPT->isObjCQualifiedIdType()) { - CanBeInstanceMethod = CanBeClassMethod = true; + MsgD = OPT->getInterfaceDecl(); + assert(MsgD); + CanBeInstanceMethod = true; break; } + + case ObjCMessageExpr::Class: + CanBeClassMethod = true; + MsgD = Msg->getClassReceiver()->getAs<ObjCInterfaceType>()->getDecl(); + break; - if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) { + case ObjCMessageExpr::SuperClass: CanBeClassMethod = true; + MsgD = Msg->getSuperType()->getAs<ObjCInterfaceType>()->getDecl(); break; - } - MsgD = OPT->getInterfaceDecl(); - assert(MsgD); - CanBeInstanceMethod = true; - break; + case ObjCMessageExpr::SuperInstance: + CanBeInstanceMethod = true; + MsgD = Msg->getSuperType()->getAs<ObjCObjectPointerType>() + ->getInterfaceDecl(); + break; + } } assert(CanBeInstanceMethod || CanBeClassMethod); |