llvm-ar: Don't write the directory in the string table.

We were already doing the right thing for short file names, but not long
ones.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-07-15 23:15:33 +00:00
parent 8770f7af5f
commit 167af8c16c
2 changed files with 13 additions and 4 deletions

View File

@ -160,7 +160,7 @@ static void writeStringTable(raw_fd_ostream &Out,
bool Thin) {
unsigned StartOffset = 0;
for (const NewArchiveIterator &I : Members) {
StringRef Name = I.getName();
StringRef Name = sys::path::filename(I.getName());
if (!useStringTable(Thin, Name))
continue;
if (StartOffset == 0) {

View File

@ -6,17 +6,26 @@ RUN: cd %t
RUN: echo -n bar. > 0123456789abcde
RUN: echo -n zed. > 0123456789abcdef
RUN: mkdir -p foo
RUN: echo -n bar2 > foo/0123456789abcde
RUN: echo -n zed2 > foo/0123456789abcdef
RUN: rm -f %t.a
RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef
RUN: llvm-ar --format=gnu rc %t.a 0123456789abcde 0123456789abcdef foo/0123456789abcde foo/0123456789abcdef
RUN: cat %t.a | FileCheck -strict-whitespace %s
CHECK: !<arch>
CHECK-NEXT: // 18 `
CHECK-NEXT: // 36 `
CHECK-NEXT: 0123456789abcdef/
CHECK-NEXT: 0123456789abcdef/
CHECK-NEXT: 0123456789abcde/0 0 0 644 4 `
CHECK-NEXT: bar./0 0 0 0 644 4 `
CHECK-NEXT: bar.
CHECK-SAME: /0 0 0 0 644 4 `
CHECK-NEXT: zed.
CHECK-SAME: 0123456789abcde/0 0 0 644 4 `
CHECK-NEXT: bar2
CHECK-SAME: /18 0 0 0 644 4 `
CHECK-NEXT: zed2
RUN: rm -f %t.a
RUN: llvm-ar --format=bsd rc %t.a 0123456789abcde 0123456789abcdef