[cfe-commits] r125296 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/warn-overloaded-virtual.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Feb 10 10:13:42 PST 2011


Author: akirtzidis
Date: Thu Feb 10 12:13:41 2011
New Revision: 125296

URL: http://llvm.org/viewvc/llvm-project?rev=125296&view=rev
Log:
For -Woverloaded-virtual take into account canonical methods. Fixes rdar://8979966 & http://llvm.org/PR9182.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=125296&r1=125295&r2=125296&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Feb 10 12:13:41 2011
@@ -2827,6 +2827,7 @@
        ++Path.Decls.first) {
     NamedDecl *D = *Path.Decls.first;
     if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
+      MD = MD->getCanonicalDecl();
       foundSameNameMethod = true;
       // Interested only in hidden virtual methods.
       if (!MD->isVirtual())
@@ -2871,10 +2872,10 @@
       for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
                                           E = MD->end_overridden_methods();
            I != E; ++I)
-        Data.OverridenAndUsingBaseMethods.insert(*I);
+        Data.OverridenAndUsingBaseMethods.insert((*I)->getCanonicalDecl());
     if (UsingShadowDecl *shad = dyn_cast<UsingShadowDecl>(*res.first))
       if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(shad->getTargetDecl()))
-        Data.OverridenAndUsingBaseMethods.insert(MD);
+        Data.OverridenAndUsingBaseMethods.insert(MD->getCanonicalDecl());
   }
 
   if (DC->lookupInBases(&FindHiddenVirtualMethod, &Data, Paths) &&

Modified: cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp?rev=125296&r1=125295&r2=125296&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-overloaded-virtual.cpp Thu Feb 10 12:13:41 2011
@@ -39,3 +39,16 @@
   void foo(float);
   void foo();
 };
+
+namespace PR9182 {
+struct Base {
+  virtual void foo(int);
+};
+
+void Base::foo(int) { }
+
+struct Derived : public Base {
+  virtual void foo(int);   
+  void foo(int, int);   
+};
+}





More information about the cfe-commits mailing list