diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2015-10-26 19:41:23 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2015-10-26 19:41:23 +0000 |
| commit | 7a952e53f9782b59b3c3b8598915c794ec331827 (patch) | |
| tree | 25527acf29de30dcbbe78b9ecbd96f370d7338a3 /llvm/lib/DebugInfo/Symbolize | |
| parent | 7ff1836471151f6f0524aa674a5bb9a0be3447f1 (diff) | |
| download | bcm5719-llvm-7a952e53f9782b59b3c3b8598915c794ec331827.tar.gz bcm5719-llvm-7a952e53f9782b59b3c3b8598915c794ec331827.zip | |
[LLVMSymbolize] Use std::unique_ptr more extensively to clarify ownership.
llvm-svn: 251336
Diffstat (limited to 'llvm/lib/DebugInfo/Symbolize')
| -rw-r--r-- | llvm/lib/DebugInfo/Symbolize/Symbolize.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp index ffe3747db0c..57e24c94858 100644 --- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -61,8 +61,8 @@ getDILineInfoSpecifier(const LLVMSymbolizer::Options &Opts) { Opts.PrintFunctions); } -ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx) - : Module(Obj), DebugInfoContext(DICtx) { +ModuleInfo::ModuleInfo(ObjectFile *Obj, std::unique_ptr<DIContext> DICtx) + : Module(Obj), DebugInfoContext(std::move(DICtx)) { std::unique_ptr<DataExtractor> OpdExtractor; uint64_t OpdAddress = 0; // Find the .opd (function descriptor) section if any, for big-endian @@ -308,7 +308,7 @@ std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName, } void LLVMSymbolizer::flush() { - DeleteContainerSeconds(Modules); + Modules.clear(); ObjectPairForPathArch.clear(); ObjectFileForArch.clear(); } @@ -512,7 +512,7 @@ ModuleInfo * LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { const auto &I = Modules.find(ModuleName); if (I != Modules.end()) - return I->second; + return I->second.get(); std::string BinaryName = ModuleName; std::string ArchName = Opts.DefaultArch; size_t ColonPos = ModuleName.find_last_of(':'); @@ -528,10 +528,10 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { if (!Objects.first) { // Failed to find valid object file. - Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr)); + Modules.emplace(ModuleName, nullptr); return nullptr; } - DIContext *Context = nullptr; + std::unique_ptr<DIContext> Context; if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) { // If this is a COFF object, assume it contains PDB debug information. If // we don't find any we will fall back to the DWARF case. @@ -539,15 +539,16 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) { PDB_ErrorCode Error = loadDataForEXE(PDB_ReaderType::DIA, Objects.first->getFileName(), Session); if (Error == PDB_ErrorCode::Success) { - Context = new PDBContext(*CoffObject, std::move(Session)); + Context.reset(new PDBContext(*CoffObject, std::move(Session))); } } if (!Context) - Context = new DWARFContextInMemory(*Objects.second); + Context.reset(new DWARFContextInMemory(*Objects.second)); assert(Context); - ModuleInfo *Info = new ModuleInfo(Objects.first, Context); - Modules.insert(make_pair(ModuleName, Info)); - return Info; + auto Info = make_unique<ModuleInfo>(Objects.first, std::move(Context)); + ModuleInfo *Res = Info.get(); + Modules.emplace(ModuleName, std::move(Info)); + return Res; } std::string LLVMSymbolizer::printDILineInfo(DILineInfo LineInfo, |

