This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Config: config struct propagated through Context
ClosedPublic

Authored by sammccall on Jun 25 2020, 2:47 PM.

Details

Summary

This introduces the "semantic form" of config exposed to features,
contrasted with the "syntactic form" exposed to users in e9fb1506b83d.

The two are not connected, CompiledFragment and Provider will bridge that gap.
Nor is configuration actually set: that needs changes to ClangdServer,
TUScheduler, and BackgroundQueue.

Diff Detail

Event Timeline

sammccall created this revision.Jun 25 2020, 2:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 25 2020, 2:47 PM
sammccall updated this revision to Diff 273543.Jun 25 2020, 3:59 PM

config() -> Config::current(). "config" already names a namespace.

Thanks, LGTM. Just a question around the order of config vs other mangling.

clang-tools-extra/clangd/CompileCommands.cpp
187

what's the rationale behind applying this before any other mangling?

I can see that the rest of the mangling happens to make sure clangd works out-of-the-box for "more" users, so should be safe to apply as a final step.
But on the other hand, applying config after those would give the user full control over the final command, which I believe is equally important.

sammccall marked an inline comment as done.Jun 26 2020, 2:49 AM
sammccall added inline comments.
clang-tools-extra/clangd/CompileCommands.cpp
187

I'll be honest, I don't really know which is better here. The differences are subtle, and there are arguments for each. I think we should probably just pick one and be open to changing it later.

My reasoning for this behavior: currently the user view of compile commands is basically "strings in compile_commands.json", and this mangling we do is best thought of as modifying the behavior of the driver. E.g. in an ideal world -fsyntax-only would not be a flag, we'd just use APIs that imply that behavior.
In this view of the world, the user is expected to understand compile commands + tweaks but not the mangling, so placing tweaks after mangling means they can't really reason about the transformations. And it allows stripping structurally important things we inject like fsyntax-only which seems wrong.

This argument works better for some args/manglings than others, and the way we log args cuts against it a bit too.

kadircet accepted this revision.Jun 26 2020, 7:08 AM

oops, thought I've stamped it last time.

clang-tools-extra/clangd/CompileCommands.cpp
187

SG, as you mentioned in the last paragraph I would be looking at logs to figure out what my compile commands for a file are, but may be it's just me. Hence having this tweaking in the middle was a little bit surprising. (Moreover, if one day we decide to have build system integrations it might imply there won't be any written compile_commands.json, but we'll rather fetch them on the fly and logs might be the only way to look at those commands. Even in such a scenario, I suppose changing the way we log might be a better approach because we indeed do more manipulations even after logging e.g. turning off preamble related options)

This revision is now accepted and ready to land.Jun 26 2020, 7:08 AM
sammccall marked 2 inline comments as done.Jun 29 2020, 11:18 AM
sammccall added inline comments.
clang-tools-extra/clangd/CompileCommands.cpp
187

Yeah logging earlier would be nice but there's a layering problem - CDB doesn't know if this is a file we're actually editing, and we only want to log if it is. I think this is annoying, but not urgent to solve.

This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.

Thanks, reverted and looking into it.