[PATCH] Fix UBSan error reports in ValueMapCallbackVH and AssertingVH<T> empty/tombstone keys generation.

Chandler Carruth chandlerc at gmail.com
Fri Jan 9 13:02:45 PST 2015


================
Comment at: include/llvm/IR/ValueHandle.h:239-248
@@ -239,4 +238,12 @@
 struct DenseMapInfo<AssertingVH<T> > {
   typedef DenseMapInfo<T*> PointerInfo;
   static inline AssertingVH<T> getEmptyKey() {
-    return AssertingVH<T>(PointerInfo::getEmptyKey());
+    AssertingVH<T> Res;
+    Value *V = const_cast<Value *>(
+        reinterpret_cast<const Value *>(PointerInfo::getEmptyKey()));
+#ifndef NDEBUG
+    Res.ValueHandleBase::operator=(V);
+#else
+    Res.ThePtr = V;
+#endif
+    return Res;
----------------
I think you need to use DenseMapInfo<Value *> here?

http://reviews.llvm.org/D6903

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list