[OPENMP] Capture references to global variables.
In C++11 variable to global variables are considered as constant
expressions and these variables are not captured in the outlined
regions. Patch allows capturing of such variables in the OpenMP regions.
llvm-svn: 315074
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 1bb57b6..b1b7c1b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2297,8 +2297,12 @@
VD->isUsableInConstantExpressions(getContext()) &&
VD->checkInitIsICE() &&
// Do not emit if it is private OpenMP variable.
- !(E->refersToEnclosingVariableOrCapture() && CapturedStmtInfo &&
- LocalDeclMap.count(VD))) {
+ !(E->refersToEnclosingVariableOrCapture() &&
+ ((CapturedStmtInfo &&
+ (LocalDeclMap.count(VD->getCanonicalDecl()) ||
+ CapturedStmtInfo->lookup(VD->getCanonicalDecl()))) ||
+ LambdaCaptureFields.lookup(VD->getCanonicalDecl()) ||
+ isa<BlockDecl>(CurCodeDecl)))) {
llvm::Constant *Val =
ConstantEmitter(*this).emitAbstract(E->getLocation(),
*VD->evaluateValue(),