Merge pull request #64372 from hyp/eng/igen-cxx

[interop] SourceKit should retry generating module interface with C++…
This commit is contained in:
Alex Lorenz
2023-03-14 20:03:17 -07:00
committed by GitHub
2 changed files with 64 additions and 2 deletions

View File

@@ -699,8 +699,26 @@ void SwiftLangSupport::editorOpenInterface(EditorConsumer &Consumer,
SynthesizedExtensions,
InterestedUSR);
if (!IFaceGenRef) {
Consumer.handleRequestError(ErrMsg.c_str());
return;
// Retry to generate a module interface with C++ interop enabled,
// if the first attempt failed.
bool retryWithCxxEnabled = true;
for (const auto &arg: Args) {
if (StringRef(arg).startswith("-cxx-interoperability-mode=") ||
StringRef(arg).startswith("-enable-experimental-cxx-interop")) {
retryWithCxxEnabled = false;
break;
}
}
if (retryWithCxxEnabled) {
std::vector<const char *> AdjustedArgs(Args.begin(), Args.end());
AdjustedArgs.push_back("-cxx-interoperability-mode=swift-5.9");
return editorOpenInterface(Consumer, Name, ModuleName, Group, AdjustedArgs,
SynthesizedExtensions, InterestedUSR);
}
else {
Consumer.handleRequestError(ErrMsg.c_str());
return;
}
}
IFaceGenRef->reportEditorInfo(Consumer);