[llvm] r277582 - [PM] Add the explicit copy, move, swap, and assignment boilerplate

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 07:53:07 PDT 2016



> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Chandler Carruth via llvm-commits
> Sent: Wednesday, August 03, 2016 1:16 AM
> To: llvm-commits at lists.llvm.org
> Subject: [llvm] r277582 - [PM] Add the explicit copy, move, swap, and
> assignment boilerplate
> 
> Author: chandlerc
> Date: Wed Aug  3 03:16:08 2016
> New Revision: 277582
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=277582&view=rev
> Log:
> [PM] Add the explicit copy, move, swap, and assignment boilerplate
> required by MSVC 2013.
> 
> This also makes the repeating pass wrapper assignable. Mildly
> unfortunate as it means we can't use a const member for the int, but
> that is a really minor invariant to try to preserve at the cost of loss
> of regularity of the type. Yet another annoyance of the particular C++
> object / move semantic model.
> 
> Modified:
>     llvm/trunk/include/llvm/IR/PassManager.h
> 
> Modified: llvm/trunk/include/llvm/IR/PassManager.h
> URL: http://llvm.org/viewvc/llvm-
> project/llvm/trunk/include/llvm/IR/PassManager.h?rev=277582&r1=277581&r2=2
> 77582&view=diff
> ==========================================================================
> ====
> --- llvm/trunk/include/llvm/IR/PassManager.h (original)
> +++ llvm/trunk/include/llvm/IR/PassManager.h Wed Aug  3 03:16:08 2016
> @@ -995,6 +995,21 @@ template <typename PassT>
>  class RepeatingPassWrapper : public
> PassInfoMixin<RepeatingPassWrapper<PassT>> {
>  public:
>    RepeatingPassWrapper(int Count, PassT P) : Count(Count),
> P(std::move(P)) {}
> +  // We have to explicitly define all the special member functions
> because MSVC
> +  // refuses to generate them.

Aaron Ballman says this kind of thing should have a FIXME citing
MSVC 2013 specifically, because we can remove it after we upgrade
the minimum to 2015.  (Just spreading the word here.)
Thanks,
--paulr

> +  RepeatingPassWrapper(const RepeatingPassWrapper &Arg)
> +      : Count(Arg.Count), P(Arg.P) {}
> +  RepeatingPassWrapper(RepeatingPassWrapper &&Arg)
> +      : Count(Arg.Count), P(std::move(Arg.P)) {}
> +  friend void swap(RepeatingPassWrapper &LHS, RepeatingPassWrapper &RHS)
> {
> +    using std::swap;
> +    swap(LHS.Count, RHS.Count);
> +    swap(LHS.P, RHS.P);
> +  }
> +  RepeatingPassWrapper &operator=(RepeatingPassWrapper RHS) {
> +    swap(*this, RHS);
> +    return *this;
> +  }
> 
>    template <typename IRUnitT, typename... Ts>
>    PreservedAnalyses run(IRUnitT &Arg, AnalysisManager<IRUnitT> &AM,
> @@ -1006,7 +1021,7 @@ public:
>    }
> 
>  private:
> -  const int Count;
> +  int Count;
>    PassT P;
>  };
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list