[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

sarnex wrote:

Thanks!

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

https://github.com/sarnex closed 
https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon approved this pull request.


https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

sarnex wrote:

@Fznamznon Are you okay with merging this change? Thanks

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LG even without a way to test the change.

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

> I didn't add a test because this can't be reproduced yet in this repo, I 
> reproduced this only in intel's fork with more SYCL support.

But that does sound specific to the downstream, right? Do we observe the issue 
there because intel's fork used to add OpenCLKernelAttr implicitly in SemaSYCL?

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

sarnex wrote:

> Do we observe the issue there because intel's fork used to add 
> OpenCLKernelAttr implicitly in SemaSYCL?
Yes, since the attribute is created implicitly, there's no spelling to check so 
there's no `AttrName`.

I understand we can only reproduce the problem out-of-tree, but since it's just 
a `nullptr` check and in general the assumption in this code that `AttrName` is 
always available is wrong, I think it's okay to have the fix here.

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)


Changes

I didn't add a test because this can't be reproduced yet in this repo, I 
reproduced this only in intel's fork with more SYCL support.

I also fixed some formatting.

---
Full diff: https://github.com/llvm/llvm-project/pull/143546.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+3-3) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index f889e41c8699f..82861a3d618d9 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1590,11 +1590,11 @@ def DeviceKernel : DeclOrTypeAttr {
 // list, but here we have the same spelling with unscores and without,
 // so handle that case manually.
   return A.getAttributeSpellingListIndex() == Keyword_kernel ||
-  A.getAttrName()->getName() == "kernel";
+  (A.getAttrName() && A.getAttrName()->getName() == "kernel");
 }
 static inline bool isOpenCLSpelling(const AttributeCommonInfo* A) {
-if (!A) return false;
-return isOpenCLSpelling(*A);
+  if (!A) return false;
+  return isOpenCLSpelling(*A);
 }
 }];
 }

``




https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

https://github.com/sarnex ready_for_review 
https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

sarnex wrote:

CI fails not related

https://github.com/llvm/llvm-project/pull/143546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Attr] Fix possible crash when trying to check for DeviceKernel spelling (PR #143546)

2025-06-10 Thread Nick Sarnie via cfe-commits

https://github.com/sarnex created 
https://github.com/llvm/llvm-project/pull/143546

I didn't add a test because this can't be reproduced yet in this repo, I 
reproduced this only in intel's fork with more SYCL support.

I also fixed some formatting.

>From b5c115df82873ecd092d86be3e7e8339e076981f Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" 
Date: Tue, 10 Jun 2025 07:58:05 -0700
Subject: [PATCH] [Clang][Attr] Fix possible crash when trying to check for
 DeviceKernelAttr spelling

Signed-off-by: Sarnie, Nick 
---
 clang/include/clang/Basic/Attr.td | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index f889e41c8699f..82861a3d618d9 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1590,11 +1590,11 @@ def DeviceKernel : DeclOrTypeAttr {
 // list, but here we have the same spelling with unscores and without,
 // so handle that case manually.
   return A.getAttributeSpellingListIndex() == Keyword_kernel ||
-  A.getAttrName()->getName() == "kernel";
+  (A.getAttrName() && A.getAttrName()->getName() == "kernel");
 }
 static inline bool isOpenCLSpelling(const AttributeCommonInfo* A) {
-if (!A) return false;
-return isOpenCLSpelling(*A);
+  if (!A) return false;
+  return isOpenCLSpelling(*A);
 }
 }];
 }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits