rename symbol graph files for cross-import overlays

rdar://79474927
This commit is contained in:
Victoria Mitchell
2021-06-22 16:50:34 -06:00
parent 29176fc32a
commit 183db81d12
4 changed files with 43 additions and 24 deletions

View File

@@ -25,26 +25,14 @@ namespace {
int serializeSymbolGraph(SymbolGraph &SG,
const SymbolGraphOptions &Options) {
SmallString<256> FileName;
if (SG.DeclaringModule.hasValue()) {
// Save a cross-import overlay symbol graph as `MainModule@BystandingModule[@BystandingModule...]@OverlayModule.symbols.json`
//
// The overlay module's name is added as a disambiguator in case an overlay
// declares multiple modules for the same set of imports.
FileName.append(SG.DeclaringModule.getValue()->getNameStr());
for (auto BystanderModule : SG.BystanderModules) {
FileName.push_back('@');
FileName.append(BystanderModule.str());
}
FileName.append(SG.M.getNameStr());
if (SG.ExtendedModule.hasValue()) {
FileName.push_back('@');
FileName.append(SG.M.getNameStr());
} else {
FileName.append(SG.M.getNameStr());
if (SG.ExtendedModule.hasValue()) {
FileName.push_back('@');
FileName.append(SG.ExtendedModule.getValue()->getNameStr());
}
FileName.append(SG.ExtendedModule.getValue()->getNameStr());
} else if (SG.DeclaringModule.hasValue()) {
// Treat cross-import overlay modules as "extensions" of their declaring module
FileName.push_back('@');
FileName.append(SG.DeclaringModule.getValue()->getNameStr());
}
FileName.append(".symbols.json");