krasimir added inline comments.
================
Comment at: clang/lib/Format/Format.cpp:1891
+ if (compareIgnoringCarriageReturns(
+ result, Code.substr(IncludesBeginOffset, IncludesBlockSize)))
return;
----------------
Here `compartIgnoringCarriageReturns` is a bit imprecise: there could be `\r`-s
not followed by `\n`-s in the source code.
Since we have constructed `result` with newlines as `\n`-s in this code, I'd
suggest to instead implement a function that replaces all occurrences of `\r\n`
with `\n` in a string (something like "stripNewlineCRs") and have a comparison
like `result == stripNewlineCRs(...)` here. That shouldn't be much harder than
this approach and will be a bit more precise.
I've looked around the Format code for preexisting functionality we can reuse,
but it seems most of the `\r\n` handling is concerned with outputting the right
newline encoding and not with reading it.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68227/new/
https://reviews.llvm.org/D68227
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits