Search code examples
c++exceptioncoding-stylellvmclang

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


LLVM/Clang are considered good C++ code bases. I wonder why C++ exceptions are not used in them at all?

Memory is managed using something like pools, and errors are reported with returned values and codes like in C. They are 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?


Solution

  • 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.)