@@ -789,6 +789,97 @@ TEST(MinimizeSourceToDependencyDirectivesTest,
789789 Out.data ());
790790}
791791
792+ TEST (MinimizeSourceToDependencyDirectivesTest,
793+ WhitespaceAfterLineContinuationSlashLineComment) {
794+ SmallVector<char , 128 > Out;
795+
796+ ASSERT_FALSE (minimizeSourceToDependencyDirectives (" // some comment \\ \n "
797+ " module A;\n " ,
798+ Out));
799+ EXPECT_STREQ (" " , Out.data ());
800+ }
801+
802+ TEST (MinimizeSourceToDependencyDirectivesTest,
803+ WhitespaceAfterLineContinuationSlashAllDirectives) {
804+ SmallVector<char , 512 > Out;
805+ SmallVector<dependency_directives_scan::Token, 16 > Tokens;
806+ SmallVector<Directive, 16 > Directives;
807+
808+ StringRef Input = " #define \\ \n "
809+ " A\n "
810+ " #undef\t\\ \n "
811+ " A\n "
812+ " #endif \\\t\t\n "
813+ " \n "
814+ " #if \\ \t\n "
815+ " A\n "
816+ " #ifdef\t\\ \n "
817+ " A\n "
818+ " #ifndef \\ \t\n "
819+ " A\n "
820+ " #elifdef \\ \n "
821+ " A\n "
822+ " #elifndef \\ \n "
823+ " A\n "
824+ " #elif \\\t\t \n "
825+ " A\n "
826+ " #else \\\t \t\n "
827+ " \n "
828+ " #include \\ \n "
829+ " <A>\n "
830+ " #include_next \\ \n "
831+ " <A>\n "
832+ " #__include_macros\\ \n "
833+ " <A>\n "
834+ " #import \\ \t\n "
835+ " <A>\n "
836+ " @import \\\t \n "
837+ " A;\n "
838+ " #pragma clang \\ \n "
839+ " module \\ \n "
840+ " import A\n "
841+ " #pragma \\ \n "
842+ " push_macro(A)\n "
843+ " #pragma \\\t \n "
844+ " pop_macro(A)\n "
845+ " #pragma \\ \n "
846+ " include_alias(<A>,\\ \n "
847+ " <B>)\n "
848+ " export \\ \n "
849+ " module m;\n "
850+ " import\t\\\t \n "
851+ " m;\n "
852+ " #pragma\t\\ \n "
853+ " clang\t\\ \t\n "
854+ " system_header\n " ;
855+ ASSERT_FALSE (
856+ minimizeSourceToDependencyDirectives (Input, Out, Tokens, Directives));
857+
858+ EXPECT_EQ (pp_define, Directives[0 ].Kind );
859+ EXPECT_EQ (pp_undef, Directives[1 ].Kind );
860+ EXPECT_EQ (pp_endif, Directives[2 ].Kind );
861+ EXPECT_EQ (pp_if, Directives[3 ].Kind );
862+ EXPECT_EQ (pp_ifdef, Directives[4 ].Kind );
863+ EXPECT_EQ (pp_ifndef, Directives[5 ].Kind );
864+ EXPECT_EQ (pp_elifdef, Directives[6 ].Kind );
865+ EXPECT_EQ (pp_elifndef, Directives[7 ].Kind );
866+ EXPECT_EQ (pp_elif, Directives[8 ].Kind );
867+ EXPECT_EQ (pp_else, Directives[9 ].Kind );
868+ EXPECT_EQ (pp_include, Directives[10 ].Kind );
869+ EXPECT_EQ (pp_include_next, Directives[11 ].Kind );
870+ EXPECT_EQ (pp___include_macros, Directives[12 ].Kind );
871+ EXPECT_EQ (pp_import, Directives[13 ].Kind );
872+ EXPECT_EQ (decl_at_import, Directives[14 ].Kind );
873+ EXPECT_EQ (pp_pragma_import, Directives[15 ].Kind );
874+ EXPECT_EQ (pp_pragma_push_macro, Directives[16 ].Kind );
875+ EXPECT_EQ (pp_pragma_pop_macro, Directives[17 ].Kind );
876+ EXPECT_EQ (pp_pragma_include_alias, Directives[18 ].Kind );
877+ EXPECT_EQ (cxx_export_module_decl, Directives[19 ].Kind );
878+ EXPECT_EQ (cxx_import_decl, Directives[20 ].Kind );
879+ EXPECT_EQ (pp_pragma_system_header, Directives[21 ].Kind );
880+ EXPECT_EQ (pp_eof, Directives[22 ].Kind );
881+ }
882+
792883TEST (MinimizeSourceToDependencyDirectivesTest, PoundWarningAndError) {
793884 SmallVector<char , 128 > Out;
794885
0 commit comments