[PATCH] D135551: [clang] replace `assert(0)` with `llvm_unreachable` NFC

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 08:39:52 PDT 2022


dblaikie added a comment.

Because I was looking, some other `assert(0)` -> `llvm_unreachable` cleanups (though, yes, even the earliest cleanups include some assert(0) -> report_fatal_error, but for externally/user-reachable failures, like invalid bitcode, I think). Some of these are more blanket/wide reaching than others, for sure. (& no doubt the naive search through the commit log doesn't find all the cleanups)

I /think/ when I was looking I did find one from 2017 that Richard Smith approved that included llvm_unreachable in the Clang C API, in terms of more recent precedent for some of this... but can't find that again right now.

rGabd1561f15e <https://reviews.llvm.org/rGabd1561f15ee466c0fd9abeede2cdcde2ebb2cec>:[LLDBAssert] Use unreachable instead of assert(0)
rGf9da10ce4544ea66fe6fad5b943d3700d192a1e1 <https://reviews.llvm.org/rGf9da10ce4544ea66fe6fad5b943d3700d192a1e1>:Change to assert(0,x) to llvm_unreachable(x)
rG7a247f709baa2cd19111af9e18965df4e419949a <https://reviews.llvm.org/rG7a247f709baa2cd19111af9e18965df4e419949a>:Turn effective assert(0) into llvm_unreachable
rG35b2f75733c98e5904c5a75f8bcedeb96c4f4eda <https://reviews.llvm.org/rG35b2f75733c98e5904c5a75f8bcedeb96c4f4eda>:Convert some assert(0) to llvm_unreachable or fold an 'if' condition into the assert.
rGd8d43191d8afe2c4b5b2d3be62cd73ddc3ddc6c9 <https://reviews.llvm.org/rGd8d43191d8afe2c4b5b2d3be62cd73ddc3ddc6c9>:Replace some assert(0)'s with llvm_unreachable.
rG2a30d7889fc54c8a74d73b79be3dd030bac41b06 <https://reviews.llvm.org/rG2a30d7889fc54c8a74d73b79be3dd030bac41b06>:Replace some assert(0)'s with llvm_unreachable.
rG0039f3f0607702f2d16d60addff74c67869e2144 <https://reviews.llvm.org/rG0039f3f0607702f2d16d60addff74c67869e2144>:Replace some assert(0)'s with llvm_unreachable.
rGc7193c48d9d7e44e9fd0c39205e8b7cfbf5d5458 <https://reviews.llvm.org/rGc7193c48d9d7e44e9fd0c39205e8b7cfbf5d5458>:Convert assert(0) to llvm_unreachable to silence a warning about Addend being uninitialized in default case.
rG7b7a67c5c8daa051e42837dc3e5e65adab9cf09c <https://reviews.llvm.org/rG7b7a67c5c8daa051e42837dc3e5e65adab9cf09c>:[ARM64] Fix 'assert("...")' to be 'assert(0 && "...")'. Otherwise, it is no assert at all. ;] Some of these should probably be switched to llvm_unreachable, but I didn't want to perturb the behavior in this patch.
rGeaa3a7efab65d0a65ddda7fdb7e5fbdbd5f897ad <https://reviews.llvm.org/rGeaa3a7efab65d0a65ddda7fdb7e5fbdbd5f897ad>:Use llvm_unreachable instead of assert(0)
rGd7fd95a5c1eb19e5754281b540f09e86ced1b9d4 <https://reviews.llvm.org/rGd7fd95a5c1eb19e5754281b540f09e86ced1b9d4>:Change assert(0 && "text") to llvm_unreachable(0 && "text")
rG2962d9599e463265edae599285bbc6351f1cc0ef <https://reviews.llvm.org/rG2962d9599e463265edae599285bbc6351f1cc0ef>:Suggest llvm_unreachable over assert(0).
rG2e007de42de48dc05bdb7aa9d3c9e8902ee720fe <https://reviews.llvm.org/rG2e007de42de48dc05bdb7aa9d3c9e8902ee720fe>:Revert "Target/AMDGPU/AMDILIntrinsicInfo.cpp: Use llvm_unreachable() in nonreturn function, instead of assert(0)."
rGdc4261794fdbf2e3001f369d8b8bbd77eb923602 <https://reviews.llvm.org/rGdc4261794fdbf2e3001f369d8b8bbd77eb923602>:Target/AMDGPU/AMDILIntrinsicInfo.cpp: Use llvm_unreachable() in nonreturn function, instead of assert(0).
rG751eb3d2b30d90069b1797a31f8e489f0763c585 <https://reviews.llvm.org/rG751eb3d2b30d90069b1797a31f8e489f0763c585>:use llvm_unreachable() instead of assert(0) for invalid enum values in switch statements
rGbdf39a46a302df7cb07e948a6780265b3335fbda <https://reviews.llvm.org/rGbdf39a46a302df7cb07e948a6780265b3335fbda>:Convert assert(0) to llvm_unreachable.
rGeb455832b4c7cb1046ab9fb9f6f8ca40202874a4 <https://reviews.llvm.org/rGeb455832b4c7cb1046ab9fb9f6f8ca40202874a4>:Silence various build warnings from Hexagon backend that show up in release builds. Mostly converting 'assert(0)' to 'llvm_unreachable' to silence warnings about missing returns. Also fold some variable declarations into asserts to prevent the variables from being unused in release builds.
rGabd1561f15ee466c0fd9abeede2cdcde2ebb2cec <https://reviews.llvm.org/rGabd1561f15ee466c0fd9abeede2cdcde2ebb2cec>:[LLDBAssert] Use unreachable instead of assert(0)
rGf9da10ce4544ea66fe6fad5b943d3700d192a1e1 <https://reviews.llvm.org/rGf9da10ce4544ea66fe6fad5b943d3700d192a1e1>:Change to assert(0,x) to llvm_unreachable(x)
rG7a247f709baa2cd19111af9e18965df4e419949a <https://reviews.llvm.org/rG7a247f709baa2cd19111af9e18965df4e419949a>:Turn effective assert(0) into llvm_unreachable
rG35b2f75733c98e5904c5a75f8bcedeb96c4f4eda <https://reviews.llvm.org/rG35b2f75733c98e5904c5a75f8bcedeb96c4f4eda>:Convert some assert(0) to llvm_unreachable or fold an 'if' condition into the assert.
rGd8d43191d8afe2c4b5b2d3be62cd73ddc3ddc6c9 <https://reviews.llvm.org/rGd8d43191d8afe2c4b5b2d3be62cd73ddc3ddc6c9>:Replace some assert(0)'s with llvm_unreachable.
rG2a30d7889fc54c8a74d73b79be3dd030bac41b06 <https://reviews.llvm.org/rG2a30d7889fc54c8a74d73b79be3dd030bac41b06>:Replace some assert(0)'s with llvm_unreachable.
rG0039f3f0607702f2d16d60addff74c67869e2144 <https://reviews.llvm.org/rG0039f3f0607702f2d16d60addff74c67869e2144>:Replace some assert(0)'s with llvm_unreachable.
rGc7193c48d9d7e44e9fd0c39205e8b7cfbf5d5458 <https://reviews.llvm.org/rGc7193c48d9d7e44e9fd0c39205e8b7cfbf5d5458>:Convert assert(0) to llvm_unreachable to silence a warning about Addend being uninitialized in default case.
rG7b7a67c5c8daa051e42837dc3e5e65adab9cf09c <https://reviews.llvm.org/rG7b7a67c5c8daa051e42837dc3e5e65adab9cf09c>:[ARM64] Fix 'assert("...")' to be 'assert(0 && "...")'. Otherwise, it is no assert at all. ;] Some of these should probably be switched to llvm_unreachable, but I didn't want to perturb the behavior in this patch.
rGeaa3a7efab65d0a65ddda7fdb7e5fbdbd5f897ad <https://reviews.llvm.org/rGeaa3a7efab65d0a65ddda7fdb7e5fbdbd5f897ad>:Use llvm_unreachable instead of assert(0)
rGd7fd95a5c1eb19e5754281b540f09e86ced1b9d4 <https://reviews.llvm.org/rGd7fd95a5c1eb19e5754281b540f09e86ced1b9d4>:Change assert(0 && "text") to llvm_unreachable(0 && "text")
rG2962d9599e463265edae599285bbc6351f1cc0ef <https://reviews.llvm.org/rG2962d9599e463265edae599285bbc6351f1cc0ef>:Suggest llvm_unreachable over assert(0).
rG2e007de42de48dc05bdb7aa9d3c9e8902ee720fe <https://reviews.llvm.org/rG2e007de42de48dc05bdb7aa9d3c9e8902ee720fe>:Revert "Target/AMDGPU/AMDILIntrinsicInfo.cpp: Use llvm_unreachable() in nonreturn function, instead of assert(0)."
rGdc4261794fdbf2e3001f369d8b8bbd77eb923602 <https://reviews.llvm.org/rGdc4261794fdbf2e3001f369d8b8bbd77eb923602>:Target/AMDGPU/AMDILIntrinsicInfo.cpp: Use llvm_unreachable() in nonreturn function, instead of assert(0).
rG751eb3d2b30d90069b1797a31f8e489f0763c585 <https://reviews.llvm.org/rG751eb3d2b30d90069b1797a31f8e489f0763c585>:use llvm_unreachable() instead of assert(0) for invalid enum values in switch statements
rGbdf39a46a302df7cb07e948a6780265b3335fbda <https://reviews.llvm.org/rGbdf39a46a302df7cb07e948a6780265b3335fbda>:Convert assert(0) to llvm_unreachable.
rGeb455832b4c7cb1046ab9fb9f6f8ca40202874a4 <https://reviews.llvm.org/rGeb455832b4c7cb1046ab9fb9f6f8ca40202874a4>:Silence various build warnings from Hexagon backend that show up in release builds. Mostly converting 'assert(0)' to 'llvm_unreachable' to silence warnings about missing returns. Also fold some variable declarations into asserts to prevent the variables from being unused in release builds.
rG8619c37b5b8795fcc722373f5fd9a5d0c07195af <https://reviews.llvm.org/rG8619c37b5b8795fcc722373f5fd9a5d0c07195af>:Replace assert(0) with llvm_unreachable to avoid warnings about dropping off the end of a non-void function in Release builds.
rGa2886c21d9a08d63c324cc61aa91ae0893507a31 <https://reviews.llvm.org/rGa2886c21d9a08d63c324cc61aa91ae0893507a31>:Convert assert(0) to llvm_unreachable
rGe55c556a247a9c0decb4e256d9e897dfc9cf841d <https://reviews.llvm.org/rGe55c556a247a9c0decb4e256d9e897dfc9cf841d>:Convert assert(0) to llvm_unreachable
rGc514b5474a3feb6b4b2775b75c4f8eaf0676a9d0 <https://reviews.llvm.org/rGc514b5474a3feb6b4b2775b75c4f8eaf0676a9d0>:Convert assert(0) to llvm_unreachable
rGee4dab5f1f7a0c32167b8b91c5733e77d4d88dcc <https://reviews.llvm.org/rGee4dab5f1f7a0c32167b8b91c5733e77d4d88dcc>:Convert assert(0) to llvm_unreachable
rGc4965bce14249ad13bd532af827bdd5c21b340fd <https://reviews.llvm.org/rGc4965bce14249ad13bd532af827bdd5c21b340fd>:Convert assert(0) to llvm_unreachable
rG4ed7278ff4ef206d01867fda76bf90df36398c4c <https://reviews.llvm.org/rG4ed7278ff4ef206d01867fda76bf90df36398c4c>:Convert assert(0) to llvm_unreachable in X86 Target directory.
rG83f3bdaa457e7ac28fdda724808be8fd4f1d275d <https://reviews.llvm.org/rG83f3bdaa457e7ac28fdda724808be8fd4f1d275d>:Convert some assert(0) in default of switch statements to llvm_unreachable.
rG83d382b1cad133cb163a68dd7149fae2802275e1 <https://reviews.llvm.org/rG83d382b1cad133cb163a68dd7149fae2802275e1>:Switch assert(0/false) llvm_unreachable.
rGea431722972fa481bbe2898d180678a08f977fa0 <https://reviews.llvm.org/rGea431722972fa481bbe2898d180678a08f977fa0>:Prefer llvm_unreachable to assert(0)
rG1ab40bef8dfe416cc82455eea39d01d496752d90 <https://reviews.llvm.org/rG1ab40bef8dfe416cc82455eea39d01d496752d90>:After converting assert(0) to LLVM_UNREACHABLE we lost file/line location. Fix by making the LLVM_UNREACHABLE pass __FILE__ and __LINE__ to llvm_unreachable.
rG56d065972602c45a4109617f32eb8605e5017c5e <https://reviews.llvm.org/rG56d065972602c45a4109617f32eb8605e5017c5e>:assert(0) -> LLVM_UNREACHABLE. Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds.
rG6dd2730024c20647b92ddfbb80e9a8bf33308ccd <https://reviews.llvm.org/rG6dd2730024c20647b92ddfbb80e9a8bf33308ccd>:Start converting to new error handling API. cerr+abort -> llvm_report_error assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable-> abort() included)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135551



More information about the cfe-commits mailing list