Skip to content

Commit

Permalink
[llvm-objcopy] Delete redundant !Config.xx.empty() when followed by p…
Browse files Browse the repository at this point in the history
…ositive is_contained() check

Summary: The original intention of !Config.xx.empty() was probably to emphasize the thing that is currently considered, but I feel the simplified form is actually easier to understand and it is also consistent with the call sites in other llvm components.

Reviewers: alexshap, rupprecht, jakehehrlich, jhenderson, espindola

Reviewed By: alexshap, rupprecht

Subscribers: emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D55040

llvm-svn: 347891
  • Loading branch information
MaskRay committed Nov 29, 2018
1 parent 644aa88 commit e4ee066
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
Expand Up @@ -216,8 +216,7 @@ static void handleArgs(const CopyConfig &Config, Object &Obj,
if (!Sym.isCommon() &&
((Config.LocalizeHidden &&
(Sym.Visibility == STV_HIDDEN || Sym.Visibility == STV_INTERNAL)) ||
(!Config.SymbolsToLocalize.empty() &&
is_contained(Config.SymbolsToLocalize, Sym.Name))))
is_contained(Config.SymbolsToLocalize, Sym.Name)))
Sym.Binding = STB_LOCAL;

// Note: these two globalize flags have very similar names but different
Expand All @@ -235,13 +234,11 @@ static void handleArgs(const CopyConfig &Config, Object &Obj,
Sym.getShndx() != SHN_UNDEF)
Sym.Binding = STB_LOCAL;

if (!Config.SymbolsToGlobalize.empty() &&
is_contained(Config.SymbolsToGlobalize, Sym.Name) &&
if (is_contained(Config.SymbolsToGlobalize, Sym.Name) &&
Sym.getShndx() != SHN_UNDEF)
Sym.Binding = STB_GLOBAL;

if (!Config.SymbolsToWeaken.empty() &&
is_contained(Config.SymbolsToWeaken, Sym.Name) &&
if (is_contained(Config.SymbolsToWeaken, Sym.Name) &&
Sym.Binding == STB_GLOBAL)
Sym.Binding = STB_WEAK;

Expand All @@ -266,8 +263,7 @@ static void handleArgs(const CopyConfig &Config, Object &Obj,
}

Obj.removeSymbols([&](const Symbol &Sym) {
if ((!Config.SymbolsToKeep.empty() &&
is_contained(Config.SymbolsToKeep, Sym.Name)) ||
if (is_contained(Config.SymbolsToKeep, Sym.Name) ||
(Config.KeepFileSymbols && Sym.Type == STT_FILE))
return false;

Expand All @@ -279,10 +275,8 @@ static void handleArgs(const CopyConfig &Config, Object &Obj,
if (Config.StripAll || Config.StripAllGNU)
return true;

if (!Config.SymbolsToRemove.empty() &&
is_contained(Config.SymbolsToRemove, Sym.Name)) {
if (is_contained(Config.SymbolsToRemove, Sym.Name))
return true;
}

if (Config.StripUnneeded && !Sym.Referenced &&
(Sym.Binding == STB_LOCAL || Sym.getShndx() == SHN_UNDEF) &&
Expand Down

0 comments on commit e4ee066

Please sign in to comment.