-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Add
-fvisibility-global-new-delete=
option
By default the implicitly declared replaceable global new and delete operators are given a default visibility attribute. Previous work, see: https://reviews.llvm.org/D53787, added `-fvisibility-global-new-delete-hidden` to change this to a hidden visibility attribute. This change adds `-fvisibility-global-new-delete=` which controls whether (or not) to add an implicit visibility attribute to the implicit declarations for these functions, and what visibility that attribute will specify. The option takes 4 values: `force-hidden`, `force-protected`, `force-default` and `source`. Option values `force-hidden`, `force-protected` and `force-default` assign hidden, protected, and default visibilities respectively; the use of the term force in the value names is designed to imply to a user that the semantics of this option differ significantly from `-fvisibility=`. An option value of `source` implies that no implicit attribute is added; without the attribute the replaceable global new and delete operators behave normally (like other functions) with respect to visibility attributes, pragmas and options. The motivation for the `source` value is to facilitate users who intend to replace these functions either for a single linkage unit or a limited set of linkage units. `-fvisibility-global-new-delete=source` can be applied globally to the compilations in a build where the existing `-fvisibility-global-new-delete-hidden` cannot, as it conflicts with a common pattern where these functions are dynamically imported. The existing `-fvisibility-global-new-delete-hidden` is now a deprecated spelling of `-fvisibility-global-new-delete=force-hidden` A release note has been added for these changes. `-fvisibility-global-new-delete=source` will be set by default for PS5. PS5 users that want the normal toolchain behaviour will be able to supply `-fvisibility-global-new-delete=force-default`.
- Loading branch information
1 parent
128d53f
commit dc60cb2
Showing
9 changed files
with
157 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %clang_cc1 %s -std=c++11 -triple x86_64-unknown-unknown -fvisibility=hidden -emit-llvm -o - | FileCheck %s -DLINKAGE=dso_local | ||
// RUN: %clang_cc1 %s -std=c++11 -triple x86_64-unknown-unknown -fvisibility=default -fvisibility-global-new-delete=force-hidden -emit-llvm -o - | FileCheck %s -DLINKAGE=hidden | ||
// RUN: %clang_cc1 %s -std=c++11 -triple x86_64-unknown-unknown -fvisibility=hidden -fvisibility-global-new-delete=force-protected -emit-llvm -o - | FileCheck %s -DLINKAGE=protected | ||
// RUN: %clang_cc1 %s -std=c++11 -triple x86_64-unknown-unknown -fvisibility=hidden -fvisibility-global-new-delete=force-default -emit-llvm -o - | FileCheck %s -DLINKAGE=dso_local | ||
// RUN: %clang_cc1 %s -std=c++11 -triple x86_64-unknown-unknown -fvisibility=hidden -fvisibility-global-new-delete=source -emit-llvm -o - | FileCheck %s -DLINKAGE=hidden | ||
|
||
namespace std { | ||
typedef __typeof__(sizeof(0)) size_t; | ||
struct nothrow_t {}; | ||
} | ||
|
||
// Definition which inherits visibility from the implicit compiler generated declaration. | ||
void operator delete(void*) throw() {} | ||
// CHECK: define [[LINKAGE]] void @_ZdlPv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/// Check driver handling for "-fvisibility-global-new-delete-hidden" and "-fvisibility-global-new-delete=". | ||
|
||
/// These options are not added by default. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm %s 2>&1 | \ | ||
// RUN: FileCheck -check-prefix=DEFAULTS %s | ||
// DEFAULTS-NOT: "-fvisibility-global-new-delete=" | ||
// DEFAULTS-NOT: "-fvisibility-global-new-delete-hidden" | ||
|
||
// DEFINE: %{implicit-check-nots} = --implicit-check-not=-fvisibility-global-new-delete= --implicit-check-not=-fvisibility-global-new-delete-hidden | ||
|
||
/// "-fvisibility-global-new-delete=source" added by default for PS5. | ||
// RUN: %clang -### --target=x86_64-sie-ps5 -c -emit-llvm %s 2>&1 | \ | ||
// RUN: FileCheck -check-prefix=PS5 %s | ||
// PS5: "-fvisibility-global-new-delete=source" | ||
|
||
/// -fvisibility-global-new-delete-hidden added explicitly. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete-hidden %s 2>&1 | FileCheck -check-prefixes=VGNDH,DEPRECATED %s %{implicit-check-nots} | ||
// RUN: %clang -### --target=x86_64-sie-ps5 -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete-hidden %s 2>&1 | FileCheck -check-prefixes=VGNDH,DEPRECATED %s %{implicit-check-nots} | ||
// DEPRECATED-DAG: clang: warning: argument '-fvisibility-global-new-delete-hidden' is deprecated, use '-fvisibility-global-new-delete=force-hidden' instead [-Wdeprecated] | ||
// VGNDH-DAG: "-fvisibility-global-new-delete=force-hidden" | ||
|
||
/// -fvisibility-global-new-delete=force-hidden added explicitly. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-hidden %s 2>&1 | FileCheck -check-prefixes=VGNDH %s %{implicit-check-nots} | ||
// RUN: %clang -### --target=x86_64-sie-ps5 -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-hidden %s 2>&1 | FileCheck -check-prefixes=VGNDH %s %{implicit-check-nots} | ||
|
||
/// -fvisibility-global-new-delete=force-protected added explicitly. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-protected %s 2>&1 | FileCheck -check-prefixes=VGNDP %s %{implicit-check-nots} | ||
// RUN: %clang -### --target=x86_64-sie-ps5 -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-protected %s 2>&1 | FileCheck -check-prefixes=VGNDP %s %{implicit-check-nots} | ||
// VGNDP-DAG: "-fvisibility-global-new-delete=force-protected" | ||
|
||
/// -fvisibility-global-new-delete=force-default added explicitly. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-default %s 2>&1 | FileCheck -check-prefixes=VGNDD %s %{implicit-check-nots} | ||
// RUN: %clang -### --target=x86_64-sie-ps5 -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-default %s 2>&1 | FileCheck -check-prefixes=VGNDD %s %{implicit-check-nots} | ||
// VGNDD-DAG: "-fvisibility-global-new-delete=force-default" | ||
|
||
/// last specfied used: -fvisibility-global-new-delete-hidden. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete=force-default -fvisibility-global-new-delete=force-protected -fvisibility-global-new-delete-hidden %s 2>&1 | \ | ||
// RUN: FileCheck -check-prefixes=VGNDH,DEPRECATED %s %{implicit-check-nots} | ||
|
||
/// last specfied used: -fvisibility-global-new-delete=. | ||
// RUN: %clang -### --target=x86_64-unknown-unknown -c -emit-llvm \ | ||
// RUN: -fvisibility-global-new-delete-hidden -fvisibility-global-new-delete=force-default -fvisibility-global-new-delete=force-protected %s 2>&1 | \ | ||
// RUN: FileCheck -check-prefixes=VGNDP,DEPRECATED %s %{implicit-check-nots} |