@@ -1086,10 +1086,6 @@ bool SemaHLSL::handleRootSignatureElements(
1086
1086
using RangeInfo = llvm::hlsl::rootsig::RangeInfo;
1087
1087
using OverlappingRanges = llvm::hlsl::rootsig::OverlappingRanges;
1088
1088
1089
- // Each RangeInfo will contain an index back to its associated
1090
- // RootSignatureElement in our Elements ArrayRef
1091
- size_t InfoIndex = 0 ;
1092
-
1093
1089
// 1. Collect RangeInfos
1094
1090
llvm::SmallVector<RangeInfo> Infos;
1095
1091
for (const hlsl::RootSignatureElement &RootSigElem : Elements) {
@@ -1105,7 +1101,7 @@ bool SemaHLSL::handleRootSignatureElements(
1105
1101
Info.Space = Descriptor->Space ;
1106
1102
Info.Visibility = Descriptor->Visibility ;
1107
1103
1108
- Info.Index = InfoIndex ;
1104
+ Info.Cookie = static_cast < void *>(&RootSigElem) ;
1109
1105
Infos.push_back (Info);
1110
1106
} else if (const auto *Constants =
1111
1107
std::get_if<llvm::hlsl::rootsig::RootConstants>(&Elem)) {
@@ -1117,7 +1113,7 @@ bool SemaHLSL::handleRootSignatureElements(
1117
1113
Info.Space = Constants->Space ;
1118
1114
Info.Visibility = Constants->Visibility ;
1119
1115
1120
- Info.Index = InfoIndex ;
1116
+ Info.Cookie = static_cast < void *>(&RootSigElem) ;
1121
1117
Infos.push_back (Info);
1122
1118
} else if (const auto *Sampler =
1123
1119
std::get_if<llvm::hlsl::rootsig::StaticSampler>(&Elem)) {
@@ -1129,7 +1125,7 @@ bool SemaHLSL::handleRootSignatureElements(
1129
1125
Info.Space = Sampler->Space ;
1130
1126
Info.Visibility = Sampler->Visibility ;
1131
1127
1132
- Info.Index = InfoIndex ;
1128
+ Info.Cookie = static_cast < void *>(&RootSigElem) ;
1133
1129
Infos.push_back (Info);
1134
1130
} else if (const auto *Clause =
1135
1131
std::get_if<llvm::hlsl::rootsig::DescriptorTableClause>(
@@ -1146,7 +1142,7 @@ bool SemaHLSL::handleRootSignatureElements(
1146
1142
Info.Space = Clause->Space ;
1147
1143
1148
1144
// Note: Clause does not hold the visibility this will need to
1149
- Info.Index = InfoIndex ;
1145
+ Info.Cookie = static_cast < void *>(&RootSigElem) ;
1150
1146
Infos.push_back (Info);
1151
1147
} else if (const auto *Table =
1152
1148
std::get_if<llvm::hlsl::rootsig::DescriptorTable>(&Elem)) {
@@ -1160,28 +1156,26 @@ bool SemaHLSL::handleRootSignatureElements(
1160
1156
for (RangeInfo &Info : TableInfos)
1161
1157
Info.Visibility = Table->Visibility ;
1162
1158
}
1163
-
1164
- InfoIndex++;
1165
1159
}
1166
1160
1167
1161
// Helper to report diagnostics
1168
- auto ReportOverlap = [this , &Elements ](OverlappingRanges Overlap) {
1162
+ auto ReportOverlap = [this ](OverlappingRanges Overlap) {
1169
1163
const RangeInfo *Info = Overlap.A ;
1170
1164
const RangeInfo *OInfo = Overlap.B ;
1171
1165
auto CommonVis = Info->Visibility == llvm::dxbc::ShaderVisibility::All
1172
1166
? OInfo->Visibility
1173
1167
: Info->Visibility ;
1174
- SourceLocation InfoLoc = Elements[ Info->Index ]. getLocation ( );
1175
- this ->Diag (InfoLoc , diag::err_hlsl_resource_range_overlap)
1168
+ auto Elem = static_cast < const hlsl::RootSignatureElement *>( Info->Cookie );
1169
+ this ->Diag (Elem-> getLocation () , diag::err_hlsl_resource_range_overlap)
1176
1170
<< llvm::to_underlying (Info->Class ) << Info->LowerBound
1177
1171
<< /* unbounded=*/ (Info->UpperBound == RangeInfo::Unbounded)
1178
1172
<< Info->UpperBound << llvm::to_underlying (OInfo->Class )
1179
1173
<< OInfo->LowerBound
1180
1174
<< /* unbounded=*/ (OInfo->UpperBound == RangeInfo::Unbounded)
1181
1175
<< OInfo->UpperBound << Info->Space << CommonVis;
1182
1176
1183
- SourceLocation OInfoLoc = Elements[ OInfo->Index ]. getLocation ( );
1184
- this ->Diag (OInfoLoc , diag::note_hlsl_resource_range_here);
1177
+ auto OElem = static_cast < const hlsl::RootSignatureElement *>( OInfo->Cookie );
1178
+ this ->Diag (OElem-> getLocation () , diag::note_hlsl_resource_range_here);
1185
1179
};
1186
1180
1187
1181
llvm::SmallVector<OverlappingRanges> Overlaps =
0 commit comments