From: Jonas Devlieghere Date: Wed, 5 Jun 2019 17:14:32 +0000 (+0000) Subject: [dsymutil] Support more than 4 architectures X-Git-Tag: llvmorg-10-init~3691 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3027a2999c32d4cdedf9b639b61fc4653f1bba4b;p=platform%2Fupstream%2Fllvm.git [dsymutil] Support more than 4 architectures When running dsymutil on a fat binary, we use temporary files in a small vector of size four. When processing more than 4 architectures, this resulted in a user-after-move, because the temporary files got moved to the heap. Instead of storing an optional temp file, we now use a unique pointer, so the location of the actual temp file doesn't change. We could test this by checking in 5 binaries for 5 different architectures, but this seems wasteful, especially since the number of elements in the small vector is arbitrary. llvm-svn: 362621 --- diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp index b7ab352..cd0f280 100644 --- a/llvm/tools/dsymutil/MachOUtils.cpp +++ b/llvm/tools/dsymutil/MachOUtils.cpp @@ -35,7 +35,7 @@ llvm::Error ArchAndFile::createTempFile() { if (!T) return T.takeError(); - File = llvm::Optional(std::move(*T)); + File = llvm::make_unique(std::move(*T)); return Error::success(); } diff --git a/llvm/tools/dsymutil/MachOUtils.h b/llvm/tools/dsymutil/MachOUtils.h index 83b6481..bc88f58 100644 --- a/llvm/tools/dsymutil/MachOUtils.h +++ b/llvm/tools/dsymutil/MachOUtils.h @@ -26,13 +26,14 @@ namespace MachOUtils { struct ArchAndFile { std::string Arch; // Optional because TempFile has no default constructor. - Optional File; + std::unique_ptr File; llvm::Error createTempFile(); llvm::StringRef path() const; ArchAndFile(StringRef Arch) : Arch(Arch) {} ArchAndFile(ArchAndFile &&A) = default; + ArchAndFile &operator=(ArchAndFile &&A) = default; ~ArchAndFile(); };