This is an archive of the discontinued LLVM Phabricator instance.

Ensure -extract-api handles multiple headers correctly
ClosedPublic

Authored by dang on Mar 17 2022, 11:12 AM.

Details

Summary

clang -extract-api should accept multiple headers and forward them to a
single CC1 instance. This change introduces a new ExtractAPIJobAction.
Currently API Extraction is done during the Precompile phase as this is
the current phase that matches the requirements the most. Adding a new
phase would need to change some logic in how phases are scheduled. If
the headers scheduled for API extraction are of different types the
driver emits a diagnostic.

Diff Detail

Event Timeline

dang created this revision.Mar 17 2022, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 11:12 AM
dang requested review of this revision.Mar 17 2022, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 11:12 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dang updated this revision to Diff 416261.Mar 17 2022, 11:16 AM

Get rid of spurious clang-format changes due to reverted modifications

ributzka added inline comments.Mar 17 2022, 11:19 AM
clang/include/clang/Driver/Phases.h
17 ↗(On Diff #416260)

Is this an unrelated formatting change?

clang/lib/Driver/Phases.cpp
19 ↗(On Diff #416260)

Unrelated format change?

Nice! Thank you for adding support for multiple headers. Is this a step towards the json input file list?

clang/include/clang/Basic/DiagnosticDriverKinds.td
467

Could you please add a test for this?

dang added a comment.EditedMar 17 2022, 11:57 AM

If people think it would be preferable to add a new phase and change phase scheduling a little I am happy to do that too!

dang added inline comments.Mar 17 2022, 4:22 PM
clang/include/clang/Driver/Phases.h
17 ↗(On Diff #416260)

Fixed it in the latest diff. I had modified this in my first attempt at getting this to work so git-clang-format got confused...

clang/lib/Driver/Phases.cpp
19 ↗(On Diff #416260)

Same as the other change...

dang added a comment.Mar 17 2022, 4:32 PM

Nice! Thank you for adding support for multiple headers. Is this a step towards the json input file list?

My understanding was that for this iteration at least we were going with just feeding the headers directly to clang without an input file list. Maybe we should talk about this offline as I might be missing something.

dang updated this revision to Diff 416359.Mar 17 2022, 4:41 PM

Add test to check that command line with different header kinds gets diagnosed
appropriately.

dang marked an inline comment as done.Mar 17 2022, 4:41 PM
zixuw added a comment.Mar 17 2022, 5:12 PM

Nice! Thank you for adding support for multiple headers. Is this a step towards the json input file list?

My understanding was that for this iteration at least we were going with just feeding the headers directly to clang without an input file list. Maybe we should talk about this offline as I might be missing something.

In my initial proposed design, clang-extract-api takes in multiple headers directly as inputs. What would be the need to have a json file list?

dang added a comment.Mar 17 2022, 5:25 PM

Nice! Thank you for adding support for multiple headers. Is this a step towards the json input file list?

My understanding was that for this iteration at least we were going with just feeding the headers directly to clang without an input file list. Maybe we should talk about this offline as I might be missing something.

In my initial proposed design, clang-extract-api takes in multiple headers directly as inputs. What would be the need to have a json file list?

It might be better if we need to pass in information about specific headers. We can discuss more offline but I don't think it is necessary for this iteration at least.

dang updated this revision to Diff 416942.Mar 21 2022, 7:49 AM

Rebase on top of main to bring latest fixes to ExtractAPIAction

zixuw accepted this revision.Mar 21 2022, 9:41 AM

LGTM. Thanks Daniel!

This revision is now accepted and ready to land.Mar 21 2022, 9:41 AM
This revision was automatically updated to reflect the committed changes.