This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExtractAPI] Modify declaration fragment methods to add a new fragment at an arbitrary offset.
ClosedPublic

Authored by Ruturaj4 on May 21 2023, 10:44 AM.

Details

Summary

The current implementation doesn't support merging declaration fragments at arbitrary offsets. This patch adds that support
by modifying declaration fragment methods.

Diff Detail

Event Timeline

Ruturaj4 created this revision.May 21 2023, 10:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
Ruturaj4 requested review of this revision.May 21 2023, 10:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2023, 10:44 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dang requested changes to this revision.May 23 2023, 7:50 AM
dang added inline comments.
clang/include/clang/ExtractAPI/DeclarationFragments.h
102–120

This shouldn't need to be part of the public interface of the DeclarationFragments type and can just be a static function in DeclarationFragments.cpp.

114

Is this parameter intmax_t to allow negative indices? If so I really don't think it's a good idea. I would prefer if we exposed an iterator interface to DeclarationFragments to make the API more like that of a vector type. (The iterator would just need to be the iterator for the underlying vector).

clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
119

I don't think the API naming makes it clear that you can and what it means to insert at a negative offset. I would much rather we had an iterator based interface and didn't necessarily do chained calls. It could look something like this:

auto &DeclFrag = Record.second->Declaration;
DeclFrag.insert(DeclFrag.begin(), "typedef", DeclarationGragments::FragmentKind::Keyword, "", nullptr);
// the rest of the code
This revision now requires changes to proceed.May 23 2023, 7:50 AM
Ruturaj4 marked 3 inline comments as done.May 27 2023, 4:54 PM

Daniel, I made all the changes as you desired, thanks.

Ruturaj4 updated this revision to Diff 526296.May 27 2023, 4:56 PM
  1. Updating D151048: [clang][ExtractAPI] Modify declaration fragment methods to add a new fragment at an arbitrary offset. #
  2. Enter a brief description of the changes included in this update.
  3. The first line is used as subject, next lines as comment. #
  4. If you intended to create a new revision, use:
  5. $ arc diff --create

I made all the suggested changes.

dang accepted this revision.May 30 2023, 7:27 AM
This revision is now accepted and ready to land.May 30 2023, 7:27 AM
This revision was landed with ongoing or failed builds.May 30 2023, 3:31 PM
This revision was automatically updated to reflect the committed changes.