Skip to content

Commit

Permalink
[lld] As part of using inclusive language within the llvm
Browse files Browse the repository at this point in the history
project, migrate away from the use of blacklist and whitelist.
  • Loading branch information
echristo committed Jun 20, 2020
1 parent 76ff077 commit 058ec20
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
6 changes: 2 additions & 4 deletions lld/include/lld/ReaderWriter/MachOLinkingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class MachOLinkingContext : public LinkingContext {

enum class ExportMode {
globals, // Default, all global symbols exported.
whiteList, // -exported_symbol[s_list], only listed symbols exported.
blackList // -unexported_symbol[s_list], no listed symbol exported.
exported, // -exported_symbol[s_list], only listed symbols exported.
unexported // -unexported_symbol[s_list], no listed symbol exported.
};

enum class DebugInfoMode {
Expand Down Expand Up @@ -423,8 +423,6 @@ class MachOLinkingContext : public LinkingContext {
private:
Writer &writer() const override;
mach_o::MachODylibFile* loadIndirectDylib(StringRef path);
void checkExportWhiteList(const DefinedAtom *atom) const;
void checkExportBlackList(const DefinedAtom *atom) const;
struct ArchInfo {
StringRef archName;
MachOLinkingContext::Arch arch;
Expand Down
16 changes: 8 additions & 8 deletions lld/lib/Driver/DarwinLdDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,12 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {

// Handle -exported_symbols_list <file>
for (auto expFile : parsedArgs.filtered(OPT_exported_symbols_list)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::unexported) {
error("-exported_symbols_list cannot be combined with "
"-unexported_symbol[s_list]");
return false;
}
ctx.setExportMode(MachOLinkingContext::ExportMode::whiteList);
ctx.setExportMode(MachOLinkingContext::ExportMode::exported);
if (std::error_code ec = parseExportsList(expFile->getValue(), ctx)) {
error(ec.message() + ", processing '-exported_symbols_list " +
expFile->getValue());
Expand All @@ -665,23 +665,23 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {

// Handle -exported_symbol <symbol>
for (auto symbol : parsedArgs.filtered(OPT_exported_symbol)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::unexported) {
error("-exported_symbol cannot be combined with "
"-unexported_symbol[s_list]");
return false;
}
ctx.setExportMode(MachOLinkingContext::ExportMode::whiteList);
ctx.setExportMode(MachOLinkingContext::ExportMode::exported);
ctx.addExportSymbol(symbol->getValue());
}

// Handle -unexported_symbols_list <file>
for (auto expFile : parsedArgs.filtered(OPT_unexported_symbols_list)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::exported) {
error("-unexported_symbols_list cannot be combined with "
"-exported_symbol[s_list]");
return false;
}
ctx.setExportMode(MachOLinkingContext::ExportMode::blackList);
ctx.setExportMode(MachOLinkingContext::ExportMode::unexported);
if (std::error_code ec = parseExportsList(expFile->getValue(), ctx)) {
error(ec.message() + ", processing '-unexported_symbols_list " +
expFile->getValue());
Expand All @@ -691,12 +691,12 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx) {

// Handle -unexported_symbol <symbol>
for (auto symbol : parsedArgs.filtered(OPT_unexported_symbol)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::exported) {
error("-unexported_symbol cannot be combined with "
"-exported_symbol[s_list]");
return false;
}
ctx.setExportMode(MachOLinkingContext::ExportMode::blackList);
ctx.setExportMode(MachOLinkingContext::ExportMode::unexported);
ctx.addExportSymbol(symbol->getValue());
}

Expand Down
8 changes: 4 additions & 4 deletions lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ bool MachOLinkingContext::validateImpl() {
}

// If -exported_symbols_list used, all exported symbols must be defined.
if (_exportMode == ExportMode::whiteList) {
if (_exportMode == ExportMode::exported) {
for (const auto &symbol : _exportedSymbols)
addInitialUndefinedSymbol(symbol.getKey());
}
Expand All @@ -618,7 +618,7 @@ bool MachOLinkingContext::validateImpl() {
if (needsStubsPass())
addDeadStripRoot(binderSymbolName());
// If using -exported_symbols_list, make all exported symbols live.
if (_exportMode == ExportMode::whiteList) {
if (_exportMode == ExportMode::exported) {
setGlobalsAreDeadStripRoots(false);
for (const auto &symbol : _exportedSymbols)
addDeadStripRoot(symbol.getKey());
Expand Down Expand Up @@ -852,9 +852,9 @@ bool MachOLinkingContext::exportSymbolNamed(StringRef sym) const {
case ExportMode::globals:
llvm_unreachable("exportSymbolNamed() should not be called in this mode");
break;
case ExportMode::whiteList:
case ExportMode::exported:
return _exportedSymbols.count(sym);
case ExportMode::blackList:
case ExportMode::unexported:
return !_exportedSymbols.count(sym);
}
llvm_unreachable("_exportMode unknown enum value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ llvm::Error Util::getSymbolTableRegion(const DefinedAtom* atom,
inGlobalsRegion = false;
return llvm::Error::success();
case Atom::scopeLinkageUnit:
if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) &&
if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::exported) &&
_ctx.exportSymbolNamed(atom->name())) {
return llvm::make_error<GenericError>(
Twine("cannot export hidden symbol ") + atom->name());
Expand Down

0 comments on commit 058ec20

Please sign in to comment.