From 8e8dd110be5f1b4944a9dacd4f4a09bf8ecc6892 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Fri, 27 Jan 2023 03:25:16 +0000 Subject: [PATCH] [lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable Suggested in https://reviews.llvm.org/D140030 --- lldb/unittests/Symbol/TestTypeSystemClang.cpp | 65 ++++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp index 556eb33..ec5cc77 100644 --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -600,25 +600,25 @@ TEST_F(TestCreateClassTemplateDecl, FindExistingTemplates) { // 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 with T = int creates a new template. ClassTemplateDecl *single_type_arg = - ExpectNewTemplate("", {{"T"}, {intArg1}}); + ExpectNewTemplate("", {{"T"}, {intArg}}); // Test that changing the parameter name doesn't create a new class template. - ExpectReusedTemplate(" (A = int)", {{"A"}, {intArg1}}, + ExpectReusedTemplate(" (A = int)", {{"A"}, {intArg}}, single_type_arg); // Test that changing the used type doesn't create a new class template. @@ -629,50 +629,51 @@ TEST_F(TestCreateClassTemplateDecl, FindExistingTemplates) { // and I = 47; ClassTemplateDecl *type_and_char_value = ExpectNewTemplate(" (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(" (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 . // The class template from above can't be reused. ExpectNewTemplate(" (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 . ClassTemplateDecl *type_and_char_value_and_type = ExpectNewTemplate("", - {{"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("", - {{"", "", ""}, {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( llvm::SmallVector{"", ""}, - llvm::SmallVector{intArg1, intArg1})); + llvm::SmallVector{intArg, intArg})); ClassTemplateDecl *type_pack = ExpectNewTemplate(" (int, int)", infos); @@ -688,46 +689,46 @@ TEST_F(TestCreateClassTemplateDecl, FindExistingTemplatesWithParameterPack) { infos.SetParameterPack( std::make_unique( llvm::SmallVector{"", ""}, - llvm::SmallVector{intArg1, longArg1})); + llvm::SmallVector{intArg, longArg})); ExpectReusedTemplate(" (int, long)", infos, type_pack); // Change the number of pack values. infos.SetParameterPack( std::make_unique( llvm::SmallVector{""}, - llvm::SmallVector{intArg1})); + llvm::SmallVector{intArg})); ExpectReusedTemplate(" (int)", infos, type_pack); // The names of the pack values shouldn't matter. infos.SetParameterPack( std::make_unique( llvm::SmallVector{"A"}, - llvm::SmallVector{intArg1})); + llvm::SmallVector{intArg})); ExpectReusedTemplate(" (int)", infos, type_pack); // Changing the kind of template argument will create a new template. infos.SetParameterPack( std::make_unique( llvm::SmallVector{"A"}, - llvm::SmallVector{intArg2})); + llvm::SmallVector{int1Arg})); ClassTemplateDecl *int_pack = ExpectNewTemplate(" (int = 1)", infos); // Changing the value of integral parameters will not create a new template. infos.SetParameterPack( std::make_unique( llvm::SmallVector{"A"}, - llvm::SmallVector{intArg3})); + llvm::SmallVector{int123Arg})); ExpectReusedTemplate(" (int = 123)", infos, int_pack); // Changing the integral type will create a new template. infos.SetParameterPack( std::make_unique( llvm::SmallVector{"A"}, - llvm::SmallVector{longArg2})); + llvm::SmallVector{long1Arg})); ExpectNewTemplate(" (long = 1)", infos); // Prependinding a non-pack parameter will create a new template. - infos.InsertArg("T", intArg1); + infos.InsertArg("T", intArg); ExpectNewTemplate(" (T = int, long = 1)", infos); } -- 2.7.4