Handle newlines on Windows correctly.

llvm-svn: 223750
This commit is contained in:
Nikola Smiljanic 2014-12-09 02:57:56 +00:00
parent 53c038a581
commit 76c21b5a27
5 changed files with 26 additions and 1 deletions

View File

@ -270,7 +270,7 @@ int main(int argc, char **argv) {
// Write new file to disk // Write new file to disk
std::error_code EC; 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) { if (EC) {
llvm::errs() << "Could not open " << FileName << " for writing\n"; llvm::errs() << "Could not open " << FileName << " for writing\n";
continue; continue;

View File

@ -0,0 +1,6 @@
// This file intentionally uses a CRLF newlines!
void foo() {
int *x = 0;
}

View File

@ -0,0 +1,6 @@
// This file intentionally uses a CRLF newlines!
void foo() {
int *x = nullptr;
}

View File

@ -0,0 +1,8 @@
---
MainSourceFile: source1.cpp
Replacements:
- FilePath: $(path)/crlf.cpp
Offset: 79
Length: 1
ReplacementText: nullptr
...

View File

@ -0,0 +1,5 @@
// RUN: mkdir -p %T/Inputs/crlf
// RUN: cp %S/Inputs/crlf/crlf.cpp %T/Inputs/crlf/crlf.cpp
// RUN: sed "s#\$(path)#%/T/Inputs/crlf#" %S/Inputs/crlf/file1.yaml > %T/Inputs/crlf/file1.yaml
// RUN: clang-apply-replacements %T/Inputs/crlf
// RUN: diff %T/Inputs/crlf/crlf.cpp %S/Inputs/crlf/crlf.cpp.expected