[clang] [clang-format] TableGen multi line string support. (PR #78032)

Hirofumi Nakamura via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 04:42:12 PST 2024


================
@@ -274,13 +274,13 @@ void FormatTokenLexer::tryMergePreviousTokens() {
       return;
     }
   }
-  if (Style.isTableGen()) {
-    if (tryMergeTokens({tok::l_square, tok::l_brace},
-                       TT_TableGenMultiLineString)) {
-      // Multi line string starts with [{
-      Tokens.back()->Tok.setKind(tok::string_literal);
-      return;
-    }
+  // TableGen's Multi line string starts with [{
+  if (Style.isTableGen() && tryMergeTokens({tok::l_square, tok::l_brace},
+                                           TT_TableGenMultiLineString)) {
+    // This must never be annotated as other types.
+    Tokens.back()->setTypeIsFinalized();
----------------
hnakamura5 wrote:

This is to clarify the intention is only finalizing the merged token. And not setting type to something else.
How about that?

I know the both the plan does not differ so much. If you regards `setTypeIsFinalized()` is unsuitable API, I will change the way.

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


More information about the cfe-commits mailing list