[clang] [clang][bytecode] Allow constructor calls on extern RVO pointers (PR #195654)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 06:34:36 PDT 2026


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

Turns out 8b258206819d48ff6410ea99f3c63738318bd178 caused a regression in that it broke function calls with extern RVO pointers. However, that check in CheckInvoke() seems unneeded anyway, so remove it.

>From 6c07dc68c47b0cc2d1d03fe1921ce42edeecd030 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 4 May 2026 15:32:56 +0200
Subject: [PATCH] [clang][bytecode] Allow constructor calls on extern RVO
 pointers

Turns out 8b258206819d48ff6410ea99f3c63738318bd178 caused a regression
in that it broke function calls with extern RVO pointers. However, that
check in CheckInvoke() seems unneeded anyway, so remove it.
---
 clang/lib/AST/ByteCode/Interp.cpp   |  2 --
 clang/test/AST/ByteCode/records.cpp | 11 +++++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 0fa4021cae1f6..30b54f5dab236 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -904,8 +904,6 @@ static bool CheckInvoke(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
   if (!Ptr.isDummy() && !isConstexprUnknown(Ptr)) {
     if (!CheckLive(S, OpPC, Ptr, AK_MemberCall))
       return false;
-    if (!CheckExtern(S, OpPC, Ptr))
-      return false;
     if (!CheckRange(S, OpPC, Ptr, AK_MemberCall))
       return false;
     if (!IsCtorDtor && !CheckLifetime(S, OpPC, Ptr, AK_MemberCall))
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index 2b21f5f8ecf45..20ead8cffdd99 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -2000,3 +2000,14 @@ namespace EmptyRecords {
                                   // both-note {{in call}}
   constexpr int testc = f(e3, 3);
 }
+
+namespace RVOPtrIsExtern {
+  struct __ph {
+  } extern const _1;
+  constexpr void test(__ph) {}
+  constexpr bool test_all() {
+    test(_1);
+    return true;
+  }
+  static_assert(test_all(), "");
+}



More information about the cfe-commits mailing list