[clang] a96ad13 - [clang][bytecode] Dummy variables can have pointers to them (#166908)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 7 01:51:21 PST 2025
Author: Timm Baeder
Date: 2025-11-07T10:51:17+01:00
New Revision: a96ad136f6f6116a369337c52d0e86f94c548e8c
URL: https://github.com/llvm/llvm-project/commit/a96ad136f6f6116a369337c52d0e86f94c548e8c
DIFF: https://github.com/llvm/llvm-project/commit/a96ad136f6f6116a369337c52d0e86f94c548e8c.diff
LOG: [clang][bytecode] Dummy variables can have pointers to them (#166908)
at the point when they become proper globals.
Added:
Modified:
clang/lib/AST/ByteCode/Program.cpp
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 4d34e0b0a9b46..c468303efea7e 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -197,7 +197,8 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
// global variable and points to the block we just created.
if (auto DummyIt = DummyVariables.find(Redecl);
DummyIt != DummyVariables.end()) {
- assert(!Globals[DummyIt->second]->block()->hasPointers());
+ Global *Dummy = Globals[DummyIt->second];
+ Dummy->block()->movePointersTo(NewGlobal->block());
Globals[DummyIt->second] = NewGlobal;
DummyVariables.erase(DummyIt);
}
diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index 331fe8387e1c7..ff104243a9735 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
consteval int id(int i) { return i; }
constexpr char id(char c) { return c; }
More information about the cfe-commits
mailing list