aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/CodeGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-01 13:01:07 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-01 13:01:07 +0800
commitb4d1ddb99e1305f6ea6217e7570dda2a94b16e51 (patch)
treefb4501033e8d03f06511bff638e0929c4114f465 /backend/lib/CodeGen
parentfd8770b01a7a3ae85ba85fb43b21803c88593ad7 (diff)
downloadrcc-project-b4d1ddb99e1305f6ea6217e7570dda2a94b16e51.tar.gz
rcc-project-b4d1ddb99e1305f6ea6217e7570dda2a94b16e51.tar.xz
[CMake] Match LLVM EH and RTTI defaults
Disable C++ exceptions and RTTI by default while retaining explicit, validated opt-in switches. Replace the arena's exception syntax with an RAII construction guard so both configurations share one implementation.
Diffstat (limited to 'backend/lib/CodeGen')
-rw-r--r--backend/lib/CodeGen/MachineFunction.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/backend/lib/CodeGen/MachineFunction.cpp b/backend/lib/CodeGen/MachineFunction.cpp
index e19c115..fc1508c 100644
--- a/backend/lib/CodeGen/MachineFunction.cpp
+++ b/backend/lib/CodeGen/MachineFunction.cpp
@@ -35,16 +35,13 @@ public:
[[nodiscard]] ObjectT *create(ArgumentTs &&...Arguments) {
void *Storage = Resource.allocate(sizeof(ObjectT), alignof(ObjectT));
ObjectT *Object = ::new (Storage) ObjectT(std::forward<ArgumentTs>(Arguments)...);
- try {
- Destructors.push_back(DestructorRecord{
- Object,
- [](void *RawObject) noexcept { std::destroy_at(static_cast<ObjectT *>(RawObject)); },
- });
- } catch (...) {
- std::destroy_at(Object);
- throw;
- }
- return Object;
+ auto DestroyObject = [](ObjectT *TypedObject) noexcept { std::destroy_at(TypedObject); };
+ std::unique_ptr<ObjectT, decltype(DestroyObject)> ConstructionGuard(Object, DestroyObject);
+ Destructors.push_back(DestructorRecord{
+ Object,
+ [](void *RawObject) noexcept { std::destroy_at(static_cast<ObjectT *>(RawObject)); },
+ });
+ return ConstructionGuard.release();
}
private: