aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-04-11 10:35:28 +0200
committerGitHub <noreply@github.com>2025-04-11 10:35:28 +0200
commitfafeaab6d91334e9c251aa222cbca1eb94536bf2 (patch)
tree70e0dbea594a62fbfc6abe62f1e4d04ee1cdfceb /clang/lib/AST/ByteCode/Interp.cpp
parent0276915a6c888906b2140a3d97e5ce32057a3ca5 (diff)
downloadllvm-fafeaab6d91334e9c251aa222cbca1eb94536bf2.zip
llvm-fafeaab6d91334e9c251aa222cbca1eb94536bf2.tar.gz
llvm-fafeaab6d91334e9c251aa222cbca1eb94536bf2.tar.bz2
[clang][bytecode] Misc TypeidPointer fixes (#135322)
Fix comparing type id pointers, add mor info when print()ing them, use the most derived type in GetTypeidPtr() and the canonically unqualified type when we know the type statically.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Interp.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 768ae6e..0afd772 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1848,7 +1848,23 @@ bool GetTypeidPtr(InterpState &S, CodePtr OpPC, const Type *TypeInfoType) {
if (!P.isBlockPointer())
return false;
- S.Stk.push<Pointer>(P.getType().getTypePtr(), TypeInfoType);
+ // Pick the most-derived type.
+ const Type *T = P.getDeclPtr().getType().getTypePtr();
+ // ... unless we're currently constructing this object.
+ // FIXME: We have a similar check to this in more places.
+ if (S.Current->getFunction()) {
+ for (const InterpFrame *Frame = S.Current; Frame; Frame = Frame->Caller) {
+ if (const Function *Func = Frame->getFunction();
+ Func && (Func->isConstructor() || Func->isDestructor()) &&
+ P.block() == Frame->getThis().block()) {
+ T = Func->getParentDecl()->getTypeForDecl();
+ break;
+ }
+ }
+ }
+
+ S.Stk.push<Pointer>(T->getCanonicalTypeUnqualified().getTypePtr(),
+ TypeInfoType);
return true;
}