From a7287785ad0fbc4c18f1205fa085099669519364 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 21 Jan 2008 22:54:46 +0000 Subject: [PATCH] Fixed buggy caching of the hash value of an ImutAVLTree node. llvm-svn: 46229 --- llvm/include/llvm/ADT/ImmutableSet.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h index 11724603647e..9f08b038fc69 100644 --- a/llvm/include/llvm/ADT/ImmutableSet.h +++ b/llvm/include/llvm/ADT/ImmutableSet.h @@ -231,9 +231,12 @@ private: } inline unsigned ComputeHash() { - if (!isMutable() && Hash) return Hash; - Hash = ComputeHash(getSafeLeft(), getRight(), getValue()); - return Hash; + if (Hash) return Hash; + + unsigned X = ComputeHash(getSafeLeft(), getRight(), getValue()); + if (!isMutable()) Hash = X; + + return X; } /// Profile - Generates a FoldingSet profile for a tree node before it is