[PATCH] D42376: [clang-format] Ignore UnbreakableTailLength sometimes during breaking

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 15:50:50 PST 2018


djasper added inline comments.


================
Comment at: lib/Format/ContinuationIndenter.cpp:1579
         (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) {
+      unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+                                           ? 0
----------------
I think a comment might help here. Specifically, it should mention that this is required for the special case where there is an unbreakable tail only if certain other formatting decisions have been taken. The UnbreakableTailLength is an overapproximation in that case and we need to be correct here.

Thinking about this some more, there might actually be cases where this is still not correct as the unbreakable tail is neither 0 nor the precomputed value.

E.g. can we construct a case where there is a trailing comma in a braced list? Maybe this:

vector<string> x = {"aaaaaa",};

In this case, I think the comma will always be part of the string literal, but the "};" only get part of the tail if we don't wrap after the "{".


Repository:
  rC Clang

https://reviews.llvm.org/D42376





More information about the cfe-commits mailing list