Make the non-const DeclContext::getParent call the const version, instead of the other way around.

llvm-svn: 59646
This commit is contained in:
Argyrios Kyrtzidis 2008-11-19 17:36:39 +00:00
parent 50a1270d87
commit 7768a30c37
2 changed files with 7 additions and 6 deletions

View File

@ -294,9 +294,10 @@ protected:
public: public:
/// getParent - Returns the containing DeclContext if this is a ScopedDecl, /// getParent - Returns the containing DeclContext if this is a ScopedDecl,
/// else returns NULL. /// else returns NULL.
DeclContext *getParent(); const DeclContext *getParent() const;
const DeclContext *getParent() const { DeclContext *getParent() {
return const_cast<DeclContext*>(this)->getParent(); return const_cast<DeclContext*>(
const_cast<const DeclContext*>(this)->getParent());
} }
bool isFunctionOrMethod() const { bool isFunctionOrMethod() const {

View File

@ -353,10 +353,10 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
// DeclContext Implementation // DeclContext Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
DeclContext *DeclContext::getParent() { const DeclContext *DeclContext::getParent() const {
if (ScopedDecl *SD = dyn_cast<ScopedDecl>(this)) if (const ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
return SD->getDeclContext(); return SD->getDeclContext();
else if (BlockDecl *BD = dyn_cast<BlockDecl>(this)) else if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
return BD->getParentContext(); return BD->getParentContext();
else else
return NULL; return NULL;