[clang] 649e811 - [C++20] [Modules] Handling capturing strucuted bindings
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 28 19:46:15 PST 2023
Author: Chuanqi Xu
Date: 2023-11-29T11:45:31+08:00
New Revision: 649e8111a95ae0d8814576e9ca74823572ee404b
URL: https://github.com/llvm/llvm-project/commit/649e8111a95ae0d8814576e9ca74823572ee404b
DIFF: https://github.com/llvm/llvm-project/commit/649e8111a95ae0d8814576e9ca74823572ee404b.diff
LOG: [C++20] [Modules] Handling capturing strucuted bindings
Close https://github.com/llvm/llvm-project/issues/72828.
This should be an overlook that we extend the type of captures but we
forgot to fix it in deserializer side.
Added:
clang/test/Modules/pr72828.cppm
Modified:
clang/lib/Serialization/ASTReaderDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 79817b3fb1ec3a0..bc16cfc67a24f9f 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2032,7 +2032,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
break;
case LCK_ByCopy:
case LCK_ByRef:
- auto *Var = readDeclAs<VarDecl>();
+ auto *Var = readDeclAs<ValueDecl>();
SourceLocation EllipsisLoc = readSourceLocation();
new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
ToCapture++;
diff --git a/clang/test/Modules/pr72828.cppm b/clang/test/Modules/pr72828.cppm
new file mode 100644
index 000000000000000..574523188507a17
--- /dev/null
+++ b/clang/test/Modules/pr72828.cppm
@@ -0,0 +1,24 @@
+// Test that we can handle capturing structured bindings.
+//
+// RUN: rm -fr %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \
+// RUN: %s -emit-module-interface -o %t/m.pcm
+// RUN: %clang_cc1 -std=c++23 -triple %itanium_abi_triple \
+// RUN: -S -emit-llvm -disable-llvm-passes %t/m.pcm \
+// RUN: -o - | FileCheck %s
+
+export module m;
+
+struct s {
+ int m;
+};
+
+void f() {
+ auto [x] = s();
+ [x] {};
+}
+
+// Check that we can generate the LLVM IR expectedly.
+// CHECK: define{{.*}}@_ZGIW1m
More information about the cfe-commits
mailing list