================
@@ -665,6 +666,101 @@ OutlinedFunctionDecl
*BuildSYCLKernelEntryPointOutline(Sema &SemaRef,
return OFD;
}
+class KernelArgsChecker : public SubobjectVisitor<KernelArgsChecker> {
+ SemaSYCL &SemaSYCLRef;
+ bool IsValid = true;
+ using ObjectAccess =
+ llvm::PointerUnion<ParmVarDecl *, CXXBaseSpecifier *, FieldDecl *>;
+ SmallVector<ObjectAccess, 4> ObjectAccessPath;
+
+ void emitObjectAccessPathNotes() {
+ for (auto Parent : ObjectAccessPath) {
+ if (auto *FD = Parent.dyn_cast<FieldDecl *>()) {
+ SemaSYCLRef.Diag(FD->getParent()->getLocation(),
+ diag::note_within_field_of_type)
+ << FD->getParent();
+ } else if (auto *BS = Parent.dyn_cast<CXXBaseSpecifier *>()) {
+ CXXRecordDecl *RD = BS->getType()->getAsCXXRecordDecl();
+ assert(RD);
+ SemaSYCLRef.Diag(BS->getBeginLoc(), diag::note_within_base_of_type)
+ << RD;
+ } else {
+ // Nothing to emit for ParmVarDecl since its location just points to
+ // skep-attributed function template.
+ assert(isa<ParmVarDecl *>(Parent));
+ }
+ }
+ }
+
+public:
+ KernelArgsChecker(SemaSYCL &SR, SourceLocation Loc)
+ : SubobjectVisitor<KernelArgsChecker>(SR.getASTContext()),
+ SemaSYCLRef(SR) {}
+
+ void checkParameter(ParmVarDecl *PVD) {
+ ObjectAccessPath.push_back(PVD);
+ // Check the immediate type of the parameter.
+ if (checkType(PVD->getType())) {
+ // If type checking wasn't short circuited, visit subobjects to check
+ // them.
+ visit(PVD->getType());
+ }
+ ObjectAccessPath.pop_back();
+ // We either visited everything or we stopped visiting due to invalid
kernel
+ // argument type.
----------------
Fznamznon wrote:
Fixed now.
https://github.com/llvm/llvm-project/pull/192957
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits