[clang] [clang] Fix a crash when dynamic_cast-ing to a `final` class (PR #148088)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 11 09:56:30 PDT 2025
================
@@ -2341,8 +2341,15 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr,
} else if (IsExact) {
// If the destination type is effectively final, this pointer points to the
// right type if and only if its vptr has the right value.
- Value = CGM.getCXXABI().emitExactDynamicCast(
- *this, ThisAddr, SrcRecordTy, DestTy, DestRecordTy, CastEnd, CastNull);
+ std::optional<llvm::Value *> ExactCast =
+ CGM.getCXXABI().emitExactDynamicCast(*this, ThisAddr, SrcRecordTy,
----------------
efriedma-quic wrote:
Can we restructure this code in a way that's easier to read?
Like, maybe split emitExactDynamicCast into two functions: one to compute the offset, and one to actually do the cast. If we fail to compute the offset, we can skip all the work constructing the control flow, because the result is always just null.
https://github.com/llvm/llvm-project/pull/148088
More information about the cfe-commits
mailing list