@@ -801,9 +801,10 @@ HLSLSemanticAttr *SemaHLSL::createSemantic(const SemanticInfo &Info,
801801 return nullptr ;
802802}
803803
804- bool SemaHLSL::determineActiveSemanticOnScalar (FunctionDecl *FD,
805- DeclaratorDecl *D,
806- SemanticInfo &ActiveSemantic) {
804+ bool SemaHLSL::determineActiveSemanticOnScalar (
805+ FunctionDecl *FD, DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
806+ llvm::StringSet<> &ActiveInputSemantics) {
807+
807808 if (ActiveSemantic.Semantic == nullptr ) {
808809 ActiveSemantic.Semantic = D->getAttr <HLSLSemanticAttr>();
809810 if (ActiveSemantic.Semantic &&
@@ -833,15 +834,7 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
833834 for (unsigned I = 0 ; I < ElementCount; ++I) {
834835 Twine VariableName = BaseName.concat (Twine (Location + I));
835836
836- auto It = ActiveInputSemantics.find (FD);
837- if (It == ActiveInputSemantics.end ()) {
838- llvm::StringSet<> Set ({VariableName.str ()});
839- auto Item = std::make_pair (FD, std::move (Set));
840- ActiveInputSemantics.insert (std::move (Item));
841- continue ;
842- }
843-
844- auto [_, Inserted] = ActiveInputSemantics[FD].insert (VariableName.str ());
837+ auto [_, Inserted] = ActiveInputSemantics.insert (VariableName.str ());
845838 if (!Inserted) {
846839 Diag (D->getLocation (), diag::err_hlsl_semantic_index_overlap)
847840 << VariableName.str ();
@@ -852,8 +845,9 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
852845 return true ;
853846}
854847
855- bool SemaHLSL::determineActiveSemantic (FunctionDecl *FD, DeclaratorDecl *D,
856- SemanticInfo &ActiveSemantic) {
848+ bool SemaHLSL::determineActiveSemantic (
849+ FunctionDecl *FD, DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
850+ llvm::StringSet<> &ActiveInputSemantics) {
857851 if (ActiveSemantic.Semantic == nullptr ) {
858852 ActiveSemantic.Semantic = D->getAttr <HLSLSemanticAttr>();
859853 if (ActiveSemantic.Semantic &&
@@ -864,12 +858,13 @@ bool SemaHLSL::determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *D,
864858 const Type *T = D->getType ()->getUnqualifiedDesugaredType ();
865859 const RecordType *RT = dyn_cast<RecordType>(T);
866860 if (!RT)
867- return determineActiveSemanticOnScalar (FD, D, ActiveSemantic);
861+ return determineActiveSemanticOnScalar (FD, D, ActiveSemantic,
862+ ActiveInputSemantics);
868863
869864 const RecordDecl *RD = RT->getDecl ();
870865 for (FieldDecl *Field : RD->fields ()) {
871866 SemanticInfo Info = ActiveSemantic;
872- if (!determineActiveSemantic (FD, Field, Info)) {
867+ if (!determineActiveSemantic (FD, Field, Info, ActiveInputSemantics )) {
873868 Diag (Field->getLocation (), diag::note_hlsl_semantic_used_here) << Field;
874869 return false ;
875870 }
@@ -942,12 +937,14 @@ void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) {
942937 llvm_unreachable (" Unhandled environment in triple" );
943938 }
944939
940+ llvm::StringSet<> ActiveInputSemantics;
945941 for (ParmVarDecl *Param : FD->parameters ()) {
946942 SemanticInfo ActiveSemantic;
947943 ActiveSemantic.Semantic = nullptr ;
948944 ActiveSemantic.Index = std::nullopt ;
949945
950- if (!determineActiveSemantic (FD, Param, ActiveSemantic)) {
946+ if (!determineActiveSemantic (FD, Param, ActiveSemantic,
947+ ActiveInputSemantics)) {
951948 Diag (Param->getLocation (), diag::note_previous_decl) << Param;
952949 FD->setInvalidDecl ();
953950 }
0 commit comments