This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add beforeExecute() callback to FeatureModules.
ClosedPublic

Authored by adamcz on Apr 21 2022, 7:29 AM.

Details

Summary

It runs immediatelly before FrontendAction::Execute() with a mutable
CompilerInstance, allowing FeatureModules to register callbacks, remap
files, etc.

Diff Detail

Event Timeline

adamcz created this revision.Apr 21 2022, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2022, 7:29 AM
adamcz requested review of this revision.Apr 21 2022, 7:29 AM
kadircet accepted this revision.Apr 21 2022, 8:02 AM

thanks, lgtm!

clang-tools-extra/clangd/FeatureModule.h
109

nit: triple slashes

109

comment still says preamble build. I'd either talk more about Allows customizing the compiler instance before starting the execution on input or get rid of CompilerInvocation in that list. as in theory modifications to only parts of it will be respected (since we've already issued beginsourcefile on compiler instance and created some structs with whatever we had in compiler invocation prior to this call).

clang-tools-extra/clangd/ParsedAST.cpp
553

could you have a comment that says we must perform this after Action::BeginSourceFile to ensure PP and rest of the helper structs are initialized and closer to the end so that other modifications we do in clangd (like adjusting diag severities/marking main file as include-guarded) is visible to modules?

to make sure it doesn't get moved around without these in mind.

clang-tools-extra/clangd/Preamble.cpp
72

nit: std::move

117

could we move this to the bottom, to make it closer to the way parsedast calls it?

488

nit: drop braces

This revision is now accepted and ready to land.Apr 21 2022, 8:02 AM
adamcz updated this revision to Diff 424215.Apr 21 2022, 8:51 AM
adamcz marked 5 inline comments as done.

addressed review comments

This revision was landed with ongoing or failed builds.Apr 21 2022, 9:04 AM
This revision was automatically updated to reflect the committed changes.