[Lldb-commits] [lldb] 8e8dd11 - [lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 26 19:47:45 PST 2023


Author: Michael Buch
Date: 2023-01-27T03:46:50Z
New Revision: 8e8dd110be5f1b4944a9dacd4f4a09bf8ecc6892

URL: https://github.com/llvm/llvm-project/commit/8e8dd110be5f1b4944a9dacd4f4a09bf8ecc6892
DIFF: https://github.com/llvm/llvm-project/commit/8e8dd110be5f1b4944a9dacd4f4a09bf8ecc6892.diff

LOG: [lldb][Test][NFC] TestCreateClassTemplateDecl: make variable names more readable

Suggested in https://reviews.llvm.org/D140030

Added: 
    

Modified: 
    lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 556eb333c3f35..ec5cc776d960f 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 <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.
@@ -629,50 +629,51 @@ TEST_F(TestCreateClassTemplateDecl, FindExistingTemplates) {
   // 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);
@@ -688,46 +689,46 @@ TEST_F(TestCreateClassTemplateDecl, FindExistingTemplatesWithParameterPack) {
   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);
 }
 


        


More information about the lldb-commits mailing list