Skip to content

Commit 77acb10

Browse files
committed
Refactor getCalGraphSection function as suggested in review.
1 parent 75bffeb commit 77acb10

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,18 +5307,15 @@ static std::optional<object::SectionRef>
53075307
getCallGraphSection(const object::ELFObjectFile<ELFT> &ObjF) {
53085308
// Get the .llvm.callgraph section.
53095309
StringRef CallGraphSectionName(".llvm.callgraph");
5310-
std::optional<object::SectionRef> CallGraphSection;
53115310
for (auto Sec : ObjF.sections()) {
5312-
StringRef Name;
5313-
if (Expected<StringRef> NameOrErr = Sec.getName())
5314-
Name = *NameOrErr;
5315-
else
5311+
if (Expected<StringRef> NameOrErr = Sec.getName()) {
5312+
StringRef Name = *NameOrErr;
5313+
if (Name == CallGraphSectionName)
5314+
return Sec;
5315+
} else
53165316
consumeError(NameOrErr.takeError());
5317-
5318-
if (Name == CallGraphSectionName)
5319-
return Sec;
53205317
}
5321-
return CallGraphSection;
5318+
return std::nullopt;
53225319
}
53235320

53245321
namespace callgraph {

0 commit comments

Comments
 (0)