[llvm] 8b18572 - [docs] Fix RST code-block syntax in HowToSetUpLLVMStyleRTTI.rst
Kristof Beyls via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 02:25:54 PDT 2022
Author: Kristof Beyls
Date: 2022-06-03T11:24:49+02:00
New Revision: 8b18572ea7ca7733d8140cb1947079b8704d37db
URL: https://github.com/llvm/llvm-project/commit/8b18572ea7ca7733d8140cb1947079b8704d37db
DIFF: https://github.com/llvm/llvm-project/commit/8b18572ea7ca7733d8140cb1947079b8704d37db.diff
LOG: [docs] Fix RST code-block syntax in HowToSetUpLLVMStyleRTTI.rst
Added:
Modified:
llvm/docs/HowToSetUpLLVMStyleRTTI.rst
Removed:
################################################################################
diff --git a/llvm/docs/HowToSetUpLLVMStyleRTTI.rst b/llvm/docs/HowToSetUpLLVMStyleRTTI.rst
index 5293658bef5fe..37843c1ef80e0 100644
--- a/llvm/docs/HowToSetUpLLVMStyleRTTI.rst
+++ b/llvm/docs/HowToSetUpLLVMStyleRTTI.rst
@@ -494,6 +494,7 @@ constructible from ``nullptr`` and that results in a value you can tell is
invalid.
.. code-block:: c++
+
class SomeValue {
public:
SomeValue(void *ptr) : ptr(ptr) {}
@@ -509,6 +510,7 @@ now, we assume that the types we want to cast *to* all provide ``classof``. So
we can use some provided cast traits like so:
.. code-block:: c++
+
template<typename T>
struct CastInfo<T, SomeValue>
: public CastIsPossible<T, SomeValue>,
@@ -525,6 +527,7 @@ Now given the value above ``SomeValue``, maybe we'd like to be able to cast to
that type from a char pointer type. So what we would do in that case is:
.. code-block:: c++
+
template<typename T>
struct CastInfo<SomeValue, T *>
: public NullableValueCastFailed<SomeValue>,
@@ -547,6 +550,7 @@ way to tell when an object is invalid, you may want to use ``llvm::Optional``.
In those cases, you probably want something like this:
.. code-block:: c++
+
template<typename T>
struct CastInfo<T, SomeValue>
: public OptionalValueCast<T, SomeValue> {};
@@ -555,12 +559,14 @@ That cast trait requires that ``T`` is constructible from ``const SomeValue &``
but it enables casting like so:
.. code-block:: c++
+
SomeValue someVal = ...;
Optional<AnotherValue> valOr = dyn_cast<AnotherValue>(someVal);
With the ``_is_present`` variants, you can even do optional chaining like this:
.. code-block:: c++
+
Optional<SomeValue> someVal = ...;
Optional<AnotherValue> valOr = dyn_cast_if_present<AnotherValue>(someVal);
More information about the llvm-commits
mailing list