From ac9d265eb7cd71c78440fc507cf4143a1509f764 Mon Sep 17 00:00:00 2001 From: Olivier Parcollet Date: Thu, 6 Aug 2026 15:59:12 +0000 Subject: [PATCH 1/5] [clu] Fix inject_bool_vartempl_specialization An explicit specialization is required to carry its template argument list "as written". A null worked by accident until LLVM 23. --- src/clu/inject_bool_vartempl_specialization.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clu/inject_bool_vartempl_specialization.cpp b/src/clu/inject_bool_vartempl_specialization.cpp index 5828c6a..7adf1d4 100644 --- a/src/clu/inject_bool_vartempl_specialization.cpp +++ b/src/clu/inject_bool_vartempl_specialization.cpp @@ -15,6 +15,13 @@ clang::VarTemplateSpecializationDecl *clu::inject_bool_vartempl_specialization(c Spec->setConstexpr(true); // mirrors the template's 'static constexpr bool'; required for concept evaluation Spec->setInit(new (Ctx) clang::CXXBoolLiteralExpr(Value, Ctx.BoolTy, clang::SourceLocation())); // NOLINT set to true Spec->setTemplateSpecializationKind(clang::TSK_ExplicitSpecialization); // treat as user-written template<> constexpr bool is_wrapped = true + // An explicit specialization must also carry its argument list "as written": RecursiveASTVisitor + // dereferences getTemplateArgsAsWritten() unconditionally for TSK_ExplicitSpecialization since + // LLVM 23 (llvm/llvm-project#199131), so leaving it null segfaults every AST matcher traversal. + clang::SourceLocation Loc = VTD->getLocation(); // stands in for the angle-bracket and argument locations of the synthesized + clang::TemplateArgumentListInfo ArgsAsWritten(Loc, Loc); + ArgsAsWritten.addArgument(clang::TemplateArgumentLoc(Arg, Ctx.getTrivialTypeSourceInfo(T, Loc))); + Spec->setTemplateArgsAsWritten(ArgsAsWritten); VTD->AddSpecialization(Spec, InsertPos); // register in the template's hash table at the position found above VTD->getDeclContext()->addDecl(Spec); // make visible in the c2py namespace for subsequent AST lookups return Spec; From 24d6260b185f73c9eedd5fa1511b59498b504e30 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 6 Aug 2026 15:59:27 +0000 Subject: [PATCH 2/5] [llvm] Support LLVM/Clang 23 - doc_string: ASTContext::getRawCommentForDeclNoCache was generalized to macros and renamed to getRawCommentNoCache (llvm/llvm-project#198452) - custom_action: DiagnosticOptions::ShowColors became a protected tri-state enum option reached via setShowColors (llvm/llvm-project#202441) Co-authored-by: Olivier Parcollet --- src/clu/doc_string.cpp | 8 +++++++- src/tools/clair-c2py/custom_action.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/clu/doc_string.cpp b/src/clu/doc_string.cpp index 5db4be9..815137e 100644 --- a/src/clu/doc_string.cpp +++ b/src/clu/doc_string.cpp @@ -60,7 +60,13 @@ namespace clu { str_t get_raw_comment(const clang::Decl *d) { auto &ctx = d->getASTContext(); - if (const clang::RawComment *rc = ctx.getRawCommentForDeclNoCache(d)) { +#if LLVM_VERSION_MAJOR >= 23 + // getRawCommentForDeclNoCache was generalized to macros and renamed (llvm/llvm-project#198452) + const clang::RawComment *rc = ctx.getRawCommentNoCache(d); +#else + const clang::RawComment *rc = ctx.getRawCommentForDeclNoCache(d); +#endif + if (rc) { return str_t{rc->getRawText(ctx.getSourceManager())}; } else return {}; // no comment is not an error diff --git a/src/tools/clair-c2py/custom_action.cpp b/src/tools/clair-c2py/custom_action.cpp index 8679750..e272428 100644 --- a/src/tools/clair-c2py/custom_action.cpp +++ b/src/tools/clair-c2py/custom_action.cpp @@ -28,7 +28,14 @@ bool custom_action::BeginInvocation(clang::CompilerInstance &CI) { // Force color diagnostics if requested via environment variables // This ensures colors work even when output is redirected to a pipe - if (std::getenv("CLICOLOR_FORCE") || std::getenv("LLVM_FORCE_COLOR")) { CI.getDiagnosticOpts().ShowColors = true; } + if (std::getenv("CLICOLOR_FORCE") || std::getenv("LLVM_FORCE_COLOR")) { +#if LLVM_VERSION_MAJOR >= 23 + // ShowColors became a tri-state enum option with accessors (llvm/llvm-project#202441) + CI.getDiagnosticOpts().setShowColors(clang::ShowColorsKind::On); +#else + CI.getDiagnosticOpts().ShowColors = true; +#endif + } return true; } From 67180cb8d557fdd2b3f20e212738b23f4e3ad1fb Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 6 Aug 2026 09:42:55 -0400 Subject: [PATCH 3/5] [ghactions] Extend the build matrix to LLVM 21, 22 and 23 Ubuntu 24.04 only ships clang-20, so the newer releases are installed from the versioned apt.llvm.org suites (llvm-toolchain-noble-). The llvm.sh helper is deliberately not used: it maps 23 to the unversioned "development" suite, which moves on to the next major version as soon as LLVM branches for a release and would then stop providing clang-23. The compiler is now derived from a single matrix.llvm key rather than being repeated in cc / cxx, so a version bump can no longer install the packages of one LLVM version while compiling with another -- which would silently test the wrong toolchain, since clang_detection.cmake locates LLVM through the compiler's resource dir. macos keeps explicit cc / cxx because brew's llvm provides the unversioned clang. The ccache keys move from matrix.cc to the same fallback so that the four ubuntu jobs do not share one cache. Assisted-by: Claude --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 019acc3..0407471 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,11 @@ jobs: fail-fast: false matrix: include: - - {os: ubuntu-24.04, cc: clang-20, cxx: clang++-20, doc: ON } + # ubuntu builds with the versioned clang packages of matrix.llvm, macos with the unversioned clang of brew's llvm + - {os: ubuntu-24.04, llvm: 20, doc: ON } + - {os: ubuntu-24.04, llvm: 21, doc: OFF, apt_llvm_org: true } + - {os: ubuntu-24.04, llvm: 22, doc: OFF, apt_llvm_org: true } + - {os: ubuntu-24.04, llvm: 23, doc: OFF, apt_llvm_org: true } - {os: macos-14, cc: clang, cxx: clang++, doc: OFF } runs-on: ${{ matrix.os }} @@ -37,9 +41,20 @@ jobs: - uses: actions/cache/restore@v4 with: path: ${{ env.CCACHE_DIR }} - key: ccache-${{ matrix.os }}-${{ matrix.cc }}-${{ github.run_id }} + key: ccache-${{ matrix.os }}-${{ matrix.cc || matrix.llvm }}-${{ github.run_id }} restore-keys: - ccache-${{ matrix.os }}-${{ matrix.cc }}- + ccache-${{ matrix.os }}-${{ matrix.cc || matrix.llvm }}- + + # LLVM releases newer than the one in the ubuntu repositories (currently 20) come from apt.llvm.org. + # The versioned suite is used rather than llvm.sh, whose unversioned "development" suite moves on to + # the next major version as soon as LLVM branches for release. + - name: Add the apt.llvm.org repository + if: ${{ matrix.apt_llvm_org }} + run: | + sudo apt-get update + sudo apt-get install -y lsb-release wget software-properties-common gnupg + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc > /dev/null + sudo add-apt-repository -y "deb https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{ matrix.llvm }} main" - name: Install ubuntu dependencies if: ${{ contains(matrix.os, 'ubuntu') }} @@ -48,13 +63,13 @@ jobs: sudo apt-get install lsb-release wget software-properties-common && sudo apt-get install ccache - clang-20 + clang-${{ matrix.llvm }} g++ doxygen - llvm-20-dev - libclang-20-dev + llvm-${{ matrix.llvm }}-dev + libclang-${{ matrix.llvm }}-dev libomp-dev - clang-format-20 + clang-format-${{ matrix.llvm }} libgmp-dev libhdf5-dev libopenblas-dev @@ -98,8 +113,8 @@ jobs: - name: Build clair env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} + CC: ${{ matrix.cc || format('clang-{0}', matrix.llvm) }} + CXX: ${{ matrix.cxx || format('clang++-{0}', matrix.llvm) }} run: | cmake -B build -S. -DCMAKE_INSTALL_PREFIX=$HOME/install -DBuild_Documentation=${{ matrix.doc }} cd build && make -j2 || make -j1 VERBOSE=1 @@ -117,7 +132,7 @@ jobs: if: always() with: path: ${{ env.CCACHE_DIR }} - key: ccache-${{ matrix.os }}-${{ matrix.cc }}-${{ github.run_id }} + key: ccache-${{ matrix.os }}-${{ matrix.cc || matrix.llvm }}-${{ github.run_id }} - name: Deploy unstable documentation to website if: matrix.doc == 'ON' && github.ref == 'refs/heads/unstable' From 9854f0962e8b8c16dbe8b227878132ab2f846386 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 6 Aug 2026 13:57:37 -0400 Subject: [PATCH 4/5] [ghactions] Switch the macOS CI runner to macos-26 The macos-14 runners have long queue waits. Follow app4triqs (d14ce18) and move to the GA macos-26 image. Assisted-by: Claude --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0407471..80fd08b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: - {os: ubuntu-24.04, llvm: 21, doc: OFF, apt_llvm_org: true } - {os: ubuntu-24.04, llvm: 22, doc: OFF, apt_llvm_org: true } - {os: ubuntu-24.04, llvm: 23, doc: OFF, apt_llvm_org: true } - - {os: macos-14, cc: clang, cxx: clang++, doc: OFF } + - {os: macos-26, cc: clang, cxx: clang++, doc: OFF } runs-on: ${{ matrix.os }} From a866b48a30c7a53a0654f87a521b6031215a7c27 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 6 Aug 2026 16:36:55 -0400 Subject: [PATCH 5/5] [ghactions] Update checkout and cache actions off the Node 20 runtime - actions/checkout v4 -> v7 - actions/cache/restore and /save v4 -> v6 Assisted-by: Claude --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80fd08b..9a15aae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,9 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - - uses: actions/cache/restore@v4 + - uses: actions/cache/restore@v6 with: path: ${{ env.CCACHE_DIR }} key: ccache-${{ matrix.os }}-${{ matrix.cc || matrix.llvm }}-${{ github.run_id }} @@ -128,7 +128,7 @@ jobs: if: always() run: ccache -sv - - uses: actions/cache/save@v4 + - uses: actions/cache/save@v6 if: always() with: path: ${{ env.CCACHE_DIR }}