================ @@ -455,14 +456,22 @@ void createHostLayoutStructForBuffer(Sema &S, HLSLBufferDecl *BufDecl) { LS->setImplicit(true); LS->startDefinition(); - for (const Decl *D : BufDecl->decls()) { - const VarDecl *VD = dyn_cast<VarDecl>(D); + for (Decl *D : BufDecl->decls()) { + VarDecl *VD = dyn_cast<VarDecl>(D); if (!VD || VD->getStorageClass() == SC_Static) continue; const Type *Ty = VD->getType()->getUnqualifiedDesugaredType(); if (FieldDecl *FD = createFieldForHostLayoutStruct( - S, Ty, VD->getIdentifier(), LS, BufDecl)) + S, Ty, VD->getIdentifier(), LS, BufDecl)) { + // add the field decl to the layout struct LS->addDecl(FD); + // update address space of the original decl to hlsl_constant + // and disable initialization + QualType NewTy = + AST.getAddrSpaceQualType(VD->getType(), LangAS::hlsl_constant); + VD->setType(NewTy); + VD->setInit(nullptr); ---------------- tex3d wrote:
Does this `VD->setInit(nullptr);` silently get rid of an initializer if there was one? This feels a bit sketchy, unless I'm missing something. I know we don't currently support capturing initializers for constant buffer values, but it is part of HLSL syntax and could in theory be captured. Silently erasing it from the AST node at this point seems weird. https://github.com/llvm/llvm-project/pull/123411 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits