[clang] [clang-tools-extra] [clang] improve class type sugar preservation in pointers to members (PR #130537)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 10 08:02:31 PDT 2025


================
@@ -5172,8 +5179,28 @@ QualType::DestructionKind QualType::isDestructedTypeImpl(QualType type) {
   return DK_none;
 }
 
+bool MemberPointerType::isSugared() const {
+  CXXRecordDecl *D1 = getMostRecentCXXRecordDecl(),
+                *D2 = getQualifier()->getAsRecordDecl();
+  return D1 != D2 && D1->getCanonicalDecl() != D2->getCanonicalDecl();
----------------
erichkeane wrote:

Should this/could this assert that D1 & D2 are not  null?    Both `getAs` and `getMostRecent` can return null, right?  This should probably be tolerant of this (even if we attempt to not make it the case, we can find ourselves in weird 'situations' after serialization that being tolerant of this is valuable).

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


More information about the cfe-commits mailing list