llvm.org GIT mirror llvm / cd04094
[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 Sean Silva 4 years ago
1 changed file(s) with 14 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
376376 argument is-a ``C``". As long as your implementation fulfills this
377377 contract, you can tweak and optimize it as much as you want.
378378
379 For example, LLVM-style RTTI can work fine in the presence of
380 multiple-inheritance by defining an appropriate ``classof``.
381 An example of this in practice is
382 `Decl `_ vs.
383 `DeclContext `_
384 inside Clang.
385 The ``Decl`` hierarchy is done very similarly to the example setup
386 demonstrated in this tutorial.
387 The key part is how to then incorporate ``DeclContext``: all that is needed
388 is in ``bool DeclContext::classof(const Decl *)``, which asks the question
389 "Given a ``Decl``, how can I determine if it is-a ``DeclContext``?".
390 It answers this with a simple switch over the set of ``Decl`` "kinds", and
391 returning true for ones that are known to be ``DeclContext``'s.
392
379393 .. TODO::
380394
381395 Touch on some of the more advanced features, like ``isa_impl`` and