Skip to content

Commit 11f0a79

Browse files
committed
Assert that YDimExpr or ZDimExpr cannot be null at a different place
Do it after checking for 3 argument requirement for OpenCL and cl:: spellings
1 parent 690d6ce commit 11f0a79

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,13 +3148,15 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
31483148
// to the default value 1, but only if the sycl:: or intel::
31493149
// reqd_work_group_size spelling was used.
31503150
auto SetDefaultValue = [](Sema &S, const ParsedAttr &AL, SourceLocation loc) {
3151-
assert((AL.getKind() == ParsedAttr::AT_ReqdWorkGroupSize && AL.hasScope() &&
3152-
(AL.getScopeName()->isStr("sycl") ||
3153-
AL.getScopeName()->isStr("intel"))) &&
3154-
"Attribute does not exist in sycl:: or intel:: scope");
3151+
Expr *E =
3152+
(AL.getKind() == ParsedAttr::AT_ReqdWorkGroupSize && AL.hasScope() &&
3153+
(AL.getScopeName()->isStr("sycl") ||
3154+
AL.getScopeName()->isStr("intel")))
3155+
? IntegerLiteral::Create(S.Context, llvm::APInt(32, 1),
3156+
S.Context.IntTy, AL.getLoc())
3157+
: nullptr;
31553158

3156-
return IntegerLiteral::Create(S.Context, llvm::APInt(32, 1),
3157-
S.Context.IntTy, AL.getLoc());
3159+
return E;
31583160
};
31593161

31603162
Expr *YDimExpr = AL.isArgExpr(1) ? AL.getArgAsExpr(1)
@@ -3176,6 +3178,8 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
31763178

31773179
ASTContext &Ctx = S.getASTContext();
31783180

3181+
assert(YDimExpr && "YDimExpr cannot be NULL");
3182+
assert(ZDimExpr && "ZDimExpr cannot be NULL");
31793183
if (!XDimExpr->isValueDependent() && !YDimExpr->isValueDependent() &&
31803184
!ZDimExpr->isValueDependent()) {
31813185
llvm::APSInt XDimVal, YDimVal, ZDimVal;

0 commit comments

Comments
 (0)