diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjC.cpp | 40 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntime.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGStmtOpenMP.cpp | 39 |
5 files changed, 46 insertions, 43 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 6631bfb0df2..06b794fc8d0 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1075,7 +1075,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { src = I->second; } } else { - DeclRefExpr declRef(const_cast<VarDecl *>(variable), + DeclRefExpr declRef(getContext(), const_cast<VarDecl *>(variable), /*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type.getNonReferenceType(), VK_LValue, SourceLocation()); @@ -1149,7 +1149,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) { // We use one of these or the other depending on whether the // reference is nested. - DeclRefExpr declRef(const_cast<VarDecl *>(variable), + DeclRefExpr declRef(getContext(), const_cast<VarDecl *>(variable), /*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type, VK_LValue, SourceLocation()); diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 2b3696a4f2b..2262c998af0 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -547,7 +547,7 @@ namespace { void Emit(CodeGenFunction &CGF, Flags flags) override { // Compute the address of the local variable, in case it's a // byref or something. - DeclRefExpr DRE(const_cast<VarDecl*>(&Var), false, + DeclRefExpr DRE(CGF.getContext(), const_cast<VarDecl *>(&Var), false, Var.getType(), VK_LValue, SourceLocation()); llvm::Value *value = CGF.EmitLoadOfScalar(CGF.EmitDeclRefLValue(&DRE), SourceLocation()); @@ -565,7 +565,7 @@ namespace { : CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {} void Emit(CodeGenFunction &CGF, Flags flags) override { - DeclRefExpr DRE(const_cast<VarDecl*>(&Var), false, + DeclRefExpr DRE(CGF.getContext(), const_cast<VarDecl *>(&Var), false, Var.getType(), VK_LValue, SourceLocation()); // Compute the address of the local variable, in case it's a byref // or something. diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index bfb31337b2c..d497179a533 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -1125,8 +1125,9 @@ static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); - DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), - VK_LValue, SourceLocation()); + DeclRefExpr argRef(CGF.getContext(), argVar, false, + argVar->getType().getNonReferenceType(), VK_LValue, + SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy); @@ -1170,8 +1171,9 @@ static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF, // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); - DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), - VK_LValue, SourceLocation()); + DeclRefExpr argRef(CGF.getContext(), argVar, false, + argVar->getType().getNonReferenceType(), VK_LValue, + SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy); @@ -1343,7 +1345,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, // Otherwise, fake up some ASTs and emit a normal assignment. ValueDecl *selfDecl = setterMethod->getSelfDecl(); - DeclRefExpr self(selfDecl, false, selfDecl->getType(), + DeclRefExpr self(getContext(), selfDecl, false, selfDecl->getType(), VK_LValue, SourceLocation()); ImplicitCastExpr selfLoad(ImplicitCastExpr::OnStack, selfDecl->getType(), CK_LValueToRValue, &self, @@ -1354,7 +1356,8 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, ParmVarDecl *argDecl = *setterMethod->param_begin(); QualType argType = argDecl->getType().getNonReferenceType(); - DeclRefExpr arg(argDecl, false, argType, VK_LValue, SourceLocation()); + DeclRefExpr arg(getContext(), argDecl, false, argType, VK_LValue, + SourceLocation()); ImplicitCastExpr argLoad(ImplicitCastExpr::OnStack, argType.getUnqualifiedType(), CK_LValueToRValue, &arg, VK_RValue); @@ -1516,7 +1519,8 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, llvm::Value *CodeGenFunction::LoadObjCSelf() { VarDecl *Self = cast<ObjCMethodDecl>(CurFuncDecl)->getSelfDecl(); - DeclRefExpr DRE(Self, /*is enclosing local*/ (CurFuncDecl != CurCodeDecl), + DeclRefExpr DRE(getContext(), Self, + /*is enclosing local*/ (CurFuncDecl != CurCodeDecl), Self->getType(), VK_LValue, SourceLocation()); return EmitLoadOfScalar(EmitDeclRefLValue(&DRE), SourceLocation()); } @@ -1702,9 +1706,9 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ // Initialize the variable, in case it's a __block variable or something. EmitAutoVarInit(variable); - const VarDecl* D = cast<VarDecl>(SD->getSingleDecl()); - DeclRefExpr tempDRE(const_cast<VarDecl*>(D), false, D->getType(), - VK_LValue, SourceLocation()); + const VarDecl *D = cast<VarDecl>(SD->getSingleDecl()); + DeclRefExpr tempDRE(getContext(), const_cast<VarDecl *>(D), false, + D->getType(), VK_LValue, SourceLocation()); elementLValue = EmitLValue(&tempDRE); elementType = D->getType(); elementIsVariable = true; @@ -3374,13 +3378,13 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr DstExpr(&DstDecl, false, DestTy, - VK_RValue, SourceLocation()); + DeclRefExpr DstExpr(getContext(), &DstDecl, false, DestTy, VK_RValue, + SourceLocation()); UnaryOperator DST(&DstExpr, UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false); - DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy, - VK_RValue, SourceLocation()); + DeclRefExpr SrcExpr(getContext(), &SrcDecl, false, SrcTy, VK_RValue, + SourceLocation()); UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false); @@ -3457,8 +3461,8 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( StartFunction(FD, ReturnTy, Fn, FI, args); - DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy, - VK_RValue, SourceLocation()); + DeclRefExpr SrcExpr(getContext(), &SrcDecl, false, SrcTy, VK_RValue, + SourceLocation()); UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false); @@ -3483,8 +3487,8 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( CXXConstExpr->getConstructionKind(), SourceRange()); - DeclRefExpr DstExpr(&DstDecl, false, DestTy, - VK_RValue, SourceLocation()); + DeclRefExpr DstExpr(getContext(), &DstDecl, false, DestTy, VK_RValue, + SourceLocation()); RValue DV = EmitAnyExpr(&DstExpr); CharUnits Alignment diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index d7a0a72de10..746d3d3e647 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -353,7 +353,7 @@ public: if (VD->isLocalVarDeclOrParm()) continue; - DeclRefExpr DRE(const_cast<VarDecl *>(VD), + DeclRefExpr DRE(CGF.getContext(), const_cast<VarDecl *>(VD), /*RefersToEnclosingVariableOrCapture=*/false, VD->getType().getNonReferenceType(), VK_LValue, C.getLocation()); diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 4f635efe713..ee385930843 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -73,7 +73,7 @@ public: assert(VD == VD->getCanonicalDecl() && "Canonical decl must be captured."); DeclRefExpr DRE( - const_cast<VarDecl *>(VD), + CGF.getContext(), const_cast<VarDecl *>(VD), isCapturedVar(CGF, VD) || (CGF.CapturedStmtInfo && InlinedShareds.isGlobalVarCaptured(VD)), VD->getType().getNonReferenceType(), VK_LValue, C.getLocation()); @@ -191,7 +191,7 @@ public: auto *VD = C.getCapturedVar(); assert(VD == VD->getCanonicalDecl() && "Canonical decl must be captured."); - DeclRefExpr DRE(const_cast<VarDecl *>(VD), + DeclRefExpr DRE(CGF.getContext(), const_cast<VarDecl *>(VD), isCapturedVar(CGF, VD) || (CGF.CapturedStmtInfo && InlinedShareds.isGlobalVarCaptured(VD)), @@ -222,7 +222,7 @@ LValue CodeGenFunction::EmitOMPSharedLValue(const Expr *E) { LambdaCaptureFields.lookup(OrigVD) || (CapturedStmtInfo && CapturedStmtInfo->lookup(OrigVD)) || (CurCodeDecl && isa<BlockDecl>(CurCodeDecl)); - DeclRefExpr DRE(const_cast<VarDecl *>(OrigVD), IsCaptured, + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(OrigVD), IsCaptured, OrigDRE->getType(), VK_LValue, OrigDRE->getExprLoc()); return EmitLValue(&DRE); } @@ -763,7 +763,7 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D, const auto *VDInit = cast<VarDecl>(cast<DeclRefExpr>(*InitsRef)->getDecl()); bool IsRegistered; - DeclRefExpr DRE(const_cast<VarDecl *>(OrigVD), + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(OrigVD), /*RefersToEnclosingVariableOrCapture=*/FD != nullptr, (*IRef)->getType(), VK_LValue, (*IRef)->getExprLoc()); LValue OriginalLVal = EmitLValue(&DRE); @@ -878,8 +878,8 @@ bool CodeGenFunction::EmitOMPCopyinClause(const OMPExecutableDirective &D) { getContext().getTargetInfo().isTLSSupported()) { assert(CapturedStmtInfo->lookup(VD) && "Copyin threadprivates should have been captured!"); - DeclRefExpr DRE(const_cast<VarDecl *>(VD), true, (*IRef)->getType(), - VK_LValue, (*IRef)->getExprLoc()); + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(VD), true, + (*IRef)->getType(), VK_LValue, (*IRef)->getExprLoc()); MasterAddr = EmitLValue(&DRE).getAddress(); LocalDeclMap.erase(VD); } else { @@ -953,11 +953,10 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit( const auto *DestVD = cast<VarDecl>(cast<DeclRefExpr>(*IDestRef)->getDecl()); PrivateScope.addPrivate(DestVD, [this, OrigVD, IRef]() { - DeclRefExpr DRE( - const_cast<VarDecl *>(OrigVD), - /*RefersToEnclosingVariableOrCapture=*/CapturedStmtInfo->lookup( - OrigVD) != nullptr, - (*IRef)->getType(), VK_LValue, (*IRef)->getExprLoc()); + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(OrigVD), + /*RefersToEnclosingVariableOrCapture=*/ + CapturedStmtInfo->lookup(OrigVD) != nullptr, + (*IRef)->getType(), VK_LValue, (*IRef)->getExprLoc()); return EmitLValue(&DRE).getAddress(); }); // Check if the variable is also a firstprivate: in this case IInit is @@ -1384,7 +1383,7 @@ bool CodeGenFunction::EmitOMPLinearClauseInit(const OMPLoopDirective &D) { dyn_cast<DeclRefExpr>(VD->getInit()->IgnoreImpCasts())) { AutoVarEmission Emission = EmitAutoVarAlloca(*VD); const auto *OrigVD = cast<VarDecl>(Ref->getDecl()); - DeclRefExpr DRE(const_cast<VarDecl *>(OrigVD), + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(OrigVD), CapturedStmtInfo->lookup(OrigVD) != nullptr, VD->getInit()->getType(), VK_LValue, VD->getInit()->getExprLoc()); @@ -1429,7 +1428,7 @@ void CodeGenFunction::EmitOMPLinearClauseFinal( } } const auto *OrigVD = cast<VarDecl>(cast<DeclRefExpr>(*IC)->getDecl()); - DeclRefExpr DRE(const_cast<VarDecl *>(OrigVD), + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(OrigVD), CapturedStmtInfo->lookup(OrigVD) != nullptr, (*IC)->getType(), VK_LValue, (*IC)->getExprLoc()); Address OrigAddr = EmitLValue(&DRE).getAddress(); @@ -1497,7 +1496,7 @@ void CodeGenFunction::EmitOMPPrivateLoopCounters( if (LocalDeclMap.count(VD) || CapturedStmtInfo->lookup(VD) || VD->hasGlobalStorage()) { (void)LoopScope.addPrivate(PrivateVD, [this, VD, E]() { - DeclRefExpr DRE(const_cast<VarDecl *>(VD), + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(VD), LocalDeclMap.count(VD) || CapturedStmtInfo->lookup(VD), E->getType(), VK_LValue, E->getExprLoc()); return EmitLValue(&DRE).getAddress(); @@ -1644,7 +1643,7 @@ void CodeGenFunction::EmitOMPSimdFinal( if (CED) { OrigAddr = EmitLValue(CED->getInit()->IgnoreImpCasts()).getAddress(); } else { - DeclRefExpr DRE(const_cast<VarDecl *>(PrivateVD), + DeclRefExpr DRE(getContext(), const_cast<VarDecl *>(PrivateVD), /*RefersToEnclosingVariableOrCapture=*/false, (*IPC)->getType(), VK_LValue, (*IPC)->getExprLoc()); OrigAddr = EmitLValue(&DRE).getAddress(); @@ -2929,11 +2928,11 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( CopyFn, CallArgs); for (const auto &Pair : LastprivateDstsOrigs) { const auto *OrigVD = cast<VarDecl>(Pair.second->getDecl()); - DeclRefExpr DRE( - const_cast<VarDecl *>(OrigVD), - /*RefersToEnclosingVariableOrCapture=*/CGF.CapturedStmtInfo->lookup( - OrigVD) != nullptr, - Pair.second->getType(), VK_LValue, Pair.second->getExprLoc()); + DeclRefExpr DRE(CGF.getContext(), const_cast<VarDecl *>(OrigVD), + /*RefersToEnclosingVariableOrCapture=*/ + CGF.CapturedStmtInfo->lookup(OrigVD) != nullptr, + Pair.second->getType(), VK_LValue, + Pair.second->getExprLoc()); Scope.addPrivate(Pair.first, [&CGF, &DRE]() { return CGF.EmitLValue(&DRE).getAddress(); }); |