diff options
| author | Jordan Rupprecht <rupprecht@google.com> | 2018-10-05 23:25:39 +0000 | 
|---|---|---|
| committer | Jordan Rupprecht <rupprecht@google.com> | 2018-10-05 23:25:39 +0000 | 
| commit | 34c0e470ae30d7205ad257a56db7e8c588edd3d5 (patch) | |
| tree | a3016e96aee1bc97c7b144e3780980b754b2d0e7 /llvm/tools/llvm-ar/llvm-ar.cpp | |
| parent | 4b36f7911d8d186b60c1c63b5680e7a7ab300b61 (diff) | |
| download | bcm5719-llvm-34c0e470ae30d7205ad257a56db7e8c588edd3d5.tar.gz bcm5719-llvm-34c0e470ae30d7205ad257a56db7e8c588edd3d5.zip | |
[llvm-ar] Use POSIX-specified timestamps for 'tv'.
Summary:
The POSIX spec says:
```
If the −t option is used with the −v option, the standard output format shall be:
"%s %u/%u %u %s %d %d:%d %d %s\n", <member mode>, <user ID>,
<group ID>, <number of bytes in member>,
<abbreviated month>, <day-of-month>, <hour>,
<minute>, <year>, <file>
where:
...
<abbreviated month>
Equivalent to the format of the %b conversion specification format in date.
<day-of-month>
Equivalent to the format of the %e conversion specification format in date.
<hour> Equivalent to the format of the %H conversion specification format in date.
<minute> Equivalent to the format of the %M conversion specification format in date.
<year> Equivalent to the format of the %Y conversion specification format in date.
```
This actually used to be the format printed by llvm-ar. It was apparently accidentally changed (see r207385 followed by comments in r207387). This makes it conform to GNU ar for easier replacement.
Reviewers: MaskRay
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D52940
llvm-svn: 343901
Diffstat (limited to 'llvm/tools/llvm-ar/llvm-ar.cpp')
| -rw-r--r-- | llvm/tools/llvm-ar/llvm-ar.cpp | 7 | 
1 files changed, 6 insertions, 1 deletions
| diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 9d2d765cdea..454b3971d28 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -24,6 +24,7 @@  #include "llvm/Support/Errc.h"  #include "llvm/Support/FileSystem.h"  #include "llvm/Support/Format.h" +#include "llvm/Support/FormatVariadic.h"  #include "llvm/Support/InitLLVM.h"  #include "llvm/Support/LineIterator.h"  #include "llvm/Support/MemoryBuffer.h" @@ -367,7 +368,11 @@ static void doDisplayTable(StringRef Name, const object::Archive::Child &C) {      outs() << ' ' << format("%6llu", Size.get());      auto ModTimeOrErr = C.getLastModified();      failIfError(ModTimeOrErr.takeError()); -    outs() << ' ' << ModTimeOrErr.get(); +    // Note: formatv() only handles the default TimePoint<>, which is in +    // nanoseconds. +    // TODO: fix format_provider<TimePoint<>> to allow other units. +    sys::TimePoint<> ModTimeInNs = ModTimeOrErr.get(); +    outs() << ' ' << formatv("{0:%b %e %H:%M %Y}", ModTimeInNs);      outs() << ' ';    } | 

