From: Edward O'Callaghan Date: Tue, 27 Oct 2009 02:36:32 +0000 (+0000) Subject: Convert Preprocessor Clang tests to FileCheck in regards to PR5307. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b396a37a235b4d11da3520bc981f07419d7fc31b;p=clang Convert Preprocessor Clang tests to FileCheck in regards to PR5307. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85199 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Preprocessor/c99-6_10_3_4_p5.c b/test/Preprocessor/c99-6_10_3_4_p5.c index 22bdf8258c..08b2c42360 100644 --- a/test/Preprocessor/c99-6_10_3_4_p5.c +++ b/test/Preprocessor/c99-6_10_3_4_p5.c @@ -1,10 +1,5 @@ // Example from C99 6.10.3.4p5 - -// RUN: clang-cc -E %s | grep -F 'f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);' && -// RUN: clang-cc -E %s | grep -F 'f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);' && -// RUN: clang-cc -E %s | grep -F 'int i[] = { 1, 23, 4, 5, };' && -// RUN: clang-cc -E %s | grep -F 'char c[2][6] = { "hello", "" };' - +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s #define x 3 #define f(a) f(x * (a)) @@ -26,4 +21,8 @@ p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) }; char c[2][6] = { str(hello), str() }; +// CHECK: f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); +// CHECK: f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); +// CHECK: int i[] = { 1, 23, 4, 5, }; +// CHECK: char c[2][6] = { "hello", "" }; diff --git a/test/Preprocessor/c99-6_10_3_4_p6.c b/test/Preprocessor/c99-6_10_3_4_p6.c index c48d2efd2e..8072d7b87b 100644 --- a/test/Preprocessor/c99-6_10_3_4_p6.c +++ b/test/Preprocessor/c99-6_10_3_4_p6.c @@ -1,10 +1,6 @@ // Example from C99 6.10.3.4p6 -// RUN: clang-cc -E %s | grep -F 'printf("x" "1" "= %d, x" "2" "= s" x1, x2);' && -// RUN: clang-cc -E %s | grep 'fputs("strncmp(\\"abc\\\\0d\\" \\"abc\\", .\\\\4.) == 0" ": @\\n", s);' && -// RUN: clang-cc -E %s | grep -F 'include "vers2.h"' && -// RUN: clang-cc -E %s | grep -F '"hello";' && -// RUN: clang-cc -E %s | grep -F '"hello" ", world"' +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s #define str(s) # s #define xstr(s) str(s) @@ -22,3 +18,10 @@ include xstr(INCFILE(2).h) glue(HIGH, LOW); xglue(HIGH, LOW) + +// CHECK: printf("x" "1" "= %d, x" "2" "= s" x1, x2); +// CHECK: fputs("strncmp(\"abc\\0d\" \"abc\", '\\4') == 0" ": @\n", s); +// CHECK: include "vers2.h" +// CHECK: "hello"; +// CHECK: "hello" ", world" + diff --git a/test/Preprocessor/c99-6_10_3_4_p7.c b/test/Preprocessor/c99-6_10_3_4_p7.c index a53df8263f..6a7eb48173 100644 --- a/test/Preprocessor/c99-6_10_3_4_p7.c +++ b/test/Preprocessor/c99-6_10_3_4_p7.c @@ -1,9 +1,10 @@ // Example from C99 6.10.3.4p7 -// RUN: clang-cc -E %s | grep -F 'int j[] = { 123, 45, 67, 89,' && -// RUN: clang-cc -E %s | grep -F '10, 11, 12, };' +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s #define t(x,y,z) x ## y ## z int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), t(10,,), t(,11,), t(,,12), t(,,) }; +// CHECK: int j[] = { 123, 45, 67, 89, +// CHECK: 10, 11, 12, }; diff --git a/test/Preprocessor/c99-6_10_3_4_p9.c b/test/Preprocessor/c99-6_10_3_4_p9.c index 39c34546ad..704241e46e 100644 --- a/test/Preprocessor/c99-6_10_3_4_p9.c +++ b/test/Preprocessor/c99-6_10_3_4_p9.c @@ -1,16 +1,20 @@ // Example from C99 6.10.3.4p9 -// RUN: clang-cc -E %s | grep -F 'fprintf(stderr, "Flag");' && -// RUN: clang-cc -E %s | grep -F 'fprintf(stderr, "X = %d\n", x);' && -// RUN: clang-cc -E %s | grep -F 'puts("The first, second, and third items.");' && -// RUN: clang-cc -E %s | grep -F '((x>y)?puts("x>y"): printf("x is %d but y is %d", x, y));' +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s #define debug(...) fprintf(stderr, __VA_ARGS__) #define showlist(...) puts(#__VA_ARGS__) #define report(test, ...) ((test)?puts(#test):\ printf(__VA_ARGS__)) -debug("Flag"); -debug("X = %d\n", x); -showlist(The first, second, and third items.); -report(x>y, "x is %d but y is %d", x, y); +debug("Flag"); +// CHECK: fprintf(stderr, "Flag"); + +debug("X = %d\n", x); +// CHECK: fprintf(stderr, "X = %d\n", x); + +showlist(The first, second, and third items.); +// CHECK: puts("The first, second, and third items."); + +report(x>y, "x is %d but y is %d", x, y); +// CHECK: ((x>y)?puts("x>y"): printf("x is %d but y is %d", x, y)); diff --git a/test/Preprocessor/comment_save.c b/test/Preprocessor/comment_save.c index 30b043433c..ae609b117e 100644 --- a/test/Preprocessor/comment_save.c +++ b/test/Preprocessor/comment_save.c @@ -1,7 +1,8 @@ -// RUN: clang-cc -E -C %s | grep '^// foo$' && -// RUN: clang-cc -E -C %s | grep -F '^/* bar */$' +// RUN: clang-cc -E -C %s | FileCheck -strict-whitespace %s // foo -/* bar */ +// CHECK: // foo +/* bar */ +// CHECK: /* bar */ diff --git a/test/Preprocessor/comment_save_macro.c b/test/Preprocessor/comment_save_macro.c index 66b59d136d..06066d21d5 100644 --- a/test/Preprocessor/comment_save_macro.c +++ b/test/Preprocessor/comment_save_macro.c @@ -1,6 +1,11 @@ -// RUN: clang-cc -E -C %s | grep '^boo bork bar // zot$' && -// RUN: clang-cc -E -CC %s | grep -F '^boo bork /* blah*/ bar // zot$' && -// RUN: clang-cc -E %s | grep '^boo bork bar$' +// RUN: clang-cc -E -C %s | FileCheck -strict-whitespace %s +// CHECK: boo bork bar // zot + +// RUN: clang-cc -E -CC %s | FileCheck -strict-whitespace %s +// CHECK: boo bork /* blah*/ bar // zot + +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s +// CHECK: boo bork bar #define FOO bork // blah diff --git a/test/Preprocessor/macro_paste_mscomment.c b/test/Preprocessor/macro_paste_mscomment.c index d6ead91068..ecd0b9d6a8 100644 --- a/test/Preprocessor/macro_paste_mscomment.c +++ b/test/Preprocessor/macro_paste_mscomment.c @@ -1,5 +1,4 @@ -// RUN: clang-cc -P -E -fms-extensions %s | sed '/^#.\+/d' | tr -d '\n' > %t && -// RUN: grep '^int foo;int bar;int baz;$' %t | count 1 +// RUN: clang-cc -P -E -fms-extensions %s | FileCheck -strict-whitespace %s // This horrible stuff should preprocess into (other than whitespace): // int foo; // int bar; @@ -7,14 +6,21 @@ int foo; +// CHECK: int foo; + #define comment /##/ dead tokens live here comment This is stupidity int bar; +// CHECK: int bar; + #define nested(x) int x comment cute little dead tokens... nested(baz) rise of the dead tokens ; +// CHECK: int baz +// CHECK: ; + diff --git a/test/Preprocessor/macro_rescan_varargs.c b/test/Preprocessor/macro_rescan_varargs.c index ed1056ab1b..8a3ad15114 100644 --- a/test/Preprocessor/macro_rescan_varargs.c +++ b/test/Preprocessor/macro_rescan_varargs.c @@ -1,5 +1,5 @@ -// RUN: clang-cc -E %s | grep -F "1: F, (, 'a', 'b', );" && -// RUN: clang-cc -E %s | grep -F "2: 'a' + 'b';" +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s + #define LPAREN ( #define RPAREN ) #define F(x, y) x + y @@ -8,3 +8,6 @@ 1: ELLIP_FUNC(F, LPAREN, 'a', 'b', RPAREN); /* 1st invocation */ 2: ELLIP_FUNC(F LPAREN 'a', 'b' RPAREN); /* 2nd invocation */ +// CHECK: 1: F, (, 'a', 'b', ); +// CHECK: 2: 'a' + 'b'; + diff --git a/test/Preprocessor/output_paste_avoid.c b/test/Preprocessor/output_paste_avoid.c index ff8afc3e47..4a15094998 100644 --- a/test/Preprocessor/output_paste_avoid.c +++ b/test/Preprocessor/output_paste_avoid.c @@ -1,23 +1,26 @@ -// RUN: clang-cc -E %s -o %t && -// This should print as ".. ." to avoid turning into ... -// RUN: grep -F 'A: . . .' %t && +// RUN: clang-cc -E %s -o %t | FileCheck -strict-whitespace %s + + #define y(a) ..a A: y(.) +// This should print as ".. ." to avoid turning into ... +// CHECK: A: . . . + -// RUN: grep -F 'C: .. .' %t && #define DOT . C: ..DOT +// CHECK: C: .. . -// RUN: grep -F 'D: + + - - + + = = =' %t && #define PLUS + #define EMPTY #define f(x) =x= D: +PLUS -EMPTY- PLUS+ f(=) +// CHECK: D: + + - - + + = = = -// RUN: grep -F 'E: L "str"' %t -// Should expand to L "str" not L"str" #define test(x) L#x E: test(str) +// Should expand to L "str" not L"str" +// CHECK: E: L "str" diff --git a/test/Preprocessor/stringize_misc.c b/test/Preprocessor/stringize_misc.c index 251116acad..60d66a0061 100644 --- a/test/Preprocessor/stringize_misc.c +++ b/test/Preprocessor/stringize_misc.c @@ -1,20 +1,23 @@ -// RUN: clang-cc -E %s | grep -F '"f(1, 2)" "g((x=y++, y))"' && -// RUN: clang-cc -E %s | grep -F '"{a=1" "b=2;}"' && -// RUN: clang-cc -E %s | grep -F '"<" "["' && -// RUN: clang-cc -E %s | grep -F '"(,)" "(...)"' && -// RUN: clang-cc -E %s | grep -F '{a=1 c=3; b=2;}' && -// RUN: clang-cc -E %s | grep -F '"a COMMA b" "(a, b)"' +// RUN: clang-cc -E %s | FileCheck -strict-whitespace %s #define M(x, y) #x #y M( f(1, 2), g((x=y++, y))) +// CHECK: "f(1, 2)" "g((x=y++, y))" + M( {a=1 , b=2;} ) /* A semicolon is not a comma */ +// CHECK: "{a=1" "b=2;}" + M( <, [ ) /* Passes the arguments < and [ */ +// CHECK: "<" "[" + M( (,), (...) ) /* Passes the arguments (,) and (...) */ +// CHECK: "(,)" "(...)" #define START_END(start, end) start c=3; end START_END( {a=1 , b=2;} ) /* braces are not parentheses */ +// CHECK: {a=1 c=3; b=2;} /* * To pass a comma token as an argument it is @@ -23,4 +26,5 @@ START_END( {a=1 , b=2;} ) /* braces are not parentheses */ #define COMMA , M(a COMMA b, (a, b)) +// CHECK: "a COMMA b" "(a, b)"