[cfe-commits] r159219 - in /cfe/trunk: lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

Rafael Espindola rafael.espindola at gmail.com
Tue Jun 26 12:18:25 PDT 2012


Author: rafael
Date: Tue Jun 26 14:18:25 2012
New Revision: 159219

URL: http://llvm.org/viewvc/llvm-project?rev=159219&view=rev
Log:
Fix a bug in my previous patch: If we are not doing a virtual call because
the member expression is qualified, call the method specified in the code,
not the most derived one we can find.

Modified:
    cfe/trunk/lib/CodeGen/CGExprCXX.cpp
    cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=159219&r1=159218&r2=159219&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Jun 26 14:18:25 2012
@@ -240,6 +240,8 @@
           MD->isVirtual() &&
           ME->hasQualifier())
         Callee = BuildAppleKextVirtualCall(MD, ME->getQualifier(), Ty);
+      else if (ME->hasQualifier())
+        Callee = CGM.GetAddrOfFunction(GlobalDecl(Dtor, Dtor_Complete), Ty);
       else {
         const CXXMethodDecl *DM =
           Dtor->getCorrespondingMethodInClass(MostDerivedClassDecl);
@@ -258,6 +260,8 @@
         MD->isVirtual() &&
         ME->hasQualifier())
       Callee = BuildAppleKextVirtualCall(MD, ME->getQualifier(), Ty);
+    else if (ME->hasQualifier())
+      Callee = CGM.GetAddrOfFunction(MD, Ty);
     else {
       const CXXMethodDecl *DerivedMethod =
         MD->getCorrespondingMethodInClass(MostDerivedClassDecl);

Modified: cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp?rev=159219&r1=159218&r2=159219&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp Tue Jun 26 14:18:25 2012
@@ -53,3 +53,21 @@
   B().h().f();
 }
 
+namespace test2 {
+  struct foo {
+    virtual void f();
+    virtual ~foo();
+  };
+
+  struct bar : public foo {
+    virtual void f();
+    virtual ~bar();
+  };
+
+  void f(bar *b) {
+    // CHECK: call void @_ZN5test23foo1fEv
+    // CHECK: call void @_ZN5test23fooD1Ev
+    b->foo::f();
+    b->foo::~foo();
+  }
+}





More information about the cfe-commits mailing list