Skip to content

build: update llvm to 21.1.4 - #292

Merged
16bit-ykiko merged 7 commits into
mainfrom
update-llvm
Nov 2, 2025
Merged

16bit-ykiko merged 7 commits into
mainfrom
update-llvm

Conversation

@16bit-ykiko

@16bit-ykiko 16bit-ykiko commented Nov 2, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Expanded code-completion coverage for additional declaration kinds
  • Bug Fixes

    • Safer handling for templates without identifiers
    • Improved resource directory resolution and updated library paths
  • Refactor

    • Upgraded LLVM support to 21.1.4 with explicit versioning
    • Modernized diagnostic ownership and compiler diagnostics wiring
    • Simplified nested-name handling and tidy configuration
  • Chores

    • Updated prebuilt LLVM assets (filenames & checksums) and generalized clang install paths
    • Pinned build tool version in CI and disabled package cache; simplified test/run args
  • Tests

    • Updated and added tidy unit tests and expectations

@coderabbitai

coderabbitai Bot commented Nov 2, 2025 •

Copy link
Copy Markdown

Walkthrough

CMake now requires an explicit LLVM_VERSION and generalizes clang copy/install paths; prebuilt LLVM assets bumped to 21.1.4. Diagnostics factory returns std::unique_ptr and compilation wiring updated for ownership. Dependent-template lookup is name-guarded; resource dir paths move to lib/clang/21 and related tidy/index/compiler tweaks applied.

Changes

