[Bugpoint] Use clang by default.
authorDavide Italiano <davide@freebsd.org>
Wed, 14 Oct 2015 19:48:01 +0000 (19:48 +0000)
committerDavide Italiano <davide@freebsd.org>
Wed, 14 Oct 2015 19:48:01 +0000 (19:48 +0000)
We now rely on gcc only if either of the following is true:
1) -gcc option is passed by the user
2) clang is not found in the default path.

Differential Revision:  http://reviews.llvm.org/D13642

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

tools/bugpoint/ExecutionDriver.cpp

index 25813b34e62d2571c2587af9d6ecca1eee996716..d7964f357bc83fd0cc084d9ae2b871a45f40d130 100644 (file)
@@ -17,6 +17,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/raw_ostream.h"
 #include <fstream>
@@ -124,8 +125,7 @@ namespace {
                cl::ZeroOrMore, cl::PositionalEatsArgs);
 
   cl::opt<std::string>
-  GCCBinary("gcc", cl::init("gcc"),
-              cl::desc("The gcc binary to use. (default 'gcc')"));
+  GCCBinary("gcc", cl::init(""), cl::desc("The gcc binary to use."));
 
   cl::list<std::string>
   GCCToolArgv("gcc-tool-args", cl::Positional,
@@ -148,6 +148,13 @@ bool BugDriver::initializeExecutionEnvironment() {
   SafeInterpreter = nullptr;
   std::string Message;
 
+  if (GCCBinary.empty()) {
+    if (sys::findProgramByName("clang"))
+      GCCBinary = "clang";
+    else
+      GCCBinary = "gcc";
+  }
+
   switch (InterpreterSel) {
   case AutoPick:
     if (!Interpreter) {