llvm.org GIT mirror llvm / 58206dd
Use findProgramByName. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221221 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 4 years ago
4 changed file(s) with 54 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
104104 SmallVector parts;
105105 Names.split(parts, "|");
106106 for (auto Name : parts) {
107 ProgramPath = sys::FindProgramByName(Name);
108 if (!ProgramPath.empty())
107 auto P = sys::findProgramByName(Name);
108 if (P) {
109 ProgramPath = *P;
109110 return true;
111 }
110112 Log << " Tried '" << Name << "'\n";
111113 }
112114 return false;
158158 return 1;
159159 }
160160
161 std::string tool = OptCmd.empty()? sys::FindProgramByName("opt") : OptCmd;
161 std::string tool = OptCmd;
162 if (OptCmd.empty()) {
163 auto Path = sys::findProgramByName("opt");
164 if (!Path)
165 errs() << Path.getError().message() << "\n";
166 else
167 tool = *Path;
168 }
162169 if (tool.empty()) {
163170 errs() << "Cannot find `opt' in PATH!\n";
171 return 1;
172 }
173
174 std::string Prog;
175 if (UseValgrind) {
176 auto Path = sys::findProgramByName("valgrind");
177 if (!Path)
178 errs() << Path.getError().message() << "\n";
179 else
180 Prog = *Path;
181 } else
182 Prog = tool;
183 if (Prog.empty()) {
184 errs() << "Cannot find `valgrind' in PATH!\n";
164185 return 1;
165186 }
166187
202223 errs() << " " << Args[i];
203224 errs() << "\n";
204225 );
205
206 std::string Prog;
207 if (UseValgrind)
208 Prog = sys::FindProgramByName("valgrind");
209 else
210 Prog = tool;
211226
212227 // Redirect stdout and stderr to nowhere if SilencePasses is given
213228 StringRef Nowhere;
426426 pos = CommandLine.find_first_of(delimiters, lastPos);
427427 }
428428
429 CmdPath = sys::FindProgramByName(Command);
430 if (CmdPath.empty()) {
429 auto Path = sys::findProgramByName(Command);
430 if (!Path) {
431431 Message =
432432 std::string("Cannot find '") + Command +
433 "' in PATH!\n";
433 "' in PATH: " + Path.getError().message() + "\n";
434434 return;
435435 }
436 CmdPath = *Path;
436437
437438 Message = "Found command in: " + CmdPath + "\n";
438439 }
906907 GCC *GCC::create(std::string &Message,
907908 const std::string &GCCBinary,
908909 const std::vector *Args) {
909 std::string GCCPath = sys::FindProgramByName(GCCBinary);
910 if (GCCPath.empty()) {
911 Message = "Cannot find `"+ GCCBinary +"' in PATH!\n";
910 auto GCCPath = sys::findProgramByName(GCCBinary);
911 if (!GCCPath) {
912 Message = "Cannot find `" + GCCBinary + "' in PATH: " +
913 GCCPath.getError().message() + "\n";
912914 return nullptr;
913915 }
914916
915917 std::string RemoteClientPath;
916 if (!RemoteClient.empty())
917 RemoteClientPath = sys::FindProgramByName(RemoteClient);
918
919 Message = "Found gcc: " + GCCPath + "\n";
920 return new GCC(GCCPath, RemoteClientPath, Args);
921 }
918 if (!RemoteClient.empty()) {
919 auto Path = sys::findProgramByName(RemoteClient);
920 if (!Path) {
921 Message = "Cannot find `" + RemoteClient + "' in PATH: " +
922 Path.getError().message() + "\n";
923 return nullptr;
924 }
925 RemoteClientPath = *Path;
926 }
927
928 Message = "Found gcc: " + *GCCPath + "\n";
929 return new GCC(*GCCPath, RemoteClientPath, Args);
930 }
2626 if (argc == 0)
2727 return 1;
2828
29 std::string Program = sys::FindProgramByName(argv[0]);
29 auto Program = sys::findProgramByName(argv[0]);
30 if (!Program) {
31 errs() << "Error: Unable to find `" << argv[0]
32 << "' in PATH: " << Program.getError().message() << "\n";
33 return 1;
34 }
3035
3136 std::string ErrMsg;
32 int Result = sys::ExecuteAndWait(Program, argv, nullptr, nullptr, 0, 0,
37 int Result = sys::ExecuteAndWait(*Program, argv, nullptr, nullptr, 0, 0,
3338 &ErrMsg);
3439 #ifdef _WIN32
3540 // Handle abort() in msvcrt -- It has exit code as 3. abort(), aka