summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Lex
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2019-09-19 22:39:24 +0000
committerAlex Lorenz <arphaman@gmail.com>2019-09-19 22:39:24 +0000
commitccf8d5b8292afd91e811c6657d73682da66f46f5 (patch)
tree224adda711c9012ebadbe2150a462794f77bf88f /clang/unittests/Lex
parent40c3d6e33590054f095b5adfcd62ddc3c5c58e69 (diff)
downloadbcm5719-llvm-ccf8d5b8292afd91e811c6657d73682da66f46f5.tar.gz
bcm5719-llvm-ccf8d5b8292afd91e811c6657d73682da66f46f5.zip
Fix for stringized function-macro args continued across lines
In case of certain #define'd macros, there's a space just before line continuation that the minimized-source lexer was missing to include, resulting in invalid stringize. Patch by: kousikk (Kousik Kumar) Differential Revision: https://reviews.llvm.org/D67635 llvm-svn: 372360
Diffstat (limited to 'clang/unittests/Lex')
-rw-r--r--clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp b/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
index 530519573a0..c00c160977e 100644
--- a/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ b/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -157,19 +157,19 @@ TEST(MinimizeSourceToDependencyDirectivesTest, DefineHorizontalWhitespace) {
ASSERT_FALSE(minimizeSourceToDependencyDirectives(
"#define MACRO(\t)\tcon \t tent\t", Out));
- EXPECT_STREQ("#define MACRO() con \t tent\n", Out.data());
+ EXPECT_STREQ("#define MACRO() con \t tent\t\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives(
"#define MACRO(\f)\fcon \f tent\f", Out));
- EXPECT_STREQ("#define MACRO() con \f tent\n", Out.data());
+ EXPECT_STREQ("#define MACRO() con \f tent\f\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives(
"#define MACRO(\v)\vcon \v tent\v", Out));
- EXPECT_STREQ("#define MACRO() con \v tent\n", Out.data());
+ EXPECT_STREQ("#define MACRO() con \v tent\v\n", Out.data());
ASSERT_FALSE(minimizeSourceToDependencyDirectives(
"#define MACRO \t\v\f\v\t con\f\t\vtent\v\f \v", Out));
- EXPECT_STREQ("#define MACRO con\f\t\vtent\n", Out.data());
+ EXPECT_STREQ("#define MACRO con\f\t\vtent\v\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest, DefineMultilineArgs) {
@@ -187,7 +187,7 @@ TEST(MinimizeSourceToDependencyDirectivesTest, DefineMultilineArgs) {
" call((a), \\\n"
" (b))",
Out));
- EXPECT_STREQ("#define MACRO(a,b) call((a),(b))\n", Out.data());
+ EXPECT_STREQ("#define MACRO(a,b) call((a), (b))\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest,
@@ -200,7 +200,17 @@ TEST(MinimizeSourceToDependencyDirectivesTest,
" call((a), \\\r"
" (b))",
Out));
- EXPECT_STREQ("#define MACRO(a,b) call((a),(b))\n", Out.data());
+ EXPECT_STREQ("#define MACRO(a,b) call((a), (b))\n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, DefineMultilineArgsStringize) {
+ SmallVector<char, 128> Out;
+
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#define MACRO(a,b) \\\n"
+ " #a \\\n"
+ " #b",
+ Out));
+ EXPECT_STREQ("#define MACRO(a,b) #a #b\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest,
@@ -213,7 +223,7 @@ TEST(MinimizeSourceToDependencyDirectivesTest,
" call((a), \\\r\n"
" (b))",
Out));
- EXPECT_STREQ("#define MACRO(a,b) call((a),(b))\n", Out.data());
+ EXPECT_STREQ("#define MACRO(a,b) call((a), (b))\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest,
@@ -226,7 +236,7 @@ TEST(MinimizeSourceToDependencyDirectivesTest,
" call((a), \\\n\r"
" (b))",
Out));
- EXPECT_STREQ("#define MACRO(a,b) call((a),(b))\n", Out.data());
+ EXPECT_STREQ("#define MACRO(a,b) call((a), (b))\n", Out.data());
}
TEST(MinimizeSourceToDependencyDirectivesTest, DefineNumber) {
OpenPOWER on IntegriCloud