Skip to content

Commit 27b7d64

Browse files
committed
[clang][cli] Streamline MarshallingInfoFlag description
This replaces the existing `MarshallingInfoFlag<...>, IsNegative` with simpler `MarshallingInfoNegativeFlag`. Reviewed By: dexonsmith Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84675
1 parent 3bf7d47 commit 27b7d64

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["1"]>;
696696
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>;
697697
def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group<Preprocessor_Group>,
698698
HelpText<"Disable linemarker output in -E mode">,
699-
MarshallingInfoFlag<"PreprocessorOutputOpts.ShowLineMarkers", "true">, IsNegative;
699+
MarshallingInfoNegativeFlag<"PreprocessorOutputOpts.ShowLineMarkers">;
700700
def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>,
701701
HelpText<"Emit metadata containing compiler name and version">;
702702
def Qn : Flag<["-"], "Qn">, Flags<[CC1Option]>,
@@ -1212,7 +1212,7 @@ def : Flag<["-"], "frecord-gcc-switches">, Alias<frecord_command_line>;
12121212
def : Flag<["-"], "fno-record-gcc-switches">, Alias<fno_record_command_line>;
12131213
def fcommon : Flag<["-"], "fcommon">, Group<f_Group>,
12141214
Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitialized global variables in a common block">,
1215-
MarshallingInfoFlag<"CodeGenOpts.NoCommon", "true">, IsNegative;
1215+
MarshallingInfoNegativeFlag<"CodeGenOpts.NoCommon">;
12161216
def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group<f_Group>;
12171217
defm complete_member_pointers : BoolOption<"complete-member-pointers",
12181218
"LangOpts->CompleteMemberPointers", DefaultsToFalse,
@@ -1856,7 +1856,7 @@ def fmodules_validate_once_per_build_session : Flag<["-"], "fmodules-validate-on
18561856
def fmodules_disable_diagnostic_validation : Flag<["-"], "fmodules-disable-diagnostic-validation">,
18571857
Group<i_Group>, Flags<[CC1Option]>,
18581858
HelpText<"Disable validation of the diagnostic options when loading the module">,
1859-
MarshallingInfoFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions", "true">, IsNegative;
1859+
MarshallingInfoNegativeFlag<"HeaderSearchOpts->ModulesValidateDiagnosticOptions">;
18601860
defm modules_validate_system_headers : BoolOption<"modules-validate-system-headers",
18611861
"HeaderSearchOpts->ModulesValidateSystemHeaders", DefaultsToFalse,
18621862
ChangedBy<PosFlag, [CC1Option], "Validate the system headers that a module depends on when loading the module">,
@@ -1944,7 +1944,7 @@ def fno_asm : Flag<["-"], "fno-asm">, Group<f_Group>;
19441944
def fno_asynchronous_unwind_tables : Flag<["-"], "fno-asynchronous-unwind-tables">, Group<f_Group>;
19451945
def fno_assume_sane_operator_new : Flag<["-"], "fno-assume-sane-operator-new">, Group<f_Group>,
19461946
HelpText<"Don't assume that C++'s global operator new can't alias any pointer">,
1947-
Flags<[CC1Option]>, MarshallingInfoFlag<"CodeGenOpts.AssumeSaneOperatorNew", "true">, IsNegative;
1947+
Flags<[CC1Option]>, MarshallingInfoNegativeFlag<"CodeGenOpts.AssumeSaneOperatorNew">;
19481948
def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>, Flags<[CC1Option, CoreOption]>,
19491949
HelpText<"Disable implicit builtin knowledge of functions">;
19501950
def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group<f_Group>, Flags<[CC1Option, CoreOption]>,
@@ -2022,15 +2022,15 @@ def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>;
20222022
def fno_temp_file : Flag<["-"], "fno-temp-file">, Group<f_Group>,
20232023
Flags<[CC1Option, CoreOption]>, HelpText<
20242024
"Directly create compilation output files. This may lead to incorrect incremental builds if the compiler crashes">,
2025-
MarshallingInfoFlag<"FrontendOpts.UseTemporary", "true">, IsNegative;
2025+
MarshallingInfoNegativeFlag<"FrontendOpts.UseTemporary">;
20262026
defm use_cxa_atexit : BoolFOption<"use-cxa-atexit",
20272027
"CodeGenOpts.CXAAtExit", DefaultsToTrue,
20282028
ChangedBy<NegFlag, [], "Don't use __cxa_atexit for calling destructors">,
20292029
ResetBy<PosFlag>>;
20302030
def fno_unit_at_a_time : Flag<["-"], "fno-unit-at-a-time">, Group<f_Group>;
20312031
def fno_unwind_tables : Flag<["-"], "fno-unwind-tables">, Group<f_Group>;
20322032
def fno_verbose_asm : Flag<["-"], "fno-verbose-asm">, Group<f_Group>, Flags<[CC1Option]>,
2033-
MarshallingInfoFlag<"CodeGenOpts.AsmVerbose", "true">, IsNegative;
2033+
MarshallingInfoNegativeFlag<"CodeGenOpts.AsmVerbose">;
20342034
def fno_working_directory : Flag<["-"], "fno-working-directory">, Group<f_Group>;
20352035
def fno_wrapv : Flag<["-"], "fno-wrapv">, Group<f_Group>;
20362036
def fobjc_arc : Flag<["-"], "fobjc-arc">, Group<f_Group>, Flags<[CC1Option]>,
@@ -3313,7 +3313,7 @@ def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group<pedantic_Group>;
33133313
def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">;
33143314
def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
33153315
HelpText<"Disable builtin #include directories">,
3316-
MarshallingInfoFlag<"HeaderSearchOpts->UseBuiltinIncludes", "true">, IsNegative;
3316+
MarshallingInfoNegativeFlag<"HeaderSearchOpts->UseBuiltinIncludes">;
33173317
def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for CUDA/HIP and"
33183318
" do not include the default CUDA/HIP wrapper headers">;
33193319
def : Flag<["-"], "nocudainc">, Alias<nogpuinc>;
@@ -3334,7 +3334,7 @@ def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>;
33343334
def nostdlibinc : Flag<["-"], "nostdlibinc">;
33353335
def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>,
33363336
HelpText<"Disable standard #include directories for the C++ standard library">,
3337-
MarshallingInfoFlag<"HeaderSearchOpts->UseStandardCXXIncludes", "true">, IsNegative;
3337+
MarshallingInfoNegativeFlag<"HeaderSearchOpts->UseStandardCXXIncludes">;
33383338
def nostdlib : Flag<["-"], "nostdlib">, Group<Link_Group>;
33393339
def nostdlibxx : Flag<["-"], "nostdlib++">;
33403340
def object : Flag<["-"], "object">;
@@ -3499,7 +3499,7 @@ def umbrella : Separate<["-"], "umbrella">;
34993499
def undefined : JoinedOrSeparate<["-"], "undefined">, Group<u_Group>;
35003500
def undef : Flag<["-"], "undef">, Group<u_Group>, Flags<[CC1Option]>,
35013501
HelpText<"undef all system defines">,
3502-
MarshallingInfoFlag<"PreprocessorOpts->UsePredefines", "true">, IsNegative;
3502+
MarshallingInfoNegativeFlag<"PreprocessorOpts->UsePredefines">;
35033503
def unexported__symbols__list : Separate<["-"], "unexported_symbols_list">;
35043504
def u : JoinedOrSeparate<["-"], "u">, Group<u_Group>;
35053505
def v : Flag<["-"], "v">, Flags<[CC1Option, CoreOption]>,
@@ -4370,7 +4370,7 @@ def fuse_ctor_homing: Flag<["-"], "fuse-ctor-homing">,
43704370

