aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOUniversal.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-12-09Return ErrorOr<std::unique_ptr<Archive>> form getAsArchive.Rafael Espindola1-14/+10
This is the same return type of Archive::create. llvm-svn: 223827
2014-10-20Be more specific about return type of MachOUniversalBinary::getObjectForArchAlexey Samsonov1-2/+2
llvm-svn: 220230
2014-09-03unique_ptrify MachOUniversalBinary::createDavid Blaikie1-2/+2
llvm-svn: 217052
2014-08-19Fix a pair of use after free. Should bring the bots back.Rafael Espindola1-2/+2
llvm-svn: 216005
2014-08-19Don't own the buffer in object::Binary.Rafael Espindola1-13/+9
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
2014-07-31A std::unique_ptr case I missed in the previous patch.Rafael Espindola1-2/+3
llvm-svn: 214379
2014-06-24Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.Rafael Espindola1-8/+9
Once the objects are constructed, they own the buffer. Passing a unique_ptr makes that clear. llvm-svn: 211595
2014-06-23Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola1-2/+2
This makes the buffer ownership on error conditions very natural. The buffer is only moved out of the argument if an object is constructed that now owns the buffer. llvm-svn: 211546
2014-06-23Convert a few methods to use ErrorOr.Rafael Espindola1-10/+6
It used to be inconvenient to mix ErrorOr and UniquePtr, but with c++11 they work OK together. llvm-svn: 211532
2014-06-19Change the output of llvm-nm and llvm-size for Mach-O universal files (akaKevin Enderby1-6/+2
fat files) to print “ (for architecture XYZ)” for fat files with more than one architecture to be like what the darwin tools do for fat files. Also clean up the Mach-O printing of archive membernames in llvm-nm to use the darwin form of "libx.a(foo.o)". llvm-svn: 211316
2014-06-18Teach llvm-size to know about Mach-O universal files (aka fat files) andKevin Enderby1-1/+1
fat files containing archives. Also fix a bug in MachOUniversalBinary::ObjectForArch::ObjectForArch() where it needed a >= when comparing the Index with the number of objects in a fat file. As the index starts at 0. llvm-svn: 211230
2014-06-14Replacing the private implementations of SwapValue with calls to ↵Artyom Skrobov1-12/+7
sys::swapByteOrder() llvm-svn: 210980
2014-06-14Renaming SwapByteOrder() to getSwappedBytes()Artyom Skrobov1-1/+1
The next commit will add swapByteOrder(), acting in-place llvm-svn: 210973
2014-06-13Remove 'using std::errro_code' from lib.Rafael Espindola1-10/+8
llvm-svn: 210871
2014-06-12Don't use 'using std::error_code' in include/llvm.Rafael Espindola1-0/+1
This should make sure that most new uses use the std prefix. llvm-svn: 210835
2014-05-14Teach llvm-nm to know about fat archives (aka MachOUniversal filesKevin Enderby1-0/+20
containing archives). First step as other tools will be updated next. llvm-svn: 208812
2014-04-15[C++11] More 'nullptr' conversion. In some cases just using a boolean check ↵Craig Topper1-1/+1
instead of comparing to nullptr. llvm-svn: 206252
2014-03-06Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles1-5/+5
This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
2014-03-05[C++11] Replace OwningPtr::take() with OwningPtr::release().Ahmed Charles1-1/+1
llvm-svn: 202957
2014-01-21Be a bit more consistent about using ErrorOr when constructing Binary objects.Rafael Espindola1-4/+14
The constructors of classes deriving from Binary normally take an error_code as an argument to the constructor. My original intent was to change them to have a trivial constructor and move the initial parsing logic to a static method returning an ErrorOr. I changed my mind because: * A constructor with an error_code out parameter is extremely convenient from the implementation side. We can incrementally construct the object and give up when we find an error. * It is very efficient when constructing on the stack or when there is no error. The only inefficient case is where heap allocating and an error is found (we have to free the memory). The result is that this is a much smaller patch. It just standardizes the create* helpers to return an ErrorOr. Almost no functionality change: The only difference is that this found that we were trying to read past the end of COFF import library but ignoring the error. llvm-svn: 199770
2014-01-07Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth1-1/+0
subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
2013-09-01Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis1-29/+29
llvm-svn: 189728
2013-08-27Revert "Fix the build broken by r189315." and "Move everything depending on ↵Charles Davis1-29/+29
Object/MachOFormat.h over to Support/MachO.h." This reverts commits r189319 and r189315. r189315 broke some tests on what I believe are big-endian platforms. llvm-svn: 189321
2013-08-27Move everything depending on Object/MachOFormat.h over to Support/MachO.h.Charles Davis1-29/+29
llvm-svn: 189315
2013-06-19MachOUniversal.cpp: Fix abuse of Twine. It would be sufficient to use ↵NAKAMURA Takumi1-3/+3
std::string instead. llvm-svn: 184291
2013-06-18Basic support for parsing Mach-O universal binaries in LLVMObject libraryAlexey Samsonov1-0/+139
llvm-svn: 184191