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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 23 10:53:22 PDT 2025


================
@@ -12937,6 +12937,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
   if (D->hasAttr<WeakRefAttr>())
     return false;
 
+  if (LangOpts.SYCLIsDevice && !D->hasAttr<SYCLKernelEntryPointAttr>() &&
+      !D->hasAttr<SYCLExternalAttr>())
----------------
erichkeane wrote:

I understood what you meant, and strongly disagree.  This is highly unreadable and requires grok'ing the entire function to understand the purpose here, and is more likely to result in future patches breaking this.  A more 'surgical' approach here would be 'more correct'.  What I proposed above is, as far as I can tell, EXACTLY this functionally, but less likely to be broken in the future.

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


More information about the cfe-commits mailing list