diff options
author | Anders Carlsson <andersca@mac.com> | 2011-01-29 05:04:11 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2011-01-29 05:04:11 +0000 |
commit | 268ab8c6b92dc40c678d8458a335698fa34915c9 (patch) | |
tree | 0c8fc26f8ab9044d2d4b416853966ea1f1b46514 /lib/CodeGen/CGExprCXX.cpp | |
parent | 1679f5a84ae1e578b0de347c89eaf31e0465f33c (diff) |
When trying to get the most derived class, don't assume that we can ignore all casts. We can only ignore derived-to-base and no-op casts. Fixes selfhost.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124528 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGExprCXX.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index fa6ac5469f..99c54f0456 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -54,7 +54,23 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD, } static const CXXRecordDecl *getMostDerivedClassDecl(const Expr *Base) { - QualType DerivedType = Base->IgnoreParenCasts()->getType(); + const Expr *E = Base; + + while (true) { + E = E->IgnoreParens(); + if (const CastExpr *CE = dyn_cast<CastExpr>(E)) { + if (CE->getCastKind() == CK_DerivedToBase || + CE->getCastKind() == CK_UncheckedDerivedToBase || + CE->getCastKind() == CK_NoOp) { + E = CE->getSubExpr(); + continue; + } + } + + break; + } + + QualType DerivedType = E->getType(); if (const PointerType *PTy = DerivedType->getAs<PointerType>()) DerivedType = PTy->getPointeeType(); |