[PATCH] D121753: [clang-format] Use a macro for non-C keywords

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 16 13:46:31 PDT 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/FormatToken.h:907
+  KEYWORD(infer, 0)                                                            \
+  KEYWORD(is, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD | ATTR_CSHARP_KEYWORD)     \
+  KEYWORD(let, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)                          \
----------------
Doubled


================
Comment at: clang/lib/Format/FormatToken.h:911
+  KEYWORD(readonly,                                                            \
+          ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD | ATTR_CSHARP_KEYWORD)         \
+  KEYWORD(set, ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD)                          \
----------------
Doubled


================
Comment at: clang/lib/Format/FormatToken.h:924
+  KEYWORD(interface,                                                           \
+          ATTR_JS_KEYWORD | ATTR_CSHARP_KEYWORD | ATTR_CSHARP_KEYWORD)         \
+  KEYWORD(native, 0)                                                           \
----------------
doubled


================
Comment at: clang/lib/Format/FormatToken.h:947
+  /* C# */                                                                     \
+  KEYWORD(dollar, 0)                                                           \
+  KEYWORD(base, ATTR_CSHARP_KEYWORD)                                           \
----------------
Why not CSharp?


================
Comment at: clang/lib/Format/FormatToken.h:992-999
+  enum {
+    ATTR_JS_KEYWORD = 0x1,
+    ATTR_CSHARP_KEYWORD = 0x2,
+  };
+  unsigned getAttrs(const FormatToken &Tok) const {
+    auto At = KeywordAttr.find(Tok.Tok.getIdentifierInfo());
+    return At == KeywordAttr.end() ? 0u : At->second;
----------------
No fan of DEFINE_LIKE_NAMES. More a fan of scoped::enums. ;)


================
Comment at: clang/lib/Format/FormatToken.h:1149
-    case tok::identifier: {
-      // For identifiers, make sure they are true identifiers, excluding the
-      // JavaScript pseudo-keywords (not lexed by LLVM/clang as keywords).
----------------
Keep the comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:115
       // Handle Qt signals.
-      else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) &&
+      else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_Q_SIGNALS) &&
                 RootToken.Next && RootToken.Next->is(tok::colon)))
----------------
I can live with that, but the former was nicer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121753/new/

https://reviews.llvm.org/D121753



More information about the cfe-commits mailing list