[llvm] r238700 - Simplify interface of function that doesn't fail.
Rafael Espindola
rafael.espindola at gmail.com
Sun May 31 16:52:50 PDT 2015
Author: rafael
Date: Sun May 31 18:52:50 2015
New Revision: 238700
URL: http://llvm.org/viewvc/llvm-project?rev=238700&view=rev
Log:
Simplify interface of function that doesn't fail.
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/ObjectFile.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Sun May 31 18:52:50 2015
@@ -79,8 +79,7 @@ protected:
StringRef &Res) const override;
std::error_code getSymbolAddress(DataRefImpl Symb,
uint64_t &Res) const override;
- std::error_code getSymbolAlignment(DataRefImpl Symb,
- uint32_t &Res) const override;
+ uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
std::error_code getSymbolOther(DataRefImpl Symb, uint8_t &Res) const override;
@@ -326,14 +325,11 @@ std::error_code ELFObjectFile<ELFT>::get
}
template <class ELFT>
-std::error_code ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb,
- uint32_t &Res) const {
+uint32_t ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb) const {
Elf_Sym_Iter Sym = toELFSymIter(Symb);
if (Sym->st_shndx == ELF::SHN_COMMON)
- Res = Sym->st_value;
- else
- Res = 0;
- return object_error::success;
+ return Sym->st_value;
+ return 0;
}
template <class ELFT>
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Sun May 31 18:52:50 2015
@@ -204,8 +204,7 @@ public:
std::error_code getSymbolAddress(DataRefImpl Symb,
uint64_t &Res) const override;
- std::error_code getSymbolAlignment(DataRefImpl Symb,
- uint32_t &Res) const override;
+ uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
std::error_code getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Res) const override;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Sun May 31 18:52:50 2015
@@ -146,7 +146,7 @@ public:
/// mapped).
std::error_code getAddress(uint64_t &Result) const;
/// @brief Get the alignment of this symbol as the actual value (not log 2).
- std::error_code getAlignment(uint32_t &Result) const;
+ uint32_t getAlignment() const;
std::error_code getSize(uint64_t &Result) const;
std::error_code getType(SymbolRef::Type &Result) const;
std::error_code getOther(uint8_t &Result) const;
@@ -206,8 +206,7 @@ protected:
DataRefImpl Symb) const override;
virtual std::error_code getSymbolAddress(DataRefImpl Symb,
uint64_t &Res) const = 0;
- virtual std::error_code getSymbolAlignment(DataRefImpl Symb,
- uint32_t &Res) const;
+ virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
virtual std::error_code getSymbolSize(DataRefImpl Symb,
uint64_t &Res) const = 0;
virtual std::error_code getSymbolType(DataRefImpl Symb,
@@ -334,8 +333,8 @@ inline std::error_code SymbolRef::getAdd
return getObject()->getSymbolAddress(getRawDataRefImpl(), Result);
}
-inline std::error_code SymbolRef::getAlignment(uint32_t &Result) const {
- return getObject()->getSymbolAlignment(getRawDataRefImpl(), Result);
+inline uint32_t SymbolRef::getAlignment() const {
+ return getObject()->getSymbolAlignment(getRawDataRefImpl());
}
inline std::error_code SymbolRef::getSize(uint64_t &Result) const {
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Sun May 31 18:52:50 2015
@@ -494,9 +494,8 @@ void RuntimeDyldImpl::emitCommonSymbols(
continue;
}
- uint32_t Align = 0;
+ uint32_t Align = Sym.getAlignment();
uint64_t Size = 0;
- Check(Sym.getAlignment(Align));
Check(Sym.getSize(Size));
CommonSize += Align + Size;
@@ -518,10 +517,9 @@ void RuntimeDyldImpl::emitCommonSymbols(
// Assign the address of each symbol
for (auto &Sym : SymbolsToAllocate) {
- uint32_t Align;
+ uint32_t Align = Sym.getAlignment();
uint64_t Size;
StringRef Name;
- Check(Sym.getAlignment(Align));
Check(Sym.getSize(Size));
Check(Sym.getName(Name));
if (Align) {
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Sun May 31 18:52:50 2015
@@ -401,16 +401,13 @@ std::error_code MachOObjectFile::getSymb
return object_error::success;
}
-std::error_code MachOObjectFile::getSymbolAlignment(DataRefImpl DRI,
- uint32_t &Result) const {
+uint32_t MachOObjectFile::getSymbolAlignment(DataRefImpl DRI) const {
uint32_t flags = getSymbolFlags(DRI);
if (flags & SymbolRef::SF_Common) {
MachO::nlist_base Entry = getSymbolTableEntryBase(this, DRI);
- Result = 1 << MachO::GET_COMM_ALIGN(Entry.n_desc);
- } else {
- Result = 0;
+ return 1 << MachO::GET_COMM_ALIGN(Entry.n_desc);
}
- return object_error::success;
+ return 0;
}
std::error_code MachOObjectFile::getSymbolSize(DataRefImpl DRI,
Modified: llvm/trunk/lib/Object/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ObjectFile.cpp Sun May 31 18:52:50 2015
@@ -37,11 +37,7 @@ std::error_code ObjectFile::printSymbolN
return object_error::success;
}
-std::error_code ObjectFile::getSymbolAlignment(DataRefImpl DRI,
- uint32_t &Result) const {
- Result = 0;
- return object_error::success;
-}
+uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; }
section_iterator ObjectFile::getRelocatedSection(DataRefImpl Sec) const {
return section_iterator(SectionRef(Sec, this));
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=238700&r1=238699&r2=238700&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sun May 31 18:52:50 2015
@@ -697,9 +697,7 @@ void llvm::PrintSymbolTable(const Object
bool Hidden = Flags & SymbolRef::SF_Hidden;
if (Common) {
- uint32_t Alignment;
- if (error(Symbol.getAlignment(Alignment)))
- Alignment = 0;
+ uint32_t Alignment = Symbol.getAlignment();
Address = Size;
Size = Alignment;
}
More information about the llvm-commits
mailing list