krasimir added inline comments.
================
Comment at: lib/Format/ContinuationIndenter.cpp:1158-1159
+ CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
+ Current.TokenText.substr(2).ltrim().startswith("clang-format on") ||
+ Current.TokenText.substr(2).ltrim().startswith("clang-format off"))
return addMultilineToken(Current, State);
----------------
klimek wrote:
> krasimir wrote:
> > klimek wrote:
> > > Generally, we shouldn't need those here, as those should be part of the
> > > Token.Finalized state.
> > Here the problem is that the comments /* clang-format on */ and /*
> > clang-format off */ control the formatting of the tokens in between, but do
> > not control their own formatting, that is they are not finalized themselves.
> > What happens is that if we rely solely on Token.Finalized and the
> > ColumnLimit is small, say 20, then:
> > ```
> > /* clang-format off */
> > ```
> > gets broken into:
> > ```
> > /* clang-format off
> > */
> > ```
> >
> > Add comments about this.
> Isn't the right fix to change the tokens of the comment to be finalized?
That's arguable. Consider [[
https://github.com/llvm-mirror/clang/blob/master/unittests/Format/FormatTest.cpp#L10916
| FormatTest.cpp:10916 ]]: in this case we still want to re-indent the /*
clang-format on/off */ comments, just not break them. If we finalize the token,
we can't re-indent.
https://reviews.llvm.org/D28764
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits