diff options
author | Sean Silva <chisophugis@gmail.com> | 2015-02-07 01:16:26 +0000 |
---|---|---|
committer | Sean Silva <chisophugis@gmail.com> | 2015-02-07 01:16:26 +0000 |
commit | b8d41c5d33cfdc9a8be8b16ba1d2c5fdc7c478f7 (patch) | |
tree | 8c6de2bd85aa4e170771700c49116370d80b5169 /llvm/docs/HowToSetUpLLVMStyleRTTI.rst | |
parent | 7f95aacfe610b2d2ca9c31a75ca6d06b84c59418 (diff) | |
download | bcm5719-llvm-b8d41c5d33cfdc9a8be8b16ba1d2c5fdc7c478f7.tar.gz bcm5719-llvm-b8d41c5d33cfdc9a8be8b16ba1d2c5fdc7c478f7.zip |
[docs][LLVM-style RTTI] Add a mention of multiple inheritance.
llvm-svn: 228479
Diffstat (limited to 'llvm/docs/HowToSetUpLLVMStyleRTTI.rst')
-rw-r--r-- | llvm/docs/HowToSetUpLLVMStyleRTTI.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/docs/HowToSetUpLLVMStyleRTTI.rst b/llvm/docs/HowToSetUpLLVMStyleRTTI.rst index c293b4e4069..38929948590 100644 --- a/llvm/docs/HowToSetUpLLVMStyleRTTI.rst +++ b/llvm/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 <http://clang.llvm.org/doxygen/classclang_1_1Decl.html>`_ vs. +`DeclContext <http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html>`_ +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 |