Skip to content

Commit 1de35b6

Browse files
committed
Update comment, use reference
1 parent ed2905d commit 1de35b6

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

+39-39
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) {
720720

721721
void SymbolFileDWARFDebugMap::ForEachSymbolFile(
722722
std::string description,
723-
std::function<IterationAction(SymbolFileDWARF *)> closure) {
723+
std::function<IterationAction(SymbolFileDWARF &)> closure) {
724724
const size_t num_oso_idxs = m_compile_unit_infos.size();
725725
const size_t update_rate = std::max<size_t>(1, num_oso_idxs / 100);
726726
Progress progress(std::move(description), "", num_oso_idxs);
@@ -733,7 +733,9 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
733733
.GetFilename()
734734
.GetString()
735735
: std::string());
736-
if (closure(oso_dwarf) == IterationAction::Stop)
736+
if (!oso_dwarf)
737+
continue;
738+
if (closure(*oso_dwarf) == IterationAction::Stop)
737739
return;
738740
}
739741
}
@@ -827,9 +829,9 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID(
827829
bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) {
828830
bool success = false;
829831
if (compiler_type) {
830-
ForEachSymbolFile("Completing type", [&](SymbolFileDWARF *oso_dwarf) {
831-
if (oso_dwarf->HasForwardDeclForCompilerType(compiler_type)) {
832-
oso_dwarf->CompleteType(compiler_type);
832+
ForEachSymbolFile("Completing type", [&](SymbolFileDWARF &oso_dwarf) {
833+
if (oso_dwarf.HasForwardDeclForCompilerType(compiler_type)) {
834+
oso_dwarf.CompleteType(compiler_type);
833835
success = true;
834836
return IterationAction::Stop;
835837
}
@@ -948,18 +950,17 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
948950
uint32_t total_matches = 0;
949951

950952
ForEachSymbolFile(
951-
"Looking up global variables", [&](SymbolFileDWARF *oso_dwarf) {
953+
"Looking up global variables", [&](SymbolFileDWARF &oso_dwarf) {
952954
const uint32_t old_size = variables.GetSize();
953-
oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
954-
variables);
955+
oso_dwarf.FindGlobalVariables(name, parent_decl_ctx, max_matches,
956+
variables);
955957
const uint32_t oso_matches = variables.GetSize() - old_size;
956958
if (oso_matches > 0) {
957959
total_matches += oso_matches;
958960

959-
// Are we getting all matches?
961+
// If we are getting all matches, keep going.
960962
if (max_matches == UINT32_MAX)
961-
return IterationAction::Continue; // Yep, continue getting
962-
// everything
963+
return IterationAction::Continue;
963964

964965
// If we have found enough matches, lets get out
965966
if (max_matches >= total_matches)
@@ -980,18 +981,17 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
980981
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
981982
uint32_t total_matches = 0;
982983
ForEachSymbolFile(
983-
"Looking up global variables", [&](SymbolFileDWARF *oso_dwarf) {
984+
"Looking up global variables", [&](SymbolFileDWARF &oso_dwarf) {
984985
const uint32_t old_size = variables.GetSize();
985-
oso_dwarf->FindGlobalVariables(regex, max_matches, variables);
986+
oso_dwarf.FindGlobalVariables(regex, max_matches, variables);
986987

987988
const uint32_t oso_matches = variables.GetSize() - old_size;
988989
if (oso_matches > 0) {
989990
total_matches += oso_matches;
990991

991-
// Are we getting all matches?
992+
// If we are getting all matches, keep going.
992993
if (max_matches == UINT32_MAX)
993-
return IterationAction::Continue; // Yep, continue getting
994-
// everything
994+
return IterationAction::Continue;
995995

996996
// If we have found enough matches, lets get out
997997
if (max_matches >= total_matches)
@@ -1106,10 +1106,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(
11061106
LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
11071107
lookup_info.GetLookupName().GetCString());
11081108

1109-
ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF *oso_dwarf) {
1109+
ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF &oso_dwarf) {
11101110
uint32_t sc_idx = sc_list.GetSize();
1111-
oso_dwarf->FindFunctions(lookup_info, parent_decl_ctx, include_inlines,
1112-
sc_list);
1111+
oso_dwarf.FindFunctions(lookup_info, parent_decl_ctx, include_inlines,
1112+
sc_list);
11131113
if (!sc_list.IsEmpty()) {
11141114
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
11151115
sc_idx);
@@ -1125,10 +1125,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression &regex,
11251125
LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
11261126
regex.GetText().str().c_str());
11271127

1128-
ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF *oso_dwarf) {
1128+
ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF &oso_dwarf) {
11291129
uint32_t sc_idx = sc_list.GetSize();
11301130

1131-
oso_dwarf->FindFunctions(regex, include_inlines, sc_list);
1131+
oso_dwarf.FindFunctions(regex, include_inlines, sc_list);
11321132
if (!sc_list.IsEmpty()) {
11331133
RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
11341134
sc_idx);
@@ -1156,8 +1156,8 @@ void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
11561156
oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
11571157
}
11581158
} else {
1159-
ForEachSymbolFile("Looking up types", [&](SymbolFileDWARF *oso_dwarf) {
1160-
oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
1159+
ForEachSymbolFile("Looking up types", [&](SymbolFileDWARF &oso_dwarf) {
1160+
oso_dwarf.GetTypes(sc_scope, type_mask, type_list);
11611161
return IterationAction::Continue;
11621162
});
11631163
}
@@ -1176,8 +1176,8 @@ SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(
11761176
DWARFDIE SymbolFileDWARFDebugMap::FindDefinitionDIE(const DWARFDIE &die) {
11771177
DWARFDIE result;
11781178
ForEachSymbolFile(
1179-
"Looking up type definition", [&](SymbolFileDWARF *oso_dwarf) {
1180-
result = oso_dwarf->FindDefinitionDIE(die);
1179+
"Looking up type definition", [&](SymbolFileDWARF &oso_dwarf) {
1180+
result = oso_dwarf.FindDefinitionDIE(die);
11811181
return result ? IterationAction::Stop : IterationAction::Continue;
11821182
});
11831183
return result;
@@ -1236,8 +1236,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
12361236
TypeSP type_sp;
12371237

12381238
ForEachSymbolFile(
1239-
"Looking up Objective-C definition", [&](SymbolFileDWARF *oso_dwarf) {
1240-
type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE(
1239+
"Looking up Objective-C definition", [&](SymbolFileDWARF &oso_dwarf) {
1240+
type_sp = oso_dwarf.FindCompleteObjCDefinitionTypeForDIE(
12411241
die, type_name, must_be_implementation);
12421242
return type_sp ? IterationAction::Stop : IterationAction::Continue;
12431243
});
@@ -1250,8 +1250,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
12501250
void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery &query,
12511251
TypeResults &results) {
12521252
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1253-
ForEachSymbolFile("Looking up type", [&](SymbolFileDWARF *oso_dwarf) {
1254-
oso_dwarf->FindTypes(query, results);
1253+
ForEachSymbolFile("Looking up type", [&](SymbolFileDWARF &oso_dwarf) {
1254+
oso_dwarf.FindTypes(query, results);
12551255
return results.Done(query) ? IterationAction::Stop
12561256
: IterationAction::Continue;
12571257
});
@@ -1263,9 +1263,9 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
12631263
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
12641264
CompilerDeclContext matching_namespace;
12651265

1266-
ForEachSymbolFile("Looking up namespace", [&](SymbolFileDWARF *oso_dwarf) {
1266+
ForEachSymbolFile("Looking up namespace", [&](SymbolFileDWARF &oso_dwarf) {
12671267
matching_namespace =
1268-
oso_dwarf->FindNamespace(name, parent_decl_ctx, only_root_namespaces);
1268+
oso_dwarf.FindNamespace(name, parent_decl_ctx, only_root_namespaces);
12691269

12701270
return matching_namespace ? IterationAction::Stop
12711271
: IterationAction::Continue;
@@ -1275,8 +1275,8 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
12751275
}
12761276

12771277
void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) {
1278-
ForEachSymbolFile("Dumping clang AST", [&s](SymbolFileDWARF *oso_dwarf) {
1279-
oso_dwarf->DumpClangAST(s);
1278+
ForEachSymbolFile("Dumping clang AST", [&s](SymbolFileDWARF &oso_dwarf) {
1279+
oso_dwarf.DumpClangAST(s);
12801280
// The underlying assumption is that DumpClangAST(...) will obtain the
12811281
// AST from the underlying TypeSystem and therefore we only need to do
12821282
// this once and can stop after the first iteration hence we return true.
@@ -1412,8 +1412,8 @@ SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
14121412

14131413
void SymbolFileDWARFDebugMap::ParseDeclsForContext(
14141414
lldb_private::CompilerDeclContext decl_ctx) {
1415-
ForEachSymbolFile("Parsing declarations", [&](SymbolFileDWARF *oso_dwarf) {
1416-
oso_dwarf->ParseDeclsForContext(decl_ctx);
1415+
ForEachSymbolFile("Parsing declarations", [&](SymbolFileDWARF &oso_dwarf) {
1416+
oso_dwarf.ParseDeclsForContext(decl_ctx);
14171417
return IterationAction::Continue;
14181418
});
14191419
}
@@ -1542,8 +1542,8 @@ SymbolFileDWARFDebugMap::AddOSOARanges(SymbolFileDWARF *dwarf2Data,
15421542

15431543
ModuleList SymbolFileDWARFDebugMap::GetDebugInfoModules() {
15441544
ModuleList oso_modules;
1545-
ForEachSymbolFile("Parsing modules", [&](SymbolFileDWARF *oso_dwarf) {
1546-
ObjectFile *oso_objfile = oso_dwarf->GetObjectFile();
1545+
ForEachSymbolFile("Parsing modules", [&](SymbolFileDWARF &oso_dwarf) {
1546+
ObjectFile *oso_objfile = oso_dwarf.GetObjectFile();
15471547
if (oso_objfile) {
15481548
ModuleSP module_sp = oso_objfile->GetModule();
15491549
if (module_sp)
@@ -1603,8 +1603,8 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
16031603
void SymbolFileDWARFDebugMap::GetCompileOptions(
16041604
std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
16051605

1606-
ForEachSymbolFile("Parsing compile options", [&](SymbolFileDWARF *oso_dwarf) {
1607-
oso_dwarf->GetCompileOptions(args);
1606+
ForEachSymbolFile("Parsing compile options", [&](SymbolFileDWARF &oso_dwarf) {
1607+
oso_dwarf.GetCompileOptions(args);
16081608
return IterationAction::Continue;
16091609
});
16101610
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class SymbolFileDWARFDebugMap : public SymbolFileCommon {
238238
/// continues. Otherwise, iteration terminates.
239239
void
240240
ForEachSymbolFile(std::string description,
241-
std::function<IterationAction(SymbolFileDWARF *)> closure);
241+
std::function<IterationAction(SymbolFileDWARF &)> closure);
242242

243243
CompileUnitInfo *GetCompileUnitInfoForSymbolWithIndex(uint32_t symbol_idx,
244244
uint32_t *oso_idx_ptr);

0 commit comments

Comments
 (0)