Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not using C++ exceptions by design, in llvm/clang

llvm/clang are considered good C++ code bases. I wonder why C++ exceptions arenot used in them at all?

Memory is managed using something like pools, and erros are reported with returnd values and codes like in C. They even wrapping operator new to be placement new that returns error and not exception when no memory.

Do you have idea why llvm philosophy is not to use C++ exceptions when most books recommend using them?

like image 968
zaharpopov Avatar asked Nov 02 '10 17:11

zaharpopov


People also ask

Does Clang support C?

The Clang project provides a language front-end and tooling infrastructure for languages in the C language family (C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.

What is __ Cxa_throw?

__cxa_throw. External interface to throw in the C++ support library. Takes three arguments: an exception object, a typeinfo for that object, and a pointer to the destructor to call when we are done with that object.

What version of C++ does LLVM use?

C++ Standard Versions Unless otherwise documented, LLVM subprojects are written using standard C++17 code and avoid unnecessary vendor-specific extensions.

Does LLVM use Clang?

Clang operates in tandem with the LLVM compiler back end and has been a subproject of LLVM 2.6 and later. As with LLVM, it is free and open-source software under the Apache License 2.0 software license. Its contributors include Apple, Microsoft, Google, ARM, Sony, Intel, and AMD.


1 Answers

Chris Lattner recently clarified this issue in the LLVM project coding standards.

Not using exceptions and RTTI reduces executable size and reduces overhead. (You might argue that zero-cost exceptions have no overhead unless thrown. At a minimum, they actually break up the code into smaller basic blocks and inhibit some types of code motion.)

like image 88
ohmantics Avatar answered Sep 28 '22 05:09

ohmantics