[PATCH] D111889: [AIX] Support of Big archive (read)

Digger Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 07:47:54 PST 2021


DiggerLin marked 3 inline comments as done.
DiggerLin added inline comments.


================
Comment at: llvm/lib/Object/Archive.cpp:292
 
-Expected<sys::TimePoint<std::chrono::seconds>>
-ArchiveMemberHeader::getLastModified() const {
-  unsigned Seconds;
-  if (StringRef(ArMemHdr->LastModified, sizeof(ArMemHdr->LastModified))
-          .rtrim(' ')
-          .getAsInteger(10, Seconds)) {
-    std::string Buf;
-    raw_string_ostream OS(Buf);
-    OS.write_escaped(
-        StringRef(ArMemHdr->LastModified, sizeof(ArMemHdr->LastModified))
-            .rtrim(" "));
-    OS.flush();
-    uint64_t Offset =
-        reinterpret_cast<const char *>(ArMemHdr) - Parent->getData().data();
-    return malformedError("characters in LastModified field in archive header "
-                          "are not all decimal numbers: '" +
-                          Buf + "' for the archive member header at offset " +
-                          Twine(Offset));
+#define getFieldRawString(T) StringRef(T, sizeof(T)).rtrim(" ")
+
----------------
DiggerLin wrote:
> jhenderson wrote:
> > Use a (potentially templated) function, not a macro. This macro does nothing beneficial that a function can't do.
> for the T is not type , it is concrete field of the ArMemHdrType , it can not be templated function.
for example :

```
#include <stdio.h>
struct T {
 char V[80];
};

T t= { {0} };

template <class T>
int getSize(T m) {
  printf(" size of =%u \n", sizeof(m));
  return sizeof(m);
}

int main() {
 getSize(t.V);
 return 0;
}
~
```

bash> clang++ t.cpp
t.cpp:10:29: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  printf(" size of =%d \n", sizeof(m));
                    ~~      ^~~~~~~~~
                    %lu
**t.cpp:15:2: note: in instantiation of function template specialization 'getSize<char *>' requested here
 getSize(t.V);**
 ^
1 warning generated.
 ^
1 warning generated.
-bash-4.2$ ./a.out
 size of =8

the size is wrong.
~


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111889/new/

https://reviews.llvm.org/D111889



More information about the llvm-commits mailing list