[llvm] r301773 - [docs] Simplify some language for Error/cantFail in the programmer's manual.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 30 10:24:53 PDT 2017
Author: lhames
Date: Sun Apr 30 12:24:52 2017
New Revision: 301773
URL: http://llvm.org/viewvc/llvm-project?rev=301773&view=rev
Log:
[docs] Simplify some language for Error/cantFail in the programmer's manual.
Modified:
llvm/trunk/docs/ProgrammersManual.rst
Modified: llvm/trunk/docs/ProgrammersManual.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.rst?rev=301773&r1=301772&r2=301773&view=diff
==============================================================================
--- llvm/trunk/docs/ProgrammersManual.rst (original)
+++ llvm/trunk/docs/ProgrammersManual.rst Sun Apr 30 12:24:52 2017
@@ -776,22 +776,21 @@ readability.
Using cantFail to simplify safe callsites
"""""""""""""""""""""""""""""""""""""""""
-Some functions may only fail for a subset of their inputs. For such functions
-call-sites using known-safe inputs can assume that the result will be a success
-value.
+Some functions may only fail for a subset of their inputs, so calls using known
+safe inputs can be assumed to succeed.
The cantFail functions encapsulate this by wrapping an assertion that their
argument is a success value and, in the case of Expected<T>, unwrapping the
-T value from the Expected<T> argument:
+T value:
.. code-block:: c++
- Error mayFail(int X);
- Expected<int> mayFail2(int X);
+ Error onlyFailsForSomeXValues(int X);
+ Expected<int> onlyFailsForSomeXValues2(int X);
void foo() {
- cantFail(mayFail(KnownSafeValue));
- int Y = cantFail(mayFail2(KnownSafeValue));
+ cantFail(onlyFailsForSomeXValues(KnownSafeValue));
+ int Y = cantFail(onlyFailsForSomeXValues2(KnownSafeValue));
...
}
@@ -801,8 +800,8 @@ terminate the program on an error input,
is success. In debug builds this will result in an assertion failure if an error
is encountered. In release builds the behavior of cantFail for failure values is
undefined. As such, care must be taken in the use of cantFail: clients must be
-certain that a cantFail wrapped call really can not fail under any
-circumstances.
+certain that a cantFail wrapped call really can not fail with the given
+arguments.
Use of the cantFail functions should be rare in library code, but they are
likely to be of more use in tool and unit-test code where inputs and/or
More information about the llvm-commits
mailing list