@@ -2382,26 +2382,16 @@ getSFINAEControlParams(
23822382 // template argument in a list of template arguments. It is used
23832383 // to find the index of the controlling parameter in the list of
23842384 // template arguments of the template declaration.
2385- auto FindParam = [this ](
2386- llvm::ArrayRef<clang::TemplateArgument> Arguments,
2387- clang::TemplateArgument const & Arg) -> std::size_t
2388- {
2389- if (Arg.getKind () != clang::TemplateArgument::Type)
2390- {
2391- return -1 ;
2392- }
2393- auto const It = std::ranges::find_if (
2394- Arguments,
2395- [&](clang::TemplateArgument const & Other)
2396- {
2397- if (Other.getKind () != clang::TemplateArgument::Type)
2398- {
2399- return false ;
2400- }
2401- return context_.hasSameType (Other.getAsType (), Arg.getAsType ());
2402- });
2385+ auto FindParam =
2386+ [this ](
2387+ llvm::ArrayRef<clang::TemplateArgument> Arguments,
2388+ clang::TemplateArgument const & Arg) -> std::size_t {
2389+ auto const It = std::ranges::
2390+ find_if (Arguments, [&](clang::TemplateArgument const & Other) {
2391+ return context_.isSameTemplateArgument (Arg, Other);
2392+ });
24032393 bool const found = It != Arguments.end ();
2404- return found ? It - Arguments.data () : static_cast <std::size_t >(-1 );
2394+ return found ? It - Arguments.begin () : static_cast <std::size_t >(-1 );
24052395 };
24062396
24072397 if (auto * ATD = dyn_cast<clang::TypeAliasTemplateDecl>(TD))
@@ -2441,9 +2431,40 @@ getSFINAEControlParams(
24412431 // the primary template arguments
24422432 clang::TemplateParameterList* primaryTemplParams = ATD->getTemplateParameters ();
24432433 MRDOCS_SYMBOL_TRACE (primaryTemplParams, context_);
2434+
2435+ llvm::SmallBitVector primaryControllingParams (
2436+ primaryTemplParams->size ());
2437+ for (std::size_t i = 0 ; i < sfinaeControl->ControllingParams .size ();
2438+ ++i)
2439+ {
2440+ if (sfinaeControl->ControllingParams [i])
2441+ {
2442+ // Find the index of the parameter that represents the SFINAE
2443+ // result in the underlying template arguments
2444+ auto resultType = tryGetTemplateArgument (
2445+ sfinaeControl->Parameters ,
2446+ underlyingTemplateInfo->Arguments ,
2447+ i);
2448+ MRDOCS_CHECK_OR_CONTINUE (resultType);
2449+ MRDOCS_SYMBOL_TRACE (*resultType, context_);
2450+
2451+ // Find the index of the parameter that represents the param
2452+ // in the primary template arguments
2453+ auto ParamIdx = FindParam (
2454+ ATD->getInjectedTemplateArgs (context_),
2455+ *resultType);
2456+ if (ParamIdx == static_cast <std::size_t >(-1 ))
2457+ {
2458+ continue ;
2459+ }
2460+
2461+ primaryControllingParams.set (ParamIdx);
2462+ }
2463+ }
2464+
24442465 return SFINAEControlParams (
24452466 primaryTemplParams,
2446- std::move (sfinaeControl-> ControllingParams ),
2467+ std::move (primaryControllingParams ),
24472468 ParamIdx);
24482469 }
24492470
0 commit comments