Skip to content

Commit 1d189de

Browse files
Merge pull request swiftlang#37641 from apple/QuietMisdreavus/5.5/spi-symbols
[5.5] [SymbolGraph][Driver] add symbol-graph flag to include SPI symbols
2 parents 221d81e + fd26b86 commit 1d189de

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
@@ -399,6 +399,9 @@ class FrontendOptions {
399399
/// which are inherited through classes or default implementations.
400400
bool SkipInheritedDocs = false;
401401

402+
/// Whether to include symbols with SPI information in the symbol graph.
403+
bool IncludeSPISymbolsInSymbolGraph = false;
404+
402405
private:
403406
static bool canActionEmitDependencies(ActionType);
404407
static bool canActionEmitReferenceDependencies(ActionType);

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,4 +1230,9 @@ def skip_inherited_docs : Flag<["-"], "skip-inherited-docs">,
12301230
HelpText<"Skip emitting doc comments for members inherited through classes or "
12311231
"default implementations">;
12321232

1233+
def include_spi_symbols : Flag<["-"], "include-spi-symbols">,
1234+
Flags<[SwiftSymbolGraphExtractOption, FrontendOption,
1235+
NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
1236+
HelpText<"Add symbols with SPI information to the symbol graph">;
1237+
12331238
include "FrontendOptions.td"

include/swift/Serialization/SerializationOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace swift {
3232
const char *SourceInfoOutputPath = nullptr;
3333
std::string SymbolGraphOutputDir;
3434
bool SkipSymbolGraphInheritedDocs = true;
35+
bool IncludeSPISymbolsInSymbolGraph = false;
3536

3637
StringRef GroupInfoPath;
3738
StringRef ImportedHeader;

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
@@ -250,6 +250,7 @@ bool ArgsToFrontendOptionsConverter::convert(
250250
}
251251

252252
Opts.SkipInheritedDocs = Args.hasArg(OPT_skip_inherited_docs);
253+
Opts.IncludeSPISymbolsInSymbolGraph = Args.hasArg(OPT_include_spi_symbols);
253254

254255
return false;
255256
}

lib/Frontend/Frontend.cpp

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

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

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5653,6 +5653,7 @@ void swift::serialize(ModuleOrSourceFile DC,
56535653
/*EmitSynthesizedMembers*/true,
56545654
/*PrintMessages*/false,
56555655
/*EmitInheritedDocs*/options.SkipSymbolGraphInheritedDocs,
5656+
/*IncludeSPISymbols*/options.IncludeSPISymbolsInSymbolGraph,
56565657
};
56575658
symbolgraphgen::emitSymbolGraphForModule(M, SGOpts);
56585659
}

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)