From d01dea749e48eb9962a5f58d89f67c4392396ecc Mon Sep 17 00:00:00 2001 From: Christopher Lamb Date: Mon, 24 Dec 2007 20:59:36 +0000 Subject: Almost the best possible handling of stdin/stdout for llvm-emit-bc! llvm-svn: 45346 --- clang/Driver/ASTConsumers.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'clang/Driver/ASTConsumers.cpp') diff --git a/clang/Driver/ASTConsumers.cpp b/clang/Driver/ASTConsumers.cpp index df9d2e4fe71..f3b595ffb1b 100644 --- a/clang/Driver/ASTConsumers.cpp +++ b/clang/Driver/ASTConsumers.cpp @@ -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()) { - llvm::sys::Path Path(InFile); - Path.eraseSuffix(); - Path.appendSuffix("bc"); - FileName = Path.toString(); - Out = new std::ofstream(FileName.c_str()); + 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()); } -- cgit v1.2.3