Skip to content

Commit

Permalink
[clang][ExtractAPI] Add ability to create multiple symbol graphs (#86676
Browse files Browse the repository at this point in the history
)

This extends ExtractAPI to take into account symbols defined in categories to types defined in an external module.
This introduces 2 new command line flags, `--symbol-graph-dir=DIR` and `--emit-extension-symbol-graphs`, when used together this generates additional symbol graph files at `DIR/ExtendedModule@ProductName.symbols.json` for each external module that is extended in this way.

Additionally this makes some cleanups to tests to make them more resilient and cleans up the `APISet` data structure.
  • Loading branch information
daniel-grumberg committed Apr 2, 2024
1 parent e03f16f commit b31414b
Show file tree
Hide file tree
Showing 79 changed files with 3,888 additions and 8,845 deletions.
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ def err_drv_extract_api_wrong_kind : Error<
"header file '%0' input '%1' does not match the type of prior input "
"in api extraction; use '-x %2' to override">;

def err_drv_missing_symbol_graph_dir: Error<
"Must provide a symbol graph output directory using --symbol-graph-dir=<directory>">;

def err_drv_unexpected_symbol_graph_output : Error<
"Unexpected output symbol graph '%1'; please provide --symbol-graph-dir=<directory> instead">;

def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
InGroup<DiagGroup<"slash-u-filename">>;
def note_use_dashdash : Note<
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,6 @@ def warn_profile_data_misexpect : Warning<
def err_extract_api_ignores_file_not_found :
Error<"file '%0' specified by '--extract-api-ignores=' not found">, DefaultFatal;

def warn_missing_symbol_graph_dir : Warning<"Missing symbol graph output directory, defaulting to working directory">;

}
21 changes: 18 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1507,14 +1507,29 @@ def extract_api : Flag<["-"], "extract-api">,
def product_name_EQ: Joined<["--"], "product-name=">,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoString<FrontendOpts<"ProductName">>;
def emit_symbol_graph_EQ: JoinedOrSeparate<["--"], "emit-symbol-graph=">,
def emit_symbol_graph: Flag<["-"], "emit-symbol-graph">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Generate Extract API information as a side effect of compilation.">,
MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
HelpText<"Generate Extract API information as a side effect of compilation.">,
MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraph">>;
def emit_extension_symbol_graphs: Flag<["--"], "emit-extension-symbol-graphs">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Generate additional symbol graphs for extended modules.">,
MarshallingInfoFlag<FrontendOpts<"EmitExtensionSymbolGraphs">>;
def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
def symbol_graph_dir_EQ: Joined<["--"], "symbol-graph-dir=">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Directory in which to emit symbol graphs.">,
MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
def emit_pretty_sgf: Flag<["--"], "pretty-sgf">,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Emit pretty printed symbol graphs">,
MarshallingInfoFlag<FrontendOpts<"EmitPrettySymbolGraphs">>;
def emit_sgf_symbol_labels_for_testing: Flag<["--"], "emit-sgf-symbol-labels-for-testing">,
Visibility<[CC1Option]>,
MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraphSymbolLabelsForTesting">>;
def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>,
Visibility<[ClangOption, CC1Option]>,
Expand Down
Loading

0 comments on commit b31414b

Please sign in to comment.