]> granicus.if.org Git - clang/commitdiff
Remove redundant method context (now that ObjCMethodDecl isa ScopedDecl).
authorSteve Naroff <snaroff@apple.com>
Thu, 8 Jan 2009 19:41:02 +0000 (19:41 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 8 Jan 2009 19:41:02 +0000 (19:41 +0000)
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

Driver/RewriteObjC.cpp
include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
lib/CodeGen/CGObjCGNU.cpp

index f135e0475ac5862c8b3c42ff5a5f0ca4f4d8e91f..614c30996ebce638450be78a877c64b99650f85c 100644 (file)
@@ -882,7 +882,7 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
   NameStr += "_";
   
   if (ObjCCategoryImplDecl *CID = 
-      dyn_cast<ObjCCategoryImplDecl>(OMD->getMethodContext())) {
+      dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
     NameStr += CID->getNameAsString();
     NameStr += "_";
   }
index 0acb88dc0dbf4fd0b114c0a32df39310be01cba0..112fcfd9c8d438022881e69824df3024aa006430 100644 (file)
@@ -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<ObjCMethodDecl*>(this)->getClassInterface();
index 0b6eff1af56075da7930d95442e01093eadf82d1..05d7e1149536f72572f91cf20c9dd586298f4610 100644 (file)
@@ -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<ObjCCategoryImplDecl>(getMethodContext()))
+  if (const ObjCCategoryImplDecl *CID = 
+      dyn_cast<ObjCCategoryImplDecl>(getDeclContext()))
     length += CID->getNameAsString().size()+1;
   length += getSelector().getAsString().size(); // selector name
   return length; 
 }
 
 ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
-  if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(MethodContext))
+  if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(getDeclContext()))
     return ID;
-  if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(MethodContext))
+  if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(getDeclContext()))
     return CD->getClassInterface();
   if (ObjCImplementationDecl *IMD = 
-        dyn_cast<ObjCImplementationDecl>(MethodContext))
+        dyn_cast<ObjCImplementationDecl>(getDeclContext()))
     return IMD->getClassInterface();
-  if (ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(MethodContext))
+  if (ObjCCategoryImplDecl *CID = 
+        dyn_cast<ObjCCategoryImplDecl>(getDeclContext()))
     return CID->getClassInterface();
   assert(false && "unknown method context");
   return 0;
index 41acf5ed508505f5080f8062a0f9fd37f2336186..3fdfb5e197ee42f55bb7e5945e099adf8cbbf946 100644 (file)
@@ -934,7 +934,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
 
 llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD) {  
   const ObjCCategoryImplDecl *OCD = 
-    dyn_cast<ObjCCategoryImplDecl>(OMD->getMethodContext());
+    dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext());
   std::string CategoryName = OCD ? OCD->getNameAsString() : "";
   std::string ClassName = OMD->getClassInterface()->getNameAsString();
   std::string MethodName = OMD->getSelector().getAsString();