[clang] 48f8b74 - [clang][Interp] Support GenericSelectionExprs

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 31 23:15:29 PST 2024


Author: Timm Bäder
Date: 2024-02-01T08:15:11+01:00
New Revision: 48f8b74c35991fd3842e135481960449b1e25363

URL: https://github.com/llvm/llvm-project/commit/48f8b74c35991fd3842e135481960449b1e25363
DIFF: https://github.com/llvm/llvm-project/commit/48f8b74c35991fd3842e135481960449b1e25363.diff

LOG: [clang][Interp] Support GenericSelectionExprs

Just delegate to the resulting expression.

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/lib/AST/Interp/ByteCodeExprGen.h
    clang/test/Sema/c2x-auto.c
    clang/test/Sema/c2x-bool.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index c0721b0daf9a3..a93635a9f6888 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1940,6 +1940,12 @@ bool ByteCodeExprGen<Emitter>::VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
   return this->emitConst(E->getPackLength(), E);
 }
 
+template <class Emitter>
+bool ByteCodeExprGen<Emitter>::VisitGenericSelectionExpr(
+    const GenericSelectionExpr *E) {
+  return this->delegate(E->getResultExpr());
+}
+
 template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
   if (E->containsErrors())
     return false;

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index ec88f31ae516a..1710b4446432b 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -108,6 +108,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
   bool VisitOffsetOfExpr(const OffsetOfExpr *E);
   bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E);
   bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
+  bool VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;

diff  --git a/clang/test/Sema/c2x-auto.c b/clang/test/Sema/c2x-auto.c
index 7cbd1db31315a..97754b2fb836b 100644
--- a/clang/test/Sema/c2x-auto.c
+++ b/clang/test/Sema/c2x-auto.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s
+// RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s -fexperimental-new-constant-interpreter
 
 void test_basic_types(void) {
   auto undefined;     // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}

diff  --git a/clang/test/Sema/c2x-bool.c b/clang/test/Sema/c2x-bool.c
index 0bc147228fda4..98cb8507359d0 100644
--- a/clang/test/Sema/c2x-bool.c
+++ b/clang/test/Sema/c2x-bool.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
 
 _Static_assert(_Generic(true, _Bool : 1, default: 0));
 _Static_assert(_Generic(false, _Bool : 1, default: 0));


        


More information about the cfe-commits mailing list