From 558f5d2a396c533ddceb9ff278fcb2b76641c0f2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 30 Nov 2010 19:20:40 +0000 Subject: [PATCH] forbid rtti and exceptions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120450 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CodingStandards.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/CodingStandards.html b/docs/CodingStandards.html index ff00c816738..a2420805ec6 100644 --- a/docs/CodingStandards.html +++ b/docs/CodingStandards.html @@ -29,6 +29,7 @@
  • Treat Compiler Warnings Like Errors
  • Write Portable Code
  • +
  • Do not use RTTI or Exceptions
  • Use of class/struct Keywords
  • @@ -404,6 +405,28 @@ libSystem.

    + +
    +Do not use RTTI or Exceptions +
    +
    + +

    LLVM does not use RTTI (e.g. dynamic_cast<>) or exceptions, in an +effort to reduce code and executable size. These two language features violate +the general C++ principle of "you only pay for what you use", causing executable +bloat even if exceptions are never used in a code base, or if RTTI is never used +for a class. Because of this, we turn them off globally in the code. +

    + +

    +That said, LLVM does make extensive use of a hand-rolled form of RTTI that use +templates like isa<>, cast<>, +and dyn_cast<>. This form of RTTI is opt-in and can be added to any +class. It is also substantially more efficient than dynamic_cast<>. +

    + +
    +
    Use of class and struct Keywords