summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-08-20 16:00:22 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-08-20 16:00:22 +0000
commit5b14cddec6bdb8da8f375dfe0c0910ff970a0e05 (patch)
tree87150966d70ffced5c988fef58ab8096ed398afa /lib/CodeGen/CGExpr.cpp
parent7a2e99a914ddab10a489bbe9c099ab429706c3cb (diff)
downloadclang-5b14cddec6bdb8da8f375dfe0c0910ff970a0e05.tar.gz
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340181 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 605c01d52b..b74937e9ca 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -2437,6 +2437,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
// 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() &&
@@ -2446,7 +2447,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
(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(),