summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-06-30 20:32:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-06-30 20:32:26 +0000
commit10fcac7b0768dfb1d9fb3030f2bb664ad8e4e65b (patch)
tree061af9263ce956b767a139713c0d8ab2862b06a2 /llvm/include
parent391e53812a5ec4ad8ef8cc4b9a9b81b1a7caf762 (diff)
downloadbcm5719-llvm-10fcac7b0768dfb1d9fb3030f2bb664ad8e4e65b.tar.gz
bcm5719-llvm-10fcac7b0768dfb1d9fb3030f2bb664ad8e4e65b.zip
Use ErrorOr in getRelocationAdress.
We can probably do better in this method, but this is an improvement and enables further ErrorOr cleanups. llvm-svn: 241114
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Object/COFF.h3
-rw-r--r--llvm/include/llvm/Object/ELFObjectFile.h15
-rw-r--r--llvm/include/llvm/Object/MachO.h3
-rw-r--r--llvm/include/llvm/Object/ObjectFile.h9
4 files changed, 11 insertions, 19 deletions
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h
index b64945dd652..95623364fd4 100644
--- a/llvm/include/llvm/Object/COFF.h
+++ b/llvm/include/llvm/Object/COFF.h
@@ -673,8 +673,7 @@ protected:
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
void moveRelocationNext(DataRefImpl &Rel) const override;
- std::error_code getRelocationAddress(DataRefImpl Rel,
- uint64_t &Res) const override;
+ ErrorOr<uint64_t> getRelocationAddress(DataRefImpl Rel) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
uint64_t getRelocationType(DataRefImpl Rel) const override;
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index f2c65dc21d8..f5fc132711c 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -227,8 +227,7 @@ protected:
section_iterator getRelocatedSection(DataRefImpl Sec) const override;
void moveRelocationNext(DataRefImpl &Rel) const override;
- std::error_code getRelocationAddress(DataRefImpl Rel,
- uint64_t &Res) const override;
+ ErrorOr<uint64_t> getRelocationAddress(DataRefImpl Rel) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
uint64_t getRelocationType(DataRefImpl Rel) const override;
@@ -670,21 +669,17 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
}
template <class ELFT>
-std::error_code
-ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
- uint64_t &Result) const {
+ErrorOr<uint64_t>
+ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel) const {
uint64_t ROffset = getROffset(Rel);
const Elf_Ehdr *Header = EF.getHeader();
if (Header->e_type == ELF::ET_REL) {
const Elf_Shdr *RelocationSec = getRelSection(Rel);
const Elf_Shdr *RelocatedSec = EF.getSection(RelocationSec->sh_info);
- Result = ROffset + RelocatedSec->sh_addr;
- } else {
- Result = ROffset;
+ return ROffset + RelocatedSec->sh_addr;
}
-
- return std::error_code();
+ return ROffset;
}
template <class ELFT>
diff --git a/llvm/include/llvm/Object/MachO.h b/llvm/include/llvm/Object/MachO.h
index 0e934e5a66d..1978223169e 100644
--- a/llvm/include/llvm/Object/MachO.h
+++ b/llvm/include/llvm/Object/MachO.h
@@ -234,8 +234,7 @@ public:
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
void moveRelocationNext(DataRefImpl &Rel) const override;
- std::error_code getRelocationAddress(DataRefImpl Rel,
- uint64_t &Res) const override;
+ ErrorOr<uint64_t> getRelocationAddress(DataRefImpl Rel) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
section_iterator getRelocationSection(DataRefImpl Rel) const;
diff --git a/llvm/include/llvm/Object/ObjectFile.h b/llvm/include/llvm/Object/ObjectFile.h
index 4f26ce9661c..bd864f250bd 100644
--- a/llvm/include/llvm/Object/ObjectFile.h
+++ b/llvm/include/llvm/Object/ObjectFile.h
@@ -50,7 +50,7 @@ public:
void moveNext();
- std::error_code getAddress(uint64_t &Result) const;
+ ErrorOr<uint64_t> getAddress() const;
uint64_t getOffset() const;
symbol_iterator getSymbol() const;
uint64_t getType() const;
@@ -230,8 +230,7 @@ protected:
// Same as above for RelocationRef.
friend class RelocationRef;
virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
- virtual std::error_code getRelocationAddress(DataRefImpl Rel,
- uint64_t &Res) const = 0;
+ virtual ErrorOr<uint64_t> getRelocationAddress(DataRefImpl Rel) const = 0;
virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
@@ -432,8 +431,8 @@ inline void RelocationRef::moveNext() {
return OwningObject->moveRelocationNext(RelocationPimpl);
}
-inline std::error_code RelocationRef::getAddress(uint64_t &Result) const {
- return OwningObject->getRelocationAddress(RelocationPimpl, Result);
+inline ErrorOr<uint64_t> RelocationRef::getAddress() const {
+ return OwningObject->getRelocationAddress(RelocationPimpl);
}
inline uint64_t RelocationRef::getOffset() const {
OpenPOWER on IntegriCloud