[PATCH] D126945: [LLVM][Docs] Fix code-block declarations in HowToSetUpLLVMStyleRTTI.rst
Aman LaChapelle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 2 22:57:47 PDT 2022
bzcheeseman created this revision.
Herald added a project: All.
bzcheeseman requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126945
Files:
llvm/docs/HowToSetUpLLVMStyleRTTI.rst
Index: llvm/docs/HowToSetUpLLVMStyleRTTI.rst
===================================================================
--- llvm/docs/HowToSetUpLLVMStyleRTTI.rst
+++ llvm/docs/HowToSetUpLLVMStyleRTTI.rst
@@ -494,6 +494,7 @@
invalid.
.. code-block:: c++
+
class SomeValue {
public:
SomeValue(void *ptr) : ptr(ptr) {}
@@ -509,6 +510,7 @@
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 @@
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 @@
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 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126945.433958.patch
Type: text/x-patch
Size: 1354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220603/1d8f442e/attachment.bin>
More information about the llvm-commits
mailing list