aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2019-07-10 22:00:59 +0000
committerAlex Lorenz <arphaman@gmail.com>2019-07-10 22:00:59 +0000
commitacd38fa683686672cfbed237c242009d30f696d4 (patch)
treeae3c437167e15abf10b4bd9c81a7cc6b0a9d1d83 /unittests
parentfa50bf0cf89f59254ae0969e936c597ec1da78b9 (diff)
[clang-scan-deps] Dependency directives source minimizer:
single quotes are not digit separators after a valid character literal prefix The single quote character can act as a c++ digit separator. However, the minimizer shouldn't treat it as such when it's actually following a valid character literal prefix, like L, U, u, or u8. Differential Revision: https://reviews.llvm.org/D64525 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365700 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp b/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
index d13723bdd1..cfa3ec91e0 100644
--- a/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ b/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -507,4 +507,41 @@ int c = 12 ' ';
EXPECT_STREQ("#include <bob>\n#include <foo>\n", Out.data());
}
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixL) {
+ SmallVector<char, 128> Out;
+
+ StringRef Source = R"(L'P'
+#if DEBUG
+// '
+#endif
+#include <test.h>
+)";
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+ EXPECT_STREQ("#include <test.h>\n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixU) {
+ SmallVector<char, 128> Out;
+
+ StringRef Source = R"(int x = U'P';
+#include <test.h>
+// '
+)";
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+ EXPECT_STREQ("#include <test.h>\n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixu) {
+ SmallVector<char, 128> Out;
+
+ StringRef Source = R"(int x = u'b';
+int y = u8'a';
+int z = 128'78;
+#include <test.h>
+// '
+)";
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+ EXPECT_STREQ("#include <test.h>\n", Out.data());
+}
+
} // end anonymous namespace