aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2023-10-30 07:37:42 -0400
committerGitHub <noreply@github.com>2023-10-30 07:37:42 -0400
commit8f11f984817ffe48725e35cffa0fdc45492497e9 (patch)
tree0edc1014567d1c24b48ee2f8c2fc7fed99a5c2cc
parentedebbb46b5033720a52e1a2cc3a2a96efbab88c2 (diff)
downloadllvm-8f11f984817ffe48725e35cffa0fdc45492497e9.zip
llvm-8f11f984817ffe48725e35cffa0fdc45492497e9.tar.gz
llvm-8f11f984817ffe48725e35cffa0fdc45492497e9.tar.bz2
[clang][NFC] Assert not llvm_unreachable (#70149)
An assert is better here.
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index c25ddef..7633c6b 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2084,11 +2084,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
Value *Src = Visit(const_cast<Expr*>(E));
llvm::Type *SrcTy = Src->getType();
llvm::Type *DstTy = ConvertType(DestTy);
- if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
- SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace()) {
- llvm_unreachable("wrong cast for pointers in different address spaces"
- "(must be an address space cast)!");
- }
+ assert(
+ (!SrcTy->isPtrOrPtrVectorTy() || !DstTy->isPtrOrPtrVectorTy() ||
+ SrcTy->getPointerAddressSpace() == DstTy->getPointerAddressSpace()) &&
+ "Address-space cast must be used to convert address spaces");
if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
if (auto *PT = DestTy->getAs<PointerType>()) {