-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[cling] Update policy for GetFullyQualifiedName in cling utils
#19292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
GetFullyQualifiedName in cling utils
Just like in CppInterOp, set the `SuppressElaboration` and `FullyQualifiedName` policies when getting the fully qualified name of a QualType. Closes the following JIRA ticket: https://its.cern.ch/jira/browse/ROOT-10150
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // reproducer from https://its.cern.ch/jira/browse/ROOT-10150 | ||
|
|
||
| #include <TInterpreter.h> | ||
| #include <functional> | ||
| #include <iostream> | ||
|
|
||
| namespace Foo { | ||
| struct Particle { | ||
| float m_pt; | ||
| float pt() const { return m_pt; } | ||
| }; | ||
| } // namespace Foo | ||
|
|
||
| template <typename FType> | ||
| FType get_functor(std::string const &functor_string) | ||
| { | ||
| auto intern = gInterpreter->MakeInterpreterValue(); | ||
| gInterpreter->Evaluate(functor_string.c_str(), *intern); | ||
| return *static_cast<FType *>(intern->GetAsPointer()); | ||
| } | ||
|
|
||
| void reproduceROOT10150() | ||
| { | ||
| auto functor = get_functor<std::function<bool(Foo::Particle const &)>>( | ||
| "std::function<bool(Foo::Particle const&)>( [](Foo::Particle const& particle){return particle.pt() > 15;} );"); | ||
| Foo::Particle low_pT_particle{1.f}, high_pT_particle{40.f}; | ||
| std::cout << functor(high_pT_particle) << " " << functor(low_pT_particle) << std::endl; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,13 +216,13 @@ TEST(RNTuple, TypeNameTemplatesNestedAlias) | |
| ASSERT_EQ(2, hashSubfields.size()); | ||
| EXPECT_EQ("fHash", hashSubfields[0]->GetFieldName()); | ||
| EXPECT_EQ("std::string", hashSubfields[0]->GetTypeName()); | ||
| EXPECT_EQ("EdmHash<1>::value_type", hashSubfields[0]->GetTypeAlias()); | ||
| EXPECT_EQ("EdmHash::value_type", hashSubfields[0]->GetTypeAlias()); | ||
|
|
||
| EXPECT_EQ("fHash2", hashSubfields[1]->GetFieldName()); | ||
| EXPECT_EQ("std::string", hashSubfields[1]->GetTypeName()); | ||
| // FIXME: This should really be EdmHash<1>::value_typeT<EdmHash<1>::value_type>, but this is the value we get from | ||
| // TDataMember::GetFullTypeName right now... | ||
| EXPECT_EQ("value_typeT<EdmHash<1>::value_type>", hashSubfields[1]->GetTypeAlias()); | ||
| EXPECT_EQ("EdmHash::value_typeT<EdmHash::value_type>", hashSubfields[1]->GetTypeAlias()); | ||
|
Comment on lines
223
to
+225
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is equally wrong, the expected outcome is even documented in the comment. |
||
| } | ||
|
|
||
| TEST(RNTuple, ContextDependentTypeNames) | ||
|
|
@@ -257,7 +257,7 @@ TEST(RNTuple, ContextDependentTypeNames) | |
| { | ||
| const auto &fdesc = desc.GetFieldDescriptor(desc.FindFieldId("m", fooId)); | ||
| EXPECT_EQ(fdesc.GetTypeName(), "std::vector<std::int32_t>"); | ||
| EXPECT_EQ(fdesc.GetTypeAlias(), "MyVec<std::int32_t>"); | ||
| EXPECT_EQ(fdesc.GetTypeAlias(), "CustomStruct::MyVec<std::int32_t>"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old version may be correct, depending on how you argue: it's the type alias as the user wrote it, inside of |
||
| } | ||
| { | ||
| const auto &fdesc = desc.GetFieldDescriptor(desc.FindFieldId("a", baseId)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is incorrect:
EdmHashis a template class and requires template arguments. Clang stores the inner class outside the template instantiation as an optimization, but the type must have arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep it's incorrect :( I realized the printing policies are quite brittle in general, and I can't make all cases work. I'll report on the problems I found soon, in a separate GitHub issue I guess.