]> granicus.if.org Git - clang/commitdiff
Remove a const_cast by propagating constness to the member function.
authorDmitri Gribenko <gribozavr@gmail.com>
Sat, 3 Nov 2012 14:24:57 +0000 (14:24 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Sat, 3 Nov 2012 14:24:57 +0000 (14:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167357 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1ba2400e653add23a4353eecdb70c1fcd7bbaf4c..d559feed171af01b288ef2f40172b7f499d6bf13 100644 (file)
@@ -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<const NamedDecl *> &Overridden);
+  void getOverriddenMethods(
+                        const NamedDecl *Method,
+                        SmallVectorImpl<const NamedDecl *> &Overridden) const;
   
   /// \brief Notify the AST context that a new import declaration has been
   /// parsed or implicitly created within this translation unit.
index 71764dbd9719b5a9095cb47fcb235ed093aabb29..2f7288109c0e69fd74454d5c8cd00781572ed082 100644 (file)
@@ -411,13 +411,12 @@ comments::FullComment *ASTContext::getCommentForDecl(
   const RawComment *RC = getRawCommentForAnyRedecl(D, &OriginalDecl);
   if (!RC) {
     if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
-      SmallVector<const NamedDecl*, 8> overridden;
+      SmallVector<const NamedDecl*, 8> Overridden;
       if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
-        addRedeclaredMethods(OMD, overridden);
-      const_cast<ASTContext *>(this)->getOverriddenMethods(dyn_cast<NamedDecl>(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<NamedDecl>(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<const NamedDecl *> &Overridden) {
+void ASTContext::getOverriddenMethods(
+                      const NamedDecl *D,
+                      SmallVectorImpl<const NamedDecl *> &Overridden) const {
   assert(D);
 
   if (const CXXMethodDecl *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {