Fixed buggy caching of the hash value of an ImutAVLTree node.
authorTed Kremenek <kremenek@apple.com>
Mon, 21 Jan 2008 22:54:46 +0000 (22:54 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 21 Jan 2008 22:54:46 +0000 (22:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46229 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ImmutableSet.h

index 11724603647e855ae4ff129043261e56a49cd0fe..9f08b038fc69ea77585d8eedb1784a0deec69b62 100644 (file)
@@ -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