Cohort / File(s) Change Summary
CMake / LLVM packaging
CMakeLists.txt, cmake/llvm_setup.cmake, cmake/package.cmake, config/prebuilt-llvm.json, xmake.lua
Setup functions now accept an explicit LLVM_VERSION; package calls setup_llvm("21.1.4"); prebuilt asset metadata updated to 21.1.4 (filenames & SHA256s); clang copy/install generalized to copy clang/* and install under lib/clang/; xmake selection and test runargs adjusted.
Resource path
include/Support/FileSystem.h
init_resource_dir return type changed to std::expected<void, std::string>; error payloads now formatted strings; resource path updated from lib/clang/20 to lib/clang/21.
Diagnostic ownership & wiring
include/Compiler/Diagnostic.h, src/Compiler/Diagnostic.cpp, src/Compiler/Compilation.cpp
Diagnostic::create now returns std::unique_ptr<DiagnosticCollector> (uses make_unique and moves diagnostics); Compilation updated to use diagnostic consumer unique_ptr, transfer ownership via release()/moves, and move diagnostics into CompilationUnit.
AST resolver & semantics
include/AST/Resolver.h, include/AST/Semantic.h, src/AST/Resolver.cpp
Dependent-template specialization lookup now extracts and guards template names via getDependentTemplateName(); removed explicit TypeSpecWithTemplate case; DependentTemplateStorage and prefix construction updated to use storage's type pointer.
Tidy, Directive, tests
src/Compiler/Tidy.cpp, src/Compiler/Directive.cpp, tests/unit/Compiler/Tidy.cpp
Tidy diagnostics/context wiring adjusted; static init simplified; module import iteration switched to value semantics and .getLoc() usage; tests renamed/updated and a new Tidy test added asserting diagnostics.
Index & Feature tweaks
src/Index/USRGeneration.cpp, src/Feature/CodeCompletion.cpp
Trailing-requires captured by reference; SVE include macro changed; dependent-template identifier emission now uses DT->getName().getIdentifier(); added additional Decl kinds to an unreachable branch in completionKind.
CI / Build tools
.github/workflows/xmake.yml
Fixed xmake-version to 3.0.0 (replaced branch ref) and disabled xmake package cache across jobs.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant CMake as cmake/llvm_setup.cmake
    participant Remote as prebuilt-llvm.json
    participant FS as Filesystem/install

    Dev->>CMake: setup_llvm(LLVM_VERSION)
    CMake->>Remote: lookup assets for LLVM_VERSION
    Remote-->>CMake: asset metadata
    CMake->>CMake: fetch/install archive
    CMake->>FS: copy/install `clang/*` -> `lib/clang/` (generalized)
    CMake-->>Dev: LLVM configured for LLVM_VERSION
Loading
sequenceDiagram
    participant Caller
    participant Compilation as src/Compiler/Compilation.cpp
    participant DiagFactory as Diagnostic::create
    participant DiagConsumer as DiagnosticCollector (unique_ptr)
    participant Instance as CompilerInstance

    Caller->>Compilation: prepare diagnostics vector
    Compilation->>DiagFactory: Diagnostic::create(diagnostics)
    DiagFactory-->>DiagConsumer: returns std::unique_ptr
    rect rgb(235,245,255)
      Note over DiagConsumer,Instance: ownership transfer via release()/move
    end
    Compilation->>Instance: createDiagnostics(..., DiagConsumer.release())
    Compilation->>Compilation: std::move(diagnostics) into unit
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus areas:
    • src/Compiler/Compilation.cpp — verify diagnostic ownership transfer (release()), lifetime, and error paths.
    • include/Compiler/Diagnostic.h & src/Compiler/Diagnostic.cpp — ensure signature change is propagated and callers updated.
    • src/AST/Resolver.cpp & include/AST/Resolver.h — validate guarded name extraction handles operator and nameless templates.
    • cmake/llvm_setup.cmake & cmake/package.cmake — confirm all call sites provide LLVM_VERSION and install paths match CI asset names.

Possibly related PRs

  • feat: run clang-tidy #200 — touches clang-tidy integration and diagnostic/compilation plumbing overlapping with Diagnostic::create and tidy wiring.

Suggested reviewers

  • star-hengxing

Poem

🐇 I hopped from twenty to twenty-one today,
I packed clang files in a tidy, modern way,
Names are checked before templates peep,
Diagnostics snug in unique_ptr keep,
Builds hum along — the rabbit hops away.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "build: update llvm to 21.1.4" accurately describes the main objective of the changeset. The version bump is consistently applied across multiple configuration files (config/prebuilt-llvm.json updated from 20.1.5 to 21.1.4, cmake/package.cmake passing "21.1.4" to setup_llvm, and paths updated from lib/clang/20 to lib/clang/21). While the changeset includes supporting refactorings to the diagnostic system, AST resolver, and CMake configuration, these are necessary implementation changes to accommodate the LLVM version upgrade. The title is concise, clear, and specific enough that a developer reviewing the PR history would immediately understand this is about upgrading the LLVM dependency to version 21.1.4.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-llvm

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0cec83 and a7bf683.

📒 Files selected for processing (2)
  • include/Support/FileSystem.h (1 hunks)
  • xmake.lua (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • xmake.lua
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: build (macos-15)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (windows-2025)
  • GitHub Check: linux (ubuntu-24.04, debug)
  • GitHub Check: windows (windows-2025)
  • GitHub Check: macos (macos-15, release)
  • GitHub Check: macos (macos-15, debug)
  • GitHub Check: linux (ubuntu-24.04, release)
🔇 Additional comments (2)
include/Support/FileSystem.h (2)

45-45: LGTM! LLVM version path correctly updated.

The path update from lib/clang/20 to lib/clang/21 aligns with the LLVM 21.1.4 upgrade.


42-42: All callers have been correctly updated to handle the new error type.

The search found 2 callers of init_resource_dir:

  • bin/clice.cc:114: Correctly checks the result and passes result.error() to logging
  • bin/unit_tests.cc:204: Correctly checks the result and passes result.error() to string printing

Both properly handle the std::expected<void, std::string> return type with appropriate error message formatting.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
config/prebuilt-llvm.json (1)

11-17: Release-LTO archives still pinned to 20.1.5

We now hard-pin the toolchain to LLVM 21.1.4 and resolve the resource directory under lib/clang/21. However, all of the is_lto entries here still reference the 20.1.5 artifacts. When the release/LTO builds fetch those bundles they only contain lib/clang/20, so fs::real_path in init_resource_dir aborts because the expected lib/clang/21 directory is missing.(reviews.llvm.org) With the 21.1.4 release already available, the LTO archives need to be rebuilt (and the version/filename fields bumped) before this upgrade can ship, otherwise every release+LTO configuration will fail to start.(discourse.llvm.org)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b1e379 and 0fa00b5.

📒 Files selected for processing (17)
  • CMakeLists.txt (1 hunks)
  • cmake/llvm_setup.cmake (6 hunks)
  • cmake/package.cmake (1 hunks)
  • config/prebuilt-llvm.json (3 hunks)
  • include/AST/Resolver.h (1 hunks)
  • include/AST/Semantic.h (0 hunks)
  • include/Compiler/Diagnostic.h (1 hunks)
  • include/Support/FileSystem.h (1 hunks)
  • src/AST/Resolver.cpp (6 hunks)
  • src/Compiler/Compilation.cpp (4 hunks)
  • src/Compiler/Diagnostic.cpp (1 hunks)
  • src/Compiler/Directive.cpp (1 hunks)
  • src/Compiler/Tidy.cpp (3 hunks)
  • src/Feature/CodeCompletion.cpp (1 hunks)
  • src/Index/USRGeneration.cpp (3 hunks)
  • tests/unit/Compiler/Tidy.cpp (1 hunks)
  • xmake.lua (1 hunks)
💤 Files with no reviewable changes (1)
  • include/AST/Semantic.h
🧰 Additional context used
🧬 Code graph analysis (5)
include/AST/Resolver.h (1)
src/AST/Resolver.cpp (8)
  • type (308-354)
  • type (308-308)
  • type (467-561)
  • type (467-467)
  • type (643-653)
  • type (643-643)
  • lookup (801-805)
  • lookup (801-802)
src/Compiler/Tidy.cpp (1)
src/Compiler/Compilation.cpp (2)
  • instance (80-87)
  • instance (80-81)
tests/unit/Compiler/Tidy.cpp (2)
src/Compiler/Tidy.cpp (2)
  • is_fast_tidy_check (54-66)
  • is_fast_tidy_check (54-54)
src/Compiler/Compilation.cpp (6)
  • compile (317-319)
  • compile (317-317)
  • compile (321-348)
  • compile (321-321)
  • compile (350-370)
  • compile (350-350)
src/AST/Resolver.cpp (1)
include/AST/Resolver.h (4)
  • lookup (43-45)
  • lookup (47-56)
  • lookup (58-60)
  • lookup (62-97)
src/Compiler/Compilation.cpp (2)
src/Compiler/Diagnostic.cpp (2)
  • create (260-263)
  • create (261-261)
src/Compiler/CompilationUnit.cpp (2)
  • diagnostics (217-219)
  • diagnostics (217-217)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: linux (ubuntu-24.04, release)
  • GitHub Check: macos (macos-15, debug)
  • GitHub Check: linux (ubuntu-24.04, debug)
  • GitHub Check: macos (macos-15, release)
  • GitHub Check: windows (windows-2025)
  • GitHub Check: build (macos-15)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (windows-2025)
🔇 Additional comments (2)
src/Compiler/Directive.cpp (1)

126-128: API usage is correct; no null safety concerns.

The code properly adapts to LLVM 21.1.4's ModuleIdPath iteration pattern where IdentifierInfo pointers are always valid for identifier tokens. The change from structured binding to explicit method calls (getIdentifierInfo() and getLoc()) correctly maps to the LLVM 21.1.4 IdentifierLoc API. Similar patterns appear in Clang's pragma handling code without null checks, confirming this is standard usage for module import paths where identifier information is guaranteed to be present.

src/Feature/CodeCompletion.cpp (1)

184-186: Code is correct and complete—no missing Decl kinds.

The three new Decl kinds added in lines 184-186 (OpenACCRoutine, OpenACCDeclare, HLSLRootSignature) are properly handled. Verification confirms that all other new Clang 21 Decl kinds (UsingPack, UnresolvedUsingIfExists, PragmaComment, PragmaDetectMismatch, etc.) are already accounted for elsewhere in the switch statement. The three additions are correctly categorized as non-NamedDecl types that cannot appear in code completion results and appropriately marked with std::unreachable(). The switch statement is exhaustive with no missing enum cases.

Comment thread src/Compiler/Compilation.cpp
Comment thread src/Index/USRGeneration.cpp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
include/Support/FileSystem.h (1)

47-47: Consider using error.message() for more readable error messages.

Formatting std::error_code directly produces output like "system:2". Using error.message() would provide a more user-friendly error description.

Apply this diff:

-        return std::unexpected(std::format("{}:{}", error, path));
+        return std::unexpected(std::format("{}:{}", error.message(), path));
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1a791 and e0cec83.

📒 Files selected for processing (1)
  • include/Support/FileSystem.h (1 hunks)
🔇 Additional comments (2)
include/Support/FileSystem.h (2)

45-45: LGTM! Version update aligns with LLVM 21.1.4 upgrade.

The path update from lib/clang/20 to lib/clang/21 correctly reflects the LLVM version bump.


42-42: All callers correctly handle the new std::string error type—no updates needed.

Verification confirms both call sites (bin/unit_tests.cc and bin/clice.cc) properly invoke result.error() and pass the string to output functions. The breaking API change has been fully implemented.

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.

1 participant