================
@@ -427,18 +592,61 @@ class OutlinedFunctionDeclBodyInstantiator
return DRE;
}
+ // Diagnose CXXThisExpr in a potentially evaluated expression.
+ ExprResult TransformCXXThisExpr(CXXThisExpr *CTE) {
+ if (SemaRef.currentEvaluationContext().isPotentiallyEvaluated()) {
+ SemaRef.Diag(CTE->getExprLoc(), diag::err_sycl_entry_point_invalid_this)
+ << (CTE->isImplicitCXXThis() ? /* implicit */ 1 : /* empty */ 0)
+ << FD->getAttr<SYCLKernelEntryPointAttr>();
+ }
+ return CTE;
+ }
+
private:
Sema &SemaRef;
ParmDeclMap &MapRef;
+ FunctionDecl *FD;
};
+OutlinedFunctionDecl *BuildSYCLKernelEntryPointOutline(Sema &SemaRef,
+ FunctionDecl *FD,
+ CompoundStmt *Body) {
+ using ParmDeclMap = OutlinedFunctionDeclBodyInstantiator::ParmDeclMap;
+ ParmDeclMap ParmMap;
+
+ OutlinedFunctionDecl *OFD = OutlinedFunctionDecl::Create(
+ SemaRef.getASTContext(), FD, FD->getNumParams());
+ unsigned i = 0;
+ for (ParmVarDecl *PVD : FD->parameters()) {
+ ImplicitParamDecl *IPD = ImplicitParamDecl::Create(
+ SemaRef.getASTContext(), OFD, SourceLocation(), PVD->getIdentifier(),
+ PVD->getType(), ImplicitParamKind::Other);
+ OFD->setParam(i, IPD);
+ ParmMap[PVD] = IPD;
+ ++i;
+ }
+
+ OutlinedFunctionDeclBodyInstantiator OFDBodyInstantiator(SemaRef, ParmMap,
+ FD);
+ Stmt *OFDBody = OFDBodyInstantiator.TransformStmt(Body).get();
+ OFD->setBody(OFDBody);
+ OFD->setNothrow();
+
+ return OFD;
+}
+
} // unnamed namespace
StmtResult SemaSYCL::BuildSYCLKernelCallStmt(FunctionDecl *FD,
- CompoundStmt *Body) {
+ CompoundStmt *Body,
+ Expr *LaunchIdExpr) {
assert(!FD->isInvalidDecl());
assert(!FD->isTemplated());
assert(FD->hasPrototype());
+ // The current context must be the function definition context to ensure
+ // that name lookup and parameter and local variable creation are performed
+ // within the correct scope.
+ assert(SemaRef.CurContext == FD);
----------------
AaronBallman wrote:
Another good place for some `&& "explanation"`. (You should assume this comment
applies to all asserts.)
https://github.com/llvm/llvm-project/pull/152403
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits