llvm.org GIT mirror llvm / 1cd4c56
Tweak to r250117 and change to use ErrorOr and drop isSizeValid for ArchiveMemberHeader, suggestion by Rafael Espíndola. Also The clang-x86-win2008-selfhost bot still does not like the malformed-machos 00000031.a test, so removing it for now. All the other bots are fine with it however. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250222 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 4 years ago
3 changed file(s) with 13 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
3636 llvm::StringRef getName() const;
3737
3838 /// Members are not larger than 4GB.
39 uint32_t getSize() const;
40 bool isSizeValid() const;
39 ErrorOr getSize() const;
4140
4241 sys::fs::perms getAccessMode() const;
4342 sys::TimeValue getLastModified() const;
4242 return llvm::StringRef(Name, end);
4343 }
4444
45 uint32_t ArchiveMemberHeader::getSize() const {
45 ErrorOr ArchiveMemberHeader::getSize() const {
4646 uint32_t Ret;
4747 if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret))
48 llvm_unreachable("Size is not a decimal number.");
48 return object_error::parse_failed;
4949 return Ret;
50 }
51
52 bool ArchiveMemberHeader::isSizeValid() const {
53 uint32_t Ret;
54 if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret))
55 return false;
56 return true;
5750 }
5851
5952 sys::fs::perms ArchiveMemberHeader::getAccessMode() const {
9588
9689 uint64_t Size = sizeof(ArchiveMemberHeader);
9790 Data = StringRef(Start, Size);
98 // Check to make sure the size is valid.
99 const ArchiveMemberHeader *Header =
100 reinterpret_cast(Data.data());
101 if (!Header->isSizeValid())
102 return;
10391 if (!isThinMember()) {
10492 Size += getRawSize();
10593 Data = StringRef(Start, Size);
118106 }
119107
120108 uint64_t Archive::Child::getSize() const {
121 if (Parent->IsThin)
122 return getHeader()->getSize();
109 if (Parent->IsThin) {
110 ErrorOr Size = getHeader()->getSize();
111 if (Size.getError())
112 return 0;
113 return Size.get();
114 }
123115 return Data.size() - StartOfFile;
124116 }
125117
126118 uint64_t Archive::Child::getRawSize() const {
127 return getHeader()->getSize();
119 ErrorOr Size = getHeader()->getSize();
120 if (Size.getError())
121 return 0;
122 return Size.get();
128123 }
129124
130125 bool Archive::Child::isThinMember() const {
3838 # RUN: | FileCheck -check-prefix=m0337 %s
3939
4040 # m0337: subq $16, %rsp
41
42 # RUN: llvm-objdump -arch x86_64 -macho -disassemble \
43 # RUN: %p/Inputs/malformed-machos/00000031.a \
44 # RUN: | FileCheck -check-prefix=0031a %s
45
46 # 0031a: Archive
47