Skip to content

Commit a6d1fd1

Browse files
committed
work around to resolve lambda variables
1 parent 8f44d69 commit a6d1fd1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cling/src/core/metacling/src/TClingDataMemberInfo.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,21 @@ const char *TClingDataMemberInfo::TypeName() const
642642
vdType = CppyyLegacy::TMetaUtils::ReSubstTemplateArg(vdType, fClassInfo->GetType() );
643643

644644
CppyyLegacy::TMetaUtils::GetFullyQualifiedTypeName(buf, vdType, *fInterp);
645+
if (buf.find("(lambda)") != std::string::npos) {
646+
// TODO: this is a special case that works in conjunction with the support
647+
// for lambda variables. As of LLVM16, template instantiations of scopes with
648+
// decltype of a lambda functions will print "(lambda)" as the template arg,
649+
// instead of an implicit function ptr type. This makes the scope name unusable.
650+
// For the relevant use case, however, the scope isn't relevant: only the actual
651+
// type of the data member represented here is. Hence, taking the canonical type
652+
// is fine (the by-passed typedef isn't used). This need not be generally true,
653+
// but it's a niche case to begin with and the scoped type isn't going to be
654+
// usuable as-is. Further, as of C++17, classes can be implicitly instantiated
655+
// meaning that an `std::function` can be used as a workaround to get at a
656+
// workable type of a lambda.
657+
buf.clear();
658+
CppyyLegacy::TMetaUtils::GetFullyQualifiedTypeName(buf, vdType.getCanonicalType(), *fInterp);
659+
}
645660

646661
return buf.c_str();
647662
}

0 commit comments

Comments
 (0)