[clang] 8f11f98 - [clang][NFC] Assert not llvm_unreachable (#70149)
    via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Oct 30 04:37:46 PDT 2023
    
    
  
Author: Nathan Sidwell
Date: 2023-10-30T07:37:42-04:00
New Revision: 8f11f984817ffe48725e35cffa0fdc45492497e9
URL: https://github.com/llvm/llvm-project/commit/8f11f984817ffe48725e35cffa0fdc45492497e9
DIFF: https://github.com/llvm/llvm-project/commit/8f11f984817ffe48725e35cffa0fdc45492497e9.diff
LOG: [clang][NFC] Assert not llvm_unreachable (#70149)
An assert is better here.
Added: 
    
Modified: 
    clang/lib/CodeGen/CGExprScalar.cpp
Removed: 
    
################################################################################
diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index c25ddeff9adc3a7..7633c6b17db88eb 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 
diff erent 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>()) {
        
    
    
More information about the cfe-commits
mailing list