[clang] [clang-format] Don't break module names (PR #193834)

via cfe-commits cfe-commits at lists.llvm.org
Sun May 3 20:08:39 PDT 2026


=?utf-8?q?Björn_Schäpers?= <bjoern at hazardy.de>,
=?utf-8?q?Björn_Schäpers?= <bjoern at hazardy.de>,
=?utf-8?q?Björn_Schäpers?= <bjoern at hazardy.de>,
=?utf-8?q?Björn_Schäpers?= <bjoern at hazardy.de>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/193834 at github.com>


================
@@ -1359,29 +1359,21 @@ bool UnwrappedLineParser::parseModuleImport() {
     return false;
   }
 
-  nextToken();
-  while (!eof()) {
-    if (FormatTok->is(tok::colon)) {
-      FormatTok->setFinalizedType(TT_ModulePartitionColon);
-    }
+  for (nextToken(); !eof(); nextToken()) {
     // Handle import <foo/bar.h> as we would an include statement.
-    else if (FormatTok->is(tok::less)) {
-      nextToken();
-      while (FormatTok->isNoneOf(tok::semi, tok::greater) && !eof()) {
-        // Mark tokens up to the trailing line comments as implicit string
-        // literals.
-        if (FormatTok->isNot(tok::comment) &&
-            !FormatTok->TokenText.starts_with("//")) {
-          FormatTok->setFinalizedType(TT_ImplicitStringLiteral);
-        }
-        nextToken();
+    if (FormatTok->is(tok::less)) {
+
+      for (nextToken(); FormatTok->isNoneOf(tok::semi, tok::greater) && !eof();
+           nextToken()) {
----------------
owenca wrote:

```suggestion
      for (nextToken(); FormatTok->isNoneOf(tok::semi, tok::eof); nextToken()) {
        if (FormatTok->is(tok::greater)) {
          nextToken();
          break;
        }
```

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


More information about the cfe-commits mailing list