summaryrefslogtreecommitdiffstats
path: root/test/LLVMC
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
committered <ed@FreeBSD.org>2009-06-02 17:52:33 +0000
commit3277b69d734b9c90b44ebde4ede005717e2c3b2e (patch)
tree64ba909838c23261cace781ece27d106134ea451 /test/LLVMC
downloadFreeBSD-src-3277b69d734b9c90b44ebde4ede005717e2c3b2e.zip
FreeBSD-src-3277b69d734b9c90b44ebde4ede005717e2c3b2e.tar.gz
Import LLVM, at r72732.
Diffstat (limited to 'test/LLVMC')
-rw-r--r--test/LLVMC/EmptyCompilationGraph.td6
-rw-r--r--test/LLVMC/EnvParentheses.td16
-rw-r--r--test/LLVMC/ExternOptions.td22
-rw-r--r--test/LLVMC/ForwardAs.td18
-rw-r--r--test/LLVMC/HookWithArguments.td16
-rw-r--r--test/LLVMC/MultiValuedOption.td21
-rw-r--r--test/LLVMC/MultipleCompilationGraphs.td8
-rw-r--r--test/LLVMC/NoActions.td12
-rw-r--r--test/LLVMC/NoCompilationGraph.td4
-rw-r--r--test/LLVMC/OneOrMore.td22
-rw-r--r--test/LLVMC/TestWarnings.td7
-rw-r--r--test/LLVMC/emit-llvm.c4
-rw-r--r--test/LLVMC/false.c14
-rw-r--r--test/LLVMC/hello.c12
-rw-r--r--test/LLVMC/hello.cpp8
-rw-r--r--test/LLVMC/hello.m12
-rw-r--r--test/LLVMC/hello.mm8
-rw-r--r--test/LLVMC/include.c9
-rw-r--r--test/LLVMC/llvmc.exp27
-rw-r--r--test/LLVMC/opt-test.c12
-rw-r--r--test/LLVMC/sink.c12
-rw-r--r--test/LLVMC/test_data/false.cpp17
-rw-r--r--test/LLVMC/test_data/false2.cpp6
-rw-r--r--test/LLVMC/test_data/together.c9
-rw-r--r--test/LLVMC/together.cpp9
-rw-r--r--test/LLVMC/wall.c12
26 files changed, 323 insertions, 0 deletions
diff --git a/test/LLVMC/EmptyCompilationGraph.td b/test/LLVMC/EmptyCompilationGraph.td
new file mode 100644
index 0000000..f4a3047
--- /dev/null
+++ b/test/LLVMC/EmptyCompilationGraph.td
@@ -0,0 +1,6 @@
+// Check that the compilation graph can be empty.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+
+include "llvm/CompilerDriver/Common.td"
+
+def Graph : CompilationGraph<[]>;
diff --git a/test/LLVMC/EnvParentheses.td b/test/LLVMC/EnvParentheses.td
new file mode 100644
index 0000000..cf2a0e3
--- /dev/null
+++ b/test/LLVMC/EnvParentheses.td
@@ -0,0 +1,16 @@
+// Check the fix for PR4157.
+// http://llvm.org/bugs/show_bug.cgi?id=4157
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: not grep {)));} %t
+
+include "llvm/CompilerDriver/Common.td"
+
+def dummy_tool : Tool<[
+(cmd_line "gcc -o $OUTFILE $INFILE $ENV(FOO)/bar"),
+(in_language "dummy"),
+(out_language "dummy")
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
+
+def Graph : CompilationGraph<[]>;
diff --git a/test/LLVMC/ExternOptions.td b/test/LLVMC/ExternOptions.td
new file mode 100644
index 0000000..a04a88b
--- /dev/null
+++ b/test/LLVMC/ExternOptions.td
@@ -0,0 +1,22 @@
+// Check that extern options work.
+// The dummy tool and graph are required to silence warnings.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: grep {extern .* AutoGeneratedSwitch_Wall} %t
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[(switch_option "Wall", (extern)),
+ (parameter_option "std", (extern)),
+ (prefix_list_option "L", (extern))]>;
+
+def dummy_tool : Tool<[
+(cmd_line "dummy_cmd"),
+(in_language "dummy"),
+(out_language "dummy"),
+(actions (case
+ (switch_on "Wall"), (stop_compilation),
+ (not_empty "std"), (stop_compilation),
+ (not_empty "L"), (stop_compilation)))
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/ForwardAs.td b/test/LLVMC/ForwardAs.td
new file mode 100644
index 0000000..5e5a087
--- /dev/null
+++ b/test/LLVMC/ForwardAs.td
@@ -0,0 +1,18 @@
+// Check the fix for PR4159.
+// http://llvm.org/bugs/show_bug.cgi?id=4159
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: grep unique_name %t
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[(parameter_option "dummy", (extern))]>;
+
+def dummy_tool : Tool<[
+(cmd_line "dummy_cmd"),
+(in_language "dummy"),
+(out_language "dummy"),
+(actions (case
+ (not_empty "dummy"), (forward_as "dummy", "unique_name")))
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/HookWithArguments.td b/test/LLVMC/HookWithArguments.td
new file mode 100644
index 0000000..0f7c379
--- /dev/null
+++ b/test/LLVMC/HookWithArguments.td
@@ -0,0 +1,16 @@
+// Check that hooks with arguments work.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: grep {Hook(const char\\* Arg0, const char\\* Arg1, const char\\* Arg2);} %t | count 1
+// RUN: grep "/path" %t | count 1
+// RUN: grep "VARIABLE" %t | count 1
+// RUN: grep "/2path" %t | count 1
+
+include "llvm/CompilerDriver/Common.td"
+
+def dummy_tool : Tool<[
+(cmd_line "$CALL(Hook, 'Arg1', 'Arg2', 'Arg3 Arg3Cont')/path arg1 $ENV(VARIABLE)/2path arg2 $INFILE"),
+(in_language "dummy"),
+(out_language "dummy")
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/MultiValuedOption.td b/test/LLVMC/MultiValuedOption.td
new file mode 100644
index 0000000..d68a115
--- /dev/null
+++ b/test/LLVMC/MultiValuedOption.td
@@ -0,0 +1,21 @@
+// Check that multivalued options work.
+// The dummy tool and graph are required to silence warnings.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: grep cl::multi_val(2) %t | count 1
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[
+ (prefix_list_option "foo", (multi_val 2)),
+ (parameter_list_option "baz", (multi_val 2), (extern))]>;
+
+def dummy_tool : Tool<[
+(cmd_line "dummy_cmd"),
+(in_language "dummy"),
+(out_language "dummy"),
+(actions (case
+ (not_empty "foo"), (forward_as "foo", "bar"),
+ (not_empty "baz"), (forward "baz")))
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/MultipleCompilationGraphs.td b/test/LLVMC/MultipleCompilationGraphs.td
new file mode 100644
index 0000000..3305fc6
--- /dev/null
+++ b/test/LLVMC/MultipleCompilationGraphs.td
@@ -0,0 +1,8 @@
+// Check that multiple compilation graphs are allowed.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+
+include "llvm/CompilerDriver/Common.td"
+
+def Graph1 : CompilationGraph<[]>;
+def Graph2 : CompilationGraph<[]>;
+def Graph3 : CompilationGraph<[]>;
diff --git a/test/LLVMC/NoActions.td b/test/LLVMC/NoActions.td
new file mode 100644
index 0000000..43fd007
--- /dev/null
+++ b/test/LLVMC/NoActions.td
@@ -0,0 +1,12 @@
+// Check that tools without associated actions are accepted.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s | grep dummy_tool
+
+include "llvm/CompilerDriver/Common.td"
+
+def dummy_tool : Tool<[
+(cmd_line "dummy_cmd"),
+(in_language "dummy"),
+(out_language "dummy")
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/NoCompilationGraph.td b/test/LLVMC/NoCompilationGraph.td
new file mode 100644
index 0000000..6476a37
--- /dev/null
+++ b/test/LLVMC/NoCompilationGraph.td
@@ -0,0 +1,4 @@
+// Check that the compilation graph is not required.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+
+include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/OneOrMore.td b/test/LLVMC/OneOrMore.td
new file mode 100644
index 0000000..f27ae97
--- /dev/null
+++ b/test/LLVMC/OneOrMore.td
@@ -0,0 +1,22 @@
+// Check that (one_or_more) and (zero_or_one) properties work.
+// The dummy tool and graph are required to silence warnings.
+// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: grep cl::ZeroOrOne %t | count 1
+// RUN: grep cl::OneOrMore %t | count 1
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[
+ (prefix_list_option "foo", (one_or_more)),
+ (parameter_list_option "baz", (zero_or_one))]>;
+
+def dummy_tool : Tool<[
+(cmd_line "dummy_cmd"),
+(in_language "dummy"),
+(out_language "dummy"),
+(actions (case
+ (not_empty "foo"), (forward_as "foo", "bar"),
+ (not_empty "baz"), (forward "baz")))
+]>;
+
+def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>;
diff --git a/test/LLVMC/TestWarnings.td b/test/LLVMC/TestWarnings.td
new file mode 100644
index 0000000..bf2173c
--- /dev/null
+++ b/test/LLVMC/TestWarnings.td
@@ -0,0 +1,7 @@
+// Check that the compiler warns about unused options.
+// This should fail because the output is printed on stderr.
+// RUN: ignore tblgen -I $srcroot/include --gen-llvmc %s |& grep "option '-Wall' has no effect!"
+
+include "llvm/CompilerDriver/Common.td"
+
+def OptList : OptionList<[(switch_option "Wall", (extern))]>;
diff --git a/test/LLVMC/emit-llvm.c b/test/LLVMC/emit-llvm.c
new file mode 100644
index 0000000..38bbba6
--- /dev/null
+++ b/test/LLVMC/emit-llvm.c
@@ -0,0 +1,4 @@
+// RUN: llvmc -c -emit-llvm -o - %s | llvm-dis | grep "@f0()" | count 1
+
+int f0(void) {
+}
diff --git a/test/LLVMC/false.c b/test/LLVMC/false.c
new file mode 100644
index 0000000..eb2883d
--- /dev/null
+++ b/test/LLVMC/false.c
@@ -0,0 +1,14 @@
+// Test that we can compile .c files as C++ and vice versa
+// RUN: llvmc -x c++ %s -x c %p/test_data/false.cpp -x lisp -x whatnot -x none %p/test_data/false2.cpp -o %t
+// RUN: ./%t | grep hello
+
+#include <iostream>
+
+extern "C" void test();
+extern std::string test2();
+
+int main() {
+ std::cout << "h";
+ test();
+ std::cout << test2() << '\n';
+}
diff --git a/test/LLVMC/hello.c b/test/LLVMC/hello.c
new file mode 100644
index 0000000..1cda9c3
--- /dev/null
+++ b/test/LLVMC/hello.c
@@ -0,0 +1,12 @@
+/*
+ * Check that we can compile helloworld
+ * RUN: llvmc %s -o %t
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/hello.cpp b/test/LLVMC/hello.cpp
new file mode 100644
index 0000000..27c89d6
--- /dev/null
+++ b/test/LLVMC/hello.cpp
@@ -0,0 +1,8 @@
+// Test that we can compile C++ code.
+// RUN: llvmc %s -o %t
+// RUN: ./%t | grep hello
+#include <iostream>
+
+int main() {
+ std::cout << "hello" << '\n';
+}
diff --git a/test/LLVMC/hello.m b/test/LLVMC/hello.m
new file mode 100644
index 0000000..1cda9c3
--- /dev/null
+++ b/test/LLVMC/hello.m
@@ -0,0 +1,12 @@
+/*
+ * Check that we can compile helloworld
+ * RUN: llvmc %s -o %t
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/hello.mm b/test/LLVMC/hello.mm
new file mode 100644
index 0000000..ff82e4a
--- /dev/null
+++ b/test/LLVMC/hello.mm
@@ -0,0 +1,8 @@
+// Test that we can compile Objective-C++ code.
+// RUN: llvmc %s -o %t
+// RUN: ./%t | grep hello
+#include <iostream>
+
+int main() {
+ std::cout << "hello" << '\n';
+}
diff --git a/test/LLVMC/include.c b/test/LLVMC/include.c
new file mode 100644
index 0000000..07ae761
--- /dev/null
+++ b/test/LLVMC/include.c
@@ -0,0 +1,9 @@
+/*
+ * Check that the 'include' options work.
+ * RUN: echo "int x;\n" > %t1.inc
+ * RUN: llvmc -include %t1.inc -fsyntax-only %s
+ */
+
+int f0(void) {
+ return x;
+}
diff --git a/test/LLVMC/llvmc.exp b/test/LLVMC/llvmc.exp
new file mode 100644
index 0000000..fd5a046
--- /dev/null
+++ b/test/LLVMC/llvmc.exp
@@ -0,0 +1,27 @@
+load_lib llvm.exp
+
+# 'false.c' is really C++, so it must be treated differently.
+set special_file "$srcdir/$subdir/false.c"
+
+if [ llvm_gcc_supports c ] then {
+ # tcl seems to lack 'filter' which would've made this easier...
+ set temp [glob -nocomplain $srcdir/$subdir/*.{c}]
+ set c_files [list]
+ foreach f $temp { if {$f != $special_file} {lappend c_files $f}}
+
+ RunLLVMTests [lsort $c_files]
+}
+
+if [ llvm_gcc_supports c++ ] then {
+ RunLLVMTests [lsort [concat [glob -nocomplain $srcdir/$subdir/*.{cpp}] $special_file]]
+}
+
+if [ llvm_gcc_supports objc ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{m}]]
+}
+
+if [ llvm_gcc_supports obj-c++ ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{mm}]]
+}
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{td}]]
diff --git a/test/LLVMC/opt-test.c b/test/LLVMC/opt-test.c
new file mode 100644
index 0000000..ed2df52
--- /dev/null
+++ b/test/LLVMC/opt-test.c
@@ -0,0 +1,12 @@
+/*
+ * Check that the -opt switch works.
+ * RUN: llvmc %s -opt -o %t
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/sink.c b/test/LLVMC/sink.c
new file mode 100644
index 0000000..3edbf78
--- /dev/null
+++ b/test/LLVMC/sink.c
@@ -0,0 +1,12 @@
+/*
+ * Check that the 'sink' options work.
+ * RUN: llvmc -v -Wall %s -o %t |& grep "Wall"
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/test_data/false.cpp b/test/LLVMC/test_data/false.cpp
new file mode 100644
index 0000000..d3a7102
--- /dev/null
+++ b/test/LLVMC/test_data/false.cpp
@@ -0,0 +1,17 @@
+/* RUN: ignore */
+#include <stdio.h>
+
+/* Make this invalid C++ */
+typedef struct {
+ int i;
+ char c;
+} a;
+
+static a b = { .i = 65, .c = 'r'};
+
+void test() {
+ b.i = 9;
+ fflush(stdout);
+ printf("el");
+}
+
diff --git a/test/LLVMC/test_data/false2.cpp b/test/LLVMC/test_data/false2.cpp
new file mode 100644
index 0000000..a020514
--- /dev/null
+++ b/test/LLVMC/test_data/false2.cpp
@@ -0,0 +1,6 @@
+// RUN: ignore
+#include <string>
+
+std::string test2() {
+ return "lo";
+}
diff --git a/test/LLVMC/test_data/together.c b/test/LLVMC/test_data/together.c
new file mode 100644
index 0000000..1b9b5f6
--- /dev/null
+++ b/test/LLVMC/test_data/together.c
@@ -0,0 +1,9 @@
+/*
+ * RUN: ignore
+ */
+
+#include <stdio.h>
+
+void test() {
+ printf("hello\n");
+}
diff --git a/test/LLVMC/together.cpp b/test/LLVMC/together.cpp
new file mode 100644
index 0000000..b07250e
--- /dev/null
+++ b/test/LLVMC/together.cpp
@@ -0,0 +1,9 @@
+// Check that we can compile files of different types together.
+// RUN: llvmc %s %p/test_data/together.c -o %t
+// RUN: ./%t | grep hello
+
+extern "C" void test();
+
+int main() {
+ test();
+}
diff --git a/test/LLVMC/wall.c b/test/LLVMC/wall.c
new file mode 100644
index 0000000..2c72ea6
--- /dev/null
+++ b/test/LLVMC/wall.c
@@ -0,0 +1,12 @@
+/*
+ * Check that -Wall works as intended
+ * RUN: llvmc -Wall %s -o %t
+ * RUN: ./%t | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
OpenPOWER on IntegriCloud