]> granicus.if.org Git - clang/commitdiff
Almost the best possible handling of stdin/stdout for llvm-emit-bc!
authorChristopher Lamb <christopher.lamb@gmail.com>
Mon, 24 Dec 2007 20:59:36 +0000 (20:59 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Mon, 24 Dec 2007 20:59:36 +0000 (20:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45346 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/ASTConsumers.cpp

index df9d2e4fe719be224c480ac10634de2f963b28e6..f3b595ffb1b096a676557b0a600438508b72323c 100644 (file)
@@ -644,14 +644,18 @@ ASTConsumer *clang::CreateBCWriter(const std::string& InFile,
   std::string FileName = OutputFile;
   
   std::ostream *Out;
-  if (OutputFile == "-" || InFile == "-")
+  if (OutputFile == "-")
     Out = llvm::cout.stream();
   else if (!OutputFile.size()) {
-    llvm::sys::Path Path(InFile);
-    Path.eraseSuffix();
-    Path.appendSuffix("bc");
-    FileName = Path.toString();
-    Out = new std::ofstream(FileName.c_str());
+    if (InFile == "-")
+      Out = llvm::cout.stream();
+    else {
+      llvm::sys::Path Path(InFile);
+      Path.eraseSuffix();
+      Path.appendSuffix("bc");
+      FileName = Path.toString();
+      Out = new std::ofstream(FileName.c_str());
+    }
   } else {
     Out = new std::ofstream(FileName.c_str());
   }