[llvm] r228874 - Change Path::filename_pos() to skip the drive letter.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Feb 17 08:58:41 PST 2015


testcase?

On 11 February 2015 at 16:16, Zachary Turner <zturner at google.com> wrote:
> Author: zturner
> Date: Wed Feb 11 15:16:35 2015
> New Revision: 228874
>
> URL: http://llvm.org/viewvc/llvm-project?rev=228874&view=rev
> Log:
> Change Path::filename_pos() to skip the drive letter.
>
> For Windows, filename_pos() tries to find the filename by
> searching for separators after the last :.  Instead, it should
> really check for the only location that a : is valid, which is
> in the second character, and search for separators after that.
>
> Modified:
>     llvm/trunk/lib/Support/Path.cpp
>
> Modified: llvm/trunk/lib/Support/Path.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=228874&r1=228873&r2=228874&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/Path.cpp (original)
> +++ llvm/trunk/lib/Support/Path.cpp Wed Feb 11 15:16:35 2015
> @@ -98,8 +98,11 @@ namespace {
>      size_t pos = str.find_last_of(separators, str.size() - 1);
>
>  #ifdef LLVM_ON_WIN32
> -    if (pos == StringRef::npos)
> -      pos = str.find_last_of(':', str.size() - 2);
> +    if (pos == StringRef::npos) {
> +      // Skip the drive letter, if one exists.
> +      if (str.size() >= 2 && str[1] == ':')
> +        pos = 2;
> +    }
>  #endif
>
>      if (pos == StringRef::npos ||
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list