@@ -5186,24 +5186,31 @@ std::string Converter::ConvertIRFragment(
51865186 ConvertIRFragment ((*re)->inner , bindings, expr, args, num_args, ctx);
51875187 } else if (auto *call =
51885188 std::get_if<std::unique_ptr<GenericCallFragment>>(&frag)) {
5189- result +=
5190- ConvertGenericCall (**call, bindings, expr, args, num_args, ctx);
5189+ result += ConvertGenericCall (**call, bindings, expr, args, num_args, ctx);
51915190 }
51925191 }
51935192
51945193 return result;
51955194}
51965195
5197- std::string Converter::ConvertGenericCall (
5198- const TranslationRule::GenericCallFragment &call,
5199- llvm::ArrayRef<clang::TemplateArgument> bindings, clang::Expr *expr,
5200- clang::Expr **args, unsigned num_args, TempMaterializationCtx *ctx) {
5196+ std::string
5197+ Converter::ConvertGenericCall (const TranslationRule::GenericCallFragment &call,
5198+ llvm::ArrayRef<clang::TemplateArgument> bindings,
5199+ clang::Expr *expr, clang::Expr **args,
5200+ unsigned num_args, TempMaterializationCtx *ctx) {
52015201 std::vector<std::string> call_args;
52025202 for (const auto &arg : call.args ) {
52035203 call_args.push_back (
52045204 ConvertIRFragment (arg, bindings, expr, args, num_args, ctx));
52055205 }
5206- auto type = RuleRegistry::GetGenericType (ctx_, expr, call.generic );
5206+ clang::QualType type;
5207+ if (call.generic <= bindings.size () &&
5208+ bindings[call.generic - 1 ].getKind () == clang::TemplateArgument::Type) {
5209+ type = bindings[call.generic - 1 ].getAsType ();
5210+ } else {
5211+ assert (expr && " unbound generic outside an expression rule" );
5212+ type = RuleRegistry::GetGenericType (ctx_, expr, call.generic );
5213+ }
52075214 if (call.method == " default" ) {
52085215 assert (call_args.empty () && " default takes no arguments" );
52095216 return GetUnboxedDefaultAsString (type);
0 commit comments