Skip to content

Commit 1491282

Browse files
committed
[clang] Change cc1 -fvisibility's canonical spelling to -fvisibility=
1 parent dc549bf commit 1491282

16 files changed

+45
-54
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,8 +2952,9 @@ def fvisibility_externs_nodllstorageclass_EQ : Joined<["-"], "fvisibility-extern
29522952
HelpText<"The visibility for external declarations without an explicit DLL dllstorageclass [-fvisibility-from-dllstorageclass]">,
29532953
MarshallingInfoVisibility<LangOpts<"ExternDeclNoDLLStorageClassVisibility">, "HiddenVisibility">,
29542954
ShouldParseIf<fvisibility_from_dllstorageclass.KeyPath>;
2955-
def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group<f_Group>,
2956-
HelpText<"Set the default symbol visibility for all global definitions">, Values<"default,protected,internal,hidden">;
2955+
def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group<f_Group>, Flags<[CC1Option]>,
2956+
HelpText<"Set the default symbol visibility for all global definitions">,
2957+
MarshallingInfoVisibility<LangOpts<"ValueVisibilityMode">, "DefaultVisibility">;
29572958
defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden",
29582959
LangOpts<"InlineVisibilityHidden">, DefaultFalse,
29592960
PosFlag<SetTrue, [CC1Option], "Give inline C++ member functions hidden visibility by default">,
@@ -6065,12 +6066,10 @@ def stack_protector : Separate<["-"], "stack-protector">,
60656066
def stack_protector_buffer_size : Separate<["-"], "stack-protector-buffer-size">,
60666067
HelpText<"Lower bound for a buffer to be considered for stack protection">,
60676068
MarshallingInfoInt<CodeGenOpts<"SSPBufferSize">, "8">;
6068-
def fvisibility : Separate<["-"], "fvisibility">,
6069-
HelpText<"Default type and symbol visibility">,
6070-
MarshallingInfoVisibility<LangOpts<"ValueVisibilityMode">, "DefaultVisibility">;
6071-
def ftype_visibility : Separate<["-"], "ftype-visibility">,
6069+
def : Separate<["-"], "fvisibility">, Alias<fvisibility_EQ>;
6070+
def ftype_visibility : Joined<["-"], "ftype-visibility=">,
60726071
HelpText<"Default type visibility">,
6073-
MarshallingInfoVisibility<LangOpts<"TypeVisibilityMode">, fvisibility.KeyPath>;
6072+
MarshallingInfoVisibility<LangOpts<"TypeVisibilityMode">, fvisibility_EQ.KeyPath>;
60746073
def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-to-externs">,
60756074
HelpText<"Apply global symbol visibility to external declarations without an explicit visibility">,
60766075
MarshallingInfoFlag<LangOpts<"SetVisibilityForExternDecls">>;

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,7 @@ void AMDGPUToolChain::addClangTargetOptions(
707707
// supported for the foreseeable future.
708708
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
709709
options::OPT_fvisibility_ms_compat)) {
710-
CC1Args.push_back("-fvisibility");
711-
CC1Args.push_back("hidden");
710+
CC1Args.push_back("-fvisibility=hidden");
712711
CC1Args.push_back("-fapply-global-visibility-to-externs");
713712
}
714713
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,10 +2386,8 @@ void Clang::AddWebAssemblyTargetArgs(const ArgList &Args,
23862386
ArgStringList &CmdArgs) const {
23872387
// Default to "hidden" visibility.
23882388
if (!Args.hasArg(options::OPT_fvisibility_EQ,
2389-
options::OPT_fvisibility_ms_compat)) {
2390-
CmdArgs.push_back("-fvisibility");
2391-
CmdArgs.push_back("hidden");
2392-
}
2389+
options::OPT_fvisibility_ms_compat))
2390+
CmdArgs.push_back("-fvisibility=hidden");
23932391
}
23942392

