[clang] [OpenCL] No need to check array of struct for kernel arguments (PR #138894)
Jiefeng Wang via cfe-commits
cfe-commits at lists.llvm.org
Thu May 15 07:53:23 PDT 2025
https://github.com/jiefwo updated https://github.com/llvm/llvm-project/pull/138894
>From 78e6da1b9f49e23afe77878b81a0aafde8108976 Mon Sep 17 00:00:00 2001
From: Jiefeng Wang <wangjiefeng at huawei.com>
Date: Wed, 7 May 2025 23:02:03 +0800
Subject: [PATCH] [OpenCL] No need to check array of struct for kernel
arguments
Since arrays decay into pointers, no need to check them for arguments.
This commit reverts part of the changes from the commit
"[OpenCL] Check for invalid kernel arguments in array types"
3b238ed6626983beb238b95eada4172184fb2d29.
---
clang/lib/Sema/SemaDecl.cpp | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6b561d7bfc6e7..364fb064ccc2d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9717,14 +9717,10 @@ static void checkIsValidOpenCLKernelParameter(
SmallVector<const FieldDecl *, 4> HistoryStack;
HistoryStack.push_back(nullptr);
- // At this point we already handled everything except of a RecordType or
- // an ArrayType of a RecordType.
- assert((PT->isArrayType() || PT->isRecordType()) && "Unexpected type.");
- const RecordType *RecTy =
- PT->getPointeeOrArrayElementType()->getAs<RecordType>();
- const RecordDecl *OrigRecDecl = RecTy->getDecl();
-
- VisitStack.push_back(RecTy->getDecl());
+ // At this point we already handled everything except of a RecordType.
+ assert(PT->isRecordType() && "Unexpected type.");
+ const RecordDecl *PD = PT->castAs<RecordType>()->getDecl();
+ VisitStack.push_back(PD);
assert(VisitStack.back() && "First decl null?");
do {
@@ -9789,8 +9785,8 @@ static void checkIsValidOpenCLKernelParameter(
S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
}
- S.Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
- << OrigRecDecl->getDeclName();
+ S.Diag(PD->getLocation(), diag::note_within_field_of_type)
+ << PD->getDeclName();
// We have an error, now let's go back up through history and show where
// the offending field came from
More information about the cfe-commits
mailing list