Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions core/clingutils/src/TClingUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4047,6 +4047,7 @@ static void KeepNParams(clang::QualType& normalizedType,
const int nNormArgs = normArgs.size();

bool mightHaveChanged = false;
int latestNonDefaultArg = -1;

// becomes true when a parameter has a value equal to its default
for (int formal = 0, inst = 0; formal != nArgs; ++formal, ++inst) {
Expand Down Expand Up @@ -4085,10 +4086,12 @@ static void KeepNParams(clang::QualType& normalizedType,
argsToKeep.push_back(normTArg);
}
// Done.
latestNonDefaultArg = -1;
break;
}
mightHaveChanged |= RecurseKeepNParams(normTArg, tArg, interp, normCtxt, astCtxt);
argsToKeep.push_back(normTArg);
latestNonDefaultArg = formal;
continue;
} else {
if (!isStdDropDefault) {
Expand All @@ -4110,16 +4113,21 @@ static void KeepNParams(clang::QualType& normalizedType,
} else if (argKind == clang::TemplateArgument::Integral){
equal = areEqualValues(tArg, *tParPtr);
}

argsToKeep.push_back(normTArg);
if (!equal) {
latestNonDefaultArg = formal;
mightHaveChanged |= RecurseKeepNParams(normTArg, tArg, interp, normCtxt, astCtxt);
argsToKeep.push_back(normTArg);
} else {
mightHaveChanged = true;
}


} // of loop over parameters and arguments

if (latestNonDefaultArg >= 0)
argsToKeep.resize(latestNonDefaultArg + 1);

if (!prefix_changed && !mightHaveChanged) {
normalizedType = originalNormalizedType;
return;
Expand All @@ -4140,7 +4148,6 @@ static void KeepNParams(clang::QualType& normalizedType,
normalizedType = astCtxt.getElaboratedType(clang::ElaboratedTypeKeyword::None, prefix, normalizedType);
normalizedType = astCtxt.getQualifiedType(normalizedType,prefix_qualifiers);
}

}

////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions core/foundation/src/TClassEdit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ void TClassEdit::TSplitType::ShortType(std::string &answ, int mode)
// do the same for all inside
for (int i=1;i<narg; i++) {
if (!strchr(fElements[i].c_str(),'<')) {
if (mode&kResolveTypedef) {
fElements[i] = ResolveTypedef(fElements[i].c_str(),true);
}
if (mode&kDropStd) {
unsigned int offset = (0==strncmp("const ",fElements[i].c_str(),6)) ? 6 : 0;
RemoveStd( fElements[i], offset );
}
if (mode&kResolveTypedef) {
fElements[i] = ResolveTypedef(fElements[i].c_str(),true);
}
continue;
}
fElements[i] = TClassEdit::ShortType(fElements[i].c_str(),mode | TClassEdit::kKeepOuterConst);
Expand Down
22 changes: 22 additions & 0 deletions core/foundation/test/testClassEdit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,29 @@ TEST(TClassEdit, GetNormalizedName)

n.clear();
EXPECT_THROW(TClassEdit::GetNormalizedName(n, "_Atomic(map<string, TObjArray* >*"), std::runtime_error);
}

TEST(TClassEdit, GetNormalizedNameTypedef)
{
std::string n;

gInterpreter->Declare(R"(
struct MyAlloc {};
using MyMap = std::map<int,int,std::less<int>,MyAlloc>;
)");

TClassEdit::GetNormalizedName(n, "MyMap");
EXPECT_STREQ("map<int,int,less<int>,MyAlloc>", n.c_str());

gInterpreter->Declare(R"(
using MyMapDefault = std::map<int,int,std::less<int>,std::allocator<std::pair<const int,int>>>;
)");

TClassEdit::GetNormalizedName(n, "MyMapDefault");
EXPECT_STREQ("map<int,int>", n.c_str());

TClassEdit::GetNormalizedName(n, "std::map<int,int,std::less<int>,std::allocator<std::pair<const int,int>>>");
EXPECT_STREQ("map<int,int>", n.c_str());
}

// https://github.com/root-project/root/issues/18654
Expand Down
Loading