summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2017-05-11 22:08:05 +0000
committerSean Callanan <scallanan@apple.com>2017-05-11 22:08:05 +0000
commit09e91ac6ab8a184d92100e3b1a1c4b6a0b8dc47a (patch)
tree616cd710fa1d731d0668c5f3c8058daf91569842 /lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack
parent895aea6d1502f813dda47e9ec4c77e5a0a13aaff (diff)
downloadbcm5719-llvm-09e91ac6ab8a184d92100e3b1a1c4b6a0b8dc47a.tar.gz
bcm5719-llvm-09e91ac6ab8a184d92100e3b1a1c4b6a0b8dc47a.zip
[DWARF parser] Produce correct template parameter packs
Templates can end in parameter packs, like this template <class T...> struct MyStruct { /*...*/ }; LLDB does not currently support these parameter packs; it does not emit them into the template argument list at all. This causes problems when you specialize, e.g.: template <> struct MyStruct<int> { /*...*/ }; template <> struct MyStruct<int, int> : MyStruct<int> { /*...*/ }; LLDB generates two template specializations, each with no template arguments, and then when they are imported by the ASTImporter into a parser's AST context we get a single specialization that inherits from itself, causing Clang's record layout mechanism to smash its stack. This patch fixes the problem for classes and adds tests. The tests for functions fail because Clang's ASTImporter can't import them at the moment, so I've xfailed that test. Differential Revision: https://reviews.llvm.org/D33025 llvm-svn: 302833
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile3
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py6
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp24
3 files changed, 33 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile
new file mode 100644
index 00000000000..99bfa7e03b4
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py
new file mode 100644
index 00000000000..810aefee0f0
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/TestFunctionTemplateParameterPack.py
@@ -0,0 +1,6 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+ __file__, globals(), [
+ decorators.expectedFailureAll(bugnumber="rdar://problem/32096064")])
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp
new file mode 100644
index 00000000000..e802d40e5f8
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/function-template-parameter-pack/main.cpp
@@ -0,0 +1,24 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LIDENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+template <class T> int staticSizeof() {
+ return sizeof(T);
+}
+
+template <class T1, class T2, class... Ts> int staticSizeof() {
+ return staticSizeof<T2, Ts...>() + sizeof(T1);
+}
+
+int main (int argc, char const *argv[])
+{
+ int sz = staticSizeof<long, int, char>();
+ return staticSizeof<long, int, char>() != sz; //% self.expect("expression -- sz == staticSizeof<long, int, char>()", "staticSizeof<long, int, char> worked", substrs = ["true"])
+ //% self.expect("expression -- sz == staticSizeof<long, int>() + sizeof(char)", "staticSizeof<long, int> worked", substrs = ["true"])
+ //% self.expect("expression -- sz == staticSizeof<long>() + sizeof(int) + sizeof(char)", "staticSizeof<long> worked", substrs = ["true"])
+}
OpenPOWER on IntegriCloud