[clang] [clang] Ensure we don't process OpenCL kernels as CUDA kernels (PR #163859)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 23 09:14:09 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/lib/Sema/SemaDeclAttr.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 2f1692ca6..4c5c45e34 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5214,8 +5214,7 @@ static void handleDeviceKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
     AL.setInvalid();
     return;
   }
-  if(DeviceKernelAttr::isOpenCLSpelling(AL) ||
-     !Triple.isNVPTX()) {
+  if (DeviceKernelAttr::isOpenCLSpelling(AL) || !Triple.isNVPTX()) {
     // OpenCL C++ will throw a more specific error.
     if (!LangOpts.OpenCLCPlusPlus && (!FD || IsFunctionTemplate)) {
       S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str)
@@ -5224,8 +5223,7 @@ static void handleDeviceKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
       return;
     }
     handleSimpleAttribute<DeviceKernelAttr>(S, D, AL);
-  }
-  else {
+  } else {
     handleGlobalAttr(S, D, AL);
   }
   // TODO: isGPU() should probably return true for SPIR.

``````````

</details>


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


More information about the cfe-commits mailing list