From ac47588bc4ff5927a01ed6fcd269ce86aba52a7c Mon Sep 17 00:00:00 2001 From: Shengchen Kan Date: Wed, 3 Jun 2020 14:54:56 +0800 Subject: [PATCH] [Driver] Add negative option for -fkeep-static-consts --- clang/include/clang/Driver/Options.td | 3 +-- clang/lib/Driver/ToolChains/Clang.cpp | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b807feb..05a9121 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -988,8 +988,7 @@ def fsignaling_math : Flag<["-"], "fsignaling-math">, Group; def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group; defm jump_tables : OptOutFFlag<"jump-tables", "Use", "Do not use", " jump tables for lowering switches">; defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type">; -def fkeep_static_consts : Flag<["-"], "fkeep-static-consts">, Group, Flags<[CC1Option]>, - HelpText<"Keep static const variables even if unused">; +defm keep_static_consts : OptInFFlag<"keep-static-consts", "Keep", "Don't keep", " static const variables if unused", [DriverOption]>; def ffixed_point : Flag<["-"], "ffixed-point">, Group, Flags<[CC1Option]>, HelpText<"Enable fixed point types">; def fno_fixed_point : Flag<["-"], "fno-fixed-point">, Group, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index d86fe49..b200487 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5175,7 +5175,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names); Args.AddLastArg(CmdArgs, options::OPT_femulated_tls, options::OPT_fno_emulated_tls); - Args.AddLastArg(CmdArgs, options::OPT_fkeep_static_consts); // AltiVec-like language extensions aren't relevant for assembling. if (!isa(JA) || Output.getType() != types::TY_PP_Asm) @@ -6118,6 +6117,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fforce-enable-int128"); } + if (Args.hasFlag(options::OPT_fkeep_static_consts, + options::OPT_fno_keep_static_consts, false)) + CmdArgs.push_back("-fkeep-static-consts"); + if (Args.hasFlag(options::OPT_fcomplete_member_pointers, options::OPT_fno_complete_member_pointers, false)) CmdArgs.push_back("-fcomplete-member-pointers"); -- 2.7.4