@@ -793,26 +793,16 @@ static bool isDefaultSPIRArch(ASTContext &Context) {
793
793
static ParmVarDecl *getSyclKernelHandlerArg (FunctionDecl *KernelCallerFunc) {
794
794
// Specialization constants in SYCL 2020 are not captured by lambda and
795
795
// 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
+ };
804
799
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" );
810
802
811
- assert (KHArgTooMany == KernelCallerFunc->param_end () &&
812
- " Too many kernel_handler arguments" );
813
- }
803
+ auto KHArg = llvm::find_if (KernelCallerFunc->parameters (), IsHandlerLambda);
814
804
815
- return KernelHandlerArg ;
805
+ return (KHArg != KernelCallerFunc-> param_end ()) ? *KHArg : nullptr ;
816
806
}
817
807
818
808
// anonymous namespace so these don't get linkage.
0 commit comments