aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorJason Rice <ricejasonf@gmail.com>2025-01-29 12:43:52 -0800
committerGitHub <noreply@github.com>2025-01-29 21:43:52 +0100
commitabc8812df02599fc413d9ed77b992f8236ed2af9 (patch)
treed5fc8a01c03d5700aed337d8b8516fa3d461a326 /clang/lib/CodeGen
parent608012ace43b42d97884204016c6a8f4883b4359 (diff)
downloadllvm-abc8812df02599fc413d9ed77b992f8236ed2af9.zip
llvm-abc8812df02599fc413d9ed77b992f8236ed2af9.tar.gz
llvm-abc8812df02599fc413d9ed77b992f8236ed2af9.tar.bz2
[Clang][P1061] Add stuctured binding packs (#121417)
This is an implementation of P1061 Structure Bindings Introduce a Pack without the ability to use packs outside of templates. There is a couple of ways the AST could have been sliced so let me know what you think. The only part of this change that I am unsure of is the serialization/deserialization stuff. I followed the implementation of other Exprs, but I do not really know how it is tested. Thank you for your time considering this. --------- Co-authored-by: Yanzuo Liu <zwuis@outlook.com>
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp3
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp3
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp3
3 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f0abfaa..db59579 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5083,10 +5083,9 @@ CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, llvm::Value *Storage,
assert(CGM.getCodeGenOpts().hasReducedDebugInfo());
if (auto *DD = dyn_cast<DecompositionDecl>(VD)) {
- for (auto *B : DD->bindings()) {
+ for (BindingDecl *B : DD->flat_bindings())
EmitDeclare(B, Storage, std::nullopt, Builder,
VD->getType()->isReferenceType());
- }
// Don't emit an llvm.dbg.declare for the composite storage as it doesn't
// correspond to a user variable.
return nullptr;
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 747e420d..cc6815d 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -164,9 +164,10 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
"Should not see file-scope variables inside a function!");
EmitVarDecl(VD);
if (auto *DD = dyn_cast<DecompositionDecl>(&VD))
- for (auto *B : DD->bindings())
+ for (auto *B : DD->flat_bindings())
if (auto *HD = B->getHoldingVar())
EmitVarDecl(*HD);
+
return;
}
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index eb8d3ce..a015d64 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -7014,9 +7014,10 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
case Decl::VarTemplateSpecialization:
EmitGlobal(cast<VarDecl>(D));
if (auto *DD = dyn_cast<DecompositionDecl>(D))
- for (auto *B : DD->bindings())
+ for (auto *B : DD->flat_bindings())
if (auto *HD = B->getHoldingVar())
EmitGlobal(HD);
+
break;
// Indirect fields from global anonymous structs and unions can be