[clang] [clang][Interp] Fix classify for glvalues of function type (PR #72269)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 14 07:21:41 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/72269.diff
1 Files Affected:
- (modified) clang/lib/AST/Interp/ByteCodeExprGen.h (+7-1)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/72269
More information about the cfe-commits
mailing list