[PATCH] D111541: [Object] Deduplicate the three createError functions
Raphael Isemann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 11 06:06:49 PDT 2021
teemperor created this revision.
teemperor added reviewers: jhenderson, Higuoxing, qiucf.
Herald added a subscriber: hiraditya.
teemperor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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 <https://reviews.llvm.org/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.
https://reviews.llvm.org/D111541
Files:
llvm/include/llvm/Object/ELF.h
llvm/include/llvm/Object/Error.h
llvm/lib/Object/COFFModuleDefinition.cpp
llvm/lib/Object/XCOFFObjectFile.cpp
Index: llvm/lib/Object/XCOFFObjectFile.cpp
===================================================================
--- llvm/lib/Object/XCOFFObjectFile.cpp
+++ llvm/lib/Object/XCOFFObjectFile.cpp
@@ -43,10 +43,6 @@
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) {
return reinterpret_cast<const T *>(in);
}
Index: llvm/lib/Object/COFFModuleDefinition.cpp
===================================================================
--- llvm/lib/Object/COFFModuleDefinition.cpp
+++ llvm/lib/Object/COFFModuleDefinition.cpp
@@ -80,11 +80,6 @@
(!MingwDef && Sym.contains('@'));
}
-static Error createError(const Twine &Err) {
- return make_error<StringError>(StringRef(Err.str()),
- object_error::parse_failed);
-}
-
class Lexer {
public:
Lexer(StringRef S) : Buf(S) {}
Index: llvm/include/llvm/Object/Error.h
===================================================================
--- llvm/include/llvm/Object/Error.h
+++ llvm/include/llvm/Object/Error.h
@@ -82,6 +82,10 @@
/// error() function needs to called on the llvm::Error.
Error isNotObjectErrorInvalidFileType(llvm::Error Err);
+static inline Error createError(const Twine &Err) {
+ return make_error<StringError>(Err, object_error::parse_failed);
+}
+
} // end namespace object.
} // end namespace llvm.
Index: llvm/include/llvm/Object/ELF.h
===================================================================
--- llvm/include/llvm/Object/ELF.h
+++ llvm/include/llvm/Object/ELF.h
@@ -81,10 +81,6 @@
(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 {
PADDI_R12_NO_DISP = 0x0610000039800000,
ADDIS_R12_TO_R2_NO_DISP = 0x3D820000,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111541.378642.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211011/c73beda0/attachment.bin>
More information about the llvm-commits
mailing list