Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe014f0ddd4533a7dd3c3c549dda2d78afb15039
      
https://github.com/WebKit/WebKit/commit/fe014f0ddd4533a7dd3c3c549dda2d78afb15039
  Author: David Kilzer <[email protected]>
  Date:   2026-06-19 (Fri, 19 Jun 2026)

  Changed paths:
    M Source/WTF/wtf/CheckedArithmetic.h
    M Source/WTF/wtf/PlatformHave.h

  Log Message:
  -----------
  [WTF] Work-around for clang static analyzer crash on 128-bit overflow builtins
<https://bugs.webkit.org/show_bug.cgi?id=317509>
<rdar://180158368>

Unreviewed build fix.

The clang static analyzer crashes with a segmentation fault when it
models a `__builtin_add_overflow`, `__builtin_sub_overflow`, or
`__builtin_mul_overflow` call whose overflow result type is a 128-bit
integer: `getSufficientTypeForOverflowOp()` asks for an integer type
twice as wide as the result (256-bit), which does not exist, and then
dereferences the resulting null `QualType`.  WTF's `Checked<>`
arithmetic emits these builtins, so analyzing any code that performs
128-bit checked arithmetic aborts the entire `analyze` action, leaving
every project built after the one that trips it without static-analysis
coverage (for example WebCore, built after JavaScriptCore).

Define `HAVE(BROKEN_STATIC_ANALYZER_INT128_OVERFLOW)` for Apple clang
that predates the fix (`__apple_build_version__ < 21000323`), and only
while the analyzer is running, and take the existing manual
(non-builtin) overflow path for 128-bit operands when it is set.
Ordinary compilation and analyzers that already contain the fix keep
using the overflow builtins, so generated code is unaffected and the
work-around deactivates automatically once the toolchain is current.

This is a toolchain bug fixed in apple-clang-2100.3.6.4; see
llvm/llvm-project#173795 (fixed by llvm/llvm-project#174335).

No new tests since this change is not directly testable.

* Source/WTF/wtf/PlatformHave.h:
* Source/WTF/wtf/CheckedArithmetic.h:
(WTF::ArithmeticOperations<LHS, RHS, ResultType, true, true>::add):
(WTF::ArithmeticOperations<LHS, RHS, ResultType, true, true>::sub):
(WTF::ArithmeticOperations<LHS, RHS, ResultType, true, true>::multiply):
(WTF::ArithmeticOperations<LHS, RHS, ResultType, false, false>::add):
(WTF::ArithmeticOperations<LHS, RHS, ResultType, false, false>::sub):
(WTF::ArithmeticOperations<LHS, RHS, ResultType, false, false>::multiply):

Canonical link: https://commits.webkit.org/315555@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to