[lld] r360648 - [Object] Change ObjectFile::getSectionContents to return Expected<ArrayRef<uint8_t>>
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 21:22:51 PDT 2019
Author: maskray
Date: Mon May 13 21:22:51 2019
New Revision: 360648
URL: http://llvm.org/viewvc/llvm-project?rev=360648&view=rev
Log:
[Object] Change ObjectFile::getSectionContents to return Expected<ArrayRef<uint8_t>>
Change
std::error_code getSectionContents(DataRefImpl, StringRef &) const;
to
Expected<ArrayRef<uint8_t>> getSectionContents(DataRefImpl) const;
Many object formats use ArrayRef<uint8_t> as the underlying type, which
is generally better than StringRef to represent binary data, so change
the type to decrease the number of type conversions.
Reviewed By: ruiu, sbc100
Differential Revision: https://reviews.llvm.org/D61781
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/InputFiles.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=360648&r1=360647&r2=360648&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Mon May 13 21:22:51 2019
@@ -586,7 +586,7 @@ StringRef SectionChunk::getDebugName() {
ArrayRef<uint8_t> SectionChunk::getContents() const {
ArrayRef<uint8_t> A;
- File->getCOFFObj()->getSectionContents(Header, A);
+ cantFail(File->getCOFFObj()->getSectionContents(Header, A));
return A;
}
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=360648&r1=360647&r2=360648&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon May 13 21:22:51 2019
@@ -863,7 +863,8 @@ static void findKeepUniqueSections() {
ArrayRef<Symbol *> Syms = Obj->getSymbols();
if (Obj->AddrsigSec) {
ArrayRef<uint8_t> Contents;
- Obj->getCOFFObj()->getSectionContents(Obj->AddrsigSec, Contents);
+ cantFail(
+ Obj->getCOFFObj()->getSectionContents(Obj->AddrsigSec, Contents));
const uint8_t *Cur = Contents.begin();
while (Cur != Contents.end()) {
unsigned Size;
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=360648&r1=360647&r2=360648&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Mon May 13 21:22:51 2019
@@ -176,7 +176,7 @@ SectionChunk *ObjFile::readSection(uint3
if (Name == ".drectve") {
ArrayRef<uint8_t> Data;
- COFFObj->getSectionContents(Sec, Data);
+ cantFail(COFFObj->getSectionContents(Sec, Data));
Directives = StringRef((const char *)Data.data(), Data.size());
return nullptr;
}
More information about the llvm-commits
mailing list