Skip to content

Commit db0ec31

Browse files
authored
Fix UB in UntypedPtrTyMap (#3283)
SmallDenseMap requires sentinel values out of the `SPIRVStorageClassKind` range. This became a build error after llvm-project commit `38f82534bbe9 ("Reject out-of-bounds enum sentinels in DenseMap/DenseSet. (#150308)", 2025-07-24)`. As the `SPIRVStorageClassKind` enum comes from an external header we cannot change it to an enum class or add an underlying type. This is actually solved in the `spirv.hpp11` header, but migrating to that header requires more widespread changes; just switch to a `std::unordered_map` for now.
1 parent 43a5855 commit db0ec31

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/SPIRV/libSPIRV/SPIRVModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class SPIRVModuleImpl : public SPIRVModule {
637637
SPIRVUnknownStructFieldMap UnknownStructFieldMap;
638638
SPIRVTypeBool *BoolTy;
639639
SPIRVTypeVoid *VoidTy;
640-
SmallDenseMap<SPIRVStorageClassKind, SPIRVTypeUntypedPointerKHR *>
640+
std::unordered_map<SPIRVStorageClassKind, SPIRVTypeUntypedPointerKHR *>
641641
UntypedPtrTyMap;
642642
SmallDenseMap<unsigned, SPIRVTypeInt *, 4> IntTypeMap;
643643
SmallDenseMap<std::pair<unsigned, unsigned>, SPIRVTypeFloat *, 4>

0 commit comments

Comments
 (0)