Skip to content

[metacling] Instantiate empty parameter packs#21292

Draft
hahnjo wants to merge 4 commits intoroot-project:masterfrom
hahnjo:tuple-variadic
Draft

[metacling] Instantiate empty parameter packs#21292
hahnjo wants to merge 4 commits intoroot-project:masterfrom
hahnjo:tuple-variadic

Conversation

@hahnjo
Copy link
Member

@hahnjo hahnjo commented Feb 16, 2026

This effectively reverts the change of commit 4b00923. It is needed for working conversion with variadic templates from cppyy.

TClassEdit::TSplitType will have an empty string for an empty template
parameter list.
This makes it possible to instantiate an empty RLazyDS.
This effectively reverts the change of commit 4b00923.
This was "fixed" by the previous commit enabling the default
instantiation of template parameter packs.
@github-actions
Copy link

github-actions bot commented Feb 16, 2026

Test Results

    19 files      19 suites   2d 16h 23m 0s ⏱️
 3 769 tests  3 337 ✅   0 💤   432 ❌
64 755 runs  63 178 ✅ 113 💤 1 464 ❌

For more details on these failures, see this check.

Results for commit 75f513d.

♻️ This comment has been updated with latest results.

Copy link
Member

@dpiparo dpiparo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the RDF part.

@hahnjo
Copy link
Member Author

hahnjo commented Feb 17, 2026

So this doesn't work on macOS, mostly because of std::variant related function templates where it actually fails to instantiate with the empty parameter pack. As a short-term workaround, it would be possible to only instantiate parameter packs when it's not the first parameter:

diff --git a/core/metacling/src/TClingMethodInfo.cxx b/core/metacling/src/TClingMethodInfo.cxx
index bb458163f70..692725d75c0 100644
--- a/core/metacling/src/TClingMethodInfo.cxx
+++ b/core/metacling/src/TClingMethodInfo.cxx
@@ -161,6 +161,9 @@ TClingCXXRecMethIter::InstantiateTemplateWithDefaults(const clang::RedeclarableT                                                                                                   
    llvm::SmallVector<TemplateArgument, 8> defaultTemplateArgs;
    for (const NamedDecl *templateParm: *templateParms) {
       if (templateParm->isTemplateParameterPack()) {
+         if (defaultTemplateArgs.size() == 0) {
+            return nullptr;
+         }
          defaultTemplateArgs.emplace_back(ArrayRef<TemplateArgument>{}); // empty pack.
       } else if (auto TTP = dyn_cast<TemplateTypeParmDecl>(templateParm)) {
          if (!TTP->hasDefaultArgument())

That would be get me what I need for the histograms, but potentially confusing why other member templates are not instantiated. Opinions?

@hahnjo hahnjo marked this pull request as draft February 17, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments