Skip to content

Commit ea1957a

Browse files
committed
[cling] Update policy for 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
1 parent 8ad447e commit ea1957a

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

interpreter/cling/lib/Utils/AST.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,8 @@ namespace utils {
17621762
PrintingPolicy Policy(Ctx.getPrintingPolicy());
17631763
Policy.SuppressScope = false;
17641764
Policy.AnonymousTagLocations = false;
1765+
Policy.SuppressElaboration = true;
1766+
Policy.FullyQualifiedName = true;
17651767
return FQQT.getAsString(Policy);
17661768
}
17671769

roottest/root/meta/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ ROOTTEST_ADD_TEST(loadernotapp
3838
OUTREF loadernotapp.ref
3939
DEPENDS ${GENERATE_EXECUTABLE_TEST})
4040

41+
ROOTTEST_ADD_TEST(reproduceROOT10150
42+
MACRO reproduceROOT10150.C+
43+
FAILREGEX "error")
44+
4145
ROOTTEST_COMPILE_MACRO(fornamespace.C)
4246

4347
#---Copy from source to binary some of the files
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// reproducer from https://its.cern.ch/jira/browse/ROOT-10150
2+
3+
#include <TInterpreter.h>
4+
#include <functional>
5+
#include <iostream>
6+
7+
namespace Foo {
8+
struct Particle {
9+
float m_pt;
10+
float pt() const { return m_pt; }
11+
};
12+
} // namespace Foo
13+
14+
template <typename FType>
15+
FType get_functor(std::string const &functor_string)
16+
{
17+
auto intern = gInterpreter->MakeInterpreterValue();
18+
gInterpreter->Evaluate(functor_string.c_str(), *intern);
19+
return *static_cast<FType *>(intern->GetAsPointer());
20+
}
21+
22+
void reproduceROOT10150()
23+
{
24+
auto functor = get_functor<std::function<bool(Foo::Particle const &)>>(
25+
"std::function<bool(Foo::Particle const&)>( [](Foo::Particle const& particle){return particle.pt() > 15;} );");
26+
Foo::Particle low_pT_particle{1.f}, high_pT_particle{40.f};
27+
std::cout << functor(high_pT_particle) << " " << functor(low_pT_particle) << std::endl;
28+
}

tree/ntuple/test/ntuple_type_name.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ TEST(RNTuple, TypeNameTemplatesNestedAlias)
216216
ASSERT_EQ(2, hashSubfields.size());
217217
EXPECT_EQ("fHash", hashSubfields[0]->GetFieldName());
218218
EXPECT_EQ("std::string", hashSubfields[0]->GetTypeName());
219-
EXPECT_EQ("EdmHash<1>::value_type", hashSubfields[0]->GetTypeAlias());
219+
EXPECT_EQ("EdmHash::value_type", hashSubfields[0]->GetTypeAlias());
220220

221221
EXPECT_EQ("fHash2", hashSubfields[1]->GetFieldName());
222222
EXPECT_EQ("std::string", hashSubfields[1]->GetTypeName());
223223
// FIXME: This should really be EdmHash<1>::value_typeT<EdmHash<1>::value_type>, but this is the value we get from
224224
// TDataMember::GetFullTypeName right now...
225-
EXPECT_EQ("value_typeT<EdmHash<1>::value_type>", hashSubfields[1]->GetTypeAlias());
225+
EXPECT_EQ("EdmHash::value_typeT<EdmHash::value_type>", hashSubfields[1]->GetTypeAlias());
226226
}
227227

228228
TEST(RNTuple, ContextDependentTypeNames)
@@ -257,7 +257,7 @@ TEST(RNTuple, ContextDependentTypeNames)
257257
{
258258
const auto &fdesc = desc.GetFieldDescriptor(desc.FindFieldId("m", fooId));
259259
EXPECT_EQ(fdesc.GetTypeName(), "std::vector<std::int32_t>");
260-
EXPECT_EQ(fdesc.GetTypeAlias(), "MyVec<std::int32_t>");
260+
EXPECT_EQ(fdesc.GetTypeAlias(), "CustomStruct::MyVec<std::int32_t>");
261261
}
262262
{
263263
const auto &fdesc = desc.GetFieldDescriptor(desc.FindFieldId("a", baseId));

tree/ntuple/test/ntuple_types.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ TEST(RNTuple, ContextDependentTypes)
22612261
EXPECT_EQ(field.GetTypeName(), "DerivedWithTypedef");
22622262
const auto &vec = model.GetConstField("foo.m");
22632263
EXPECT_EQ(vec.GetTypeName(), "std::vector<std::int32_t>");
2264-
EXPECT_EQ(vec.GetTypeAlias(), "MyVec<std::int32_t>");
2264+
EXPECT_EQ(vec.GetTypeAlias(), "CustomStruct::MyVec<std::int32_t>");
22652265

22662266
auto vecView = reader->GetView<DerivedWithTypedef::MyVec<int>>("foo.m");
22672267
for (const auto &i : reader->GetEntryRange()) {

0 commit comments

Comments
 (0)