diff --git a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
--- a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ b/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
diff --git a/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp b/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
--- a/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ b/clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -453,6 +453,14 @@
ASSERT_FALSE(minimizeSourceToDependencyDirectives("#include \n", Out));
EXPECT_STREQ("#include \n", Out.data());
+ ASSERT_FALSE(
+ minimizeSourceToDependencyDirectives("#include \n", Out));
+ EXPECT_STREQ("#include \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 \n", Out));
EXPECT_STREQ("#include_next \n", Out.data());
@@ -460,6 +468,13 @@
ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import \n", Out));
EXPECT_STREQ("#import \n", Out.data());
+ ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import \n", Out));
+ EXPECT_STREQ("#import \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 \n", Out));
EXPECT_STREQ("#__include_macros \n", Out.data());