Skip to content

Commit 573a98b

Browse files
Implement review comments
Signed-off-by: Elizabeth Andrews <[email protected]>
1 parent 6a43689 commit 573a98b

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -793,26 +793,16 @@ static bool isDefaultSPIRArch(ASTContext &Context) {
793793
static ParmVarDecl *getSyclKernelHandlerArg(FunctionDecl *KernelCallerFunc) {
794794
// Specialization constants in SYCL 2020 are not captured by lambda and
795795
// accessed through new optional lambda argument kernel_handler
796-
auto KHArg =
797-
std::find_if(KernelCallerFunc->param_begin(),
798-
KernelCallerFunc->param_end(), [](ParmVarDecl *PVD) {
799-
return Util::isSyclKernelHandlerType(PVD->getType());
800-
});
801-
802-
ParmVarDecl *KernelHandlerArg =
803-
(KHArg != KernelCallerFunc->param_end()) ? *KHArg : nullptr;
796+
auto IsHandlerLambda = [](ParmVarDecl *PVD) {
797+
return Util::isSyclKernelHandlerType(PVD->getType());
798+
};
804799

805-
if (KernelHandlerArg) {
806-
auto KHArgTooMany = std::find_if(
807-
std::next(KHArg), KernelCallerFunc->param_end(), [](ParmVarDecl *PVD) {
808-
return Util::isSyclKernelHandlerType(PVD->getType());
809-
});
800+
assert(llvm::count_if(KernelCallerFunc->parameters(), IsHandlerLambda) <= 1 &&
801+
"Multiple kernel_handler parameters");
810802

811-
assert(KHArgTooMany == KernelCallerFunc->param_end() &&
812-
"Too many kernel_handler arguments");
813-
}
803+
auto KHArg = llvm::find_if(KernelCallerFunc->parameters(), IsHandlerLambda);
814804

815-
return KernelHandlerArg;
805+
return (KHArg != KernelCallerFunc->param_end()) ? *KHArg : nullptr;
816806
}
817807

818808
// anonymous namespace so these don't get linkage.

0 commit comments

Comments
 (0)