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)) {
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)) {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits