[clang] 410f130 - [clang][Interp] Fix classify for glvalues of function type (#72269)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 10:41:02 PST 2023


Author: Timm Baeder
Date: 2023-11-14T19:40:59+01:00
New Revision: 410f130bb99b88f1a8f21659d98053e6f3e5e8f6

URL: https://github.com/llvm/llvm-project/commit/410f130bb99b88f1a8f21659d98053e6f3e5e8f6
DIFF: https://github.com/llvm/llvm-project/commit/410f130bb99b88f1a8f21659d98053e6f3e5e8f6.diff

LOG: [clang][Interp] Fix classify for glvalues of function type (#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

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 1c304caad5577ce..602cee45f381df5 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -129,7 +129,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