[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 22 17:47:39 PST 2021


owenpan added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:398-400
+      if (Tok && Tok->is(tok::kw_typedef))
+        Tok = Tok->getNextNonComment();
+      if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
----------------
Nits:
- It's unnecessary to add the checking for a null `TheLine->First` on line 398 since `TheLine->Last` is nonnull.
- The suggested `assert` is optional.
- Since the first token is `typedef` and the last `{`, checking for a null `Tok` on line 400 is unnecessary.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:404
                        !Style.BraceWrapping.SplitEmptyRecord);
+      } else if (Tok && Tok->is(tok::kw_enum)) {
+        ShouldMerge = Style.AllowShortEnumsOnASingleLine;
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116188



More information about the cfe-commits mailing list