[clang] [HLSL] Support packoffset attribute in AST (PR #89836)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 24 22:31:17 PDT 2024
================
@@ -7314,6 +7314,47 @@ static void handleHLSLSV_DispatchThreadIDAttr(Sema &S, Decl *D,
D->addAttr(::new (S.Context) HLSLSV_DispatchThreadIDAttr(S.Context, AL));
}
+static void handleHLSLPackOffsetAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+ if (!isa<VarDecl>(D)) {
+ S.Diag(AL.getLoc(), diag::err_hlsl_attr_invalid_ast_node)
+ << AL << "cbuffer constant";
+ return;
+ }
+ auto *BufDecl = dyn_cast<HLSLBufferDecl>(D->getDeclContext());
+ if (!BufDecl) {
+ S.Diag(AL.getLoc(), diag::err_hlsl_attr_invalid_ast_node)
+ << AL << "cbuffer constant";
+ return;
----------------
hekota wrote:
Both conditions issue the same diagnostic and `BufDecl` does not seem to be used after this. Maybe merge them?
`if (!isa<VarDecl>(D) || !isa<HLSLBufferDecl>(D->getDeclContext()) {`
https://github.com/llvm/llvm-project/pull/89836
More information about the cfe-commits
mailing list