This is an archive of the discontinued LLVM Phabricator instance.

[clangd] ExternalIndex turns off BackgroundIndex only if it isn't set
Needs ReviewPublic

Authored by kadircet on Nov 4 2020, 10:29 AM.

Details

Reviewers
sammccall
Summary

This will enable users to have a Background: Build in their in-project
configs, while having an external index specification in their user
config file.

Depends on D90749.

Diff Detail

Event Timeline

kadircet created this revision.Nov 4 2020, 10:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2020, 10:29 AM
kadircet requested review of this revision.Nov 4 2020, 10:29 AM

I'm not sure we should do this - it complicates the model substantially (I don't think I could explain it to a user), and it still leaves surprising cases.

I'm not sure config is the place for a lot of magic do-what-I-mean behavior - it's the place where the user overrides such behaviors.

(If you think the combinations are too confusing, we could consider *not* disabling background index implicitly for external indexes, and simply warning instead)

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

This is vague and hard to specify more precisely.

308

doesn't this mean that if a user has explicit Background: Build at a higher scope, then a more narrowly scoped external index won't disable it?

This seems at least as confusing as the problems this is trying to solve.

kadircet added inline comments.Nov 9 2020, 1:45 PM
clang-tools-extra/clangd/ConfigCompile.cpp
308

doesn't this mean that if a user has explicit Background: Build at a higher scope, then a more narrowly scoped external index won't disable it?

Yes. The motivating case I had was something like this:

  • Let's say user turns background-index on inside llvm-project/clang-tools-extra/clangd/.clangd.
  • Defines an external index via user-config for llvm-project.

Since user-config is the inner-most provider, it will turn off the backgrond-indexing implicitly for the whole project, and user won't be able to turn it on for a subdirectory without specifying that in user-config directory too.

sammccall added inline comments.Nov 24 2020, 7:02 AM
clang-tools-extra/clangd/ConfigCompile.cpp
308

In that scenario, I'm not sure whether the user wants background indexing on or not. (e.g. more likely *someone else* turned it on in the project config, who wasn't aware of the user config).

Maybe there's a principle here that project config for an inner directory is actually more specific and therefore should take precedence over user config for an outer directory? That seems like it might be at least as useful as the current behavior, but we shouldn't be implementing it setting-by-setting.

ormris removed a subscriber: ormris.Jun 3 2021, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2021, 2:15 PM