[NFC] [Clang] [CodeGen] Reduce code duplication when emitting trap calls (#221022)
There are a number of places in codegen where we do this:
```c++
llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
TrapCall->setDoesNotReturn();
TrapCall->setDoesNotThrow();
Builder.CreateUnreachable();
Builder.ClearInsertionPoint();
```
This patch adds a helper that does this and updates `EmitTrapCall()` to
no longer create a new block after emitting the trap call.
One test had to be updated because an unnecessary block was dropped.
Before, we were generating this:
```llvm
dtor.call_delete_after_array_destroy: ; preds = %dtor.vector.cont
call void @llvm.trap() #7
[6 lines not shown]
[Clang][Sema] Add fortify warnings for strlcat (#220341)
Add `-Wfortify-source` diagnostics for `strlcat` and `__builtin_strlcat`
when the size argument exceeds the destination buffer size.
Also add `-Wno-fortify-source` to `clang/test/Analysis/cstring-syntax.c`
to prevent the new compiler diagnostic from interfering with static
analyzer checks on intentionally underflowing test expressions.
Part of #142230
Assisted-by: Gemini
[clang-format] Parse ObjC generics in block literal return types (#220995)
The unwrapped line parser handled a block literal's return type as a
single identifier or type keyword followed by optional stars. A return
type carrying ObjC generics or a protocol qualifier, such as
`^NSArray<NSString *> *(int x) { ... }` or `^id<Proto>(int x) { ... }`,
was therefore not recognized as a block, and its body was treated as a
function body instead. This collapsed the body like a short function
and, with `RemoveSemicolon: true`, dropped the semicolon terminating the
enclosing statement, producing code that no longer compiles.
Skip a balanced angle-bracket list after the return type before looking
for the parameter list and body.
Fixes #219713
Assisted-by: Claude Code
[LoopIdiom] Adjust memmove-ext.ll test (#221251)
Some of the functions in this test have an iv value of 0 in the first
iteration which which is then used in a sub nuw which would result in
poison. Adjust these to use 1 in the first iteration.
[flang][NFC] Add FortranObjectLoadOpInterface for load provenance (#221088)
The definition walk in AliasAnalysis::getSourceImpl already keys the
address half of a descriptor access chain on
FortranObjectViewOpInterface (fir.box_addr, fir.create_box,
fir.convert), but the load step was hardcoded to fir::LoadOp. Any other
operation whose result is a value read from memory therefore terminated
the walk at SourceKind::Unknown, losing the AllocDeref/PointerDeref root
and coarsening alias results for everything reached through the loaded
descriptor.
Add FortranObjectLoadOpInterface as the value-producing dual of
FortranObjectViewOpInterface: a view op forwards an address, a load-like
op yields the value read from one. It declares a single getLoadSource
method reporting the memory reference a result was read from. fir.load
implements it as getMemref(), so this is NFC, and the box-load case in
getSourceImpl now keys on the interface instead of the concrete op.
The interface documents provenance only and makes no purity claim, so an
[5 lines not shown]
[CIR] Implement 'vtable initialization' lowering (#220946)
This showed up in a test suite, and is basically just ensuring that our
vtable pointers are properly cleaned up during destruction. The entirety
of the static functions (and the implementation) are near word-for-word
copies of what classic codegen does.
However, there ARE a few parts that are potentially untested(including
strict-vtable-pointers which aren't implemented yet), but the
implementation is put in place, as it is a mechanical copy/paste
implementation.
Note: Claude came up with additional test cases.