Skip to content

chore: bump LLVM to 77e43ec1 (May 21, 2026)#1241

Open
gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:chore/bump_llvm_for_macro_comment_support
Open

chore: bump LLVM to 77e43ec1 (May 21, 2026)#1241
gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:chore/bump_llvm_for_macro_comment_support

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

The new pin includes llvm/llvm-project#198452, which attaches documentation comments to macro definitions. That is the prerequisite for reading them from Clang directly instead of scanning the source, as we were initially doing in PR #1192.

Changes

  • Third-party: Bump LLVM to 77e43ec1 (Associate documentation comments with macro definitions llvm/llvm-project#198452).

  • CI: Update the hardcoded LLVM hash in the cache key (ci-matrix.yml) and its mirror unit test (test_cache_keys.py) to match the new pin, so the key misses and LLVM builds fresh instead of restoring the old install. Build an instrumented libc++ for MSan only (the newer libc++ needs the latest Clang, and ASan works with the normal libc++), and prune the LLVM source tree's stray .profraw fixtures.

  • Source: The pin was about six months behind, so this also adapts MrDocs to the Clang API changes across that range:

    • USRGeneration.h moved from clang/Index to clang/UnifiedSymbolResolution; the clang::index namespace and signatures are unchanged.
    • clang::DiagnosticConsumer::finish() was removed, so the collecting diagnostic consumer relies on the forwarded EndSourceFile() instead.
    • The driver option table moved to clang/Options/Options.h, with its enumerators now in clang::options and getDriverOptTable() in clang.
    • cl::getRegisteredOptions() now returns a DenseMap, so its entries expose .second instead of getValue().
    • SubstituteConstraintExpressionWithoutSatisfaction was re-synced with Clang's current implementation.

    getRawCommentForDeclNoCache, the per-declaration comment lookup getDocumentation relied on, is no longer public. Its only public replacement, getRawCommentForAnyRedecl, follows the redeclaration chain and so cannot return a single declaration's own comment. getDocumentation keeps the per-declaration behavior by porting Clang's declaration-path comment search (getLocsForCommentSearch and getRawCommentNoCacheImpl) as file-local helpers.

    Parsing the newer libc++ also needs a new vcruntime_new.h stub and C++ guards so stdbool.h, stdalign.h, and threads.h stop redefining bool, alignas, and thread_local, which are keywords, not macros, in C++.

  • Golden tests: The regenerated goldens change only because Clang's output drifted over the six months: constrained templates and destructors get different symbol IDs from USR generation, though their structure is identical (requires-clause, dtor-overloads), and a few declaration locations shifted by a line or column (auto, param-types, function-template).

Testing

No new tests are added; this is a toolchain bump. The existing unit and golden suites already cover the affected behavior and run in CI on every build, and the goldens whose output changed have been regenerated as described above.

Documentation

No documentation changes are needed: this is an internal toolchain bump with no user-facing API changes.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🛠️ Source 84% 656 453 203 10 1 9 - -
🔧 Toolchain Tests 6% 46 23 23 2 - 2 - -
🥇 Golden Tests 5% 38 19 19 5 - 5 - -
⚙️ CI 3% 25 16 9 2 - 2 - -
🔧 Toolchain 1% 7 4 3 1 - 1 - -
🧪 Unit Tests 1% 6 3 3 1 - 1 - -
🤝 Third-party 1% 6 3 3 1 - 1 - -
Total 100% 784 521 263 22 1 21 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • src/lib/AST/ClangHelpers.cpp (Source): 286 lines Δ (+259 / -27)
  • src/lib/MrDocsCompilationDatabase.cpp (Source): 274 lines Δ (+137 / -137)
  • share/mrdocs/headers/libc-stubs/vcruntime_new.h (Source): 41 lines Δ (+41 / -0)

Generated by 🚫 dangerJS against feddc6f

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.10%. Comparing base (197e765) to head (feddc6f).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1241      +/-   ##
===========================================
- Coverage    83.16%   83.10%   -0.06%     
===========================================
  Files           35       35              
  Lines         3658     3658              
  Branches       843      843              
===========================================
- Hits          3042     3040       -2     
- Misses         409      410       +1     
- Partials       207      208       +1     
Flag Coverage Δ
bootstrap 83.10% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

cppalliance-bot commented Jul 2, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1241.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-07-07 10:40:47 UTC

@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch 4 times, most recently from 9c7fcf4 to c7b6850 Compare July 7, 2026 06:06
The new pin includes llvm/llvm-project#198452, which attaches
documentation comments to macro definitions. That is the prerequisite
for reading them from Clang directly instead of scanning the source, as
we were initially doing in PR cppalliance#1192.

The pin was about six months behind, so this also adapts MrDocs to the
Clang API changes across that range:

- USRGeneration.h moved from clang/Index to
  clang/UnifiedSymbolResolution; the `clang::index` namespace and
  signatures are unchanged.
- `clang::DiagnosticConsumer::finish()` was removed, so the collecting
  diagnostic consumer relies on the forwarded `EndSourceFile()` instead.
- The driver option table moved to clang/Options/Options.h, with its
  enumerators now in `clang::options` and `getDriverOptTable()` in
  `clang`.
- `cl::getRegisteredOptions()` now returns a `DenseMap`, so its entries
  expose `.second` instead of `getValue()`.
- `SubstituteConstraintExpressionWithoutSatisfaction` was re-synced with
  Clang's current implementation.

`getRawCommentForDeclNoCache`, the per-declaration comment lookup
`getDocumentation` relied on, is no longer public. Its only public
replacement, `getRawCommentForAnyRedecl`, follows the redeclaration
chain and so cannot return a single declaration's own comment.
`getDocumentation` keeps the per-declaration behavior by porting Clang's
declaration-path comment search (`getLocsForCommentSearch` and
`getRawCommentNoCacheImpl`) as file-local helpers.

Parsing the newer libc++ also needs a new vcruntime_new.h stub and C++
guards so stdbool.h, stdalign.h, and threads.h stop redefining `bool`,
`alignas`, and `thread_local`, which are keywords, not macros, in C++.

The regenerated goldens change only because Clang's output drifted over
the six months: constrained templates and destructors get different
symbol IDs from USR generation, though their structure is identical
(requires-clause, dtor-overloads), and a few declaration locations
changed.
MemorySanitizer needs an instrumented libc++. The pinned libc++ no
longer compiles with Clang 20, so the MSan job now builds it with the
latest Clang.

AddressSanitizer works against a normal libc++, as the Apple-Clang ASan
job already does, so it never needed an instrumented one - and it can no
longer use one anyway: an ASan-instrumented libc++ requires its
consumers to compile with ASan, but MrDocs parses libcxx.cpp with
normal, non-ASan flags, and libc++'s container-check self-guard (added
upstream in llvm/llvm-project#168955) rejects that parse.

`needs_libcxx_runtimes` therefore returns true for MSan only. The matrix
values that appeared to control this (`use-libcxx`, `libcxx-runtimes`,
`llvm-runtimes`) were never consumed, so I dropped them.
The coverage step globs build/ for *.profraw, which after the bump also
holds the extracted LLVM source tree. That tree ships llvm-profdata test
fixtures in an older raw-profile version that llvm-profdata rejects,
failing the merge. Delete build/third-party profraw first; MrDocs' own
profraw live elsewhere under build/.
@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch from c7b6850 to feddc6f Compare July 7, 2026 10:29

@alandefreitas alandefreitas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice bump :)

