aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2020-12-08 18:15:21 +0100
committerJan Svoboda <jan_svoboda@apple.com>2020-12-12 10:53:28 +0100
commit6baa9769ed573741290fb186d02df7cf676fc8de (patch)
tree8ac0aff5cddf48870d87965c7e81b0c5fa0cfcb1 /clang/lib/Frontend/CompilerInvocation.cpp
parent10f40576f7b482dc55b9a0ba780c294c4e45817c (diff)
downloadllvm-6baa9769ed573741290fb186d02df7cf676fc8de.zip
llvm-6baa9769ed573741290fb186d02df7cf676fc8de.tar.gz
llvm-6baa9769ed573741290fb186d02df7cf676fc8de.tar.bz2
[clang][cli] Add flexible TableGen multiclass for boolean options
This introduces more flexible multiclass for declaring two flags controlling the same boolean keypath. Compared to existing Opt{In,Out}FFlag multiclasses, the new syntax makes it easier to read option declarations and reason about the keypath. This also makes specifying common properties of both flags possible. I'm open to suggestions on the class names. Not 100% sure the benefits are worth the added complexity. Depends on D92774. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D92775
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index be5a644..011da30 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -185,20 +185,24 @@ static FlagToValueNormalizer<T> makeFlagToValueNormalizer(T Value) {
return FlagToValueNormalizer<T>{std::move(Value)};
}
-static auto makeBooleanFlagNormalizer(OptSpecifier NegOpt) {
- return [NegOpt](OptSpecifier PosOpt, unsigned, const ArgList &Args,
- DiagnosticsEngine &) -> Optional<bool> {
- if (const Arg *A = Args.getLastArg(PosOpt, NegOpt))
- return A->getOption().matches(PosOpt);
+static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
+ OptSpecifier OtherOpt) {
+ return [Value, OtherValue, OtherOpt](OptSpecifier Opt, unsigned,
+ const ArgList &Args,
+ DiagnosticsEngine &) -> Optional<bool> {
+ if (const Arg *A = Args.getLastArg(Opt, OtherOpt)) {
+ return A->getOption().matches(Opt) ? Value : OtherValue;
+ }
return None;
};
}
-static auto makeBooleanFlagDenormalizer(const char *NegSpelling) {
- return [NegSpelling](
- SmallVectorImpl<const char *> &Args, const char *PosSpelling,
- CompilerInvocation::StringAllocator, unsigned, unsigned Value) {
- Args.push_back(Value ? PosSpelling : NegSpelling);
+static auto makeBooleanOptionDenormalizer(bool Value,
+ const char *OtherSpelling) {
+ return [Value, OtherSpelling](
+ SmallVectorImpl<const char *> &Args, const char *Spelling,
+ CompilerInvocation::StringAllocator, unsigned, bool KeyPath) {
+ Args.push_back(KeyPath == Value ? Spelling : OtherSpelling);
};
}
@@ -906,7 +910,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
Opts.DebugColumnInfo = !Args.hasArg(OPT_gno_column_info);
Opts.EmitCodeView = Args.hasArg(OPT_gcodeview);
- Opts.CodeViewGHash = Args.hasArg(OPT_gcodeview_ghash);
Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);
Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
Opts.VirtualFunctionElimination =
@@ -967,7 +970,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
std::string(Args.getLastArgValue(OPT_record_command_line));
Opts.MergeAllConstants = Args.hasArg(OPT_fmerge_all_constants);
Opts.NoCommon = !Args.hasArg(OPT_fcommon);
- Opts.NoInlineLineTables = Args.hasArg(OPT_gno_inline_line_tables);
Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Opts.OptimizeSize = getOptimizationLevelSize(Args);
Opts.SimplifyLibCalls = !(Args.hasArg(OPT_fno_builtin) ||
@@ -980,7 +982,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.RerollLoops = Args.hasArg(OPT_freroll_loops);
Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
- Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
Opts.SampleProfileFile =
std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ));
Opts.DebugInfoForProfiling = Args.hasFlag(