This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExtractAPI] Don't print locations for anonymous tags
ClosedPublic

Authored by zixuw on Oct 5 2022, 11:14 AM.

Details

Summary

ExtractAPI doesn't care about locations of anonymous TagDecls. Set the
printing policy to exclude that from anonymous decl names.

Diff Detail

Event Timeline

zixuw created this revision.Oct 5 2022, 11:14 AM
Herald added a reviewer: ributzka. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ributzka. · View Herald Transcript
zixuw requested review of this revision.Oct 5 2022, 11:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 11:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
zixuw updated this revision to Diff 465486.Oct 5 2022, 11:37 AM

Set PrintingPolicy properly

This doesn't affect any tests?

sammccall accepted this revision.Oct 5 2022, 11:55 AM

LG from my side assuming you're happy with the strings changing.

This doesn't affect any tests?

This doesn't affect tests because anonymous decls currently print as the empty string, but will soon print as (unnamed struct at /path/foo.cpp:4:1) without this patch, or (unnamed struct) with this patch.

clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
854

nit: this isn't *just* clearing AnonymousTagLocations, but also resetting any other PP flags to defaults based on LangOpts. You could getPrintingPolicy() instead if you didn't intend to do this.

This revision is now accepted and ready to land.Oct 5 2022, 11:55 AM
zixuw added a comment.Oct 5 2022, 12:20 PM

This doesn't affect any tests?

Just finished building locally, running tests to verify now

zixuw added inline comments.Oct 5 2022, 12:24 PM
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
854

Makes sense. Probably doesn't matter because I'm pretty sure PrintingPolicy for ExtractAPI is just the default now. Still, good to use getPrintingPolicy to be sure

zixuw updated this revision to Diff 465505.Oct 5 2022, 12:28 PM

Update on top of the existing PrintingPolicy in the ASTContext instead of creating a new default one.

zixuw marked an inline comment as done.Oct 5 2022, 12:30 PM

This doesn't affect any tests?

Just finished building locally, running tests to verify now

Doesn't affect any test for this patch as expected. Still need to see how does it interacts with https://reviews.llvm.org/D134813.

zixuw added a comment.Oct 5 2022, 1:09 PM

This doesn't affect any tests?

Just finished building locally, running tests to verify now

Doesn't affect any test for this patch as expected. Still need to see how does it interacts with https://reviews.llvm.org/D134813.

Interaction with D134813 looks good. Landing this

This revision was landed with ongoing or failed builds.Oct 5 2022, 1:11 PM
This revision was automatically updated to reflect the committed changes.