diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-19 17:36:39 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-19 17:36:39 +0000 |
commit | 7768a30c3740b59809a33fdf296dfc3489a88e0e (patch) | |
tree | d141b8f52299c0d02cbde5b2d79f752bbd6ae343 | |
parent | 50a1270d872c3870ab5071bf717a0367e96f2a27 (diff) | |
download | bcm5719-llvm-7768a30c3740b59809a33fdf296dfc3489a88e0e.tar.gz bcm5719-llvm-7768a30c3740b59809a33fdf296dfc3489a88e0e.zip |
Make the non-const DeclContext::getParent call the const version, instead of the other way around.
llvm-svn: 59646
-rw-r--r-- | clang/include/clang/AST/DeclBase.h | 7 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 6 |
2 files changed, 7 insertions, 6 deletions
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index ba948078a6c..bfc7607b74f 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -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 { diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 7e51ef50100..88d9a208553 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -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; |