[all-commits] [llvm/llvm-project] 2f07e6: [Clang] Fix missing vtable for `dynamic_cast<Final...

Piotr Fusik via All-commits all-commits at lists.llvm.org
Wed Jul 8 03:31:18 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2f07e6be216858d15e691b2a59514aa73db0f8dc
      https://github.com/llvm/llvm-project/commit/2f07e6be216858d15e691b2a59514aa73db0f8dc
  Author: Piotr Fusik <p.fusik at samsung.com>
  Date:   2026-07-08 (Wed, 08 Jul 2026)

  Changed paths:
    M clang/include/clang/AST/TypeBase.h
    M clang/lib/AST/Type.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/test/CodeGenCXX/dynamic-cast-exact.cpp

  Log Message:
  -----------
  [Clang] Fix missing vtable for `dynamic_cast<FinalClass &>(*this)` in a function template (#207349)

This is a follow-up to #202594, which fixed a pointer cast, but not
a reference cast. Surprisingly, `CXXDynamicCastExpr::getType()`
for a reference cast is a `RecordType` and not a `ReferenceType`.

How this happens:
In `Sema::BuildCXXNamedCast`, a `CastOperation Op` variable
is constructed. The `CastOperation` constructor initializes
`ResultType(destType.getNonLValueExprType(S.Context))`
where `QualType::getNonLValueExprType` turns a `ReferenceType` into
a `RecordType`. `Sema::BuildCXXNamedCast` then passes `Op.ResultType`
to `CXXDynamicCastExpr::Create`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list