Don't use 'using std::error_code' in include/llvm.

This should make sure that most new uses use the std prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-06-12 21:46:39 +00:00
parent 7418e1f4bd
commit 5c792faa0e
107 changed files with 692 additions and 563 deletions
+130 -109
View File
@@ -57,50 +57,63 @@ protected:
ELFFile<ELFT> EF;
void moveSymbolNext(DataRefImpl &Symb) const override;
error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const override;
error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const override;
error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const override;
error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
std::error_code getSymbolName(DataRefImpl Symb,
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;
std::error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
error_code getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Res) const override;
error_code getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const override;
std::error_code getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Res) const override;
std::error_code getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const override;
error_code getLibraryNext(DataRefImpl Data,
LibraryRef &Result) const override;
error_code getLibraryPath(DataRefImpl Data, StringRef &Res) const override;
std::error_code getLibraryNext(DataRefImpl Data,
LibraryRef &Result) const override;
std::error_code getLibraryPath(DataRefImpl Data,
StringRef &Res) const override;
void moveSectionNext(DataRefImpl &Sec) const override;
error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override;
error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const override;
error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override;
error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const override;
error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
error_code isSectionRequiredForExecution(DataRefImpl Sec,
bool &Res) const override;
error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const override;
error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
bool &Result) const override;
std::error_code getSectionName(DataRefImpl Sec,
StringRef &Res) const override;
std::error_code getSectionAddress(DataRefImpl Sec,
uint64_t &Res) const override;
std::error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const override;
std::error_code getSectionContents(DataRefImpl Sec,
StringRef &Res) const override;
std::error_code getSectionAlignment(DataRefImpl Sec,
uint64_t &Res) const override;
std::error_code isSectionText(DataRefImpl Sec, bool &Res) const override;
std::error_code isSectionData(DataRefImpl Sec, bool &Res) const override;
std::error_code isSectionBSS(DataRefImpl Sec, bool &Res) const override;
std::error_code isSectionRequiredForExecution(DataRefImpl Sec,
bool &Res) const override;
std::error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const override;
std::error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const override;
std::error_code isSectionReadOnlyData(DataRefImpl Sec,
bool &Res) const override;
std::error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb,
bool &Result) const override;
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
section_iterator getRelocatedSection(DataRefImpl Sec) const override;
void moveRelocationNext(DataRefImpl &Rel) const override;
error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const override;
error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const override;
std::error_code getRelocationAddress(DataRefImpl Rel,
uint64_t &Res) const override;
std::error_code getRelocationOffset(DataRefImpl Rel,
uint64_t &Res) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const override;
error_code getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
error_code getRelocationValueString(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
std::error_code getRelocationType(DataRefImpl Rel,
uint64_t &Res) const override;
std::error_code
getRelocationTypeName(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
std::error_code
getRelocationValueString(DataRefImpl Rel,
SmallVectorImpl<char> &Result) const override;
uint64_t getROffset(DataRefImpl Rel) const;
StringRef getRelocationTypeName(uint32_t Type) const;
@@ -164,7 +177,8 @@ protected:
bool isDyldELFObject;
public:
ELFObjectFile(MemoryBuffer *Object, error_code &EC, bool BufferOwned = true);
ELFObjectFile(MemoryBuffer *Object, std::error_code &EC,
bool BufferOwned = true);
const Elf_Sym *getSymbol(DataRefImpl Symb) const;
@@ -180,10 +194,9 @@ public:
library_iterator needed_library_begin() const override;
library_iterator needed_library_end() const override;
error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const;
error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
bool &IsDefault) const;
std::error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const;
std::error_code getSymbolVersion(SymbolRef Symb, StringRef &Version,
bool &IsDefault) const;
uint8_t getBytesInAddress() const override;
StringRef getFileFormatName() const override;
@@ -212,8 +225,8 @@ void ELFObjectFile<ELFT>::moveSymbolNext(DataRefImpl &Symb) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Symb,
StringRef &Result) const {
std::error_code ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Symb,
StringRef &Result) const {
ErrorOr<StringRef> Name = EF.getSymbolName(toELFSymIter(Symb));
if (!Name)
return Name.getError();
@@ -222,9 +235,9 @@ error_code ELFObjectFile<ELFT>::getSymbolName(DataRefImpl Symb,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolVersion(SymbolRef SymRef,
StringRef &Version,
bool &IsDefault) const {
std::error_code ELFObjectFile<ELFT>::getSymbolVersion(SymbolRef SymRef,
StringRef &Version,
bool &IsDefault) const {
DataRefImpl Symb = SymRef.getRawDataRefImpl();
const Elf_Sym *symb = getSymbol(Symb);
ErrorOr<StringRef> Ver =
@@ -236,8 +249,8 @@ error_code ELFObjectFile<ELFT>::getSymbolVersion(SymbolRef SymRef,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb,
uint64_t &Result) const {
std::error_code ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb,
uint64_t &Result) const {
const Elf_Sym *ESym = getSymbol(Symb);
switch (EF.getSymbolTableIndex(ESym)) {
case ELF::SHN_COMMON:
@@ -265,8 +278,8 @@ error_code ELFObjectFile<ELFT>::getSymbolAddress(DataRefImpl Symb,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb,
uint32_t &Res) const {
std::error_code ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb,
uint32_t &Res) const {
Elf_Sym_Iter Sym = toELFSymIter(Symb);
if (Sym->st_shndx == ELF::SHN_COMMON)
Res = Sym->st_value;
@@ -276,15 +289,16 @@ error_code ELFObjectFile<ELFT>::getSymbolAlignment(DataRefImpl Symb,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Symb,
uint64_t &Result) const {
std::error_code ELFObjectFile<ELFT>::getSymbolSize(DataRefImpl Symb,
uint64_t &Result) const {
Result = toELFSymIter(Symb)->st_size;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Result) const {
std::error_code
ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb,
SymbolRef::Type &Result) const {
const Elf_Sym *ESym = getSymbol(Symb);
switch (ESym->getType()) {
@@ -343,8 +357,9 @@ uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const {
std::error_code
ELFObjectFile<ELFT>::getSymbolSection(DataRefImpl Symb,
section_iterator &Res) const {
const Elf_Sym *ESym = getSymbol(Symb);
const Elf_Shdr *ESec = EF.getSection(ESym);
if (!ESec)
@@ -363,8 +378,8 @@ void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
StringRef &Result) const {
std::error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
StringRef &Result) const {
ErrorOr<StringRef> Name = EF.getSectionName(&*toELFShdrIter(Sec));
if (!Name)
return Name.getError();
@@ -373,44 +388,46 @@ error_code ELFObjectFile<ELFT>::getSectionName(DataRefImpl Sec,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec,
uint64_t &Result) const {
std::error_code ELFObjectFile<ELFT>::getSectionAddress(DataRefImpl Sec,
uint64_t &Result) const {
Result = toELFShdrIter(Sec)->sh_addr;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec,
uint64_t &Result) const {
std::error_code ELFObjectFile<ELFT>::getSectionSize(DataRefImpl Sec,
uint64_t &Result) const {
Result = toELFShdrIter(Sec)->sh_size;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
StringRef &Result) const {
std::error_code
ELFObjectFile<ELFT>::getSectionContents(DataRefImpl Sec,
StringRef &Result) const {
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size);
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec,
uint64_t &Result) const {
std::error_code
ELFObjectFile<ELFT>::getSectionAlignment(DataRefImpl Sec,
uint64_t &Result) const {
Result = toELFShdrIter(Sec)->sh_addralign;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec,
bool &Result) const {
std::error_code ELFObjectFile<ELFT>::isSectionText(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec,
bool &Result) const {
std::error_code ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec,
bool &Result) const {
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
EShdr->sh_type == ELF::SHT_PROGBITS;
@@ -418,8 +435,8 @@ error_code ELFObjectFile<ELFT>::isSectionData(DataRefImpl Sec,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec,
bool &Result) const {
std::error_code ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec,
bool &Result) const {
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) &&
EShdr->sh_type == ELF::SHT_NOBITS;
@@ -427,7 +444,7 @@ error_code ELFObjectFile<ELFT>::isSectionBSS(DataRefImpl Sec,
}
template <class ELFT>
error_code
std::error_code
ELFObjectFile<ELFT>::isSectionRequiredForExecution(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_ALLOC;
@@ -435,31 +452,31 @@ ELFObjectFile<ELFT>::isSectionRequiredForExecution(DataRefImpl Sec,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionZeroInit(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::isSectionReadOnlyData(DataRefImpl Sec,
std::error_code ELFObjectFile<ELFT>::isSectionVirtual(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
return object_error::success;
}
template <class ELFT>
std::error_code ELFObjectFile<ELFT>::isSectionZeroInit(DataRefImpl Sec,
bool &Result) const {
Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS;
return object_error::success;
}
template <class ELFT>
std::error_code ELFObjectFile<ELFT>::isSectionReadOnlyData(DataRefImpl Sec,
bool &Result) const {
Elf_Shdr_Iter EShdr = toELFShdrIter(Sec);
Result = !(EShdr->sh_flags & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR));
return object_error::success;
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
DataRefImpl Symb,
bool &Result) const {
std::error_code ELFObjectFile<ELFT>::sectionContainsSymbol(DataRefImpl Sec,
DataRefImpl Symb,
bool &Result) const {
Elf_Sym_Iter ESym = toELFSymIter(Symb);
uintX_t Index = ESym->st_shndx;
@@ -553,8 +570,9 @@ ELFObjectFile<ELFT>::getRelocationSymbol(DataRefImpl Rel) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
uint64_t &Result) const {
std::error_code
ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
uint64_t &Result) const {
uint64_t ROffset = getROffset(Rel);
const Elf_Ehdr *Header = EF.getHeader();
@@ -570,8 +588,9 @@ error_code ELFObjectFile<ELFT>::getRelocationAddress(DataRefImpl Rel,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel,
uint64_t &Result) const {
std::error_code
ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel,
uint64_t &Result) const {
assert(EF.getHeader()->e_type == ELF::ET_REL &&
"Only relocatable object files have relocation offsets");
Result = getROffset(Rel);
@@ -592,8 +611,8 @@ uint64_t ELFObjectFile<ELFT>::getROffset(DataRefImpl Rel) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel,
uint64_t &Result) const {
std::error_code ELFObjectFile<ELFT>::getRelocationType(DataRefImpl Rel,
uint64_t &Result) const {
const Elf_Shdr *sec = getRelSection(Rel);
switch (sec->sh_type) {
default:
@@ -616,7 +635,7 @@ StringRef ELFObjectFile<ELFT>::getRelocationTypeName(uint32_t Type) const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationTypeName(
std::error_code ELFObjectFile<ELFT>::getRelocationTypeName(
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
const Elf_Shdr *sec = getRelSection(Rel);
uint32_t type;
@@ -638,8 +657,9 @@ error_code ELFObjectFile<ELFT>::getRelocationTypeName(
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel,
int64_t &Result) const {
std::error_code
ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel,
int64_t &Result) const {
const Elf_Shdr *sec = getRelSection(Rel);
switch (sec->sh_type) {
default:
@@ -656,7 +676,7 @@ error_code ELFObjectFile<ELFT>::getRelocationAddend(DataRefImpl Rel,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getRelocationValueString(
std::error_code ELFObjectFile<ELFT>::getRelocationValueString(
DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
const Elf_Shdr *sec = getRelSection(Rel);
uint8_t type;
@@ -754,7 +774,7 @@ ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
}
template <class ELFT>
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBuffer *Object, error_code &ec,
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBuffer *Object, std::error_code &ec,
bool BufferOwned)
: ObjectFile(getELFType(static_cast<endianness>(ELFT::TargetEndianness) ==
support::little,
@@ -817,8 +837,8 @@ library_iterator ELFObjectFile<ELFT>::needed_library_begin() const {
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
LibraryRef &Result) const {
std::error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
LibraryRef &Result) const {
Elf_Dyn_Iter DI = toELFDynIter(Data);
Elf_Dyn_Iter DE = EF.end_dynamic_table();
@@ -832,8 +852,8 @@ error_code ELFObjectFile<ELFT>::getLibraryNext(DataRefImpl Data,
}
template <class ELFT>
error_code ELFObjectFile<ELFT>::getLibraryPath(DataRefImpl Data,
StringRef &Res) const {
std::error_code ELFObjectFile<ELFT>::getLibraryPath(DataRefImpl Data,
StringRef &Res) const {
Res = EF.getDynamicString(toELFDynIter(Data)->getVal());
return object_error::success;
}
@@ -931,8 +951,8 @@ unsigned ELFObjectFile<ELFT>::getArch() const {
/// FIXME: Maybe we should have a base ElfObjectFile that is not a template
/// and make these member functions?
inline error_code getELFRelocationAddend(const RelocationRef R,
int64_t &Addend) {
inline std::error_code getELFRelocationAddend(const RelocationRef R,
int64_t &Addend) {
const ObjectFile *Obj = R.getObjectFile();
DataRefImpl DRI = R.getRawDataRefImpl();
// Little-endian 32-bit
@@ -975,9 +995,10 @@ getELFDynamicSymbolIterators(SymbolicFile *Obj) {
/// This is a generic interface for retrieving GNU symbol version
/// information from an ELFObjectFile.
inline error_code GetELFSymbolVersion(const ObjectFile *Obj,
const SymbolRef &Sym, StringRef &Version,
bool &IsDefault) {
inline std::error_code GetELFSymbolVersion(const ObjectFile *Obj,
const SymbolRef &Sym,
StringRef &Version,
bool &IsDefault) {
// Little-endian 32-bit
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
return ELFObj->getSymbolVersion(Sym, Version, IsDefault);