Re: [libcxx] r324182 - [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-05 Thread Nirav Davé via cfe-commits
https://bugs.llvm.org/show_bug.cgi?id=36241


On Mon, Feb 5, 2018 at 10:20 AM Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This broke the Chromium build, see
> https://bugs.chromium.org/p/chromium/issues/detail?id=809050#c2
>
> I see there were a lot of changes landed around the same time, so I'm
> not sure what to revert here exactly.
>
> On Sun, Feb 4, 2018 at 2:03 AM, Eric Fiselier via cfe-commits
>  wrote:
> > Author: ericwf
> > Date: Sat Feb  3 17:03:08 2018
> > New Revision: 324182
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=324182&view=rev
> > Log:
> > [libc++] Fix PR35491 - std::array of zero-size doesn't work with
> non-default constructible types.
> >
> > Summary:
> > This patch fixes llvm.org/PR35491 and LWG2157  (
> https://cplusplus.github.io/LWG/issue2157)
> >
> > The fix attempts to maintain ABI compatibility by replacing the array
> with a instance of `aligned_storage`.
> >
> > Reviewers: mclow.lists, EricWF
> >
> > Reviewed By: EricWF
> >
> > Subscribers: lichray, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D41223
> >
> > Modified:
> > libcxx/trunk/include/array
> >
>  libcxx/trunk/test/std/containers/sequences/array/array.cons/default.pass.cpp
> >
>  libcxx/trunk/test/std/containers/sequences/array/array.data/data.pass.cpp
> >
>  
> libcxx/trunk/test/std/containers/sequences/array/array.data/data_const.pass.cpp
> > libcxx/trunk/test/std/containers/sequences/array/begin.pass.cpp
> >
> > Modified: libcxx/trunk/include/array
> > URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=324182&r1=324181&r2=324182&view=diff
> >
> ==
> > --- libcxx/trunk/include/array (original)
> > +++ libcxx/trunk/include/array Sat Feb  3 17:03:08 2018
> > @@ -118,6 +118,55 @@ template  c
> >  _LIBCPP_BEGIN_NAMESPACE_STD
> >
> >  template 
> > +struct __array_traits {
> > +  typedef _Tp _StorageT[_Size];
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static _LIBCPP_CONSTEXPR_AFTER_CXX14 _Tp* __data(_StorageT& __store) {
> > +return __store;
> > +  }
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static _LIBCPP_CONSTEXPR_AFTER_CXX14 _Tp const* __data(const
> _StorageT& __store) {
> > +return __store;
> > +  }
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static void __swap(_StorageT& __lhs, _StorageT& __rhs) {
> > +std::swap_ranges(__lhs, __lhs + _Size, __rhs);
> > +  }
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static void __fill(_StorageT& __arr, _Tp const& __val) {
> > +_VSTD::fill_n(__arr, _Size, __val);
> > +  }
> > +};
> > +
> > +template 
> > +struct __array_traits<_Tp, 0> {
> > +  typedef typename aligned_storage alignment_of<_Tp>::value>::type _StorageT;
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static _Tp* __data(_StorageT& __store) {
> > +_StorageT *__ptr = std::addressof(__store);
> > +return reinterpret_cast<_Tp*>(__ptr);
> > +  }
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static const _Tp* __data(const _StorageT& __store) {
> > +const _StorageT *__ptr = std::addressof(__store);
> > +return reinterpret_cast(__ptr);
> > +  }
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static void __swap(_StorageT&, _StorageT&) {}
> > +
> > +  _LIBCPP_INLINE_VISIBILITY
> > +  static void __fill(_StorageT&, _Tp const&) {
> > +  }
> > +};
> > +
> > +template 
> >  struct _LIBCPP_TEMPLATE_VIS array
> >  {
> >  // types:
> > @@ -134,31 +183,26 @@ struct _LIBCPP_TEMPLATE_VIS array
> >  typedef std::reverse_iterator   reverse_iterator;
> >  typedef std::reverse_iterator
> const_reverse_iterator;
> >
> > -value_type __elems_[_Size > 0 ? _Size : 1];
> > +typedef __array_traits<_Tp, _Size> _Traits;
> > +typename _Traits::_StorageT __elems_;
> >
> >  // No explicit construct/copy/destroy for aggregate type
> >  _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
> > -{_VSTD::fill_n(__elems_, _Size, __u);}
> > -_LIBCPP_INLINE_VISIBILITY
> > -void swap(array& __a) _NOEXCEPT_(_Size == 0 ||
> __is_nothrow_swappable<_Tp>::value)
> > -{ __swap_dispatch((std::integral_constant()),
> __a); }
> > +{_Traits::__fill(__elems_, __u);}
> >
> >  _LIBCPP_INLINE_VISIBILITY
> > -void __swap_dispatch(std::true_type, array&) {}
> > -
> > -_LIBCPP_INLINE_VISIBILITY
> > -void __swap_dispatch(std::false_type, array& __a)
> > -{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
> > +void swap(array& __a) _NOEXCEPT_(_Size == 0 ||
> __is_nothrow_swappable<_Tp>::value)
> > +{ _Traits::__swap(__elems_, __a.__elems_); }
> >
> >  // iterators:
> >  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
> > -iterator begin() _NOEXCEPT {return iterator(__elems_);}
> > +iterator begin() _NOEXCEPT {return iterator(data());}
> >  _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
> > -const_iterator begin() const

Re: [libcxx] r324182 - [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-05 Thread Nirav Davé via cfe-commits
It looks like we need to revert 324182 and 324194. I'll revert on I
reverify on trunk.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r324182 - [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.

2018-02-05 Thread Nirav Davé via cfe-commits
I reverted r324182, r324185, and r324192 in r324309. Things should be
unstuck now.

-Nirav

On Mon, Feb 5, 2018 at 9:06 PM, Nirav Davé  wrote:

> It looks like we need to revert 324182 and 324194. I'll revert on I
> reverify on trunk.
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276907 - Add flags to toggle preservation of assembly comments

2016-07-27 Thread Nirav Davé via cfe-commits
Looks like I missed the target triple. Should work now.

Thanks,

-Nirav

On Wed, Jul 27, 2016 at 4:41 PM, Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> Hi Nirav,
>
> This test is failing on darwin:
>
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26574
>
> Can you take a look?
>
> On Wed, Jul 27, 2016 at 12:57 PM, Nirav Dave via cfe-commits
>  wrote:
> > Author: niravd
> > Date: Wed Jul 27 14:57:40 2016
> > New Revision: 276907
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276907&view=rev
> > Log:
> > Add flags to toggle preservation of assembly comments
> >
> > Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.
> >
> > Reviewers: echristo, rnk
> >
> > Subscribers: mehdi_amini, llvm-commits
> >
> > Differential Revision: https://reviews.llvm.org/D22883
> >
> > Added:
> > cfe/trunk/test/CodeGen/preserve-as-comments.c
> > Modified:
> > cfe/trunk/include/clang/Driver/Options.td
> > cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > cfe/trunk/lib/Driver/Tools.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> >
> > Modified: cfe/trunk/include/clang/Driver/Options.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Driver/Options.td (original)
> > +++ cfe/trunk/include/clang/Driver/Options.td Wed Jul 27 14:57:40 2016
> > @@ -1089,6 +1089,9 @@ def fpie : Flag<["-"], "fpie">, Group >  def fno_pie : Flag<["-"], "fno-pie">, Group;
> >  def fplugin_EQ : Joined<["-"], "fplugin=">, Group,
> Flags<[DriverOption]>, MetaVarName<"">,
> >HelpText<"Load the named plugin (dynamic shared object)">;
> > +def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">,
> Group;
> > +def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">,
> Group, Flags<[CC1Option]>,
> > +  HelpText<"Do not preserve comments in inline assembly">;
> >  def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group;
> >  def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
> >  def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>;
> >
> > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> > +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Jul 27
> 14:57:40 2016
> > @@ -32,6 +32,7 @@ CODEGENOPT(DisableIntegratedAS, 1, 0) //
> >  CODEGENOPT(CompressDebugSections, 1, 0) ///<
> -Wa,-compress-debug-sections
> >  CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
> >  CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
> > +CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA,
> -fno-preserve-as-comments.
> >  CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit
> __attribute__((malloc)) operator new
> >  CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
> >  CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should
> be EH-safe.
> >
> > Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Jul 27 14:57:40 2016
> > @@ -604,6 +604,7 @@ void EmitAssemblyHelper::CreateTargetMac
> >CodeGenOpts.IncrementalLinkerCompatible;
> >Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
> >Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
> > +  Options.MCOptions.PreserveAsmComments =
> CodeGenOpts.PreserveAsmComments;
> >Options.MCOptions.ABIName = TargetOpts.ABI;
> >
> >TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
> FeaturesStr,
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=276907&r1=276906&r2=276907&view=diff
> >
> ==
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul 27 14:57:40 2016
> > @@ -4193,6 +4193,10 @@ void Clang::ConstructJob(Compilation &C,
> >  true))
> >  CmdArgs.push_back("-fno-jump-tables");
> >
> > +  if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
> > +options::OPT_fno_preserve_as_comments, true))
> > +CmdArgs.push_back("-fno-preserve-as-comments");
> > +
> >if (Arg *A = Args.getLastArg(options::OPT_m