https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/206056
Looks like we can handle more of them these days. >From 47d9f0ad1b4e548985576dfd49646a12a22f2d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 26 Jun 2026 14:08:45 +0200 Subject: [PATCH] [clang][bytecode] Make more reinterpret_casts non-fatal Looks like we can handle more of them these days. --- clang/lib/AST/ByteCode/Compiler.cpp | 27 +------------------ clang/test/AST/ByteCode/codegen.cpp | 2 +- .../cfi-unchecked-callee-attribute.cpp | 1 + 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 20b110b38ff78..020b2fc0143c5 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3486,33 +3486,8 @@ bool Compiler<Emitter>::VisitCXXReinterpretCastExpr( return this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/true, E); if (FromT == PT_Ptr || ToT == PT_Ptr) { - // Both types could be PT_Ptr because their expressions are glvalues. - OptPrimType PointeeFromT; - if (SubExpr->getType()->isPointerOrReferenceType()) - PointeeFromT = classify(SubExpr->getType()->getPointeeType()); - else - PointeeFromT = classify(SubExpr->getType()); - - OptPrimType PointeeToT; - if (E->getType()->isPointerOrReferenceType()) - PointeeToT = classify(E->getType()->getPointeeType()); - else - PointeeToT = classify(E->getType()); - - bool Fatal = true; - if (PointeeToT && PointeeFromT) { - if (isIntegerOrBoolType(*PointeeFromT) && - isIntegerOrBoolType(*PointeeToT)) - Fatal = false; - else if (E->getCastKind() == CK_LValueBitCast) - Fatal = false; - } else { - Fatal = SubExpr->getType().getTypePtr() != E->getType().getTypePtr(); - } - - if (!this->emitInvalidCast(CastKind::Reinterpret, Fatal, E)) + if (!this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/false, E)) return false; - if (E->getCastKind() == CK_LValueBitCast) return this->delegate(SubExpr); return this->VisitCastExpr(E); diff --git a/clang/test/AST/ByteCode/codegen.cpp b/clang/test/AST/ByteCode/codegen.cpp index 1b846baadc7b4..53698f13a17a2 100644 --- a/clang/test/AST/ByteCode/codegen.cpp +++ b/clang/test/AST/ByteCode/codegen.cpp @@ -118,7 +118,7 @@ int notdead() { // CHECK: _ZZ7notdeadvEN3$_0clEv // CHECK: ret i32 %cond -/// The conmparison of those two parameters should NOT work. +/// The comparison of those two parameters should NOT work. bool paramcmp(const int& lhs, const int& rhs) { if (&lhs == &rhs) return true; diff --git a/clang/test/CodeGen/cfi-unchecked-callee-attribute.cpp b/clang/test/CodeGen/cfi-unchecked-callee-attribute.cpp index feb7c9c30a219..b71111b057e9f 100644 --- a/clang/test/CodeGen/cfi-unchecked-callee-attribute.cpp +++ b/clang/test/CodeGen/cfi-unchecked-callee-attribute.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=cfi-icall -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=cfi-icall -o - %s -fexperimental-new-constant-interpreter | FileCheck %s #define CFI_UNCHECKED_CALLEE __attribute__((cfi_unchecked_callee)) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
