[clang] [clang-format] Keep C++20 module/import decls on a single line (PR #199459)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 22:51:02 PDT 2026


================
@@ -1350,40 +1351,60 @@ static bool isC78ParameterDecl(const FormatToken *Tok, const FormatToken *Next,
   return Tok->Previous && Tok->Previous->isOneOf(tok::l_paren, tok::comma);
 }
 
-bool UnwrappedLineParser::parseModuleImport() {
-  assert(FormatTok->is(Keywords.kw_import) && "'import' expected");
+bool UnwrappedLineParser::parseModuleDecl() {
+  assert(IsCpp);
+  assert(FormatTok->is(Keywords.kw_module));
 
-  if (auto Token = Tokens->peekNextToken(/*SkipComment=*/true);
-      !Token->Tok.getIdentifierInfo() &&
-      Token->isNoneOf(tok::colon, tok::less, tok::string_literal)) {
+  if (Style.Language == FormatStyle::LK_C ||
----------------
owenca wrote:

Exactly. Objective-C/C++ has always been treated as a superset of C++, both before *and* after the `LK_C` implementation 0968df9c3a5562f6a8d9f7948065848f3a273b81. That's why we can't exclude `LK_ObjC` here.

https://github.com/llvm/llvm-project/pull/199459


More information about the cfe-commits mailing list