[llvm] r206866 - Use unique_ptr to manage ParsedBinariesAndObjects in LLVMSymbolizer
David Blaikie
dblaikie at gmail.com
Mon Apr 21 22:26:15 PDT 2014
Author: dblaikie
Date: Tue Apr 22 00:26:14 2014
New Revision: 206866
URL: http://llvm.org/viewvc/llvm-project?rev=206866&view=rev
Log:
Use unique_ptr to manage ParsedBinariesAndObjects in LLVMSymbolizer
Modified:
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=206866&r1=206865&r2=206866&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Tue Apr 22 00:26:14 2014
@@ -207,7 +207,6 @@ std::string LLVMSymbolizer::symbolizeDat
void LLVMSymbolizer::flush() {
DeleteContainerSeconds(Modules);
- DeleteContainerPointers(ParsedBinariesAndObjects);
BinaryForPath.clear();
ObjectFileForArch.clear();
}
@@ -305,8 +304,8 @@ LLVMSymbolizer::getOrCreateBinary(const
if (!error(BinaryOrErr.getError())) {
std::unique_ptr<Binary> ParsedBinary(BinaryOrErr.get());
// Check if it's a universal binary.
- Bin = ParsedBinary.release();
- ParsedBinariesAndObjects.push_back(Bin);
+ Bin = ParsedBinary.get();
+ ParsedBinariesAndObjects.push_back(std::move(ParsedBinary));
if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
// On Darwin we may find DWARF in separate object file in
// resource directory.
@@ -316,7 +315,7 @@ LLVMSymbolizer::getOrCreateBinary(const
error_code EC = BinaryOrErr.getError();
if (EC != errc::no_such_file_or_directory && !error(EC)) {
DbgBin = BinaryOrErr.get();
- ParsedBinariesAndObjects.push_back(DbgBin);
+ ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
}
}
// Try to locate the debug binary using .gnu_debuglink section.
@@ -329,7 +328,7 @@ LLVMSymbolizer::getOrCreateBinary(const
BinaryOrErr = createBinary(DebugBinaryPath);
if (!error(BinaryOrErr.getError())) {
DbgBin = BinaryOrErr.get();
- ParsedBinariesAndObjects.push_back(DbgBin);
+ ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
}
}
}
@@ -353,8 +352,8 @@ LLVMSymbolizer::getObjectFileFromBinary(
return I->second;
std::unique_ptr<ObjectFile> ParsedObj;
if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
- Res = ParsedObj.release();
- ParsedBinariesAndObjects.push_back(Res);
+ Res = ParsedObj.get();
+ ParsedBinariesAndObjects.push_back(std::move(ParsedObj));
}
ObjectFileForArch[std::make_pair(UB, ArchName)] = Res;
} else if (Bin->isObject()) {
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=206866&r1=206865&r2=206866&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Tue Apr 22 00:26:14 2014
@@ -19,6 +19,7 @@
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/MemoryBuffer.h"
#include <map>
+#include <memory>
#include <string>
namespace llvm {
@@ -72,7 +73,7 @@ private:
std::string printDILineInfo(DILineInfo LineInfo) const;
// Owns all the parsed binaries and object files.
- SmallVector<Binary*, 4> ParsedBinariesAndObjects;
+ SmallVector<std::unique_ptr<Binary>, 4> ParsedBinariesAndObjects;
// Owns module info objects.
typedef std::map<std::string, ModuleInfo *> ModuleMapTy;
ModuleMapTy Modules;
More information about the llvm-commits
mailing list