This is an archive of the discontinued LLVM Phabricator instance.

[clangd] UnusedIncludes: Strict config now uses the include-cleaner-library implementation.
ClosedPublic

Authored by hokein on Mar 10 2023, 1:36 AM.

Details

Summary

And remove the classical clangd-own unused-include implementation.

Diff Detail

Event Timeline

hokein created this revision.Mar 10 2023, 1:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2023, 1:36 AM
Herald added a subscriber: arphaman. · View Herald Transcript
hokein requested review of this revision.Mar 10 2023, 1:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2023, 1:36 AM
kadircet added inline comments.Mar 10 2023, 1:50 AM
clang-tools-extra/clangd/ConfigCompile.cpp
433

i think we should at least be emitting a diagnostics to encourage people for moving back to strict, so what about something like:

if (F.UnusuedIncludes) {
  auto Val = compileEnum....; // only for Strict and None
  if (!Val && **F.UnusedIncludes == "Experiment") {
       diag(Warning, "Experiment is deprecated for UnusedIncludes, use Strict instead.", F.UnusedIncludes.Range);
       Val = Config::IncludesPolicy::Strict;
  }
}
clang-tools-extra/clangd/IncludeCleaner.cpp
769

can you also delete computeUnusedIncludes and its friends (also from the tests)?

hokein updated this revision to Diff 504069.Mar 10 2023, 2:32 AM
hokein marked an inline comment as done.

Add diagnostic for Experiment flag usage.

clang-tools-extra/clangd/ConfigCompile.cpp
433

I thought it was not worth a diagnostic because this flag was introduced recently, and we have never advertised it to open-source users.

But the flag is in the recent clangd16 release, so it probably justifies the value.

BTW, looks like we forgot to update the release notes for clangd16, https://github.com/llvm/llvm-project/blob/release/16.x/clang-tools-extra/docs/ReleaseNotes.rst#improvements-to-clangd is empty.

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

this is in plan, but in a separate patch, https://reviews.llvm.org/D145776

kadircet accepted this revision.Mar 10 2023, 2:35 AM
kadircet added inline comments.
clang-tools-extra/clangd/ConfigCompile.cpp
433

But the flag is in the recent clangd16 release, so it probably justifies the value.

right.

BTW, looks like we forgot to update the release notes for clangd16, https://github.com/llvm/llvm-project/blob/release/16.x/clang-tools-extra/docs/ReleaseNotes.rst#improvements-to-clangd is empty.

yeah, i've aslo noticed that will take a look. but regarding this feature, I don't think we should be advertising Experiment there, right?

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

as mentioned on that patch, i think it's better to land them in single step, to make sure we can revert a single patch if we want the old behavior rather than multiple.

This revision is now accepted and ready to land.Mar 10 2023, 2:35 AM
hokein updated this revision to Diff 504073.Mar 10 2023, 2:39 AM

add the removal of the clangd-own implementation.

hokein edited the summary of this revision. (Show Details)Mar 10 2023, 2:45 AM
This revision was landed with ongoing or failed builds.Mar 10 2023, 2:56 AM
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.