This is an archive of the discontinued LLVM Phabricator instance.

[clang][extract-api] Process only APIs declared in inputs
ClosedPublic

Authored by dang on Apr 5 2022, 11:55 AM.

Details

Summary

We should only process APIs declared in the command line inputs to avoid
drowning the ExtractAPI output with symbols the user doesn't care about.
This is achieved by keeping track of the provided input files and
checking that the associated Decl or Macro is declared in one of those files.

Diff Detail

Event Timeline

dang created this revision.Apr 5 2022, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 11:55 AM
dang requested review of this revision.Apr 5 2022, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 11:55 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cishida added inline comments.Apr 5 2022, 12:22 PM
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
68

s/externsal/external

74

How is this searching by the way the header was included? It looks like comparisons are based on file locations as KnownIncludes stores file paths.

clang/test/ExtractAPI/known_files_only.c
7

It may be useful to add a test for the headermap case to ensure the remapped location is recognized.

zixuw added inline comments.Apr 5 2022, 1:20 PM
clang/test/ExtractAPI/known_files_only.c
21

I would just include another header split from this test file but not passed into the command line to avoid pulling in extra dependencies. Makes the test self-contained and more consistent, also simpler.

167

uri not normalized.

dang updated this revision to Diff 420875.Apr 6 2022, 8:17 AM
dang marked 2 inline comments as done.

Address code review feedback:

  • Remove unnecessary code
  • Add a test to validate that everything works in the presence of header maps
  • Simplify existing test
  • Fix small nits
dang marked 2 inline comments as done.Apr 6 2022, 8:20 AM
dang added inline comments.
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
74

Upon second thought and further testing all this stuff isn't needed because we always construct the input buffer using #include "ABSOLUTE_PATH". I have added a test to validate that this works when using a header map. If we ever move to relative includes, then we should change how this to use only include string comparisons (potentially caching the FileEntries as a performance optimization).

cishida accepted this revision.Apr 6 2022, 1:00 PM

LGTM

This revision is now accepted and ready to land.Apr 6 2022, 1:00 PM
dang updated this revision to Diff 421143.Apr 7 2022, 2:46 AM

Rebase on top of latest changes.

dang marked an inline comment as done.Apr 7 2022, 2:55 AM
zixuw accepted this revision.Apr 7 2022, 9:04 AM
This revision was landed with ongoing or failed builds.Apr 7 2022, 9:56 AM
This revision was automatically updated to reflect the committed changes.