[llvm] r249696 - Windows: Fixed sys::findProgramByName to work with files containing dot in their name.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 06:30:18 PDT 2015


Thanks!

On 8 October 2015 at 12:03, George Rimar via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: grimar
> Date: Thu Oct  8 11:03:19 2015
> New Revision: 249696
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249696&view=rev
> Log:
> 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
>
> Modified:
>     llvm/trunk/lib/Support/Windows/Program.inc
>
> Modified: llvm/trunk/lib/Support/Windows/Program.inc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Program.inc?rev=249696&r1=249695&r2=249696&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Windows/Program.inc (original)
> +++ llvm/trunk/lib/Support/Windows/Program.inc Thu Oct  8 11:03:19 2015
> @@ -75,8 +75,15 @@ ErrorOr<std::string> sys::findProgramByN
>
>      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<wchar_t, MAX_PATH> 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());
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list