forked from OSchip/llvm-project
[Object] Deduplicate the three createError functions
The Object library currently has three identical functions that translate a Twine into a parser error. Until recently these functions have coexisted peacefully, but since D110320 Clang with enabled modules is now diagnosing that we have several definitions of `createError` in Object. This patch just merges them all and puts them into Object's `Error.h` where the error code for `parse_failed` is also defined which seems cleaner and unbreaks the bots. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D111541
This commit is contained in:
parent
c3abfe4207
commit
bdc35b0efc
|
@ -81,10 +81,6 @@ getElfArchType(StringRef Object) {
|
||||||
(uint8_t)Object[ELF::EI_DATA]);
|
(uint8_t)Object[ELF::EI_DATA]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Error createError(const Twine &Err) {
|
|
||||||
return make_error<StringError>(Err, object_error::parse_failed);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PPCInstrMasks : uint64_t {
|
enum PPCInstrMasks : uint64_t {
|
||||||
PADDI_R12_NO_DISP = 0x0610000039800000,
|
PADDI_R12_NO_DISP = 0x0610000039800000,
|
||||||
ADDIS_R12_TO_R2_NO_DISP = 0x3D820000,
|
ADDIS_R12_TO_R2_NO_DISP = 0x3D820000,
|
||||||
|
|
|
@ -82,6 +82,10 @@ private:
|
||||||
/// error() function needs to called on the llvm::Error.
|
/// error() function needs to called on the llvm::Error.
|
||||||
Error isNotObjectErrorInvalidFileType(llvm::Error Err);
|
Error isNotObjectErrorInvalidFileType(llvm::Error Err);
|
||||||
|
|
||||||
|
inline Error createError(const Twine &Err) {
|
||||||
|
return make_error<StringError>(Err, object_error::parse_failed);
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace object.
|
} // end namespace object.
|
||||||
|
|
||||||
} // end namespace llvm.
|
} // end namespace llvm.
|
||||||
|
|
|
@ -80,11 +80,6 @@ static bool isDecorated(StringRef Sym, bool MingwDef) {
|
||||||
(!MingwDef && Sym.contains('@'));
|
(!MingwDef && Sym.contains('@'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Error createError(const Twine &Err) {
|
|
||||||
return make_error<StringError>(StringRef(Err.str()),
|
|
||||||
object_error::parse_failed);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Lexer {
|
class Lexer {
|
||||||
public:
|
public:
|
||||||
Lexer(StringRef S) : Buf(S) {}
|
Lexer(StringRef S) : Buf(S) {}
|
||||||
|
|
|
@ -43,10 +43,6 @@ static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset) {
|
||||||
Offset);
|
Offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Error createError(const Twine &Err) {
|
|
||||||
return make_error<StringError>(Err, object_error::parse_failed);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> static const T *viewAs(uintptr_t in) {
|
template <typename T> static const T *viewAs(uintptr_t in) {
|
||||||
return reinterpret_cast<const T *>(in);
|
return reinterpret_cast<const T *>(in);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue