[llvm-commits] [llvm] r120450 - /llvm/trunk/docs/CodingStandards.html

Chris Lattner sabre at nondot.org
Tue Nov 30 11:20:40 PST 2010


Author: lattner
Date: Tue Nov 30 13:20:40 2010
New Revision: 120450

URL: http://llvm.org/viewvc/llvm-project?rev=120450&view=rev
Log:
forbid rtti and exceptions

Modified:
    llvm/trunk/docs/CodingStandards.html

Modified: llvm/trunk/docs/CodingStandards.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodingStandards.html?rev=120450&r1=120449&r2=120450&view=diff
==============================================================================
--- llvm/trunk/docs/CodingStandards.html (original)
+++ llvm/trunk/docs/CodingStandards.html Tue Nov 30 13:20:40 2010
@@ -29,6 +29,7 @@
           <li><a href="#ci_warningerrors">Treat Compiler Warnings Like
               Errors</a></li>
           <li><a href="#ci_portable_code">Write Portable Code</a></li>
+          <li><a href="#ci_rtti_exceptions">Do not use RTTI or Exceptions</a></li>
           <li><a href="#ci_class_struct">Use of <tt>class</tt>/<tt>struct</tt> Keywords</a></li>
         </ol></li>
     </ol></li>
@@ -406,6 +407,28 @@
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection">
+<a name="ci_rtti_exceptions">Do not use RTTI or Exceptions</a>
+</div>
+<div class="doc_text">
+
+<p>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.
+</p>
+
+<p>
+That said, LLVM does make extensive use of a hand-rolled form of RTTI that use
+templates like <a href="ProgrammersManual.html#isa">isa<>, cast<>,
+and dyn_cast<></a>.  This form of RTTI is opt-in and can be added to any
+class.  It is also substantially more efficient than dynamic_cast<>.
+</p>
+
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
 <a name="ci_class_struct">Use of <tt>class</tt> and <tt>struct</tt> Keywords</a>
 </div>
 <div class="doc_text">





More information about the llvm-commits mailing list