[llvm] r368573 - [llvm-ar] Accept file paths with windows format slashes

Jordan Rupprecht via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 07:22:07 PDT 2019


Looks like there's a buildbot error, so I committed r368578 to get things
green again:

FAILED: /usr/local/bin/c++   -DGTEST_HAS_RTTI=0 -D_DEBUG
-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D_LARGEFILE_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/llvm-ar
-I/home/buildslave/buildslave/clang-cmake-armv7-lnt/llvm/tools/llvm-ar
-I/usr/include/libxml2 -Iinclude
-I/home/buildslave/buildslave/clang-cmake-armv7-lnt/llvm/include -fPIC
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type
-Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color
-ffunction-sections -fdata-sections -O3    -UNDEBUG  -fno-exceptions
-fno-rtti -MMD -MT tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.o
-MF tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.o.d -o
tools/llvm-ar/CMakeFiles/llvm-ar.dir/llvm-ar.cpp.o -c
/home/buildslave/buildslave/clang-cmake-armv7-lnt/llvm/tools/llvm-ar/llvm-ar.cpp
/home/buildslave/buildslave/clang-cmake-armv7-lnt/llvm/tools/llvm-ar/llvm-ar.cpp:
In function ‘std::__cxx11::string normalizePath(llvm::StringRef)’:
/home/buildslave/buildslave/clang-cmake-armv7-lnt/llvm/tools/llvm-ar/llvm-ar.cpp:478:26:
error: operands to ?: have different types ‘std::__cxx11::string {aka
std::__cxx11::basic_string<char>}’ and ‘llvm::StringRef’
   return CompareFullPath ? sys::path::convert_to_slash(Path)
          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                          : sys::path::filename(Path);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~


