diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-12-03 13:07:22 -0800 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-12-03 13:08:01 -0800 |
commit | 9f37c0e703c095e6bee20dd3a64a5087dca967a8 (patch) | |
tree | 3760fcefa2d15272a2d71cc49bd2820a547fbe49 /clang/lib/CodeGen/CGDecl.cpp | |
parent | 59e69fefab883984e81c77aef58ba587060e87f2 (diff) | |
download | bcm5719-llvm-9f37c0e703c095e6bee20dd3a64a5087dca967a8.tar.gz bcm5719-llvm-9f37c0e703c095e6bee20dd3a64a5087dca967a8.zip |
Revert "[NFC] Pass a reference to CodeGenFunction to methods of LValue and"
This reverts commit 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17. This seems
to have broken UBSan because of a null dereference.
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 2ddc1a66e18..f60628b9b62 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -570,7 +570,7 @@ namespace { Var.getType(), VK_LValue, SourceLocation()); // Compute the address of the local variable, in case it's a byref // or something. - llvm::Value *Addr = CGF.EmitDeclRefLValue(&DRE).getPointer(CGF); + llvm::Value *Addr = CGF.EmitDeclRefLValue(&DRE).getPointer(); // In some cases, the type of the function argument will be different from // the type of the pointer. An example of this is @@ -685,18 +685,18 @@ static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF, LValue srcLV = CGF.EmitLValue(srcExpr); // Handle a formal type change to avoid asserting. - auto srcAddr = srcLV.getAddress(CGF); + auto srcAddr = srcLV.getAddress(); if (needsCast) { - srcAddr = CGF.Builder.CreateElementBitCast( - srcAddr, destLV.getAddress(CGF).getElementType()); + srcAddr = CGF.Builder.CreateElementBitCast(srcAddr, + destLV.getAddress().getElementType()); } // If it was an l-value, use objc_copyWeak. if (srcExpr->getValueKind() == VK_LValue) { - CGF.EmitARCCopyWeak(destLV.getAddress(CGF), srcAddr); + CGF.EmitARCCopyWeak(destLV.getAddress(), srcAddr); } else { assert(srcExpr->getValueKind() == VK_XValue); - CGF.EmitARCMoveWeak(destLV.getAddress(CGF), srcAddr); + CGF.EmitARCMoveWeak(destLV.getAddress(), srcAddr); } return true; } @@ -714,7 +714,7 @@ static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF, static void drillIntoBlockVariable(CodeGenFunction &CGF, LValue &lvalue, const VarDecl *var) { - lvalue.setAddress(CGF.emitBlockByrefAddress(lvalue.getAddress(CGF), var)); + lvalue.setAddress(CGF.emitBlockByrefAddress(lvalue.getAddress(), var)); } void CodeGenFunction::EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, @@ -774,18 +774,17 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, const ValueDecl *D, if (capturedByInit) { // We can use a simple GEP for this because it can't have been // moved yet. - tempLV.setAddress(emitBlockByrefAddress(tempLV.getAddress(*this), + tempLV.setAddress(emitBlockByrefAddress(tempLV.getAddress(), cast<VarDecl>(D), /*follow*/ false)); } - auto ty = - cast<llvm::PointerType>(tempLV.getAddress(*this).getElementType()); + auto ty = cast<llvm::PointerType>(tempLV.getAddress().getElementType()); llvm::Value *zero = CGM.getNullPointer(ty, tempLV.getType()); // If __weak, we want to use a barrier under certain conditions. if (lifetime == Qualifiers::OCL_Weak) - EmitARCInitWeak(tempLV.getAddress(*this), zero); + EmitARCInitWeak(tempLV.getAddress(), zero); // Otherwise just do a simple store. else @@ -828,9 +827,9 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, const ValueDecl *D, if (capturedByInit) drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D)); if (accessedByInit) - EmitARCStoreWeak(lvalue.getAddress(*this), value, /*ignored*/ true); + EmitARCStoreWeak(lvalue.getAddress(), value, /*ignored*/ true); else - EmitARCInitWeak(lvalue.getAddress(*this), value); + EmitARCInitWeak(lvalue.getAddress(), value); return; } @@ -1898,10 +1897,11 @@ void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D, else if (auto *FD = dyn_cast<FieldDecl>(D)) Overlap = getOverlapForFieldInit(FD); // TODO: how can we delay here if D is captured by its initializer? - EmitAggExpr(init, AggValueSlot::forLValue( - lvalue, *this, AggValueSlot::IsDestructed, - AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased, Overlap)); + EmitAggExpr(init, AggValueSlot::forLValue(lvalue, + AggValueSlot::IsDestructed, + AggValueSlot::DoesNotNeedGCBarriers, + AggValueSlot::IsNotAliased, + Overlap)); } return; } @@ -2457,7 +2457,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg, // objc_storeStrong attempts to release its old value. llvm::Value *Null = CGM.EmitNullConstant(D.getType()); EmitStoreOfScalar(Null, lv, /* isInitialization */ true); - EmitARCStoreStrongCall(lv.getAddress(*this), ArgVal, true); + EmitARCStoreStrongCall(lv.getAddress(), ArgVal, true); DoStore = false; } else |