From 0b54602333d4ed0ec7981025a546e6043d6ad74f Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 12 Nov 2025 10:51:33 +0100 Subject: [PATCH 1/2] [rootcling] Remove check for unique_ptr members Since https://github.com/llvm/llvm-project/commit/f5e687d7bf49cd9fe38ba7acdeb52d4f30468dee libc++ implements _LIBCPP_COMPRESSED_PAIR with an anonymous struct (a Clang extension). This results in unique_ptr having a single FieldDecl with an empty name that does not appear as a data member in TClass. Instead, the AST has multiple IndirectFieldDecl's that "refer" into the anonymous struct. In ROOT, we now have two options: We could support anonymous structs, either by allowing data members with empty names or by adding all indirect field declarations as members. However, I would argue that we actually do NOT want to support this extension for IO classes. Instead remove the (questionable) check in rootcling that verifies the number of data members in unique_ptr. (cherry picked from commit fff03d237091f12d9dcf9981e78ccdcfcf3c2558) --- io/rootpcm/src/rootclingIO.cxx | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/io/rootpcm/src/rootclingIO.cxx b/io/rootpcm/src/rootclingIO.cxx index b10b466e18d82..f47afce365d56 100644 --- a/io/rootpcm/src/rootclingIO.cxx +++ b/io/rootpcm/src/rootclingIO.cxx @@ -76,26 +76,6 @@ static bool IsUnsupportedUniquePointer(const char *normName, TDataMember *dm) if (!isUniquePtrOffsetZero) return true; - auto clm = TClass::GetClass(dmTypeName); - if (!clm) { - Error("CloseStreamerInfoROOTFile", "Class %s is not available.", dmTypeName); - return true; - } - - // TODO: Is it not clear what situation we are checking for by checking if - // the unique_ptr class has any data members. - clm->BuildRealData(nullptr, /* istransient = */ true); - auto upDms = clm->GetListOfRealData(); - if (!upDms) { - Error("CloseStreamerInfoROOTFile", "Cannot determine unique pointer %s data members.", dmTypeName); - return true; - } - - if (0 == upDms->GetSize()) { - Error("CloseStreamerInfoROOTFile", "Unique pointer %s has zero data members.", dmTypeName); - return true; - } - // We check if the unique_ptr has a default deleter std::vector out; int i; From ca96566a5ac9c5e147aae42b91f3282a4fea6665 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 12 Nov 2025 10:58:41 +0100 Subject: [PATCH 2/2] [core] Remove dead code in TCling::InspectMembers Since the previous commit, IsUnsupportedUniquePointer does not check the number of data members anymore. (cherry picked from commit a62a650fcc58952df076cd289d1b04b86b00cc43) --- core/metacling/src/TCling.cxx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/core/metacling/src/TCling.cxx b/core/metacling/src/TCling.cxx index f9e8b1f9c1575..30d702fb4c602 100644 --- a/core/metacling/src/TCling.cxx +++ b/core/metacling/src/TCling.cxx @@ -2720,15 +2720,6 @@ void TCling::InspectMembers(TMemberInspector& insp, const void* obj, return; } - if (TClassEdit::IsUniquePtr(cl->GetName())) { - // Ignore error caused by the inside of std::unique_ptr - // This is needed solely because of rootclingIO's IsUnsupportedUniquePointer - // which checks the number of elements in the GetListOfRealData. - // If this usage is removed, this can be replaced with a return statement. - // See https://github.com/root-project/root/issues/13574 - isTransient = true; - } - const char* cobj = (const char*) obj; // for ptr arithmetics // Treat the case of std::complex in a special manner. We want to enforce