Fix some problems with ASTCallbackVH in its use as a DenseMap key.
authorDan Gohman <gohman@apple.com>
Fri, 31 Jul 2009 18:21:48 +0000 (18:21 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 31 Jul 2009 18:21:48 +0000 (18:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77696 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/AliasSetTracker.h
lib/Analysis/AliasSetTracker.cpp

index 99d7ce80e5d9767aad153a989b7aab61e3f6bbb9..1fb4c8f24721e4607d1b1780d733fb9a389302f6 100644 (file)
@@ -259,12 +259,19 @@ class AliasSetTracker {
     virtual void deleted();
   public:
     ASTCallbackVH(Value *V, AliasSetTracker *AST = 0);
+    ASTCallbackVH &operator=(Value *V);
+  };
+  /// ASTCallbackVHDenseMapInfo - Traits to tell DenseMap that ASTCallbackVH
+  /// is not a POD (it needs its destructor called).
+  struct ASTCallbackVHDenseMapInfo : public DenseMapInfo<Value *> {
+    static bool isPod() { return false; }
   };
 
   AliasAnalysis &AA;
   ilist<AliasSet> AliasSets;
 
-  typedef DenseMap<ASTCallbackVH, AliasSet::PointerRec*, DenseMapInfo<Value*> >
+  typedef DenseMap<ASTCallbackVH, AliasSet::PointerRec*,
+                   ASTCallbackVHDenseMapInfo>
     PointerMapType;
 
   // Map from pointers to their node
index 9f201c322df516df43f07d41e0b0b173391a8679..760964c806b9ac5e7bc4d89791a4df4c81679151 100644 (file)
@@ -586,10 +586,12 @@ void AliasSetTracker::ASTCallbackVH::deleted() {
 }
 
 AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast)
-  : CallbackVH(V == DenseMapInfo<Value *>::getEmptyKey() ? 0 :
-               V == DenseMapInfo<Value *>::getTombstoneKey() ? 0 :
-               V),
-    AST(ast) {}
+  : CallbackVH(V), AST(ast) {}
+
+AliasSetTracker::ASTCallbackVH &
+AliasSetTracker::ASTCallbackVH::operator=(Value *V) {
+  return *this = ASTCallbackVH(V, AST);
+}
 
 //===----------------------------------------------------------------------===//
 //                            AliasSetPrinter Pass