Skip to content

Commit 156e58d

Browse files
use symbol graph opts instead of serialization opts for SGFs
1 parent 6b5d884 commit 156e58d

File tree

7 files changed

+22
-33
lines changed

7 files changed

+22
-33
lines changed

include/swift/Serialization/SerializationOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ namespace swift {
3232
const char *OutputPath = nullptr;
3333
const char *DocOutputPath = nullptr;
3434
const char *SourceInfoOutputPath = nullptr;
35-
std::string SymbolGraphOutputDir;
3635
std::string ABIDescriptorPath;
37-
bool SkipSymbolGraphInheritedDocs = true;
38-
bool IncludeSPISymbolsInSymbolGraph = false;
3936
llvm::VersionTuple UserModuleVersion;
4037
std::string SDKName;
4138

include/swift/Subsystems.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ namespace swift {
8686
class SourceFileDepGraph;
8787
}
8888

89+
namespace symbolgraphgen {
90+
struct SymbolGraphOptions;
91+
}
92+
8993
/// @{
9094

9195
/// \returns true if the declaration should be verified. This can return
@@ -187,6 +191,7 @@ namespace swift {
187191
/// Serializes a module or single source file to the given output file.
188192
void
189193
serialize(ModuleOrSourceFile DC, const SerializationOptions &options,
194+
const symbolgraphgen::SymbolGraphOptions &symbolGraphOptions,
190195
const SILModule *M = nullptr,
191196
const fine_grained_dependencies::SourceFileDepGraph *DG = nullptr);
192197

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,6 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
153153
getIRGenOptions().PublicLinkLibraries;
154154
serializationOpts.SDKName = getLangOptions().SDKName;
155155
serializationOpts.ABIDescriptorPath = outs.ABIDescriptorOutputPath.c_str();
156-
157-
if (opts.EmitSymbolGraph) {
158-
if (!opts.SymbolGraphOutputDir.empty()) {
159-
serializationOpts.SymbolGraphOutputDir = opts.SymbolGraphOutputDir;
160-
} else {
161-
serializationOpts.SymbolGraphOutputDir = serializationOpts.OutputPath;
162-
}
163-
SmallString<256> OutputDir(serializationOpts.SymbolGraphOutputDir);
164-
llvm::sys::fs::make_absolute(OutputDir);
165-
serializationOpts.SymbolGraphOutputDir = OutputDir.str().str();
166-
}
167-
serializationOpts.SkipSymbolGraphInheritedDocs = opts.SkipInheritedDocs;
168-
serializationOpts.IncludeSPISymbolsInSymbolGraph = opts.IncludeSPISymbolsInSymbolGraph;
169156

170157
if (!getIRGenOptions().ForceLoadSymbolName.empty())
171158
serializationOpts.AutolinkForceLoad = true;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "swift/Serialization/SerializationOptions.h"
6666
#include "swift/Serialization/SerializedModuleLoader.h"
6767
#include "swift/SILOptimizer/PassManager/Passes.h"
68+
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
6869
#include "swift/Syntax/Serialization/SyntaxSerialization.h"
6970
#include "swift/Syntax/SyntaxNodes.h"
7071
#include "swift/TBDGen/TBDGen.h"
@@ -1301,7 +1302,9 @@ static bool serializeSIB(SILModule *SM, const PrimarySpecificPaths &PSPs,
13011302
serializationOpts.SerializeAllSIL = true;
13021303
serializationOpts.IsSIB = true;
13031304

1304-
serialize(MSF, serializationOpts, SM);
1305+
symbolgraphgen::SymbolGraphOptions symbolGraphOptions;
1306+
1307+
serialize(MSF, serializationOpts, symbolGraphOptions, SM);
13051308
return Context.hadError();
13061309
}
13071310

@@ -1554,11 +1557,11 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
15541557
fine_grained_dependencies::withReferenceDependencies(
15551558
Mod, *Instance.getDependencyTracker(), Mod->getModuleFilename(),
15561559
alsoEmitDotFile, [&](SourceFileDepGraph &&g) {
1557-
serialize(MSF, serializationOpts, SM.get(), &g);
1560+
serialize(MSF, serializationOpts, Invocation.getSymbolGraphOptions(), SM.get(), &g);
15581561
return false;
15591562
});
15601563
} else {
1561-
serialize(MSF, serializationOpts, SM.get());
1564+
serialize(MSF, serializationOpts, Invocation.getSymbolGraphOptions(), SM.get());
15621565
}
15631566
};
15641567

