From: Mike Stump Date: Fri, 27 Mar 2009 00:40:20 +0000 (+0000) Subject: Fix searching for gcc, we only want executable files. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=950bedd8a9f00caabd2f1fc6812d70e08103f847;p=clang 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/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index cb7f3b035a..464faf8fa5 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -178,8 +178,12 @@ public: /// /// \arg TC - The provided tool chain for additional information on /// directories to search. + /// + /// \arg WantFile - False when searching for an executable file, otherwise + /// true. Defaults to false. // FIXME: This should be in CompilationInfo. - llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC) const; + llvm::sys::Path GetProgramPath(const char *Name, const ToolChain &TC, + bool WantFile = false) const; /// HandleImmediateArgs - Handle any arguments which should be /// treated before building actions or binding tools. diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h index e85d7a7e20..761b4990cb 100644 --- a/include/clang/Driver/ToolChain.h +++ b/include/clang/Driver/ToolChain.h @@ -72,7 +72,8 @@ public: // Helper methods llvm::sys::Path GetFilePath(const Compilation &C, const char *Name) const; - llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name) const; + llvm::sys::Path GetProgramPath(const Compilation &C, const char *Name, + bool WantFile = false) const; // Platform defaults information diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 6202702f09..16e7e85ea8 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -294,7 +294,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { } 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::GetFilePath(const char *Name, } 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 aed58c9422..a7f6550205 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -30,6 +30,7 @@ llvm::sys::Path ToolChain::GetFilePath(const Compilation &C, } 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); }