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 c3a6b67..b6bd516 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -642,14 +642,20 @@
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);
}