-<p>C++ allows the specification of which exception types that can be thrown from
-a function. To represent this a top level landing pad may exist to filter out
-invalid types. To express this in LLVM code the landing pad will call <a
-href="#llvm_eh_filter"><tt>llvm.eh.filter</tt></a> instead of <a
-href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The arguments are the
-same, but what gets created in the exception table is different. <a
-href="#llvm_eh_filter"><tt>llvm.eh.filter</tt></a> will return a negative value
-if it doesn't find a match. If no match is found then a call to
-<tt>__cxa_call_unexpected</tt> should be made, otherwise
-<tt>_Unwind_Resume</tt>. Each of these functions require a reference to the
-exception structure.</p>
+<p>C++ allows the specification of which exception types can be thrown from a
+ function. To represent this a top level landing pad may exist to filter out
+ invalid types. To express this in LLVM code the landing pad will
+ call <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>. The
+ arguments are a reference to the exception structure, a reference to the
+ personality function, the length of the filter expression (the number of type
+ infos plus one), followed by the type infos themselves.
+ <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> will return a
+ negative value if the exception does not match any of the type infos. If no
+ match is found then a call to <tt>__cxa_call_unexpected</tt> should be made,
+ otherwise <tt>_Unwind_Resume</tt>. Each of these functions requires a
+ reference to the exception structure. Note that the most general form of an
+ <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> call can contain
+ any number of type infos, filter expressions and cleanups (though having more
+ than one cleanup is pointless). The LLVM C++ front-end can generate such
+ <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> calls due to
+ inlining creating nested exception handling scopes.</p>
+
+</div>
+
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="restrictions">Restrictions</a>
+</div>
+
+<div class="doc_text">
+
+<p>The semantics of the invoke instruction require that any exception that
+ unwinds through an invoke call should result in a branch to the invoke's
+ unwind label. However such a branch will only happen if the
+ <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> matches. Thus in
+ order to ensure correct operation, the front-end must only generate
+ <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> calls that are
+ guaranteed to always match whatever exception unwinds through the invoke.
+ For most languages it is enough to pass zero, indicating the presence of
+ a <a href="#cleanups">cleanup</a>, as the
+ last <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a> argument.
+ However for C++ this is not sufficient, because the C++ personality function
+ will terminate the program if it detects that unwinding the exception only
+ results in matches with cleanups. For C++ a <tt>null i8*</tt> should be
+ passed as the last <a href="#llvm_eh_selector"><tt>llvm.eh.selector</tt></a>
+ argument instead. This is interpreted as a catch-all by the C++ personality
+ function, and will always match.</p>