[llvm] r249763 - MC: Stop using Fragment::getNextNode()
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 15:36:09 PDT 2015
Author: dexonsmith
Date: Thu Oct 8 17:36:08 2015
New Revision: 249763
URL: http://llvm.org/viewvc/llvm-project?rev=249763&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=249763&r1=249762&r2=249763&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Oct 8 17:36:08 2015
@@ -97,17 +97,17 @@ void MCAsmLayout::invalidateFragmentsFro
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;
}
}
More information about the llvm-commits
mailing list