This is an archive of the discontinued LLVM Phabricator instance.

[clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations
ClosedPublic

Authored by kbobyrev on Oct 13 2021, 5:58 AM.

Diff Detail

Event Timeline

kbobyrev created this revision.Oct 13 2021, 5:58 AM
kbobyrev requested review of this revision.Oct 13 2021, 5:58 AM
kbobyrev planned changes to this revision.Oct 13 2021, 6:07 AM
kbobyrev updated this revision to Diff 379367.Oct 13 2021, 7:10 AM

Make the logic correct.

kbobyrev updated this revision to Diff 379664.Oct 14 2021, 4:35 AM

Only get function redecls as used for definition.

kbobyrev retitled this revision from [clangd] IncludeCleaner: ReferencedLocationCrawler should handle FunctionDecls to [clangd] IncludeCleaner: Don't consider the definition as usage for function forward declarations.Oct 24 2021, 11:16 PM
kbobyrev edited reviewers, added: kadircet; removed: sammccall.
kbobyrev added a subscriber: sammccall.
kadircet accepted this revision.Oct 26 2021, 1:17 AM

thanks, lgtm!

clang-tools-extra/clangd/IncludeCleaner.cpp
42

i've got a feeling that this might have nasty side effects in the presence of functions with defaulted-arguments, but they're pretty obscure (like declare a function with a default parameter in a header, then in the main file both include the header and have a forward declaration of the function, now that forward declaration can't have the default parameter because the one in the header has. but who does that really). so i suppose it won't result in any false positives in practice.

This revision is now accepted and ready to land.Oct 26 2021, 1:17 AM