Compute section names only once.
This simplifies error handling as there is now only one place in the
code that needs to consider the possibility that the name is
corrupted. Before we would do it in every access.
llvm-svn: 280937
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 943a4ab..7af2a1a 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -99,7 +99,7 @@
template <class ELFT>
bool LinkerScript<ELFT>::shouldKeep(InputSectionBase<ELFT> *S) {
for (Regex *Re : Opt.KeptSections)
- if (Re->match(S->getSectionName()))
+ if (Re->match(S->Name))
return true;
return false;
}
@@ -121,7 +121,7 @@
if (fileMatches(I, sys::path::filename(F->getName())))
for (InputSectionBase<ELFT> *S : F->getSections())
if (!isDiscarded(S) && !S->OutSec &&
- const_cast<Regex &>(Re).match(S->getSectionName()))
+ const_cast<Regex &>(Re).match(S->Name))
Ret.push_back(S);
}
@@ -132,7 +132,7 @@
template <class ELFT>
static bool compareName(InputSectionBase<ELFT> *A, InputSectionBase<ELFT> *B) {
- return A->getSectionName() < B->getSectionName();
+ return A->Name < B->Name;
}
template <class ELFT>