Author: hans Date: Tue Aug 21 15:41:40 2018 New Revision: 340352 URL: http://llvm.org/viewvc/llvm-project?rev=340352&view=rev Log: Merging r340181: ------------------------------------------------------------------------ r340181 | abataev | 2018-08-20 18:00:22 +0200 (Mon, 20 Aug 2018) | 7 lines
[OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured by a block. Added checks for capturing of the variable in the block when trying to emit correct address for the variable with the reference type. This extra check allows correctly identify the variables that are not captured in the block context. ------------------------------------------------------------------------ Added: cfe/branches/release_70/test/CodeGenCXX/block-byref.cpp - copied unchanged from r340181, cfe/trunk/test/CodeGenCXX/block-byref.cpp Modified: cfe/branches/release_70/ (props changed) cfe/branches/release_70/lib/CodeGen/CGExpr.cpp Propchange: cfe/branches/release_70/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Aug 21 15:41:40 2018 @@ -1,4 +1,4 @@ /cfe/branches/type-system-rewrite:134693-134817 -/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339372-339374,339379,339428,339494,339597,339603,340048,340079,340101,340191 +/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339372-339374,339379,339428,339494,339597,339603,340048,340079,340101,340181,340191 /cfe/trunk/test:170344 /cfe/trunk/test/SemaTemplate:126920 Modified: cfe/branches/release_70/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/CodeGen/CGExpr.cpp?rev=340352&r1=340351&r2=340352&view=diff ============================================================================== --- cfe/branches/release_70/lib/CodeGen/CGExpr.cpp (original) +++ cfe/branches/release_70/lib/CodeGen/CGExpr.cpp Tue Aug 21 15:41:40 2018 @@ -2408,6 +2408,7 @@ LValue CodeGenFunction::EmitDeclRefLValu // A DeclRefExpr for a reference initialized by a constant expression can // appear without being odr-used. Directly emit the constant initializer. const Expr *Init = VD->getAnyInitializer(VD); + const auto *BD = dyn_cast_or_null<BlockDecl>(CurCodeDecl); if (Init && !isa<ParmVarDecl>(VD) && VD->getType()->isReferenceType() && VD->isUsableInConstantExpressions(getContext()) && VD->checkInitIsICE() && @@ -2417,7 +2418,7 @@ LValue CodeGenFunction::EmitDeclRefLValu (LocalDeclMap.count(VD->getCanonicalDecl()) || CapturedStmtInfo->lookup(VD->getCanonicalDecl()))) || LambdaCaptureFields.lookup(VD->getCanonicalDecl()) || - isa<BlockDecl>(CurCodeDecl)))) { + (BD && BD->capturesVariable(VD))))) { llvm::Constant *Val = ConstantEmitter(*this).emitAbstract(E->getLocation(), *VD->evaluateValue(), _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits