[clang] [clang][SYCL] Add sycl_external attribute and restrict emitting device code (PR #140282)

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 16 07:01:07 PDT 2025


================
@@ -202,6 +202,17 @@ void SemaSYCL::handleKernelAttr(Decl *D, const ParsedAttr &AL) {
   handleSimpleAttribute<DeviceKernelAttr>(*this, D, AL);
 }
 
+void SemaSYCL::handleExternalAttr(Decl *D, const ParsedAttr &AL) {
+  auto *ND = cast<NamedDecl>(D);
+  if (!ND->isExternallyVisible()) {
----------------
tahonermann wrote:

Since the attribute is defined to only appertain to functions (via the `Subjects` declaration), I believe we can assume `FuncionDecl` here.
```suggestion
  auto *FD = cast<FunctionDecl>(D);
  if (!FD->isExternallyVisible()) {
```

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


More information about the cfe-commits mailing list