Skip to content

Commit 6b5d884

Browse files
add new flag -symbol-graph-minimum-access-level
1 parent 22aa3c5 commit 6b5d884

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,11 @@ def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
12691269
HelpText<"Emit a symbol graph to directory <dir>">,
12701270
MetaVarName<"<dir>">;
12711271

1272+
def symbol_graph_minimum_access_level: Separate<["-"], "symbol-graph-minimum-access-level">,
1273+
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
1274+
HelpText<"Include symbols with this access level or more when emitting a symbol graph">,
1275+
MetaVarName<"<level>">;
1276+
12721277
def pretty_print: Flag<["-"], "pretty-print">,
12731278
Flags<[SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
12741279
HelpText<"Pretty-print the output JSON">;

lib/Driver/ToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ ToolChain::constructInvocation(const CompileJobAction &job,
590590
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
591591
}
592592
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
593+
context.Args.AddLastArg(Arguments, options::OPT_symbol_graph_minimum_access_level);
593594

594595
return II;
595596
}
@@ -1081,6 +1082,7 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
10811082
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);
10821083
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph_dir);
10831084
context.Args.AddLastArg(Arguments, options::OPT_include_spi_symbols);
1085+
context.Args.AddLastArg(Arguments, options::OPT_symbol_graph_minimum_access_level);
10841086

10851087
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
10861088

lib/Frontend/CompilerInvocation.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,20 @@ static void ParseSymbolGraphArgs(symbolgraphgen::SymbolGraphOptions &Opts,
11041104
Opts.SkipInheritedDocs = Args.hasArg(OPT_skip_inherited_docs);
11051105
Opts.IncludeSPISymbols = Args.hasArg(OPT_include_spi_symbols);
11061106

1107+
if (auto *A = Args.getLastArg(OPT_symbol_graph_minimum_access_level)) {
1108+
Opts.MinimumAccessLevel =
1109+
llvm::StringSwitch<AccessLevel>(A->getValue())
1110+
.Case("open", AccessLevel::Open)
1111+
.Case("public", AccessLevel::Public)
1112+
.Case("internal", AccessLevel::Internal)
1113+
.Case("fileprivate", AccessLevel::FilePrivate)
1114+
.Case("private", AccessLevel::Private)
1115+
.Default(AccessLevel::Public);
1116+
} else {
1117+
Opts.MinimumAccessLevel = AccessLevel::Public;
1118+
}
1119+
11071120
// default values for generating symbol graphs during a build
1108-
Opts.MinimumAccessLevel = AccessLevel::Public;
11091121
Opts.PrettyPrint = false;
11101122
Opts.EmitSynthesizedMembers = true;
11111123
Opts.PrintMessages = false;

0 commit comments

Comments
 (0)