diff options
| author | Mike Stump <mrs@apple.com> | 2009-11-16 06:50:58 +0000 |
|---|---|---|
| committer | Mike Stump <mrs@apple.com> | 2009-11-16 06:50:58 +0000 |
| commit | c849c052d6b4b70f2651c1969531861a5f230053 (patch) | |
| tree | b67620b7b9fd6e85155ea4dfd0c53512532a28c2 /lib/CodeGen/CGExpr.cpp | |
| parent | 083e3060b77917c1c1096127ab99ae921d7e8782 (diff) | |
| download | clang-c849c052d6b4b70f2651c1969531861a5f230053.tar.gz clang-c849c052d6b4b70f2651c1969531861a5f230053.tar.bz2 clang-c849c052d6b4b70f2651c1969531861a5f230053.tar.xz | |
Implement most of dynamic_cast. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88901 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 27ea41d6e4..1844b02516 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1290,16 +1290,26 @@ CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator* E) { return LValue::MakeAddr(Temp, MakeQualifiers(E->getType())); } -/// EmitCastLValue - Casts are never lvalues. If a cast is needed by the code -/// generator in an lvalue context, then it must mean that we need the address -/// of an aggregate in order to access one of its fields. This can happen for -/// all the reasons that casts are permitted with aggregate result, including -/// noop aggregate casts, and cast from scalar to union. +/// EmitCastLValue - Casts are never lvalues unless that cast is a dynamic_cast. +/// If the cast is a dynamic_cast, we can have the usual lvalue result, +/// otherwise if a cast is needed by the code generator in an lvalue context, +/// then it must mean that we need the address of an aggregate in order to +/// access one of its fields. This can happen for all the reasons that casts +/// are permitted with aggregate result, including noop aggregate casts, and +/// cast from scalar to union. LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { switch (E->getCastKind()) { default: return EmitUnsupportedLValue(E, "unexpected cast lvalue"); + case CastExpr::CK_Dynamic: { + LValue LV = EmitLValue(E->getSubExpr()); + llvm::Value *V = LV.getAddress(); + const CXXDynamicCastExpr *DCE = cast<CXXDynamicCastExpr>(E); + return LValue::MakeAddr(EmitDynamicCast(V, DCE), + MakeQualifiers(E->getType())); + } + case CastExpr::CK_NoOp: case CastExpr::CK_ConstructorConversion: case CastExpr::CK_UserDefinedConversion: |
