[clang][cli] Fix round-trip of OPT_plugin_arg

The test Frontend/plugin-delayed-template.cpp is failing when asserts
are enabled because it hits an assertion in denormalizeStringImpl when
trying to round-trip OPT_plugin_arg. Fix this by adjusting how the
option is handled, as the first part is joined to -plugin-arg and the
second is separate.

Differential Revision: https://reviews.llvm.org/D99606
This commit is contained in:
John Brawn 2021-03-30 18:33:10 +01:00
parent 700431128e
commit eae3b2a715
1 changed files with 7 additions and 2 deletions

View File

@ -211,6 +211,7 @@ static void denormalizeStringImpl(SmallVectorImpl<const char *> &Args,
switch (OptClass) {
case Option::SeparateClass:
case Option::JoinedOrSeparateClass:
case Option::JoinedAndSeparateClass:
Args.push_back(Spelling);
Args.push_back(SA(Value));
break;
@ -2477,9 +2478,13 @@ static void GenerateFrontendArgs(const FrontendOptions &Opts,
GenerateProgramAction();
for (const auto &PluginArgs : Opts.PluginArgs)
for (const auto &PluginArgs : Opts.PluginArgs) {
Option Opt = getDriverOptTable().getOption(OPT_plugin_arg);
const char *Spelling =
SA(Opt.getPrefix() + Opt.getName() + PluginArgs.first);
for (const auto &PluginArg : PluginArgs.second)
GenerateArg(Args, OPT_plugin_arg, PluginArgs.first + PluginArg, SA);
denormalizeString(Args, Spelling, SA, Opt.getKind(), 0, PluginArg);
}
for (const auto &Ext : Opts.ModuleFileExtensions)
if (auto *TestExt = dyn_cast_or_null<TestModuleFileExtension>(Ext.get()))