@@ -769,22 +769,25 @@ void SemaHLSL::ActOnTopLevelFunction(FunctionDecl *FD) {
769769 }
770770}
771771
772- HLSLSemanticAttr *SemaHLSL::createSemantic (const SemanticInfo &Info) {
772+ HLSLSemanticAttr *SemaHLSL::createSemantic (const SemanticInfo &Info,
773+ Decl *TargetDecl) {
773774 std::string SemanticName = Info.Semantic ->getAttrName ()->getName ().upper ();
774775
775776 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 );
778779 } else if (SemanticName == " SV_GROUPINDEX" ) {
779- return createSemanticAttr<HLSLSV_GroupIndexAttr>(*Info.Semantic ,
780+ return createSemanticAttr<HLSLSV_GroupIndexAttr>(*Info.Semantic , TargetDecl,
780781 Info.Index );
781782 } else if (SemanticName == " SV_GROUPTHREADID" ) {
782783 return createSemanticAttr<HLSLSV_GroupThreadIDAttr>(*Info.Semantic ,
783- Info.Index );
784+ TargetDecl, Info.Index );
784785 } 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 );
786788 } 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 );
788791 } else
789792 Diag (Info.Semantic ->getLoc (), diag::err_hlsl_unknown_semantic)
790793 << *Info.Semantic ;
@@ -806,13 +809,12 @@ bool SemaHLSL::isSemanticOnScalarValid(FunctionDecl *FD, DeclaratorDecl *D,
806809 return false ;
807810 }
808811
809- auto *A = createSemantic (ActiveSemantic);
812+ auto *A = createSemantic (ActiveSemantic, D );
810813 if (!A)
811814 return false ;
812815
813816 checkSemanticAnnotation (FD, D, A);
814- D->dropAttrs <HLSLSemanticAttr>();
815- D->addAttr (A);
817+ FD->addAttr (A);
816818 return true ;
817819}
818820
@@ -1702,28 +1704,30 @@ void SemaHLSL::diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL,
17021704 diagnoseInputIDType (ValueType, AL);
17031705 if (IsOutput)
17041706 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);
17061709 } else if (SemanticName == " SV_GROUPINDEX" ) {
17071710 if (IsOutput)
17081711 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);
17101713 } else if (SemanticName == " SV_GROUPTHREADID" ) {
17111714 diagnoseInputIDType (ValueType, AL);
17121715 if (IsOutput)
17131716 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);
17151719 } else if (SemanticName == " SV_GROUPID" ) {
17161720 diagnoseInputIDType (ValueType, AL);
17171721 if (IsOutput)
17181722 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);
17201724 } else if (SemanticName == " SV_POSITION" ) {
17211725 const auto *VT = ValueType->getAs <VectorType>();
17221726 if (!ValueType->hasFloatingRepresentation () ||
17231727 (VT && VT->getNumElements () > 4 ))
17241728 Diag (AL.getLoc (), diag::err_hlsl_attr_invalid_type)
17251729 << AL << " float/float1/float2/float3/float4" ;
1726- Attribute = createSemanticAttr<HLSLSV_PositionAttr>(AL, Index);
1730+ Attribute = createSemanticAttr<HLSLSV_PositionAttr>(AL, nullptr , Index);
17271731 } else
17281732 Diag (AL.getLoc (), diag::err_hlsl_unknown_semantic) << AL;
17291733
0 commit comments