summaryrefslogtreecommitdiffstats
path: root/clang/test/Preprocessor
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-09-19 00:41:32 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-09-19 00:41:32 +0000
commit0834a4b90139341eacdfff167b052595a95cf2e5 (patch)
treefaeeee0d2c1fa35cfaf80c16b4e4ff862e749a85 /clang/test/Preprocessor
parent5cc15addbec0797e8c8e2b8dc099415762b4b8de (diff)
downloadbcm5719-llvm-0834a4b90139341eacdfff167b052595a95cf2e5.tar.gz
bcm5719-llvm-0834a4b90139341eacdfff167b052595a95cf2e5.zip
Make Preprocessor::Lex non-recursive.
Before this patch, Lex() would recurse whenever the current lexer changed (e.g. upon entry into a macro). This patch turns the recursion into a loop: the various lex routines now don't return a token when the current lexer changes, and at the top level Preprocessor::Lex() now loops until it finds a token. Normally, the recursion wouldn't end up being very deep, but the recursion depth can explode in edge cases like a bunch of consecutive macros which expand to nothing (like in the testcase test/Preprocessor/macro_expand_empty.c in this patch). <rdar://problem/14569770> llvm-svn: 190980
Diffstat (limited to 'clang/test/Preprocessor')
-rw-r--r--clang/test/Preprocessor/hash_line.c13
-rw-r--r--clang/test/Preprocessor/macro_expand_empty.c14
2 files changed, 21 insertions, 6 deletions
diff --git a/clang/test/Preprocessor/hash_line.c b/clang/test/Preprocessor/hash_line.c
index 64edae0d957..c4de9f04044 100644
--- a/clang/test/Preprocessor/hash_line.c
+++ b/clang/test/Preprocessor/hash_line.c
@@ -1,11 +1,12 @@
// The 1 and # should not go on the same line.
// RUN: %clang_cc1 -E %s | FileCheck --strict-whitespace %s
-// CHECK-NOT: 1{{.*}}#
// CHECK: {{^1$}}
-// CHECK-NOT: 1{{.*}}#
-// CHECK: {{^ #$}}
-// CHECK-NOT: 1{{.*}}#
-1
+// CHECK-NEXT: {{^ #$}}
+// CHECK-NEXT: {{^2$}}
+// CHECK-NEXT: {{^ #$}}
#define EMPTY
+#define IDENTITY(X) X
+1
EMPTY #
-
+2
+IDENTITY() #
diff --git a/clang/test/Preprocessor/macro_expand_empty.c b/clang/test/Preprocessor/macro_expand_empty.c
new file mode 100644
index 00000000000..3fb6394dc9e
--- /dev/null
+++ b/clang/test/Preprocessor/macro_expand_empty.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// Check that this doesn't crash
+
+#define IDENTITY1(x) x
+#define IDENTITY2(x) IDENTITY1(x) IDENTITY1(x) IDENTITY1(x) IDENTITY1(x)
+#define IDENTITY3(x) IDENTITY2(x) IDENTITY2(x) IDENTITY2(x) IDENTITY2(x)
+#define IDENTITY4(x) IDENTITY3(x) IDENTITY3(x) IDENTITY3(x) IDENTITY3(x)
+#define IDENTITY5(x) IDENTITY4(x) IDENTITY4(x) IDENTITY4(x) IDENTITY4(x)
+#define IDENTITY6(x) IDENTITY5(x) IDENTITY5(x) IDENTITY5(x) IDENTITY5(x)
+#define IDENTITY7(x) IDENTITY6(x) IDENTITY6(x) IDENTITY6(x) IDENTITY6(x)
+#define IDENTITY8(x) IDENTITY7(x) IDENTITY7(x) IDENTITY7(x) IDENTITY7(x)
+#define IDENTITY9(x) IDENTITY8(x) IDENTITY8(x) IDENTITY8(x) IDENTITY8(x)
+#define IDENTITY0(x) IDENTITY9(x) IDENTITY9(x) IDENTITY9(x) IDENTITY9(x)
+IDENTITY0()
OpenPOWER on IntegriCloud