@@ -589,6 +589,34 @@ TEST(FunctionReflectionTest, InstantiateTemplateMethod) {
589
589
EXPECT_TRUE (TA1.getAsType ()->isIntegerType ());
590
590
}
591
591
592
+ TEST (FunctionReflectionTest, InstantiateVariadicFunctionTemplate) {
593
+ std::vector<Decl*> Decls;
594
+ std::string code = R"(
595
+ template<typename... Args> void VariadicFnTemplate(Args... args) {}
596
+ )" ;
597
+
598
+ GetAllTopLevelDecls (code, Decls);
599
+ ASTContext& C = Interp->getCI ()->getASTContext ();
600
+
601
+ // Example instantiation with int and double
602
+ std::vector<Cpp::TemplateArgInfo> args1 = {C.IntTy .getAsOpaquePtr (),
603
+ C.DoubleTy .getAsOpaquePtr ()};
604
+ auto Instance1 = Cpp::InstantiateTemplate (Decls[0 ], args1.data (),
605
+ /* type_size*/ args1.size ());
606
+ // EXPECT_TRUE(isa<FunctionTemplateDecl>((Decl*)Instance1));
607
+ FunctionDecl* FD = cast<FunctionDecl>((Decl*)Instance1);
608
+ FunctionDecl* FnTD1 = FD->getTemplateInstantiationPattern ();
609
+ EXPECT_TRUE (FnTD1->isThisDeclarationADefinition ());
610
+ // TemplateArgument TA1 = FD->getTemplateSpecializationArgs()->get(0);
611
+
612
+ // // Validate the first argument is of integer type
613
+ // EXPECT_TRUE(TA1.getAsType()->isIntegerType());
614
+
615
+ // // Validate the second argument is of double type
616
+ // TemplateArgument TA2 = FD->getTemplateSpecializationArgs()->get(1);
617
+ // EXPECT_TRUE(TA2.getAsType()->isFloatingType());
618
+ }
619
+
592
620
TEST (FunctionReflectionTest, BestTemplateFunctionMatch) {
593
621
std::vector<Decl*> Decls;
594
622
std::string code = R"(
0 commit comments