Only print registered targets for `--version`
authorDimitry Andric <dimitry@andric.com>
Wed, 7 Jun 2017 12:05:41 +0000 (12:05 +0000)
committerDimitry Andric <dimitry@andric.com>
Wed, 7 Jun 2017 12:05:41 +0000 (12:05 +0000)
Summary:
In D33900, I added printing of the registered targets in clang's
`PrintVersion` function, which is not only used for `--version` output,
but also for `-v` (verbose mode) and `-###`.  Especially the latter
seems to trip up some test cases, so it is probably better to only print
the registered targets for `--version`.

Reviewers: nemanjai, mehdi_amini

Reviewed By: nemanjai

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33981

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304899 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp

index ec106fa93be8abfe3f4cb300725004cede390529..63496af3f3d7aea96cc8ec0889cdf196268519ce 100644 (file)
@@ -1117,10 +1117,6 @@ void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
-
-  // Print registered targets.
-  OS << '\n';
-  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
@@ -1166,6 +1162,10 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   if (C.getArgs().hasArg(options::OPT__version)) {
     // Follow gcc behavior and use stdout for --version and stderr for -v.
     PrintVersion(C, llvm::outs());
+
+    // Print registered targets.
+    llvm::outs() << '\n';
+    llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
     return false;
   }