From cd040942669e9955197a5b59986655cde8a46c01 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Sat, 7 Feb 2015 01:16:26 +0000 Subject: [PATCH] [docs][LLVM-style RTTI] Add a mention of multiple inheritance. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228479 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/HowToSetUpLLVMStyleRTTI.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/HowToSetUpLLVMStyleRTTI.rst b/docs/HowToSetUpLLVMStyleRTTI.rst index c293b4e4069..38929948590 100644 --- a/docs/HowToSetUpLLVMStyleRTTI.rst +++ b/docs/HowToSetUpLLVMStyleRTTI.rst @@ -377,6 +377,20 @@ contract for ``classof`` is "return ``true`` if the dynamic type of the argument is-a ``C``". As long as your implementation fulfills this contract, you can tweak and optimize it as much as you want. +For example, LLVM-style RTTI can work fine in the presence of +multiple-inheritance by defining an appropriate ``classof``. +An example of this in practice is +`Decl `_ vs. +`DeclContext `_ +inside Clang. +The ``Decl`` hierarchy is done very similarly to the example setup +demonstrated in this tutorial. +The key part is how to then incorporate ``DeclContext``: all that is needed +is in ``bool DeclContext::classof(const Decl *)``, which asks the question +"Given a ``Decl``, how can I determine if it is-a ``DeclContext``?". +It answers this with a simple switch over the set of ``Decl`` "kinds", and +returning true for ones that are known to be ``DeclContext``'s. + .. TODO:: Touch on some of the more advanced features, like ``isa_impl`` and