[PATCH] D81130: [docs] Fix self-contradictory description of llvm_unreachable

Jan Korous via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 20:53:54 PDT 2020


jkorous created this revision.
jkorous added reviewers: aaron.ballman, Bigcheese.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.

Just two paragraphs above it says:

> If the compiler does not support this [skipping code generation for a particular branch], it will fall back to the "abort" implementation.

And that actually correctly describes current `llvm_unreachable` implementation.
https://llvm.org/docs/CodingStandards.html#assert-liberally

Alternatively, if we agree that `llvm_unreachable` should really have an assert-like semantics then we can make the call to `abort` in `llvm_unreachable_internal` conditional on `#ifndef NDEBUG`.
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/ErrorHandling.cpp#L210
That would've to be approved by more people though.


https://reviews.llvm.org/D81130

Files:
  llvm/docs/CodingStandards.rst
  llvm/include/llvm/Support/ErrorHandling.h


Index: llvm/include/llvm/Support/ErrorHandling.h
===================================================================
--- llvm/include/llvm/Support/ErrorHandling.h
+++ llvm/include/llvm/Support/ErrorHandling.h
@@ -127,7 +127,7 @@
 /// In !NDEBUG builds, prints the message and location info to stderr.
 /// In NDEBUG builds, becomes an optimizer hint that the current location
 /// is not supposed to be reachable.  On compilers that don't support
-/// such hints, prints a reduced message instead.
+/// such hints, prints a reduced message instead and aborts the program.
 ///
 /// Use this instead of assert(0).  It conveys intent more clearly and
 /// allows compilers to omit some unnecessary code.
Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -1200,8 +1200,7 @@
 Use of ``assert`` should always include a testable predicate (as opposed to
 ``assert(false)``).
 
-Neither assertions or ``llvm_unreachable`` will abort the program on a release
-build. If the error condition can be triggered by user input then the
+If the error condition can be triggered by user input then the
 recoverable error mechanism described in :doc:`ProgrammersManual` should be
 used instead. In cases where this is not practical, ``report_fatal_error`` may
 be used.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81130.268355.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200604/ad37ebbf/attachment.bin>


More information about the llvm-commits mailing list