Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/lib/Lex/DependencyDirectivesScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,13 @@ bool Scanner::lexModule(const char *&First, const char *const End) {
return false;
break;
}
case ';': {
// Handle the global module fragment `module;`.
if (Id == "module" && !Export)
break;
skipLine(First, End);
return false;
}
case '<':
case '"':
break;
Expand Down
9 changes: 5 additions & 4 deletions clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,16 +1122,17 @@ ort \
)";
ASSERT_FALSE(
minimizeSourceToDependencyDirectives(Source, Out, Tokens, Directives));
EXPECT_STREQ("#include \"textual-header.h\"\nexport module m;"
EXPECT_STREQ("module;#include \"textual-header.h\"\nexport module m;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a \n after the module; so that #include starts on a new line.

"exp\\\nort import:l[[rename]];"
"import<<=3;import a b d e d e f e;"
"import foo[[no_unique_address]];import foo();"
"import f(:sefse);import f(->a=3);"
"<TokBeforeEOF>\n",
Out.data());
ASSERT_EQ(Directives.size(), 11u);
EXPECT_EQ(Directives[0].Kind, pp_include);
EXPECT_EQ(Directives[1].Kind, cxx_export_module_decl);
ASSERT_EQ(Directives.size(), 12u);
EXPECT_EQ(Directives[0].Kind, cxx_module_decl);
EXPECT_EQ(Directives[1].Kind, pp_include);
EXPECT_EQ(Directives[2].Kind, cxx_export_module_decl);
}

TEST(MinimizeSourceToDependencyDirectivesTest, ObjCMethodArgs) {
Expand Down
Loading