[Sema] Add and test new Subobject Attribute#7258
Conversation
| RecordDecl *RD = RT->getDecl(); | ||
| if (!RD->hasAttr<HLSLSubObjectAttr>()) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Given that you've added the attribute now, it would be pretty easy to avoid the string compares by adding a parameter to it containing an integer representation of the Subobjectkind similar to how HLSLResourceAttr does. The callers of CreateSubobjectStateObjectConfig and friends that call StartSubObjectDecl have the AR_OBJECT enums, which indicate which DXIL:SubobjectKind they need. It would be pretty easy to plumb it down and apply it to the attr.
| static CXXRecordDecl *StartSubobjectDecl(ASTContext &context, | ||
| const char *name) { | ||
| static CXXRecordDecl *StartSubobjectDecl(ASTContext &context, const char *name, | ||
| ArBasicKind kind) { |
There was a problem hiding this comment.
I'm afraid this isn't quite what I had in mind. If you pass in the correct DXIL::SubobjectKind type into StartsSubObjectDecl even if you have to cast it to a uint from:
CreateSubobjectStateObjectConfigCreateSubobjectRootSignatureCreateSubobjectSubobjectToExportsSassocCreateSubobjectRaytracingShaderConfigCreateSubobjectRaytracingShaderConfig1CreateSubobjectTriangleHitGroupCreateSubobjectProceuralPrimitiveHitGroup
I think each of these know what SubobjectKind they're going to require, so there's no need to let the AR_OBJECT types escape SemaHLSL.cpp.
| return false; | ||
| HLSLSubObjectAttr *Attr = RD->getAttr<HLSLSubObjectAttr>(); | ||
|
|
||
| switch (Attr->getSubObjKindUint()) { |
There was a problem hiding this comment.
Just to make sure of clarity here. I expected the argument to be the DXIL::SubobjectKind enum rather than the AR_OBJECTs which wouldn't require any conversion here apart from casting it back to the enum type.
pow2clk
left a comment
There was a problem hiding this comment.
Thanks for indulging me!
This PR adds and tests a new subobject attribute. It will be useful for checking if a given decl is a subobject decl. This functionality will be used in #7239
We need an attribute in order to determine whether to check its initializer for availability attributes or not.
Fixes #7257