Skip to content

Commit dfb558b

Browse files
committed
[clang][cli] Port LangOpts to marshalling system, pt.2
Port some miscellaneous language options to the marshalling system for oautomatic command line parsing and generation. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D95347
1 parent 5133673 commit dfb558b

File tree

2 files changed

+67
-95
lines changed

2 files changed

+67
-95
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,13 @@ class MarshallingInfoVisibility<KeyPathAndMacro kpm, code default>
436436
// Key paths that are constant during parsing of options with the same key path prefix.
437437
defvar cplusplus = LangOpts<"CPlusPlus">;
438438
defvar cpp11 = LangOpts<"CPlusPlus11">;
439+
defvar cpp17 = LangOpts<"CPlusPlus17">;
439440
defvar cpp20 = LangOpts<"CPlusPlus20">;
440441
defvar c99 = LangOpts<"C99">;
441442
defvar c2x = LangOpts<"C2x">;
442443
defvar lang_std = LangOpts<"LangStd">;
443444
defvar open_cl = LangOpts<"OpenCL">;
445+
defvar cuda = LangOpts<"CUDA">;
444446
defvar render_script = LangOpts<"RenderScript">;
445447
defvar hip = LangOpts<"HIP">;
446448
defvar gnu_mode = LangOpts<"GNUMode">;
@@ -993,8 +995,10 @@ defm apple_pragma_pack : BoolFOption<"apple-pragma-pack",
993995
LangOpts<"ApplePragmaPack">, DefaultFalse,
994996
PosFlag<SetTrue, [CC1Option], "Enable Apple gcc-compatible #pragma pack handling">,
995997
NegFlag<SetFalse>>;
996-
def fxl_pragma_pack : Flag<["-"], "fxl-pragma-pack">, Group<f_Group>, Flags<[CC1Option]>,
997-
HelpText<"Enable IBM XL #pragma pack handling">;
998+
defm xl_pragma_pack : BoolFOption<"xl-pragma-pack",
999+
LangOpts<"XLPragmaPack">, DefaultFalse,
1000+
PosFlag<SetTrue, [CC1Option], "Enable IBM XL #pragma pack handling">,
1001+
NegFlag<SetFalse>>;
9981002
def shared_libsan : Flag<["-"], "shared-libsan">,
9991003
HelpText<"Dynamically link the sanitizer runtime">;
10001004
def static_libsan : Flag<["-"], "static-libsan">,
@@ -1271,8 +1275,6 @@ def fdiagnostics_show_template_tree : Flag<["-"], "fdiagnostics-show-template-tr
12711275
Group<f_Group>, Flags<[CC1Option]>,
12721276
HelpText<"Print a template comparison tree for differing templates">,
12731277
MarshallingInfoFlag<DiagnosticOpts<"ShowTemplateTree">>;
1274-
def fdeclspec : Flag<["-"], "fdeclspec">, Group<f_clang_Group>,
1275-
HelpText<"Allow __declspec as a keyword">, Flags<[CC1Option]>;
12761278
def fdiscard_value_names : Flag<["-"], "fdiscard-value-names">, Group<f_clang_Group>,
12771279
HelpText<"Discard value names in LLVM IR">, Flags<[NoXarchOption]>;
12781280
def fno_discard_value_names : Flag<["-"], "fno-discard-value-names">, Group<f_clang_Group>,
@@ -1344,14 +1346,21 @@ def fdenormal_fp_math_EQ : Joined<["-"], "fdenormal-fp-math=">, Group<f_Group>,
13441346
def ffp_model_EQ : Joined<["-"], "ffp-model=">, Group<f_Group>, Flags<[NoXarchOption]>,
13451347
HelpText<"Controls the semantics of floating-point calculations.">;
13461348
def ffp_exception_behavior_EQ : Joined<["-"], "ffp-exception-behavior=">, Group<f_Group>, Flags<[CC1Option]>,
1347-
HelpText<"Specifies the exception behavior of floating-point operations.">;
1349+
HelpText<"Specifies the exception behavior of floating-point operations.">,
1350+
Values<"ignore,maytrap,strict">, NormalizedValuesScope<"LangOptions">,
1351+
NormalizedValues<["FPE_Ignore", "FPE_MayTrap", "FPE_Strict"]>,
1352+
MarshallingInfoString<LangOpts<"FPExceptionMode">, "FPE_Ignore">, AutoNormalizeEnum;
13481353
defm fast_math : OptInFFlag<"fast-math", "Allow aggressive, lossy floating-point optimizations", "", "", [],
13491354
LangOpts<"FastMath">, [cl_fast_relaxed_math.KeyPath]>;
13501355
def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, Flags<[CC1Option]>,
13511356
HelpText<"Allow unsafe floating-point math optimizations which may decrease precision">,
13521357
MarshallingInfoFlag<LangOpts<"UnsafeFPMath">>,
13531358
ImpliedByAnyOf<[cl_unsafe_math_optimizations.KeyPath, ffast_math.KeyPath]>;
1354-
defm math_errno : OptInFFlag<"math-errno", "Require math functions to indicate errors by setting errno">;
1359+
defm math_errno : BoolFOption<"math-errno",
1360+
LangOpts<"MathErrno">, DefaultFalse,
1361+
PosFlag<SetTrue, [CC1Option], "Require math functions to indicate errors by setting errno">,
1362+
NegFlag<SetFalse>>,
1363+
ShouldParseIf<!strconcat("!", open_cl.KeyPath)>;
13551364
def fbracket_depth_EQ : Joined<["-"], "fbracket-depth=">, Group<f_Group>, Flags<[CoreOption]>;
13561365
def fsignaling_math : Flag<["-"], "fsignaling-math">, Group<f_Group>;
13571366
def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group<f_Group>;
@@ -1850,6 +1859,19 @@ def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group<f_Group>, Flags<
18501859
"PPTMK_FullGeneralityVirtualInheritance"]>,
18511860
MarshallingInfoString<LangOpts<"MSPointerToMemberRepresentationMethod">, "PPTMK_BestCase">,
18521861
AutoNormalizeEnum;
1862+
// __declspec is enabled by default for the PS4 by the driver, and also
1863+
// enabled for Microsoft Extensions or Borland Extensions, here.
1864+
//
1865+
// FIXME: __declspec is also currently enabled for CUDA, but isn't really a
1866+
// CUDA extension. However, it is required for supporting
1867+
// __clang_cuda_builtin_vars.h, which uses __declspec(property). Once that has
1868+
// been rewritten in terms of something more generic, remove the Opts.CUDA
1869+
// term here.
1870+
defm declspec : BoolOption<"f", "declspec",
1871+
LangOpts<"DeclSpecKeyword">, DefaultFalse,
1872+
PosFlag<SetTrue, [], "Allow", [fms_extensions.KeyPath, fborland_extensions.KeyPath, cuda.KeyPath]>,
1873+
NegFlag<SetFalse, [], "Disallow">,
1874+
BothFlags<[CC1Option], " __declspec as a keyword">>, Group<f_clang_Group>;
18531875
def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
18541876
Flags<[NoXarchOption, CC1Option]>, MetaVarName<"<directory>">,
18551877
HelpText<"Specify the module cache path">;
@@ -1976,7 +1998,6 @@ def fmudflapth : Flag<["-"], "fmudflapth">, Group<f_Group>;
19761998
def fmudflap : Flag<["-"], "fmudflap">, Group<f_Group>;
19771999
def fnested_functions : Flag<["-"], "fnested-functions">, Group<f_Group>;
19782000
def fnext_runtime : Flag<["-"], "fnext-runtime">, Group<f_Group>;
1979-
def fno_xl_pragma_pack : Flag<["-"], "fno-xl-pragma-pack">, Group<f_Group>;
19802001
def fno_asm : Flag<["-"], "fno-asm">, Group<f_Group>;
19812002
def fno_asynchronous_unwind_tables : Flag<["-"], "fno-asynchronous-unwind-tables">, Group<f_Group>;
19822003
def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group<f_Group>,
@@ -1997,8 +2018,6 @@ defm digraphs : BoolFOption<"digraphs",
19972018
PosFlag<SetTrue, [], "Enable alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:' (default)">,
19982019
NegFlag<SetFalse, [], "Disallow alternative token representations '<:', ':>', '<%', '%>', '%:', '%:%:'">,
19992020
BothFlags<[CC1Option]>>;
2000-
def fno_declspec : Flag<["-"], "fno-declspec">, Group<f_clang_Group>,
2001-
HelpText<"Disallow __declspec as a keyword">, Flags<[CC1Option]>;
20022021
def fno_eliminate_unused_debug_symbols : Flag<["-"], "fno-eliminate-unused-debug-symbols">, Group<f_Group>;
20032022
def fno_inline_functions : Flag<["-"], "fno-inline-functions">, Group<f_clang_Group>, Flags<[CC1Option]>;
20042023
def fno_inline : Flag<["-"], "fno-inline">, Group<f_clang_Group>, Flags<[CC1Option]>;
@@ -2084,10 +2103,10 @@ defm sized_deallocation : BoolFOption<"sized-deallocation",
20842103
LangOpts<"SizedDeallocation">, DefaultFalse,
20852104
PosFlag<SetTrue, [CC1Option], "Enable C++14 sized global deallocation functions">,
20862105
NegFlag<SetFalse>>;
2087-
def faligned_allocation : Flag<["-"], "faligned-allocation">, Flags<[CC1Option]>,
2088-
HelpText<"Enable C++17 aligned allocation functions">, Group<f_Group>;
2089-
def fno_aligned_allocation: Flag<["-"], "fno-aligned-allocation">,
2090-
Group<f_Group>, Flags<[CC1Option]>;
2106+
defm aligned_allocation : BoolFOption<"aligned-allocation",
2107+
LangOpts<"AlignedAllocation">, Default<cpp17.KeyPath>,
2108+
PosFlag<SetTrue, [], "Enable C++17 aligned allocation functions">,
2109+
NegFlag<SetFalse>, BothFlags<[CC1Option]>>;
20912110
def fnew_alignment_EQ : Joined<["-"], "fnew-alignment=">,
20922111
HelpText<"Specifies the largest alignment guaranteed by '::operator new(size_t)'">,
20932112
MetaVarName<"<align>">, Group<f_Group>, Flags<[CC1Option]>,
@@ -2243,10 +2262,10 @@ defm short_enums : BoolFOption<"short-enums",
22432262
PosFlag<SetTrue, [CC1Option], "Allocate to an enum type only as many bytes as it"
22442263
" needs for the declared range of possible values">,
22452264
NegFlag<SetFalse>>;
2246-
def fchar8__t : Flag<["-"], "fchar8_t">, Group<f_Group>, Flags<[CC1Option]>,
2247-
HelpText<"Enable C++ builtin type char8_t">;
2248-
def fno_char8__t : Flag<["-"], "fno-char8_t">, Group<f_Group>, Flags<[CC1Option]>,
2249-
HelpText<"Disable C++ builtin type char8_t">;
2265+
defm char8__t : BoolFOption<"char8_t",
2266+
LangOpts<"Char8">, Default<cpp20.KeyPath>,
2267+
PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">,
2268+
BothFlags<[CC1Option], " C++ builtin type char8_t">>;
22502269
def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
22512270
HelpText<"Force wchar_t to be a short unsigned int">;
22522271
def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,
@@ -2269,7 +2288,10 @@ defm spell_checking : BoolFOption<"spell-checking",
22692288
NegFlag<SetFalse, [CC1Option], "Disable spell-checking">, PosFlag<SetTrue>>;
22702289
def fspell_checking_limit_EQ : Joined<["-"], "fspell-checking-limit=">, Group<f_Group>;
22712290
def fsigned_bitfields : Flag<["-"], "fsigned-bitfields">, Group<f_Group>;
2272-
defm signed_char : OptOutFFlag<"signed-char", "char is signed", "char is unsigned">;
2291+
defm signed_char : BoolFOption<"signed-char",
2292+
LangOpts<"CharIsSigned">, DefaultTrue,
2293+
NegFlag<SetFalse, [CC1Option], "char is unsigned">, PosFlag<SetTrue, [], "char is signed">>,
2294+
ShouldParseIf<!strconcat("!", open_cl.KeyPath)>;
22732295
def fsplit_stack : Flag<["-"], "fsplit-stack">, Group<f_Group>;
22742296
def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group<f_Group>,
22752297
HelpText<"Enable stack protectors for all functions">;
@@ -2874,7 +2896,9 @@ def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group<m_Group>, Fl
28742896
HelpText<"Disable stack probes which are enabled by default">,
28752897
MarshallingInfoFlag<CodeGenOpts<"NoStackArgProbe">>;
28762898
def mthread_model : Separate<["-"], "mthread-model">, Group<m_Group>, Flags<[CC1Option]>,
2877-
HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">;
2899+
HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">,
2900+
NormalizedValues<["POSIX", "Single"]>, NormalizedValuesScope<"LangOptions::ThreadModelKind">,
2901+
MarshallingInfoString<LangOpts<"ThreadModel">, "POSIX">, AutoNormalizeEnum;
28782902
def meabi : Separate<["-"], "meabi">, Group<m_Group>, Flags<[CC1Option]>,
28792903
HelpText<"Set EABI type, e.g. 4, 5 or gnu (default depends on triple)">, Values<"default,4,5,gnu">,
28802904
MarshallingInfoString<TargetOpts<"EABIVersion">, "Default">,
@@ -2995,7 +3019,9 @@ def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">,
29953019
Group<m_aarch64_Features_Group>, Flags<[NoXarchOption,CC1Option]>,
29963020
HelpText<"Specify the size in bits of an SVE vector register. Defaults to the"
29973021
" vector length agnostic value of \"scalable\". (AArch64 only)">,
2998-
Values<"128,256,512,1024,2048,scalable">;
3022+
Values<"128,256,512,1024,2048,scalable">,
3023+
NormalizedValues<["128", "256", "512", "1024", "2048", "0"]>,
3024+
MarshallingInfoString<LangOpts<"ArmSveVectorBits">, "0">, AutoNormalizeEnum;
29993025

