]> granicus.if.org Git - clang/commitdiff
Compare the canonical types and document why we give up on the covariant case.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 28 Jun 2012 17:57:36 +0000 (17:57 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 28 Jun 2012 17:57:36 +0000 (17:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159360 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprCXX.cpp

index 4b0bff0ad0db7f30298533195131672a3d673451..cb15fe272978cbd695fe6834e415e2b5557c68fe 100644 (file)
@@ -202,8 +202,14 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE,
       // we don't have support for that yet, so do a virtual call.
       DevirtualizedMethod = NULL;
     }
-    if (DevirtualizedMethod && DevirtualizedMethod->getResultType() !=
-        MD->getResultType())
+    // If the return types are not the same, this might be a case where more
+    // code needs to run to compensate for it. For example, the derived
+    // method might return a type that inherits form from the return
+    // type of MD and has a prefix.
+    // For now we just avoid devirtualizing these covariant cases.
+    if (DevirtualizedMethod &&
+        DevirtualizedMethod->getResultType().getCanonicalType() !=
+        MD->getResultType().getCanonicalType())
       DevirtualizedMethod = NULL;
   }