aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-21 20:06:58 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-21 20:06:58 +0000
commit793007242ba209b68ce14ec7547ac70ee981303a (patch)
tree95877190e46aed74e33e7118a0301d0ba6284654
parent6347f420ee0b097c0e642dc6c51afee5f1b14235 (diff)
driver: Print --version on stdout, to match gcc.
- Patch by Jean-Daniel Dupas git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76632 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/Driver.h5
-rw-r--r--lib/Driver/Driver.cpp14
2 files changed, 11 insertions, 8 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index c0def2bcca..623485bc6a 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -21,6 +21,9 @@
#include <set>
#include <string>
+namespace llvm {
+ class raw_ostream;
+}
namespace clang {
namespace driver {
class Action;
@@ -185,7 +188,7 @@ public:
void PrintOptions(const ArgList &Args) const;
/// PrintVersion - Print the driver version.
- void PrintVersion(const Compilation &C) const;
+ void PrintVersion(const Compilation &C, llvm::raw_ostream &OS) const;
/// GetFilePath - Lookup \arg Name in the list of file search paths.
///
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index df72426057..c4136df56b 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -385,7 +385,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
OS.flush();
}
-void Driver::PrintVersion(const Compilation &C) const {
+void Driver::PrintVersion(const Compilation &C, llvm::raw_ostream &OS) const {
static char buf[] = "$URL$";
char *zap = strstr(buf, "/lib/Driver");
if (zap)
@@ -402,17 +402,16 @@ void Driver::PrintVersion(const Compilation &C) const {
#endif
// FIXME: The following handlers should use a callback mechanism, we
// don't know what the client would like to do.
-
- llvm::errs() << "clang version " CLANG_VERSION_STRING " ("
+ OS << "clang version " CLANG_VERSION_STRING " ("
<< vers << " " << revision << ")" << '\n';
const ToolChain &TC = C.getDefaultToolChain();
- llvm::errs() << "Target: " << TC.getTripleString() << '\n';
+ OS << "Target: " << TC.getTripleString() << '\n';
// Print the threading model.
//
// FIXME: Implement correctly.
- llvm::errs() << "Thread model: " << "posix" << '\n';
+ OS << "Thread model: " << "posix" << '\n';
}
bool Driver::HandleImmediateArgs(const Compilation &C) {
@@ -432,13 +431,14 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
}
if (C.getArgs().hasArg(options::OPT__version)) {
- PrintVersion(C);
+ // Follow gcc behavior and use stdout for --version and stderr for -v
+ PrintVersion(C, llvm::outs());
return false;
}
if (C.getArgs().hasArg(options::OPT_v) ||
C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
- PrintVersion(C);
+ PrintVersion(C, llvm::errs());
SuppressMissingInputWarning = true;
}