[libcxx] r187927 - Zhihao Yuan: Replace operator& with addressof in reference_wrapper constructor.
Arnold Schwaighofer
aschwaighofer at apple.com
Wed Aug 7 20:09:04 PDT 2013
Hi Howard,
this broke our internal apple bots. I have reverted it in r187959.
The failure can easily reproduced by checking out libcxx into a recent clang.
Thanks,
Arnold
$ cat test.cpp
#include <iostream>
int main(int argc, char **argv) {
std::cout << "foo";
return 0;
}
$ clang++ -v test.cpp -stdlib=libc++
clang version 3.4 (trunk 187955) (llvm/trunk 187956)
Target: x86_64-apple-darwin12.0.0
Thread model: posix
"/Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -d
isable-free -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 142 -v -resource-dir /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/clang/3.4 -stdlib=li
bc++ -fdeprecated-macro -fdebug-compilation-dir /Volumes/Data/backedup/dev/os/buildczar/llvm/release-libcxx -ferror-limit 19 -fmessage-len
gth 138 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-pro
perties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -ve
ctorize-slp -o /var/folders/nx/qkg2dhvd3d9c3pt9gp1wslwr0000gn/T/test-a7a764.o -x c++ test.cpp
clang -cc1 version 3.4 based upon LLVM 3.4svn default target x86_64-apple-darwin12.0.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1
/usr/local/include
/Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/clang/3.4/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
In file included from test.cpp:1:
In file included from /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/iostream:38:
In file included from /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/ios:216:
In file included from /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/__locale:15:
In file included from /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/string:439:
In file included from /Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/algorithm:627:
/Volumes/Data/backedup/dev/os/buildczar/llvm/release2/install/bin/../lib/c++/v1/memory:913:24: error: no member named 'addressof' in
namespace 'std::__1'
{return _VSTD::addressof(__r);}
On Aug 7, 2013, at 6:02 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> Author: hhinnant
> Date: Wed Aug 7 18:02:42 2013
> New Revision: 187927
>
> URL: http://llvm.org/viewvc/llvm-project?rev=187927&view=rev
> Log:
> Zhihao Yuan: Replace operator& with addressof in reference_wrapper constructor.
>
> Modified:
> libcxx/trunk/include/__functional_base
> libcxx/trunk/include/memory
>
> Modified: libcxx/trunk/include/__functional_base
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=187927&r1=187926&r2=187927&view=diff
> ==============================================================================
> --- libcxx/trunk/include/__functional_base (original)
> +++ libcxx/trunk/include/__functional_base Wed Aug 7 18:02:42 2013
> @@ -365,6 +365,56 @@ struct __invoke_return
> typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
> };
>
> +// addressof
> +
> +template <class _Tp>
> +inline _LIBCPP_INLINE_VISIBILITY
> +_Tp*
> +addressof(_Tp& __x) _NOEXCEPT
> +{
> + return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
> +}
> +
> +#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
> +// Objective-C++ Automatic Reference Counting uses qualified pointers
> +// that require special addressof() signatures. When
> +// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
> +// itself is providing these definitions. Otherwise, we provide them.
> +template <class _Tp>
> +inline _LIBCPP_INLINE_VISIBILITY
> +__strong _Tp*
> +addressof(__strong _Tp& __x) _NOEXCEPT
> +{
> + return &__x;
> +}
> +
> +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
> +template <class _Tp>
> +inline _LIBCPP_INLINE_VISIBILITY
> +__weak _Tp*
> +addressof(__weak _Tp& __x) _NOEXCEPT
> +{
> + return &__x;
> +}
> +#endif
> +
> +template <class _Tp>
> +inline _LIBCPP_INLINE_VISIBILITY
> +__autoreleasing _Tp*
> +addressof(__autoreleasing _Tp& __x) _NOEXCEPT
> +{
> + return &__x;
> +}
> +
> +template <class _Tp>
> +inline _LIBCPP_INLINE_VISIBILITY
> +__unsafe_unretained _Tp*
> +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
> +{
> + return &__x;
> +}
> +#endif
> +
> template <class _Tp>
> class _LIBCPP_TYPE_VIS reference_wrapper
> : public __weak_result_type<_Tp>
> @@ -377,7 +427,8 @@ private:
>
> public:
> // construct/copy/destroy
> - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {}
> + _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT
> + : __f_(_VSTD::addressof(__f)) {}
> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
> private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
> #endif
>
> Modified: libcxx/trunk/include/memory
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=187927&r1=187926&r2=187927&view=diff
> ==============================================================================
> --- libcxx/trunk/include/memory (original)
> +++ libcxx/trunk/include/memory Wed Aug 7 18:02:42 2013
> @@ -618,55 +618,7 @@ void* align(size_t alignment, size_t siz
>
> _LIBCPP_BEGIN_NAMESPACE_STD
>
> -// addressof
> -
> -template <class _Tp>
> -inline _LIBCPP_INLINE_VISIBILITY
> -_Tp*
> -addressof(_Tp& __x) _NOEXCEPT
> -{
> - return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
> -}
> -
> -#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
> -// Objective-C++ Automatic Reference Counting uses qualified pointers
> -// that require special addressof() signatures. When
> -// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler
> -// itself is providing these definitions. Otherwise, we provide them.
> -template <class _Tp>
> -inline _LIBCPP_INLINE_VISIBILITY
> -__strong _Tp*
> -addressof(__strong _Tp& __x) _NOEXCEPT
> -{
> - return &__x;
> -}
> -
> -#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK
> -template <class _Tp>
> -inline _LIBCPP_INLINE_VISIBILITY
> -__weak _Tp*
> -addressof(__weak _Tp& __x) _NOEXCEPT
> -{
> - return &__x;
> -}
> -#endif
> -
> -template <class _Tp>
> -inline _LIBCPP_INLINE_VISIBILITY
> -__autoreleasing _Tp*
> -addressof(__autoreleasing _Tp& __x) _NOEXCEPT
> -{
> - return &__x;
> -}
> -
> -template <class _Tp>
> -inline _LIBCPP_INLINE_VISIBILITY
> -__unsafe_unretained _Tp*
> -addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
> -{
> - return &__x;
> -}
> -#endif
> +// addressof moved to <__functional_base>
>
> template <class _Tp> class allocator;
>
>
>
> _______________________________________________
> 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