[PATCH] D28764: [clang-format] Implement comment reflowing (v3)

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 04:17:46 PST 2017


klimek 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);
----------------
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?


https://reviews.llvm.org/D28764





More information about the cfe-commits mailing list