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

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 12:29:06 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();
----------------
HazardyKnusperkeks wrote:

I wouldn't add that function, it is so specific. Normally you set the type.

Most likely `tryMergeTokens` should just be refactored to call `setFinalizedType`, that types may change happens only in the `TokenAnnotator` all prior set types shouldn't change.

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


More information about the cfe-commits mailing list