[PATCH] D141772: [clang][Interp] Fix record initialization via CallExpr subclasses

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 04:17:07 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcef69ce7791f: [clang][Interp] Fix record initialization via CallExpr subclasses (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D141772?vs=489280&id=509985#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141772/new/

https://reviews.llvm.org/D141772

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===================================================================
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -98,12 +98,20 @@
     int b;
 
   constexpr C() : a(100), b(200) {}
+
+  constexpr C get() const {
+    return *this;
+  }
 };
 
 constexpr C c;
 static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
+constexpr C c2 = C().get();
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
 constexpr int getB() {
   C c;
   int &j = c.b;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1413,7 +1413,7 @@
     if (!this->emitDupPtr(Initializer))
       return false;
 
-    return this->VisitCallExpr(CE);
+    return this->visit(CE);
   } else if (const auto *DIE = dyn_cast<CXXDefaultInitExpr>(Initializer)) {
     return this->visitInitializer(DIE->getExpr());
   } else if (const auto *CE = dyn_cast<CastExpr>(Initializer)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141772.509985.patch
Type: text/x-patch
Size: 1096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230331/bd1ecb7d/attachment-0001.bin>


More information about the cfe-commits mailing list