// Construct CVTRES.EXE command line and execute it.
std::string program = "cvtres.exe";
- std::string programPath = llvm::sys::FindProgramByName(program);
- if (programPath.empty()) {
+ ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
+ if (!programPathOrErr) {
llvm::errs() << "Unable to find " << program << " in PATH\n";
return false;
}
+ const std::string &programPath = *programPathOrErr;
std::vector<const char *> args;
args.push_back(programPath.c_str());
// Run RC.EXE /fo tmp.res tmp.rc
std::string program = "rc.exe";
- std::string programPath = llvm::sys::FindProgramByName(program);
- if (programPath.empty()) {
+ ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
+ if (!programPathOrErr) {
diag << "Unable to find " << program << " in PATH\n";
return false;
}
+ const std::string &programPath = *programPathOrErr;
std::vector<const char *> args;
args.push_back(programPath.c_str());
args.push_back("/fo");
return false;
if (!StringRef(argv[1]).equals_lower("/lib"))
return false;
- std::string path = llvm::sys::FindProgramByName("lib.exe");
- if (path.empty()) {
+ ErrorOr<std::string> pathOrErr = llvm::sys::findProgramByName("lib.exe");
+ if (!pathOrErr) {
diag << "Unable to find lib.exe in PATH\n";
return true;
}
+ const std::string &path = *pathOrErr;
// Run lib.exe
std::vector<const char *> vec;
/// Creates a .def file and runs lib.exe on it to create an import library.
void writeImportLibrary(const PECOFFLinkingContext &ctx) {
+ std::string fileContents = createModuleDefinitionFile(ctx);
+
std::string program = "lib.exe";
- std::string programPath = llvm::sys::FindProgramByName(program);
+ ErrorOr<std::string> programPathOrErr = llvm::sys::findProgramByName(program);
+ if (!programPathOrErr) {
+ llvm::errs() << "Unable to find " << program << " in PATH\n";
+ } else {
+ const std::string &programPath = *programPathOrErr;
- std::string fileContents = createModuleDefinitionFile(ctx);
- std::string defPath = writeToTempFile(fileContents);
- llvm::FileRemover tmpFile(defPath);
+ std::string defPath = writeToTempFile(fileContents);
+ llvm::FileRemover tmpFile(defPath);
- std::string defArg = "/def:";
- defArg.append(defPath);
- std::string outputArg = "/out:";
- outputArg.append(ctx.getOutputImportLibraryPath());
+ std::string defArg = "/def:";
+ defArg.append(defPath);
+ std::string outputArg = "/out:";
+ outputArg.append(ctx.getOutputImportLibraryPath());
- std::vector<const char *> args;
- args.push_back(programPath.c_str());
- args.push_back("/nologo");
- args.push_back(ctx.is64Bit() ? "/machine:x64" : "/machine:x86");
- args.push_back(defArg.c_str());
- args.push_back(outputArg.c_str());
- args.push_back(nullptr);
+ std::vector<const char *> args;
+ args.push_back(programPath.c_str());
+ args.push_back("/nologo");
+ args.push_back(ctx.is64Bit() ? "/machine:x64" : "/machine:x86");
+ args.push_back(defArg.c_str());
+ args.push_back(outputArg.c_str());
+ args.push_back(nullptr);
- if (programPath.empty()) {
- llvm::errs() << "Unable to find " << program << " in PATH\n";
- } else if (llvm::sys::ExecuteAndWait(programPath.c_str(), &args[0]) != 0) {
- llvm::errs() << program << " failed\n";
+ if (llvm::sys::ExecuteAndWait(programPath.c_str(), &args[0]) != 0)
+ llvm::errs() << program << " failed\n";
}
// If /lldmoduledeffile:<filename> is given, make a copy of the