Skip to content

Commit 8f11f98

Browse files
authored
[clang][NFC] Assert not llvm_unreachable (#70149)
An assert is better here.
1 parent edebbb4 commit 8f11f98

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,11 +2084,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
20842084
Value *Src = Visit(const_cast<Expr*>(E));
20852085
llvm::Type *SrcTy = Src->getType();
20862086
llvm::Type *DstTy = ConvertType(DestTy);
2087-
if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
2088-
SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace()) {
2089-
llvm_unreachable("wrong cast for pointers in different address spaces"
2090-
"(must be an address space cast)!");
2091-
}
2087+
assert(
2088+
(!SrcTy->isPtrOrPtrVectorTy() || !DstTy->isPtrOrPtrVectorTy() ||
2089+
SrcTy->getPointerAddressSpace() == DstTy->getPointerAddressSpace()) &&
2090+
"Address-space cast must be used to convert address spaces");
20922091

20932092
if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
20942093
if (auto *PT = DestTy->getAs<PointerType>()) {

0 commit comments

Comments
 (0)