diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 640dd377506d..a3f54c146286 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -125,9 +125,9 @@ public: NamedDecl *getMethodContext() const { return MethodContext; } - const ObjCInterfaceDecl *getClassInterface() const; - ObjCInterfaceDecl *getClassInterface() { - return (ObjCInterfaceDecl*)((ObjCMethodDecl*)this)->getClassInterface(); + ObjCInterfaceDecl *getClassInterface(); + const ObjCInterfaceDecl *getClassInterface() const { + return const_cast(this)->getClassInterface(); } Selector getSelector() const { return SelName; } diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index a8ef5aa473bd..8126485c4ff8 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -417,16 +417,15 @@ unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { return length; } -const ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() const { +ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { if (ObjCInterfaceDecl *ID = dyn_cast(MethodContext)) return ID; if (ObjCCategoryDecl *CD = dyn_cast(MethodContext)) return CD->getClassInterface(); if (ObjCImplementationDecl *IMD = - dyn_cast(MethodContext)) + dyn_cast(MethodContext)) return IMD->getClassInterface(); - if (ObjCCategoryImplDecl *CID = - dyn_cast(MethodContext)) + if (ObjCCategoryImplDecl *CID = dyn_cast(MethodContext)) return CID->getClassInterface(); assert(false && "unknown method context"); return 0;