[llvm] [ProgrammersManual] Update report_fatal_error docs (PR #138502)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 01:01:17 PDT 2025


================
@@ -437,6 +437,15 @@ that should never be entered if the program invariants hold:
       llvm_unreachable("X should be Foo or Bar here");
   }
 
+Additionally, ``reportFatalInternalError`` can be used to report invariant
+violations even in builds that do not enable assertions:
+
+.. code-block:: c++
+
+  if (VerifyFooAnalysis && !Foo.verify()) {
+    reportFatalInternalError("Analysis 'foo' not preserved");
+  }
+
----------------
nikic wrote:

I think this section in general needs some more information on what these APIs do under different build options. E.g. for llvm_unreachable() we have three different behaviors based on the value of LLVM_ENABLE_ASSERTIONS and LLVM_UNREACHABLE_OPTIMIZE. It will either abort with a crash trace, aggressively optimize away the unreachable path or produce a trap. (Which means that llvm_unreachable can be both weaker and stronger than plain assert...) 

https://github.com/llvm/llvm-project/pull/138502


More information about the llvm-commits mailing list