[libcxx] r318690 - Fix std::string::data() symbol during library build.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 12:23:27 PST 2017


Author: ericwf
Date: Mon Nov 20 12:23:27 2017
New Revision: 318690

URL: http://llvm.org/viewvc/llvm-project?rev=318690&view=rev
Log:
Fix std::string::data() symbol during library build.

The non-const data() member of std::string is only exposed
in C++17 and beyond. However std::string is externally instantiated
and so the member function needs to be exposed to be externally instantiated.

On Linux and OS X this shouldn't cause a problem, because
_LIBCPP_INLINE_VISIBILITY ensures the symbol is always inlined.

However on Windows, the symbol gets marked dllimport, but
there is no definition to import, causing link errors.

Modified:
    libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=318690&r1=318689&r2=318690&view=diff
==============================================================================
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Nov 20 12:23:27 2017
@@ -1128,7 +1128,7 @@ public:
     const value_type* c_str() const _NOEXCEPT {return data();}
     _LIBCPP_INLINE_VISIBILITY
     const value_type* data() const _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
-#if _LIBCPP_STD_VER > 14
+#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
     _LIBCPP_INLINE_VISIBILITY
     value_type* data()             _NOEXCEPT  {return _VSTD::__to_raw_pointer(__get_pointer());}
 #endif




More information about the cfe-commits mailing list