@@ -113,7 +113,7 @@ rarely have to include this file directly).
113113
114114``isa<> ``:
115115 The ``isa<> `` operator works exactly like the Java "``instanceof ``" operator.
116- It returns true or false depending on whether a reference or pointer points to
116+ It returns `` true `` or `` false `` depending on whether a reference or pointer points to
117117 an instance of the specified class. This can be very useful for constraint
118118 checking of various sorts (example below).
119119
@@ -167,7 +167,7 @@ rarely have to include this file directly).
167167``isa_and_present<> ``:
168168 The ``isa_and_present<> `` operator works just like the ``isa<> `` operator,
169169 except that it allows for a null pointer as an argument (which it then
170- returns false). This can sometimes be useful, allowing you to combine several
170+ returns `` false `` ). This can sometimes be useful, allowing you to combine several
171171 null checks into one.
172172
173173``cast_if_present<> ``:
@@ -402,7 +402,7 @@ doxygen documentation or by looking at the unit test suite.
402402Error handling
403403--------------
404404
405- Proper error handling helps us identify bugs in our code, and helps end- users
405+ Proper error handling helps us identify bugs in our code, and helps end users
406406understand errors in their tool usage. Errors fall into two broad categories:
407407*programmatic * and *recoverable *, with different strategies for handling and
408408reporting.
@@ -449,10 +449,10 @@ violations even in builds that do not enable assertions:
449449Recoverable Errors
450450^^^^^^^^^^^^^^^^^^
451451
452- Recoverable errors represent an error in the program's environment, for example
452+ Recoverable errors represent an error in the program's environment, for example,
453453a resource failure (a missing file, a dropped network connection, etc.), or
454454malformed input. These errors should be detected and communicated to a level of
455- the program where they can be handled appropriately. Handling the error may be
455+ the program that can handle them appropriately. Handling the error may be
456456as simple as reporting the issue to the user, or it may involve attempts at
457457recovery.
458458
@@ -668,7 +668,7 @@ Since the list of handlers passed to ``handleErrors`` may not cover every error
668668type that can occur, the ``handleErrors `` function also returns an Error value
669669that must be checked or propagated. If the error value that is passed to
670670``handleErrors `` does not match any of the handlers it will be returned from
671- handleErrors. Idiomatic use of ``handleErrors `` thus looks like:
671+ `` handleErrors `` . Idiomatic use of ``handleErrors `` thus looks like:
672672
673673.. code-block :: c++
674674
@@ -683,18 +683,18 @@ handleErrors. Idiomatic use of ``handleErrors`` thus looks like:
683683 }))
684684 return Err;
685685
686- In cases where you truly know that the handler list is exhaustive the
686+ In cases where you truly know that the handler list is exhaustive, the
687687``handleAllErrors `` function can be used instead. This is identical to
688688``handleErrors `` except that it will terminate the program if an unhandled
689689error is passed in, and can therefore return void. The ``handleAllErrors ``
690690function should generally be avoided: the introduction of a new error type
691691elsewhere in the program can easily turn a formerly exhaustive list of errors
692692into a non-exhaustive list, risking unexpected program termination. Where
693- possible, use handleErrors and propagate unknown errors up the stack instead.
693+ possible, use `` handleErrors `` and propagate unknown errors up the stack instead.
694694
695695For tool code, where errors can be handled by printing an error message then
696696exiting with an error code, the :ref: `ExitOnError <err_exitonerr >` utility
697- may be a better choice than handleErrors, as it simplifies control flow when
697+ may be a better choice than `` handleErrors `` , as it simplifies control flow when
698698calling fallible functions.
699699
700700In situations where it is known that a particular call to a fallible function
@@ -706,9 +706,9 @@ simplifying control flow.
706706StringError
707707"""""""""""
708708
709- Many kinds of errors have no recovery strategy, the only action that can be
709+ Many kinds of errors have no recovery strategy; the only action that can be
710710taken is to report them to the user so that the user can attempt to fix the
711- environment. In this case representing the error as a string makes perfect
711+ environment. In this case, representing the error as a string makes perfect
712712sense. LLVM provides the ``StringError `` class for this purpose. It takes two
713713arguments: A string error message, and an equivalent ``std::error_code `` for
714714interoperability. It also provides a ``createStringError `` function to simplify
@@ -721,7 +721,7 @@ common usage of this class:
721721 createStringError(errc::executable_format_error, "Bad executable");
722722
723723If you're certain that the error you're building will never need to be converted
724- to a ``std::error_code `` you can use the ``inconvertibleErrorCode() `` function:
724+ to a ``std::error_code ``, you can use the ``inconvertibleErrorCode() `` function:
725725
726726.. code-block :: c++
727727
@@ -791,18 +791,18 @@ actually recognises three different forms of handler signature:
791791 Error(std::unique_ptr<UserDefinedError> E);
792792
793793Any error returned from a handler will be returned from the ``handleErrors ``
794- function so that it can be handled itself, or propagated up the stack.
794+ function so that it can be handled itself or propagated up the stack.
795795
796796.. _err_exitonerr :
797797
798798Using ExitOnError to simplify tool code
799799"""""""""""""""""""""""""""""""""""""""
800800
801- Library code should never call ``exit `` for a recoverable error, however in tool
801+ Library code should never call ``exit `` for a recoverable error; however, in tool
802802code (especially command line tools) this can be a reasonable approach. Calling
803803``exit `` upon encountering an error dramatically simplifies control flow as the
804804error no longer needs to be propagated up the stack. This allows code to be
805- written in straight-line style, as long as each fallible call is wrapped in a
805+ written in a straight-line style, as long as each fallible call is wrapped in a
806806check and call to exit. The ``ExitOnError `` class supports this pattern by
807807providing call operators that inspect ``Error `` values, stripping the error away
808808in the success case and logging to ``stderr `` then exiting in the failure case.
@@ -827,7 +827,7 @@ turning them into non-failing calls:
827827 }
828828
829829On failure, the error's log message will be written to ``stderr ``, optionally
830- preceded by a string "banner" that can be set by calling the setBanner method. A
830+ preceded by a string "banner" that can be set by calling the `` setBanner `` method. A
831831mapping can also be supplied from ``Error `` values to exit codes using the
832832``setExitCodeMapper `` method:
833833
@@ -854,8 +854,8 @@ Some functions may only fail for a subset of their inputs, so calls using known
854854safe inputs can be assumed to succeed.
855855
856856The cantFail functions encapsulate this by wrapping an assertion that their
857- argument is a success value and, in the case of Expected<T>, unwrapping the
858- T value:
857+ argument is a success value and, in the case of `` Expected<T> `` , unwrapping the
858+ `` T `` value:
859859
860860.. code-block :: c++
861861
@@ -868,16 +868,16 @@ T value:
868868 ...
869869 }
870870
871- Like the ExitOnError utility, cantFail simplifies control flow. Their treatment
871+ Like the ExitOnError utility, `` cantFail `` simplifies control flow. Their treatment
872872of error cases is very different, however: Where ExitOnError is guaranteed to
873- terminate the program on an error input, cantFail simply asserts that the result
873+ terminate the program on an error input, `` cantFail `` simply asserts that the result
874874is success. In debug builds this will result in an assertion failure if an error
875- is encountered. In release builds, the behavior of cantFail for failure values is
876- undefined. As such, care must be taken in the use of cantFail: clients must be
877- certain that a cantFail wrapped call really can not fail with the given
875+ is encountered. In release builds, the behavior of `` cantFail `` for failure values is
876+ undefined. As such, care must be taken in the use of `` cantFail `` : clients must be
877+ certain that a `` cantFail `` wrapped call really can not fail with the given
878878arguments.
879879
880- Use of the cantFail functions should be rare in library code, but they are
880+ Use of the `` cantFail `` functions should be rare in library code, but they are
881881likely to be of more use in tool and unit-test code where inputs and/or
882882mocked-up classes or functions may be known to be safe.
883883
@@ -979,7 +979,7 @@ completing the walk over the archive they could use the ``joinErrors`` utility:
979979 }
980980
981981The ``joinErrors `` routine builds a special error type called ``ErrorList ``,
982- which holds a list of user defined errors. The ``handleErrors `` routine
982+ which holds a list of user- defined errors. The ``handleErrors `` routine
983983recognizes this type and will attempt to handle each of the contained errors in
984984order. If all contained errors can be handled, ``handleErrors `` will return
985985``Error::success() ``; otherwise, ``handleErrors `` will concatenate the remaining
@@ -1146,7 +1146,7 @@ be passed by value.
11461146The ``LDBG `` and ``LLVM_DEBUG() `` macros and ``-debug `` option
11471147--------------------------------------------------------------
11481148
1149- Often when working on your pass you will put a bunch of debugging printouts and
1149+ Often, when working on your pass, you will put a bunch of debugging printouts and
11501150other code into your pass. After you get it working, you want to remove it, but
11511151you may need it again in the future (to work out new bugs that you run across).
11521152
@@ -1183,7 +1183,7 @@ The debug output can be enabled by passing the ``-debug`` command line argument.
11831183 $ opt < a.bc > /dev/null -mypass -debug
11841184 [my-pass MyPass.cpp:123 2] I am here!
11851185
1186- While `LDBG() ` is useful to add debug output to your code, there are cases
1186+ While `` LDBG() ` ` is useful to add debug output to your code, there are cases
11871187where you may need to guard a block of code with a debug check. The
11881188``llvm/Support/Debug.h `` (`doxygen
11891189<https://llvm.org/doxygen/Debug_8h_source.html> `__) file provides a macro named
@@ -1220,7 +1220,7 @@ with ``-debug``.
12201220Fine grained debug info with ``DEBUG_TYPE `` and the ``-debug-only `` option
12211221^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12221222
1223- Sometimes you may find yourself in a situation where enabling ``-debug `` just
1223+ Sometimes, you may find yourself in a situation where enabling ``-debug `` just
12241224turns on **too much ** information (such as when working on the code generator).
12251225If you want to enable debug information with more fine-grained control, you
12261226can control the debug type and level with associate with each logging statement
@@ -1389,7 +1389,7 @@ maintainable and useful.
13891389Adding debug counters to aid in debugging your code
13901390---------------------------------------------------
13911391
1392- Sometimes, when writing new passes, or trying to track down bugs, it
1392+ Sometimes, when writing new passes or trying to track down bugs, it
13931393is useful to be able to control whether certain things in your pass
13941394happen or not. For example, there are times the minimization tooling
13951395can only easily give you large testcases. You would like to narrow
@@ -1729,17 +1729,17 @@ page and one extra indirection when accessing elements with their positional
17291729index.
17301730
17311731In order to minimise the memory footprint of this container, it's important to
1732- balance the ``PageSize `` so that it's not too small (otherwise the overhead of the
1733- pointer per page might become too high) and not too big (otherwise the memory
1732+ balance the ``PageSize `` so that it's not too small (otherwise, the overhead of the
1733+ pointer per page might become too high) and not too big (otherwise, the memory
17341734is wasted if the page is not fully used).
17351735
17361736Moreover, while retaining the order of the elements based on their insertion
17371737index, like a vector, iterating over the elements via ``begin() `` and ``end() ``
1738- is not provided in the API, due to the fact accessing the elements in order
1738+ is not provided in the API, due to the fact that accessing the elements in order
17391739would allocate all the iterated pages, defeating memory savings and the purpose
17401740of the ``PagedVector ``.
17411741
1742- Finally a ``materialized_begin() `` and ``materialized_end `` iterators are
1742+ Finally, ``materialized_begin() `` and ``materialized_end `` iterators are
17431743provided to access the elements associated to the accessed pages, which could
17441744speed up operations that need to iterate over initialized elements in a
17451745non-ordered manner.
@@ -1782,9 +1782,9 @@ loop.
17821782^^^^^^^
17831783
17841784``std::deque `` is, in some senses, a generalized version of ``std::vector ``.
1785- Like ``std::vector ``, it provides constant time random access and other similar
1785+ Like ``std::vector ``, it provides constant- time random access and other similar
17861786properties, but it also provides efficient access to the front of the list. It
1787- does not guarantee continuity of elements within memory.
1787+ does not guarantee the continuity of elements within memory.
17881788
17891789In exchange for this extra flexibility, ``std::deque `` has significantly higher
17901790constant factor costs than ``std::vector ``. If possible, use ``std::vector `` or
@@ -1843,7 +1843,7 @@ Related classes of interest are explained in the following subsections:
18431843llvm/ADT/PackedVector.h
18441844^^^^^^^^^^^^^^^^^^^^^^^
18451845
1846- Useful for storing a vector of values using only a few number of bits for each
1846+ Useful for storing a vector of values using only a few bits for each
18471847value. Apart from the standard operations of a vector-like container, it can
18481848also perform an 'or' set operation.
18491849
@@ -1901,13 +1901,13 @@ non-empty ``ilist``\ s.
19011901
19021902The only sensible solution to this problem is to allocate a so-called *sentinel *
19031903along with the intrusive list, which serves as the ``end `` iterator, providing
1904- the back-link to the last element. However conforming to the C++ convention it
1904+ the back-link to the last element. However, conforming to the C++ convention it
19051905is illegal to ``operator++ `` beyond the sentinel and it also must not be
19061906dereferenced.
19071907
19081908These constraints allow for some implementation freedom to the ``ilist `` how to
19091909allocate and store the sentinel. The corresponding policy is dictated by
1910- ``ilist_traits<T> ``. By default a ``T `` gets heap-allocated whenever the need
1910+ ``ilist_traits<T> ``. By default, a ``T `` gets heap-allocated whenever the need
19111911for a sentinel arises.
19121912
19131913While the default policy is sufficient in most cases, it may break down when
@@ -1941,7 +1941,7 @@ String-like containers
19411941
19421942There are a variety of ways to pass around and use strings in C and C++, and
19431943LLVM adds a few new options to choose from. Pick the first option on this list
1944- that will do what you need, they are ordered according to their relative cost.
1944+ that will do what you need; they are ordered according to their relative cost.
19451945
19461946Note that it is generally preferred to *not * pass strings around as ``const
19471947char* ``'s. These have a number of problems, including the fact that they
@@ -1973,12 +1973,12 @@ either because they are C string literals, ``std::string``, a C array, or a
19731973``StringRef `` has a few major limitations which make more powerful string containers
19741974useful:
19751975
1976- #. You cannot directly convert a ``StringRef `` to a ' const char*' because there is
1976+ #. You cannot directly convert a ``StringRef `` to a `` const char* `` because there is
19771977 no way to add a trailing nul (unlike the ``.c_str() `` method on various stronger
19781978 classes).
19791979
19801980#. ``StringRef `` doesn't own or keep alive the underlying string bytes.
1981- As such it can easily lead to dangling pointers, and is not suitable for
1981+ As such, it can easily lead to dangling pointers, and is not suitable for
19821982 embedding in datastructures in most cases (instead, use an ``std::string `` or
19831983 something like that).
19841984
0 commit comments