lib/Serialization/Serialization.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,6 +5746,7 @@ void swift::serializeToBuffers(
57465746

57475747
void swift::serialize(ModuleOrSourceFile DC,
57485748
const SerializationOptions &options,
5749+
const symbolgraphgen::SymbolGraphOptions &symbolGraphOptions,
57495750
const SILModule *M,
57505751
const fine_grained_dependencies::SourceFileDepGraph *DG) {
57515752
assert(!withNullAsEmptyStringRef(options.OutputPath).empty());
@@ -5790,22 +5791,12 @@ void swift::serialize(ModuleOrSourceFile DC,
57905791
});
57915792
}
57925793

5793-
if (!options.SymbolGraphOutputDir.empty()) {
5794+
if (!symbolGraphOptions.OutputDir.empty()) {
57945795
if (DC.is<ModuleDecl *>()) {
57955796
auto *M = DC.get<ModuleDecl*>();
57965797
FrontendStatsTracer tracer(getContext(DC).Stats,
57975798
"Serialization, symbolgraph");
5798-
symbolgraphgen::SymbolGraphOptions SGOpts {
5799-
options.SymbolGraphOutputDir,
5800-
M->getASTContext().LangOpts.Target,
5801-
/* PrettyPrint */false,
5802-
AccessLevel::Public,
5803-
/*EmitSynthesizedMembers*/true,
5804-
/*PrintMessages*/false,
5805-
/*EmitInheritedDocs*/options.SkipSymbolGraphInheritedDocs,
5806-
/*IncludeSPISymbols*/options.IncludeSPISymbolsInSymbolGraph,
5807-
};
5808-
symbolgraphgen::emitSymbolGraphForModule(M, SGOpts);
5799+
symbolgraphgen::emitSymbolGraphForModule(M, symbolGraphOptions);
58095800
}
58105801
}
58115802
emitABIDescriptor(DC, options);

tools/sil-func-extractor/SILFunctionExtractor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "swift/Serialization/SerializedModuleLoader.h"
3737
#include "swift/Serialization/SerializationOptions.h"
3838
#include "swift/Serialization/SerializedSILLoader.h"
39+
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
3940
#include "swift/Subsystems.h"
4041
#include "llvm/Support/CommandLine.h"
4142
#include "llvm/Support/Debug.h"
@@ -356,7 +357,9 @@ int main(int argc, char **argv) {
356357
serializationOpts.SerializeAllSIL = true;
357358
serializationOpts.IsSIB = true;
358359

359-
serialize(CI.getMainModule(), serializationOpts, SILMod.get());
360+
symbolgraphgen::SymbolGraphOptions symbolGraphOpts;
361+
362+
serialize(CI.getMainModule(), serializationOpts, symbolGraphOpts, SILMod.get());
360363
} else {
361364
const StringRef OutputFile =
362365
OutputFilename.size() ? StringRef(OutputFilename) : "-";

tools/sil-opt/SILOpt.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "swift/Serialization/SerializedModuleLoader.h"
3232
#include "swift/Serialization/SerializedSILLoader.h"
3333
#include "swift/Serialization/SerializationOptions.h"
34+
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
3435
#include "swift/IRGen/IRGenPublic.h"
3536
#include "swift/IRGen/IRGenSILPasses.h"
3637
#include "llvm/ADT/Statistic.h"
@@ -633,7 +634,9 @@ int main(int argc, char **argv) {
633634
serializationOpts.SerializeAllSIL = EmitSIB;
634635
serializationOpts.IsSIB = EmitSIB;
635636

636-
serialize(CI.getMainModule(), serializationOpts, SILMod.get());
637+
symbolgraphgen::SymbolGraphOptions symbolGraphOptions;
638+
639+
serialize(CI.getMainModule(), serializationOpts, symbolGraphOptions, SILMod.get());
637640
} else {
638641
const StringRef OutputFile = OutputFilename.size() ?
639642
StringRef(OutputFilename) : "-";

0 commit comments

Comments
 (0)