diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-09-22 22:00:46 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-09-22 22:00:46 +0000 |
| commit | 8c978b4fc2cd24a89c50e6319d5feacf88b1f8dc (patch) | |
| tree | 77b4693a6a36459fd055151e9d9cce8ca19d8fb2 /clang/lib | |
| parent | 8fef09cd80bd6382688c213561dcfb5fdb4ff056 (diff) | |
| download | bcm5719-llvm-8c978b4fc2cd24a89c50e6319d5feacf88b1f8dc.tar.gz bcm5719-llvm-8c978b4fc2cd24a89c50e6319d5feacf88b1f8dc.zip | |
No need to null check implicit lvalue cast exprs.
llvm-svn: 82580
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 308376c179e..1e923a90478 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -231,9 +231,9 @@ public: if (E->getType()->isVariablyModifiedType()) CGF.EmitVLASize(E->getType()); - return EmitCastExpr(E->getSubExpr(), E->getType(), E->getCastKind()); + return EmitCastExpr(E); } - Value *EmitCastExpr(const Expr *E, QualType T, CastExpr::CastKind Kind); + Value *EmitCastExpr(const CastExpr *E); Value *VisitCallExpr(const CallExpr *E) { if (E->getCallReturnType()->isReferenceType()) @@ -618,8 +618,11 @@ Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { // VisitCastExpr - Emit code for an explicit or implicit cast. Implicit casts // have to handle a more broad range of conversions than explicit casts, as they // handle things like function to ptr-to-function decay etc. -Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy, - CastExpr::CastKind Kind) { +Value *ScalarExprEmitter::EmitCastExpr(const CastExpr *CE) { + const Expr *E = CE->getSubExpr(); + QualType DestTy = CE->getType(); + CastExpr::CastKind Kind = CE->getCastKind(); + if (!DestTy->isVoidType()) TestAndClearIgnoreResultAssign(); @@ -681,12 +684,16 @@ Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy, Value *Src = Visit(const_cast<Expr*>(E)); // FIXME: This should be true, but that leads to a failure in virt.cpp - bool NullCheckValue = false; + bool NullCheckValue = true; - // We always assume that 'this' is never null. - if (isa<CXXThisExpr>(E)) + if (isa<CXXThisExpr>(E)) { + // We always assume that 'this' is never null. NullCheckValue = false; - + } else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(CE)) { + // And that lvalue casts are never null. + if (ICE->isLvalueCast()) + NullCheckValue = false; + } return CGF.GetAddressCXXOfBaseClass(Src, DerivedClassDecl, BaseClassDecl, NullCheckValue); } |

