smeenai updated this revision to Diff 80361.
smeenai added a comment.

Addressing @compnerd's comments


https://reviews.llvm.org/D26949

Files:
  src/abort_message.cpp
  src/abort_message.h
  src/cxa_exception.cpp
  src/cxa_exception.hpp
  src/cxa_handlers.cpp
  src/cxa_handlers.hpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  src/cxa_unexpected.cpp
  src/fallback_malloc.cpp
  src/fallback_malloc.h
  src/private_typeinfo.cpp
  src/private_typeinfo.h
  src/stdlib_exception.cpp

Index: src/stdlib_exception.cpp
===================================================================
--- src/stdlib_exception.cpp
+++ src/stdlib_exception.cpp
@@ -9,8 +9,6 @@
 
 #include <exception>
 
-#pragma GCC visibility push(default)
-
 namespace std
 {
 
@@ -37,5 +35,3 @@
 }
 
 }  // std
-
-#pragma GCC visibility pop
Index: src/private_typeinfo.h
===================================================================
--- src/private_typeinfo.h
+++ src/private_typeinfo.h
@@ -16,7 +16,6 @@
 #include <cstddef>
 
 namespace __cxxabiv1 {
-#pragma GCC visibility push(hidden)
 
 class _LIBCXXABI_TYPE_VIS __shim_type_info : public std::type_info {
 public:
@@ -67,7 +66,7 @@
 
 class _LIBCXXABI_TYPE_VIS __class_type_info;
 
-struct __dynamic_cast_info
+struct _LIBCXXABI_HIDDEN __dynamic_cast_info
 {
 // const data supplied to the search:
 
@@ -153,7 +152,7 @@
   has_unambiguous_public_base(__dynamic_cast_info *, void *, int) const;
 };
 
-struct __base_class_type_info
+struct _LIBCXXABI_HIDDEN __base_class_type_info
 {
 public:
     const __class_type_info* __base_type;
@@ -248,8 +247,6 @@
   _LIBCXXABI_HIDDEN bool can_catch_nested(const __shim_type_info *) const;
 };
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
 
 #endif  // __PRIVATE_TYPEINFO_H_
Index: src/private_typeinfo.cpp
===================================================================
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -55,12 +55,7 @@
 #include <string.h>
 #endif
 
-namespace __cxxabiv1
-{
-
-#pragma GCC visibility push(hidden)
-
-inline
+static inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
@@ -73,6 +68,8 @@
 #endif
 }
 
+namespace __cxxabiv1
+{
 
 // __shim_type_info
 
@@ -538,9 +535,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(default)
-
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
@@ -715,9 +709,6 @@
 #pragma clang diagnostic pop
 #endif
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(hidden)
-
 // Call this function when you hit a static_type which is a base (above) a dst_type.
 // Let caller know you hit a static_type.  But only start recording details if
 // this is (static_ptr, static_type) -- the node we are casting from.
@@ -1300,6 +1291,4 @@
                                   use_strcmp);
 }
 
-#pragma GCC visibility pop
-
 }  // __cxxabiv1
Index: src/fallback_malloc.h
===================================================================
--- src/fallback_malloc.h
+++ src/fallback_malloc.h
@@ -10,21 +10,18 @@
 #ifndef _FALLBACK_MALLOC_H
 #define _FALLBACK_MALLOC_H
 
+#include "__cxxabi_config.h"
 #include <cstddef> // for size_t
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 // Allocate some memory from _somewhere_
-void * __malloc_with_fallback(size_t size);
+_LIBCXXABI_HIDDEN void * __malloc_with_fallback(size_t size);
 
 // Allocate and zero-initialize memory from _somewhere_
-void * __calloc_with_fallback(size_t count, size_t size);
-
-void __free_with_fallback(void *ptr);
+_LIBCXXABI_HIDDEN void * __calloc_with_fallback(size_t count, size_t size);
 
-#pragma GCC visibility pop
+_LIBCXXABI_HIDDEN void __free_with_fallback(void *ptr);
 
 } // namespace __cxxabiv1
 
Index: src/fallback_malloc.cpp
===================================================================
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -191,8 +191,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 void * __malloc_with_fallback(size_t size) {
     void *ptr = std::malloc(size);
     if (NULL == ptr) // if malloc fails, fall back to emergency stash
@@ -218,6 +216,4 @@
         std::free(ptr);
 }
 
