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

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 10 10:23:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nick Sarnie (sarnex)

<details>
<summary>Changes</summary>

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);
     }
 }];
 }

``````````

</details>


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


More information about the cfe-commits mailing list