================
@@ -387,8 +397,162 @@ void
SemaSYCL::CheckSYCLEntryPointFunctionDecl(FunctionDecl *FD) {
}
}
+ExprResult SemaSYCL::BuildSYCLKernelLaunchIdExpr(FunctionDecl *FD,
+ QualType KNT) {
+ // The current context must be the function definition context to ensure
+ // that name lookup is performed within the correct scope.
+ assert(SemaRef.CurContext == FD);
+
+ // An appropriate source location is required to emit diagnostics if
+ // lookup fails to produce an overload set. The desired location is the
+ // start of the function body, but that is not yet available since the
+ // body of the function has not yet been set when this function is called.
+ // The general location of the function is used instead.
+ SourceLocation Loc = FD->getLocation();
+
+ ASTContext &Ctx = SemaRef.getASTContext();
+ IdentifierInfo &SYCLKernelLaunchID =
+ Ctx.Idents.get("sycl_kernel_launch", tok::TokenKind::identifier);
+
+ // Establish a code synthesis context for the implicit name lookup of
+ // a template named 'sycl_kernel_launch'. In the event of an error, this
+ // ensures an appropriate diagnostic note is issued to explain why the
+ // lookup was performed.
+ Sema::CodeSynthesisContext CSC;
+ CSC.Kind = Sema::CodeSynthesisContext::SYCLKernelLaunchLookup;
+ CSC.Entity = FD;
+ Sema::ScopedCodeSynthesisContext ScopedCSC(SemaRef, CSC);
+
+ // Perform ordinary name lookup for a function or variable template that
+ // accepts a single type template argument.
+ LookupResult Result(SemaRef, &SYCLKernelLaunchID, Loc,
+ Sema::LookupOrdinaryName);
+ CXXScopeSpec EmptySS;
+ if (SemaRef.LookupTemplateName(Result, SemaRef.getCurScope(), EmptySS,
+ /*ObjectType*/ QualType(),
+ /*EnteringContext*/ false,
+ Sema::TemplateNameIsRequired))
+ return ExprError();
+ if (Result.isAmbiguous())
+ return ExprError();
+
+ TemplateArgumentListInfo TALI{Loc, Loc};
+ TemplateArgument KNTA = TemplateArgument(KNT);
+ TemplateArgumentLoc TAL =
+ SemaRef.getTrivialTemplateArgumentLoc(KNTA, QualType(), Loc);
+ TALI.addArgument(TAL);
+
+ ExprResult IdExpr;
+ if (SemaRef.isPotentialImplicitMemberAccess(EmptySS, Result,
+ /*IsAddressOfOperand*/ false))
+ // The lookup result allows for a possible implicit member access that
+ // would require an implicit or explicit 'this' argument.
+ IdExpr = SemaRef.BuildPossibleImplicitMemberExpr(
+ EmptySS, SourceLocation(), Result, &TALI, SemaRef.getCurScope());
+ else
+ IdExpr = SemaRef.BuildTemplateIdExpr(EmptySS, SourceLocation(), Result,
+ /*RequiresADL*/ true, &TALI);
----------------
bader wrote:
Coding standards suggests using braces for such if-statements.
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
https://github.com/llvm/llvm-project/pull/152403
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits