From ec0b29efd9f21e18e680796173ce44d2c77dd530 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 8 Oct 2015 22:36:08 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249763 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCAssembler.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 143d284897f..c656b8a14d1 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -97,17 +97,17 @@ void MCAsmLayout::invalidateFragmentsFrom(MCFragment *F) { 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(this)->layoutFragment(Cur); - Cur = Cur->getNextNode(); + assert(I != Sec->end() && "Layout bookkeeping error"); + const_cast(this)->layoutFragment(&*I); + ++I; } } -- 2.34.1