From: Steve Naroff Date: Thu, 8 Jan 2009 19:41:02 +0000 (+0000) Subject: Remove redundant method context (now that ObjCMethodDecl isa ScopedDecl). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e0a540b6d846178857289ec0eb8470a278d11a3;p=clang Remove redundant method context (now that ObjCMethodDecl isa ScopedDecl). Convert clients to use the standard getDeclContext() API. Doug, thanks for the review! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61935 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp index f135e0475a..614c30996e 100644 --- a/Driver/RewriteObjC.cpp +++ b/Driver/RewriteObjC.cpp @@ -882,7 +882,7 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD, NameStr += "_"; if (ObjCCategoryImplDecl *CID = - dyn_cast(OMD->getMethodContext())) { + dyn_cast(OMD->getDeclContext())) { NameStr += CID->getNameAsString(); NameStr += "_"; } diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 0acb88dc0d..112fcfd9c8 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -114,9 +114,6 @@ private: /// in, inout, etc. unsigned objcDeclQualifier : 6; - // Context this method is declared in. - DeclContext *MethodContext; - // Type of this method. QualType MethodDeclType; /// ParamInfo - new[]'d array of pointers to VarDecls for the formal @@ -150,7 +147,6 @@ private: IsInstance(isInstance), IsVariadic(isVariadic), IsSynthesized(isSynthesized), DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None), - MethodContext(contextDecl), MethodDeclType(T), ParamInfo(0), NumMethodParams(0), EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {} @@ -182,9 +178,7 @@ public: SourceRange getSourceRange() const { return SourceRange(getLocation(), EndLoc); } - - DeclContext *getMethodContext() const { return MethodContext; } - + ObjCInterfaceDecl *getClassInterface(); const ObjCInterfaceDecl *getClassInterface() const { return const_cast(this)->getClassInterface(); diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 0b6eff1af5..05d7e11495 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -812,22 +812,23 @@ unsigned ObjCMethodDecl::getSynthesizedMethodSize() const { // Get length of this name. unsigned length = 3; // _I_ or _C_ length += getClassInterface()->getNameAsString().size()+1; // extra for _ - if (ObjCCategoryImplDecl *CID = - dyn_cast(getMethodContext())) + if (const ObjCCategoryImplDecl *CID = + dyn_cast(getDeclContext())) length += CID->getNameAsString().size()+1; length += getSelector().getAsString().size(); // selector name return length; } ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() { - if (ObjCInterfaceDecl *ID = dyn_cast(MethodContext)) + if (ObjCInterfaceDecl *ID = dyn_cast(getDeclContext())) return ID; - if (ObjCCategoryDecl *CD = dyn_cast(MethodContext)) + if (ObjCCategoryDecl *CD = dyn_cast(getDeclContext())) return CD->getClassInterface(); if (ObjCImplementationDecl *IMD = - dyn_cast(MethodContext)) + dyn_cast(getDeclContext())) return IMD->getClassInterface(); - if (ObjCCategoryImplDecl *CID = dyn_cast(MethodContext)) + if (ObjCCategoryImplDecl *CID = + dyn_cast(getDeclContext())) return CID->getClassInterface(); assert(false && "unknown method context"); return 0; diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 41acf5ed50..3fdfb5e197 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -934,7 +934,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() { llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD) { const ObjCCategoryImplDecl *OCD = - dyn_cast(OMD->getMethodContext()); + dyn_cast(OMD->getDeclContext()); std::string CategoryName = OCD ? OCD->getNameAsString() : ""; std::string ClassName = OMD->getClassInterface()->getNameAsString(); std::string MethodName = OMD->getSelector().getAsString();