From b4d1ddb99e1305f6ea6217e7570dda2a94b16e51 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 13:01:07 +0800 Subject: [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. --- backend/lib/CodeGen/MachineFunction.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'backend/lib/CodeGen/MachineFunction.cpp') 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(Arguments)...); - try { - Destructors.push_back(DestructorRecord{ - Object, - [](void *RawObject) noexcept { std::destroy_at(static_cast(RawObject)); }, - }); - } catch (...) { - std::destroy_at(Object); - throw; - } - return Object; + auto DestroyObject = [](ObjectT *TypedObject) noexcept { std::destroy_at(TypedObject); }; + std::unique_ptr ConstructionGuard(Object, DestroyObject); + Destructors.push_back(DestructorRecord{ + Object, + [](void *RawObject) noexcept { std::destroy_at(static_cast(RawObject)); }, + }); + return ConstructionGuard.release(); } private: -- cgit v1.2.3