43714371
def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">,
43724372
HelpText<"Don't run the LLVM IR verifier pass">,
4373-
MarshallingInfoFlag<"CodeGenOpts.VerifyModule", "true">, IsNegative;
4373+
MarshallingInfoNegativeFlag<"CodeGenOpts.VerifyModule">;
43744374
def disable_llvm_passes : Flag<["-"], "disable-llvm-passes">,
43754375
HelpText<"Use together with -emit-llvm to get pristine LLVM IR from the "
43764376
"frontend by not running any LLVM passes at all">,
@@ -4432,7 +4432,7 @@ def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
44324432
MarshallingInfoFlag<"CodeGenOpts.RelaxedAliasing">;
44334433
def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">,
44344434
HelpText<"Turn off struct-path aware Type Based Alias Analysis">,
4435-
MarshallingInfoFlag<"CodeGenOpts.StructPathTBAA", "true">, IsNegative;
4435+
MarshallingInfoNegativeFlag<"CodeGenOpts.StructPathTBAA">;
44364436
def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">,
44374437
HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">;
44384438
def mdebug_pass : Separate<["-"], "mdebug-pass">,
@@ -4595,7 +4595,7 @@ def msign_return_address_key_EQ : Joined<["-"], "msign-return-address-key=">,
45954595
def mbranch_target_enforce : Flag<["-"], "mbranch-target-enforce">,
45964596
MarshallingInfoFlag<"LangOpts->BranchTargetEnforcement">;
45974597
def fno_dllexport_inlines : Flag<["-"], "fno-dllexport-inlines">,
4598-
MarshallingInfoFlag<"LangOpts->DllExportInlines", "true">, IsNegative;
4598+
MarshallingInfoNegativeFlag<"LangOpts->DllExportInlines">;
45994599
def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">,
46004600
HelpText<"Emit Windows Control Flow Guard tables only (no checks)">,
46014601
MarshallingInfoFlag<"CodeGenOpts.ControlFlowGuardNoChecks">;
@@ -4701,10 +4701,10 @@ def code_completion_patterns : Flag<["-"], "code-completion-patterns">,
47014701
MarshallingInfoFlag<"FrontendOpts.CodeCompleteOpts.IncludeCodePatterns">;
47024702
def no_code_completion_globals : Flag<["-"], "no-code-completion-globals">,
47034703
HelpText<"Do not include global declarations in code-completion results.">,
4704-
MarshallingInfoFlag<"FrontendOpts.CodeCompleteOpts.IncludeGlobals", "true">, IsNegative;
4704+
MarshallingInfoNegativeFlag<"FrontendOpts.CodeCompleteOpts.IncludeGlobals">;
47054705
def no_code_completion_ns_level_decls : Flag<["-"], "no-code-completion-ns-level-decls">,
47064706
HelpText<"Do not include declarations inside namespaces (incl. global namespace) in the code-completion results.">,
4707-
MarshallingInfoFlag<"FrontendOpts.CodeCompleteOpts.IncludeNamespaceLevelDecls", "true">, IsNegative;
4707+
MarshallingInfoNegativeFlag<"FrontendOpts.CodeCompleteOpts.IncludeNamespaceLevelDecls">;
47084708
def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments">,
47094709
HelpText<"Include brief documentation comments in code-completion results.">,
47104710
MarshallingInfoFlag<"FrontendOpts.CodeCompleteOpts.IncludeBriefComments">;
@@ -4734,10 +4734,10 @@ def ast_dump_filter : Separate<["-"], "ast-dump-filter">,
47344734
MarshallingInfoString<"FrontendOpts.ASTDumpFilter">;
47354735
def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">,
47364736
HelpText<"Do not automatically generate or update the global module index">,
4737-
MarshallingInfoFlag<"FrontendOpts.UseGlobalModuleIndex", "true">, IsNegative;
4737+
MarshallingInfoNegativeFlag<"FrontendOpts.UseGlobalModuleIndex">;
47384738
def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">,
47394739
HelpText<"Do not automatically import modules for error recovery">,
4740-
MarshallingInfoFlag<"LangOpts->ModulesErrorRecovery", "true">, IsNegative;
4740+
MarshallingInfoNegativeFlag<"LangOpts->ModulesErrorRecovery">;
47414741
def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">,
47424742
HelpText<"Use the current working directory as the home directory of "
47434743
"module maps specified by -fmodule-map-file=<FILE>">,
@@ -4780,7 +4780,7 @@ def fconcepts_ts : Flag<["-"], "fconcepts-ts">,
47804780
def fno_concept_satisfaction_caching : Flag<["-"],
47814781
"fno-concept-satisfaction-caching">,
47824782
HelpText<"Disable satisfaction caching for C++2a Concepts.">,
4783-
MarshallingInfoFlag<"LangOpts->ConceptSatisfactionCaching", "true">, IsNegative;
4783+
MarshallingInfoNegativeFlag<"LangOpts->ConceptSatisfactionCaching">;
47844784

