Author: Timm Bäder Date: 2023-03-31T13:16:49+02:00 New Revision: cef69ce7791f2b6415ef3991347904381717a1ec
URL: https://github.com/llvm/llvm-project/commit/cef69ce7791f2b6415ef3991347904381717a1ec DIFF: https://github.com/llvm/llvm-project/commit/cef69ce7791f2b6415ef3991347904381717a1ec.diff LOG: [clang][Interp] Fix record initialization via CallExpr subclasses We can't just use VisitCallExpr() here, as that doesn't handle CallExpr subclasses such as CXXMemberCallExpr. Differential Revision: https://reviews.llvm.org/D141772 Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/records.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 1e61bc992448..afa5372a5112 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1413,7 +1413,7 @@ bool ByteCodeExprGen<Emitter>::visitRecordInitializer(const Expr *Initializer) { 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)) { diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index c0bfdeb090eb..448e1c0eb722 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -98,12 +98,20 @@ class C { 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits