Skip to content

Commit f0bbbda

Browse files
Add option to provide an allow list of reexported modules for swift-symbolgraph-extract
1 parent 532a7de commit f0bbbda

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,10 @@ def output_dir : Separate<["-"], "output-dir">,
15731573
HelpText<"Output directory">,
15741574
MetaVarName<"<dir>">;
15751575

1576+
def experimental_allowed_reexported_modules: CommaJoined<["-"], "experimental_allowed_reexported_modules">,
1577+
Flags<[NoDriverOption, SwiftSymbolGraphExtractOption]>,
1578+
HelpText<"Allow reexporting symbols from the provided modules if they are themselves exported from the main module. This is a comma separated list of module names.">;
1579+
15761580
def skip_synthesized_members: Flag<[ "-" ], "skip-synthesized-members">,
15771581
Flags<[NoDriverOption, SwiftSymbolGraphExtractOption]>,
15781582
HelpText<"Skip members inherited through classes or default implementations">;

include/swift/SymbolGraphGen/SymbolGraphOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "llvm/TargetParser/Triple.h"
14+
#include "llvm/ADT/ArrayRef.h"
15+
1416
#include "swift/AST/AttrKind.h"
1517

1618
#ifndef SWIFT_SYMBOLGRAPHGEN_SYMBOLGRAPHOPTIONS_H
@@ -63,6 +65,10 @@ struct SymbolGraphOptions {
6365
/// but SourceKit should be able to load the information when pulling symbol
6466
/// information for individual queries.
6567
bool PrintPrivateStdlibSymbols = false;
68+
69+
/// If this has a value specifies an explicit allow list of reexported module
70+
/// names that should be included symbol graph.
71+
std::optional<llvm::ArrayRef<StringRef>> AllowedReexportedModules = {};
6672
};
6773

6874
} // end namespace symbolgraphgen

lib/DriverTool/swift_symbolgraph_extract_main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
163163
}
164164
}
165165

166+
SmallVector<StringRef, 4> AllowedRexports;
167+
if (auto *A =
168+
ParsedArgs.getLastArg(OPT_experimental_allowed_reexported_modules)) {
169+
for (const auto *val : A->getValues())
170+
AllowedRexports.emplace_back(val);
171+
}
172+
166173
symbolgraphgen::SymbolGraphOptions Options;
167174
Options.OutputDir = OutputDir;
168175
Options.Target = Target;
@@ -175,6 +182,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
175182
Options.EmitExtensionBlockSymbols =
176183
ParsedArgs.hasFlag(OPT_emit_extension_block_symbols,
177184
OPT_omit_extension_block_symbols, /*default=*/false);
185+
Options.AllowedReexportedModules = AllowedRexports;
178186

179187
if (auto *A = ParsedArgs.getLastArg(OPT_minimum_access_level)) {
180188
Options.MinimumAccessLevel =

0 commit comments

Comments
 (0)