@@ -711,23 +711,7 @@ template <class _CharT, class _Traits, class _Allocator>
711711class basic_string {
712712private:
713713 using __default_allocator_type = allocator<_CharT>;
714- #ifndef _LIBCPP_HAS_NO_ASAN
715- pointer __asan_volatile_wrapper (pointer __ptr) const {
716- volatile pointer __copy_ptr = __ptr;
717-
718- return __copy_ptr;
719- }
720-
721- const_pointer const __asan_volatile_wrapper (const_pointer __ptr) const {
722- volatile const_pointer __copy_ptr = __ptr;
723714
724- return __copy_ptr;
725- }
726-
727- #define _LIBCPP_ASAN_VOLATILE_WRAPPER (ptr ) __asan_volatile_wrapper(ptr)
728- #else
729- #define _LIBCPP_ASAN_VOLATILE_WRAPPER (ptr ) ptr
730- #endif
731715public:
732716 typedef basic_string __self;
733717 typedef basic_string_view<_CharT, _Traits> __self_view;
@@ -751,7 +735,7 @@ public:
751735 //
752736 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether
753737 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
754- #ifndef _LIBCPP_HAS_NO_ASAN
738+ #if !defined( _LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
755739 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
756740 // relocatable. Because the object's memory might be poisoned when its content
757741 // is kept inside objects memory (short string optimization), instead of in allocated
@@ -765,7 +749,23 @@ public:
765749 basic_string,
766750 void >;
767751#endif
752+ #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
753+ pointer __asan_volatile_wrapper (pointer __ptr) const {
754+ volatile pointer __copy_ptr = __ptr;
755+
756+ return __copy_ptr;
757+ }
758+
759+ const_pointer const __asan_volatile_wrapper (const_pointer __ptr) const {
760+ volatile const_pointer __copy_ptr = __ptr;
761+
762+ return __copy_ptr;
763+ }
768764
765+ #define _LIBCPP_ASAN_VOLATILE_WRAPPER (ptr ) __asan_volatile_wrapper(ptr)
766+ #else
767+ #define _LIBCPP_ASAN_VOLATILE_WRAPPER (ptr ) ptr
768+ #endif
769769 static_assert ((!is_array<value_type>::value), " Character type of basic_string must not be an array" );
770770 static_assert ((is_standard_layout<value_type>::value), " Character type of basic_string must be standard-layout" );
771771 static_assert ((is_trivial<value_type>::value), " Character type of basic_string must be trivial" );
0 commit comments