diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-08 18:23:20 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-08 18:23:20 +0000 |
commit | 2aa800a955132d83a666bcd52d3d59d09cffc079 (patch) | |
tree | f67526d50f10362ff19e569637585c27023264c6 | |
parent | e696b6924d14b0e0590b5d923ca1646e6f67ac40 (diff) |
Constify CXXRecordDecl::isVirtuallyDerivedFrom.
No functionality change. A couple ugly const_casts because the ancestor
search code is used for other purposes as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161509 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclCXX.h | 2 | ||||
-rw-r--r-- | lib/AST/CXXInheritance.cpp | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 0d498fe4e5..05835a8aae 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1295,7 +1295,7 @@ public: /// /// \returns true if this class is virtually derived from Base, /// false otherwise. - bool isVirtuallyDerivedFrom(CXXRecordDecl *Base) const; + bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const; /// \brief Determine whether this class is provably not derived from /// the type \p Base. diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index f9aa9127d2..cf3913bac0 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -97,7 +97,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base, Paths); } -bool CXXRecordDecl::isVirtuallyDerivedFrom(CXXRecordDecl *Base) const { +bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const { if (!getNumVBases()) return false; @@ -107,8 +107,12 @@ bool CXXRecordDecl::isVirtuallyDerivedFrom(CXXRecordDecl *Base) const { if (getCanonicalDecl() == Base->getCanonicalDecl()) return false; - Paths.setOrigin(const_cast<CXXRecordDecl*>(this)); - return lookupInBases(&FindVirtualBaseClass, Base->getCanonicalDecl(), Paths); + Paths.setOrigin(const_cast<CXXRecordDecl*>(this)); + + const void *BasePtr = static_cast<const void*>(Base->getCanonicalDecl()); + return lookupInBases(&FindVirtualBaseClass, + const_cast<void *>(BasePtr), + Paths); } static bool BaseIsNot(const CXXRecordDecl *Base, void *OpaqueTarget) { @@ -161,7 +165,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches, return AllMatches; } -bool CXXBasePaths::lookupInBases(ASTContext &Context, +bool CXXBasePaths::lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, CXXRecordDecl::BaseMatchesCallback *BaseMatches, void *UserData) { |