[PATCH] D119226: [clang][lex][minimizer] Avoid treating path separators as comments
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 15 00:50:56 PST 2022
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119226.408744.patch
Type: text/x-patch
Size: 2071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220215/c8f69651/attachment.bin>
More information about the cfe-commits
mailing list