summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-01-29 05:04:11 +0000
committerAnders Carlsson <andersca@mac.com>2011-01-29 05:04:11 +0000
commit6b3afd7df119fcfc1a16182b598d8c4523916400 (patch)
tree816c6fdcdc2b0a7eb4b2df622c4f8c511624985a /clang/lib/CodeGen/CGExprCXX.cpp
parent73c29178acb9d415aa192775c01e43184f2fe1ee (diff)
downloadbcm5719-llvm-6b3afd7df119fcfc1a16182b598d8c4523916400.tar.gz
bcm5719-llvm-6b3afd7df119fcfc1a16182b598d8c4523916400.zip
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.
llvm-svn: 124528
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index fa6ac5469f8..99c54f0456b 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud