Allow bitcode output to be redirected to stdout.

llvm-svn: 45340
This commit is contained in:
Christopher Lamb 2007-12-24 03:23:55 +00:00
parent 76270e6be6
commit 5a3416409f
1 changed files with 7 additions and 1 deletions

View 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);
}