Reimplementing rawCommentForDecl ourselves ended up a little verbose. We could add the pinned commit (77e43ec1) to the comment on locsForCommentSearch so the next bump can compare the port against the exact revision it came from. We could also check why they removed it in their PRs, issues and git blame (doing that might even reveal a better way of doing things) and we should consider filing an issue upstream asking to re-expose a per-declaration lookup (making getRawCommentNoCache public would do). If Clang takes it, we can delete the port on a later bump.

# *.profraw.
- name: Prune third-party profraw
if: matrix.coverage
run: find build/third-party -name '*.profraw' -delete

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What’s this profraw issue? The explanation is more descriptive than explanatory of the motivation of the command. It seems to me like if this is happening and coverage is globing the wrong directory, that’s what should be fixed instead of a second workaround to accommodate the first mistake.

standards: '23'
main-entry-factors: |
clang Coverage
# MSan builds an instrumented libc++ from the pinned LLVM sources,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don’t like some of the excessive comments that likely come from using AI. The thing with AI is that it doesn’t know how to not say things. For instance, you tell AI to not say “X” and very often it gives you text like “I’m not even going to bring up X”.

Because it’s a text-generating machine. It has no button for not generating text.

For instance, in this particular PR, it’s obvious AI was moving MSan to latest-factors and felt like it just to justify this in a comment. The comment is coherent with what it had in its context but it’s not coherent with the rest of the code. After this is merged, a person reading this file doesn’t know this context. This looks like it’s documentation for latest-factors and makes no sense there. The user wouldn’t even know this option was not in latest-factors before. The user won’t understand why msan and not latest-factors is explained here. They won’t understand why this is the only factor singled-out and so on.

append-common-cxxflags: |
clang: -gz=zstd
extra-values: |
# libc++ runtimes: clang + (ASan or MSan) needs instrumented libc++

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why are these gone? Weren't they being used? Interesting. I thought we used the custom libc++ whenever we had msan or asan. It it because the logic for this necessity is now being checked in the bootstrap script?

// Non-allocating placement allocation functions
void* operator new ( std::size_t count, void* ptr );
void* operator new[]( std::size_t count, void* ptr );
#include <vcruntime_new.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Interesting. Is this something being fixed in passing or do we have something about the new version that interacts with the libc stubs? In fact, I would have this question about all other changes to the libc stubs. It's unexpected to me that they interacted in an LLVM bump.

<source-path>function-template.cpp</source-path>
<line-number>22</line-number>
<column-number>6</column-number>
<column-number>1</column-number>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These changes to line numbers and column numbers are curious. Since the fixtures didn't change, we need to check whether they were broken before or whether they're broken now. Or maybe they're referencing a different part of the symbol.

return False
san = sanitizer_flag_name(sanitizer.lower())
if san not in ("address", "memory"):
if san != "memory":

@alandefreitas alandefreitas Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We could discuss this with Matheus, but I believe the changes to this file are incorrect. At the very least we lose some std lib annotations, and so on. ASan doesn't need sanitized dependencies as much as MSan but it's less effective without sanitized dependencies. And we're building+caching our own libc++ anyway so the cost is low.

#ifndef MRDOCS_SHARE_HEADERS_LIBC_STUBS_VCRUNTIME_NEW_H
#define MRDOCS_SHARE_HEADERS_LIBC_STUBS_VCRUNTIME_NEW_H

// libc++ includes this Microsoft runtime header (through <__new/align_val_t.h>)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This whole comment, especially "Provide just enough of it for parsing." seems redundant because this is true for all stubs by definition. They're headers libc++ includes for its own functionality and we provide only enough for parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants