From 32baf62b9a3aea3b63be6925b64aa182b0a2278e Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 12 Sep 2009 06:04:24 +0000 Subject: When necessary, null check the base value in GetAddressCXXOfBaseClass. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81611 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprScalar.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExprScalar.cpp') diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 7adbc9fd3b..aee5446434 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -669,8 +669,16 @@ Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy, CXXRecordDecl *BaseClassDecl = cast(BaseClassTy->getDecl()); Value *Src = Visit(const_cast(E)); + + // FIXME: This should be true, but that leads to a failure in virt.cpp + bool NullCheckValue = false; + + // We always assume that 'this' is never null. + if (isa(E)) + NullCheckValue = false; + return CGF.GetAddressCXXOfBaseClass(Src, DerivedClassDecl, BaseClassDecl, - /*NullCheckValue=*/true); + NullCheckValue); } } -- cgit v1.2.3