LLVM/project 473c7fb — llvm/include/llvm/IR RuntimeLibcalls.td, llvm/test/Transforms/Util/DeclareRuntimeLibcalls bsd.ll hexagon.ll

RuntimeLibcalls: Add signatures for the memcpy variants and __stack_smash_handler (#239367)

The XCore and Hexagon memcpy variants take the usual destination,
source and size, except hexagon_memcpy_forward_vp4cp4n2 which takes a
word count. __stack_smash_handler uses the OpenBSD prototype.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+5-4llvm/include/llvm/IR/RuntimeLibcalls.td
+4-4llvm/test/Transforms/Util/DeclareRuntimeLibcalls/hexagon.ll
+1-1llvm/test/Transforms/Util/DeclareRuntimeLibcalls/bsd.ll
+10-93 files

LLVM/project a54fb53 — libcxx/include/__configuration attributes.h, libcxx/include/__numeric reduce.h transform_reduce.h

Revert "[libc++] Allow the compiler to reorder computation in reduction loops" (#239721)

Reverts llvm/llvm-project#237918
DeltaFile
+0-6libcxx/include/__configuration/attributes.h
+0-2libcxx/include/__numeric/transform_reduce.h
+0-1libcxx/include/__numeric/reduce.h
+0-93 files

LLVM/project 13bbcde — llvm/include/llvm/IR Instruction.h, llvm/lib/IR Instruction.cpp

IR: Implement Instruction::mayReadOrWriteMemory with a single switch (#239479)

Separately calling mayReadFromMemory and mayWriteToMemory performed 2
calls and was slower. This speeds up attributor-light pass up to 2.7%
(callgrind), and 0.2-5.8% faster with other pending Attributor
compile-time changes applied.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+21-0llvm/lib/IR/Instruction.cpp
+1-3llvm/include/llvm/IR/Instruction.h
+22-32 files

LLVM/project 9d1dc5f — llvm/include/llvm/IR RuntimeLibcalls.td, llvm/lib/Target/Mips MipsSubtarget.cpp

RuntimeLibcalls: Add the MIPS16 hard float helpers to "compiler-rt" (#239405)

The __mips16_* hard float helpers were not in any library, so they
were never available. libgcc's mips16.S provides them for O32, but not
for R6. compiler-rt does not provide them, but we don't get try to
distinguish the 2.

Since these coexist with standard symbol names, this needs explicit
handling to prefer these implementations.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+45-34llvm/include/llvm/IR/RuntimeLibcalls.td
+67-8llvm/lib/Target/Mips/MipsSubtarget.cpp
+34-0llvm/test/Transforms/Util/DeclareRuntimeLibcalls/mips.ll
+146-423 files

LLVM/project 431f7ef — clang/docs OverflowBehaviorTypes.md, clang/include/clang/Basic DiagnosticSemaKinds.td

[Clang][OBT] Add overflow handler diagnostics

Add three warnings:
- -Woverflow-behavior-goto-no-effect (on): the operand of
  __builtin_overflow_goto performs no checked operation. Not issued for
  dependent operands or during template instantiation.
- -Woverflow-behavior-no-handler (off): an expression's checks trap
  because no handler is visible. Projects that require a handler can
  promote it to an error.
- -Woverflow-behavior-unreachable-handler (on): checks in a lambda or
  block trap although the enclosing function has a handler, which they
  cannot reach.

The last two report once per outermost unhandled expression. They are
emitted when the outermost function body is complete, so that labels
defined after a lambda are known, and per instantiation for templates.
The walk runs only when the function has a handler or the off-by-default
warning is enabled.


    [2 lines not shown]
DeltaFile
+129-1clang/lib/Sema/SemaStmt.cpp
+80-0clang/test/Sema/overflow-behavior-handler-warnings.c
+41-0clang/test/SemaCXX/overflow-behavior-handler-warnings.cpp
+11-6clang/include/clang/Sema/ScopeInfo.h
+14-0clang/include/clang/Basic/DiagnosticSemaKinds.td
+11-0clang/docs/OverflowBehaviorTypes.md
+286-76 files not shown
+311-812 files

LLVM/project 490aa0c — clang/include/clang/AST Expr.h, clang/lib/Parse ParseExpr.cpp

[Clang][OBT] Add __builtin_overflow_goto

__builtin_overflow_goto(expr, label) sends the failed trap overflow
behavior type checks of operations written in expr to label instead of
to the default __overflow handler. It yields the value of expr, which
must have integer or void type, and keeps its value category. A void
operand lets a GNU statement expression guard a whole block:

  #define try(x, label) __builtin_overflow_goto(({ x; }), label)

  try(a + 1, L);              // yields a + 1
  try({ a--; a += 2; }, L);   // void

When builtins and GNU local handler labels nest, the innermost applies.
Effects before the failing check are kept. The builtin may not branch out
of code whose checks always trap, such as a constructor initializer or a
new-expression initializer; the jump scope checker rejects it, and runs for
every function that uses the builtin.


    [12 lines not shown]
DeltaFile
+95-11clang/lib/Sema/JumpDiagnostics.cpp
+101-0clang/test/CodeGen/overflow-behavior-goto.c
+95-0clang/test/SemaCXX/overflow-behavior-goto.cpp
+85-0clang/test/Sema/overflow-behavior-goto.c
+51-0clang/include/clang/AST/Expr.h
+42-0clang/lib/Parse/ParseExpr.cpp
+469-1147 files not shown
+890-1853 files

LLVM/project b975b4b — clang/docs OverflowBehaviorTypes.md, clang/include/clang/AST OverflowHandler.h

[Clang][OBT] Branch to the overflow handler on trap OBT conversion checks

Implicit and explicit integral conversions into or out of an __ob_trap
type check for truncation and sign change. Route a failed check to the
overflow handler label, when one is visible, the same way arithmetic
checks already do. Compound assignments check the conversion back to
the left-hand type even when the operator itself (for example <<=) is
not checked, so they count as checked operations too.

The shared predicate gains isOverflowHandlerCheckedConversion, which
mirrors the width and signedness rules CodeGen uses to decide whether a
check is emitted, and CodeGen asserts that the two agree. The jump scope
checker therefore diagnoses exactly the conversion branches CodeGen
emits.

Assisted-By: claude
Signed-off-by: Justin Stitt <justinstitt at google.com>
DeltaFile
+63-0clang/test/CodeGen/overflow-behavior-handler.c
+51-0clang/lib/AST/OverflowHandler.cpp
+45-4clang/lib/CodeGen/CGExprScalar.cpp
+38-0clang/test/Sema/overflow-behavior-handler.c
+5-3clang/docs/OverflowBehaviorTypes.md
+6-0clang/include/clang/AST/OverflowHandler.h
+208-76 files

LLVM/project 3e37d51 — clang/test/CodeGen overflow-behavior-handler-scopes.c, clang/test/CodeGenCXX overflow-behavior-handler.cpp

[Clang][OBT] Test cleanups on the path to the overflow handler

An overflow that branches out of a scope must run that scope's cleanups
before reaching the handler. Test that destructors of locals leaving
scope and of full-expression temporaries run first, that objects still
in scope at the handler are destroyed when it returns, and that pending
_Defer bodies run innermost first.

Assisted-By: claude
DeltaFile
+46-0clang/test/CodeGenCXX/overflow-behavior-handler.cpp
+23-0clang/test/CodeGen/overflow-behavior-handler-scopes.c
+69-02 files

LLVM/project 5f4381c — llvm/include/llvm/IR RuntimeLibcalls.td

RuntimeLibcalls: Add signatures for the MIPS16 return helpers (#239404)

MIPS16 functions call these to move a floating point return value into
floating point registers. Each takes the value being returned, with
complex values as a pair of floats or doubles.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+7-4llvm/include/llvm/IR/RuntimeLibcalls.td
+7-41 files

LLVM/project edfda95 — lldb/include/lldb/Target LanguageRuntime.h, lldb/source/Plugins/LanguageRuntime/CPlusPlus CPPLanguageRuntime.h

[lldb] Remove ConstString in LanguageRuntime (#237429)
DeltaFile
+6-12lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+3-3lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+3-3lldb/include/lldb/Target/LanguageRuntime.h
+1-1lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+1-1lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+1-1lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+15-211 files not shown
+16-227 files

LLVM/project f7101ca — lldb/source/Commands CommandObjectType.cpp, lldb/unittests/DataFormatter FormatterSectionTest.cpp

[lldb] Remove ConstString from CommandObjectType (#237416)

After removing ConstString from the DataFormatters library, I realized
that the CommandObject that most interacted with it was still producing
ConstStrings. These codepaths should be mostly free of ConstStrings now.

I also removed them from the unittests.
DeltaFile
+38-51lldb/source/Commands/CommandObjectType.cpp
+13-14lldb/unittests/DataFormatter/FormatterSectionTest.cpp
+51-652 files

LLVM/project 03be26c — lldb/tools/swift-debugserver/Sources/Driver CMakeLists.txt DebugServer.swift

[debugserver] Add a gdb server subcommand to swift-debugserver (#239033)

This is further scaffolding for the project.
Notes:
- Command objects now have `Command` at the end of them. I will probably
create a GDBServer object later, and although the names conflicting
isn't inherently a problem, I think it's more readable this way.
- Subcommand is now a Protocol. I was going back and forth on this one,
but I think it brings some simplification to the driver. The size
increase is only ~1kB right now, so we can revisit this later if it
presents a problem later in the project.
- Right now, GDBServerCommand doesn't actually do anything. The parse
function processes 3 flags and options that lldb uses to spawn
debugserver on my local machine.
- The actual parsing is ad-hoc currently. When we add support for
platform mode, this logic should be broken out into a common library or
we should adopt a library that handles this for us.

Assisted-by: claude
DeltaFile
+67-0lldb/tools/swift-debugserver/Sources/Driver/GDBServerCommand.swift
+23-0lldb/tools/swift-debugserver/Sources/Driver/Subcommand.swift
+0-20lldb/tools/swift-debugserver/Sources/Driver/Version.swift
+20-0lldb/tools/swift-debugserver/Sources/Driver/VersionCommand.swift
+4-15lldb/tools/swift-debugserver/Sources/Driver/DebugServer.swift
+3-1lldb/tools/swift-debugserver/Sources/Driver/CMakeLists.txt
+117-366 files

LLVM/project d210dce — llvm/include/llvm/Transforms/IPO Attributor.h

Update llvm/include/llvm/Transforms/IPO/Attributor.h

Co-authored-by: Shilei Tian <i at tianshilei.me>
DeltaFile
+1-1llvm/include/llvm/Transforms/IPO/Attributor.h
+1-11 files

LLVM/project 2f11c80 — llvm/lib/Transforms/Utils ControlFlowUtils.cpp, llvm/utils profcheck-xfail.txt

[ControlFlowHub][profcheck] Set branch weights on guard branches (#239656)

Stop-gap until a more reasoned PR lands (e.g. #230740)
DeltaFile
+9-4llvm/lib/Transforms/Utils/ControlFlowUtils.cpp
+0-11llvm/utils/profcheck-xfail.txt
+9-152 files

LLVM/project 1536439 — utils/bazel/llvm-project-overlay/mlir BUILD.bazel

[Bazel] Fixes 4955dfb (#239667)

This fixes 4955dfbcf451b60203b9ec151fa7fa1ed4ef7884 (#228638).

Buildkite error link:
https://buildkite.com/llvm-project/upstream-bazel/builds?commit=4955dfbcf451b60203b9ec151fa7fa1ed4ef7884

Co-authored-by: Google Bazel Bot <google-bazel-bot at google.com>
DeltaFile
+1-0utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+1-01 files

LLVM/project 5542ffc — mlir/lib/Dialect/LLVMIR/Transforms InlinerInterfaceImpl.cpp, mlir/test/Dialect/LLVMIR inlining-memprof.mlir

[mlir][llvm] Update MemProf metadata when inlining calls (#239391)

Fix https://github.com/llvm/llvm-project/issues/239141

The MLIR inliner carried llvm.memprof and llvm.callsite over unchanged,
so contexts went stale across an MLIR-side inline. Handle them in
processInlinedCallBlocks, matching LLVM's propagateMemProfMetadata.

Unlike LLVM's call-stack trie rebuild, the kept subset is carried over
unchanged.
DeltaFile
+180-0mlir/test/Dialect/LLVMIR/inlining-memprof.mlir
+87-0mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
+267-02 files

LLVM/project cb6b8f8 — llvm/utils/gn/secondary/libcxx/include BUILD.gn

[gn build] Port f021128a32ca (#239709)
DeltaFile
+2-0llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+2-01 files

LLVM/project 60524d0 — llvm/include/llvm/Transforms/IPO Attributor.h, llvm/lib/Transforms/IPO Attributor.cpp

Attributor: Use an array indexed by opcode for OpcodeInstMap (#239454)

This avoids a DenseMap lookup for every instruction when building the
InformationCache, and for every opcode checked by
checkForAllInstructions.

CTMark instructions:u with -attributor-enable=light changes by O3
-0.04%,
ThinLTO -0.02%. The attributor-light pass itself is 0.2-2.5% faster
(callgrind), and 1.4-7.2% faster with the other pending Attributor
compile-time changes applied.

Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DeltaFile
+5-3llvm/lib/Transforms/IPO/Attributor.cpp
+4-2llvm/include/llvm/Transforms/IPO/Attributor.h
+9-52 files

LLVM/project 84a8c0e — llvm/lib/Target/WebAssembly/GISel WebAssemblyLegalizerInfo.cpp

[WebAssembly] WebAssemblyLegalizerInfo.cpp - remove empty switch. NFC. (#239684)

Fixes MSVC "warning C4065: switch statement contains 'default' but no 'case' labels"
DeltaFile
+0-4llvm/lib/Target/WebAssembly/GISel/WebAssemblyLegalizerInfo.cpp
+0-41 files

LLVM/project 70ca71b — llvm/lib/Transforms/Vectorize SLPVectorizer.cpp, llvm/lib/Transforms/Vectorize/SLPVectorizer SLPCostAnalysis.h SLPCostAnalysis.cpp

[SLP]Emit full byte reversal of extracted fields as bswap

Gathers of the fully reversed bytes of a scalar are emitted as a byte
swap instead of a bitcast plus reverse shuffle, if not more expensive.
The byte swaps of scalars extracted from the same vector are estimated
together with all their extractions, since the shuffle folds them.

Fixes #235677

Assisted-by: Cursor

Reviewers: RKSimon, bababuck

Pull Request: https://github.com/llvm/llvm-project/pull/235810
DeltaFile
+31-105llvm/test/Transforms/SLPVectorizer/X86/extracted-subfields-bswap.ll
+70-12llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+80-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPCostAnalysis.cpp
+19-0llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPCostAnalysis.h
+200-1174 files

LLVM/project d7bd26a — flang/lib/Lower Bridge.cpp, flang/test/Lower/OpenMP assumption-noopenmp-submodule.f90 assumption-submodule.f90

[flang][OpenMP] Support for "omp assumes absent" (#236693)
DeltaFile
+150-10flang/test/Lower/OpenMP/assumption.f90
+29-12flang/lib/Lower/Bridge.cpp
+34-0flang/test/Lower/OpenMP/assumption-submodule.f90
+31-0flang/test/Semantics/OpenMP/declarative-directive01.f90
+0-24flang/test/Lower/OpenMP/assumption-noopenmp-submodule.f90
+21-0flang/test/Parser/OpenMP/assumption.f90
+265-469 files not shown
+323-6415 files

LLVM/project 82885a1 — llvm/include/llvm/Support SuffixTree.h, llvm/lib/Support SuffixTree.cpp

[Support][NFC] Initialize suffix tree metadata during construction (#232720)

Compute internal path lengths and leaf suffix starts during insertion to
eliminate the final `setSuffixIndices()` traversal.

This change preserves functional behavior while avoiding the final
metadata traversal.

SuffixTree construction CPU time against main `f14f34f217a9`:
Core i9-13900K, Linux x86_64, X86 `-Oz`, outlining always enabled,
leaf descendants enabled. Sum inputs per round; for each version, drop
the minimum and maximum of 10 rounds and average the remaining 8.

| Workload | Mode | Baseline (s) | Optimized (s) | CPU change |
| --- | --- | ---: | ---: | ---: |
| CTMark | NoLTO | 0.185136 | 0.174090 | -5.97% |
| CTMark | FullLTO | 0.086525 | 0.075911 | -12.27% |
| SPEC2017 C/C++ Rate | NoLTO | 1.232714 | 1.156888 | -6.15% |
| SPEC2017 C/C++ Rate | FullLTO | 0.570815 | 0.456092 | -20.10% |

    [6 lines not shown]
DeltaFile
+8-33llvm/lib/Support/SuffixTree.cpp
+0-4llvm/include/llvm/Support/SuffixTree.h
+8-372 files

LLVM/project 7d2b3c9 — llvm/docs ReleaseNotes.md, llvm/utils/TableGen InstrInfoEmitter.cpp GlobalISelEmitter.cpp

[TableGen] Remove HwMode expansion from CodeGenDAGPatterns. (#238932)

GlobalISel and Selection both handle HwMode expansion during instruction
selection now.

The only remaining user is FastISel, but no in tree target uses FastISel
with HwModes. If it becomes necessary, I think it should be done at
selection time like SelectionDAG and GlobalISel. For now, FastISel will
skip patterns that use HwMode.

Assisted-by: Claude
DeltaFile
+2-115llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+11-2llvm/utils/TableGen/FastISelEmitter.cpp
+4-8llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
+2-4llvm/utils/TableGen/GlobalISelEmitter.cpp
+1-2llvm/utils/TableGen/InstrInfoEmitter.cpp
+3-0llvm/docs/ReleaseNotes.md
+23-1311 files not shown
+24-1327 files

LLVM/project 5f43e2c — llvm/include/llvm/IR DroppedVariableStats.h, llvm/lib/CodeGen DroppedVariableStatsMIR.cpp

DroppedVarStats: Count variables visible from inlined frames (#239280)

A dropped variable is only counted if an instruction remains from which
a debugger could observe it. The check needs to consider all inlined
frames to check if the variable is visible from one. The old code would
have false negatives as it wouldn't consider inlined scopes as visible
(see added tests inlined_code_in_scope and
nested_inlined_code_in_scope).

Also remove VisitedScope, which guarded against cycles, but cycles
cannot happen in scopes.

Assisted-by: Claude
DeltaFile
+83-3llvm/test/Other/dropped-var-stats-inlined-instances.ll
+22-43llvm/lib/IR/DroppedVariableStats.cpp
+9-12llvm/include/llvm/IR/DroppedVariableStats.h
+1-2llvm/lib/CodeGen/DroppedVariableStatsMIR.cpp
+1-1llvm/lib/IR/DroppedVariableStatsIR.cpp
+116-615 files

LLVM/project bf51440 — flang-rt/lib/runtime exceptions.cpp

[flang-rt][cuda] Fix the aarch64 build of the runtime with CUDA 12.0 (#239488)
DeltaFile
+15-3flang-rt/lib/runtime/exceptions.cpp
+15-31 files

LLVM/project 6600c16 — llvm/lib/Target/ARC CMakeLists.txt ARCSubtarget.h

[ARC] Declare command line options in TableGen (#239691)

Move the cl::opt options into ARCOptions.td. ARCTargetMachine holds
`const ARCOptions &CLOpts`, and ARCSubtarget copies it.

LLM-aided
DeltaFile
+12-15llvm/lib/Target/ARC/ARCOptAddrMode.cpp
+18-0llvm/lib/Target/ARC/ARCOptions.td
+6-10llvm/lib/Target/ARC/ARCFrameLowering.cpp
+8-3llvm/lib/Target/ARC/ARCSubtarget.cpp
+8-2llvm/lib/Target/ARC/ARCSubtarget.h
+4-0llvm/lib/Target/ARC/CMakeLists.txt
+56-302 files not shown
+63-308 files

LLVM/project ed4d199 — lldb/source/Plugins/Process/gdb-remote GDBRemoteRegisterContext.cpp, lldb/test/API/functionalities/gdb_remote_client arm64-ios-main.yaml TestRestoreRegistersAfterReconfigure.py

[lldb] Don't restore registers saved under a different layout (#239445)

When g packets are avoided, WriteAllRegisterValues restores each
register by indexing the saved buffer with the current register offsets.
A reconfigure between save and restore, such as a change of the SVE
vector length, can move those offsets past the end of the buffer, in
which case lldb reads out of bounds and sends the bytes to the stub.

Fail the restore when the buffer size no longer matches the register
data size.

rdar://186993734
Assisted-by: Claude
DeltaFile
+110-0lldb/test/API/functionalities/gdb_remote_client/TestRestoreRegistersAfterReconfigure.py
+48-0lldb/test/API/functionalities/gdb_remote_client/arm64-ios-main.yaml
+4-0lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+162-03 files

LLVM/project 1b88a35 — llvm/include/llvm/MC MCGOFFAttributes.h MCSymbolGOFF.h, llvm/lib/MC GOFFObjectWriter.cpp

[SystemZ][z/OS] Make symbols renameable

z/OS can rename symbols, but only if the symbol is marked as
renameable in the ESD record. Until now all symbols were emitted as
non-renameable. Mark them renameable by default, with these exceptions:
- CELQSTRT and CELQINPL stay non-renameable.
- CELQBST is renameable.
Section-level PR symbols are unchanged.

Add a renameable flag to MCSymbolGOFF and the ER attributes, and
update the affected tests.

Note that HLASM has no way to express this flag, so it is only
visible in the GOFF object output.

Assisted by: IBM Bob
DeltaFile
+12-4llvm/include/llvm/MC/MCSymbolGOFF.h
+7-5llvm/lib/MC/GOFFObjectWriter.cpp
+5-3llvm/lib/Target/SystemZ/SystemZXPLINKAsmPrinter.cpp
+3-3llvm/test/CodeGen/SystemZ/zos-section-1.ll
+3-2llvm/include/llvm/MC/MCGOFFAttributes.h
+3-0llvm/lib/Target/SystemZ/MCTargetDesc/SystemZTargetStreamer.h
+33-172 files not shown
+35-198 files

LLVM/project 0387066 — clang/include/clang/Analysis/Analyses/LifetimeSafety Loans.h, clang/lib/Analysis/LifetimeSafety LifetimeAnnotations.cpp FactsGenerator.cpp

[LifetimeSafety] Support allocating/freeing functions annotated `ownership_takes`/`ownership_returns` (#213439)

This PR extends LifetimeSafety to model allocating/freeing functions
annotated with `__attribute__((ownership_returns))` /
`__attribute__((ownership_takes))`.

# Contents

* Adds `handleAllocatingCall`, which treats the call result as a fresh
allocation and issues a new loan for it (mirroring `new`).
* Adds `handleFreeingCall`, which treats the annotated arguments as
freed and invalidates their origins (mirroring `delete`), enabling
use-after-free and escape-invalidation diagnostics.
* Extends the `AccessPath` base union to also accept allocating
`CallExpr`s, keeping the number of alternatives unchanged. (breaks build
on 32-bit systems if 1 more template parameter is added)

Completes part of #213435

Assisted-by: DeepSeek V4 for writing most of the code
DeltaFile
+207-0clang/test/Sema/LifetimeSafety/safety.cpp
+47-0clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp
+39-0clang/test/Sema/LifetimeSafety/invalidations.cpp
+16-7clang/include/clang/Analysis/Analyses/LifetimeSafety/Loans.h
+14-3clang/lib/Sema/SemaLifetimeSafety.h
+14-0clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp
+337-104 files not shown
+370-1310 files

LLVM/project ed6eead — clang/lib/Analysis/LifetimeSafety LifetimeAnnotations.cpp FactsGenerator.cpp, clang/test/Sema/LifetimeSafety safety.cpp

[LifetimeSafety] Support allocating/freeing functions and builtins (#213443)

This extends LifetimeSafety to model allocating/freeing functions annotated with "ownership_returns" / "ownership_takes", as well as malloc-style builtins without requiring any attributes.

Contents

* Adds "handleAllocatingCall", which treats allocation results as fresh allocations and issues new loans (mirroring "new").
* Adds "handleFreeingCall", which invalidates the origins of freed arguments (mirroring "delete"), enabling use-after-free and escape-invalidation diagnostics.
* Extends the "AccessPath" base union to support allocating "CallExpr"s without increasing the number of alternatives.
* Adds support for "malloc"/"calloc"/"realloc"/"free" and their "__builtin_" spellings as allocating/freeing functions.

Closes #213435

Assisted-by: DeepSeek V4 for writing most of the code
DeltaFile
+30-2clang/test/Sema/LifetimeSafety/safety.cpp
+21-8clang/lib/Analysis/LifetimeSafety/FactsGenerator.cpp
+20-0clang/lib/Analysis/LifetimeSafety/LifetimeAnnotations.cpp
+5-0clang/test/Sema/LifetimeSafety/Inputs/lifetime-analysis.h
+76-104 files