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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 30 06:39:43 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());
----------------
erichkeane wrote:

Is the problem that we run this profile in the 'middle' of a TU and the most recent decl changes by the end?  If so, this makes sense.

That said, I'd expect this to be the above suggestion in case this member pointer type has a redeclaration that perhaps changes what the actual referenced decl is.

```suggestion
    Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl()->getCanonicalDecl());
```

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


More information about the cfe-commits mailing list