23952393
void Clang::AddVETargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
@@ -5982,21 +5980,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
59825980
if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ,
59835981
options::OPT_fvisibility_ms_compat)) {
59845982
if (A->getOption().matches(options::OPT_fvisibility_EQ)) {
5985-
CmdArgs.push_back("-fvisibility");
5986-
CmdArgs.push_back(A->getValue());
5983+
A->render(Args, CmdArgs);
59875984
} else {
59885985
assert(A->getOption().matches(options::OPT_fvisibility_ms_compat));
5989-
CmdArgs.push_back("-fvisibility");
5990-
CmdArgs.push_back("hidden");
5991-
CmdArgs.push_back("-ftype-visibility");
5992-
CmdArgs.push_back("default");
5986+
CmdArgs.push_back("-fvisibility=hidden");
5987+
CmdArgs.push_back("-ftype-visibility=default");
59935988
}
59945989
} else if (IsOpenMPDevice) {
59955990
// When compiling for the OpenMP device we want protected visibility by
59965991
// default. This prevents the device from accidentally preempting code on
59975992
// the host, makes the system more robust, and improves performance.
5998-
CmdArgs.push_back("-fvisibility");
5999-
CmdArgs.push_back("protected");
5993+
CmdArgs.push_back("-fvisibility=protected");
60005994
}
60015995

60025996
if (!RawTriple.isPS4())

clang/lib/Driver/ToolChains/HIPAMD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void HIPAMDToolChain::addClangTargetOptions(
242242
// supported for the foreseeable future.
243243
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
244244
options::OPT_fvisibility_ms_compat)) {
245-
CC1Args.append({"-fvisibility", "hidden"});
245+
CC1Args.append({"-fvisibility=hidden"});
246246
CC1Args.push_back("-fapply-global-visibility-to-externs");
247247
}
248248

clang/lib/Driver/ToolChains/HIPSPV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void HIPSPVToolChain::addClangTargetOptions(
152152
if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
153153
options::OPT_fvisibility_ms_compat))
154154
CC1Args.append(
155-
{"-fvisibility", "hidden", "-fapply-global-visibility-to-externs"});
155+
{"-fvisibility=hidden", "-fapply-global-visibility-to-externs"});
156156

