Skip to content

Commit 31b0430

Browse files
[clang][ExtractAPI] Add ability to create multiple symbol graphs (llvm#86676)
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/[email protected]` 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.
1 parent 21fe9b4 commit 31b0430

File tree

76 files changed

+3898
-7557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3898
-7557
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,12 @@ def err_drv_extract_api_wrong_kind : Error<
521521
"header file '%0' input '%1' does not match the type of prior input "
522522
"in api extraction; use '-x %2' to override">;
523523

524+
def err_drv_missing_symbol_graph_dir: Error<
525+
"Must provide a symbol graph output directory using --symbol-graph-dir=<directory>">;
526+
527+
def err_drv_unexpected_symbol_graph_output : Error<
528+
"Unexpected output symbol graph '%1'; please provide --symbol-graph-dir=<directory> instead">;
529+
524530
def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
525531
InGroup<DiagGroup<"slash-u-filename">>;
526532
def note_use_dashdash : Note<

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,6 @@ def warn_profile_data_misexpect : Warning<
360360
def err_extract_api_ignores_file_not_found :
361361
Error<"file '%0' specified by '--extract-api-ignores=' not found">, DefaultFatal;
362362

363+
def warn_missing_symbol_graph_dir : Warning<"Missing symbol graph output directory, defaulting to working directory">;
364+
363365
}

clang/include/clang/Driver/Options.td

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,13 +1223,30 @@ def extract_api : Flag<["-"], "extract-api">, Flags<[CC1Option]>, Group<Action_G
12231223
HelpText<"Extract API information">;
12241224
def product_name_EQ: Joined<["--"], "product-name=">, Flags<[CC1Option]>,
12251225
MarshallingInfoString<FrontendOpts<"ProductName">>;
1226-
def emit_symbol_graph_EQ: JoinedOrSeparate<["--"], "emit-symbol-graph=">, Flags<[CC1Option]>,
1227-
HelpText<"Generate Extract API information as a side effect of compilation.">,
1228-
MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
1229-
def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">, Flags<[CC1Option]>,
1230-
HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
1231-
MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
1232-
def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
1226+
def emit_symbol_graph: Flag<["-"], "emit-symbol-graph">,
1227+
Flags<[CC1Option]>,
1228+
HelpText<"Generate Extract API information as a side effect of compilation.">,
1229+
MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraph">>;
1230+
def emit_extension_symbol_graphs: Flag<["--"], "emit-extension-symbol-graphs">,
1231+
Flags<[CC1Option]>,
1232+
HelpText<"Generate additional symbol graphs for extended modules.">,
1233+
MarshallingInfoFlag<FrontendOpts<"EmitExtensionSymbolGraphs">>;
1234+
def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">,
1235+
Flags<[CC1Option]>,
1236+
HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
1237+
MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
1238+
def symbol_graph_dir_EQ: Joined<["--"], "symbol-graph-dir=">,
1239+
Flags<[CC1Option]>,
1240+
HelpText<"Directory in which to emit symbol graphs.">,
1241+
MarshallingInfoString<FrontendOpts<"SymbolGraphOutputDir">>;
1242+
def emit_pretty_sgf: Flag<["--"], "pretty-sgf">,
1243+
Flags<[CC1Option]>,
1244+
HelpText<"Emit pretty printed symbol graphs">,
1245+
MarshallingInfoFlag<FrontendOpts<"EmitPrettySymbolGraphs">>;
1246+
def emit_sgf_symbol_labels_for_testing: Flag<["--"], "emit-sgf-symbol-labels-for-testing">,
1247+
Flags<[CC1Option]>,
1248+
MarshallingInfoFlag<FrontendOpts<"EmitSymbolGraphSymbolLabelsForTesting">>;
1249+
def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
12331250
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>, Flags<[CC1Option]>,
12341251
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,
12351252
MarshallingInfoInt<LangOpts<"MaxTokens">>;

0 commit comments

Comments
 (0)