]> granicus.if.org Git - clang/commitdiff
Make the non-const DeclContext::getParent call the const version, instead of the...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Nov 2008 17:36:39 +0000 (17:36 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Nov 2008 17:36:39 +0000 (17:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59646 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ba948078a6ca3b7ee2e84a45c1545a1824592cfe..bfc7607b74fc49861ed65a3de4caf5c3656d4b11 100644 (file)
@@ -294,9 +294,10 @@ protected:
 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 {
index 7e51ef5010078f02866f75d3535cc365486ffe2a..88d9a208553af6dd66980db249fa933a79a6835a 100644 (file)
@@ -353,10 +353,10 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
 // 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;