[clang] [HLSL] Split out the ROV attribute from the resource attribute, make it a new spellable attribute. (PR #102414)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 12 11:42:01 PDT 2024
================
@@ -116,12 +116,17 @@ struct BuiltinTypeDeclBuilder {
QualType(TTD->getTypeForDecl(), 0));
}
// add handle member
- llvm::SmallVector<Attr *, 2> Attrs;
Attr *ResourceClassAttr =
HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC);
Attr *ResourceAttr =
- HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV);
- addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
+ HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK);
+ if (IsROV) {
+ Attr *ROVAttr = HLSLROVAttr::CreateImplicit(Record->getASTContext());
+ addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr, ROVAttr},
+ Access);
+ } else
+ addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
----------------
bogner wrote:
Having to deal with each attribute separately like this seems awkward. Doesn't it work to simply add the attribute after the fact? Something like:
```suggestion
HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK);
addMemberVariable("h", Ty, {ResourceClassAttr, ResourceAttr}, Access);
if (IsROV)
Fields["h"]->addAttr(
HLSLROVAttr::CreateImplicit(Record->getASTContext()));
```
https://github.com/llvm/llvm-project/pull/102414
More information about the cfe-commits
mailing list