@@ -800,9 +800,10 @@ HLSLSemanticAttr *SemaHLSL::createSemantic(const SemanticInfo &Info,
800800 return nullptr ;
801801}
802802
803- bool SemaHLSL::determineActiveSemanticOnScalar (FunctionDecl *FD,
804- DeclaratorDecl *D,
805- SemanticInfo &ActiveSemantic) {
803+ bool SemaHLSL::determineActiveSemanticOnScalar (
804+ FunctionDecl *FD, DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
805+ llvm::StringSet<> &ActiveInputSemantics) {
806+
806807 if (ActiveSemantic.Semantic == nullptr ) {
807808 ActiveSemantic.Semantic = D->getAttr <HLSLSemanticAttr>();
808809 if (ActiveSemantic.Semantic &&
@@ -832,15 +833,7 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
832833 for (unsigned I = 0 ; I < ElementCount; ++I) {
833834 Twine VariableName = BaseName.concat (Twine (Location + I));
834835
835- auto It = ActiveInputSemantics.find (FD);
836- if (It == ActiveInputSemantics.end ()) {
837- llvm::StringSet<> Set ({VariableName.str ()});
838- auto Item = std::make_pair (FD, std::move (Set));
839- ActiveInputSemantics.insert (std::move (Item));
840- continue ;
841- }
842-
843- auto [_, Inserted] = ActiveInputSemantics[FD].insert (VariableName.str ());
836+ auto [_, Inserted] = ActiveInputSemantics.insert (VariableName.str ());
844837 if (!Inserted) {
845838 Diag (D->getLocation (), diag::err_hlsl_semantic_index_overlap)
846839 << VariableName.str ();
@@ -851,8 +844,9 @@ bool SemaHLSL::determineActiveSemanticOnScalar(FunctionDecl *FD,
851844 return true ;
852845}
853846
854- bool SemaHLSL::determineActiveSemantic (FunctionDecl *FD, DeclaratorDecl *D,
855- SemanticInfo &ActiveSemantic) {
847+ bool SemaHLSL::determineActiveSemantic (
848+ FunctionDecl *FD, DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
849+ llvm::StringSet<> &ActiveInputSemantics) {
856850 if (ActiveSemantic.Semantic == nullptr ) {
857851 ActiveSemantic.Semantic = D->getAttr <HLSLSemanticAttr>();
858852 if (ActiveSemantic.Semantic &&
@@ -863,12 +857,13 @@ bool SemaHLSL::determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *D,
863857 const Type *T = D->getType ()->getUnqualifiedDesugaredType ();
864858 const RecordType *RT = dyn_cast<RecordType>(T);
865859 if (!RT)
866- return determineActiveSemanticOnScalar (FD, D, ActiveSemantic);
860+ return determineActiveSemanticOnScalar (FD, D, ActiveSemantic,
861+ ActiveInputSemantics);
867862
868863 const RecordDecl *RD = RT->getDecl ();
869864 for (FieldDecl *Field : RD->fields ()) {
870865 SemanticInfo Info = ActiveSemantic;
871- if (!determineActiveSemantic (FD, Field, Info)) {
866+ if (!determineActiveSemantic (FD, Field, Info, ActiveInputSemantics )) {
872867 Diag (Field->getLocation (), diag::note_hlsl_semantic_used_here) << Field;
873868 return false ;
874869 }
@@ -941,12 +936,14 @@ void SemaHLSL::CheckEntryPoint(FunctionDecl *FD) {
941936 llvm_unreachable (" Unhandled environment in triple" );
942937 }
943938
939+ llvm::StringSet<> ActiveInputSemantics;
944940 for (ParmVarDecl *Param : FD->parameters ()) {
945941 SemanticInfo ActiveSemantic;
946942 ActiveSemantic.Semantic = nullptr ;
947943 ActiveSemantic.Index = std::nullopt ;
948944
949- if (!determineActiveSemantic (FD, Param, ActiveSemantic)) {
945+ if (!determineActiveSemantic (FD, Param, ActiveSemantic,
946+ ActiveInputSemantics)) {
950947 Diag (Param->getLocation (), diag::note_previous_decl) << Param;
951948 FD->setInvalidDecl ();
952949 }
0 commit comments