From 6832fae7da205502966a8d165ff3ce9c8bfcfd32 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 12 Apr 2017 08:48:39 +0000 Subject: [PATCH] [IR] Rename the class templates for the case iterator and case handle to not collide with the naming convention for template *arguments*. In at least one case they actually collided and this confuses MSVC. llvm-svn: 300038 --- llvm/include/llvm/IR/Instructions.h | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index dbbe6ee..9e4b499 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -3096,7 +3096,7 @@ public: // -2 static const unsigned DefaultPseudoIndex = static_cast(~0L-1); - template class CaseIteratorT; + template class CaseIteratorImpl; /// A handle to a particular switch case. It exposes a convenient interface /// to both the case value and the successor block. @@ -3104,10 +3104,10 @@ public: /// We define this as a template and instantiate it to form both a const and /// non-const handle. template - class CaseHandleT { + class CaseHandleImpl { // Directly befriend both const and non-const iterators. - friend class SwitchInst::CaseIteratorT< - CaseHandleT>; + friend class SwitchInst::CaseIteratorImpl< + CaseHandleImpl>; protected: // Expose the switch type we're parameterized with to the iterator. @@ -3116,8 +3116,8 @@ public: SwitchInstT *SI; ptrdiff_t Index; - CaseHandleT() = default; - CaseHandleT(SwitchInstT *SI, ptrdiff_t Index) : SI(SI), Index(Index) {} + CaseHandleImpl() = default; + CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index) : SI(SI), Index(Index) {} public: /// Resolves case value for current case. @@ -3146,20 +3146,21 @@ public: return (unsigned)Index != DefaultPseudoIndex ? Index + 1 : 0; } - bool operator==(const CaseHandleT &RHS) const { + bool operator==(const CaseHandleImpl &RHS) const { assert(SI == RHS.SI && "Incompatible operators."); return Index == RHS.Index; } }; - typedef CaseHandleT + typedef CaseHandleImpl ConstCaseHandle; - class CaseHandle : public CaseHandleT { - friend class SwitchInst::CaseIteratorT; + class CaseHandle + : public CaseHandleImpl { + friend class SwitchInst::CaseIteratorImpl; public: - CaseHandle(SwitchInst *SI, ptrdiff_t Index) : CaseHandleT(SI, Index) {} + CaseHandle(SwitchInst *SI, ptrdiff_t Index) : CaseHandleImpl(SI, Index) {} /// Sets the new value for current case. void setValue(ConstantInt *V) { @@ -3175,8 +3176,8 @@ public: }; template - class CaseIteratorT - : public iterator_facade_base, + class CaseIteratorImpl + : public iterator_facade_base, std::random_access_iterator_tag, CaseHandleT> { typedef typename CaseHandleT::SwitchInstType SwitchInstT; @@ -3186,29 +3187,29 @@ public: public: /// Default constructed iterator is in an invalid state until assigned to /// a case for a particular switch. - CaseIteratorT() = default; + CaseIteratorImpl() = default; /// Initializes case iterator for given SwitchInst and for given /// case number. - CaseIteratorT(SwitchInstT *SI, unsigned CaseNum) : Case(SI, CaseNum) {} + CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum) : Case(SI, CaseNum) {} /// Initializes case iterator for given SwitchInst and for given /// TerminatorInst's successor index. - static CaseIteratorT fromSuccessorIndex(SwitchInstT *SI, - unsigned SuccessorIndex) { + static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, + unsigned SuccessorIndex) { assert(SuccessorIndex < SI->getNumSuccessors() && "Successor index # out of range!"); - return SuccessorIndex != 0 ? CaseIteratorT(SI, SuccessorIndex - 1) - : CaseIteratorT(SI, DefaultPseudoIndex); + return SuccessorIndex != 0 ? CaseIteratorImpl(SI, SuccessorIndex - 1) + : CaseIteratorImpl(SI, DefaultPseudoIndex); } /// Support converting to the const variant. This will be a no-op for const /// variant. - operator CaseIteratorT() const { - return CaseIteratorT(Case.SI, Case.Index); + operator CaseIteratorImpl() const { + return CaseIteratorImpl(Case.SI, Case.Index); } - CaseIteratorT &operator+=(ptrdiff_t N) { + CaseIteratorImpl &operator+=(ptrdiff_t N) { // Check index correctness after addition. // Note: Index == getNumCases() means end(). assert(Case.Index + N >= 0 && @@ -3217,7 +3218,7 @@ public: Case.Index += N; return *this; } - CaseIteratorT &operator-=(ptrdiff_t N) { + CaseIteratorImpl &operator-=(ptrdiff_t N) { // Check index correctness after subtraction. // Note: Case.Index == getNumCases() means end(). assert(Case.Index - N >= 0 && @@ -3226,12 +3227,14 @@ public: Case.Index -= N; return *this; } - ptrdiff_t operator-(const CaseIteratorT &RHS) const { + ptrdiff_t operator-(const CaseIteratorImpl &RHS) const { assert(Case.SI == RHS.Case.SI && "Incompatible operators."); return Case.Index - RHS.Case.Index; } - bool operator==(const CaseIteratorT &RHS) const { return Case == RHS.Case; } - bool operator<(const CaseIteratorT &RHS) const { + bool operator==(const CaseIteratorImpl &RHS) const { + return Case == RHS.Case; + } + bool operator<(const CaseIteratorImpl &RHS) const { assert(Case.SI == RHS.Case.SI && "Incompatible operators."); return Case.Index < RHS.Case.Index; } @@ -3239,8 +3242,8 @@ public: const CaseHandleT &operator*() const { return Case; } }; - typedef CaseIteratorT CaseIt; - typedef CaseIteratorT ConstCaseIt; + typedef CaseIteratorImpl CaseIt; + typedef CaseIteratorImpl ConstCaseIt; static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, -- 2.7.4