Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1714,6 +1714,9 @@ def fvisibility_inlines_hidden : Flag<["-"], "fvisibility-inlines-hidden">, Group, HelpText<"Give inline C++ member functions hidden visibility by default">, Flags<[CC1Option]>; +def fno_visibility_inlines_hidden : Flag<["-"], "fno-visibility-inlines-hidden">, Group, + HelpText<"Do not give inline C++ member functions hidden visibility by default">, + Flags<[CC1Option]>; def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, Group, HelpText<"Give global types 'default' visibility and global functions and " "variables 'hidden' visibility by default">; Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -4167,7 +4167,8 @@ } } - Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden); + Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden, + options::OPT_fno_visibility_inlines_hidden); Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ); Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2310,8 +2310,11 @@ Opts.setTypeVisibilityMode(Opts.getValueVisibilityMode()); } - if (Args.hasArg(OPT_fvisibility_inlines_hidden)) + if (Args.hasFlag(OPT_fvisibility_inlines_hidden, + OPT_fno_visibility_inlines_hidden, + false)) { Opts.InlineVisibilityHidden = 1; + } if (Args.hasArg(OPT_ftrapv)) { Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping); Index: test/Driver/visibility-inlines-hidden.cpp =================================================================== --- /dev/null +++ test/Driver/visibility-inlines-hidden.cpp @@ -0,0 +1,19 @@ +// RUN: %clang -### -S -fvisibility-inlines-hidden %s 2> %t.log +// RUN: FileCheck -check-prefix=CHECK-1 %s < %t.log +// CHECK-1: "-fvisibility-inlines-hidden" +// CHECK-1-NOT: "-fno-visibility-inlines-hidden" + +// RUN: %clang -### -S -fno-visibility-inlines-hidden %s 2> %t.log +// RUN: FileCheck -check-prefix=CHECK-2 %s < %t.log +// CHECK-2: "-fno-visibility-inlines-hidden" +// CHECK-2-NOT: "-fvisibility-inlines-hidden" + +// RUN: %clang -### -S -fvisibility-inlines-hidden -fno-visibility-inlines-hidden %s 2> %t.log +// RUN: FileCheck -check-prefix=CHECK-3 %s < %t.log +// CHECK-3: "-fno-visibility-inlines-hidden" +// CHECK-3-NOT: "-fvisibility-inlines-hidden" + +// RUN: %clang -### -S -fno-visibility-inlines-hidden -fvisibility-inlines-hidden %s 2> %t.log +// RUN: FileCheck -check-prefix=CHECK-4 %s < %t.log +// CHECK-4: "-fvisibility-inlines-hidden" +// CHECK-4-NOT: "-fno-visibility-inlines-hidden"