17 Commits

Author SHA1 Message Date
Erich Keane
c186db874b
[CIR] Implement 'typeid' operator lowering (#184449)
This patch adds typeid lowering, which uses a lot of the infrastructure
from dynamic_cast. However, this adds a `get_type_info` operation that
gets the type info out of a vtable pointer as well, which lets the
offset be handled by the ABI specific lowering code.
2026-03-05 06:07:13 -08:00
Andy Kaylor
abb228af20
[CIR] Fix handling of cleanup scopes inside a try body (#183869)
We had a problem where scope terminators were not being created
correctly when a cleanup scope appeared inside the body of a try
operation. This was caused by cleanup scope operation not being properly
flushed before the try body scope was completed.

This change fixes the problem by creating a RunCleanupsScope in the
lambda that pupulates the try body and forcing cleanups before adding
the yield terminator to the try body.

The test case also exposed a secondary bug where we were not properly
updating the innermostEHScope variable when popping a cleanup from the
eh stack. That is also fixed here.
2026-03-02 14:30:19 -08:00
Andy Kaylor
4a8d5327ff
[CIR] Update cir::ResumeOp to require an EH token (#183192)
This updates the cir::ResumeOp operation to require an EH token operand.
We already had the token available at both locations where the operation
was being created. Adding this operand makes finding the token more
robust during CFG flattening.

This change was entirely AI generated, but I have reviewed it closely.
2026-02-25 13:36:38 -08:00
Andy Kaylor
023b7dad0f
[CIR] Update the design for structured catch handler representation (#183134)
This updates the design for catch handler regions in CIR try operations
to add an EH token argument to the regions and to use the
`cir.begin_catch` and `cir.end_catch` operations in the structured
representation rather than a `cir.catch_param`. This matches the
flattened representation and will make flattening easier to implement.

This leaves the generation of begin_catch and end_catch operands in the
`CXXABI` interface and Itanium implementation. However, because this
representation is no longer target-specific, I intend to move this code
to `CIRGenFunction` in a future change.

I used AI tools to generate many of the changes in this PR, but I have
carefully reviewed the changes and updated as needed.
2026-02-24 22:33:39 +00:00
Amr Hesham
990996358d
[CIR] Represent Cleanups with Cleanup scopes (#180276)
Represent the Cleanups stack explicitly with Cleanup scopes
2026-02-23 18:03:37 +01:00
Andy Kaylor
b6cd2133d4
[CIR] Simplify try-catch handling (#180857)
With the new exception handling device, we no longer need to track the
location of potential catch blocks, and so we no longer need to
represent catch handlers on the EH stack. This allows us to
significantly simplify the generation of try-catch blocks.

This change emits catch blocks directly when visiting the try operation
and removes unnecessary EH management code.

This is not an exhaustive cleanup of the EH management code. Some things
that may appear to be obvious simplifications (such as removing the
union of bitfields in EHScope, and possibly making EHScopeStack just a
stack of EHCleanups) are deferred until we have a better idea of how
things like EH filters will be implemented.

This change breaks lowering of cir.try operations to LLVM IR in a
somewhat trivial way. Even before this PR, lowering of `cir.try` ops
with catch handlers was not implemented. However, we had one test case
where the only call in a try-region was marked with the `noexcept`
attribute. Previously, we did not emit catch handlers in that
circumstance. Now we do. As such, nothing that previously worked is
broken by this patch, but there is one test that would now fail. I
handled this by removing the RUN line for lowering this test to LLVM IR.
I left the checks so this will be easy to re-enable when proper try-op
lowering is implemented.
2026-02-13 10:40:53 -08:00
David Stone
584a589965
[clang][NFC] #include "clang/AST/StmtVisitor.h" where necessary (#172538) 2026-01-16 11:17:03 -07:00
Amr Hesham
18b38cf546
[CIR] Support Try catch with handler for specific type (#171042)
Add support for try-catch with a handler for a specific exception type

Issue https://github.com/llvm/llvm-project/issues/154992
2025-12-16 19:52:44 +01:00
Henrich Lauko
b2f36149d8
[CIR] Implement function personality attribute and its lowering (#171001) 2025-12-12 01:55:47 +01:00
Amr Hesham
5160a05b0e
[CIR] Emit CatchParamOp in the catch region (#171169)
Emit structured CatchParamOp in the catch region

Issue https://github.com/llvm/llvm-project/issues/154992
2025-12-10 13:53:17 +01:00
Andy Kaylor
ef0cd1dae3
[CIR][NFC] Fix warnings in release builds (#168791)
This fixes several warnings that occur in CIR release builds.
2025-11-19 16:12:17 -08:00
Amr Hesham
3d01d6ebfd
[CIR] Upstream non-empty Try block with catch all (#165158)
Upstream support for try block and catch all block with a function call
that may throw an exception.

Issue https://github.com/llvm/llvm-project/issues/154992
2025-11-16 10:50:04 +01:00
Amr Hesham
b0658b1151
[CIR][NFC] Upstream EHPersonality for function (#164883)
Upstream the EHPersonality class for a function as a prerequisite for
working with the handlers

Issue #154992
2025-10-25 13:40:47 +02:00
Amr Hesham
d019a02a19
[CIR] Upstream Exception CXXTryStmt (#162528)
Upstream the basic support for the C++ try catch statement with a try
block that doesn't contain any call instructions and with a catch-all
statement

Issue #154992
2025-10-21 19:34:58 +02:00
Amr Hesham
c25a2c7284
[CIR] Upstream Exception with empty try block (#162737)
Upstream, the basic support for the C++ try catch statement with an
empty try block

Issue https://github.com/llvm/llvm-project/issues/154992
2025-10-10 17:57:47 +02:00
Amr Hesham
ddef9ad6a1
[CIR] Upstream Exception ThrowOp with subexpr (#161818)
Upstream the support for ThrowOp with subexpr

Issue #154992
2025-10-07 17:53:35 +02:00
Amr Hesham
0499eb83fa
[CIR] Upstream Re-Throw with no return (#154994)
This change adds support for the throw op without sub expression and
with noreturn


Issue #154992
2025-08-29 20:24:35 +02:00