30003026
def msign_return_address_EQ : Joined<["-"], "msign-return-address=">,
30013027
Flags<[CC1Option]>, Group<m_Group>, Values<"none,all,non-leaf">,
@@ -3064,7 +3090,8 @@ def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>;
30643090
def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>;
30653091
def mefpu2 : Flag<["-"], "mefpu2">, Group<m_ppc_Features_Group>;
30663092
def mabi_EQ_vec_extabi : Flag<["-"], "mabi=vec-extabi">, Group<m_Group>, Flags<[CC1Option]>,
3067-
HelpText<"Enable the extended Altivec ABI on AIX (AIX only). Uses volatile and nonvolatile vector registers">;
3093+
HelpText<"Enable the extended Altivec ABI on AIX (AIX only). Uses volatile and nonvolatile vector registers">,
3094+
MarshallingInfoFlag<LangOpts<"EnableAIXExtendedAltivecABI">>;
30683095
def mabi_EQ_vec_default : Flag<["-"], "mabi=vec-default">, Group<m_Group>, Flags<[CC1Option]>,
30693096
HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only volatile vector registers.">;
30703097
def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>;
@@ -5007,11 +5034,13 @@ def print_stats : Flag<["-"], "print-stats">,
50075034
def stats_file : Joined<["-"], "stats-file=">,
50085035
HelpText<"Filename to write statistics to">,
50095036
MarshallingInfoString<FrontendOpts<"StatsFile">>;
5010-
def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
5011-
HelpText<"Dump record layout information">;
50125037
def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">,
50135038
HelpText<"Dump record layout information in a simple form used for testing">,
50145039
MarshallingInfoFlag<LangOpts<"DumpRecordLayoutsSimple">>;
5040+
def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">,
5041+
HelpText<"Dump record layout information">,
5042+
MarshallingInfoFlag<LangOpts<"DumpRecordLayouts">>,
5043+
ImpliedByAnyOf<[fdump_record_layouts_simple.KeyPath]>;
50155044
def fix_what_you_can : Flag<["-"], "fix-what-you-can">,
50165045
HelpText<"Apply fix-it advice even in the presence of unfixable errors">,
50175046
MarshallingInfoFlag<FrontendOpts<"FixWhatYouCan">>;
@@ -5045,7 +5074,9 @@ def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">,
50455074
MarshallingInfoFlag<LangOpts<"BuildingPCHWithObjectFile">>;
50465075

