This is an archive of the discontinued LLVM Phabricator instance.

[clang][extract-api] Add support for true anonymous enums
ClosedPublic

Authored by dang on Apr 11 2022, 11:54 AM.

Details

Summary

Anonymous enums without a typedef should have a "(anonymous)" identifier.

Diff Detail

Event Timeline

dang created this revision.Apr 11 2022, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 11:54 AM
dang requested review of this revision.Apr 11 2022, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 11:54 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
zixuw added inline comments.Apr 11 2022, 12:04 PM
clang/test/ExtractAPI/enum.c
693

nit: normalize

702

So the Name of the record is literally (anonymous)? I think this might create problems (well I guess we always had this problem) that multiple anonymous records of the same kind getting the same Name, and RecordMap is indexed with it...
We should switch the key of RecordMaps to USR instead probably.

729

nit: normalize

dang updated this revision to Diff 422160.Apr 12 2022, 3:20 AM

Address code review feedback:

  • Normalize test file URIs
  • Key RecordMaps by USR instead of by Name
dang marked 3 inline comments as done.Apr 12 2022, 3:21 AM
dang added inline comments.
clang/test/ExtractAPI/enum.c
702

Agreed, added this to this patch.

zixuw added inline comments.Apr 12 2022, 9:00 AM
clang/test/ExtractAPI/enum.c
702

Nice! Thanks Daniel!
Could you please also update the test case to see if it now handles two anonymous records correctly?

dang updated this revision to Diff 422296.Apr 12 2022, 10:52 AM
dang marked an inline comment as done.

Add a second anonymous enum to the test case to make sure that distinct symbols
are generated for both of them.

zixuw accepted this revision.Apr 12 2022, 10:55 AM

LGTM

This revision is now accepted and ready to land.Apr 12 2022, 10:55 AM
This revision was landed with ongoing or failed builds.Apr 13 2022, 2:31 PM
This revision was automatically updated to reflect the committed changes.