owenpan added inline comments.

================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2707-2708
+  if (FormatTok->is(tok::l_brace)) {
+    CompoundStatementIndenter Indenter(this, Style, Line->Level);
+    FormatToken *LeftBrace = FormatTok;
+    parseBlock();
----------------
You swapped these two lines. We want to remember the `l_brace` before calling 
other functions in case they update `FormatTok`.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2743-2744
 
-  keepAncestorBraces();
-
-  if (FormatTok->is(tok::l_brace)) {
-    FormatToken *LeftBrace = FormatTok;
-    CompoundStatementIndenter Indenter(this, Style, Line->Level);
-    parseBlock();
-    if (Style.RemoveBracesLLVM) {
-      assert(!NestedTooDeep.empty());
-      if (!NestedTooDeep.back())
-        markOptionalBraces(LeftBrace);
-    }
-    addUnwrappedLine();
-  } else {
-    parseUnbracedBody();
-  }
-
-  if (Style.RemoveBracesLLVM)
-    NestedTooDeep.pop_back();
+  parseLoopBody(/*TryRemoveBraces=*/Style.RemoveBracesLLVM,
+                /*WrapRightBrace=*/true);
 }
----------------
Or just the following as they are not default arguments now:
```
  parseLoopBody(Style.RemoveBracesLLVM, true);
```


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2751
 
-  keepAncestorBraces();
-
-  if (FormatTok->is(tok::l_brace)) {
-    CompoundStatementIndenter Indenter(this, Style, Line->Level);
-    parseBlock();
-    if (Style.BraceWrapping.BeforeWhile)
-      addUnwrappedLine();
-  } else {
-    parseUnbracedBody();
-  }
-
-  if (Style.RemoveBracesLLVM)
-    NestedTooDeep.pop_back();
+  parseLoopBody(/*BracesAreoptional=*/false, Style.BraceWrapping.BeforeWhile);
 
----------------
Or just the following:
```
  parseLoopBody(false, Style.BraceWrapping.BeforeWhile);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121757

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

Reply via email to