[PATCH] D47577: [clang-format] Separate block comments with CRLF correctly
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 8 02:14:20 PDT 2018
krasimir requested changes to this revision.
krasimir added inline comments.
This revision now requires changes to proceed.
================
Comment at: lib/Format/BreakableToken.cpp:327
+ TokenText.substr(2, TokenText.size() - 4)
+ .split(Lines, TokenText.count('\r') > 0 ? "\r\n" : "\n");
----------------
alexfh wrote:
> FYI, there's a global UseCRLF flag in WhitespaceManager. It may make sense to use it everywhere instead of deciding for each comment. But I'll let actual clang-format maintainers decide on pros and cons of this.
In case the text contains both `\r\n`-s and `\n` not preceded by `\r`, this would not break on the `\n`; neither will a version using `WhitespaceManager::UsesCRLF`. That is computed by:
```
bool inputUsesCRLF(StringRef Text) {
return Text.count('\r') * 2 > Text.count('\n');
}```
which implies that we at least tentatively support such mixed cases.
I'd try keeping the split here just by `"\n"` and stripping a trailing `"\r"`from each line as a second step.
Repository:
rC Clang
https://reviews.llvm.org/D47577
More information about the cfe-commits
mailing list