[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 04:35:19 PDT 2025


================
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-    Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl());
+    Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl());
----------------
ilya-biryukov wrote:

> Hmm... then I'm surprised that this patch is needed at all for the purposes of non-determinism

My theory is that non-determinism is caused by side-effects in the deserialization logic that runs behind `getMostRecentCXXRecordDecl()`. We probably just get unlucky with rehashing points at different times for the hash table (`FoldingSet`) that makes us either call or not call `getMostRecentCXXRecordDecl`.

It is not a new issue, just rare and now getting surfaced by the new place where `getMostRecentCXXRecordDecl` is called.

https://github.com/llvm/llvm-project/pull/137910


More information about the cfe-commits mailing list