Fix Clang unroll warning in LEB128 helpers - #13
Merged
Conversation
Bare #pragma unroll forces a full unroll, which fails on these break-bounded loops and triggers -Wpass-failed=transform-warning. unroll_count(5) requests a partial unroll with a runtime remainder fallback, avoiding the warning while keeping an unroll hint for Clang (symmetric with GCC's #pragma GCC unroll 5). Verified with Homebrew llvm@18 (-O2/-O3 -Wall): warning gone. Full release build and ctest (5151/5151) pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
heifner
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Description
Replace Clang's forced
#pragma unroll(full unroll) hint on the LEB128 helper loops with#pragma clang loop unroll_count(5). These loops can terminate early based on encoded byte contents, so a forced full unroll request has no fallback and Clang emits-Wpass-failed=transform-warningwhen it can't comply (seen in downstream Release builds, reproduced locally with Homebrew llvm@18 at-O2/-O3 -Wall).unroll_count(5)requests a partial unroll by a fixed factor instead. Unlike a forced full unroll, it has a runtime-remainder-loop fallback, so it succeeds without warning — while still giving Clang an unroll hint (previously these loops would have had no hint at all under one earlier version of this fix). This also makes the Clang hint symmetric with GCC's existing#pragma GCC unroll 5, which was already count-based rather than forcing a full unroll.#ifdef __clang__/#elif defined(__GNUC__)guard style kept consistent with the rest of the file.API Changes
No API changes.
Documentation Additions
No documentation additions required.
Testing
cmake -S . -B build/release -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_OVERLAY_TRIPLETS=build/vcpkg-triplets -DVCPKG_TARGET_TRIPLET=arm64-osx-release -DENABLE_TESTS=ON -DENABLE_SPEC_TESTS=ON -DENABLE_CCACHE=ONcmake --build build/release -j— clean build, noleb128.hppwarningsctest -j --output-on-failure— 5151/5151 tests passedllvm@18(clang++ -std=c++17 -O2/-O3 -Wall) on the real header:-Wpass-failed=transform-warningreproduced with bare#pragma unroll, gone with#pragma clang loop unroll_count(5)