Skip to content

Commit 030ab5e

Browse files
committed
Address review comments
Signed-off-by: Soumi Manna <[email protected]>
1 parent 2330ed3 commit 030ab5e

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,29 +3451,27 @@ static void handleWorkGroupSizeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
34513451
}
34523452

34533453
// Handles max_work_group_size attribute.
3454-
// Returns a AttrArgResult value; EqualToOne means all argument values are
3455-
// equal to one, NotEqualToOne means at least one argument value is not
3456-
// equal to one, and Unknown means that at least one of the argument values
3457-
// could not be determined.
3458-
enum class AttrArgResult { Unknown, EqualToOne, NotEqualToOne };
3459-
static AttrArgResult AreAllAttrArgsOne(const Expr *E, const Expr *E1,
3460-
const Expr *E2, const Expr *E3) {
3454+
// If the declaration has a SYCLIntelMaxWorkGroupSizeAttr,
3455+
// check to see if the attribute holds equal values (1, 1, 1).
3456+
// Returns true if the attribute values are equal to one.
3457+
static bool InvalidWorkGroupSizeAttrs(const Expr *E, const Expr *E1,
3458+
const Expr *E2, const Expr *E3) {
34613459
// If any of the operand is still value dependent, we can't test anything.
34623460
const auto *CE = dyn_cast<ConstantExpr>(E);
34633461
const auto *CE1 = dyn_cast<ConstantExpr>(E1);
34643462
const auto *CE2 = dyn_cast<ConstantExpr>(E2);
34653463
const auto *CE3 = dyn_cast<ConstantExpr>(E3);
34663464

34673465
if (!CE || !CE1 || !CE2 || !CE3)
3468-
return AttrArgResult::Unknown;
3466+
return false;
34693467

34703468
// Otherwise, check if the attribute values are equal to one.
34713469
if (CE->getResultAsAPSInt() == 0 &&
34723470
(CE1->getResultAsAPSInt() != 1 || CE2->getResultAsAPSInt() != 1 ||
34733471
CE3->getResultAsAPSInt() != 1)) {
3474-
return AttrArgResult::NotEqualToOne;
3472+
return true;
34753473
}
3476-
return AttrArgResult::EqualToOne;
3474+
return false;
34773475
}
34783476

34793477
void Sema::AddSYCLIntelMaxWorkGroupSizeAttr(Decl *D,
@@ -3520,8 +3518,7 @@ void Sema::AddSYCLIntelMaxWorkGroupSizeAttr(Decl *D,
35203518
// the attribute holds equal values to (1, 1, 1) in case the value of
35213519
// SYCLIntelMaxGlobalWorkDimAttr equals to 0.
35223520
if (const auto *DeclAttr = D->getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3523-
if (AreAllAttrArgsOne(DeclAttr->getValue(), XDim, YDim, ZDim) ==
3524-
AttrArgResult::NotEqualToOne) {
3521+
if (InvalidWorkGroupSizeAttrs(DeclAttr->getValue(), XDim, YDim, ZDim)) {
35253522
Diag(CI.getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
35263523
<< CI << DeclAttr;
35273524
return;
@@ -3582,8 +3579,8 @@ SYCLIntelMaxWorkGroupSizeAttr *Sema::MergeSYCLIntelMaxWorkGroupSizeAttr(
35823579
// (1, 1, 1) in case the value of SYCLIntelMaxGlobalWorkDimAttr
35833580
// equals to 0.
35843581
if (const auto *DeclAttr = D->getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3585-
if (AreAllAttrArgsOne(DeclAttr->getValue(), A.getXDim(), A.getYDim(),
3586-
A.getZDim()) == AttrArgResult::NotEqualToOne) {
3582+
if (InvalidWorkGroupSizeAttrs(DeclAttr->getValue(), A.getXDim(),
3583+
A.getYDim(), A.getZDim())) {
35873584
Diag(A.getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
35883585
<< &A << DeclAttr;
35893586
return nullptr;

0 commit comments

Comments
 (0)