Skip to content

Conversation

@Lancern
Copy link
Member

@Lancern Lancern commented Jun 14, 2025

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.

@Lancern Lancern added the clang:bytecode Issues for the clang bytecode constexpr interpreter label Jun 14, 2025
@Lancern Lancern requested a review from tbaederr June 14, 2025 14:30
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 14, 2025

@llvm/pr-subscribers-clang

Author: Sirui Mu (Lancern)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/144226.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Compiler.cpp (-4)
  • (added) clang/test/AST/ByteCode/structured-binding.cpp (+8)
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/structured-binding.cpp b/clang/test/AST/ByteCode/structured-binding.cpp
new file mode 100644
index 0000000000000..63eaad8448249
--- /dev/null
+++ b/clang/test/AST/ByteCode/structured-binding.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++17 -verify %s
+
+void f1() {
+  int arr[2] = {};
+  auto [a, b] = arr;
+  static_assert(&a != &b);  // expected-no-diagnostics
+}

@Lancern Lancern force-pushed the clang/bytecode/structured-binding branch from 50afed7 to 8046031 Compare June 15, 2025 06:43
@Lancern Lancern force-pushed the clang/bytecode/structured-binding branch from 8046031 to 72b99e6 Compare June 15, 2025 13:46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot the namespace name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that... Updated.

@Lancern Lancern force-pushed the clang/bytecode/structured-binding branch from 72b99e6 to c9649ce Compare June 15, 2025 14:25
Copy link
Contributor

@tbaederr tbaederr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@Lancern
Copy link
Member Author

Lancern commented Jun 15, 2025

I'll merge it once the CI is green.

@Lancern Lancern merged commit 5676478 into llvm:main Jun 15, 2025
7 checks passed
@Lancern Lancern deleted the clang/bytecode/structured-binding branch June 15, 2025 15:00
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 15, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-windows running on linaro-armv8-windows-msvc-05 while building clang at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/141/builds/9465

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
UNSUPPORTED: lldb-api :: commands/process/handle/TestProcessHandle.py (201 of 2243)
XFAIL: lldb-api :: commands/process/launch-with-shellexpand/TestLaunchWithShellExpand.py (202 of 2243)
PASS: lldb-api :: commands/process/launch/TestProcessLaunch.py (203 of 2243)
PASS: lldb-api :: commands/process/reverse-continue/TestReverseContinue.py (204 of 2243)
PASS: lldb-api :: commands/process/reverse-continue/TestReverseContinueCommandNotSupported.py (205 of 2243)
PASS: lldb-api :: commands/process/signal/TestProcessSignal.py (206 of 2243)
PASS: lldb-api :: commands/quit/TestQuit.py (207 of 2243)
PASS: lldb-api :: commands/register/register/TestRegistersUnavailable.py (208 of 2243)
UNSUPPORTED: lldb-api :: commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py (209 of 2243)
UNSUPPORTED: lldb-api :: commands/register/register/aarch64_mte_ctrl_register/TestMTECtrlRegister.py (210 of 2243)
FAIL: lldb-api :: commands/process/detach-resumes/TestDetachResumes.py (211 of 2243)
******************** TEST 'lldb-api :: commands/process/detach-resumes/TestDetachResumes.py' FAILED ********************
Script:
--
C:/Users/tcwg/scoop/apps/python/current/python.exe C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/llvm-project/lldb\test\API\dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib --env LLVM_INCLUDE_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/include --env LLVM_TOOLS_DIR=C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin --arch aarch64 --build-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex --lldb-module-cache-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-lldb\lldb-api --clang-module-cache-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/lldb-test-build.noindex/module-cache-clang\lldb-api --executable C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/lldb.exe --compiler C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/clang.exe --dsymutil C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin/dsymutil.exe --make C:/Users/tcwg/scoop/shims/make.exe --llvm-tools-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./bin --lldb-obj-root C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/tools/lldb --lldb-libs-dir C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/./lib --cmake-build-type Release --skip-category=watchpoint C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\commands\process\detach-resumes -p TestDetachResumes.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 567647888ea3dd292827bbac445d316d6a6b0ecb)
  clang revision 567647888ea3dd292827bbac445d316d6a6b0ecb
  llvm revision 567647888ea3dd292827bbac445d316d6a6b0ecb
Skipping the following test categories: ['watchpoint', 'libc++', 'libstdcxx', 'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']


--
Command Output (stderr):
--
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
ls: cannot access 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\lldb-test-build.noindex\commands\process\detach-resumes\TestDetachResumes.test_detach_resumes\exit_file_1750000626': No such file or directory
FAIL: LLDB (C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe-aarch64) :: test_detach_resumes (TestDetachResumes.DetachResumesTestCase.test_detach_resumes)

======================================================================

FAIL: test_detach_resumes (TestDetachResumes.DetachResumesTestCase.test_detach_resumes)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\commands\process\detach-resumes\TestDetachResumes.py", line 59, in test_detach_resumes

    lldbutil.wait_for_file_on_target(self, exit_file_path)


akuhlens pushed a commit to akuhlens/llvm-project that referenced this pull request Jun 24, 2025
…llvm#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants