This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExtractAPI] Refactor serializer to the CRTP
ClosedPublic

Authored by evelez7 on May 25 2023, 11:22 AM.

Details

Summary

Refactor SerializerBase and SymbolGraphSerializer to use a visitor pattern described by the CRTP.

Diff Detail

Event Timeline

evelez7 created this revision.May 25 2023, 11:22 AM
Herald added a project: Restricted Project. · View Herald Transcript
evelez7 requested review of this revision.May 25 2023, 11:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 11:22 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dang added a comment.May 26 2023, 8:12 AM

LGTM with minor changes

clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
58

It would be nice to keep this as default, i.e.

~APISetVisitor() = default;
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
20

In LLVM we tend to explicitly include any header we use and we definitely use the definitions ins API.h

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
748

This isn't part of the visitation scheme but more of a way of serializing a single record. I would prefer to keep this as serializeSingleRecord

808

Does this need to be explicit like this? Would it not work to just call traverseAPISet(); since we would inherit it through inheritance.

evelez7 updated this revision to Diff 526148.May 26 2023, 11:52 AM

Address review feedback

dang accepted this revision.May 30 2023, 7:29 AM
This revision is now accepted and ready to land.May 30 2023, 7:29 AM
This revision was automatically updated to reflect the committed changes.
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h