forked from OSchip/llvm-project
[LiveDebugValues] Prevent some misuse of LocIndex::fromRawInteger, NFC
Make it a compile-time error to pass an int/unsigned/etc to fromRawInteger. Hopefully this prevents errors of the form: ``` for (unsigned ID : getVarLocs()) { auto VL = LocMap[LocIndex::fromRawInteger(ID)]; ... ```
This commit is contained in:
parent
29a4239d31
commit
d64a22a2ad
|
@ -138,7 +138,10 @@ struct LocIndex {
|
|||
return (static_cast<uint64_t>(Location) << 32) | Index;
|
||||
}
|
||||
|
||||
static LocIndex fromRawInteger(uint64_t ID) {
|
||||
template<typename IntT> static LocIndex fromRawInteger(IntT ID) {
|
||||
static_assert(std::is_unsigned<IntT>::value &&
|
||||
sizeof(ID) == sizeof(uint64_t),
|
||||
"Cannot convert raw integer to LocIndex");
|
||||
return {static_cast<uint32_t>(ID >> 32), static_cast<uint32_t>(ID)};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue