[lld-macho] Addressed additional post-commit comments from D126046
- fixed newlines - renamed helper function for clarity - added additional comment Differential Revision: https://reviews.llvm.org/D126792
This commit is contained in:
parent
485432f3c8
commit
82de9bb66b
|
@ -938,8 +938,8 @@ bool SymbolPatterns::match(StringRef symbolName) const {
|
|||
return matchLiteral(symbolName) || matchGlob(symbolName);
|
||||
}
|
||||
|
||||
static void handleSymbolPatternsListHelper(const Arg *arg,
|
||||
SymbolPatterns &symbolPatterns) {
|
||||
static void parseSymbolPatternsFile(const Arg *arg,
|
||||
SymbolPatterns &symbolPatterns) {
|
||||
StringRef path = arg->getValue();
|
||||
Optional<MemoryBufferRef> buffer = readFile(path);
|
||||
if (!buffer) {
|
||||
|
@ -953,6 +953,7 @@ static void handleSymbolPatternsListHelper(const Arg *arg,
|
|||
symbolPatterns.insert(line);
|
||||
}
|
||||
}
|
||||
|
||||
static void handleSymbolPatterns(InputArgList &args,
|
||||
SymbolPatterns &symbolPatterns,
|
||||
unsigned singleOptionCode,
|
||||
|
@ -960,7 +961,7 @@ static void handleSymbolPatterns(InputArgList &args,
|
|||
for (const Arg *arg : args.filtered(singleOptionCode))
|
||||
symbolPatterns.insert(arg->getValue());
|
||||
for (const Arg *arg : args.filtered(listFileOptionCode))
|
||||
handleSymbolPatternsListHelper(arg, symbolPatterns);
|
||||
parseSymbolPatternsFile(arg, symbolPatterns);
|
||||
}
|
||||
|
||||
static void createFiles(const InputArgList &args) {
|
||||
|
@ -1426,7 +1427,6 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
|||
switch (arg->getOption().getID()) {
|
||||
case OPT_x:
|
||||
config->localSymbolsPresence = SymtabPresence::None;
|
||||
|
||||
break;
|
||||
case OPT_non_global_symbols_no_strip_list:
|
||||
if (excludeLocal) {
|
||||
|
@ -1435,7 +1435,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
|||
} else {
|
||||
includeLocal = true;
|
||||
config->localSymbolsPresence = SymtabPresence::SelectivelyIncluded;
|
||||
handleSymbolPatternsListHelper(arg, config->localSymbolPatterns);
|
||||
parseSymbolPatternsFile(arg, config->localSymbolPatterns);
|
||||
}
|
||||
break;
|
||||
case OPT_non_global_symbols_strip_list:
|
||||
|
@ -1445,7 +1445,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
|||
} else {
|
||||
excludeLocal = true;
|
||||
config->localSymbolsPresence = SymtabPresence::SelectivelyExcluded;
|
||||
handleSymbolPatternsListHelper(arg, config->localSymbolPatterns);
|
||||
parseSymbolPatternsFile(arg, config->localSymbolPatterns);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -991,7 +991,9 @@ void SymtabSection::finalizeContents() {
|
|||
|
||||
// Local symbols aren't in the SymbolTable, so we walk the list of object
|
||||
// files to gather them.
|
||||
// But if `-x` is set, then we don't need to.
|
||||
// But if `-x` is set, then we don't need to. localSymbolsHandler() will do
|
||||
// the right thing regardless, but this check is a perf optimization because
|
||||
// iterating through all the input files and their symbols is expensive.
|
||||
if (config->localSymbolsPresence != SymtabPresence::None) {
|
||||
for (const InputFile *file : inputFiles) {
|
||||
if (auto *objFile = dyn_cast<ObjFile>(file)) {
|
||||
|
|
Loading…
Reference in New Issue