-#pragma GCC visibility pop
-
 } // namespace __cxxabiv1
Index: src/cxa_unexpected.cpp
===================================================================
--- src/cxa_unexpected.cpp
+++ src/cxa_unexpected.cpp
@@ -14,14 +14,10 @@
 namespace __cxxabiv1
 {
 
-#pragma GCC visibility push(default)
-
 extern "C"
 {
 
 }
 
-#pragma GCC visibility pop
-
 }  // namespace __cxxabiv1
 
Index: src/cxa_noexception.cpp
===================================================================
--- src/cxa_noexception.cpp
+++ src/cxa_noexception.cpp
@@ -22,8 +22,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(default)
-
 extern "C" {
 
 void
@@ -55,6 +53,4 @@
 
 }  // extern "C"
 
-#pragma GCC visibility pop
-
 }  // abi
Index: src/cxa_new_delete.cpp
===================================================================
--- src/cxa_new_delete.cpp
+++ src/cxa_new_delete.cpp
@@ -31,7 +31,7 @@
 * The loop terminates when an attempt to allocate the requested storage is
   successful or when a called new_handler function does not return.
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void *
 operator new(std::size_t size)
 #if !__has_feature(cxx_noexcept)
@@ -68,7 +68,7 @@
 Calls operator new(size). If the call returns normally, returns the result of
 that call. Otherwise, returns a null pointer.
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void*
 operator new(size_t size, const std::nothrow_t&)
 #if __has_feature(cxx_noexcept)
@@ -97,7 +97,7 @@
 
 Returns operator new(size).
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void*
 operator new[](size_t size)
 #if !__has_feature(cxx_noexcept)
@@ -113,7 +113,7 @@
 Calls operator new[](size). If the call returns normally, returns the result
 of that call. Otherwise, returns a null pointer.
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void*
 operator new[](size_t size, const std::nothrow_t&)
 #if __has_feature(cxx_noexcept)
@@ -143,7 +143,7 @@
 If ptr is null, does nothing. Otherwise, reclaims the storage allocated by the
 earlier call to operator new.
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void
 operator delete(void* ptr)
 #if __has_feature(cxx_noexcept)
