[clang] [HLSL] Ignore complex types that do not contribute to cbuffer layout (PR #184276)

Joshua Batista via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 9 11:48:52 PDT 2026


================
@@ -568,15 +588,21 @@ void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) {
         VD->getType().getAddressSpace() == LangAS::hlsl_groupshared)
       continue;
     const Type *Ty = VD->getType()->getUnqualifiedDesugaredType();
+
+    QualType NewTy;
     if (FieldDecl *FD =
             createFieldForHostLayoutStruct(S, Ty, VD->getIdentifier(), LS)) {
       // add the field decl to the layout struct
       LS->addDecl(FD);
       // update address space of the original decl to hlsl_constant
-      QualType NewTy =
-          AST.getAddrSpaceQualType(VD->getType(), LangAS::hlsl_constant);
-      VD->setType(NewTy);
+      NewTy = AST.getAddrSpaceQualType(VD->getType(), LangAS::hlsl_constant);
+    } else {
+      // Declarations in default cbuffer $Globals had the address space set to
----------------
bob80905 wrote:

Just curious, is there an argument to be made here that such declarations should never have had their address space set to hlsl_constant? Should this kind of validation be moved earlier? Or is it impossible to know before this point? Seems odd to me we're removing something that was added invalidly before.

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


More information about the cfe-commits mailing list