Skip to content

Commit 5b3b7ce

Browse files
committed
Fix debug field names for vectors > 4 elements
1 parent 615824d commit 5b3b7ce

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tools/clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,8 +1047,15 @@ bool CGDebugInfo::TryCollectHLSLRecordElements(const RecordType *Ty,
10471047
unsigned VecSize = hlsl::GetHLSLVecSize(QualTy);
10481048
unsigned ElemSizeInBits = CGM.getContext().getTypeSize(ElemQualTy);
10491049
unsigned CurrentAlignedOffset = 0;
1050+
std::string FieldNameBuf;
10501051
for (unsigned ElemIdx = 0; ElemIdx < VecSize; ++ElemIdx) {
1051-
StringRef FieldName = StringRef(&"xyzw"[ElemIdx], 1);
1052+
StringRef FieldName;
1053+
if (VecSize <= 4) {
1054+
FieldName = StringRef(&"xyzw"[ElemIdx], 1);
1055+
} else {
1056+
FieldNameBuf = "c" + std::to_string(ElemIdx);
1057+
FieldName = FieldNameBuf;
1058+
}
10521059
CurrentAlignedOffset =
10531060
llvm::RoundUpToAlignment(CurrentAlignedOffset, AlignBits);
10541061
llvm::DIType *FieldType =

0 commit comments

Comments
 (0)