]> granicus.if.org Git - clang/commit
[Sema] Provide -fvisibility-global-new-delete-hidden option
authorPetr Hosek <phosek@chromium.org>
Tue, 4 Dec 2018 03:25:25 +0000 (03:25 +0000)
committerPetr Hosek <phosek@chromium.org>
Tue, 4 Dec 2018 03:25:25 +0000 (03:25 +0000)
commitae4f70f0a454182f8337a18e8e95894f42a1207d
treebdc97364e577dc0b4ed09a19e3471ae1ab42aa25
parent1a0f6a2ab41ee8b0b5a5e957208dfe5cd46a9a92
[Sema] Provide -fvisibility-global-new-delete-hidden option

When the global new and delete operators aren't declared, Clang
provides and implicit declaration, but this declaration currently
always uses the default visibility. This is a problem when the
C++ library itself is being built with non-default visibility because
the implicit declaration will force the new and delete operators to
have the default visibility unlike the rest of the library.

The existing workaround is to use assembly to enforce the visiblity:
https://fuchsia.googlesource.com/zircon/+/master/system/ulib/zxcpp/new.cpp#108
but that solution is not always available, e.g. in the case of of
libFuzzer which is using an internal version of libc++ that's also built
with -fvisibility=hidden where the existing behavior is causing issues.

This change introduces a new option -fvisibility-global-new-delete-hidden
which makes the implicit declaration of the global new and delete
operators hidden.

Differential Revision: https://reviews.llvm.org/D53787

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348234 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/LangOptions.def
include/clang/Driver/Options.td
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Sema/SemaExprCXX.cpp