[cfe-commits] r165472 - in /cfe/trunk: lib/AST/ASTContext.cpp lib/Sema/SemaDecl.cpp test/Index/overrides.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Oct 8 18:23:45 PDT 2012


Author: akirtzidis
Date: Mon Oct  8 20:23:45 2012
New Revision: 165472

URL: http://llvm.org/viewvc/llvm-project?rev=165472&view=rev
Log:
When storing the C++ overridden methods, store them once for the
canonical method; avoid storing them again for an out-of-line definition.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Index/overrides.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=165472&r1=165471&r2=165472&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct  8 20:23:45 2012
@@ -993,7 +993,7 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
   llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
-    = OverriddenMethods.find(Method);
+    = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
     return 0;
 
@@ -1003,7 +1003,7 @@
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
   llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
-    = OverriddenMethods.find(Method);
+    = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
     return 0;
 
@@ -1013,7 +1013,7 @@
 unsigned
 ASTContext::overridden_methods_size(const CXXMethodDecl *Method) const {
   llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
-    = OverriddenMethods.find(Method);
+    = OverriddenMethods.find(Method->getCanonicalDecl());
   if (Pos == OverriddenMethods.end())
     return 0;
 
@@ -1022,6 +1022,7 @@
 
 void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method, 
                                      const CXXMethodDecl *Overridden) {
+  assert(Method->isCanonicalDecl() && Overridden->isCanonicalDecl());
   OverriddenMethods[Method].push_back(Overridden);
 }
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=165472&r1=165471&r2=165472&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Oct  8 20:23:45 2012
@@ -6038,7 +6038,8 @@
     // Find any virtual functions that this function overrides.
     if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
       if (!Method->isFunctionTemplateSpecialization() && 
-          !Method->getDescribedFunctionTemplate()) {
+          !Method->getDescribedFunctionTemplate() &&
+          Method->isCanonicalDecl()) {
         if (AddOverriddenMethods(Method->getParent(), Method)) {
           // If the function was marked as "static", we have a problem.
           if (NewFD->getStorageClass() == SC_Static) {

Modified: cfe/trunk/test/Index/overrides.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/overrides.cpp?rev=165472&r1=165471&r2=165472&view=diff
==============================================================================
--- cfe/trunk/test/Index/overrides.cpp (original)
+++ cfe/trunk/test/Index/overrides.cpp Mon Oct  8 20:23:45 2012
@@ -15,6 +15,9 @@
   virtual void f(int);
 };
 
+void C::g() {}
+
 // RUN: c-index-test -test-load-source local %s | FileCheck %s
 // CHECK: overrides.cpp:11:16: CXXMethod=g:11:16 (virtual) [Overrides @7:16] Extent=[11:3 - 11:19]
 // CHECK: overrides.cpp:15:16: CXXMethod=f:15:16 (virtual) [Overrides @2:16, @6:16] Extent=[15:3 - 15:22]
+// CHECK: overrides.cpp:18:9: CXXMethod=g:18:9 (Definition) (virtual) [Overrides @7:16] Extent=[18:1 - 18:15]





More information about the cfe-commits mailing list