[PATCH] D84185: Better defaults for MarshallingInfoString
Daniel Grumberg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 10:01:18 PDT 2020
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.
Depends on D84018 <https://reviews.llvm.org/D84018>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84185
Files:
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
Index: llvm/include/llvm/Option/OptParser.td
===================================================================
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -151,8 +151,11 @@
code DefaultValue = defaultvalue;
}
-class MarshallingInfoString<code keypath, code defaultvalue>
- : MarshallingInfo<keypath, defaultvalue> {}
+class MarshallingInfoString<code keypath, code defaultvalue="std::string()">
+ : MarshallingInfo<keypath, defaultvalue> {
+ code Normalizer = "normalizeString";
+ code Denormalizer = "denormalizeString";
+}
class MarshallingInfoFlag<code keypath, code defaultvalue>
: MarshallingInfo<keypath, defaultvalue> {
@@ -185,7 +188,6 @@
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }
class NormalizedValuesScope<code scope> { code NormalizedValuesScope = scope; }
class NormalizedValues<list<code> definitions> { list<code> NormalizedValues = definitions; }
-class DenormalizeString { code Denormalizer = "denormalizeString"; }
class AutoNormalizeEnum {
code Normalizer = "normalizeSimpleEnum";
code Denormalizer = "denormalizeSimpleEnum";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -242,6 +242,15 @@
"the tablegen option description");
}
+static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
+ const ArgList &Args,
+ DiagnosticsEngine &Diags) {
+ auto *Arg = Args.getLastArg(Opt);
+ if (!Arg)
+ return None;
+ return std::string(Arg->getValue());
+}
+
static void denormalizeString(SmallVectorImpl<const char *> &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
@@ -478,8 +487,6 @@
.Case("false", false)
.Default(false);
- Opts.DumpExplodedGraphTo =
- std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
Opts.AnalyzeSpecificFunction =
std::string(Args.getLastArgValue(OPT_analyze_function));
Opts.maxBlockVisitOnPath =
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -573,7 +573,7 @@
def triple : Separate<["-"], "triple">,
HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">,
- AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
+ AlwaysEmit, Normalizer<"normalizeTriple">;
} // Flags = [CC1Option, CC1AsOption, NoDriverOption]
@@ -4124,7 +4124,8 @@
HelpText<"Display exploded graph using GraphViz">,
MarshallingInfoFlag<"AnalyzerOpts->visualizeExplodedGraphWithGraphViz", "false">;
def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">,
- HelpText<"Dump exploded graph to the specified file">;
+ HelpText<"Dump exploded graph to the specified file">,
+ MarshallingInfoString<"AnalyzerOpts->DumpExplodedGraphTo">;
def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias<analyzer_dump_egraph>;
def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84185.279290.patch
Type: text/x-patch
Size: 3485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200720/54b6fe55/attachment.bin>
More information about the cfe-commits
mailing list