diff --git a/core/clingutils/src/TClingUtils.cxx b/core/clingutils/src/TClingUtils.cxx index c534f82b28245..ca92e458ffa34 100644 --- a/core/clingutils/src/TClingUtils.cxx +++ b/core/clingutils/src/TClingUtils.cxx @@ -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) { @@ -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) { @@ -4110,9 +4113,11 @@ 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; } @@ -4120,6 +4125,9 @@ static void KeepNParams(clang::QualType& normalizedType, } // of loop over parameters and arguments + if (latestNonDefaultArg >= 0) + argsToKeep.resize(latestNonDefaultArg + 1); + if (!prefix_changed && !mightHaveChanged) { normalizedType = originalNormalizedType; return; @@ -4140,7 +4148,6 @@ static void KeepNParams(clang::QualType& normalizedType, normalizedType = astCtxt.getElaboratedType(clang::ElaboratedTypeKeyword::None, prefix, normalizedType); normalizedType = astCtxt.getQualifiedType(normalizedType,prefix_qualifiers); } - } //////////////////////////////////////////////////////////////////////////////// diff --git a/core/foundation/src/TClassEdit.cxx b/core/foundation/src/TClassEdit.cxx index adaa639b02427..aa092c7b45035 100644 --- a/core/foundation/src/TClassEdit.cxx +++ b/core/foundation/src/TClassEdit.cxx @@ -454,13 +454,13 @@ void TClassEdit::TSplitType::ShortType(std::string &answ, int mode) // do the same for all inside for (int i=1;i*"), std::runtime_error); +} + +TEST(TClassEdit, GetNormalizedNameTypedef) +{ + std::string n; + + gInterpreter->Declare(R"( + struct MyAlloc {}; + using MyMap = std::map,MyAlloc>; + )"); + + TClassEdit::GetNormalizedName(n, "MyMap"); + EXPECT_STREQ("map,MyAlloc>", n.c_str()); + + gInterpreter->Declare(R"( + using MyMapDefault = std::map,std::allocator>>; + )"); + + TClassEdit::GetNormalizedName(n, "MyMapDefault"); + EXPECT_STREQ("map", n.c_str()); + TClassEdit::GetNormalizedName(n, "std::map,std::allocator>>"); + EXPECT_STREQ("map", n.c_str()); } // https://github.com/root-project/root/issues/18654