mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-29 13:32:33 +00:00
Make createObjectFile's signature a bit less error prone.
This will be better with c++11, but right now file_magic converts to bool, which makes the api really easy to misuse. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bf2b27cfde
commit
07dc57c38a
@ -378,9 +378,13 @@ public:
|
||||
/// return true.
|
||||
/// @brief Create ObjectFile from path.
|
||||
static ErrorOr<ObjectFile *> createObjectFile(StringRef ObjectPath);
|
||||
static ErrorOr<ObjectFile *>
|
||||
createObjectFile(MemoryBuffer *Object, bool BufferOwned = true,
|
||||
sys::fs::file_magic Type = sys::fs::file_magic::unknown);
|
||||
static ErrorOr<ObjectFile *> createObjectFile(MemoryBuffer *Object,
|
||||
bool BufferOwned,
|
||||
sys::fs::file_magic Type);
|
||||
static ErrorOr<ObjectFile *> createObjectFile(MemoryBuffer *Object) {
|
||||
return createObjectFile(Object, true, sys::fs::file_magic::unknown);
|
||||
}
|
||||
|
||||
|
||||
static inline bool classof(const Binary *v) {
|
||||
return v->isObject();
|
||||
|
@ -67,7 +67,7 @@ ErrorOr<Binary *> object::createBinary(MemoryBuffer *Source,
|
||||
case sys::fs::file_magic::coff_object:
|
||||
case sys::fs::file_magic::coff_import_library:
|
||||
case sys::fs::file_magic::pecoff_executable:
|
||||
return ObjectFile::createObjectFile(scopedSource.take(), Type);
|
||||
return ObjectFile::createObjectFile(scopedSource.take(), true, Type);
|
||||
case sys::fs::file_magic::macho_universal_binary:
|
||||
return MachOUniversalBinary::create(scopedSource.take());
|
||||
case sys::fs::file_magic::unknown:
|
||||
|
@ -703,7 +703,8 @@ static void writeSymbolTable(
|
||||
I != E; ++I, ++MemberNum) {
|
||||
MemoryBuffer *MemberBuffer = Buffers[MemberNum];
|
||||
ErrorOr<object::ObjectFile *> ObjOrErr =
|
||||
object::ObjectFile::createObjectFile(MemberBuffer, false);
|
||||
object::ObjectFile::createObjectFile(MemberBuffer, false,
|
||||
sys::fs::file_magic::unknown);
|
||||
if (!ObjOrErr)
|
||||
continue; // FIXME: check only for "not an object file" errors.
|
||||
object::ObjectFile *Obj = ObjOrErr.get();
|
||||
|
Loading…
x
Reference in New Issue
Block a user