[clang] [clang] teach OpenCL to set the param addrspace before calling CG EmitParmDecl (PR #184264)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 08:13:05 PDT 2026


================
@@ -15798,6 +15770,20 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
     T = Context.getLifetimeQualifiedType(T, lifetime);
   }
 
+  if (getLangOpts().OpenCL) {
+    assert(!isa<DecayedType>(T));
+    if (T->isArrayType() && !T.hasAddressSpace()) {
+      QualType ET = Context.getAsArrayType(T)->getElementType();
+      if (!ET.hasAddressSpace()) {
+        // Add the private address space to the contents of the pointer when a
+        // pointer parameter is declared as an array and not declared.
+        LangAS ImplAS = LangAS::opencl_private;
----------------
arsenm wrote:

I assume you meant `f(__private int *x)`

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


More information about the cfe-commits mailing list