47854785
defm recovery_ast : BoolOption<"recovery-ast",
47864786
"LangOpts->RecoveryAST", DefaultsToTrue,
@@ -4930,7 +4930,7 @@ def pch_through_hdrstop_use : Flag<["-"], "pch-through-hdrstop-use">,
49304930
HelpText<"When using a PCH, skip tokens until after a #pragma hdrstop.">;
49314931
def fno_pch_timestamp : Flag<["-"], "fno-pch-timestamp">,
49324932
HelpText<"Disable inclusion of timestamp in precompiled headers">,
4933-
MarshallingInfoFlag<"FrontendOpts.IncludeTimestamps", "true">, IsNegative;
4933+
MarshallingInfoNegativeFlag<"FrontendOpts.IncludeTimestamps">;
49344934
def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">,
49354935
HelpText<"This compilation is part of building a PCH with corresponding object file.">,
49364936
MarshallingInfoFlag<"LangOpts->BuildingPCHWithObjectFile">;
@@ -4983,7 +4983,7 @@ def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">,
49834983
MarshallingInfoString<"CodeGenOpts.ObjCDispatchMethod", "Legacy">, AutoNormalizeEnum;
49844984
def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">,
49854985
HelpText<"disable the default synthesis of Objective-C properties">,
4986-
MarshallingInfoFlag<"LangOpts->ObjCDefaultSynthProperties", "true">, IsNegative;
4986+
MarshallingInfoNegativeFlag<"LangOpts->ObjCDefaultSynthProperties">;
49874987
def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signature">,
49884988
HelpText<"enable extended encoding of block type signature">,
49894989
MarshallingInfoFlag<"LangOpts->EncodeExtendedBlockSig">;
@@ -5132,7 +5132,7 @@ def fobjc_gc : Flag<["-"], "fobjc-gc">, Group<f_Group>,
51325132

