[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 12:16:46 PST 2024


================
@@ -833,13 +885,207 @@ class AnnotatingParser {
         Left->setType(TT_ArrayInitializerLSquare);
       }
       FormatToken *Tok = CurrentToken;
+      if (Style.isTableGen()) {
+        if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) {
+          // '-' and '...' appears as a separator in slice.
+          next();
+        } else {
+          // In TableGen there must be a list of Values in square brackets.
+          // It must be ValueList or SliceElements.
+          if (!parseTableGenValue())
+            return false;
+        }
+        updateParameterCount(Left, Tok);
+        continue;
+      }
       if (!consumeToken())
         return false;
       updateParameterCount(Left, Tok);
     }
     return false;
   }
 
+  void nextTableGenNonComment() {
+    next();
+    while (CurrentToken && CurrentToken->is(tok::comment))
+      next();
+  }
+
+  bool parseTableGenValue(bool ParseNameMode = false) {
----------------
HazardyKnusperkeks wrote:

But it is still not clear what the meaning of the return value is.
If the function was called `tryToParseTableGenValue` that would be different.

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


More information about the cfe-commits mailing list