[PATCH] D76721: Clarify use of llvm_unreachable in the coding standard

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 13:28:33 PDT 2020


aaron.ballman updated this revision to Diff 252413.
aaron.ballman added a comment.

Updated based on review feedback, showing more context as well.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76721/new/

https://reviews.llvm.org/D76721

Files:
  llvm/docs/CodingStandards.rst


Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -1153,6 +1153,13 @@
 code for this branch. If the compiler does not support this, it will fall back
 to the "abort" implementation.
 
+Use ``llvm_unreachable`` to mark a specific point in code that should never be
+reached. This is especially desirable for addressing warnings about unreachable
+branches, etc., but can be used whenever reaching a particular code path is
+unconditionally a bug (not originating from user input; see below) of some kind.
+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
 recoverable error mechanism described in :doc:`ProgrammersManual` should be


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76721.252413.patch
Type: text/x-patch
Size: 958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200324/bfa7df09/attachment.bin>


More information about the llvm-commits mailing list