Simplify. NFC.

llvm-svn: 299506
This commit is contained in:
Rui Ueyama 2017-04-05 03:21:01 +00:00
parent 8f99f73c8f
commit c8124ee9a3
1 changed files with 7 additions and 10 deletions

View File

@ -423,17 +423,14 @@ void LinkerScript::processCommands(OutputSectionFactory &Factory) {
CurOutSec = Aether; CurOutSec = Aether;
Dot = 0; Dot = 0;
for (unsigned I = 0; I < Opt.Commands.size(); ++I) { for (auto It = Opt.Commands.begin(); It != Opt.Commands.end(); ++It) {
auto Iter = Opt.Commands.begin() + I;
BaseCommand *Base1 = *Iter;
// Handle symbol assignments outside of any output section. // Handle symbol assignments outside of any output section.
if (auto *Cmd = dyn_cast<SymbolAssignment>(Base1)) { if (auto *Cmd = dyn_cast<SymbolAssignment>(*It)) {
addSymbol(Cmd); addSymbol(Cmd);
continue; continue;
} }
if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base1)) { if (auto *Cmd = dyn_cast<OutputSectionCommand>(*It)) {
std::vector<InputSectionBase *> V = createInputSectionList(*Cmd); std::vector<InputSectionBase *> V = createInputSectionList(*Cmd);
// The output section name `/DISCARD/' is special. // The output section name `/DISCARD/' is special.
@ -446,15 +443,15 @@ void LinkerScript::processCommands(OutputSectionFactory &Factory) {
// This is for ONLY_IF_RO and ONLY_IF_RW. An output section directive // This is for ONLY_IF_RO and ONLY_IF_RW. An output section directive
// ".foo : ONLY_IF_R[OW] { ... }" is handled only if all member input // ".foo : ONLY_IF_R[OW] { ... }" is handled only if all member input
// sections satisfy a given constraint. If not, a directive is handled // sections satisfy a given constraint. If not, a directive is handled
// as if it wasn't present from the beginning. // as if it weren't present from the beginning.
// //
// Because we'll iterate over Commands many more times, the easiest // Because we'll iterate over Commands many more times, the easiest
// way to "make it as if it wasn't present" is to just remove it. // way to "make it as if it weren't present" is to just remove it.
if (!matchConstraints(V, Cmd->Constraint)) { if (!matchConstraints(V, Cmd->Constraint)) {
for (InputSectionBase *S : V) for (InputSectionBase *S : V)
S->Assigned = false; S->Assigned = false;
Opt.Commands.erase(Iter); --It;
--I; Opt.Commands.erase(It + 1);
continue; continue;
} }