[clang-tools-extra] [clangd] Extend FeatureModule hooks (PR #221054)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 19 02:03:14 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang-tools-extra/clangd/Diagnostics.cpp clang-tools-extra/clangd/Diagnostics.h clang-tools-extra/clangd/FeatureModule.h clang-tools-extra/clangd/ParsedAST.cpp clang-tools-extra/clangd/Preamble.cpp clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clangd/FeatureModule.h b/clang-tools-extra/clangd/FeatureModule.h
index 7d728a7a5..90714fe91 100644
--- a/clang-tools-extra/clangd/FeatureModule.h
+++ b/clang-tools-extra/clangd/FeatureModule.h
@@ -112,9 +112,10 @@ public:
/// are set up, but before clangd installs its include and macro collectors.
/// Modules should only use this when their PPCallbacks must observe
/// preamble events replayed during a main-file build.
- /// Reusing a preamble skips the main file's initial preprocessing directives.
- /// ReplayPreamble synthesizes callbacks for selected events from that region
- /// and captures their recipients before beforeExecute() is called.
+ /// Reusing a preamble skips the main file's initial preprocessing
+ /// directives. ReplayPreamble synthesizes callbacks for selected events
+ /// from that region and captures their recipients before beforeExecute() is
+ /// called.
virtual void beforePPCallbacks(CompilerInstance &CI) {}
/// Called before every AST build, both for main file and preamble. The call
diff --git a/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp b/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
index 9565adbce..5da3dec41 100644
--- a/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
@@ -142,12 +142,12 @@ TEST(FeatureModulesTest, BeforePPCallbacks) {
std::vector<std::string> Includes;
auto Module = std::make_unique<TestModule>();
Module->BeforePPCallbacks = [&Includes](CompilerInstance &CI) {
- // The preamble build processes the main file's initial directives, including
- // #include "header.h", and the included header's contents. The main-file
- // build reuses that preamble and skips those directives. ReplayPreamble
- // synthesizes InclusionDirective callbacks for the saved direct includes.
- // Register only during the main-file build to observe this replay, rather
- // than the original include during preamble construction.
+ // The preamble build processes the main file's initial directives,
+ // including #include "header.h", and the included header's contents. The
+ // main-file build reuses that preamble and skips those directives.
+ // ReplayPreamble synthesizes InclusionDirective callbacks for the saved
+ // direct includes. Register only during the main-file build to observe this
+ // replay, rather than the original include during preamble construction.
if (CI.getFrontendOpts().ProgramAction == frontend::ParseSyntaxOnly)
CI.getPreprocessor().addPPCallbacks(
std::make_unique<IncludeRecorder>(Includes));
``````````
</details>
https://github.com/llvm/llvm-project/pull/221054
More information about the cfe-commits
mailing list