llvmc: Make ExecuteProgram() look in the driver directory first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117584 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov 2010-10-28 19:33:08 +00:00
parent 8a5ff478db
commit 9f36e7389f

View File

@ -14,6 +14,7 @@
#include "llvm/CompilerDriver/Action.h"
#include "llvm/CompilerDriver/BuiltinOptions.h"
#include "llvm/CompilerDriver/Error.h"
#include "llvm/CompilerDriver/Main.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SystemUtils.h"
@ -28,7 +29,6 @@ using namespace llvmc;
namespace llvmc {
extern int Main(int argc, char** argv);
extern const char* ProgramName;
}
@ -55,10 +55,13 @@ namespace {
int ExecuteProgram (const std::string& name,
const StrVector& args) {
sys::Path prog = sys::Program::FindProgramByName(name);
sys::Path prog(name);
if (!prog.isAbsolute())
prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main);
if (prog.isEmpty()) {
prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main);
prog = sys::Program::FindProgramByName(name);
if (prog.isEmpty()) {
PrintError("Can't find program '" + name + "'");
return -1;