[all-commits] [llvm/llvm-project] 8371a2: Wrap `llvm_unreachable` macro in do-while loop

Stefan Gränitz via All-commits all-commits at lists.llvm.org
Mon Aug 8 15:51:12 PDT 2022


  Branch: refs/heads/release/15.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 8371a291093ecd545fb6cb8d1de641f6d27847f9
      https://github.com/llvm/llvm-project/commit/8371a291093ecd545fb6cb8d1de641f6d27847f9
  Author: Stefan Gränitz <stefan.graenitz at gmail.com>
  Date:   2022-08-08 (Mon, 08 Aug 2022)

  Changed paths:
    M llvm/include/llvm/Support/ErrorHandling.h

  Log Message:
  -----------
  Wrap `llvm_unreachable` macro in do-while loop

Macros that expand into multiple terms can cause interesting preprocessor hickups depending
on the context they are used in. https://github.com/llvm/llvm-project/issues/56867 reported
a miscompilation of `llvm_unreachable(msg)` inside a `LLVM_DEBUG({ ... })` block. We were
able to fix it by wrapping the expansion in a `do {} while(false)`.

Differential Revision: https://reviews.llvm.org/D131337

(cherry picked from commit 7a66fe1075cfc7568554aeea9c40997dfb581979)




More information about the All-commits mailing list