MC: Stop using Fragment::getNextNode()
Stop using `getNextNode()` to get an iterator to a fragment (at least,
in this one place). Instead, use iterator logic directly.
The `getNextNode()` interface isn't actually supposed to work for
creating iterators; it's supposed to return `nullptr` (not a real
iterator) if this is the last node. It's currently broken and will
"happen" to work, but if we ever fix the function, we'll get some
strange failures in places like this.
llvm-svn: 249763
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 143d284..c656b8a 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -97,17 +97,17 @@
void MCAsmLayout::ensureValid(const MCFragment *F) const {
MCSection *Sec = F->getParent();
- MCFragment *Cur = LastValidFragment[Sec];
- if (!Cur)
- Cur = Sec->begin();
+ MCSection::iterator I;
+ if (MCFragment *Cur = LastValidFragment[Sec])
+ I = ++MCSection::iterator(Cur);
else
- Cur = Cur->getNextNode();
+ I = Sec->begin();
// Advance the layout position until the fragment is valid.
while (!isFragmentValid(F)) {
- assert(Cur && "Layout bookkeeping error");
- const_cast<MCAsmLayout*>(this)->layoutFragment(Cur);
- Cur = Cur->getNextNode();
+ assert(I != Sec->end() && "Layout bookkeeping error");
+ const_cast<MCAsmLayout *>(this)->layoutFragment(&*I);
+ ++I;
}
}