]> granicus.if.org Git - clang/commitdiff
Allow bitcode output to be redirected to stdout.
authorChristopher Lamb <christopher.lamb@gmail.com>
Mon, 24 Dec 2007 03:23:55 +0000 (03:23 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Mon, 24 Dec 2007 03:23:55 +0000 (03:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45340 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/ASTConsumers.cpp

index c3a6b67562e17203a0179a6b77f3fb6cf25cf327..b6bd516385f3dcb9b9117d1dd67f13e84858a6be 100644 (file)
@@ -642,14 +642,20 @@ ASTConsumer *clang::CreateBCWriter(const std::string& InFile,
                                    Diagnostic &Diags,
                                    const LangOptions &Features) {
   std::string FileName = OutputFile;
+  
+  std::ostream *Out;
   if (!OutputFile.size()) {
     llvm::sys::Path Path(InFile);
     Path.eraseSuffix();
     Path.appendSuffix("bc");
     FileName = Path.toString();
+    Out = new std::ofstream(FileName.c_str());
+  } else if (OutputFile == "-") {
+    Out = llvm::cout.stream();
+  } else {
+    Out = new std::ofstream(FileName.c_str());
   }
 
-  std::ofstream *Out = new std::ofstream(FileName.c_str());
   return new BCWriter(Out, Diags, Features);
 }