- MCContext &context = MCOS.getContext();
-
- auto sec = SectionStartEndSyms.begin();
- while (sec != SectionStartEndSyms.end()) {
- assert(sec->second.first && "Start symbol must be set by now");
- MCOS.SwitchSection(sec->first);
- if (MCOS.mayHaveInstructions()) {
- MCSymbol *SectionEndSym = context.createTempSymbol();
- MCOS.EmitLabel(SectionEndSym);
- sec->second.second = SectionEndSym;
- ++sec;
- } else {
- MapVector<const MCSection *, std::pair<MCSymbol *, MCSymbol *>>::iterator
- to_erase = sec;
- sec = SectionStartEndSyms.erase(to_erase);
- }
+ std::vector<const MCSection *> Keep;
+ for (const MCSection *Sec : SectionsForRanges) {
+ MCOS.SwitchSection(Sec); // FIXME: pass the section to mayHaveInstructions
+ if (MCOS.mayHaveInstructions())
+ Keep.push_back(Sec);