Skip to content

Commit d281722

Browse files
add symbol-graph flag to include SPI symbols
rdar://70794131
1 parent cb69f2e commit d281722

File tree

14 files changed

+53
-1
lines changed

14 files changed

+53
-1
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ class FrontendOptions {
409409
/// which are inherited through classes or default implementations.
410410
bool SkipInheritedDocs = false;
411411

412+
/// Whether to include symbols with SPI information in the symbol graph.
413+
bool IncludeSPISymbolsInSymbolGraph = false;
414+
412415
private:
413416
static bool canActionEmitDependencies(ActionType);
414417
static bool canActionEmitReferenceDependencies(ActionType);

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,11 @@ def skip_inherited_docs : Flag<["-"], "skip-inherited-docs">,
12471247
HelpText<"Skip emitting doc comments for members inherited through classes or "
12481248
"default implementations">;
12491249

1250+
def include_spi_symbols : Flag<["-"], "include-spi-symbols">,
1251+
Flags<[SwiftSymbolGraphExtractOption, FrontendOption,
1252+
NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
1253+
HelpText<"Add symbols with SPI information to the symbol graph">;
1254+
12501255
// swift-api-digester-only options
12511256
def dump_sdk: Flag<["-", "--"], "dump-sdk">,
12521257
Flags<[NoDriverOption, SwiftAPIDigesterOption]>,

include/swift/Serialization/SerializationOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace swift {
3333
const char *SourceInfoOutputPath = nullptr;
3434
std::string SymbolGraphOutputDir;
3535
bool SkipSymbolGraphInheritedDocs = true;
36+
bool IncludeSPISymbolsInSymbolGraph = false;
3637
llvm::VersionTuple UserModuleVersion;
3738

3839
StringRef GroupInfoPath;

include/swift/SymbolGraphGen/SymbolGraphOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ struct SymbolGraphOptions {
4242

4343
/// Whether to skip docs for symbols with compound, "SYNTHESIZED" USRs.
4444
bool SkipInheritedDocs;
45+
46+
/// Whether to emit symbols with SPI information.
47+
bool IncludeSPISymbols;
4548
};
4649

4750
} // end namespace symbolgraphgen

lib/Driver/ToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ ToolChain::constructInvocation(const CompileJobAction &job,
581581
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile) {
582582
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);
583583
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
584+
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
584585
}
585586

586587
return II;
@@ -1071,6 +1072,7 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
10711072

10721073
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);
10731074
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
1075+
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
10741076

10751077
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
10761078

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ bool ArgsToFrontendOptionsConverter::convert(
264264
}
265265

266266
Opts.SkipInheritedDocs = Args.hasArg(OPT_skip_inherited_docs);
267+
Opts.IncludeSPISymbolsInSymbolGraph = Args.hasArg(OPT_include_spi_symbols);
267268

268269
Opts.Static = Args.hasArg(OPT_static);
269270

lib/Frontend/Frontend.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
168168
serializationOpts.SymbolGraphOutputDir = OutputDir.str().str();
169169
}
170170
serializationOpts.SkipSymbolGraphInheritedDocs = opts.SkipInheritedDocs;
171+
serializationOpts.IncludeSPISymbolsInSymbolGraph = opts.IncludeSPISymbolsInSymbolGraph;
171172

172173
if (!getIRGenOptions().ForceLoadSymbolName.empty())
173174
serializationOpts.AutolinkForceLoad = true;

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5651,6 +5651,7 @@ void swift::serialize(ModuleOrSourceFile DC,
56515651
/*EmitSynthesizedMembers*/true,
56525652
/*PrintMessages*/false,
56535653
/*EmitInheritedDocs*/options.SkipSymbolGraphInheritedDocs,
5654+
/*IncludeSPISymbols*/options.IncludeSPISymbolsInSymbolGraph,
56545655
};
56555656
symbolgraphgen::emitSymbolGraphForModule(M, SGOpts);
56565657
}

lib/SymbolGraphGen/Symbol.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ void Symbol::serializeAvailabilityMixin(llvm::json::OStream &OS) const {
471471
});
472472
}
473473

474+
void Symbol::serializeSPIMixin(llvm::json::OStream &OS) const {
475+
if (VD->isSPI())
476+
OS.attribute("spi", true);
477+
}
478+
474479
void Symbol::serialize(llvm::json::OStream &OS) const {
475480
OS.object([&](){
476481
serializeKind(OS);
@@ -487,6 +492,7 @@ void Symbol::serialize(llvm::json::OStream &OS) const {
487492
serializeAccessLevelMixin(OS);
488493
serializeAvailabilityMixin(OS);
489494
serializeLocationMixin(OS);
495+
serializeSPIMixin(OS);
490496
});
491497
}
492498

lib/SymbolGraphGen/Symbol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ class Symbol {
7676

7777
void serializeAvailabilityMixin(llvm::json::OStream &OS) const;
7878

79+
void serializeSPIMixin(llvm::json::OStream &OS) const;
80+
7981
public:
8082
Symbol(SymbolGraph *Graph, const ValueDecl *VD,
8183
const NominalTypeDecl *SynthesizedBaseTypeDecl,

0 commit comments

Comments
 (0)