summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/docs/ProgrammersManual.rst
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
committerpatrick <patrick@openbsd.org>2018-04-06 14:26:03 +0000
commitbdabc2f19ffb9e20600dad6e8a300842a7bda50e (patch)
treec50e7b2e5449b074651bb82a58517a8ebc4a8cf7 /gnu/llvm/docs/ProgrammersManual.rst
parentPrint a 'p' flag for file descriptors that were opened after pledge(2). (diff)
downloadwireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.tar.xz
wireguard-openbsd-bdabc2f19ffb9e20600dad6e8a300842a7bda50e.zip
Import LLVM 6.0.1 release including clang, lld and lldb.
"where is the kaboom?" deraadt@
Diffstat (limited to 'gnu/llvm/docs/ProgrammersManual.rst')
-rw-r--r--gnu/llvm/docs/ProgrammersManual.rst25
1 files changed, 17 insertions, 8 deletions
diff --git a/gnu/llvm/docs/ProgrammersManual.rst b/gnu/llvm/docs/ProgrammersManual.rst
index d115a9cf6de..07048a52319 100644
--- a/gnu/llvm/docs/ProgrammersManual.rst
+++ b/gnu/llvm/docs/ProgrammersManual.rst
@@ -441,6 +441,15 @@ the program where they can be handled appropriately. Handling the error may be
as simple as reporting the issue to the user, or it may involve attempts at
recovery.
+.. note::
+
+ While it would be ideal to use this error handling scheme throughout
+ LLVM, there are places where this hasn't been practical to apply. In
+ situations where you absolutely must emit a non-programmatic error and
+ the ``Error`` model isn't workable you can call ``report_fatal_error``,
+ which will call installed error handlers, print a message, and exit the
+ program.
+
Recoverable errors are modeled using LLVM's ``Error`` scheme. This scheme
represents errors using function return values, similar to classic C integer
error codes, or C++'s ``std::error_code``. However, the ``Error`` class is
@@ -486,7 +495,7 @@ that inherits from the ErrorInfo utility, E.g.:
Error printFormattedFile(StringRef Path) {
if (<check for valid format>)
- return make_error<InvalidObjectFile>(Path);
+ return make_error<BadFileFormat>(Path);
// print file contents.
return Error::success();
}
@@ -1031,7 +1040,7 @@ line argument:
.. code-block:: c++
- DEBUG(errs() << "I am here!\n");
+ DEBUG(dbgs() << "I am here!\n");
Then you can run your pass like this:
@@ -1067,10 +1076,10 @@ follows:
.. code-block:: c++
#define DEBUG_TYPE "foo"
- DEBUG(errs() << "'foo' debug type\n");
+ DEBUG(dbgs() << "'foo' debug type\n");
#undef DEBUG_TYPE
#define DEBUG_TYPE "bar"
- DEBUG(errs() << "'bar' debug type\n"));
+ DEBUG(dbgs() << "'bar' debug type\n");
#undef DEBUG_TYPE
Then you can run your pass like this:
@@ -1111,8 +1120,8 @@ preceding example could be written as:
.. code-block:: c++
- DEBUG_WITH_TYPE("foo", errs() << "'foo' debug type\n");
- DEBUG_WITH_TYPE("bar", errs() << "'bar' debug type\n"));
+ DEBUG_WITH_TYPE("foo", dbgs() << "'foo' debug type\n");
+ DEBUG_WITH_TYPE("bar", dbgs() << "'bar' debug type\n");
.. _Statistic:
@@ -1224,7 +1233,7 @@ Define your DebugCounter like this:
.. code-block:: c++
DEBUG_COUNTER(DeleteAnInstruction, "passname-delete-instruction",
- "Controls which instructions get delete").
+ "Controls which instructions get delete");
The ``DEBUG_COUNTER`` macro defines a static variable, whose name
is specified by the first argument. The name of the counter
@@ -2105,7 +2114,7 @@ is stored in the same allocation as the Value of a pair).
StringMap also provides query methods that take byte ranges, so it only ever
copies a string if a value is inserted into the table.
-StringMap iteratation order, however, is not guaranteed to be deterministic, so
+StringMap iteration order, however, is not guaranteed to be deterministic, so
any uses which require that should instead use a std::map.
.. _dss_indexmap: