[cfe-commits] r61935 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/CodeGen/CGObjCGNU.cpp

Steve Naroff snaroff at apple.com
Thu Jan 8 11:41:02 PST 2009


Author: snaroff
Date: Thu Jan  8 13:41:02 2009
New Revision: 61935

URL: http://llvm.org/viewvc/llvm-project?rev=61935&view=rev
Log:
Remove redundant method context (now that ObjCMethodDecl isa ScopedDecl).
Convert clients to use the standard getDeclContext() API.

Doug, thanks for the review!

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=61935&r1=61934&r2=61935&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Thu Jan  8 13:41:02 2009
@@ -882,7 +882,7 @@
   NameStr += "_";
   
   if (ObjCCategoryImplDecl *CID = 
-      dyn_cast<ObjCCategoryImplDecl>(OMD->getMethodContext())) {
+      dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
     NameStr += CID->getNameAsString();
     NameStr += "_";
   }

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=61935&r1=61934&r2=61935&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Jan  8 13:41:02 2009
@@ -114,9 +114,6 @@
   /// 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 @@
     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 @@
   SourceRange getSourceRange() const { 
     return SourceRange(getLocation(), EndLoc); 
   }
-  
-  DeclContext *getMethodContext() const { return MethodContext; }
-  
+    
   ObjCInterfaceDecl *getClassInterface();
   const ObjCInterfaceDecl *getClassInterface() const {
     return const_cast<ObjCMethodDecl*>(this)->getClassInterface();

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=61935&r1=61934&r2=61935&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Jan  8 13:41:02 2009
@@ -812,22 +812,23 @@
   // 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;

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=61935&r1=61934&r2=61935&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Thu Jan  8 13:41:02 2009
@@ -934,7 +934,7 @@
 
 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();





More information about the cfe-commits mailing list