[clang] 5676478 - [clang][bytecode] Avoid revisiting decomposition decl in visitDeclRef (#144226)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 15 08:00:20 PDT 2025
Author: Sirui Mu
Date: 2025-06-15T23:00:16+08:00
New Revision: 567647888ea3dd292827bbac445d316d6a6b0ecb
URL: https://github.com/llvm/llvm-project/commit/567647888ea3dd292827bbac445d316d6a6b0ecb
DIFF: https://github.com/llvm/llvm-project/commit/567647888ea3dd292827bbac445d316d6a6b0ecb.diff
LOG: [clang][bytecode] Avoid revisiting decomposition decl in visitDeclRef (#144226)
This simple patch removes the code to revisit `DecompositionDecl` in
`visitDeclRef`. The revisit will try to emit the initializer of the
`DecompositionDecl`, which could result in evaluation errors if the
`DecompositionDecl` is not within a constexpr context.
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/cxx17.cpp
Removed:
################################################################################
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..0cf3a4f666d63 100644
--- a/clang/test/AST/ByteCode/cxx17.cpp
+++ b/clang/test/AST/ByteCode/cxx17.cpp
@@ -141,3 +141,11 @@ template <int x> constexpr auto c() {
}
auto y = c<1>(); // both-note {{in instantiation of function template specialization 'c<1>' requested here}}
+
+namespace NonConstexprStructuredBinding {
+ void f1() {
+ int arr[2] = {};
+ auto [a, b] = arr;
+ static_assert(&a != &b);
+ }
+}
More information about the cfe-commits
mailing list