@@ -55,7 +55,7 @@ class DSAStackTy final {
55
55
Expr *RefExpr = nullptr;
56
56
DeclRefExpr *PrivateCopy = nullptr;
57
57
SourceLocation ImplicitDSALoc;
58
- DSAVarData() {}
58
+ DSAVarData() = default;
59
59
};
60
60
typedef llvm::SmallVector<std::pair<Expr *, OverloadedOperatorKind>, 4>
61
61
OperatorOffsetTy;
@@ -112,7 +112,7 @@ class DSAStackTy final {
112
112
Scope *CurScope, SourceLocation Loc)
113
113
: Directive(DKind), DirectiveName(Name), CurScope(CurScope),
114
114
ConstructLoc(Loc) {}
115
- SharingMapTy() {}
115
+ SharingMapTy() = default;
116
116
};
117
117
118
118
typedef SmallVector<SharingMapTy, 4> StackTy;
@@ -479,7 +479,25 @@ bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) {
479
479
}
480
480
} // namespace
481
481
482
+ static Expr *getExprAsWritten(Expr *E) {
483
+ if (auto *ExprTemp = dyn_cast<ExprWithCleanups>(E))
484
+ E = ExprTemp->getSubExpr();
485
+
486
+ if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
487
+ E = MTE->GetTemporaryExpr();
488
+
489
+ while (auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
490
+ E = Binder->getSubExpr();
491
+
492
+ if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
493
+ E = ICE->getSubExprAsWritten();
494
+ return E->IgnoreParens();
495
+ }
496
+
482
497
static ValueDecl *getCanonicalDecl(ValueDecl *D) {
498
+ if (auto *CED = dyn_cast<OMPCapturedExprDecl>(D))
499
+ if (auto *ME = dyn_cast<MemberExpr>(getExprAsWritten(CED->getInit())))
500
+ D = ME->getMemberDecl();
483
501
auto *VD = dyn_cast<VarDecl>(D);
484
502
auto *FD = dyn_cast<FieldDecl>(D);
485
503
if (VD != nullptr) {
@@ -821,6 +839,7 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(ValueDecl *D, bool FromParent) {
821
839
DVar.PrivateCopy = I->SharingMap[D].PrivateCopy;
822
840
DVar.CKind = I->SharingMap[D].Attributes;
823
841
DVar.ImplicitDSALoc = I->DefaultAttrLoc;
842
+ DVar.DKind = I->Directive;
824
843
}
825
844
826
845
return DVar;
@@ -3053,21 +3072,6 @@ bool OpenMPIterationSpaceChecker::Dependent() const {
3053
3072
(Step && Step->isValueDependent());
3054
3073
}
3055
3074
3056
- static Expr *getExprAsWritten(Expr *E) {
3057
- if (auto *ExprTemp = dyn_cast<ExprWithCleanups>(E))
3058
- E = ExprTemp->getSubExpr();
3059
-
3060
- if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
3061
- E = MTE->GetTemporaryExpr();
3062
-
3063
- while (auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
3064
- E = Binder->getSubExpr();
3065
-
3066
- if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
3067
- E = ICE->getSubExprAsWritten();
3068
- return E->IgnoreParens();
3069
- }
3070
-
3071
3075
bool OpenMPIterationSpaceChecker::SetLCDeclAndLB(ValueDecl *NewLCDecl,
3072
3076
Expr *NewLCRefExpr,
3073
3077
Expr *NewLB) {
@@ -3249,12 +3253,8 @@ static const ValueDecl *GetInitLCDecl(Expr *E) {
3249
3253
CE->getNumArgs() > 0 && CE->getArg(0) != nullptr)
3250
3254
E = CE->getArg(0)->IgnoreParenImpCasts();
3251
3255
if (auto *DRE = dyn_cast_or_null<DeclRefExpr>(E)) {
3252
- if (auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
3253
- if (auto *CED = dyn_cast<OMPCapturedExprDecl>(VD))
3254
- if (auto *ME = dyn_cast<MemberExpr>(getExprAsWritten(CED->getInit())))
3255
- return getCanonicalDecl(ME->getMemberDecl());
3256
+ if (auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3256
3257
return getCanonicalDecl(VD);
3257
- }
3258
3258
}
3259
3259
if (auto *ME = dyn_cast_or_null<MemberExpr>(E))
3260
3260
if (ME->isArrow() && isa<CXXThisExpr>(ME->getBase()->IgnoreParenImpCasts()))
@@ -8097,7 +8097,8 @@ getPrivateItem(Sema &S, Expr *&RefExpr, SourceLocation &ELoc,
8097
8097
}
8098
8098
return std::make_pair(nullptr, false);
8099
8099
}
8100
- return std::make_pair(DE ? DE->getDecl() : ME->getMemberDecl(), false);
8100
+ return std::make_pair(
8101
+ getCanonicalDecl(DE ? DE->getDecl() : ME->getMemberDecl()), false);
8101
8102
}
8102
8103
8103
8104
OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
@@ -8981,7 +8982,6 @@ static bool ActOnOMPReductionKindClause(
8981
8982
// C++
8982
8983
// reduction-identifier is either an id-expression or one of the following
8983
8984
// operators: +, -, *, &, |, ^, && and ||
8984
- // FIXME: Only 'min' and 'max' identifiers are supported for now.
8985
8985
switch (OOK) {
8986
8986
case OO_Plus:
8987
8987
case OO_Minus:
@@ -9044,7 +9044,7 @@ static bool ActOnOMPReductionKindClause(
9044
9044
case NUM_OVERLOADED_OPERATORS:
9045
9045
llvm_unreachable("Unexpected reduction identifier");
9046
9046
case OO_None:
9047
- if (auto II = DN.getAsIdentifierInfo()) {
9047
+ if (auto * II = DN.getAsIdentifierInfo()) {
9048
9048
if (II->isStr("max"))
9049
9049
BOK = BO_GT;
9050
9050
else if (II->isStr("min"))
@@ -9055,6 +9055,8 @@ static bool ActOnOMPReductionKindClause(
9055
9055
SourceRange ReductionIdRange;
9056
9056
if (ReductionIdScopeSpec.isValid())
9057
9057
ReductionIdRange.setBegin(ReductionIdScopeSpec.getBeginLoc());
9058
+ else
9059
+ ReductionIdRange.setBegin(ReductionId.getBeginLoc());
9058
9060
ReductionIdRange.setEnd(ReductionId.getEndLoc());
9059
9061
9060
9062
auto IR = UnresolvedReductions.begin(), ER = UnresolvedReductions.end();
@@ -9166,6 +9168,7 @@ static bool ActOnOMPReductionKindClause(
9166
9168
<< getOpenMPClauseName(ClauseKind);
9167
9169
if (DVar.RefExpr)
9168
9170
S.Diag(DVar.RefExpr->getExprLoc(), diag::note_omp_referenced);
9171
+ continue;
9169
9172
} else if (DVar.CKind != OMPC_unknown) {
9170
9173
S.Diag(ELoc, diag::err_omp_wrong_dsa)
9171
9174
<< getOpenMPClauseName(DVar.CKind)
@@ -9453,9 +9456,10 @@ static bool ActOnOMPReductionKindClause(
9453
9456
S.BuildBinOp(Stack->getCurScope(), ReductionId.getLocStart(),
9454
9457
BO_Assign, LHSDRE, ConditionalOp);
9455
9458
}
9456
- ReductionOp = S.ActOnFinishFullExpr(ReductionOp.get());
9459
+ if (ReductionOp.isUsable())
9460
+ ReductionOp = S.ActOnFinishFullExpr(ReductionOp.get());
9457
9461
}
9458
- if (ReductionOp.isInvalid ())
9462
+ if (! ReductionOp.isUsable ())
9459
9463
continue;
9460
9464
}
9461
9465
@@ -9767,10 +9771,6 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV,
9767
9771
HasErrors = true;
9768
9772
continue;
9769
9773
}
9770
- if (auto *CED = dyn_cast<OMPCapturedExprDecl>(D)) {
9771
- D = cast<MemberExpr>(CED->getInit()->IgnoreParenImpCasts())
9772
- ->getMemberDecl();
9773
- }
9774
9774
auto &&Info = Stack->isLoopControlVariable(D);
9775
9775
Expr *InitExpr = *CurInit;
9776
9776
0 commit comments