[cfe-commits] r59646 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/AST/DeclBase.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Wed Nov 19 09:36:39 PST 2008


Author: akirtzidis
Date: Wed Nov 19 11:36:39 2008
New Revision: 59646

URL: http://llvm.org/viewvc/llvm-project?rev=59646&view=rev
Log:
Make the non-const DeclContext::getParent call the const version, instead of the other way around.

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/lib/AST/DeclBase.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Nov 19 11:36:39 2008
@@ -294,9 +294,10 @@
 public:
   /// getParent - Returns the containing DeclContext if this is a ScopedDecl,
   /// else returns NULL.
-  DeclContext *getParent();
-  const DeclContext *getParent() const {
-    return const_cast<DeclContext*>(this)->getParent();
+  const DeclContext *getParent() const;
+  DeclContext *getParent() {
+    return const_cast<DeclContext*>(
+                             const_cast<const DeclContext*>(this)->getParent());
   }
 
   bool isFunctionOrMethod() const {

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

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Nov 19 11:36:39 2008
@@ -353,10 +353,10 @@
 // DeclContext Implementation
 //===----------------------------------------------------------------------===//
 
-DeclContext *DeclContext::getParent() {
-  if (ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
+const DeclContext *DeclContext::getParent() const {
+  if (const ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
     return SD->getDeclContext();
-  else if (BlockDecl *BD = dyn_cast<BlockDecl>(this))
+  else if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
     return BD->getParentContext();
   else
     return NULL;





More information about the cfe-commits mailing list