https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/207946
`getDeclPtr()` will return the declaration pointer, which might be unrelated to the pointer we actually care about. >From aabb5d33d6f72929f58133f7bffdc3bed04b8ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Tue, 7 Jul 2026 11:09:51 +0200 Subject: [PATCH] asdf --- clang/lib/AST/ByteCode/Interp.cpp | 2 +- clang/lib/AST/ByteCode/Pointer.cpp | 2 +- clang/test/AST/ByteCode/typeid.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 7185569dc103b..34edbfdb62a70 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -2744,7 +2744,7 @@ bool GetTypeidPtr(InterpState &S, CodePtr OpPC, const Type *TypeInfoType) { } // Pick the most-derived type. - CanQualType T = P.getDeclPtr().getType()->getCanonicalTypeUnqualified(); + CanQualType T = P.stripBaseCasts().getType()->getCanonicalTypeUnqualified(); // ... unless we're currently constructing this object. // FIXME: We have a similar check to this in more places. if (S.Current->getFunction()) { diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 4eb6df2f0d6a1..6d19379d6ecd7 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -801,7 +801,7 @@ bool Pointer::hasSameBase(const Pointer &A, const Pointer &B) { if (A.isFunctionPointer() && B.isFunctionPointer()) return true; if (A.isTypeidPointer() && B.isTypeidPointer()) - return true; + return A.asTypeidPointer().TypePtr == B.asTypeidPointer().TypePtr; if (A.StorageKind != B.StorageKind) return false; diff --git a/clang/test/AST/ByteCode/typeid.cpp b/clang/test/AST/ByteCode/typeid.cpp index f529fb3b7a533..4e7664f505c23 100644 --- a/clang/test/AST/ByteCode/typeid.cpp +++ b/clang/test/AST/ByteCode/typeid.cpp @@ -93,3 +93,16 @@ namespace MissingInitalizer { constexpr auto &x = items[0].ti; // both-error {{must be initialized by a constant expression}} \ // both-note {{initializer of 'items' is unknown}} } + +namespace TypeIdInOtherStruct { + struct X { + virtual constexpr ~X() {} + }; + struct Y : X {}; + struct Z { + mutable Y y; + }; + constexpr Z z; + auto &zti = typeid(z.y); + static_assert(&zti == &typeid(Y)); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
