mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-03 11:24:18 +00:00
Fix UBSan error reports in ValueMapCallbackVH and AssertingVH<T> empty/tombstone keys generation.
Summary: One more attempt to fix UBSan reports: make sure DenseMapInfo::getEmptyKey() and DenseMapInfo::getTombstoneKey() doesn't do any upcasts/downcasts to/from Value*. Test Plan: check-llvm test suite with/without UBSan bootstrap Reviewers: chandlerc, dexonsmith Subscribers: llvm-commits, majnemer Differential Revision: http://reviews.llvm.org/D6903 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225558 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -224,6 +224,9 @@ class ValueMapCallbackVH : public CallbackVH {
|
||||
: CallbackVH(const_cast<Value*>(static_cast<const Value*>(Key))),
|
||||
Map(Map) {}
|
||||
|
||||
// Private constructor used to create empty/tombstone DenseMap keys.
|
||||
ValueMapCallbackVH(Value *V) : CallbackVH(V), Map(nullptr) {}
|
||||
|
||||
public:
|
||||
KeyT Unwrap() const { return cast_or_null<KeySansPointerT>(getValPtr()); }
|
||||
|
||||
@ -266,19 +269,18 @@ public:
|
||||
template<typename KeyT, typename ValueT, typename Config>
|
||||
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config> > {
|
||||
typedef ValueMapCallbackVH<KeyT, ValueT, Config> VH;
|
||||
typedef DenseMapInfo<KeyT> PointerInfo;
|
||||
|
||||
static inline VH getEmptyKey() {
|
||||
return VH(PointerInfo::getEmptyKey(), nullptr);
|
||||
return VH(DenseMapInfo<Value *>::getEmptyKey());
|
||||
}
|
||||
static inline VH getTombstoneKey() {
|
||||
return VH(PointerInfo::getTombstoneKey(), nullptr);
|
||||
return VH(DenseMapInfo<Value *>::getTombstoneKey());
|
||||
}
|
||||
static unsigned getHashValue(const VH &Val) {
|
||||
return PointerInfo::getHashValue(Val.Unwrap());
|
||||
return DenseMapInfo<KeyT>::getHashValue(Val.Unwrap());
|
||||
}
|
||||
static unsigned getHashValue(const KeyT &Val) {
|
||||
return PointerInfo::getHashValue(Val);
|
||||
return DenseMapInfo<KeyT>::getHashValue(Val);
|
||||
}
|
||||
static bool isEqual(const VH &LHS, const VH &RHS) {
|
||||
return LHS == RHS;
|
||||
|
Reference in New Issue
Block a user