[PATCH] D34441: [clang-format] Support text proto messages

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 30 07:22:45 PDT 2017


djasper added inline comments.


================
Comment at: lib/Format/ContinuationIndenter.cpp:71
+                                       const FormatStyle &Style) {
+  assert(LessTok.is(tok::less));
+  return Style.Language == FormatStyle::LK_TextProto ||
----------------
Maybe rename to opensProtoMessageField() and add:

  if (!LessTok.is(tok::less))
    return false;


================
Comment at: lib/Format/ContinuationIndenter.cpp:107
 
+  if (Style.Language == FormatStyle::LK_TextProto) {
+    State.Stack.back().AvoidBinPacking = true;
----------------
Do we need to set this explicitly here? Is it not enough to set FormatStyle.BinPackParameters to false?


================
Comment at: lib/Format/TokenAnnotator.cpp:657
+        if (Style.Language == FormatStyle::LK_TextProto) {
+          FormatToken *Previous =Tok->getPreviousNonComment();
+          if (Previous && Previous->Type != TT_DictLiteral)
----------------
Missing space...


================
Comment at: lib/Format/UnwrappedLineParser.cpp:1360
   bool HasError = false;
-  nextToken();
+  if (!StartInside) nextToken();
 
----------------
Why not just call nextToken before calling this function instead of adding the "StartInside" parameter?


https://reviews.llvm.org/D34441





More information about the cfe-commits mailing list