diff options
Diffstat (limited to 'clang/test/Interpreter')
-rw-r--r-- | clang/test/Interpreter/pretty-print.c | 83 | ||||
-rw-r--r-- | clang/test/Interpreter/pretty-print.cpp | 73 |
2 files changed, 154 insertions, 2 deletions
diff --git a/clang/test/Interpreter/pretty-print.c b/clang/test/Interpreter/pretty-print.c index d21749a..56488a1 100644 --- a/clang/test/Interpreter/pretty-print.c +++ b/clang/test/Interpreter/pretty-print.c @@ -3,9 +3,88 @@ // RUN: cat %s | clang-repl -Xcc -xc | FileCheck %s // RUN: cat %s | clang-repl -Xcc -std=c++11 | FileCheck %s -// Fails with `Symbols not found: [ __clang_Interpreter_SetValueNoAlloc ]`. // UNSUPPORTED: hwasan + +char c = 'a'; c +// CHECK: (char) 'a' + const char* c_str = "Hello, world!"; c_str +// CHECK-NEXT: (const char *) "Hello, world!" + +c_str = "Goodbye, world!"; c_str +// CHECK-NEXT: (const char *) "Goodbye, world!" + +const char* c_null_str = 0; c_null_str +// CHECK-NEXT: (const char *) 0 + +"Hello, world" +// CHECK-NEXT: ({{(const )?}}char[13]) "Hello, world" + +int x = 42; x +// CHECK-NEXT: (int) 42 + +&x +// CHECK-NEXT: (int *) 0x{{[0-9a-f]+}} + +x - 2 +// CHECK-NEXT: (int) 40 + +float f = 4.2f; f +// CHECK-NEXT: (float) 4.20000f + +double d = 4.21; d +// CHECK-NEXT: (double) 4.2100000 + +long double tau = 6.2831853; tau +// CHECK-NEXT: (long double) 6.28318530000L + +int foo() { return 42; } foo() +// CHECK-NEXT: (int) 42 + +void bar(int a, float b) {} bar +// CHECK-NEXT: (void (int, float)) Function @0x{{[0-9a-f]+}} +// CHECK-NEXT: void bar(int a, float b) { + +bar +// CHECK: (void (int, float)) Function @0x{{[0-9a-f]+}} +// CHECK-NEXT: void bar(int a, float b) { + +// Arrays. + +int arr[3] = {1,2,3}; arr +// CHECK: (int[3]) { 1, 2, 3 } + +double darr[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; darr +// CHECK-NEXT: (double[3][4]) { { 1.0, 2.0, 3.0, 4.0 }, { 5.0, 6.0, 7.0, 8.0 }, { 9.0, 10.0, 11.0, 12.0 } } + +float farr[2][1] = { {0}, {3.14}}; farr +// CHECK-NEXT: (float[2][1]) { { 0.0f }, { 3.14000f } } + +0./0. +// CHECK-NEXT: (double) nan + +1.0f / 0.0f +// CHECK-NEXT: (float) inf + +0.00001f +// CHECK-NEXT: (float) 1.00000e-05f + +int * ptr = (int*)0x123; ptr +// CHECK-NEXT: (int *) 0x123 + +int * null_ptr = (int*)0; null_ptr +// CHECK-NEXT: (int *) 0x0 + +// TODO: _Bool, _Complex, _Atomic, and _BitInt +// union U { int I; float F; } u; u.I = 12; u.I +// TODO-CHECK-NEXT: (int) 12 +// struct S1{} s1; s1 +// TODO-CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}} + +// struct S2 {int d;} E = {22}; E +// TODO-CHECK-NEXT: (struct S2 &) @0x{{[0-9a-f]+}} +// E.d +// TODO-CHECK-NEXT: (int) 22 -// CHECK: Not implement yet. +%quit diff --git a/clang/test/Interpreter/pretty-print.cpp b/clang/test/Interpreter/pretty-print.cpp new file mode 100644 index 0000000..fd79d31 --- /dev/null +++ b/clang/test/Interpreter/pretty-print.cpp @@ -0,0 +1,73 @@ +// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \ +// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s +// UNSUPPORTED: system-aix +// CHECK-DRIVER: i = 10 +// RUN: cat %s | clang-repl -Xcc -std=c++11 -Xcc -fno-delayed-template-parsing | FileCheck %s +extern "C" int printf(const char*,...); + +"ab" +// CHECK: (const char[3]) "ab" + +123456 +// CHECK-NEXT: (int) 123456 + +char ch[2] = {'1','a'}; ch +// CHECK-NEXT: (char[2]) { '1', 'a' } + +char chnull[3] = {'1','a', '\0'}; chnull +// CHECK-NEXT: (char[3]) "1a" + +char ch_arr[2][3][1] = {{{'a'}, {'b'}, {'c'}}, {{'d'}, {'e'}, {'f'}}}; ch_arr +// CHECK: (char[2][3][1]) { { { 'a' }, { 'b' }, { 'c' } }, { { 'd' }, { 'e' }, { 'f' } } } +struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } }; +S3{} +// CHECK-NEXT: (S3) @0x{{[0-9a-f]+}} +S3 s3; +s3 +// CHECK-NEXT: (S3 &) @0x{{[0-9a-f]+}} + +struct S4 { ~S4() { printf("~S4()\n"); }}; +S4{} +// CHECK-NEXT: (S4) @0x{{[0-9a-f]+}} +// TODO-CHECK-NEXT: ~S4() + +enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33}; +e2 +// CHECK-NEXT: (Enum) (e2) : int -11 +::e1 +// CHECK-NEXT: (Enum) (e1) : int -12 + +enum class Color { R = 0, G, B }; +Color::R +// CHECK-NEXT: (Color) (Color::R) : int 0 + + +// Lambdas. + +auto Lambda1 = []{}; +Lambda1 +// CHECK-NEXT: ((lambda) &) @0x{{[0-9a-f]+}} +[]{} +// CHECK-NEXT: ((lambda at input_line_{{[0-9]+}}:1:1)) @0x{{[0-9a-f]+}} + +template<int n> struct F{ enum {RET=F<n-1>::RET*n} ; }; +template<> struct F<0> { enum {RET = 1}; }; +F<7>::RET +// CHECK-NEXT: (F<7>::(unnamed enum at input_line_{{[0-9]+}}:1:27)) (F<7>::RET) : unsigned int 5040 + +struct S5 { int foo() { return 42; }}; +&S5::foo +// CHECK-NEXT: (int (S5::*)()) Function @0x{{[0-9a-f]+}} + +// int i = 12; +// int &iref = i; +// iref +// // TODO-CHECK-NEXT: (int &) 12 + +// int &&rref = 100; +// rref + +// // TODO-CHECK-NEXT: (int &&) 100 + +%quit + |