From f39291772c8a8aba57a601c7c92c375f81a0651c Mon Sep 17 00:00:00 2001 From: Erik Eckstein Date: Thu, 21 May 2015 13:12:12 +0000 Subject: [PATCH] Remove const_use_iterator from SILValue and ValueBase. It was defined as the const version of use_iterator, which was wrong (e.g. you can't increment it). Actually we don't need it at all: use_begin/use_end can be const and return the non-const iterator, because a value is not the container of its uses. Swift SVN r28870 --- include/swift/SIL/SILValue.h | 53 ++++++++---------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/include/swift/SIL/SILValue.h b/include/swift/SIL/SILValue.h index 6c5dc90ae50..f4d096e58bf 100644 --- a/include/swift/SIL/SILValue.h +++ b/include/swift/SIL/SILValue.h @@ -106,15 +106,10 @@ public: bool use_empty() const { return FirstUse == nullptr; } using use_iterator = ValueBaseUseIterator; - using const_use_iterator = const ValueBaseUseIterator; - inline use_iterator use_begin(); - inline use_iterator use_end(); - inline Range getUses(); - - inline const_use_iterator use_begin() const; - inline const_use_iterator use_end() const; - inline Range getUses() const; + inline use_iterator use_begin() const; + inline use_iterator use_end() const; + inline Range getUses() const; inline bool hasOneUse() const; @@ -206,18 +201,13 @@ public: } using use_iterator = ValueUseIterator; - using const_use_iterator = const ValueUseIterator; inline bool use_empty() const; - inline use_iterator use_begin(); - inline use_iterator use_end(); - inline Range getUses(); + inline use_iterator use_begin() const; + inline use_iterator use_end() const; + inline Range getUses() const; inline bool hasOneUse() const; - inline const_use_iterator use_begin() const; - inline const_use_iterator use_end() const; - inline Range getUses() const; - // Return the underlying SILValue after stripping off all casts from the // current SILValue. SILValue stripCasts(); @@ -478,13 +468,13 @@ public: return !(lhs == rhs); } }; -inline ValueBase::use_iterator ValueBase::use_begin() { +inline ValueBase::use_iterator ValueBase::use_begin() const { return ValueBase::use_iterator(FirstUse); } -inline ValueBase::use_iterator ValueBase::use_end() { +inline ValueBase::use_iterator ValueBase::use_end() const { return ValueBase::use_iterator(nullptr); } -inline Range ValueBase::getUses() { +inline Range ValueBase::getUses() const { return { use_begin(), use_end() }; } inline bool ValueBase::hasOneUse() const { @@ -492,15 +482,6 @@ inline bool ValueBase::hasOneUse() const { if (I == E) return false; return ++I == E; } -inline ValueBase::const_use_iterator ValueBase::use_begin() const { - return ValueBase::const_use_iterator(FirstUse); -} -inline ValueBase::const_use_iterator ValueBase::use_end() const { - return ValueBase::const_use_iterator(nullptr); -} -inline Range ValueBase::getUses() const { - return {use_begin(), use_end()}; -} /// An iterator over all uses of a specific result of a ValueBase. class ValueUseIterator : public std::iteratorFirstUse, getResultNumber()); } -inline SILValue::use_iterator SILValue::use_end() { +inline SILValue::use_iterator SILValue::use_end() const { return SILValue::use_iterator(nullptr, 0); } -inline Range SILValue::getUses() { +inline Range SILValue::getUses() const { return { use_begin(), use_end() }; } inline bool SILValue::use_empty() const { return use_begin() == use_end(); } @@ -568,16 +549,6 @@ inline bool SILValue::hasOneUse() const { return ++I == E; } -inline SILValue::const_use_iterator SILValue::use_begin() const { - return SILValue::const_use_iterator((*this)->FirstUse, getResultNumber()); -} -inline SILValue::const_use_iterator SILValue::use_end() const { - return SILValue::const_use_iterator(nullptr, 0); -} -inline Range SILValue::getUses() const { - return {use_begin(), use_end()}; -} - /// A constant-size list of the operands of an instruction. template class FixedOperandList { Operand Buffer[N];