51335133
def nostdsysteminc : Flag<["-"], "nostdsysteminc">,
51345134
HelpText<"Disable standard system #include directories">,
5135-
MarshallingInfoFlag<"HeaderSearchOpts->UseStandardSystemIncludes", "true">, IsNegative;
5135+
MarshallingInfoNegativeFlag<"HeaderSearchOpts->UseStandardSystemIncludes">;
51365136
def fdisable_module_hash : Flag<["-"], "fdisable-module-hash">,
51375137
HelpText<"Disable the module hash">,
51385138
MarshallingInfoFlag<"HeaderSearchOpts->DisableModuleHash">;
@@ -5204,7 +5204,7 @@ def fcuda_allow_variadic_functions : Flag<["-"], "fcuda-allow-variadic-functions
52045204
MarshallingInfoFlag<"LangOpts->CUDAAllowVariadicFunctions">;
52055205
def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr">,
52065206
HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">,
5207-
MarshallingInfoFlag<"LangOpts->CUDAHostDeviceConstexpr", "true">, IsNegative;
5207+
MarshallingInfoNegativeFlag<"LangOpts->CUDAHostDeviceConstexpr">;
52085208

52095209
//===----------------------------------------------------------------------===//
52105210
// OpenMP Options

llvm/include/llvm/Option/OptParser.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class MarshallingInfoFlag<code keypath, code defaultvalue = "false">
173173
code Denormalizer = "denormalizeSimpleFlag";
174174
}
175175

176+
class MarshallingInfoNegativeFlag<code keypath, code defaultvalue = "true">
177+
: MarshallingInfo<keypath, defaultvalue> {
178+
code Normalizer = "normalizeSimpleNegativeFlag";
179+
code Denormalizer = "denormalizeSimpleFlag";
180+
}
181+
176182
class MarshallingInfoBitfieldFlag<code keypath, code value>
177183
: MarshallingInfoFlag<keypath, "0u"> {
178184
code Normalizer = "makeFlagToValueNormalizer("#value#")";
@@ -190,9 +196,6 @@ class MarshallingInfoBooleanFlag<code keypath, code defaultvalue, code value, co
190196

191197
// Mixins for additional marshalling attributes.
192198

193-
class IsNegative {
194-
code Normalizer = "normalizeSimpleNegativeFlag";
195-
}
196199
class AlwaysEmit { bit ShouldAlwaysEmit = true; }
197200
class Normalizer<code normalizer> { code Normalizer = normalizer; }
198201
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }

0 commit comments

Comments
 (0)