From: Chris Lattner Date: Sun, 6 Apr 2008 05:25:03 +0000 (+0000) Subject: Fix a bug I introduced in my const'ification patch. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5619688510185081cbb4621d703daf7ee24cf39a;p=clang Fix a bug I introduced in my const'ification patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49262 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 640dd37750..a3f54c1462 100644 --- a/include/clang/AST/DeclObjC.h +++ b/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/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index a8ef5aa473..8126485c4f 100644 --- a/lib/AST/DeclObjC.cpp +++ b/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;