|
@@ -594,6 +594,50 @@ TEST(MinimizeSourceToDependencyDirectivesTest, PragmaOnce) {
|
|
EXPECT_STREQ("#pragma once\n#include <test.h>\n", Out.data());
|
|
EXPECT_STREQ("#pragma once\n#include <test.h>\n", Out.data());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+TEST(MinimizeSourceToDependencyDirectivesTest,
|
|
|
|
+ SkipLineStringCharLiteralsUntilNewline) {
|
|
|
|
+ SmallVector<char, 128> Out;
|
|
|
|
+
|
|
|
|
+ StringRef Source = R"(#if NEVER_ENABLED
|
|
|
|
+ #define why(fmt, ...) #error don't try me
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+ void foo();
|
|
|
|
+)";
|
|
|
|
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
|
|
|
|
+ EXPECT_STREQ(
|
|
|
|
+ "#if NEVER_ENABLED\n#define why(fmt,...) #error don't try me\n#endif\n",
|
|
|
|
+ Out.data());
|
|
|
|
+
|
|
|
|
+ Source = R"(#if NEVER_ENABLED
|
|
|
|
+ #define why(fmt, ...) "quote dropped
|
|
|
|
+ #endif
|
|
|
|
+
|
|
|
|
+ void foo();
|
|
|
|
+ )";
|
|
|
|
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
|
|
|
|
+ EXPECT_STREQ(
|
|
|
|
+ "#if NEVER_ENABLED\n#define why(fmt,...) \"quote dropped\n#endif\n",
|
|
|
|
+ Out.data());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TEST(MinimizeSourceToDependencyDirectivesTest,
|
|
|
|
+ SupportWhitespaceBeforeLineContinuationInStringSkipping) {
|
|
|
|
+ SmallVector<char, 128> Out;
|
|
|
|
+
|
|
|
|
+ StringRef Source = "#define X '\\ \t\nx'\nvoid foo() {}";
|
|
|
|
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
|
|
|
|
+ EXPECT_STREQ("#define X '\\ \t\nx'\n", Out.data());
|
|
|
|
+
|
|
|
|
+ Source = "#define X \"\\ \r\nx\"\nvoid foo() {}";
|
|
|
|
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
|
|
|
|
+ EXPECT_STREQ("#define X \"\\ \r\nx\"\n", Out.data());
|
|
|
|
+
|
|
|
|
+ Source = "#define X \"\\ \r\nx\n#include <x>\n";
|
|
|
|
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
|
|
|
|
+ EXPECT_STREQ("#define X \"\\ \r\nx\n#include <x>\n", Out.data());
|
|
|
|
+}
|
|
|
|
+
|
|
TEST(MinimizeSourceToDependencyDirectivesTest, CxxModules) {
|
|
TEST(MinimizeSourceToDependencyDirectivesTest, CxxModules) {
|
|
SmallVector<char, 128> Out;
|
|
SmallVector<char, 128> Out;
|
|
SmallVector<Token, 4> Tokens;
|
|
SmallVector<Token, 4> Tokens;
|