@@ -161,7 +161,7 @@
 
 calls operator delete(ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void
 operator delete(void* ptr, const std::nothrow_t&)
 #if __has_feature(cxx_noexcept)
@@ -178,7 +178,7 @@
 
 Calls operator delete(ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void
 operator delete[] (void* ptr)
 #if __has_feature(cxx_noexcept)
@@ -195,7 +195,7 @@
 
 calls operator delete[](ptr)
 */
-__attribute__((__weak__, __visibility__("default")))
+__attribute__((__weak__))
 void
 operator delete[] (void* ptr, const std::nothrow_t&)
 #if __has_feature(cxx_noexcept)
Index: src/cxa_handlers.hpp
===================================================================
--- src/cxa_handlers.hpp
+++ src/cxa_handlers.hpp
@@ -20,11 +20,11 @@
 namespace std
 {
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN __attribute__((noreturn))
 void
 __unexpected(unexpected_handler func);
 
-__attribute__((visibility("hidden"), noreturn))
+_LIBCXXABI_HIDDEN __attribute__((noreturn))
 void
 __terminate(terminate_handler func) _NOEXCEPT;
 
Index: src/cxa_handlers.cpp
===================================================================
--- src/cxa_handlers.cpp
+++ src/cxa_handlers.cpp
@@ -32,7 +32,6 @@
 //  return __cxa_unexpected_handler.load(memory_order_acq);
 }
 
-__attribute__((visibility("hidden"), noreturn))
 void
 __unexpected(unexpected_handler func)
 {
@@ -57,7 +56,6 @@
 //  return __cxa_terminate_handler.load(memory_order_acq);
 }
 
-__attribute__((visibility("hidden"), noreturn))
 void
 __terminate(terminate_handler func) _NOEXCEPT
 {
@@ -104,7 +102,7 @@
 
 // In the future this will become:
 // std::atomic<std::new_handler>  __cxa_new_handler(0);
-extern "C" _LIBCXXABI_DATA_VIS new_handler __cxa_new_handler = 0;
+extern "C" new_handler __cxa_new_handler = 0;
 
 new_handler
 set_new_handler(new_handler handler) _NOEXCEPT
Index: src/cxa_exception.hpp
===================================================================
--- src/cxa_exception.hpp
+++ src/cxa_exception.hpp
@@ -20,13 +20,11 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(hidden)
-
 static const uint64_t kOurExceptionClass          = 0x434C4E47432B2B00; // CLNGC++\0
 static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1
 static const uint64_t get_vendor_and_language     = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++
 
-struct __cxa_exception {
+struct _LIBCXXABI_HIDDEN __cxa_exception {
 #if defined(__LP64__) || LIBCXXABI_ARM_EHABI
     // This is a new field to support C++ 0x exception_ptr.
     // For binary compatibility it is at the start of this
@@ -69,7 +67,7 @@
 // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html
 // The layout of this structure MUST match the layout of __cxa_exception, with
 // primaryException instead of referenceCount.
-struct __cxa_dependent_exception {
+struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
 #if defined(__LP64__) || LIBCXXABI_ARM_EHABI
     void* primaryException;
 #endif
@@ -101,24 +99,19 @@
     _Unwind_Exception unwindHeader;
 };
 
-struct __cxa_eh_globals {
+struct _LIBCXXABI_HIDDEN __cxa_eh_globals {
     __cxa_exception *   caughtExceptions;
     unsigned int        uncaughtExceptions;
 #if LIBCXXABI_ARM_EHABI
     __cxa_exception* propagatingExceptions;
 #endif
 };
 
-#pragma GCC visibility pop
-#pragma GCC visibility push(default)
-
-extern "C" __cxa_eh_globals * __cxa_get_globals      ();
-extern "C" __cxa_eh_globals * __cxa_get_globals_fast ();
-
-extern "C" void * __cxa_allocate_dependent_exception ();
-extern "C" void __cxa_free_dependent_exception (void * dependent_exception);
+extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals      ();
+extern "C" _LIBCXXABI_FUNC_VIS __cxa_eh_globals * __cxa_get_globals_fast ();
 
-#pragma GCC visibility pop
+extern "C" _LIBCXXABI_FUNC_VIS void * __cxa_allocate_dependent_exception ();
+extern "C" _LIBCXXABI_FUNC_VIS void __cxa_free_dependent_exception (void * dependent_exception);
 
 }  // namespace __cxxabiv1
 
Index: src/cxa_exception.cpp
===================================================================
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -34,8 +34,6 @@
 
 namespace __cxxabiv1 {
 
-#pragma GCC visibility push(default)
-
 //  Utility routines
 static
 inline
@@ -140,7 +138,7 @@
 //  object. Zero-fill the object. If memory can't be allocated, call
 //  std::terminate. Return a pointer to the memory to be used for the
 //  user's exception object.
-_LIBCXXABI_FUNC_VIS void *__cxa_allocate_exception(size_t thrown_size) throw() {
+void *__cxa_allocate_exception(size_t thrown_size) throw() {
     size_t actual_size = cxa_exception_size_from_exception_thrown_size(thrown_size);
     __cxa_exception *exception_header =
         static_cast<__cxa_exception *>(__malloc_with_fallback(actual_size));
@@ -152,7 +150,7 @@
 
 
 //  Free a __cxa_exception object allocated with __cxa_allocate_exception.
-_LIBCXXABI_FUNC_VIS void __cxa_free_exception(void *thrown_object) throw() {
+void __cxa_free_exception(void *thrown_object) throw() {
     __free_with_fallback(cxa_exception_from_thrown_object(thrown_object));
 }
 
@@ -203,7 +201,7 @@
 will call terminate, assuming that there was no handler for the
 exception.
 */
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void
+void
 __cxa_throw(void *thrown_object, std::type_info *tinfo, void (*dest)(void *)) {
     __cxa_eh_globals *globals = __cxa_get_globals();
     __cxa_exception* exception_header = cxa_exception_from_thrown_object(thrown_object);
@@ -236,7 +234,6 @@
 
   Requires:  exception is native
 */
-_LIBCXXABI_FUNC_VIS
 void *__cxa_get_exception_ptr(void *unwind_exception) throw() {
 #if LIBCXXABI_ARM_EHABI
     return reinterpret_cast<void*>(
@@ -252,7 +249,6 @@
 The routine to be called before the cleanup.  This will save __cxa_exception in
 __cxa_eh_globals, so that __cxa_end_cleanup() can recover later.
 */
-_LIBCXXABI_FUNC_VIS
 bool __cxa_begin_cleanup(void *unwind_arg) throw() {
     _Unwind_Exception* unwind_exception = static_cast<_Unwind_Exception*>(unwind_arg);
     __cxa_eh_globals* globals = __cxa_get_globals();
@@ -424,7 +420,7 @@
 * If it has been rethrown, there is nothing to do.
 * Otherwise delete the exception and pop the catch stack to empty.
 */
-_LIBCXXABI_FUNC_VIS void __cxa_end_catch() {
+void __cxa_end_catch() {
   static_assert(sizeof(__cxa_exception) == sizeof(__cxa_dependent_exception),
                 "sizeof(__cxa_exception) must be equal to "
                 "sizeof(__cxa_dependent_exception)");
@@ -501,7 +497,7 @@
 // Note:  exception_header may be masquerading as a __cxa_dependent_exception
 //        and that's ok.  exceptionType is there too.
 //        However watch out for foreign exceptions.  Return null for them.
-_LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type() {
+std::type_info *__cxa_current_exception_type() {
 //  get the current exception
     __cxa_eh_globals *globals = __cxa_get_globals_fast();
     if (NULL == globals)
@@ -526,7 +522,7 @@
   Note:  exception_header may be masquerading as a __cxa_dependent_exception
          and that's ok.
 */
-_LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_rethrow() {
+void __cxa_rethrow() {
     __cxa_eh_globals* globals = __cxa_get_globals();
     __cxa_exception* exception_header = globals->caughtExceptions;
     if (NULL == exception_header)
@@ -571,7 +567,7 @@
 
     Requires:  If thrown_object is not NULL, it is a native exception.
 */
-_LIBCXXABI_FUNC_VIS void
+void
 __cxa_increment_exception_refcount(void *thrown_object) throw() {
     if (thrown_object != NULL )
     {
@@ -588,7 +584,7 @@
 
     Requires:  If thrown_object is not NULL, it is a native exception.
 */
-_LIBCXXABI_FUNC_VIS void
+void
 __cxa_decrement_exception_refcount(void *thrown_object) throw() {
     if (thrown_object != NULL )
     {
@@ -612,7 +608,7 @@
     been no exceptions thrown, ever, on this thread, we can return NULL without 
     the need to allocate the exception-handling globals.
 */
-_LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw() {
+void *__cxa_current_primary_exception() throw() {
 //  get the current exception
     __cxa_eh_globals* globals = __cxa_get_globals_fast();
     if (NULL == globals)
@@ -698,6 +694,4 @@
 
 }  // extern "C"
 
-#pragma GCC visibility pop
-
 }  // abi
Index: src/abort_message.h
===================================================================
--- src/abort_message.h
+++ src/abort_message.h
@@ -10,24 +10,18 @@
 #ifndef __ABORT_MESSAGE_H_
 #define __ABORT_MESSAGE_H_
 
-#include <stdio.h>
-
-#pragma GCC visibility push(hidden)
+#include "__cxxabi_config.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-__attribute__((visibility("hidden"), noreturn))
-       void abort_message(const char* format, ...) 
-            __attribute__((format(printf, 1, 2)));
-
+_LIBCXXABI_HIDDEN __attribute__((noreturn)) void
+abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
 #ifdef __cplusplus
 }
 #endif
 
-#pragma GCC visibility pop
-
 #endif
 
Index: src/abort_message.cpp
===================================================================
--- src/abort_message.cpp
+++ src/abort_message.cpp
@@ -22,16 +22,13 @@
 #endif // __ANDROID_API__ >= 21
 #endif // __BIONIC__
 
-#pragma GCC visibility push(hidden)
-
 #ifdef __APPLE__
 #   if defined(__has_include) && __has_include(<CrashReporterClient.h>)
 #       define HAVE_CRASHREPORTERCLIENT_H
 #       include <CrashReporterClient.h>
 #   endif
 #endif
 
-__attribute__((visibility("hidden"), noreturn))
 void abort_message(const char* format, ...)
 {
     // write message to stderr
@@ -77,5 +74,3 @@
 
     abort();
 }
-
-#pragma GCC visibility pop
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to