157157
llvm::for_each(getHIPDeviceLibs(DriverArgs),
158158
[&](const BitCodeLibraryInfo &BCFile) {

clang/test/CodeGenCXX/visibility-ms-compat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -ftype-visibility default -emit-llvm -o %t
1+
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility=hidden -ftype-visibility=default -emit-llvm -o %t
22
// RUN: FileCheck %s < %t
33
// RUN: FileCheck -check-prefix=CHECK-GLOBAL %s < %t
44

clang/test/Driver/amdgpu-visibility.cl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
// RUN: %clang -### -target amdgcn-mesa-mesa3d -x cl -c -emit-llvm -fvisibility=protected %s 2>&1 | FileCheck -check-prefix=OVERRIDE-PROTECTED %s
77
// RUN: %clang -### -target amdgcn-mesa-mesa3d -x cl -c -emit-llvm -fvisibility-ms-compat %s 2>&1 | FileCheck -check-prefix=OVERRIDE-MS %s
88

9-
// DEFAULT-DAG: "-fvisibility" "hidden"
9+
// DEFAULT-DAG: "-fvisibility=hidden"
1010
// DEFAULT-DAG: "-fapply-global-visibility-to-externs"
1111

1212
// OVERRIDE-PROTECTED-NOT: "-fapply-global-visibility-to-externs"
13-
// OVERRIDE-PROTECTED: "-fvisibility" "protected"
13+
// OVERRIDE-PROTECTED: "-fvisibility=protected"
1414
// OVERRIDE-PROTECTED-NOT: "-fapply-global-visibility-to-externs"
1515

1616
// OVERRIDE-MS-NOT: "-fapply-global-visibility-to-externs"
17-
// OVERRIDE-MS-DAG: "-fvisibility" "hidden"
18-
// OVERRIDE-MS-DAG: "-ftype-visibility" "default"
17+
// OVERRIDE-MS-DAG: "-fvisibility=hidden"
18+
// OVERRIDE-MS-DAG: "-ftype-visibility=default"
1919
// OVERRIDE-MS-NOT: "-fapply-global-visibility-to-externs"

clang/test/Driver/clang-translation.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
// I386: "-mframe-pointer=all"
77
// I386: "-funwind-tables=2"
88
// I386: "-Os"
9-
// I386: "-fvisibility"
10-
// I386: "hidden"
9+
// I386: "-fvisibility=hidden"
1110
// I386: "-o"
1211
// I386: clang-translation
1312

clang/test/Driver/hip-rdc-device-only.hip

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
// EMITBC-SAME: "-emit-llvm-bc"
6060
// EMITLL-SAME: "-emit-llvm"
6161
// COMMON-SAME: {{.*}} "-main-file-name" "a.cu"
62-
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
62+
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
6363
// COMMON-SAME: "-fapply-global-visibility-to-externs"
6464
// COMMON-SAME: "-target-cpu" "gfx803"
6565
// COMMON-SAME: "-fgpu-rdc"
@@ -72,7 +72,7 @@
7272
// EMITBC-SAME: "-emit-llvm-bc"
7373
// EMITLL-SAME: "-emit-llvm"
7474
// COMMON-SAME: {{.*}} "-main-file-name" "a.cu"
75-
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
75+
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
7676
// COMMON-SAME: "-fapply-global-visibility-to-externs"
7777
// COMMON-SAME: "-target-cpu" "gfx900"
7878
// COMMON-SAME: "-fgpu-rdc"
@@ -89,7 +89,7 @@
8989
// EMITBC-SAME: "-emit-llvm-bc"
9090
// EMITLL-SAME: "-emit-llvm"
9191
// COMMON-SAME: {{.*}} "-main-file-name" "b.hip"
92-
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
92+
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
9393
// COMMON-SAME: "-fapply-global-visibility-to-externs"
9494
// COMMON-SAME: "-target-cpu" "gfx803"
9595
// COMMON-SAME: "-fgpu-rdc"
@@ -102,7 +102,7 @@
102102
// EMITBC-SAME: "-emit-llvm-bc"
103103
// EMITLL-SAME: "-emit-llvm"
104104
// COMMON-SAME: {{.*}} "-main-file-name" "b.hip"
105-
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
105+
// COMMON-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
106106
// COMMON-SAME: "-fapply-global-visibility-to-externs"
107107
// COMMON-SAME: "-target-cpu" "gfx900"
108108
// COMMON-SAME: "-fgpu-rdc"

clang/test/Driver/hip-toolchain-no-rdc.hip

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
// CHECK-SAME: "-emit-obj"
4949
// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
5050
// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
51-
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
51+
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
5252
// CHECK-SAME: "-fapply-global-visibility-to-externs"
5353
// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
5454
// CHECK-SAME: "-target-cpu" "gfx803"
@@ -71,7 +71,7 @@
7171
// CHECK-SAME: "-emit-obj"
7272
// CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
7373
// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
74-
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
74+
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
7575
// CHECK-SAME: "-fapply-global-visibility-to-externs"
7676
// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
7777
// CHECK-SAME: "-target-cpu" "gfx900"
@@ -111,7 +111,7 @@
111111
// CHECK-SAME: "-emit-obj"
112112
// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
113113
// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
114-
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
114+
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
115115
// CHECK-SAME: "-fapply-global-visibility-to-externs"
116116
// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
117117
// CHECK-SAME: "-target-cpu" "gfx803"
@@ -134,7 +134,7 @@
134134
// CHECK-SAME: "-emit-obj"
135135
// CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
136136
// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
137-
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
137+
// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility=hidden"
138138
// CHECK-SAME: "-fapply-global-visibility-to-externs"
139139
// CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
140140
// CHECK-SAME: "-target-cpu" "gfx900"

0 commit comments

Comments
 (0)