krasimir added inline comments.

================
Comment at: lib/Format/ContinuationIndenter.cpp:1579
         (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) 
{
+      unsigned UnbreakableTailLength = (State.NextToken && canBreak(State))
+                                           ? 0
----------------
djasper wrote:
> krasimir wrote:
> > djasper wrote:
> > > 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 "{".
> > In the `vector<string> x = {"aaaaa",};` only the comma is part of the 
> > `UnbreakableTailLength` of the string:
> > ```
> > M=1 C=1 T=Unknown S=0 B=0 BK=0 P=59 Name=string_literal L=100 PPK=2 
> > FakeLParens=1/ FakeRParens=0 Text='"aaaaa"'
> > M=0 C=0 T=Unknown S=0 B=0 BK=0 P=41 Name=comma L=101 PPK=2 FakeLParens= 
> > FakeRParens=1 Text=','
> > M=1 C=1 T=Unknown S=1 B=0 BK=0 P=41 Name=r_brace L=181 PPK=2 FakeLParens= 
> > FakeRParens=1 Text='}'
> > M=0 C=0 T=Unknown S=0 B=0 BK=0 P=23 Name=semi L=182 PPK=2 FakeLParens= 
> > FakeRParens=0 Text=';'
> > 
> > breakProtrudingToken: CanBreak=0, UnbreakableTailLength=1
> > ```
> > 
> Ok. The comma works around this by forcing a break before the "}". But what 
> about:
> 
>   vector<string> x = {"abc" /*comment*/};
> 
> The comment should be an unbreakable tail.
As you discovered, the comment-in-tail case is special-cased in the unbreakable 
tail computation, so this is not an issue.


Repository:
  rC Clang

https://reviews.llvm.org/D42376



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

Reply via email to