clang-apply-replacements doesn't handle windows newlines correctly

Nikola Smiljanic popizdeh at gmail.com
Tue Dec 2 19:13:55 PST 2014


I'm not entirely sure this is the right way to fix the issue, but since
SourceManager reads \r \n we should probably write them without newline
translation. What happens now is, newline is read as \r \n and when it's
written out the \n is translated so we end up with duplicated \r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141203/e0dfdb67/attachment.html>
-------------- next part --------------
 clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp b/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
index fcd1a55..607b665 100644
--- a/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
+++ b/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
@@ -270,7 +270,7 @@ int main(int argc, char **argv) {
 
     // Write new file to disk
     std::error_code EC;
-    llvm::raw_fd_ostream FileStream(FileName, EC, llvm::sys::fs::F_Text);
+    llvm::raw_fd_ostream FileStream(FileName, EC, llvm::sys::fs::F_None);
     if (EC) {
       llvm::errs() << "Could not open " << FileName << " for writing\n";
       continue;


More information about the cfe-commits mailing list