diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2221,9 +2221,10 @@ def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group; def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group, Flags<[CC1Option]>; def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group; -def fno_operator_names : Flag<["-"], "fno-operator-names">, Group, - HelpText<"Do not treat C++ operator name keywords as synonyms for operators">, - Flags<[CC1Option]>, MarshallingInfoNegativeFlag, cplusplus.KeyPath>; +defm operator_names : BoolFOption<"operator-names", + LangOpts<"CXXOperatorNames">, Default, + NegFlag, + PosFlag>; def fdiagnostics_absolute_paths : Flag<["-"], "fdiagnostics-absolute-paths">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">, MarshallingInfoFlag>; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5654,11 +5654,14 @@ Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ); + if (Args.hasFlag(options::OPT_fno_operator_names, + options::OPT_foperator_names, false)) + CmdArgs.push_back("-fno-operator-names"); + // Forward -f (flag) options which we can pass directly. Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls); Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs); - Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); Args.AddLastArg(CmdArgs, options::OPT_femulated_tls, options::OPT_fno_emulated_tls); diff --git a/clang/test/Driver/cxx-operator-names.cpp b/clang/test/Driver/cxx-operator-names.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Driver/cxx-operator-names.cpp @@ -0,0 +1,7 @@ +// RUN: %clang -### -S -foperator-names -fno-operator-names %s 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-1 %s +// CHECK-1: "-fno-operator-names" + +// RUN: %clang -### -S -fno-operator-names -foperator-names %s 2>&1 | \ +// RUN: FileCheck -check-prefix=CHECK-2 %s +// CHECK-2-NOT: "-fno-operator-names"