https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/208377

None

>From c21b83cf6bafb7db3ede0ab34ef0cdcb15caf1fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 9 Jul 2026 06:21:05 +0200
Subject: [PATCH] redecl2

---
 clang/lib/AST/ByteCode/Program.cpp            |  6 +++-
 clang/lib/AST/ByteCode/Program.h              |  2 +-
 .../test/AST/ByteCode/module-dummy-redecl.cpp | 33 +++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/AST/ByteCode/module-dummy-redecl.cpp

diff --git a/clang/lib/AST/ByteCode/Program.cpp 
b/clang/lib/AST/ByteCode/Program.cpp
index 1427724ec427c..d73011a8d8dc4 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -124,8 +124,12 @@ UnsignedOrNone Program::getOrCreateGlobal(const ValueDecl 
*VD,
   return std::nullopt;
 }
 
-unsigned Program::getOrCreateDummy(const DeclTy &D, bool IsConstexprUnknown) {
+unsigned Program::getOrCreateDummy(DeclTy D, bool IsConstexprUnknown) {
   assert(D);
+
+  if (const auto *VD = dyn_cast_if_present<VarDecl>(dyn_cast<const Decl *>(D)))
+    D = VD->getFirstDecl();
+
   // Dedup blocks since they are immutable and pointers cannot be compared.
   if (auto It = DummyVariables.find(D.getOpaqueValue());
       It != DummyVariables.end())
diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h
index c98c5c0e51a24..b0ef993258637 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -88,7 +88,7 @@ class Program final {
                                    const Expr *Init = nullptr);
 
   /// Returns or creates a dummy value for unknown declarations.
-  unsigned getOrCreateDummy(const DeclTy &D, bool IsConstexprUnknown = false);
+  unsigned getOrCreateDummy(DeclTy D, bool IsConstexprUnknown = false);
 
   /// Creates a global and returns its index.
   UnsignedOrNone createGlobal(const ValueDecl *VD, const Expr *Init,
diff --git a/clang/test/AST/ByteCode/module-dummy-redecl.cpp 
b/clang/test/AST/ByteCode/module-dummy-redecl.cpp
new file mode 100644
index 0000000000000..5519ac33c2a0a
--- /dev/null
+++ b/clang/test/AST/ByteCode/module-dummy-redecl.cpp
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t 
-fmodule-map-file=%t/module.modulemap %t/use.cpp -emit-llvm -o - -triple 
x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t 
-fmodule-map-file=%t/module.modulemap %t/use.cpp -emit-llvm -o - -triple 
x86_64-linux-gnu -fexperimental-new-constant-interpreter
+
+//--- module.modulemap
+module b { header "b.h" export * }
+module c { header "c.h" export * }
+
+//--- nonmodular.h
+template<typename T> int Z;
+
+//--- b.h
+#include "nonmodular.h"
+
+inline constexpr int *xP = &Z<decltype([] { static int n; return &n; }())>;
+
+//--- c.h
+#include "nonmodular.h"
+
+inline constexpr int *yP = &Z<decltype([] { static int n; return &n; }())>;
+
+
+//--- use.cpp
+#include "nonmodular.h"
+
+inline constexpr int *P = &Z<decltype([] { static int n; return &n; }())>;
+
+#include "b.h"
+#include "c.h"
+static_assert(xP == yP);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to