[clang] [clang][bytecode] Avoid revisiting decomposition decl in visitDeclRef (PR #144226)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 14 23:44:04 PDT 2025
https://github.com/Lancern updated https://github.com/llvm/llvm-project/pull/144226
>From 8046031437a5cfafac17c7c9d978c25fb8ed2479 Mon Sep 17 00:00:00 2001
From: Sirui Mu <msrlancern at gmail.com>
Date: Sat, 14 Jun 2025 22:25:48 +0800
Subject: [PATCH] [clang][Bytecode] Avoid revisiting decomposition decl
---
clang/lib/AST/ByteCode/Compiler.cpp | 4 ----
clang/test/AST/ByteCode/cxx17.cpp | 10 ++++++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index bf38b2e5d537d..9fe4803ce98ec 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -6591,10 +6591,6 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
return T->isReferenceType();
};
- // DecompositionDecls are just proxies for us.
- if (isa<DecompositionDecl>(VD))
- return revisit(VD);
-
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
typeShouldBeVisited(VD->getType())) {
if (const Expr *Init = VD->getAnyInitializer();
diff --git a/clang/test/AST/ByteCode/cxx17.cpp b/clang/test/AST/ByteCode/cxx17.cpp
index 08a40e0a92862..6898a544a5b2a 100644
--- a/clang/test/AST/ByteCode/cxx17.cpp
+++ b/clang/test/AST/ByteCode/cxx17.cpp
@@ -141,3 +141,13 @@ template <int x> constexpr auto c() {
}
auto y = c<1>(); // both-note {{in instantiation of function template specialization 'c<1>' requested here}}
+
+namespace non_constexpr_structured_binding {
+
+void f1() {
+ int arr[2] = {};
+ auto [a, b] = arr;
+ static_assert(&a != &b);
+}
+
+}
More information about the cfe-commits
mailing list