[libcxx-commits] [libcxx] [libc++] Fix the visibility of type traits (PR #111522)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 9 09:21:39 PDT 2024


================
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Make sure that the types and variables have the correct visibility attributes
+
+// RUN: %{cxx} %s %{flags} %{compile_flags} %{link_flags} -DSHARED -fPIC -fvisibility=hidden -shared -o %t.shared_lib
+// RUN: %{build} -fvisibility=hidden %t.shared_lib
+// RUN: %{run}
+
+#include <algorithm>
+#include <cassert>
+#include <type_traits>
+#include <vector>
+
+[[gnu::visibility("default")]] extern std::vector<const std::type_info*> shared_lib_type_infos;
+
+struct [[gnu::visibility("default")]] S {
+  static constexpr bool value = false;
+};
+
+inline std::vector<const std::type_info*> get_type_infos() {
+  return {
+      &typeid(std::remove_const<int>),
----------------
philnik777 wrote:

Technically we have to do that to be conforming I think.

Depends on what you mean by problem. We have default visibility for all the type symbols, at least on clang, so this is really just testing what we do already here. If you mean that we don't test this for any type in the library, then yes, this is the first test to make sure any type symbols have default visibility.

https://github.com/llvm/llvm-project/pull/111522


More information about the libcxx-commits mailing list