[PATCH] D45726: Format closing braces when reformatting the line containing theopening brace.This required a couple of yaks to be shaved:1. MatchingOpeningBlockLineIndex was misused to also store the closing index; instead, use a second variable, as this...

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 19 03:13:28 PDT 2018


krasimir added a comment.

Great patch!



================
Comment at: lib/Format/AffectedRangeManager.cpp:144
+      Line->First->is(tok::r_brace) &&
+      Line->MatchingOpeningBlockLineIndex != -1 &&
+      Lines[Line->MatchingOpeningBlockLineIndex]->Affected;
----------------
nit: replace `-1` with `UnwrappedLine::kInvalidIndex`


================
Comment at: lib/Format/UnwrappedLineParser.h:58
+
+  /// \brief The corresponding closing line to MatchingOpeningBlockLineIndex.
+  size_t MatchingClosingBlockLineIndex = kInvalidIndex;
----------------
This comment could be improved. I interpret it as: start with the line at `MatchingOpeningBlockLineIndex`, and store the closing block line index of it, which will result in just the index of the current line being stored here if it closes a block.


Repository:
  rC Clang

https://reviews.llvm.org/D45726





More information about the cfe-commits mailing list