]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6521757> clang ObjC rewriter: Mixed Mac and Windows line endings...
authorSteve Naroff <snaroff@apple.com>
Tue, 3 Feb 2009 20:39:18 +0000 (20:39 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 3 Feb 2009 20:39:18 +0000 (20:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63657 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteObjC.cpp

index f18a0c53ce54262f300049b90c03d7cdc24f0fc9..facb1954305e4e807856223945abeab0e38649f5 100644 (file)
@@ -456,11 +456,10 @@ void RewriteObjC::Initialize(ASTContext &context) {
      
   Rewrite.setSourceMgr(Context->getSourceManager());
   
-  Preamble = "#line 2\n";
   // declaring objc_selector outside the parameter list removes a silly
   // scope related warning...
   if (IsHeader)
-    Preamble += "#pragma once\n";
+    Preamble = "#pragma once\n";
   Preamble += "struct objc_selector; struct objc_class;\n";
   Preamble += "struct __rw_objc_super { struct objc_object *object; ";
   Preamble += "struct objc_object *superClass; ";
@@ -4494,7 +4493,10 @@ void RewriteObjC::HandleTranslationUnit(TranslationUnit& TU) {
     OutFile = &llvm::outs();
   } else if (!OutFileName.empty()) {
     std::string Err;
-    OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), false, Err);
+    OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), 
+                                       // set binary mode (critical for Windoze)
+                                       true, 
+                                       Err);
     OwnedStream.reset(OutFile);
   } else if (InFileName == "-") {
     OutFile = &llvm::outs();
@@ -4503,7 +4505,10 @@ void RewriteObjC::HandleTranslationUnit(TranslationUnit& TU) {
     Path.eraseSuffix();
     Path.appendSuffix("cpp");
     std::string Err;
-    OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), false, Err);
+    OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), 
+                                       // set binary mode (critical for Windoze)
+                                       true, 
+                                       Err);
     OwnedStream.reset(OutFile);
   }