aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.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/Compiler.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/Compiler.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index eafe735..86b4358 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -3629,15 +3629,22 @@ template <class Emitter>
bool Compiler<Emitter>::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
const Type *TypeInfoType = E->getType().getTypePtr();
+ auto canonType = [](const Type *T) {
+ return T->getCanonicalTypeUnqualified().getTypePtr();
+ };
+
if (!E->isPotentiallyEvaluated()) {
if (DiscardResult)
return true;
if (E->isTypeOperand())
return this->emitGetTypeid(
- E->getTypeOperand(Ctx.getASTContext()).getTypePtr(), TypeInfoType, E);
- return this->emitGetTypeid(E->getExprOperand()->getType().getTypePtr(),
- TypeInfoType, E);
+ canonType(E->getTypeOperand(Ctx.getASTContext()).getTypePtr()),
+ TypeInfoType, E);
+
+ return this->emitGetTypeid(
+ canonType(E->getExprOperand()->getType().getTypePtr()), TypeInfoType,
+ E);
}
// Otherwise, we need to evaluate the expression operand.