[cfe-commits] r167357 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp

Dmitri Gribenko gribozavr at gmail.com
Sat Nov 3 07:24:57 PDT 2012


Author: gribozavr
Date: Sat Nov  3 09:24:57 2012
New Revision: 167357

URL: http://llvm.org/viewvc/llvm-project?rev=167357&view=rev
Log:
Remove a const_cast by propagating constness to the member function.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=167357&r1=167356&r2=167357&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sat Nov  3 09:24:57 2012
@@ -636,8 +636,9 @@
   /// 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.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=167357&r1=167356&r2=167357&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Nov  3 09:24:57 2012
@@ -411,13 +411,12 @@
   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 @@
   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)) {





More information about the cfe-commits mailing list