r227765 - Actually we can just inline the base typedef and use the injected class name for the base class.

Benjamin Kramer benny.kra at gmail.com
Sun Feb 1 14:12:30 PST 2015


> On 01.02.2015, at 21:54, Richard Smith <richard at metafoo.co.uk> wrote:
> 
> On Sun, Feb 1, 2015 at 12:47 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sun Feb  1 14:47:51 2015
> New Revision: 227765
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=227765&view=rev
> Log:
> Actually we can just inline the base typedef and use the injected class name for the base class.
> 
> IIRC this will make MSVC angry.

MSVC 2012 seems to have no problems with it. It couldn't parse the decltype() I had in the other patch, the injected class name seem to work fine.

I think we dropped all compilers that had issues with this pattern when we made the switch to C++11.

- Ben

>  
> Modified:
>     cfe/trunk/include/clang/AST/CanonicalType.h
>     cfe/trunk/include/clang/AST/DeclTemplate.h
> 
> Modified: cfe/trunk/include/clang/AST/CanonicalType.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=227765&r1=227764&r2=227765&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/CanonicalType.h (original)
> +++ cfe/trunk/include/clang/AST/CanonicalType.h Sun Feb  1 14:47:51 2015
> @@ -382,20 +382,18 @@ namespace clang {
>  /// \brief Iterator adaptor that turns an iterator over canonical QualTypes
>  /// into an iterator over CanQualTypes.
>  template <typename InputIterator>
> -class CanTypeIterator
> -    : public llvm::iterator_adaptor_base<
> +struct CanTypeIterator
> +    : llvm::iterator_adaptor_base<
>            CanTypeIterator<InputIterator>, InputIterator,
>            typename std::iterator_traits<InputIterator>::iterator_category,
>            CanQualType,
>            typename std::iterator_traits<InputIterator>::difference_type,
>            CanProxy<Type>, CanQualType> {
> -  typedef typename CanTypeIterator::iterator_adaptor_base BaseT;
> -
> -public:
>    CanTypeIterator() {}
> -  explicit CanTypeIterator(InputIterator Iter) : BaseT(std::move(Iter)) {}
> +  explicit CanTypeIterator(InputIterator Iter)
> +      : CanTypeIterator::iterator_adaptor_base(std::move(Iter)) {}
> 
> -  CanQualType operator*() const { return CanQualType::CreateUnsafe(*BaseT::I); }
> +  CanQualType operator*() const { return CanQualType::CreateUnsafe(*this->I); }
>    CanProxy<Type> operator->() const;
>  };
> 
> 
> Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=227765&r1=227764&r2=227765&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
> +++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Feb  1 14:47:51 2015
> @@ -552,23 +552,20 @@ protected:
> 
>    template <typename EntryType, typename SETraits = SpecEntryTraits<EntryType>,
>              typename DeclType = typename SETraits::DeclType>
> -  class SpecIterator
> -      : public llvm::iterator_adaptor_base<
> +  struct SpecIterator
> +      : llvm::iterator_adaptor_base<
>              SpecIterator<EntryType, SETraits, DeclType>,
>              typename llvm::FoldingSetVector<EntryType>::iterator,
>              typename std::iterator_traits<typename llvm::FoldingSetVector<
>                  EntryType>::iterator>::iterator_category,
>              DeclType *, ptrdiff_t, DeclType *, DeclType *> {
> -    typedef typename SpecIterator::iterator_adaptor_base BaseT;
> -
> -  public:
>      SpecIterator() {}
>      explicit SpecIterator(
>          typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
> -        : BaseT(std::move(SetIter)) {}
> +        : SpecIterator::iterator_adaptor_base(std::move(SetIter)) {}
> 
>      DeclType *operator*() const {
> -      return SETraits::getMostRecentDecl(&*BaseT::I);
> +      return SETraits::getMostRecentDecl(&*this->I);
>      }
>      DeclType *operator->() const { return **this; }
>    };
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 





More information about the cfe-commits mailing list