From 941ab0fb6f6205ac83140ba3e961b136c9162779 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sat, 3 Nov 2012 14:24:57 +0000 Subject: [PATCH] Remove a const_cast by propagating constness to the member function. llvm-svn: 167357 --- clang/include/clang/AST/ASTContext.h | 5 +++-- clang/lib/AST/ASTContext.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 1ba2400..d559fee 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -636,8 +636,9 @@ public: /// the same selector and is of the same kind (class or instance). /// A method in an implementation is not considered as overriding the same /// method in the interface or its categories. - void getOverriddenMethods(const NamedDecl *Method, - SmallVectorImpl &Overridden); + void getOverriddenMethods( + const NamedDecl *Method, + SmallVectorImpl &Overridden) const; /// \brief Notify the AST context that a new import declaration has been /// parsed or implicitly created within this translation unit. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 71764db..2f728810 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -411,13 +411,12 @@ comments::FullComment *ASTContext::getCommentForDecl( const RawComment *RC = getRawCommentForAnyRedecl(D, &OriginalDecl); if (!RC) { if (isa(D) || isa(D)) { - SmallVector overridden; + SmallVector Overridden; if (const ObjCMethodDecl *OMD = dyn_cast(D)) - addRedeclaredMethods(OMD, overridden); - const_cast(this)->getOverriddenMethods(dyn_cast(D), - overridden); - for (unsigned i = 0, e = overridden.size(); i < e; i++) { - if (comments::FullComment *FC = getCommentForDecl(overridden[i], PP)) { + addRedeclaredMethods(OMD, Overridden); + getOverriddenMethods(dyn_cast(D), Overridden); + for (unsigned i = 0, e = Overridden.size(); i < e; i++) { + if (comments::FullComment *FC = getCommentForDecl(Overridden[i], PP)) { comments::FullComment *CFC = cloneFullComment(FC, D); return CFC; } @@ -1082,8 +1081,9 @@ void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method, OverriddenMethods[Method].push_back(Overridden); } -void ASTContext::getOverriddenMethods(const NamedDecl *D, - SmallVectorImpl &Overridden) { +void ASTContext::getOverriddenMethods( + const NamedDecl *D, + SmallVectorImpl &Overridden) const { assert(D); if (const CXXMethodDecl *CXXMethod = dyn_cast(D)) { -- 2.7.4