@@ -769,22 +769,25 @@ void SemaHLSL::ActOnTopLevelFunction(FunctionDecl *FD) {
769
769
}
770
770
}
771
771
772
- HLSLSemanticAttr *SemaHLSL::createSemantic (const SemanticInfo &Info) {
772
+ HLSLSemanticAttr *SemaHLSL::createSemantic (const SemanticInfo &Info,
773
+ Decl *TargetDecl) {
773
774
std::string SemanticName = Info.Semantic ->getAttrName ()->getName ().upper ();
774
775
775
776
if (SemanticName == " SV_DISPATCHTHREADID" ) {
776
- return createSemanticAttr<HLSLSV_DispatchThreadIDAttr>(*Info. Semantic ,
777
- Info.Index );
777
+ return createSemanticAttr<HLSLSV_DispatchThreadIDAttr>(
778
+ *Info. Semantic , TargetDecl, Info.Index );
778
779
} else if (SemanticName == " SV_GROUPINDEX" ) {
779
- return createSemanticAttr<HLSLSV_GroupIndexAttr>(*Info.Semantic ,
780
+ return createSemanticAttr<HLSLSV_GroupIndexAttr>(*Info.Semantic , TargetDecl,
780
781
Info.Index );
781
782
} else if (SemanticName == " SV_GROUPTHREADID" ) {
782
783
return createSemanticAttr<HLSLSV_GroupThreadIDAttr>(*Info.Semantic ,
783
- Info.Index );
784
+ TargetDecl, Info.Index );
784
785
} else if (SemanticName == " SV_GROUPID" ) {
785
- return createSemanticAttr<HLSLSV_GroupIDAttr>(*Info.Semantic , Info.Index );
786
+ return createSemanticAttr<HLSLSV_GroupIDAttr>(*Info.Semantic , TargetDecl,
787
+ Info.Index );
786
788
} else if (SemanticName == " SV_POSITION" ) {
787
- return createSemanticAttr<HLSLSV_PositionAttr>(*Info.Semantic , Info.Index );
789
+ return createSemanticAttr<HLSLSV_PositionAttr>(*Info.Semantic , TargetDecl,
790
+ Info.Index );
788
791
} else
789
792
Diag (Info.Semantic ->getLoc (), diag::err_hlsl_unknown_semantic)
790
793
<< *Info.Semantic ;
@@ -806,13 +809,12 @@ bool SemaHLSL::isSemanticOnScalarValid(FunctionDecl *FD, DeclaratorDecl *D,
806
809
return false ;
807
810
}
808
811
809
- auto *A = createSemantic (ActiveSemantic);
812
+ auto *A = createSemantic (ActiveSemantic, D );
810
813
if (!A)
811
814
return false ;
812
815
813
816
checkSemanticAnnotation (FD, D, A);
814
- D->dropAttrs <HLSLSemanticAttr>();
815
- D->addAttr (A);
817
+ FD->addAttr (A);
816
818
return true ;
817
819
}
818
820
@@ -1702,28 +1704,30 @@ void SemaHLSL::diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL,
1702
1704
diagnoseInputIDType (ValueType, AL);
1703
1705
if (IsOutput)
1704
1706
Diag (AL.getLoc (), diag::err_hlsl_semantic_output_not_supported) << AL;
1705
- Attribute = createSemanticAttr<HLSLSV_DispatchThreadIDAttr>(AL, Index);
1707
+ Attribute =
1708
+ createSemanticAttr<HLSLSV_DispatchThreadIDAttr>(AL, nullptr , Index);
1706
1709
} else if (SemanticName == " SV_GROUPINDEX" ) {
1707
1710
if (IsOutput)
1708
1711
Diag (AL.getLoc (), diag::err_hlsl_semantic_output_not_supported) << AL;
1709
- Attribute = createSemanticAttr<HLSLSV_GroupIndexAttr>(AL, Index);
1712
+ Attribute = createSemanticAttr<HLSLSV_GroupIndexAttr>(AL, nullptr , Index);
1710
1713
} else if (SemanticName == " SV_GROUPTHREADID" ) {
1711
1714
diagnoseInputIDType (ValueType, AL);
1712
1715
if (IsOutput)
1713
1716
Diag (AL.getLoc (), diag::err_hlsl_semantic_output_not_supported) << AL;
1714
- Attribute = createSemanticAttr<HLSLSV_GroupThreadIDAttr>(AL, Index);
1717
+ Attribute =
1718
+ createSemanticAttr<HLSLSV_GroupThreadIDAttr>(AL, nullptr , Index);
1715
1719
} else if (SemanticName == " SV_GROUPID" ) {
1716
1720
diagnoseInputIDType (ValueType, AL);
1717
1721
if (IsOutput)
1718
1722
Diag (AL.getLoc (), diag::err_hlsl_semantic_output_not_supported) << AL;
1719
- Attribute = createSemanticAttr<HLSLSV_GroupIDAttr>(AL, Index);
1723
+ Attribute = createSemanticAttr<HLSLSV_GroupIDAttr>(AL, nullptr , Index);
1720
1724
} else if (SemanticName == " SV_POSITION" ) {
1721
1725
const auto *VT = ValueType->getAs <VectorType>();
1722
1726
if (!ValueType->hasFloatingRepresentation () ||
1723
1727
(VT && VT->getNumElements () > 4 ))
1724
1728
Diag (AL.getLoc (), diag::err_hlsl_attr_invalid_type)
1725
1729
<< AL << " float/float1/float2/float3/float4" ;
1726
- Attribute = createSemanticAttr<HLSLSV_PositionAttr>(AL, Index);
1730
+ Attribute = createSemanticAttr<HLSLSV_PositionAttr>(AL, nullptr , Index);
1727
1731
} else
1728
1732
Diag (AL.getLoc (), diag::err_hlsl_unknown_semantic) << AL;
1729
1733
0 commit comments