Skip to content

Commit 1380a3e

Browse files
authored
Merge pull request #83044 from cmcgee1024/add_more_symbol_graph_opts_swiftc
Add pretty print and skip synthesized members to the frontend options
2 parents 5f3120b + 5048345 commit 1380a3e

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

include/swift/Option/Options.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,14 @@ def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
17791779
HelpText<"Emit a symbol graph to directory <dir>">,
17801780
MetaVarName<"<dir>">;
17811781

1782+
def symbol_graph_pretty_print: Flag<["-"], "symbol-graph-pretty-print">,
1783+
Flags<[FrontendOption, NoInteractiveOption, HelpHidden, SupplementaryOutput]>,
1784+
HelpText<"Pretty-print the output symbol graph JSON">;
1785+
1786+
def symbol_graph_skip_synthesized_members: Flag<["-"], "symbol-graph-skip-synthesized-members">,
1787+
Flags<[FrontendOption, NoInteractiveOption, HelpHidden, SupplementaryOutput]>,
1788+
HelpText<"Skip members inherited through classes or default implementations">;
1789+
17821790
def symbol_graph_minimum_access_level: Separate<["-"], "symbol-graph-minimum-access-level">,
17831791
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
17841792
HelpText<"Include symbols with this access level or more when emitting a symbol graph">,

lib/Driver/ToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
706706
context.Args.AddLastArg(Arguments, options::OPT_emit_extension_block_symbols,
707707
options::OPT_omit_extension_block_symbols);
708708
context.Args.AddLastArg(Arguments, options::OPT_symbol_graph_minimum_access_level);
709+
context.Args.AddLastArg(Arguments, options::OPT_symbol_graph_skip_synthesized_members);
710+
context.Args.AddLastArg(Arguments, options::OPT_symbol_graph_pretty_print);
709711

710712
return II;
711713
}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,8 +2241,8 @@ static void ParseSymbolGraphArgs(symbolgraphgen::SymbolGraphOptions &Opts,
22412241
}
22422242

22432243
// default values for generating symbol graphs during a build
2244-
Opts.PrettyPrint = false;
2245-
Opts.EmitSynthesizedMembers = true;
2244+
Opts.PrettyPrint = Args.hasArg(OPT_symbol_graph_pretty_print);
2245+
Opts.EmitSynthesizedMembers = !Args.hasArg(OPT_symbol_graph_skip_synthesized_members);
22462246
Opts.PrintMessages = false;
22472247
Opts.IncludeClangDocs = false;
22482248
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -module-name SkipsSynthesizedMembers -emit-module -emit-module-path %t/
3+
// RUN: %target-swift-symbolgraph-extract -module-name SkipsSynthesizedMembers -I %t -pretty-print -skip-synthesized-members -output-dir %t
4+
// RUN: %FileCheck %s --input-file %t/SkipsSynthesizedMembers.symbols.json
5+
6+
// CHECK-NOT: ::SYNTHESIZED
7+
8+
public struct ShouldAppear: Hashable {
9+
public let foo: Int
10+
}

0 commit comments

Comments
 (0)