Skip to content

Commit 8023752

Browse files
committed
[nfc] [lldb] Unindent code - obvious part
It is an obvious part of D77326. It removes some needless deep indentation and some redundant statements. It prepares the code for a more clean next patch - DWARF index callbacks in D77327.
1 parent b947a84 commit 8023752

File tree

5 files changed

+146
-140
lines changed

5 files changed

+146
-140
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create(
5353
}
5454

5555
void AppleDWARFIndex::GetGlobalVariables(ConstString basename, DIEArray &offsets) {
56-
if (m_apple_names_up)
57-
m_apple_names_up->FindByName(basename.GetStringRef(), offsets);
56+
if (!m_apple_names_up)
57+
return;
58+
m_apple_names_up->FindByName(basename.GetStringRef(), offsets);
5859
}
5960

6061
void AppleDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
@@ -80,22 +81,24 @@ void AppleDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
8081

8182
void AppleDWARFIndex::GetObjCMethods(ConstString class_name,
8283
DIEArray &offsets) {
83-
if (m_apple_objc_up)
84-
m_apple_objc_up->FindByName(class_name.GetStringRef(), offsets);
84+
if (!m_apple_objc_up)
85+
return;
86+
m_apple_objc_up->FindByName(class_name.GetStringRef(), offsets);
8587
}
8688

8789
void AppleDWARFIndex::GetCompleteObjCClass(ConstString class_name,
8890
bool must_be_implementation,
8991
DIEArray &offsets) {
90-
if (m_apple_types_up) {
91-
m_apple_types_up->FindCompleteObjCClassByName(
92-
class_name.GetStringRef(), offsets, must_be_implementation);
93-
}
92+
if (!m_apple_types_up)
93+
return;
94+
m_apple_types_up->FindCompleteObjCClassByName(
95+
class_name.GetStringRef(), offsets, must_be_implementation);
9496
}
9597

9698
void AppleDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
97-
if (m_apple_types_up)
98-
m_apple_types_up->FindByName(name.GetStringRef(), offsets);
99+
if (!m_apple_types_up)
100+
return;
101+
m_apple_types_up->FindByName(name.GetStringRef(), offsets);
99102
}
100103

101104
void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
@@ -149,8 +152,9 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
149152
}
150153

151154
void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
152-
if (m_apple_namespaces_up)
153-
m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
155+
if (!m_apple_namespaces_up)
156+
return;
157+
m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
154158
}
155159

156160
void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name,
165165
// If we find the complete version we're done.
166166
offsets.push_back(*ref);
167167
return;
168-
} else {
169-
incomplete_types.push_back(*ref);
170168
}
169+
incomplete_types.push_back(*ref);
171170
}
172171

173172
offsets.insert(offsets.end(), incomplete_types.begin(),

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

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
2121
DIEArray &die_offsets) {
2222
if (tag == 0) {
2323
ExtractDIEArray(die_info_array, die_offsets);
24-
} else {
25-
const size_t count = die_info_array.size();
26-
for (size_t i = 0; i < count; ++i) {
27-
const dw_tag_t die_tag = die_info_array[i].tag;
28-
bool tag_matches = die_tag == 0 || tag == die_tag;
29-
if (!tag_matches) {
30-
if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
31-
tag_matches =
32-
tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
33-
}
34-
if (tag_matches)
35-
die_offsets.emplace_back(die_info_array[i]);
24+
return;
25+
}
26+
27+
const size_t count = die_info_array.size();
28+
for (size_t i = 0; i < count; ++i) {
29+
const dw_tag_t die_tag = die_info_array[i].tag;
30+
bool tag_matches = die_tag == 0 || tag == die_tag;
31+
if (!tag_matches) {
32+
if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
33+
tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
3634
}
35+
if (tag_matches)
36+
die_offsets.emplace_back(die_info_array[i]);
3737
}
3838
}
3939

@@ -43,21 +43,21 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
4343
DIEArray &die_offsets) {
4444
if (tag == 0) {
4545
ExtractDIEArray(die_info_array, die_offsets);
46-
} else {
47-
const size_t count = die_info_array.size();
48-
for (size_t i = 0; i < count; ++i) {
49-
if (qualified_name_hash != die_info_array[i].qualified_name_hash)
50-
continue;
51-
const dw_tag_t die_tag = die_info_array[i].tag;
52-
bool tag_matches = die_tag == 0 || tag == die_tag;
53-
if (!tag_matches) {
54-
if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
55-
tag_matches =
56-
tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
57-
}
58-
if (tag_matches)
59-
die_offsets.emplace_back(die_info_array[i]);
46+
return;
47+
}
48+
49+
const size_t count = die_info_array.size();
50+
for (size_t i = 0; i < count; ++i) {
51+
if (qualified_name_hash != die_info_array[i].qualified_name_hash)
52+
continue;
53+
const dw_tag_t die_tag = die_info_array[i].tag;
54+
bool tag_matches = die_tag == 0 || tag == die_tag;
55+
if (!tag_matches) {
56+
if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)
57+
tag_matches = tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
6058
}
59+
if (tag_matches)
60+
die_offsets.emplace_back(die_info_array[i]);
6161
}
6262
}
6363

