Skip to content

Commit fa20c2a

Browse files
committed
Address comments
1 parent 86e125a commit fa20c2a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,16 +613,14 @@ BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addHandleMember(
613613
ResourceClass RC, bool IsROV, bool RawBuffer, AccessSpecifier Access) {
614614
assert(!Record->isCompleteDefinition() && "record is already complete");
615615

616-
ResClass = RC;
617-
618616
ASTContext &Ctx = SemaRef.getASTContext();
619617
TypeSourceInfo *ElementTypeInfo =
620618
Ctx.getTrivialTypeSourceInfo(getHandleElementType(), SourceLocation());
621619

622620
// add handle member with resource type attributes
623621
QualType AttributedResTy = QualType();
624622
SmallVector<const Attr *> Attrs = {
625-
HLSLResourceClassAttr::CreateImplicit(Ctx, ResClass),
623+
HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
626624
IsROV ? HLSLROVAttr::CreateImplicit(Ctx) : nullptr,
627625
RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) : nullptr,
628626
ElementTypeInfo
@@ -699,7 +697,7 @@ BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addArraySubscriptOperators() {
699697
AST.DeclarationNames.getCXXOperatorName(OO_Subscript);
700698

701699
addHandleAccessFunction(Subscript, /*IsConst=*/true, /*IsRef=*/true);
702-
if (ResClass == llvm::dxil::ResourceClass::UAV)
700+
if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
703701
addHandleAccessFunction(Subscript, /*IsConst=*/false, /*IsRef=*/true);
704702

705703
return *this;
@@ -742,6 +740,12 @@ QualType BuiltinTypeDeclBuilder::getHandleElementType() {
742740
return SemaRef.getASTContext().Char8Ty;
743741
}
744742

743+
HLSLAttributedResourceType::Attributes
744+
BuiltinTypeDeclBuilder::getResourceAttrs() {
745+
QualType HandleType = getResourceHandleField()->getType();
746+
return cast<HLSLAttributedResourceType>(HandleType)->getAttrs();
747+
}
748+
745749
// BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::startDefinition() {
746750
// assert(!Record->isCompleteDefinition() && "record is already complete");
747751
// Record->startDefinition();

clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class BuiltinTypeDeclBuilder {
5252
ClassTemplateDecl *PrevTemplate = nullptr;
5353
NamespaceDecl *HLSLNamespace = nullptr;
5454
llvm::StringMap<FieldDecl *> Fields;
55-
ResourceClass ResClass;
5655

5756
public:
5857
friend struct TemplateParameterListBuilder;
@@ -96,6 +95,7 @@ class BuiltinTypeDeclBuilder {
9695
QualType getFirstTemplateTypeParam();
9796
QualType getHandleElementType();
9897
Expr *getConstantIntExpr(int value);
98+
HLSLAttributedResourceType::Attributes getResourceAttrs();
9999
};
100100

101101
} // namespace hlsl

0 commit comments

Comments
 (0)