[clang-tools-extra] r223750 - Handle newlines on Windows correctly.

Nikola Smiljanic popizdeh at gmail.com
Mon Dec 8 18:57:57 PST 2014


Author: nikola
Date: Mon Dec  8 20:57:56 2014
New Revision: 223750

URL: http://llvm.org/viewvc/llvm-project?rev=223750&view=rev
Log:
Handle newlines on Windows correctly.

Added:
    clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/
    clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
    clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
    clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/file1.yaml
    clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp
Modified:
    clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

Modified: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=223750&r1=223749&r2=223750&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (original)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Mon Dec  8 20:57:56 2014
@@ -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;

Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp?rev=223750&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp Mon Dec  8 20:57:56 2014
@@ -0,0 +1,6 @@
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = 0;
+}

Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected?rev=223750&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/crlf.cpp.expected Mon Dec  8 20:57:56 2014
@@ -0,0 +1,6 @@
+
+// This file intentionally uses a CRLF newlines!
+
+void foo() {
+  int *x = nullptr;
+}

Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/file1.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/file1.yaml?rev=223750&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/file1.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/crlf/file1.yaml Mon Dec  8 20:57:56 2014
@@ -0,0 +1,8 @@
+---
+MainSourceFile:      source1.cpp
+Replacements:    
+  - FilePath:        $(path)/crlf.cpp
+    Offset:          79
+    Length:          1
+    ReplacementText: nullptr
+...

Added: clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp?rev=223750&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp Mon Dec  8 20:57:56 2014
@@ -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





More information about the cfe-commits mailing list