[lldb] Use std::make_unique<> (NFC)

Update the rest of lldb to use std::make_unique<>. I used clang-tidy to
automate this, which probably missed cases that are wrapped in ifdefs.
This commit is contained in:
Jonas Devlieghere 2020-06-24 17:44:33 -07:00
parent b5c24c24a4
commit 06412dae82
44 changed files with 154 additions and 144 deletions

View File

@ -369,7 +369,7 @@ BreakpointOptions *BreakpointLocation::GetLocationOptions() {
// potentially expensive and we don't want to do that for the simple case
// where someone is just disabling the location.
if (m_options_up == nullptr)
m_options_up.reset(new BreakpointOptions(false));
m_options_up = std::make_unique<BreakpointOptions>(false);
return m_options_up.get();
}

View File

@ -154,7 +154,7 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions &rhs)
m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(),
m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
if (rhs.m_thread_spec_up != nullptr)
m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
}
@ -170,7 +170,7 @@ operator=(const BreakpointOptions &rhs) {
m_one_shot = rhs.m_one_shot;
m_ignore_count = rhs.m_ignore_count;
if (rhs.m_thread_spec_up != nullptr)
m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
m_auto_continue = rhs.m_auto_continue;
@ -223,7 +223,8 @@ void BreakpointOptions::CopyOverSetOptions(const BreakpointOptions &incoming)
}
if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_up) {
if (!m_thread_spec_up)
m_thread_spec_up.reset(new ThreadSpec(*incoming.m_thread_spec_up));
m_thread_spec_up =
std::make_unique<ThreadSpec>(*incoming.m_thread_spec_up);
else
*m_thread_spec_up = *incoming.m_thread_spec_up;
m_set_flags.Set(eThreadSpec);
@ -509,7 +510,7 @@ const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const {
ThreadSpec *BreakpointOptions::GetThreadSpec() {
if (m_thread_spec_up == nullptr) {
m_set_flags.Set(eThreadSpec);
m_thread_spec_up.reset(new ThreadSpec());
m_thread_spec_up = std::make_unique<ThreadSpec>();
}
return m_thread_spec_up.get();

View File

@ -36,7 +36,7 @@ WatchpointOptions::WatchpointOptions(const WatchpointOptions &rhs)
m_callback_is_synchronous(rhs.m_callback_is_synchronous),
m_thread_spec_up() {
if (rhs.m_thread_spec_up != nullptr)
m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
}
// WatchpointOptions assignment operator
@ -46,7 +46,7 @@ operator=(const WatchpointOptions &rhs) {
m_callback_baton_sp = rhs.m_callback_baton_sp;
m_callback_is_synchronous = rhs.m_callback_is_synchronous;
if (rhs.m_thread_spec_up != nullptr)
m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
return *this;
}
@ -108,7 +108,7 @@ const ThreadSpec *WatchpointOptions::GetThreadSpecNoCreate() const {
ThreadSpec *WatchpointOptions::GetThreadSpec() {
if (m_thread_spec_up == nullptr)
m_thread_spec_up.reset(new ThreadSpec());
m_thread_spec_up = std::make_unique<ThreadSpec>();
return m_thread_spec_up.get();
}

View File

@ -4622,8 +4622,8 @@ protected:
// First step, make the specifier.
std::unique_ptr<SymbolContextSpecifier> specifier_up;
if (m_options.m_sym_ctx_specified) {
specifier_up.reset(
new SymbolContextSpecifier(GetDebugger().GetSelectedTarget()));
specifier_up = std::make_unique<SymbolContextSpecifier>(
GetDebugger().GetSelectedTarget());
if (!m_options.m_module_name.empty()) {
specifier_up->AddSpecification(

View File

@ -1031,8 +1031,8 @@ protected:
std::unique_ptr<RegularExpression> formatter_regex;
if (m_options.m_category_regex.OptionWasSet()) {
category_regex.reset(new RegularExpression(
m_options.m_category_regex.GetCurrentValueAsRef()));
category_regex = std::make_unique<RegularExpression>(
m_options.m_category_regex.GetCurrentValueAsRef());
if (!category_regex->IsValid()) {
result.AppendErrorWithFormat(
"syntax error in category regular expression '%s'",
@ -1044,8 +1044,8 @@ protected:
if (argc == 1) {
const char *arg = command.GetArgumentAtIndex(0);
formatter_regex.reset(
new RegularExpression(llvm::StringRef::withNullAsEmpty(arg)));
formatter_regex = std::make_unique<RegularExpression>(
llvm::StringRef::withNullAsEmpty(arg));
if (!formatter_regex->IsValid()) {
result.AppendErrorWithFormat("syntax error in regular expression '%s'",
arg);
@ -2092,7 +2092,8 @@ protected:
if (argc == 1) {
const char *arg = command.GetArgumentAtIndex(0);
regex.reset(new RegularExpression(llvm::StringRef::withNullAsEmpty(arg)));
regex = std::make_unique<RegularExpression>(
llvm::StringRef::withNullAsEmpty(arg));
if (!regex->IsValid()) {
result.AppendErrorWithFormat(
"syntax error in category regular expression '%s'", arg);

View File

@ -253,9 +253,9 @@ IOHandlerEditline::IOHandlerEditline(
m_input_sp && m_input_sp->GetIsRealTerminal();
if (use_editline) {
m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
GetOutputFILE(), GetErrorFILE(),
m_color_prompts));
m_editline_up = std::make_unique<Editline>(editline_name, GetInputFILE(),
GetOutputFILE(), GetErrorFILE(),
m_color_prompts);
m_editline_up->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
m_editline_up->SetAutoCompleteCallback(AutoCompleteCallback, this);
// See if the delegate supports fixing indentation

View File

@ -3910,7 +3910,7 @@ IOHandlerCursesGUI::IOHandlerCursesGUI(Debugger &debugger)
void IOHandlerCursesGUI::Activate() {
IOHandler::Activate();
if (!m_app_ap) {
m_app_ap.reset(new Application(GetInputFILE(), GetOutputFILE()));
m_app_ap = std::make_unique<Application>(GetInputFILE(), GetOutputFILE());
// This is both a window and a menu delegate
std::shared_ptr<ApplicationDelegate> app_delegate_sp(

View File

@ -265,11 +265,9 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
builder.setEngineKind(llvm::EngineKind::JIT)
.setErrorStr(&error_string)
.setRelocationModel(triple.isOSBinFormatMachO()
? llvm::Reloc::PIC_
: llvm::Reloc::Static)
.setMCJITMemoryManager(
std::unique_ptr<MemoryManager>(new MemoryManager(*this)))
.setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
: llvm::Reloc::Static)
.setMCJITMemoryManager(std::make_unique<MemoryManager>(*this))
.setOptLevel(llvm::CodeGenOpt::Less);
llvm::StringRef mArch;

View File

@ -399,7 +399,8 @@ uint32_t Materializer::AddPersistentVariable(
lldb::ExpressionVariableSP &persistent_variable_sp,
PersistentVariableDelegate *delegate, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(new EntityPersistentVariable(persistent_variable_sp, delegate));
*iter = std::make_unique<EntityPersistentVariable>(persistent_variable_sp,
delegate);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@ -752,7 +753,7 @@ private:
uint32_t Materializer::AddVariable(lldb::VariableSP &variable_sp, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(new EntityVariable(variable_sp));
*iter = std::make_unique<EntityVariable>(variable_sp);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@ -1030,8 +1031,8 @@ uint32_t Materializer::AddResultVariable(const CompilerType &type,
PersistentVariableDelegate *delegate,
Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(new EntityResultVariable(type, is_program_reference,
keep_in_memory, delegate));
*iter = std::make_unique<EntityResultVariable>(type, is_program_reference,
keep_in_memory, delegate);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@ -1147,7 +1148,7 @@ private:
uint32_t Materializer::AddSymbol(const Symbol &symbol_sp, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(new EntitySymbol(symbol_sp));
*iter = std::make_unique<EntitySymbol>(symbol_sp);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@ -1324,7 +1325,7 @@ private:
uint32_t Materializer::AddRegister(const RegisterInfo &register_info,
Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
iter->reset(new EntityRegister(register_info));
*iter = std::make_unique<EntityRegister>(register_info);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;

View File

@ -209,7 +209,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
// this. For now, we assume we must assume we don't own it.
std::unique_ptr<TCPSocket> tcp_socket;
tcp_socket.reset(new TCPSocket(fd, false, false));
tcp_socket = std::make_unique<TCPSocket>(fd, false, false);
// Try and get a socket option from this file descriptor to see if
// this is a socket and set m_is_socket accordingly.
int resuse;

View File

@ -798,7 +798,8 @@ void Options::HandleOptionArgumentCompletion(
interpreter.GetDebugger().GetSelectedTarget();
// Search filters require a target...
if (target_sp)
filter_up.reset(new SearchFilterByModule(target_sp, module_spec));
filter_up =
std::make_unique<SearchFilterByModule>(target_sp, module_spec);
}
break;
}

View File

@ -102,6 +102,5 @@ Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
std::unique_ptr<ScriptInterpreterLocker>
ScriptInterpreter::AcquireInterpreterLock() {
return std::unique_ptr<ScriptInterpreterLocker>(
new ScriptInterpreterLocker());
return std::make_unique<ScriptInterpreterLocker>();
}

View File

@ -331,7 +331,7 @@ ClangExpressionParser::ClangExpressionParser(
}
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
m_compiler = std::make_unique<CompilerInstance>();
// When capturing a reproducer, hook up the file collector with clang to
// collector modules and headers.
@ -641,12 +641,12 @@ ClangExpressionParser::ClangExpressionParser(
m_compiler->createASTContext();
clang::ASTContext &ast_context = m_compiler->getASTContext();
m_ast_context.reset(new TypeSystemClang(
"Expression ASTContext for '" + m_filename + "'", ast_context));
m_ast_context = std::make_unique<TypeSystemClang>(
"Expression ASTContext for '" + m_filename + "'", ast_context);
std::string module_name("$__lldb_module");
m_llvm_context.reset(new LLVMContext());
m_llvm_context = std::make_unique<LLVMContext>();
m_code_generator.reset(CreateLLVMCodeGen(
m_compiler->getDiagnostics(), module_name,
m_compiler->getHeaderSearchOpts(), m_compiler->getPreprocessorOpts(),
@ -1047,11 +1047,11 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
std::unique_ptr<clang::ASTConsumer> Consumer;
if (ast_transformer) {
Consumer.reset(new ASTConsumerForwarder(ast_transformer));
Consumer = std::make_unique<ASTConsumerForwarder>(ast_transformer);
} else if (m_code_generator) {
Consumer.reset(new ASTConsumerForwarder(m_code_generator.get()));
Consumer = std::make_unique<ASTConsumerForwarder>(m_code_generator.get());
} else {
Consumer.reset(new ASTConsumer());
Consumer = std::make_unique<ASTConsumer>();
}
clang::ASTContext &ast_context = m_compiler->getASTContext();

View File

@ -209,8 +209,8 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
clang::ASTConsumer *
ClangFunctionCaller::ClangFunctionCallerHelper::ASTTransformer(
clang::ASTConsumer *passthrough) {
m_struct_extractor.reset(new ASTStructExtractor(
passthrough, m_owner.GetWrapperStructName(), m_owner));
m_struct_extractor = std::make_unique<ASTStructExtractor>(
passthrough, m_owner.GetWrapperStructName(), m_owner);
return m_struct_extractor.get();
}

View File

@ -187,9 +187,9 @@ ClangModulesDeclVendorImpl::ClangModulesDeclVendorImpl(
m_parser(std::move(parser)) {
// Initialize our TypeSystemClang.
m_ast_context.reset(
new TypeSystemClang("ClangModulesDeclVendor ASTContext",
m_compiler_instance->getASTContext()));
m_ast_context =
std::make_unique<TypeSystemClang>("ClangModulesDeclVendor ASTContext",
m_compiler_instance->getASTContext());
}
void ClangModulesDeclVendorImpl::ReportModuleExportsHelper(

View File

@ -595,7 +595,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
// Parse the expression
//
m_materializer_up.reset(new Materializer());
m_materializer_up = std::make_unique<Materializer>();
ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
@ -783,7 +783,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// Parse the expression
//
m_materializer_up.reset(new Materializer());
m_materializer_up = std::make_unique<Materializer>();
ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
@ -919,16 +919,16 @@ void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(
auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
ast_importer = persistent_vars->GetClangASTImporter();
}
m_expr_decl_map_up.reset(
new ClangExpressionDeclMap(keep_result_in_memory, &delegate,
exe_ctx.GetTargetSP(), ast_importer, ctx_obj));
m_expr_decl_map_up = std::make_unique<ClangExpressionDeclMap>(
keep_result_in_memory, &delegate, exe_ctx.GetTargetSP(), ast_importer,
ctx_obj);
}
clang::ASTConsumer *
ClangUserExpression::ClangUserExpressionHelper::ASTTransformer(
clang::ASTConsumer *passthrough) {
m_result_synthesizer_up.reset(
new ASTResultSynthesizer(passthrough, m_top_level, m_target));
m_result_synthesizer_up = std::make_unique<ASTResultSynthesizer>(
passthrough, m_top_level, m_target);
return m_result_synthesizer_up.get();
}

View File

@ -167,7 +167,7 @@ void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
ast_importer = persistent_vars->GetClangASTImporter();
}
m_expr_decl_map_up.reset(
new ClangExpressionDeclMap(keep_result_in_memory, nullptr,
exe_ctx.GetTargetSP(), ast_importer, nullptr));
m_expr_decl_map_up = std::make_unique<ClangExpressionDeclMap>(
keep_result_in_memory, nullptr, exe_ctx.GetTargetSP(), ast_importer,
nullptr);
}

View File

@ -66,9 +66,9 @@ emulateLookupInCtxt(Sema &sema, llvm::StringRef name, DeclContext *ctxt) {
IdentifierInfo &ident = sema.getASTContext().Idents.get(name);
std::unique_ptr<LookupResult> lookup_result;
lookup_result.reset(new LookupResult(sema, DeclarationName(&ident),
SourceLocation(),
Sema::LookupOrdinaryName));
lookup_result = std::make_unique<LookupResult>(sema, DeclarationName(&ident),
SourceLocation(),
Sema::LookupOrdinaryName);
// Usually during parsing we already encountered the scopes we would use. But
// here don't have these scopes so we have to emulate the behavior of the

View File

@ -1842,7 +1842,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
m_module = &llvm_module;
m_target_data.reset(new DataLayout(m_module));
m_target_data = std::make_unique<DataLayout>(m_module);
m_intptr_ty = llvm::Type::getIntNTy(m_module->getContext(),
m_target_data->getPointerSizeInBits());

View File

@ -159,8 +159,8 @@ EmulateInstructionMIPS::EmulateInstructionMIPS(
target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());
m_context.reset(
new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
m_context = std::make_unique<llvm::MCContext>(m_asm_info.get(),
m_reg_info.get(), nullptr);
assert(m_context.get());
m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));

View File

@ -163,8 +163,8 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64(
target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());
m_context.reset(
new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
m_context = std::make_unique<llvm::MCContext>(m_asm_info.get(),
m_reg_info.get(), nullptr);
assert(m_context.get());
m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));

View File

@ -16,7 +16,7 @@ using namespace lldb_private;
bool ClassDescriptorV2::Read_objc_class(
Process *process, std::unique_ptr<objc_class_t> &objc_class) const {
objc_class.reset(new objc_class_t);
objc_class = std::make_unique<objc_class_t>();
bool ret = objc_class->Read(process, m_objc_class_ptr);
@ -197,14 +197,14 @@ bool ClassDescriptorV2::Read_class_row(
return false;
if (class_row_t_flags & RW_REALIZED) {
class_rw.reset(new class_rw_t);
class_rw = std::make_unique<class_rw_t>();
if (!class_rw->Read(process, objc_class.m_data_ptr)) {
class_rw.reset();
return false;
}
class_ro.reset(new class_ro_t);
class_ro = std::make_unique<class_ro_t>();
if (!class_ro->Read(process, class_rw->m_ro_ptr)) {
class_rw.reset();
@ -212,7 +212,7 @@ bool ClassDescriptorV2::Read_class_row(
return false;
}
} else {
class_ro.reset(new class_ro_t);
class_ro = std::make_unique<class_ro_t>();
if (!class_ro->Read(process, objc_class.m_data_ptr)) {
class_ro.reset();
@ -357,7 +357,7 @@ bool ClassDescriptorV2::Describe(
if (instance_method_func) {
std::unique_ptr<method_list_t> base_method_list;
base_method_list.reset(new method_list_t);
base_method_list = std::make_unique<method_list_t>();
if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))
return false;
@ -365,7 +365,7 @@ bool ClassDescriptorV2::Describe(
return false;
std::unique_ptr<method_t> method;
method.reset(new method_t);
method = std::make_unique<method_t>();
for (uint32_t i = 0, e = base_method_list->m_count; i < e; ++i) {
method->Read(process, base_method_list->m_first_ptr +

View File

@ -250,7 +250,8 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
contexts.GetContextAtIndex(0, context);
m_PrintForDebugger_addr.reset(new Address(context.symbol->GetAddress()));
m_PrintForDebugger_addr =
std::make_unique<Address>(context.symbol->GetAddress());
}
return m_PrintForDebugger_addr.get();
@ -346,8 +347,8 @@ bool AppleObjCRuntime::ReadObjCLibrary(const ModuleSP &module_sp) {
// Maybe check here and if we have a handler already, and the UUID of this
// module is the same as the one in the current module, then we don't have to
// reread it?
m_objc_trampoline_handler_up.reset(
new AppleObjCTrampolineHandler(m_process->shared_from_this(), module_sp));
m_objc_trampoline_handler_up = std::make_unique<AppleObjCTrampolineHandler>(
m_process->shared_from_this(), module_sp);
if (m_objc_trampoline_handler_up != nullptr) {
m_read_objc_library = true;
return true;

View File

@ -581,8 +581,8 @@ protected:
case 0:
break;
case 1: {
regex_up.reset(new RegularExpression(
llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0))));
regex_up = std::make_unique<RegularExpression>(
llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0)));
if (!regex_up->IsValid()) {
result.AppendError(
"invalid argument - please provide a valid regular expression");
@ -2006,7 +2006,7 @@ void AppleObjCRuntimeV2::WarnIfNoClassesCached(
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {
if (!m_decl_vendor_up)
m_decl_vendor_up.reset(new AppleObjCDeclVendor(*this));
m_decl_vendor_up = std::make_unique<AppleObjCDeclVendor>(*this);
return m_decl_vendor_up.get();
}

View File

@ -787,7 +787,8 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
}
// Build our vtable dispatch handler here:
m_vtables_up.reset(new AppleObjCVTables(process_sp, m_objc_module_sp));
m_vtables_up =
std::make_unique<AppleObjCVTables>(process_sp, m_objc_module_sp);
if (m_vtables_up)
m_vtables_up->ReadRegions();
}

View File

@ -25,9 +25,9 @@ AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser(
ObjCLanguageRuntime &runtime)
: ObjCLanguageRuntime::EncodingToType(), m_runtime(runtime) {
if (!m_scratch_ast_ctx_up)
m_scratch_ast_ctx_up.reset(new TypeSystemClang(
m_scratch_ast_ctx_up = std::make_unique<TypeSystemClang>(
"AppleObjCTypeEncodingParser ASTContext",
runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple()));
runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple());
}
std::string AppleObjCTypeEncodingParser::ReadStructName(StringLexer &type) {

View File

@ -903,7 +903,7 @@ size_t ObjectFileELF::ParseDependentModules() {
if (m_filespec_up)
return m_filespec_up->GetSize();
m_filespec_up.reset(new FileSpecList());
m_filespec_up = std::make_unique<FileSpecList>();
if (!ParseSectionHeaders())
return 0;
@ -2717,7 +2717,7 @@ Symtab *ObjectFileELF::GetSymtab() {
Section *symtab =
section_list->FindSectionByType(eSectionTypeELFSymbolTable, true).get();
if (symtab) {
m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
m_symtab_up = std::make_unique<Symtab>(symtab->GetObjectFile());
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
}
@ -2734,7 +2734,7 @@ Symtab *ObjectFileELF::GetSymtab() {
.get();
if (dynsym) {
if (!m_symtab_up)
m_symtab_up.reset(new Symtab(dynsym->GetObjectFile()));
m_symtab_up = std::make_unique<Symtab>(dynsym->GetObjectFile());
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, dynsym);
}
}
@ -2761,7 +2761,8 @@ Symtab *ObjectFileELF::GetSymtab() {
assert(reloc_header);
if (m_symtab_up == nullptr)
m_symtab_up.reset(new Symtab(reloc_section->GetObjectFile()));
m_symtab_up =
std::make_unique<Symtab>(reloc_section->GetObjectFile());
ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header,
reloc_id);
@ -2771,14 +2772,14 @@ Symtab *ObjectFileELF::GetSymtab() {
if (DWARFCallFrameInfo *eh_frame =
GetModule()->GetUnwindTable().GetEHFrameInfo()) {
if (m_symtab_up == nullptr)
m_symtab_up.reset(new Symtab(this));
m_symtab_up = std::make_unique<Symtab>(this);
ParseUnwindSymbols(m_symtab_up.get(), eh_frame);
}
// If we still don't have any symtab then create an empty instance to avoid
// do the section lookup next time.
if (m_symtab_up == nullptr)
m_symtab_up.reset(new Symtab(this));
m_symtab_up = std::make_unique<Symtab>(this);
// In the event that there's no symbol entry for the entry point we'll
// artificially create one. We delegate to the symtab object the figuring

View File

@ -120,7 +120,7 @@ Symtab *ObjectFileJIT::GetSymtab() {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_up == nullptr) {
m_symtab_up.reset(new Symtab(this));
m_symtab_up = std::make_unique<Symtab>(this);
std::lock_guard<std::recursive_mutex> symtab_guard(
m_symtab_up->GetMutex());
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
@ -139,7 +139,7 @@ bool ObjectFileJIT::IsStripped() {
void ObjectFileJIT::CreateSections(SectionList &unified_section_list) {
if (!m_sections_up) {
m_sections_up.reset(new SectionList());
m_sections_up = std::make_unique<SectionList>();
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
if (delegate_sp) {
delegate_sp->PopulateSectionList(this, *m_sections_up);

View File

@ -1253,7 +1253,7 @@ Symtab *ObjectFileMachO::GetSymtab() {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_up == nullptr) {
m_symtab_up.reset(new Symtab(this));
m_symtab_up = std::make_unique<Symtab>(this);
std::lock_guard<std::recursive_mutex> symtab_guard(
m_symtab_up->GetMutex());
ParseSymtab();
@ -1820,7 +1820,7 @@ void ObjectFileMachO::CreateSections(SectionList &unified_section_list) {
if (m_sections_up)
return;
m_sections_up.reset(new SectionList());
m_sections_up = std::make_unique<SectionList>();
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
// bool dump_sections = false;

View File

@ -640,7 +640,7 @@ Symtab *ObjectFilePECOFF::GetSymtab() {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_up == nullptr) {
SectionList *sect_list = GetSectionList();
m_symtab_up.reset(new Symtab(this));
m_symtab_up = std::make_unique<Symtab>(this);
std::lock_guard<std::recursive_mutex> guard(m_symtab_up->GetMutex());
const uint32_t num_syms = m_coff_header.nsyms;
@ -868,7 +868,7 @@ SectionType ObjectFilePECOFF::GetSectionType(llvm::StringRef sect_name,
void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
if (m_sections_up)
return;
m_sections_up.reset(new SectionList());
m_sections_up = std::make_unique<SectionList>();
ModuleSP module_sp(GetModule());
if (module_sp) {

View File

@ -132,7 +132,7 @@ const std::string &AdbClient::GetDeviceID() const { return m_device_id; }
Status AdbClient::Connect() {
Status error;
m_conn.reset(new ConnectionFileDescriptor);
m_conn = std::make_unique<ConnectionFileDescriptor>();
std::string port = "5037";
if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT")) {
port = env_port;

View File

@ -31,7 +31,8 @@ HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
m_thread_name(), m_originating_unique_thread_id(tid),
m_queue_id(LLDB_INVALID_QUEUE_ID) {
m_unwinder_up.reset(new HistoryUnwind(*this, pcs, pcs_are_call_addresses));
m_unwinder_up =
std::make_unique<HistoryUnwind>(*this, pcs, pcs_are_call_addresses);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
LLDB_LOGF(log, "%p HistoryThread::HistoryThread", static_cast<void *>(this));
}

View File

@ -90,7 +90,7 @@ static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind) {
ClangASTImporter &DWARFASTParserClang::GetClangASTImporter() {
if (!m_clang_ast_importer_up) {
m_clang_ast_importer_up.reset(new ClangASTImporter);
m_clang_ast_importer_up = std::make_unique<ClangASTImporter>();
}
return *m_clang_ast_importer_up;
}
@ -1783,7 +1783,7 @@ public:
m_property_getter_name(property_getter_name),
m_property_attributes(property_attributes) {
if (metadata != nullptr) {
m_metadata_up.reset(new ClangASTMetadata());
m_metadata_up = std::make_unique<ClangASTMetadata>();
*m_metadata_up = *metadata;
}
}
@ -1803,7 +1803,7 @@ public:
m_property_attributes = rhs.m_property_attributes;
if (rhs.m_metadata_up) {
m_metadata_up.reset(new ClangASTMetadata());
m_metadata_up = std::make_unique<ClangASTMetadata>();
*m_metadata_up = *rhs.m_metadata_up;
}
return *this;
@ -1835,8 +1835,8 @@ bool DWARFASTParserClang::ParseTemplateDIE(
switch (tag) {
case DW_TAG_GNU_template_parameter_pack: {
template_param_infos.packed_args.reset(
new TypeSystemClang::TemplateParameterInfos);
template_param_infos.packed_args =
std::make_unique<TypeSystemClang::TemplateParameterInfos>();
for (DWARFDIE child_die = die.GetFirstChild(); child_die.IsValid();
child_die = child_die.GetSibling()) {
if (!ParseTemplateDIE(child_die, *template_param_infos.packed_args))
@ -2354,8 +2354,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
FunctionSP func_sp;
std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
decl_up.reset(new Declaration(die.GetCU()->GetFile(decl_file),
decl_line, decl_column));
decl_up = std::make_unique<Declaration>(die.GetCU()->GetFile(decl_file),
decl_line, decl_column);
SymbolFileDWARF *dwarf = die.GetDWARF();
// Supply the type _only_ if it has already been parsed

View File

@ -769,7 +769,7 @@ SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() {
const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() {
if (m_func_aranges_up == nullptr) {
m_func_aranges_up.reset(new DWARFDebugAranges());
m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
const DWARFDebugInfoEntry *die = DIEPtr();
if (die)
die->BuildFunctionAddressRangeTable(this, m_func_aranges_up.get());

View File

@ -651,7 +651,7 @@ DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() {
static_cast<void *>(this));
if (m_context.getOrLoadRangesData().GetByteSize() > 0)
m_ranges.reset(new DWARFDebugRanges());
m_ranges = std::make_unique<DWARFDebugRanges>();
if (m_ranges)
m_ranges->Extract(m_context);
@ -1192,15 +1192,15 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(
(name != nullptr || mangled_name != nullptr)) {
std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
decl_up.reset(new Declaration(
decl_up = std::make_unique<Declaration>(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
decl_line, decl_column));
decl_line, decl_column);
std::unique_ptr<Declaration> call_up;
if (call_file != 0 || call_line != 0 || call_column != 0)
call_up.reset(new Declaration(
call_up = std::make_unique<Declaration>(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(call_file),
call_line, call_column));
call_line, call_column);
block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(),
call_up.get());
@ -1763,7 +1763,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
if (!m_global_aranges_up) {
m_global_aranges_up.reset(new GlobalVariableMap());
m_global_aranges_up = std::make_unique<GlobalVariableMap>();
ModuleSP module_sp = GetObjectFile()->GetModule();
if (module_sp) {

View File

@ -720,31 +720,31 @@ void TypeSystemClang::CreateASTContext() {
assert(!m_ast_up);
m_ast_owned = true;
m_language_options_up.reset(new LangOptions());
m_language_options_up = std::make_unique<LangOptions>();
ParseLangArgs(*m_language_options_up, clang::Language::ObjCXX,
GetTargetTriple());
m_identifier_table_up.reset(
new IdentifierTable(*m_language_options_up, nullptr));
m_builtins_up.reset(new Builtin::Context());
m_identifier_table_up =
std::make_unique<IdentifierTable>(*m_language_options_up, nullptr);
m_builtins_up = std::make_unique<Builtin::Context>();
m_selector_table_up.reset(new SelectorTable());
m_selector_table_up = std::make_unique<SelectorTable>();
clang::FileSystemOptions file_system_options;
m_file_manager_up.reset(new clang::FileManager(
file_system_options, FileSystem::Instance().GetVirtualFileSystem()));
m_file_manager_up = std::make_unique<clang::FileManager>(
file_system_options, FileSystem::Instance().GetVirtualFileSystem());
llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
m_diagnostics_engine_up.reset(
new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions()));
m_diagnostics_engine_up =
std::make_unique<DiagnosticsEngine>(diag_id_sp, new DiagnosticOptions());
m_source_manager_up.reset(
new clang::SourceManager(*m_diagnostics_engine_up, *m_file_manager_up));
m_ast_up.reset(new ASTContext(*m_language_options_up, *m_source_manager_up,
*m_identifier_table_up, *m_selector_table_up,
*m_builtins_up));
m_source_manager_up = std::make_unique<clang::SourceManager>(
*m_diagnostics_engine_up, *m_file_manager_up);
m_ast_up = std::make_unique<ASTContext>(
*m_language_options_up, *m_source_manager_up, *m_identifier_table_up,
*m_selector_table_up, *m_builtins_up);
m_diagnostic_consumer_up.reset(new NullDiagnosticConsumer);
m_diagnostic_consumer_up = std::make_unique<NullDiagnosticConsumer>();
m_ast_up->getDiagnostics().setClient(m_diagnostic_consumer_up.get(), false);
// This can be NULL if we don't know anything about the architecture or if
@ -9060,13 +9060,13 @@ void TypeSystemClang::CompleteObjCInterfaceDecl(
DWARFASTParser *TypeSystemClang::GetDWARFParser() {
if (!m_dwarf_ast_parser_up)
m_dwarf_ast_parser_up.reset(new DWARFASTParserClang(*this));
m_dwarf_ast_parser_up = std::make_unique<DWARFASTParserClang>(*this);
return m_dwarf_ast_parser_up.get();
}
PDBASTParser *TypeSystemClang::GetPDBParser() {
if (!m_pdb_ast_parser_up)
m_pdb_ast_parser_up.reset(new PDBASTParser(*this));
m_pdb_ast_parser_up = std::make_unique<PDBASTParser>(*this);
return m_pdb_ast_parser_up.get();
}
@ -9502,8 +9502,8 @@ TypeSystemClangForExpressions::TypeSystemClangForExpressions(
: TypeSystemClang("scratch ASTContext", triple),
m_target_wp(target.shared_from_this()),
m_persistent_variables(new ClangPersistentVariables) {
m_scratch_ast_source_up.reset(new ClangASTSource(
target.shared_from_this(), m_persistent_variables->GetClangASTImporter()));
m_scratch_ast_source_up = std::make_unique<ClangASTSource>(
target.shared_from_this(), m_persistent_variables->GetClangASTImporter());
m_scratch_ast_source_up->InstallASTContext(*this);
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
m_scratch_ast_source_up->CreateProxy());

View File

@ -968,7 +968,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
// CompUnits can't necessarily be resolved here, since an inlined function
// might show up in a number of CompUnits. Instead we just convert to a
// FileSpec and store it away.
m_file_spec_up.reset(new FileSpec(spec_string));
m_file_spec_up = std::make_unique<FileSpec>(spec_string);
m_type |= eFileSpecified;
break;
case eLineStartSpecified:

View File

@ -51,7 +51,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
}
if (!sym_objfile_sp)
sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
instance_up.reset(new SymbolVendor(module_sp));
instance_up = std::make_unique<SymbolVendor>(module_sp);
instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
return instance_up.release();
}

View File

@ -57,26 +57,28 @@ void UnwindTable::Initialize() {
SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
if (sect.get()) {
m_eh_frame_up.reset(
new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::EH));
m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
*object_file, sect, DWARFCallFrameInfo::EH);
}
sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
if (sect) {
m_debug_frame_up.reset(
new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::DWARF));
m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
*object_file, sect, DWARFCallFrameInfo::DWARF);
}
sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
if (sect) {
m_compact_unwind_up.reset(new CompactUnwindInfo(*object_file, sect));
m_compact_unwind_up =
std::make_unique<CompactUnwindInfo>(*object_file, sect);
}
sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
if (sect) {
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
if (sect_extab.get()) {
m_arm_unwind_up.reset(new ArmUnwindInfo(*object_file, sect, sect_extab));
m_arm_unwind_up =
std::make_unique<ArmUnwindInfo>(*object_file, sect, sect_extab);
}
}
}

View File

@ -169,7 +169,7 @@ ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
return;
}
m_lock.reset(new lldb_private::LockFile(m_file_up->GetDescriptor()));
m_lock = std::make_unique<lldb_private::LockFile>(m_file_up->GetDescriptor());
error = m_lock->WriteLock(0, 1);
if (error.Fail())
error.SetErrorStringWithFormat("Failed to lock file: %s",

View File

@ -164,7 +164,8 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
[this] { m_process->LoadOperatingSystemPlugin(true); });
}
m_experimental_properties_up.reset(new ProcessExperimentalProperties());
m_experimental_properties_up =
std::make_unique<ProcessExperimentalProperties>();
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "
@ -2748,7 +2749,7 @@ DataExtractor Process::GetAuxvData() { return DataExtractor(); }
JITLoaderList &Process::GetJITLoaders() {
if (!m_jit_loaders_up) {
m_jit_loaders_up.reset(new JITLoaderList());
m_jit_loaders_up = std::make_unique<JITLoaderList>();
JITLoader::LoadPlugins(this, *m_jit_loaders_up);
}
return *m_jit_loaders_up;

View File

@ -2458,7 +2458,7 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
SourceManager &Target::GetSourceManager() {
if (!m_source_manager_up)
m_source_manager_up.reset(new SourceManager(shared_from_this()));
m_source_manager_up = std::make_unique<SourceManager>(shared_from_this());
return *m_source_manager_up;
}
@ -3137,7 +3137,7 @@ Target::StopHook::StopHook(const StopHook &rhs)
m_thread_spec_up(), m_active(rhs.m_active),
m_auto_continue(rhs.m_auto_continue) {
if (rhs.m_thread_spec_up)
m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
}
Target::StopHook::~StopHook() = default;
@ -3427,7 +3427,8 @@ TargetProperties::TargetProperties(Target *target)
m_collection_sp->SetValueChangedCallback(
ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
m_experimental_properties_up.reset(new TargetExperimentalProperties());
m_experimental_properties_up =
std::make_unique<TargetExperimentalProperties>();
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "
@ -3437,7 +3438,8 @@ TargetProperties::TargetProperties(Target *target)
m_collection_sp =
std::make_shared<TargetOptionValueProperties>(ConstString("target"));
m_collection_sp->Initialize(g_target_properties);
m_experimental_properties_up.reset(new TargetExperimentalProperties());
m_experimental_properties_up =
std::make_unique<TargetExperimentalProperties>();
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "

View File

@ -1066,7 +1066,7 @@ ThreadPlanStack &Thread::GetPlans() const {
// ThreadPlanNull as its base plan. That will give the right answers to the
// queries GetDescription makes, and only assert if you try to run the thread.
if (!m_null_plan_stack_up)
m_null_plan_stack_up.reset(new ThreadPlanStack(*this, true));
m_null_plan_stack_up = std::make_unique<ThreadPlanStack>(*this, true);
return *(m_null_plan_stack_up.get());
}
@ -1859,7 +1859,7 @@ size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
Unwind &Thread::GetUnwinder() {
if (!m_unwinder_up)
m_unwinder_up.reset(new UnwindLLDB(*this));
m_unwinder_up = std::make_unique<UnwindLLDB>(*this);
return *m_unwinder_up;
}

View File

@ -311,7 +311,7 @@ void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
if (m_avoid_regexp_up)
*m_avoid_regexp_up = RegularExpression(name_ref);
else
m_avoid_regexp_up.reset(new RegularExpression(name_ref));
m_avoid_regexp_up = std::make_unique<RegularExpression>(name_ref);
}
void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {