Skip to content

Commit 458e603

Browse files
committed
ModuleInterface: properly handle equal-joined arguments in the ignorable flags field
Previously, we have an assumption that all equal-joined arguments are alias to the separate forms, e.g. -tbd-install_name=Foo is an alias to -tbd-install_name Foo. However, it seems having only the equal-joined version of an argument is possible. This PR adds support to that scenario.
1 parent 6fe3ccc commit 458e603

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,12 +1086,19 @@ bool swift::extractCompilerFlagsFromInterface(StringRef interfacePath,
10861086
// options and input-like options.
10871087
if (!parse->getOption().hasFlag(options::FrontendOption))
10881088
continue;
1089-
// Push the supported option and its value to the list.
1090-
// We shouldn't need to worry about cases like -tbd-install_name=Foo because
1091-
// the parsing function should have droped alias options already.
1092-
SubArgs.push_back(ArgSaver.save(parse->getSpelling()).data());
1093-
for (auto value: parse->getValues())
1094-
SubArgs.push_back(value);
1089+
auto spelling = ArgSaver.save(parse->getSpelling());
1090+
auto &values = parse->getValues();
1091+
if (spelling.endswith("=")) {
1092+
// Handle the case like -tbd-install_name=Foo. This should be rare because
1093+
// most equal-separated arguments are alias to the separate form.
1094+
assert(values.size() == 1);
1095+
SubArgs.push_back(ArgSaver.save((llvm::Twine(spelling) + values[0]).str()).data());
1096+
} else {
1097+
// Push the supported option and its value to the list.
1098+
SubArgs.push_back(spelling.data());
1099+
for (auto value: values)
1100+
SubArgs.push_back(value);
1101+
}
10951102
}
10961103

10971104
return false;

0 commit comments

Comments
 (0)