Skip to content

Use the clang-tidy version in use for check documentation links - #14830

Open
Abdelhadi Salmaoui (abdelhadi703) wants to merge 2 commits into
microsoft:mainfrom
abdelhadi703:fix/clang-tidy-doc-version
Open

Abdelhadi Salmaoui (abdelhadi703) wants to merge 2 commits into
microsoft:mainfrom
abdelhadi703:fix/clang-tidy-doc-version

Conversation

@abdelhadi703

@abdelhadi703 Abdelhadi Salmaoui (abdelhadi703) commented Oct 11, 2026 •

Copy link
Copy Markdown

Every clang-tidy diagnostic carries a link to the documentation of the check, and that link is built from a hardcoded LLVM release (currently 23.1.0). A check that only exists in a newer clang-tidy therefore gets a dead link. #12804 reported exactly this after moving from clang-tidy 18 to 19 and seeing the link stuck on the 18.1.6 page.

settings.ts already works out which clang-tidy will be used -- the bundled one or the one found on PATH -- and compares their versions, but it discarded the version afterwards. I keep it cached next to the clang-tidy path and read it back when the link is built, so the URL points at the release the running binary actually comes from. When the version could not be determined (the user set codeAnalysis.clangTidy.path explicitly, or the binary could not be executed), the link falls back to the bundled release, i.e. the previous behaviour.

The documentation is published per major release rather than per patch: 23.1.0 and 22.1.0 answer, while 23.1.1 and 22.1.3 have no page at all. The version in use is therefore reduced to its major's .1.0 release before it goes into the URL -- otherwise going from 23.1.0 to 23.1.1 would swap a working link for a 404.

The thread also mentions the version-independent documentation URLs, and that is a fair alternative -- it takes the version out of the URL for good. I went with the version in use because that is what the issue title asks for, and because the version-less page always describes the newest release: for someone on an older clang-tidy it links to checks their binary does not have, which is the same kind of mismatch in the other direction. That is a judgement call rather than a certainty, so say the word if you prefer the version-less URL -- it is a much smaller change than this one.

The URL construction now lives in LanguageServer/clangTidyDocumentation.ts and is covered by test/unit/clangTidyDocumentation.test.ts: the version in use, a patch release mapping to its major's .1.0, no version, and a malformed version. It runs with the other unit tests through yarn test. I also ran those cases directly in node, since the extension test harness installs its packages from the private Azure feed and I don't have access to it here.

No CHANGELOG entry: those are written separately before a release.

Fixes #12804.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The global cache can select the wrong workspace version, and the fallback is already behind the bundled clang-tidy release.

2 open findings
What changed in this PR

Updates clang-tidy diagnostic links to target documentation matching the selected binary version.

Changes:

  • Caches the detected clang-tidy version.
  • Centralizes documentation URL generation with fallback handling.
  • Adds unit tests and a changelog entry.
File Description
Extension/​src/​common.ts Adds the version cache.
Extension/​src/​LanguageServer/​settings.ts Captures the selected clang-tidy version.
Extension/​src/​LanguageServer/​codeAnalysis.ts Uses version-aware documentation URLs.
Extension/​src/​LanguageServer/​clangTidyDocumentation.ts Builds documentation URLs.
Extension/​test/​unit/​clangTidyDocumentation.test.ts Tests URL generation and fallback behavior.
Extension/​CHANGELOG.md Documents the fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Extension/src/LanguageServer/clangTidyDocumentation.ts
}
// TODO: This should be checking the clang-tidy version used to better support usage of older versions.
const primaryDocUri: vscode.Uri = vscode.Uri.parse(`https://releases.llvm.org/23.1.0/tools/clang/tools/extra/docs/clang-tidy/${docPage}`);
const primaryDocUri: vscode.Uri = vscode.Uri.parse(getClangTidyDocumentationUrl(docPage, new CppSettings().clangTidyVersion));

@sean-mcmanus Sean McManus (sean-mcmanus) left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version of clang-format/clang-tidy might not have docs -- I believe usually only the major.1.0 version has the docs.

Comment thread Extension/CHANGELOG.md Outdated
* Reduce CPU usage when resolving headers in large Windows workspaces.

### Bug Fixes
* Fix clang-tidy check documentation links pointing at the bundled LLVM release instead of the clang-tidy version in use. [#12804](https://github.com/microsoft/vscode-cpptools/issues/12804)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We update the changelog ourselves in a separate PR before the release.

Comment thread Extension/src/LanguageServer/clangTidyDocumentation.ts
Only the .1.0 release of each major has a published documentation page: 23.1.0 and 22.1.0
answer, 23.1.1 and 22.1.3 return 404. The version in use is reduced to its major.1.0 release
before it goes into the URL.

Also drops the changelog entry, since those are written separately before a release, and stops
reporting the cached version for a resource that sets its own codeAnalysis.clangTidy.path --
that cached version comes from a binary the resource is not running.
@abdelhadi703

Copy link
Copy Markdown
Author

Right on both counts.

On the version: I checked, and only the .1.0 release of each major has a page -- 23.1.0 and 22.1.0 return 200, 23.1.1 and 22.1.3 return 404. The version in use is now reduced to its major's .1.0 release before it goes into the URL, so 23.1.1 maps to 23.1.0 and 22.1.3 to 22.1.0. A test pins both, plus the fallback cases. That is the fix the suggestion above would have broken.

The changelog entry is gone.

One more thing I changed while I was in there: the version was read from a process-global cache, so a folder carrying its own codeAnalysis.clangTidy.path inherited the version auto-discovered for some other folder. The getter now reports no version for a resource that sets its own path, so that folder's links fall back instead of pointing at a release its binary is not running.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The globally cached documentation code action can return the wrong release URL across resources or after settings changes.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

}
// TODO: This should be checking the clang-tidy version used to better support usage of older versions.
const primaryDocUri: vscode.Uri = vscode.Uri.parse(`https://releases.llvm.org/23.1.0/tools/clang/tools/extra/docs/clang-tidy/${docPage}`);
const primaryDocUri: vscode.Uri = vscode.Uri.parse(getClangTidyDocumentationUrl(docPage, new CppSettings(realUri).clangTidyVersion));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

Links to docs for clang-tidy checks are for the bundled version instead of the used version.

3 participants