]> granicus.if.org Git - clang/commitdiff
reduce # const_casts, no functionality change.
authorChris Lattner <sabre@nondot.org>
Fri, 27 Mar 2009 19:19:59 +0000 (19:19 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 27 Mar 2009 19:19:59 +0000 (19:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67861 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp

index 002bab79dfa7185088697dc6822120b922a307c4..982da7493e6dfd384fd043f04285674c89249cdd 100644 (file)
@@ -177,15 +177,15 @@ public:
   Kind getKind() const { return DeclKind; }
   const char *getDeclKindName() const;
   
-  const DeclContext *getDeclContext() const {
-    return const_cast<Decl*>(this)->getDeclContext();
-  }
   DeclContext *getDeclContext() {
     if (isInSemaDC())
       return getSemanticDC();
     return getMultipleDC()->SemanticDC;
   }
-
+  const DeclContext *getDeclContext() const {
+    return const_cast<Decl*>(this)->getDeclContext();
+  }
+  
   void setAccess(AccessSpecifier AS) {
     Access = AS; 
     CheckAccessDeclContext();
@@ -433,14 +433,13 @@ public:
   const char *getDeclKindName() const;
 
   /// getParent - Returns the containing DeclContext.
-  const DeclContext *getParent() const {
+  DeclContext *getParent() {
     return cast<Decl>(this)->getDeclContext();
   }
-  DeclContext *getParent() {
-    return const_cast<DeclContext*>(
-                             const_cast<const DeclContext*>(this)->getParent());
+  const DeclContext *getParent() const {
+    return const_cast<DeclContext*>(this)->getParent();
   }
-
+  
   /// getLexicalParent - Returns the containing lexical DeclContext. May be
   /// different from getParent, e.g.:
   ///
@@ -450,24 +449,20 @@ public:
   ///   struct A::S {}; // getParent() == namespace 'A'
   ///                   // getLexicalParent() == translation unit
   ///
-  const DeclContext *getLexicalParent() const {
-    return cast<Decl>(this)->getLexicalDeclContext();
-  }    
   DeclContext *getLexicalParent() {
-    return const_cast<DeclContext*>(
-                      const_cast<const DeclContext*>(this)->getLexicalParent());
+    return cast<Decl>(this)->getLexicalDeclContext();
   }
-
+  const DeclContext *getLexicalParent() const {
+    return const_cast<DeclContext*>(this)->getLexicalParent();
+  }    
+  
   bool isFunctionOrMethod() const {
     switch (DeclKind) {
-      case Decl::Block:
-      case Decl::ObjCMethod:
-        return true;
-
-      default:
-       if (DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast)
-         return true;
-        return false;
+    case Decl::Block:
+    case Decl::ObjCMethod:
+      return true;
+    default:
+      return DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast;
     }
   }
 
@@ -524,12 +519,11 @@ public:
   /// context of this context, which corresponds to the innermost
   /// location from which name lookup can find the entities in this
   /// context.
-  DeclContext *getLookupContext() {
-    return const_cast<DeclContext *>(
-             const_cast<const DeclContext *>(this)->getLookupContext());
+  DeclContext *getLookupContext();
+  const DeclContext *getLookupContext() const {
+    return const_cast<DeclContext *>(this)->getLookupContext();
   }
-  const DeclContext *getLookupContext() const;
-
+  
   /// \brief Retrieve the nearest enclosing namespace context.
   DeclContext *getEnclosingNamespaceContext();
   const DeclContext *getEnclosingNamespaceContext() const {
index 47059d952c105e4761f6741b28e81160f46d5d3d..ef9dc7622f1638002a863ba49330b0a0d631a85d 100644 (file)
@@ -580,8 +580,8 @@ DeclContext::lookup(DeclarationName Name) const {
   return const_cast<DeclContext*>(this)->lookup(Name);
 }
 
-const DeclContext *DeclContext::getLookupContext() const {
-  const DeclContext *Ctx = this;
+DeclContext *DeclContext::getLookupContext() {
+  DeclContext *Ctx = this;
   // Skip through transparent contexts.
   while (Ctx->isTransparentContext())
     Ctx = Ctx->getParent();