@@ -67,22 +67,22 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray(
6767
const size_t count = die_info_array.size();
6868
for (size_t i = 0; i < count; ++i) {
6969
const dw_tag_t die_tag = die_info_array[i].tag;
70-
if (die_tag == 0 || die_tag == DW_TAG_class_type ||
71-
die_tag == DW_TAG_structure_type) {
72-
if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) {
73-
if (return_implementation_only_if_available) {
74-
// We found the one true definition for this class, so only return
75-
// that
76-
die_offsets.clear();
77-
die_offsets.emplace_back(die_info_array[i]);
78-
return;
79-
} else {
80-
// Put the one true definition as the first entry so it matches first
81-
die_offsets.emplace(die_offsets.begin(), die_info_array[i]);
82-
}
83-
} else {
70+
if (die_tag != 0 && die_tag != DW_TAG_class_type &&
71+
die_tag != DW_TAG_structure_type)
72+
continue;
73+
if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) {
74+
if (return_implementation_only_if_available) {
75+
// We found the one true definition for this class, so only return
76+
// that
77+
die_offsets.clear();
8478
die_offsets.emplace_back(die_info_array[i]);
79+
return;
80+
} else {
81+
// Put the one true definition as the first entry so it matches first
82+
die_offsets.emplace(die_offsets.begin(), die_info_array[i]);
8583
}
84+
} else {
85+
die_offsets.emplace_back(die_info_array[i]);
8686
}
8787
}
8888
}
@@ -548,24 +548,24 @@ size_t DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash(
548548
size_t DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName(
549549
llvm::StringRef name, DIEArray &die_offsets, bool must_be_implementation) {
550550
DIEInfoArray die_info_array;
551-
if (FindByName(name, die_info_array)) {
552-
if (must_be_implementation &&
553-
GetHeader().header_data.ContainsAtom(eAtomTypeTypeFlags)) {
554-
// If we have two atoms, then we have the DIE offset and the type flags
555-
// so we can find the objective C class efficiently.
556-
DWARFMappedHash::ExtractTypesFromDIEArray(die_info_array, UINT32_MAX,
557-
eTypeFlagClassIsImplementation,
558-
die_offsets);
559-
} else {
560-
// We don't only want the one true definition, so try and see what we can
561-
// find, and only return class or struct DIEs. If we do have the full
562-
// implementation, then return it alone, else return all possible
563-
// matches.
564-
const bool return_implementation_only_if_available = true;
565-
DWARFMappedHash::ExtractClassOrStructDIEArray(
566-
die_info_array, return_implementation_only_if_available, die_offsets);
567-
}
551+
if (!FindByName(name, die_info_array))
552+
return 0;
553+
if (must_be_implementation &&
554+
GetHeader().header_data.ContainsAtom(eAtomTypeTypeFlags)) {
555+
// If we have two atoms, then we have the DIE offset and the type flags
556+
// so we can find the objective C class efficiently.
557+
DWARFMappedHash::ExtractTypesFromDIEArray(die_info_array, UINT32_MAX,
558+
eTypeFlagClassIsImplementation,
559+
die_offsets);
560+
return die_offsets.size();
568561
}
562+
// We don't only want the one true definition, so try and see what we can
563+
// find, and only return class or struct DIEs. If we do have the full
564+
// implementation, then return it alone, else return all possible
565+
// matches.
566+
const bool return_implementation_only_if_available = true;
567+
DWARFMappedHash::ExtractClassOrStructDIEArray(
568+
die_info_array, return_implementation_only_if_available, die_offsets);
569569
return die_offsets.size();
570570
}
571571

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
426426
DWARFDIE die = dwarf.GetDIE(die_ref);
427427
if (!die)
428428
continue;
429-
if (SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
430-
dies.push_back(die);
429+
if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
430+
continue;
431+
dies.push_back(die);
431432
}
432433
}
433434
if (name_type_mask & eFunctionNameTypeBase) {
@@ -437,18 +438,20 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
437438
DWARFDIE die = dwarf.GetDIE(die_ref);
438439
if (!die)
439440
continue;
440-
if (SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
441-
dies.push_back(die);
441+
if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
442+
continue;
443+
dies.push_back(die);
442444
}
443-
offsets.clear();
444445
}
445446

446447
if (name_type_mask & eFunctionNameTypeMethod && !parent_decl_ctx.IsValid()) {
447448
DIEArray offsets;
448449
m_set.function_methods.Find(name, offsets);
449450
for (const DIERef &die_ref: offsets) {
450-
if (DWARFDIE die = dwarf.GetDIE(die_ref))
451-
dies.push_back(die);
451+
DWARFDIE die = dwarf.GetDIE(die_ref);
452+
if (!die)
453+
continue;
454+
dies.push_back(die);
452455
}
453456
}
454457

@@ -457,8 +460,10 @@ void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
457460
DIEArray offsets;
458461
m_set.function_selectors.Find(name, offsets);
459462
for (const DIERef &die_ref: offsets) {
460-
if (DWARFDIE die = dwarf.GetDIE(die_ref))
461-
dies.push_back(die);
463+
DWARFDIE die = dwarf.GetDIE(die_ref);
464+
if (!die)
465+
continue;
466+
dies.push_back(die);
462467
}
463468
}
464469
}

0 commit comments

Comments
 (0)