diff options
author | Joshua Batista <jbatista@microsoft.com> | 2024-09-11 13:03:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 13:03:00 -0700 |
commit | b8239e1201f5871bed5b633b76fa9536672f287f (patch) | |
tree | 0d6f5887813bb46f5ab244f14ae2eab4fb67535b /clang/lib/Sema/HLSLExternalSemaSource.cpp | |
parent | c31d343857f514dde9146279797ebdcd4010e60b (diff) | |
download | llvm-b8239e1201f5871bed5b633b76fa9536672f287f.zip llvm-b8239e1201f5871bed5b633b76fa9536672f287f.tar.gz llvm-b8239e1201f5871bed5b633b76fa9536672f287f.tar.bz2 |
[HLSL] Add StructuredBuffer to external sema source (#106316)
This PR adds `StructuredBuffer` to `HLSLExternalSemaSource.cpp`, by
copying the logic from RWBuffer but just replacing the name with
StructuredBuffer. The change now allows StructuredBuffers to be defined
in HLSL, though they function the same as RWBuffers.
Further work to apply the appropriate attributes that distinguish
StructuredBuffers from other Buffer types will be deferred.
This improves our position on
https://github.com/llvm/llvm-project/issues/106189
Diffstat (limited to 'clang/lib/Sema/HLSLExternalSemaSource.cpp')
-rw-r--r-- | clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp index 071e64f..da7bbf8 100644 --- a/clang/lib/Sema/HLSLExternalSemaSource.cpp +++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp @@ -525,6 +525,16 @@ void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { .addArraySubscriptOperators() .completeDefinition(); }); + + Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "StructuredBuffer") + .addSimpleTemplateParams(*SemaPtr, {"element_type"}) + .Record; + onCompletion(Decl, [this](CXXRecordDecl *Decl) { + setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, + ResourceKind::TypedBuffer, /*IsROV=*/false) + .addArraySubscriptOperators() + .completeDefinition(); + }); } void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record, |