[libcxx-commits] [PATCH] D64941: [libc++] Fix link error with _LIBCPP_HIDE_FROM_ABI_PER_TU and std::string

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 18 12:39:33 PDT 2019


ldionne created this revision.
ldionne added a reviewer: mclow.lists.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous, christof.
Herald added a project: libc++.

This is effectively a revert of r344616, which was a partial fix for
PR38964 (compilation of <string> with GCC in C++03 mode). However, that
configuration is explicitly not supported anymore and that partial fix
breaks compilation with Clang when per-TU insulation is provided.

PR42676
rdar://52899715


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64941

Files:
  libcxx/include/string
  libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp


Index: libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/strings/basic.string/PR42676.sh.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Regression test for PR42676.
+
+// RUN: %cxx %flags %s -o %t.exe %compile_flags -D_LIBCPP_HIDE_FROM_ABI_PER_TU
+// RUN: %t.exe
+
+#include <memory>
+#include <string>
+
+int main() {
+    std::string s1(10u, '-', std::allocator<char>()); (void)s1;
+    std::string s2("hello", std::allocator<char>()); (void)s2;
+    std::string s3("hello"); (void)s3;
+}
Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -812,9 +812,7 @@
     basic_string(basic_string&& __str, const allocator_type& __a);
 #endif  // _LIBCPP_CXX03_LANG
 
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
-#endif
     _LIBCPP_INLINE_VISIBILITY
     basic_string(const _CharT* __s) {
       _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
@@ -824,9 +822,7 @@
 #   endif
     }
 
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
-#endif
         _LIBCPP_INLINE_VISIBILITY
         basic_string(const _CharT* __s, const _Allocator& __a);
 
@@ -837,9 +833,7 @@
     _LIBCPP_INLINE_VISIBILITY
     basic_string(size_type __n, _CharT __c);
 
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
     template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type>
-#endif
         _LIBCPP_INLINE_VISIBILITY
         basic_string(size_type __n, _CharT __c, const _Allocator& __a);
 
@@ -1800,9 +1794,7 @@
 }
 
 template <class _CharT, class _Traits, class _Allocator>
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 template <class>
-#endif
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
     : __r_(__second_tag(), __a)
 {
@@ -1939,9 +1931,7 @@
 }
 
 template <class _CharT, class _Traits, class _Allocator>
-#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 template <class>
-#endif
 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a)
     : __r_(__second_tag(), __a)
 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64941.210651.patch
Type: text/x-patch
Size: 2747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190718/4ee78fe7/attachment.bin>


More information about the libcxx-commits mailing list