diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1634,10 +1634,18 @@ parseJavaScriptEs6ImportExport(); return; } - if (!Style.isCpp()) - break; - // Handle C++ "(inline|export) namespace". - [[fallthrough]]; + if (Style.isCpp()) { + nextToken(); + if (FormatTok->is(Keywords.kw_import)) { + parseModuleImport(); + return; + } + if (FormatTok->is(tok::kw_namespace)) { + parseNamespace(); + return; + } + } + break; case tok::kw_inline: nextToken(); if (FormatTok->is(tok::kw_namespace)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -25140,6 +25140,7 @@ verifyFormat("export module foo.bar;", Style); verifyFormat("export module foo.bar:baz;", Style); verifyFormat("export import ;", Style); + verifyFormat("export import ;", Style); verifyFormat("export type_name var;", Style); verifyFormat("template export using A = B;", Style);