Skip to content

Commit 40b084e

Browse files
Merge pull request #37640 from apple/QuietMisdreavus/spi-symbols
add symbol-graph flag to include SPI symbols
2 parents fc80a9a + d281722 commit 40b084e

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
@@ -425,6 +425,9 @@ class FrontendOptions {
425425
/// which are inherited through classes or default implementations.
426426
bool SkipInheritedDocs = false;
427427

428+
/// Whether to include symbols with SPI information in the symbol graph.
429+
bool IncludeSPISymbolsInSymbolGraph = false;
430+
428431
private:
429432
static bool canActionEmitDependencies(ActionType);
430433
static bool canActionEmitReferenceDependencies(ActionType);

include/swift/Option/Options.td

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

1255+
def include_spi_symbols : Flag<["-"], "include-spi-symbols">,
1256+
Flags<[SwiftSymbolGraphExtractOption, FrontendOption,
1257+
NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
1258+
HelpText<"Add symbols with SPI information to the symbol graph">;
1259+
12551260
// swift-api-digester-only options
12561261
def dump_sdk: Flag<["-", "--"], "dump-sdk">,
12571262
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
@@ -582,6 +582,7 @@ ToolChain::constructInvocation(const CompileJobAction &job,
582582
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile) {
583583
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);
584584
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
585+
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
585586
}
586587

587588
return II;
@@ -1072,6 +1073,7 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
10721073

10731074
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);
10741075
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
1076+
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
10751077

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

lib/Frontend/ArgsToFrontendOptionsConverter.cpp

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

274274
Opts.SkipInheritedDocs = Args.hasArg(OPT_skip_inherited_docs);
275+
Opts.IncludeSPISymbolsInSymbolGraph = Args.hasArg(OPT_include_spi_symbols);
275276

276277
Opts.Static = Args.hasArg(OPT_static);
277278

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
@@ -5665,6 +5665,7 @@ void swift::serialize(ModuleOrSourceFile DC,
56655665
/*EmitSynthesizedMembers*/true,
56665666
/*PrintMessages*/false,
56675667
/*EmitInheritedDocs*/options.SkipSymbolGraphInheritedDocs,
5668+
/*IncludeSPISymbols*/options.IncludeSPISymbolsInSymbolGraph,
56685669
};
56695670
symbolgraphgen::emitSymbolGraphForModule(M, SGOpts);
56705671
}

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)