aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-06-28 17:57:36 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-06-28 17:57:36 +0000
commit80bc96e6aa9bc8331473385150cff5e0db305da6 (patch)
tree880925aab464cbd70c45ea9cb0aee361d9ddf80d /lib/CodeGen/CGExprCXX.cpp
parent0239df868e2e09f4963bc310c56ea129f51a2288 (diff)
Compare the canonical types and document why we give up on the covariant case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--lib/CodeGen/CGExprCXX.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index 4b0bff0ad0..cb15fe2729 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -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;
}