================
@@ -697,7 +699,9 @@ BuiltinTypeDeclBuilder 
&BuiltinTypeDeclBuilder::addArraySubscriptOperators() {
       AST.DeclarationNames.getCXXOperatorName(OO_Subscript);
 
   addHandleAccessFunction(Subscript, /*IsConst=*/true, /*IsRef=*/true);
-  addHandleAccessFunction(Subscript, /*IsConst=*/false, /*IsRef=*/true);
+  if (ResClass == llvm::dxil::ResourceClass::UAV)
+    addHandleAccessFunction(Subscript, /*IsConst=*/false, /*IsRef=*/true);
----------------
bogner wrote:

I just realized that we can actually simplify this - while we don't store the 
resource information directly, we do have access to the `handle` member that 
does keep track of this information at this point via 
`getResourceHandleField()`. So we could do something like this:
```c++
HLSLAttributedResourceType::Attributes
BuiltinTypeDeclBuilder::getResourceAttrs() const {
  QualType HandleType = getResourceHandleField()->getType();
  return cast<HLSLAttributedResourceType>(HandleType)->getAttrs();
}
```

and then all we need to do is check `getResourceAttrs().ResourceClass` here.

https://github.com/llvm/llvm-project/pull/147806
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to