diff options
author | John McCall <rjmccall@apple.com> | 2010-03-30 23:58:03 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-30 23:58:03 +0000 |
commit | d9c7c6568e17e3bdc7006da3253eb2900a70ec3f (patch) | |
tree | a866ba628ca57eba03330d2f1efa9258512bce2b /clang/lib/CodeGen/CGExprScalar.cpp | |
parent | 4d2972d7939f51b1380bce918effceabe0da15ea (diff) | |
download | bcm5719-llvm-d9c7c6568e17e3bdc7006da3253eb2900a70ec3f.tar.gz bcm5719-llvm-d9c7c6568e17e3bdc7006da3253eb2900a70ec3f.zip |
Introduce a new kind of derived-to-base cast which bypasses the need for
null checks, and make sure we elide null checks when accessing base class
members.
llvm-svn: 99963
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 1ef06ccf6f6..42bf68ed52c 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -769,6 +769,9 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { static bool ShouldNullCheckClassCastValue(const CastExpr *CE) { const Expr *E = CE->getSubExpr(); + + if (CE->getCastKind() == CastExpr::CK_UncheckedDerivedToBase) + return false; if (isa<CXXThisExpr>(E)) { // We always assume that 'this' is never null. @@ -826,6 +829,7 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return CGF.GetAddressOfDerivedClass(Src, BaseClassDecl, DerivedClassDecl, NullCheckValue); } + case CastExpr::CK_UncheckedDerivedToBase: case CastExpr::CK_DerivedToBase: { const RecordType *DerivedClassTy = E->getType()->getAs<PointerType>()->getPointeeType()->getAs<RecordType>(); |