Skip to content

Commit e2fc85c

Browse files
committed
[clang][cli] Better defaults for MarshallingInfoString
Depends on D84018 Reviewed By: Bigcheese Original patch by Daniel Grumberg. Differential Revision: https://reviews.llvm.org/D84185
1 parent 4e2e785 commit e2fc85c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,7 +3933,7 @@ def target_feature : Separate<["-"], "target-feature">,
39333933
def triple : Separate<["-"], "triple">,
39343934
HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
39353935
MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">,
3936-
AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
3936+
AlwaysEmit, Normalizer<"normalizeTriple">;
39373937
def target_abi : Separate<["-"], "target-abi">,
39383938
HelpText<"Target a particular ABI type">;
39393939
def target_sdk_version_EQ : Joined<["-"], "target-sdk-version=">,
@@ -3998,7 +3998,8 @@ def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
39983998
HelpText<"Display exploded graph using GraphViz">,
39993999
MarshallingInfoFlag<"AnalyzerOpts->visualizeExplodedGraphWithGraphViz">;
40004000
def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">,
4001-
HelpText<"Dump exploded graph to the specified file">;
4001+
HelpText<"Dump exploded graph to the specified file">,
4002+
MarshallingInfoString<"AnalyzerOpts->DumpExplodedGraphTo">;
40024003
def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias<analyzer_dump_egraph>;
40034004

40044005
def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ static void denormalizeSimpleEnumJoined(SmallVectorImpl<const char *> &Args,
272272
"the tablegen option description");
273273
}
274274

275+
static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
276+
const ArgList &Args,
277+
DiagnosticsEngine &Diags) {
278+
auto *Arg = Args.getLastArg(Opt);
279+
if (!Arg)
280+
return None;
281+
return std::string(Arg->getValue());
282+
}
283+
275284
static void denormalizeString(SmallVectorImpl<const char *> &Args,
276285
const char *Spelling,
277286
CompilerInvocation::StringAllocator SA,
@@ -498,8 +507,6 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
498507
.Case("false", false)
499508
.Default(false);
500509

501-
Opts.DumpExplodedGraphTo =
502-
std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
503510
Opts.AnalyzeSpecificFunction =
504511
std::string(Args.getLastArgValue(OPT_analyze_function));
505512
Opts.maxBlockVisitOnPath =

llvm/include/llvm/Option/OptParser.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ class MarshallingInfo<code keypath, code defaultvalue> {
155155
code DefaultValue = defaultvalue;
156156
}
157157

158-
class MarshallingInfoString<code keypath, code defaultvalue>
159-
: MarshallingInfo<keypath, defaultvalue> {}
158+
class MarshallingInfoString<code keypath, code defaultvalue="std::string()">
159+
: MarshallingInfo<keypath, defaultvalue> {
160+
code Normalizer = "normalizeString";
161+
code Denormalizer = "denormalizeString";
162+
}
160163

161164
class MarshallingInfoFlag<code keypath, code defaultvalue = "false">
162165
: MarshallingInfo<keypath, defaultvalue> {
@@ -189,7 +192,6 @@ class Normalizer<code normalizer> { code Normalizer = normalizer; }
189192
class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }
190193
class NormalizedValuesScope<code scope> { code NormalizedValuesScope = scope; }
191194
class NormalizedValues<list<code> definitions> { list<code> NormalizedValues = definitions; }
192-
class DenormalizeString { code Denormalizer = "denormalizeString"; }
193195
class AutoNormalizeEnum {
194196
code Normalizer = "normalizeSimpleEnum";
195197
code Denormalizer = "denormalizeSimpleEnum";

0 commit comments

Comments
 (0)