Almost the best possible handling of stdin/stdout for llvm-emit-bc!

llvm-svn: 45346
This commit is contained in:
Christopher Lamb 2007-12-24 20:59:36 +00:00
parent 1c0f5d2436
commit d01dea749e
1 changed files with 10 additions and 6 deletions

View File

@ -644,14 +644,18 @@ ASTConsumer *clang::CreateBCWriter(const std::string& InFile,
std::string FileName = OutputFile;
std::ostream *Out;
if (OutputFile == "-" || InFile == "-")
if (OutputFile == "-")
Out = llvm::cout.stream();
else if (!OutputFile.size()) {
if (InFile == "-")
Out = llvm::cout.stream();
else {
llvm::sys::Path Path(InFile);
Path.eraseSuffix();
Path.appendSuffix("bc");
FileName = Path.toString();
Out = new std::ofstream(FileName.c_str());
}
} else {
Out = new std::ofstream(FileName.c_str());
}