From: George Rimar Date: Thu, 8 Oct 2015 16:03:19 +0000 (+0000) Subject: Windows: Fixed sys::findProgramByName to work with files containing dot in their... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fedf66703c32642b5d73a424c52f6598b1e7be79;p=oota-llvm.git Windows: Fixed sys::findProgramByName to work with files containing dot in their name. Problem was in SearchPathW function that does not attach an extension if file already has one. That does not work for executables like ld.lld2 for example which require to have .exe extension but SearchPath thinks that its "lld2". Solution was to add the extension manually. Differential Revision: http://reviews.llvm.org/D13536 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249696 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc index fe83118b064..e2a167c0a2b 100644 --- a/lib/Support/Windows/Program.inc +++ b/lib/Support/Windows/Program.inc @@ -75,8 +75,15 @@ ErrorOr sys::findProgramByName(StringRef Name, do { U16Result.reserve(Len); - Len = ::SearchPathW(Path, c_str(U16Name), - U16Ext.empty() ? nullptr : c_str(U16Ext), + // Lets attach the extension manually. That is needed for files + // with a point in name like aaa.bbb. SearchPathW will not add extension + // from its argument to such files because it thinks they already had one. + SmallVector U16NameExt; + if (std::error_code EC = + windows::UTF8ToUTF16(Twine(Name + Ext).str(), U16NameExt)) + return EC; + + Len = ::SearchPathW(Path, c_str(U16NameExt), nullptr, U16Result.capacity(), U16Result.data(), nullptr); } while (Len > U16Result.capacity());