[Lldb-commits] [PATCH] D57363: Fix handling of CreateTemplateParameterList when there is an empty pack

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 29 14:22:33 PST 2019


shafik updated this revision to Diff 184173.
shafik marked 19 inline comments as done.
shafik added a comment.

Addressed comments, including

- Renamed test
- Reduced test size
- Stream-lined code in CreateTemplateParameterList(...)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57363/new/

https://reviews.llvm.org/D57363

Files:
  packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile
  packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py
  packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp
  source/Symbol/ClangASTContext.cpp


Index: source/Symbol/ClangASTContext.cpp
===================================================================
--- source/Symbol/ClangASTContext.cpp
+++ source/Symbol/ClangASTContext.cpp
@@ -1549,25 +1549,24 @@
     }
   }
 
-  if (template_param_infos.packed_args &&
-      template_param_infos.packed_args->args.size()) {
+  if (template_param_infos.packed_args) {
     IdentifierInfo *identifier_info = nullptr;
     if (template_param_infos.pack_name && template_param_infos.pack_name[0])
       identifier_info = &ast->Idents.get(template_param_infos.pack_name);
     const bool parameter_pack_true = true;
-    if (IsValueParam(template_param_infos.packed_args->args[0])) {
+
+    if (!template_param_infos.packed_args->args.empty() &&
+        IsValueParam(template_param_infos.packed_args->args[0])) {
       template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
-          *ast, decl_context,
-          SourceLocation(), SourceLocation(), depth, num_template_params,
-          identifier_info,
+          *ast, decl_context, SourceLocation(), SourceLocation(), depth,
+          num_template_params, identifier_info,
           template_param_infos.packed_args->args[0].getIntegralType(),
           parameter_pack_true, nullptr));
     } else {
       template_param_decls.push_back(TemplateTypeParmDecl::Create(
-          *ast, decl_context,
-          SourceLocation(), SourceLocation(), depth, num_template_params,
-          identifier_info,
-          is_typename, parameter_pack_true));
+          *ast, decl_context, SourceLocation(), SourceLocation(), depth,
+          num_template_params, identifier_info, is_typename,
+          parameter_pack_true));
     }
   }
   clang::Expr *const requires_clause = nullptr; // TODO: Concepts
Index: packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/main.cpp
@@ -0,0 +1,9 @@
+template <typename N, class... P>
+struct A {
+    int foo() { return 1;}
+};
+
+int main() {
+  A<int> b;
+  return b.foo(); // break here
+}
Index: packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/TestClassTemplateSpecializationParametersHandling.py
@@ -0,0 +1,23 @@
+"""
+Test Expression Parser code gen for ClassTemplateSpecializationDecl to insure
+that we generate a TemplateTypeParmDecl in the TemplateParameterList for empty
+variadic packs.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestClassTemplateSpecializationParametersHandling(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def test_class_template_specialization(self):
+        self.build()
+
+        lldbutil.run_to_source_breakpoint(self, '// break here',
+                lldb.SBFileSpec("main.cpp", False))
+
+        self.expect("expr -u 0 -- b.foo()", substrs=['$0 = 1'])
Index: packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/expression_command/class_template_specialization_empty_pack/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57363.184173.patch
Type: text/x-patch
Size: 3706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190129/dfe7f760/attachment-0001.bin>


More information about the lldb-commits mailing list