diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 3697eb7c41b6..1df5a7338657 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1216,14 +1216,9 @@ static void removeUnusedSyntheticSections() { // If there are no other sections in the output section, remove it from the // output. - if (OS->Commands.empty()) { - // Also remove script commands matching the output section. - llvm::erase_if(Script->Opt.Commands, [&](BaseCommand *Cmd) { - if (auto *Sec = dyn_cast(Cmd)) - return Sec == OS; - return false; - }); - } + if (OS->Commands.empty()) + llvm::erase_if(Script->Opt.Commands, + [&](BaseCommand *Cmd) { return Cmd == OS; }); } }