From 8b18572ea7ca7733d8140cb1947079b8704d37db Mon Sep 17 00:00:00 2001 From: Kristof Beyls Date: Fri, 3 Jun 2022 11:24:49 +0200 Subject: [PATCH] [docs] Fix RST code-block syntax in HowToSetUpLLVMStyleRTTI.rst --- llvm/docs/HowToSetUpLLVMStyleRTTI.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llvm/docs/HowToSetUpLLVMStyleRTTI.rst b/llvm/docs/HowToSetUpLLVMStyleRTTI.rst index 5293658..37843c1 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 struct CastInfo : public CastIsPossible, @@ -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 struct CastInfo : public NullableValueCastFailed, @@ -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 struct CastInfo : public OptionalValueCast {}; @@ -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 valOr = dyn_cast(someVal); With the ``_is_present`` variants, you can even do optional chaining like this: .. code-block:: c++ + Optional someVal = ...; Optional valOr = dyn_cast_if_present(someVal); -- 2.7.4