aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-12-24 03:23:55 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-12-24 03:23:55 +0000
commit2d6c065fa977ef4331f4076d268b87fae5791398 (patch)
tree16202b42a5db669d540930d4c021274fbd410481
parentfe947ad3624ad45bc5ef9fd36a3f9ff00efdb1fd (diff)
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
-rw-r--r--Driver/ASTConsumers.cpp8
1 files changed, 7 insertions, 1 deletions
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);
}