From a818c30d664cd4ba4b9ed69fb2048a6ea55ec9cd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 31 Jul 2009 18:21:48 +0000 Subject: [PATCH] Fix some problems with ASTCallbackVH in its use as a DenseMap key. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77696 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AliasSetTracker.h | 9 ++++++++- lib/Analysis/AliasSetTracker.cpp | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 99d7ce80e5d..1fb4c8f2472 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -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 { + static bool isPod() { return false; } }; AliasAnalysis &AA; ilist AliasSets; - typedef DenseMap > + typedef DenseMap PointerMapType; // Map from pointers to their node diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 9f201c322df..760964c806b 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -586,10 +586,12 @@ void AliasSetTracker::ASTCallbackVH::deleted() { } AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast) - : CallbackVH(V == DenseMapInfo::getEmptyKey() ? 0 : - V == DenseMapInfo::getTombstoneKey() ? 0 : - V), - AST(ast) {} + : CallbackVH(V), AST(ast) {} + +AliasSetTracker::ASTCallbackVH & +AliasSetTracker::ASTCallbackVH::operator=(Value *V) { + return *this = ASTCallbackVH(V, AST); +} //===----------------------------------------------------------------------===// // AliasSetPrinter Pass