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

via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 06:35:21 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

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.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (-2) 
- (modified) clang/test/AST/ByteCode/records.cpp (+11) 


``````````diff
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(), "");
+}

``````````

</details>


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


More information about the cfe-commits mailing list