[llvm] r362621 - [dsymutil] Support more than 4 architectures

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 10:14:33 PDT 2019


Author: jdevlieghere
Date: Wed Jun  5 10:14:32 2019
New Revision: 362621

URL: http://llvm.org/viewvc/llvm-project?rev=362621&view=rev
Log:
[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.

Modified:
    llvm/trunk/tools/dsymutil/MachOUtils.cpp
    llvm/trunk/tools/dsymutil/MachOUtils.h

Modified: llvm/trunk/tools/dsymutil/MachOUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachOUtils.cpp?rev=362621&r1=362620&r2=362621&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachOUtils.cpp (original)
+++ llvm/trunk/tools/dsymutil/MachOUtils.cpp Wed Jun  5 10:14:32 2019
@@ -35,7 +35,7 @@ llvm::Error ArchAndFile::createTempFile(
   if (!T)
     return T.takeError();
 
-  File = llvm::Optional<sys::fs::TempFile>(std::move(*T));
+  File = llvm::make_unique<sys::fs::TempFile>(std::move(*T));
   return Error::success();
 }
 

Modified: llvm/trunk/tools/dsymutil/MachOUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachOUtils.h?rev=362621&r1=362620&r2=362621&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachOUtils.h (original)
+++ llvm/trunk/tools/dsymutil/MachOUtils.h Wed Jun  5 10:14:32 2019
@@ -26,13 +26,14 @@ namespace MachOUtils {
 struct ArchAndFile {
   std::string Arch;
   // Optional because TempFile has no default constructor.
-  Optional<llvm::sys::fs::TempFile> File;
+  std::unique_ptr<llvm::sys::fs::TempFile> File;
 
   llvm::Error createTempFile();
   llvm::StringRef path() const;
 
   ArchAndFile(StringRef Arch) : Arch(Arch) {}
   ArchAndFile(ArchAndFile &&A) = default;
+  ArchAndFile &operator=(ArchAndFile &&A) = default;
   ~ArchAndFile();
 };
 




More information about the llvm-commits mailing list