[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 11 02:21:35 PDT 2018


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/Format/TokenAnnotator.cpp:773
     case tok::r_brace:
-      // Lines can start with '}'.
-      if (Tok->Previous)
+      // Lines can start with '}' except in text protos.
+      if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
----------------
krasimir wrote:
> sammccall wrote:
> > In what sense of "line" is this true?
> This is the UnwrappedLine concept of clang-format: roughly a maximal sequence of tokens that we could have put on the same line if there was no column limit.
I still don't understand why it's true for say C or JS then.
(kinda relevant here because I would like to understand why proto is an exception)


================
Comment at: unittests/Format/FormatTestProto.cpp:21
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
----------------
DoNotCheck is never used, consider removing it


================
Comment at: unittests/Format/FormatTestProto.cpp:21
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+
----------------
sammccall wrote:
> DoNotCheck is never used, consider removing it
(nit: is the SC_ prefix really needed in tests?)


Repository:
  rC Clang

https://reviews.llvm.org/D44203





More information about the cfe-commits mailing list