Fix searching for gcc, we only want executable files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67806 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 6202702..16e7e85 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -294,7 +294,7 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-    llvm::outs() << GetProgramPath("libgcc.a", TC).toString() << "\n";
+    llvm::outs() << GetProgramPath("libgcc.a", TC, true).toString() << "\n";
     return false;
   }
 
@@ -925,13 +925,14 @@
 }
 
 llvm::sys::Path Driver::GetProgramPath(const char *Name, 
-                                       const ToolChain &TC) const {
+                                       const ToolChain &TC,
+                                       bool WantFile) const {
   const ToolChain::path_list &List = TC.getProgramPaths();
   for (ToolChain::path_list::const_iterator 
          it = List.begin(), ie = List.end(); it != ie; ++it) {
     llvm::sys::Path P(*it);
     P.appendComponent(Name);
-    if (P.exists())
+    if (WantFile ? P.exists() : P.canExecute())
       return P;
   }
 
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index aed58c9..a7f6550 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -30,6 +30,7 @@
 }
 
 llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, 
-                                          const char *Name) const {
-  return Host.getDriver().GetProgramPath(Name, *this);
+                                          const char *Name,
+                                          bool WantFile) const {
+  return Host.getDriver().GetProgramPath(Name, *this, WantFile);
 }