aboutsummaryrefslogtreecommitdiff
path: root/lit/Expr
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /lit/Expr
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'lit/Expr')
-rw-r--r--lit/Expr/Inputs/anonymous-struct.cpp26
-rw-r--r--lit/Expr/Inputs/call-function.cpp53
-rw-r--r--lit/Expr/TestCallStdStringFunction.test14
-rw-r--r--lit/Expr/TestCallStopAndContinue.test12
-rw-r--r--lit/Expr/TestCallUserAnonTypedef.test11
-rw-r--r--lit/Expr/TestCallUserDefinedFunction.test20
-rw-r--r--lit/Expr/lit.local.cfg1
7 files changed, 137 insertions, 0 deletions
diff --git a/lit/Expr/Inputs/anonymous-struct.cpp b/lit/Expr/Inputs/anonymous-struct.cpp
new file mode 100644
index 000000000000..5b170c5f943a
--- /dev/null
+++ b/lit/Expr/Inputs/anonymous-struct.cpp
@@ -0,0 +1,26 @@
+#include <tgmath.h>
+
+typedef struct {
+ float f;
+ int i;
+} my_untagged_struct;
+
+double multiply(my_untagged_struct *s)
+{
+ return s->f * s->i;
+}
+
+double multiply(my_untagged_struct *s, int x)
+{
+ return multiply(s) * x;
+}
+
+int main(int argc, char **argv)
+{
+ my_untagged_struct s = {
+ .f = (float)argc,
+ .i = argc,
+ };
+ // lldb testsuite break
+ return !(multiply(&s, argc) == pow(argc, 3));
+}
diff --git a/lit/Expr/Inputs/call-function.cpp b/lit/Expr/Inputs/call-function.cpp
new file mode 100644
index 000000000000..cc5f52dbf567
--- /dev/null
+++ b/lit/Expr/Inputs/call-function.cpp
@@ -0,0 +1,53 @@
+#include <iostream>
+#include <string>
+#include <cstring>
+
+struct Five
+{
+ int number;
+ const char *name;
+};
+
+Five
+returnsFive()
+{
+ Five my_five = {5, "five"};
+ return my_five;
+}
+
+unsigned int
+fib(unsigned int n)
+{
+ if (n < 2)
+ return n;
+ else
+ return fib(n - 1) + fib(n - 2);
+}
+
+int
+add(int a, int b)
+{
+ return a + b;
+}
+
+bool
+stringCompare(const char *str)
+{
+ if (strcmp( str, "Hello world" ) == 0)
+ return true;
+ else
+ return false;
+}
+
+int main (int argc, char const *argv[])
+{
+ std::string str = "Hello world";
+ std::cout << str << std::endl;
+ std::cout << str.c_str() << std::endl;
+ Five main_five = returnsFive();
+#if 0
+ print str
+ print str.c_str()
+#endif
+ return 0; // Please test these expressions while stopped at this line:
+}
diff --git a/lit/Expr/TestCallStdStringFunction.test b/lit/Expr/TestCallStdStringFunction.test
new file mode 100644
index 000000000000..dadb5dbd0961
--- /dev/null
+++ b/lit/Expr/TestCallStdStringFunction.test
@@ -0,0 +1,14 @@
+# XFAIL: windows
+# -> llvm.org/pr21765
+
+# XFAIL: freebsd
+# -> llvm.org/pr17807
+
+# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s
+
+breakpoint set --file call-function.cpp --line 52
+run
+print str
+# CHECK: Hello world
+print str.c_str()
+# CHECK: Hello world
diff --git a/lit/Expr/TestCallStopAndContinue.test b/lit/Expr/TestCallStopAndContinue.test
new file mode 100644
index 000000000000..263fa2a6f59a
--- /dev/null
+++ b/lit/Expr/TestCallStopAndContinue.test
@@ -0,0 +1,12 @@
+# XFAIL: windows
+# -> llvm.org/pr24489
+
+# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -o continue -o "thread list" -- %t 2>&1 | FileCheck %s
+
+breakpoint set --file call-function.cpp --line 52
+run
+breakpoint set --file call-function.cpp --line 14
+expression -i false -- returnsFive()
+# CHECK: Execution was interrupted, reason: breakpoint
+# CHECK: stop reason = User Expression thread plan
+# CHECK: Completed expression: (Five) $0 = (number = 5{{.*}}, name = "five")
diff --git a/lit/Expr/TestCallUserAnonTypedef.test b/lit/Expr/TestCallUserAnonTypedef.test
new file mode 100644
index 000000000000..510f40c22e2d
--- /dev/null
+++ b/lit/Expr/TestCallUserAnonTypedef.test
@@ -0,0 +1,11 @@
+# XFAIL: windows
+
+# XFAIL: armhf-linux
+# -> llvm.org/pr27868
+
+# RUN: %cxx %p/Inputs/anonymous-struct.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s
+
+breakpoint set --file anonymous-struct.cpp --line 24
+run
+expression multiply(&s)
+# CHECK: $0 = 1
diff --git a/lit/Expr/TestCallUserDefinedFunction.test b/lit/Expr/TestCallUserDefinedFunction.test
new file mode 100644
index 000000000000..0c98a9bae78c
--- /dev/null
+++ b/lit/Expr/TestCallUserDefinedFunction.test
@@ -0,0 +1,20 @@
+# XFAIL: windows
+# -> llvm.org/pr24489
+
+# RUN: %cxx %p/Inputs/call-function.cpp -g -o %t && %lldb -b -s %s -- %t | FileCheck %s
+
+breakpoint set --file call-function.cpp --line 52
+run
+expression fib(5)
+# CHECK: $0 = 5
+expression add(4,8)
+# CHECK: $1 = 12
+
+expression add(add(5,2),add(3,4))
+# CHECK: $2 = 14
+expression add(add(5,2),fib(5))
+# CHECK: $3 = 12
+expression stringCompare((const char*) "Hello world")
+# CHECK: $4 = true
+expression stringCompare((const char*) "Hellworld")
+# CHECK: $5 = false
diff --git a/lit/Expr/lit.local.cfg b/lit/Expr/lit.local.cfg
new file mode 100644
index 000000000000..df9b335dd131
--- /dev/null
+++ b/lit/Expr/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.test']