================
@@ -665,6 +666,109 @@ OutlinedFunctionDecl 
*BuildSYCLKernelEntryPointOutline(Sema &SemaRef,
   return OFD;
 }
 
+class KernelParamsChecker : public ConstSubobjectVisitor<KernelParamsChecker> {
+  SemaSYCL &SemaSYCLRef;
+  bool IsValid = true;
+  using ObjectAccess =
+      llvm::PointerUnion<const ParmVarDecl *, const CXXBaseSpecifier *,
+                         const FieldDecl *>;
+  SmallVector<ObjectAccess, 4> ObjectAccessPath;
+
+  void emitObjectAccessPathNotes() {
+    for (auto Parent : llvm::reverse(ObjectAccessPath)) {
+      if (auto *FD = Parent.dyn_cast<const FieldDecl *>()) {
+        const CXXRecordDecl *ParentRD = cast<CXXRecordDecl>(FD->getParent());
+        if (ParentRD->isLambda()) {
+          SemaSYCLRef.Diag(ParentRD->getLocation(), diag::note_within_capture)
+              << ParentRD->getCapture(FD->getFieldIndex())->getCapturedVar();
+        } else {
+          SemaSYCLRef.Diag(ParentRD->getLocation(),
+                           diag::note_within_field_of_type)
+              << ParentRD;
+        }
+      } else if (auto *BS = Parent.dyn_cast<const CXXBaseSpecifier *>()) {
+        CXXRecordDecl *RD = BS->getType()->getAsCXXRecordDecl();
+        assert(RD);
+        SemaSYCLRef.Diag(BS->getBeginLoc(), diag::note_within_base_of_type)
+            << RD;
+      } else {
+        auto *Param = cast<const ParmVarDecl *>(Parent);
----------------
AaronBallman wrote:

```suggestion
        const auto *Param = cast<ParmVarDecl>(Parent);
```
?

https://github.com/llvm/llvm-project/pull/192957
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to