50475076
def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">,
5048-
HelpText<"Aligned allocation/deallocation functions are unavailable">;
5077+
HelpText<"Aligned allocation/deallocation functions are unavailable">,
5078+
MarshallingInfoFlag<LangOpts<"AlignedAllocationUnavailable">>,
5079+
ShouldParseIf<faligned_allocation.KeyPath>;
50495080

50505081
//===----------------------------------------------------------------------===//
50515082
// Language Options
@@ -5075,7 +5106,9 @@ def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
50755106
HelpText<"Name of the split dwarf debug info file to encode in the object file">,
50765107
MarshallingInfoString<CodeGenOpts<"SplitDwarfFile">>;
50775108
def fno_wchar : Flag<["-"], "fno-wchar">,
5078-
HelpText<"Disable C++ builtin type wchar_t">;
5109+
HelpText<"Disable C++ builtin type wchar_t">,
5110+
MarshallingInfoNegativeFlag<LangOpts<"WChar">, cplusplus.KeyPath>,
5111+
ShouldParseIf<cplusplus.KeyPath>;
50795112
def fconstant_string_class : Separate<["-"], "fconstant-string-class">,
50805113
MetaVarName<"<class name>">,
50815114
HelpText<"Specify the class to use for constant Objective-C string objects.">,
@@ -5100,7 +5133,8 @@ def function_alignment : Separate<["-"], "function-alignment">,
51005133
HelpText<"default alignment for functions">,
51015134
MarshallingInfoStringInt<LangOpts<"FunctionAlignment">>;
51025135
def pic_level : Separate<["-"], "pic-level">,
5103-
HelpText<"Value for __PIC__">;
5136+
HelpText<"Value for __PIC__">,
5137+
MarshallingInfoStringInt<LangOpts<"PICLevel">>;
51045138
def pic_is_pie : Flag<["-"], "pic-is-pie">,
51055139
HelpText<"File is for a position independent executable">,
51065140
MarshallingInfoFlag<LangOpts<"PIE">>;
@@ -5187,10 +5221,10 @@ def fdebugger_cast_result_to_id : Flag<["-"], "fdebugger-cast-result-to-id">,
51875221
def fdebugger_objc_literal : Flag<["-"], "fdebugger-objc-literal">,
51885222
HelpText<"Enable special debugger support for Objective-C subscripting and literals">,
51895223
MarshallingInfoFlag<LangOpts<"DebuggerObjCLiteral">>;
5190-
def fdeprecated_macro : Flag<["-"], "fdeprecated-macro">,
5191-
HelpText<"Defines the __DEPRECATED macro">;
5192-
def fno_deprecated_macro : Flag<["-"], "fno-deprecated-macro">,
5193-
HelpText<"Undefines the __DEPRECATED macro">;
5224+
defm deprecated_macro : BoolOption<"f", "deprecated-macro",
5225+
LangOpts<"Deprecated">, DefaultFalse,
5226+
PosFlag<SetTrue, [], "Defines">, NegFlag<SetFalse, [], "Undefines">,
5227+
BothFlags<[], " the __DEPRECATED macro">>;
51945228
def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-runtime">,
51955229
HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">;
51965230
// TODO: Enforce values valid for MSVtorDispMode.

0 commit comments

Comments
 (0)