[PATCH] D96092: [AST] Update LVal before evaluating lambda decl fields.
Zequan Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 4 16:48:30 PST 2021
zequanwu updated this revision to Diff 321617.
zequanwu marked an inline comment as done.
zequanwu added a comment.
Remove comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96092/new/
https://reviews.llvm.org/D96092
Files:
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===================================================================
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1437,3 +1437,13 @@
return true;
}
static_assert(destroy_at_test());
+
+namespace PR48582 {
+ struct S {
+ void *p = this;
+ constexpr S() {}
+ constexpr S(const S&) {}
+ };
+ constexpr bool b = [a = S(), b = S()] { return a.p == b.p; }();
+ static_assert(!b);
+}
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10016,6 +10016,7 @@
auto *CaptureInitIt = E->capture_init_begin();
const LambdaCapture *CaptureIt = ClosureClass->captures_begin();
bool Success = true;
+ const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(ClosureClass);
for (const auto *Field : ClosureClass->fields()) {
assert(CaptureInitIt != E->capture_init_end());
// Get the initializer for this field
@@ -10026,8 +10027,13 @@
if (!CurFieldInit)
return Error(E);
+ LValue Subobject = This;
+
+ if (!HandleLValueMember(Info, E, Subobject, Field, &Layout))
+ return false;
+
APValue &FieldVal = Result.getStructField(Field->getFieldIndex());
- if (!EvaluateInPlace(FieldVal, Info, This, CurFieldInit)) {
+ if (!EvaluateInPlace(FieldVal, Info, Subobject, CurFieldInit)) {
if (!Info.keepEvaluatingAfterFailure())
return false;
Success = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96092.321617.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210205/de2a0c3a/attachment-0001.bin>
More information about the cfe-commits
mailing list