// Test an empty template parameter list: <>
ExpectNewTemplate("<>", {{}, {}});
- clang::TemplateArgument intArg1(m_ast->getASTContext().IntTy);
- clang::TemplateArgument intArg2(m_ast->getASTContext(),
- llvm::APSInt(llvm::APInt(32, 47)),
- m_ast->getASTContext().IntTy);
+ clang::TemplateArgument intArg(m_ast->getASTContext().IntTy);
+ clang::TemplateArgument int47Arg(m_ast->getASTContext(),
+ llvm::APSInt(llvm::APInt(32, 47)),
+ m_ast->getASTContext().IntTy);
clang::TemplateArgument floatArg(m_ast->getASTContext().FloatTy);
- clang::TemplateArgument charArg1(m_ast->getASTContext(),
- llvm::APSInt(llvm::APInt(8, 47)),
- m_ast->getASTContext().SignedCharTy);
+ clang::TemplateArgument char47Arg(m_ast->getASTContext(),
+ llvm::APSInt(llvm::APInt(8, 47)),
+ m_ast->getASTContext().SignedCharTy);
- clang::TemplateArgument charArg2(m_ast->getASTContext(),
- llvm::APSInt(llvm::APInt(8, 123)),
- m_ast->getASTContext().SignedCharTy);
+ clang::TemplateArgument char123Arg(m_ast->getASTContext(),
+ llvm::APSInt(llvm::APInt(8, 123)),
+ m_ast->getASTContext().SignedCharTy);
// Test that <typename T> with T = int creates a new template.
ClassTemplateDecl *single_type_arg =
- ExpectNewTemplate("<typename T>", {{"T"}, {intArg1}});
+ ExpectNewTemplate("<typename T>", {{"T"}, {intArg}});
// Test that changing the parameter name doesn't create a new class template.
- ExpectReusedTemplate("<typename A> (A = int)", {{"A"}, {intArg1}},
+ ExpectReusedTemplate("<typename A> (A = int)", {{"A"}, {intArg}},
single_type_arg);
// Test that changing the used type doesn't create a new class template.
// and I = 47;
ClassTemplateDecl *type_and_char_value =
ExpectNewTemplate("<typename A, signed char I> (I = 47)",
- {{"A", "I"}, {floatArg, charArg1}});
+ {{"A", "I"}, {floatArg, char47Arg}});
// Change the value of the I parameter to 123. The previously created
// class template should still be reused.
ExpectReusedTemplate("<typename A, signed char I> (I = 123)",
- {{"A", "I"}, {floatArg, charArg2}}, type_and_char_value);
+ {{"A", "I"}, {floatArg, char123Arg}},
+ type_and_char_value);
// Change the type of the I parameter to int so we have <typename A, int I>.
// The class template from above can't be reused.
ExpectNewTemplate("<typename A, int I> (I = 123)",
- {{"A", "I"}, {floatArg, intArg2}});
+ {{"A", "I"}, {floatArg, int47Arg}});
// Test a second type parameter will also cause a new template to be created.
// We now have <typename A, int I, typename B>.
ClassTemplateDecl *type_and_char_value_and_type =
ExpectNewTemplate("<typename A, int I, typename B>",
- {{"A", "I", "B"}, {floatArg, intArg2, intArg1}});
+ {{"A", "I", "B"}, {floatArg, int47Arg, intArg}});
// Remove all the names from the parameters which shouldn't influence the
// way the templates get merged.
ExpectReusedTemplate("<typename, int, typename>",
- {{"", "", ""}, {floatArg, intArg2, intArg1}},
+ {{"", "", ""}, {floatArg, int47Arg, intArg}},
type_and_char_value_and_type);
}
TEST_F(TestCreateClassTemplateDecl, FindExistingTemplatesWithParameterPack) {
// The same as FindExistingTemplates but for templates with parameter packs.
TypeSystemClang::TemplateParameterInfos infos;
- clang::TemplateArgument intArg1(m_ast->getASTContext().IntTy);
- clang::TemplateArgument intArg2(m_ast->getASTContext(),
+ clang::TemplateArgument intArg(m_ast->getASTContext().IntTy);
+ clang::TemplateArgument int1Arg(m_ast->getASTContext(),
llvm::APSInt(llvm::APInt(32, 1)),
m_ast->getASTContext().IntTy);
- clang::TemplateArgument intArg3(m_ast->getASTContext(),
- llvm::APSInt(llvm::APInt(32, 123)),
- m_ast->getASTContext().IntTy);
- clang::TemplateArgument longArg1(m_ast->getASTContext().LongTy);
- clang::TemplateArgument longArg2(m_ast->getASTContext(),
+ clang::TemplateArgument int123Arg(m_ast->getASTContext(),
+ llvm::APSInt(llvm::APInt(32, 123)),
+ m_ast->getASTContext().IntTy);
+ clang::TemplateArgument longArg(m_ast->getASTContext().LongTy);
+ clang::TemplateArgument long1Arg(m_ast->getASTContext(),
llvm::APSInt(llvm::APInt(64, 1)),
m_ast->getASTContext().LongTy);
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"", ""},
- llvm::SmallVector<TemplateArgument>{intArg1, intArg1}));
+ llvm::SmallVector<TemplateArgument>{intArg, intArg}));
ClassTemplateDecl *type_pack =
ExpectNewTemplate("<typename ...> (int, int)", infos);
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"", ""},
- llvm::SmallVector<TemplateArgument>{intArg1, longArg1}));
+ llvm::SmallVector<TemplateArgument>{intArg, longArg}));
ExpectReusedTemplate("<typename ...> (int, long)", infos, type_pack);
// Change the number of pack values.
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{""},
- llvm::SmallVector<TemplateArgument>{intArg1}));
+ llvm::SmallVector<TemplateArgument>{intArg}));
ExpectReusedTemplate("<typename ...> (int)", infos, type_pack);
// The names of the pack values shouldn't matter.
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"A"},
- llvm::SmallVector<TemplateArgument>{intArg1}));
+ llvm::SmallVector<TemplateArgument>{intArg}));
ExpectReusedTemplate("<typename ...> (int)", infos, type_pack);
// Changing the kind of template argument will create a new template.
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"A"},
- llvm::SmallVector<TemplateArgument>{intArg2}));
+ llvm::SmallVector<TemplateArgument>{int1Arg}));
ClassTemplateDecl *int_pack = ExpectNewTemplate("<int ...> (int = 1)", infos);
// Changing the value of integral parameters will not create a new template.
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"A"},
- llvm::SmallVector<TemplateArgument>{intArg3}));
+ llvm::SmallVector<TemplateArgument>{int123Arg}));
ExpectReusedTemplate("<int ...> (int = 123)", infos, int_pack);
// Changing the integral type will create a new template.
infos.SetParameterPack(
std::make_unique<TypeSystemClang::TemplateParameterInfos>(
llvm::SmallVector<const char *>{"A"},
- llvm::SmallVector<TemplateArgument>{longArg2}));
+ llvm::SmallVector<TemplateArgument>{long1Arg}));
ExpectNewTemplate("<long ...> (long = 1)", infos);
// Prependinding a non-pack parameter will create a new template.
- infos.InsertArg("T", intArg1);
+ infos.InsertArg("T", intArg);
ExpectNewTemplate("<typename T, long...> (T = int, long = 1)", infos);
}