Use std::unique_ptr to make the ownership explicit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-07-31 03:12:45 +00:00
parent 0a8cc452b1
commit 79002da926
25 changed files with 74 additions and 60 deletions

View File

@@ -300,9 +300,9 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
return I->second;
Binary *Bin = nullptr;
Binary *DbgBin = nullptr;
ErrorOr<Binary *> BinaryOrErr = createBinary(Path);
ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(Path);
if (!error(BinaryOrErr.getError())) {
std::unique_ptr<Binary> ParsedBinary(BinaryOrErr.get());
std::unique_ptr<Binary> ParsedBinary = std::move(BinaryOrErr.get());
// Check if it's a universal binary.
Bin = ParsedBinary.get();
ParsedBinariesAndObjects.push_back(std::move(ParsedBinary));
@@ -314,8 +314,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
BinaryOrErr = createBinary(ResourcePath);
std::error_code EC = BinaryOrErr.getError();
if (EC != errc::no_such_file_or_directory && !error(EC)) {
DbgBin = BinaryOrErr.get();
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
DbgBin = BinaryOrErr.get().get();
ParsedBinariesAndObjects.push_back(std::move(BinaryOrErr.get()));
}
}
// Try to locate the debug binary using .gnu_debuglink section.
@@ -327,8 +327,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
findDebugBinary(Path, DebuglinkName, CRCHash, DebugBinaryPath)) {
BinaryOrErr = createBinary(DebugBinaryPath);
if (!error(BinaryOrErr.getError())) {
DbgBin = BinaryOrErr.get();
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
DbgBin = BinaryOrErr.get().get();
ParsedBinariesAndObjects.push_back(std::move(BinaryOrErr.get()));
}
}
}