Roll src/buildtools/third_party/libc++abi/trunk/ 5fb4080bf..6918862bf (1 commit)

Allows cleaning up a hack from the last roll.

https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/5fb4080bfe3d..6918862bfc2b

$ git log 5fb4080bf..6918862bf --date=short --no-merges --format='%ad %ae %s'
2021-02-26 thakis [libcxxabi] Fewer assumptions about path from libcxx to libcxxabi

Created with:
  roll-dep src/buildtools/third_party/libc++abi/trunk

Bug: 1180836
Change-Id: I092a550015ab7a4be482df67a2f4634d978bb7fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2722591
Commit-Queue: Nico Weber <thakis@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#858180}
GitOrigin-RevId: be5f93dd961562aae30bd9c3f8664b1016242cbb
diff --git a/DEPS b/DEPS
index b5f443e..7ddfdac 100644
--- a/DEPS
+++ b/DEPS
@@ -20,7 +20,7 @@
   # TODO(crbug.com/1166332) rename to clang_format_revision.
   'clang_fmt_revision':    '99803d74e35962f63a775f29477882afd4d57d94',
   'libcxx_revision':       '8fa87946779682841e21e2da977eccfb6cb3bded',
-  'libcxxabi_revision':    '5fb4080bfe3daeb36e10abe50202d6579bf95072',
+  'libcxxabi_revision':    '6918862bfc2bff22b45058fac22b1596c49982fb',
 }
 
 deps = {
diff --git a/third_party/libc++abi/BUILD.gn b/third_party/libc++abi/BUILD.gn
index 8ab7584..8b1da01 100644
--- a/third_party/libc++abi/BUILD.gn
+++ b/third_party/libc++abi/BUILD.gn
@@ -88,8 +88,6 @@
     configs += [ "//build/config/gcc:symbol_visibility_default" ]
   }
 
-  # TODO(thakis): This is a gross workaround for https:/llvm.org/PR49313
-  # We had to copy refstring.h into libc++abi for the relative path to work,
-  # but the copy includes more stuff from libc++'s internal headers.
-  include_dirs = [ "../libc++/trunk/src/include" ]
+  # stdlib_stdexcept.cpp depends on libc++ internals.
+  include_dirs = [ "../libc++/trunk" ]
 }
diff --git a/third_party/libc++abi/README.chromium b/third_party/libc++abi/README.chromium
index 3b47c4b..a57429e 100644
--- a/third_party/libc++abi/README.chromium
+++ b/third_party/libc++abi/README.chromium
@@ -9,8 +9,3 @@
 Description:
 
 libc++abi for Chromium.
-
-Local changes:
-- Copied buildtools/third_party/libc++/trunk/src/include/refstring.h to
-  buildtools/third_party/libc++abi/libcxx/src/include/refstring.h to work
-  around https://llvm.org/PR49313
diff --git a/third_party/libc++abi/libcxx/src/include/refstring.h b/third_party/libc++abi/libcxx/src/include/refstring.h
deleted file mode 100644
index cefd7ca..0000000
--- a/third_party/libc++abi/libcxx/src/include/refstring.h
+++ /dev/null
@@ -1,140 +0,0 @@
-//===------------------------ __refstring ---------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_REFSTRING_H
-#define _LIBCPP_REFSTRING_H
-
-#include <__config>
-#include <stdexcept>
-#include <cstddef>
-#include <cstring>
-#include "atomic_support.h"
-
-// MacOS and iOS used to ship with libstdc++, and still support old applications
-// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed
-// to be ABI compatible, such that they can be thrown from one library and caught
-// in the other.
-//
-// For that reason, we must look for libstdc++ in the same process and if found,
-// check the string stored in the exception object to see if it is the GCC empty
-// string singleton before manipulating the reference count. This is done so that
-// if an exception is created with a zero-length string in libstdc++, libc++abi
-// won't try to delete the memory.
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
-    defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#   define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
-#   include <dlfcn.h>
-#   include <mach-o/dyld.h>
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-namespace __refstring_imp { namespace {
-typedef int count_t;
-
-struct _Rep_base {
-    std::size_t len;
-    std::size_t cap;
-    count_t     count;
-};
-
-inline _Rep_base* rep_from_data(const char *data_) noexcept {
-    char *data = const_cast<char *>(data_);
-    return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-}
-
-inline char * data_from_rep(_Rep_base *rep) noexcept {
-    char *data = reinterpret_cast<char *>(rep);
-    return data + sizeof(*rep);
-}
-
-#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
-inline
-const char* compute_gcc_empty_string_storage() _NOEXCEPT
-{
-    void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-    if (handle == nullptr)
-        return nullptr;
-    void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
-    if (sym == nullptr)
-        return nullptr;
-    return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-}
-
-inline
-const char*
-get_gcc_empty_string_storage() _NOEXCEPT
-{
-    static const char* p = compute_gcc_empty_string_storage();
-    return p;
-}
-#endif
-
-}} // namespace __refstring_imp
-
-using namespace __refstring_imp;
-
-inline
-__libcpp_refstring::__libcpp_refstring(const char* msg) {
-    std::size_t len = strlen(msg);
-    _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
-    rep->len = len;
-    rep->cap = len;
-    rep->count = 0;
-    char *data = data_from_rep(rep);
-    std::memcpy(data, msg, len + 1);
-    __imp_ = data;
-}
-
-inline
-__libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT
-    : __imp_(s.__imp_)
-{
-    if (__uses_refcount())
-        __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
-}
-
-inline
-__libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) _NOEXCEPT {
-    bool adjust_old_count = __uses_refcount();
-    struct _Rep_base *old_rep = rep_from_data(__imp_);
-    __imp_ = s.__imp_;
-    if (__uses_refcount())
-        __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
-    if (adjust_old_count)
-    {
-        if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0)
-        {
-            ::operator delete(old_rep);
-        }
-    }
-    return *this;
-}
-
-inline
-__libcpp_refstring::~__libcpp_refstring() {
-    if (__uses_refcount()) {
-        _Rep_base* rep = rep_from_data(__imp_);
-        if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {
-            ::operator delete(rep);
-        }
-    }
-}
-
-inline
-bool __libcpp_refstring::__uses_refcount() const {
-#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
-    return __imp_ != get_gcc_empty_string_storage();
-#else
-    return true;
-#endif
-}
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif //_LIBCPP_REFSTRING_H