On Mon, Aug 12, 2019 at 6:59 AM Owen Reynolds via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: gbreynoo
> Date: Mon Aug 12 07:00:28 2019
> New Revision: 368573
>
> URL: http://llvm.org/viewvc/llvm-project?rev=368573&view=rev
> Log:
> [llvm-ar] Accept file paths with windows format slashes
>
> The internal representation of llvm-ar archives uses linux style slashes
> for paths, no matter the OS. In the case of windows this meant file
> paths input intending to match existing members would only match if
> linux style slashes where used. This change allows either slash
> direction to be input by the user.
>
> This change includes removing an unnecessary call to normalisePath and
> moving the call of another.
>
> Differential Revision: https://reviews.llvm.org/D65743
>
> Added:
>     llvm/trunk/test/tools/llvm-ar/windows-path.test
> Modified:
>     llvm/trunk/tools/llvm-ar/llvm-ar.cpp
>
> Added: llvm/trunk/test/tools/llvm-ar/windows-path.test
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/windows-path.test?rev=368573&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-ar/windows-path.test (added)
> +++ llvm/trunk/test/tools/llvm-ar/windows-path.test Mon Aug 12 07:00:28
> 2019
> @@ -0,0 +1,44 @@
> +# Test that windows path seperators are handled correctly.
> +REQUIRES: system-windows
> +
> +# Note: many of these tests depend on relative paths, so we have to cd to
> a
> +# test directory first.
> +RUN: mkdir -p %t && cd %t
> +RUN: rm -rf a b && mkdir a b
> +RUN: echo hello-a      > a/foo.txt
> +RUN: echo hello-b      > b/foo.txt
> +RUN: echo hello-parent > foo.txt
> +
> +# P is implied when using thin archives.
> +# Create an archive.
> +RUN: rm -f archive.a
> +RUN: llvm-ar rcST archive.a a\..\a\foo.txt
> +RUN: llvm-ar rcST archive.a foo.txt
> +RUN: llvm-ar rcST archive.a b\foo.txt b/foo.txt
> +RUN: llvm-ar dT archive.a foo.txt
> +RUN: llvm-ar t archive.a | FileCheck %s --check-prefix=ARCHIVE
> --implicit-check-not {{.}}
> +
> +ARCHIVE:      a/foo.txt
> +ARCHIVE-NEXT: b/foo.txt
> +ARCHIVE-NEXT: b/foo.txt
> +
> +RUN: llvm-ar t archive.a | FileCheck %s --check-prefix=LIST-BOTH
> --implicit-check-not {{.}}
> +RUN: llvm-ar t archive.a a\foo.txt | FileCheck %s --check-prefix=LIST-A
> --implicit-check-not {{.}}
> +RUN: llvm-ar t archive.a b\foo.txt | FileCheck %s --check-prefix=LIST-B
> --implicit-check-not {{.}}
> +
> +LIST-BOTH:       a/foo.txt
> +LIST-BOTH-NEXT:  b/foo.txt
> +LIST-BOTH-NEXT:  b/foo.txt
> +LIST-A:          a/foo.txt
> +LIST-B:          b/foo.txt
> +
> +# Nesting a thin archive with a name conflict.
> +RUN: rm -f a\nested.a b\nested.a nested.a
> +RUN: llvm-ar rcST a\nested.a a\foo.txt
> +RUN: llvm-ar rcST b\nested.a b\foo.txt
> +RUN: llvm-ar rcST nested.a a\nested.a foo.txt b\nested.a
> +RUN: llvm-ar t nested.a | FileCheck %s --check-prefix=NESTED
> --implicit-check-not {{.}}
> +
> +NESTED:      a/foo.txt
> +NESTED-NEXT: foo.txt
> +NESTED-NEXT: b/foo.txt
>
> Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=368573&r1=368572&r2=368573&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
> +++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Mon Aug 12 07:00:28 2019
> @@ -474,8 +474,9 @@ static void doDisplayTable(StringRef Nam
>    outs() << Name << "\n";
>  }
>
> -static StringRef normalizePath(StringRef Path) {
> -  return CompareFullPath ? Path : sys::path::filename(Path);
> +static std::string normalizePath(StringRef Path) {
> +  return CompareFullPath ? sys::path::convert_to_slash(Path)
> +                         : sys::path::filename(Path);
>  }
>
>  // Implement the 'x' operation. This function extracts files back to the
> file
> @@ -698,9 +699,8 @@ static InsertAction computeInsertAction(
>      return IA_MoveOldMember;
>
>    if (Operation == ReplaceOrInsert) {
> -    StringRef PosName = normalizePath(RelPos);
>      if (!OnlyUpdate) {
> -      if (PosName.empty())
> +      if (RelPos.empty())
>          return IA_AddNewMember;
>        return IA_MoveNewMember;
>      }
> @@ -712,12 +712,12 @@ static InsertAction computeInsertAction(
>      auto ModTimeOrErr = Member.getLastModified();
>      failIfError(ModTimeOrErr.takeError());
>      if (Status.getLastModificationTime() < ModTimeOrErr.get()) {
> -      if (PosName.empty())
> +      if (RelPos.empty())
>          return IA_AddOldMember;
>        return IA_MoveOldMember;
>      }
>
> -    if (PosName.empty())
> +    if (RelPos.empty())
>        return IA_AddNewMember;
>      return IA_MoveNewMember;
>    }
> @@ -732,8 +732,8 @@ computeNewArchiveMembers(ArchiveOperatio
>    std::vector<NewArchiveMember> Ret;
>    std::vector<NewArchiveMember> Moved;
>    int InsertPos = -1;
> -  StringRef PosName = normalizePath(RelPos);
>    if (OldArchive) {
> +    std::string PosName = normalizePath(RelPos);
>      Error Err = Error::success();
>      StringMap<int> MemberCount;
>      for (auto &Child : OldArchive->children(Err)) {
> @@ -1009,7 +1009,7 @@ static void runMRIScript() {
>        ArchiveName = Rest;
>        break;
>      case MRICommand::Delete: {
> -      StringRef Name = normalizePath(Rest);
> +      std::string Name = normalizePath(Rest);
>        llvm::erase_if(NewMembers,
>                       [=](NewArchiveMember &M) { return M.MemberName ==
> Name; });
>        break;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/7f45f923/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4849 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/7f45f923/attachment.bin>


More information about the llvm-commits mailing list