From: Christopher Lamb Date: Mon, 24 Dec 2007 03:23:55 +0000 (+0000) Subject: Allow bitcode output to be redirected to stdout. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d6c065fa977ef4331f4076d268b87fae5791398;p=clang Allow bitcode output to be redirected to stdout. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45340 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index c3a6b67562..b6bd516385 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -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); }