owenpan created this revision. owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, curdeius. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fixes https://github.com/llvm/llvm-project/issues/57798. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D134700 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25048,6 +25048,7 @@ verifyFormat("export module foo.bar;", Style); verifyFormat("export module foo.bar:baz;", Style); verifyFormat("export import <string_view>;", Style); + verifyFormat("export import <Foo/Bar>;", Style); verifyFormat("export type_name var;", Style); verifyFormat("template <class T> export using A = B<T>;", Style); Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ 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)) {
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25048,6 +25048,7 @@ verifyFormat("export module foo.bar;", Style); verifyFormat("export module foo.bar:baz;", Style); verifyFormat("export import <string_view>;", Style); + verifyFormat("export import <Foo/Bar>;", Style); verifyFormat("export type_name var;", Style); verifyFormat("template <class T> export using A = B<T>;", Style); Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ 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)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits