owenpan added a comment.

Moving the handling of empty record blocks might be NFC? Maybe option 4 for now 
and the refactoring in another patch?



================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:288
+    // Try to merge a control statement block with left brace unwrapped.
+    if (TheLine->Last->is(tok::l_brace) &&
         TheLine->First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for)) {
----------------
Is `TheLine->First != TheLine->Last` redundant?


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:310
+                   : 0;
+      }
+      if (TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
----------------
I don't think you can drop `else` here.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:317
+                   : 0;
+      }
+      if (TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&
----------------
Ditto.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:335-360
+      // Handle empty record blocks where the brace has already been wrapped.
+      if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last) {
+        bool EmptyBlock = NextLine.First->is(tok::r_brace);
+
+        const FormatToken *Tok = PreviousLine.First;
+        if (Tok && Tok->is(tok::comment))
+          Tok = Tok->getNextNonComment();
----------------
Handling empty record blocks here instead of earlier may have unknown side 
effects?


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

https://reviews.llvm.org/D115060

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to