================
@@ -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.
----------------
Fznamznon wrote:
So, I've made an experiment:
```
// h1.h
-----------------------------------------------------------
// In some header...
struct S {
int &dm;
};
struct KT {
void operator()() const {}
S s;
};
-----------------------------------------------------------
// h2.h
-----------------------------------------------------------
#include "sycl.hpp"
template<typename KN, typename KT>
void submit_kernel(const KT &k) {
single_task<KN>(k);
}
-----------------------------------------------------------
// sycl.hpp
-----------------------------------------------------------
// POTENTIAL SYCL impl
template<typename KNT, typename T>
[[clang::sycl_kernel_entry_point(KNT)]]
void single_task(T) {}
-----------------------------------------------------------
// src.cpp
-----------------------------------------------------------
#include "h1.h"
#include "h2.h"
// In some other file...
void f(const KT &k) {
submit_kernel<struct KN>(k);
}
-----------------------------------------------------------
// compile line
clang -cc1 -fsycl-is-device -emit-llvm -triple spirv64-unknown-unknown
-aux-triple x86_64-linux src.cpp -Wall -std=c++17
result WITHOUT parmvardecl note
./h1.h:3:8: error: 'int &' cannot be used as the type of a kernel parameter
3 | int &dm;
| ^
./h2.h:6:3: note: in instantiation of function template specialization
'single_task<KN, KT>' requested here
6 | single_task<KN>(k);
| ^
src.cpp:7:3: note: in instantiation of function template specialization
'submit_kernel<KN, KT>' requested here
7 | submit_kernel<struct KN>(k);
| ^
./h1.h:5:8: note: within field of type 'KT' declared here
5 | struct KT {
| ^
./h1.h:2:8: note: within field of type 'S' declared here
2 | struct S {
| ^
1 error generated.
result WITH parmvardecl note
In file included from src.cpp:1:
./h1.h:3:8: error: 'int &' cannot be used as the type of a kernel parameter
3 | int &dm;
| ^
./h2.h:6:3: note: in instantiation of function template specialization
'single_task<KN, KT>' requested here
6 | single_task<KN>(k);
| ^
src.cpp:7:3: note: in instantiation of function template specialization
'submit_kernel<KN, KT>' requested here
7 | submit_kernel<struct KN>(k);
| ^
./sycl.hpp:3:18: note: within parameter '' declared here <---- NEW NOTE
3 | void single_task(T) {}
| ^
./h1.h:5:8: note: within field of type 'KT' declared here
5 | struct KT {
| ^
./h1.h:2:8: note: within field of type 'S' declared here
2 | struct S {
| ^
1 error generated.
```
@bader , I was wondering if you could kindly help to resolve the dispute and
provide your opinion. Do you think that an additional note coming from SYCL
headers pointing to a declaration of a template is somehow helpful for the user
experience or rather confusing?
https://github.com/llvm/llvm-project/pull/192957
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits