Skip to content

Commit e20d466

Browse files
committed
[clang][cli] Port more options to new parsing system
This patch adds marshalling information to more options. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D94957
1 parent 4ab704d commit e20d466

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,10 +3071,10 @@ def mwavefrontsize64 : Flag<["-"], "mwavefrontsize64">, Group<m_Group>,
30713071
def mno_wavefrontsize64 : Flag<["-"], "mno-wavefrontsize64">, Group<m_Group>,
30723072
HelpText<"Specify wavefront size 32 mode (AMDGPU only)">;
30733073

3074-
def munsafe_fp_atomics : Flag<["-"], "munsafe-fp-atomics">, Group<m_Group>,
3075-
HelpText<"Enable unsafe floating point atomic instructions (AMDGPU only)">,
3076-
Flags<[CC1Option]>;
3077-
def mno_unsafe_fp_atomics : Flag<["-"], "mno-unsafe-fp-atomics">, Group<m_Group>;
3074+
defm unsafe_fp_atomics : BoolCC1Option<"unsafe-fp-atomics",
3075+
TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultsToFalse,
3076+
ChangedBy<PosFlag, [], "Enable unsafe floating point atomic instructions (AMDGPU only)">,
3077+
ResetBy<NegFlag>, BothFlags<[]>, "m">, Group<m_Group>;
30783078

30793079
def faltivec : Flag<["-"], "faltivec">, Group<f_Group>, Flags<[NoXarchOption]>;
30803080
def fno_altivec : Flag<["-"], "fno-altivec">, Group<f_Group>, Flags<[NoXarchOption]>;
@@ -4378,7 +4378,10 @@ def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-optio
43784378
MarshallingInfoFlag<AnalyzerOpts<"ShowCheckerOptionDeveloperList">>;
43794379

43804380
def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">,
4381-
HelpText<"Don't emit errors on invalid analyzer-config inputs">;
4381+
HelpText<"Don't emit errors on invalid analyzer-config inputs">,
4382+
Values<"true,false">, NormalizedValues<[[{false}], [{true}]]>,
4383+
MarshallingInfoString<AnalyzerOpts<"ShouldEmitErrorsOnInvalidConfigValue">, [{true}]>,
4384+
AutoNormalizeEnum;
43824385

43834386
def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compatibility-mode=">,
43844387
Alias<analyzer_config_compatibility_mode>;
@@ -4842,7 +4845,8 @@ def plugin_arg : JoinedAndSeparate<["-"], "plugin-arg-">,
48424845
MetaVarName<"<name> <arg>">,
48434846
HelpText<"Pass <arg> to plugin <name>">;
48444847
def add_plugin : Separate<["-"], "add-plugin">, MetaVarName<"<name>">,
4845-
HelpText<"Use the named plugin action in addition to the default action">;
4848+
HelpText<"Use the named plugin action in addition to the default action">,
4849+
MarshallingInfoStringVector<FrontendOpts<"AddPluginActions">>;
48464850
def ast_dump_filter : Separate<["-"], "ast-dump-filter">,
48474851
MetaVarName<"<dump_filter>">,
48484852
HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration"
@@ -5118,10 +5122,13 @@ def fhalf_no_semantic_interposition : Flag<["-"], "fhalf-no-semantic-interpositi
51185122
def fno_validate_pch : Flag<["-"], "fno-validate-pch">,
51195123
HelpText<"Disable validation of precompiled headers">,
51205124
MarshallingInfoFlag<PreprocessorOpts<"DisablePCHValidation">>;
5121-
def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">,
5122-
HelpText<"Accept a PCH file that was created with compiler errors">;
51235125
def fallow_pcm_with_errors : Flag<["-"], "fallow-pcm-with-compiler-errors">,
5124-
HelpText<"Accept a PCM file that was created with compiler errors">;
5126+
HelpText<"Accept a PCM file that was created with compiler errors">,
5127+
MarshallingInfoFlag<FrontendOpts<"AllowPCMWithCompilerErrors">>;
5128+
def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">,
5129+
HelpText<"Accept a PCH file that was created with compiler errors">,
5130+
MarshallingInfoFlag<PreprocessorOpts<"AllowPCHWithCompilerErrors">>,
5131+
ImpliedByAnyOf<[fallow_pcm_with_errors]>;
51255132
def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">,
51265133
HelpText<"Dump declarations that are deserialized from PCH, for testing">,
51275134
MarshallingInfoFlag<PreprocessorOpts<"DumpDeserializedPCHDecls">>;

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,6 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
634634
}
635635
}
636636

637-
Opts.ShouldEmitErrorsOnInvalidConfigValue =
638-
/* negated */!llvm::StringSwitch<bool>(
639-
Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
640-
.Case("true", true)
641-
.Case("false", false)
642-
.Default(false);
643-
644637
Opts.CheckersAndPackages.clear();
645638
for (const Arg *A :
646639
Args.filtered(OPT_analyzer_checker, OPT_analyzer_disable_checker)) {
@@ -828,10 +821,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
828821
<< "a filename";
829822
}
830823

831-
static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
832-
Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
833-
}
834-
835824
/// Create a new Regex instance out of the string value in \p RpassArg.
836825
/// It returns a pointer to the newly generated Regex instance.
837826
static std::shared_ptr<llvm::Regex>
@@ -1645,7 +1634,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
16451634
Opts.ProgramAction = frontend::PluginAction;
16461635
Opts.ActionName = A->getValue();
16471636
}
1648-
Opts.AddPluginActions = Args.getAllArgValues(OPT_add_plugin);
16491637
for (const auto *AA : Args.filtered(OPT_plugin_arg))
16501638
Opts.PluginArgs[AA->getValue(0)].emplace_back(AA->getValue(1));
16511639

@@ -1686,7 +1674,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
16861674
if (Val.find('=') == StringRef::npos)
16871675
Opts.ModuleFiles.push_back(std::string(Val));
16881676
}
1689-
Opts.AllowPCMWithCompilerErrors = Args.hasArg(OPT_fallow_pcm_with_errors);
16901677

16911678
if (Opts.ProgramAction != frontend::GenerateModule && Opts.IsSystemModule)
16921679
Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
@@ -2845,8 +2832,6 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
28452832
frontend::ActionKind Action) {
28462833
Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
28472834
Args.hasArg(OPT_pch_through_hdrstop_use);
2848-
Opts.AllowPCHWithCompilerErrors =
2849-
Args.hasArg(OPT_fallow_pch_with_errors, OPT_fallow_pcm_with_errors);
28502835

28512836
for (const auto *A : Args.filtered(OPT_error_on_deserialized_pch_decl))
28522837
Opts.DeserializedPCHDeclsToErrorOn.insert(A->getValue());
@@ -2930,9 +2915,6 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
29302915

29312916
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args,
29322917
DiagnosticsEngine &Diags) {
2933-
Opts.AllowAMDGPUUnsafeFPAtomics =
2934-
Args.hasFlag(options::OPT_munsafe_fp_atomics,
2935-
options::OPT_mno_unsafe_fp_atomics, false);
29362918
if (Arg *A = Args.getLastArg(options::OPT_target_sdk_version_EQ)) {
29372919
llvm::VersionTuple Version;
29382920
if (Version.tryParse(A->getValue()))
@@ -2987,7 +2969,6 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
29872969
}
29882970
Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
29892971
/*DefaultDiagColor=*/false);
2990-
ParseCommentArgs(LangOpts.CommentOpts, Args);
29912972
// FIXME: We shouldn't have to pass the DashX option around here
29922973
InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags,
29932974
LangOpts.IsHeaderFile);

0 commit comments

Comments
 (0)