This revision was automatically updated to reflect the committed changes. Closed by commit rGd8298f04a968: [clang][lex][minimizer] Avoid treating path separators as comments (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119226/new/ https://reviews.llvm.org/D119226 Files: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp =================================================================== --- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp +++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp @@ -453,6 +453,14 @@ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#include <A>\n", Out)); EXPECT_STREQ("#include <A>\n", Out.data()); + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#include <A//A.h>\n", Out)); + EXPECT_STREQ("#include <A//A.h>\n", Out.data()); + + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#include \"A//A.h\"\n", Out)); + EXPECT_STREQ("#include \"A//A.h\"\n", Out.data()); + ASSERT_FALSE( minimizeSourceToDependencyDirectives("#include_next <A>\n", Out)); EXPECT_STREQ("#include_next <A>\n", Out.data()); @@ -460,6 +468,13 @@ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import <A>\n", Out)); EXPECT_STREQ("#import <A>\n", Out.data()); + ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import <A//A.h>\n", Out)); + EXPECT_STREQ("#import <A//A.h>\n", Out.data()); + + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#import \"A//A.h\"\n", Out)); + EXPECT_STREQ("#import \"A//A.h\"\n", Out.data()); + ASSERT_FALSE( minimizeSourceToDependencyDirectives("#__include_macros <A>\n", Out)); EXPECT_STREQ("#__include_macros <A>\n", Out.data()); Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp =================================================================== --- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp +++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp @@ -401,7 +401,7 @@ do { // Iterate over strings correctly to avoid comments and newlines. if (*Last == '"' || *Last == '\'' || - (*Last == '<' && top() == pp_include)) { + (*Last == '<' && (top() == pp_include || top() == pp_import))) { if (LLVM_UNLIKELY(isRawStringLiteral(First, Last))) skipRawString(Last, End); else
Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp =================================================================== --- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp +++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp @@ -453,6 +453,14 @@ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#include <A>\n", Out)); EXPECT_STREQ("#include <A>\n", Out.data()); + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#include <A//A.h>\n", Out)); + EXPECT_STREQ("#include <A//A.h>\n", Out.data()); + + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#include \"A//A.h\"\n", Out)); + EXPECT_STREQ("#include \"A//A.h\"\n", Out.data()); + ASSERT_FALSE( minimizeSourceToDependencyDirectives("#include_next <A>\n", Out)); EXPECT_STREQ("#include_next <A>\n", Out.data()); @@ -460,6 +468,13 @@ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import <A>\n", Out)); EXPECT_STREQ("#import <A>\n", Out.data()); + ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import <A//A.h>\n", Out)); + EXPECT_STREQ("#import <A//A.h>\n", Out.data()); + + ASSERT_FALSE( + minimizeSourceToDependencyDirectives("#import \"A//A.h\"\n", Out)); + EXPECT_STREQ("#import \"A//A.h\"\n", Out.data()); + ASSERT_FALSE( minimizeSourceToDependencyDirectives("#__include_macros <A>\n", Out)); EXPECT_STREQ("#__include_macros <A>\n", Out.data()); Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp =================================================================== --- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp +++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp @@ -401,7 +401,7 @@ do { // Iterate over strings correctly to avoid comments and newlines. if (*Last == '"' || *Last == '\'' || - (*Last == '<' && top() == pp_include)) { + (*Last == '<' && (top() == pp_include || top() == pp_import))) { if (LLVM_UNLIKELY(isRawStringLiteral(First, Last))) skipRawString(Last, End); else
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits