Skip to content

Commit 9fde71b

Browse files
authored
Merge pull request #4442 from daniel-grumberg/clang-extract-api
SymbolGraph ExtractAPI support for C and Objective-C in clang
2 parents 8349b25 + 553436e commit 9fde71b

Some content is hidden

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

49 files changed

+9486
-22
lines changed

clang/include/clang/AST/RawCommentList.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,21 @@ class RawComment {
139139
std::string getFormattedText(const SourceManager &SourceMgr,
140140
DiagnosticsEngine &Diags) const;
141141

142+
struct CommentLine {
143+
std::string Text;
144+
PresumedLoc Begin;
145+
PresumedLoc End;
146+
147+
CommentLine(StringRef Text, PresumedLoc Begin, PresumedLoc End)
148+
: Text(Text), Begin(Begin), End(End) {}
149+
};
150+
151+
/// Returns sanitized comment text as separated lines with locations in
152+
/// source, suitable for further processing and rendering requiring source
153+
/// locations.
154+
std::vector<CommentLine> getFormattedLines(const SourceManager &SourceMgr,
155+
DiagnosticsEngine &Diags) const;
156+
142157
/// Parse the comment, assuming it is attached to decl \c D.
143158
comments::FullComment *parse(const ASTContext &Context,
144159
const Preprocessor *PP, const Decl *D) const;

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ def err_test_module_file_extension_format : Error<
435435
"-ftest-module-file-extension argument '%0' is not of the required form "
436436
"'blockname:major:minor:hashed:user info'">;
437437

438+
def err_drv_extract_api_wrong_kind : Error<
439+
"header file '%0' input '%1' does not match the type of prior input "
440+
"in api extraction; use '-x %2' to override">;
441+
438442
def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">,
439443
InGroup<DiagGroup<"slash-u-filename">>;
440444
def note_use_dashdash : Note<

clang/include/clang/Driver/Action.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Action {
5959
PreprocessJobClass,
6060
PrecompileJobClass,
6161
HeaderModulePrecompileJobClass,
62+
ExtractAPIJobClass,
6263
AnalyzeJobClass,
6364
MigrateJobClass,
6465
CompileJobClass,
@@ -437,6 +438,19 @@ class HeaderModulePrecompileJobAction : public PrecompileJobAction {
437438
const char *getModuleName() const { return ModuleName; }
438439
};
439440

441+
class ExtractAPIJobAction : public JobAction {
442+
void anchor() override;
443+
444+
public:
445+
ExtractAPIJobAction(Action *Input, types::ID OutputType);
446+
447+
static bool classof(const Action *A) {
448+
return A->getKind() == ExtractAPIJobClass;
449+
}
450+
451+
void addHeaderInput(Action *Input) { getInputs().push_back(Input); }
452+
};
453+
440454
class AnalyzeJobAction : public JobAction {
441455
void anchor() override;
442456

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@ def emit_merged_ifs : Flag<["-"], "emit-merged-ifs">,
10881088
HelpText<"Generate Interface Stub Files, emit merged text not binary.">;
10891089
def interface_stub_version_EQ : JoinedOrSeparate<["-"], "interface-stub-version=">, Flags<[CC1Option]>;
10901090
def exported__symbols__list : Separate<["-"], "exported_symbols_list">;
1091+
def extract_api : Flag<["-"], "extract-api">, Flags<[CC1Option]>, Group<Action_Group>,
1092+
HelpText<"Extract API information">;
1093+
def product_name_EQ: Joined<["--"], "product-name=">, Flags<[CC1Option]>,
1094+
MarshallingInfoString<FrontendOpts<"ProductName">>;
10911095
def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
10921096
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>, Flags<[CC1Option]>,
10931097
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,

clang/include/clang/Driver/Types.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,5 @@ TYPE("dSYM", dSYM, INVALID, "dSYM", phases
100100
TYPE("dependencies", Dependencies, INVALID, "d", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
101101
TYPE("cuda-fatbin", CUDA_FATBIN, INVALID, "fatbin", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
102102
TYPE("hip-fatbin", HIP_FATBIN, INVALID, "hipfb", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
103+
TYPE("api-information", API_INFO, INVALID, "json", phases::Precompile)
103104
TYPE("none", Nothing, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)

0 commit comments

Comments
 (0)