mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-12 12:33:17 +00:00
[docs][LLVM-style RTTI] Add a mention of multiple inheritance.
llvm-svn: 228479
This commit is contained in:
parent
79a2edfa80
commit
d2940e0dbb
@ -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
|
argument is-a ``C``". As long as your implementation fulfills this
|
||||||
contract, you can tweak and optimize it as much as you want.
|
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::
|
.. TODO::
|
||||||
|
|
||||||
Touch on some of the more advanced features, like ``isa_impl`` and
|
Touch on some of the more advanced features, like ``isa_impl`` and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user