[clang] [clang][Interp] Fix classify for glvalues of function type (PR #72269)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 14 07:21:11 PST 2023
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/72269
This can't be tested right now but will show up once we use the new interpreter in evaluateAsConstantExpression() as well.
Pulled out from https://github.com/llvm/llvm-project/pull/70763
>From 074dd59057f1e1e1f2612ce4603a09420ca0a828 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Tue, 14 Nov 2023 16:19:34 +0100
Subject: [PATCH] [clang][Interp] Fix classify for glvalues of function type
This can't be tested right now but will show up once we use the new
interpreter in evaluateAsConstantExpression() as well.
---
clang/lib/AST/Interp/ByteCodeExprGen.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index ec9b6bb1408453c..2a75f22e13bed60 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -130,7 +130,13 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
/// Classifies a type.
std::optional<PrimType> classify(const Expr *E) const {
- return E->isGLValue() ? PT_Ptr : classify(E->getType());
+ if (E->isGLValue()) {
+ if (E->getType()->isFunctionType())
+ return PT_FnPtr;
+ return PT_Ptr;
+ }
+
+ return classify(E->getType());
}
std::optional<PrimType> classify(QualType Ty) const {
return Ctx.classify(Ty);
More information about the cfe-commits
mailing list