Skip to content

Conversation

@tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Jul 6, 2025

We need to ignore the lvalue path, just like we do for lvalue reference types.

We need to ignore the lvalue path, just like we do for lvalue reference
types.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Jul 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 6, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

We need to ignore the lvalue path, just like we do for lvalue reference types.


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

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Pointer.cpp (+1-1)
  • (added) clang/test/AST/ByteCode/libcxx/rvalue-reference-param.cpp (+122)
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp
index 0ad47645d39cc..08eec8172cd4e 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -207,7 +207,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const {
 
   bool UsePath = true;
   if (const ValueDecl *VD = getDeclDesc()->asValueDecl();
-      VD && VD->getType()->isLValueReferenceType())
+      VD && VD->getType()->isReferenceType())
     UsePath = false;
 
   // Build the path into the object.
diff --git a/clang/test/AST/ByteCode/libcxx/rvalue-reference-param.cpp b/clang/test/AST/ByteCode/libcxx/rvalue-reference-param.cpp
new file mode 100644
index 0000000000000..0e8127d27f888
--- /dev/null
+++ b/clang/test/AST/ByteCode/libcxx/rvalue-reference-param.cpp
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -std=c++2c -verify=expected,both %s -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2c -verify=ref,both      %s
+
+template <int __v> struct integral_constant {
+  static const int value = __v;
+};
+template <bool _Val> using _BoolConstant = integral_constant<_Val>;
+template <class _From, class _To>
+constexpr bool is_convertible_v = __is_convertible(_From, _To);
+template <class _Tp> _Tp __declval(int);
+template <class _Tp> decltype(__declval<_Tp>(0)) declval();
+template <class _Tp, class _Up>
+using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>;
+template <class _If> struct conditional {
+  using type = _If;
+};
+template <bool, class _IfRes, class>
+using conditional_t = conditional<_IfRes>::type;
+template <class _Tp, class>
+concept __weakly_equality_comparable_with = requires(_Tp __t) { __t; };
+template <bool, class _Tp = void> using __enable_if_t = _Tp;
+template <template <class> class, class>
+integral_constant<true> __sfinae_test_impl(int);
+template <template <class> class _Templ, class... _Args>
+using _IsValidExpansion = decltype(__sfinae_test_impl<_Templ, _Args...>(0));
+template <class _Tp>
+using __test_for_primary_template =
+    __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>;
+template <class _Tp>
+using __is_primary_template =
+    _IsValidExpansion<__test_for_primary_template, _Tp>;
+template <class _Ip>
+using iter_difference_t =
+    conditional_t<__is_primary_template<_Ip>::value, _Ip, _Ip>::difference_type;
+template <int> struct _OrImpl {
+  template <class, class _First>
+  using _Result = _OrImpl<!_First::value>::template _Result<_First>;
+};
+template <> struct _OrImpl<false> {
+  template <class _Res> using _Result = _Res;
+};
+template <class... _Args>
+using _Or = _OrImpl<sizeof...(_Args)>::template _Result<_Args...>;
+struct input_iterator_tag {};
+template <class _Dp, class _Bp>
+concept derived_from = is_convertible_v<_Dp, _Bp>;
+template <class _Ip>
+concept input_or_output_iterator = requires(_Ip __i) { __i; };
+template <class _Sp, class _Ip>
+concept sentinel_for = __weakly_equality_comparable_with<_Sp, _Ip>;
+struct __iter_concept_category_test {
+  template <class> using _Apply = input_iterator_tag;
+};
+struct __test_iter_concept
+    : _IsValidExpansion<__iter_concept_category_test::_Apply, int>,
+      __iter_concept_category_test {};
+struct __iter_concept_cache {
+  using type = _Or<int, __test_iter_concept>;
+};
+template <class _Iter>
+using _ITER_CONCEPT = __iter_concept_cache::type::_Apply<_Iter>;
+template <class _Ip>
+concept input_iterator = derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>;
+template <class _T1, class _T2> struct pair {
+  _T1 first;
+  _T2 second;
+};
+struct {
+  template <class _Tp> auto operator()(_Tp __t) { return __t.begin(); }
+} begin;
+template <class _Tp> using iterator_t = decltype(begin(declval<_Tp>()));
+template <class _Tp>
+concept __member_size = requires(_Tp __t) { __t; };
+struct {
+  template <__member_size _Tp> constexpr void operator()(_Tp &&__t) {
+    __t.size(); // both-note 2{{in instantiation}}
+  }
+} size;
+template <class _Tp>
+concept range = requires(_Tp __t) { __t; };
+template <class _Tp>
+concept input_range = input_iterator<_Tp>;
+template <range _Rp>
+using range_difference_t = iter_difference_t<iterator_t<_Rp>>;
+struct {
+  template <range _Rp> constexpr range_difference_t<_Rp> operator()(_Rp &&__r) {
+    size(__r); // both-note 2{{in instantiation}}
+  } // both-warning {{does not return a value}}
+} distance;
+template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
+struct subrange {
+  _Iter __begin_;
+  _Sent __end_;
+  _Iter begin();
+  constexpr _Iter size() { __end_ - __begin_; } // both-warning {{does not return a value}} \
+                                                // both-note {{in instantiation}}
+};
+struct {
+  template <input_range _Range1, input_range _Range2>
+  void operator()(_Range1 &&__range1, _Range2) {
+    (void)(distance(__range1) != 0); // both-note 3{{in instantiation}}
+  }
+} equal;
+template <class _Owner> struct __key_value_iterator {
+  using difference_type = _Owner::difference_type;
+  constexpr friend difference_type operator-(__key_value_iterator,
+                                             __key_value_iterator &) {} // both-warning {{does not return a value}}
+};
+struct flat_multimap {
+  template <bool> using __iterator = __key_value_iterator<flat_multimap>;
+  using difference_type =
+      decltype(static_cast<int *>(nullptr) - static_cast<int *>(nullptr));
+  pair<__iterator<true>, __iterator<true>> equal_range(const char *);
+} test_expected_range;
+void test() {
+  flat_multimap m;
+  auto test_found = [](auto map, auto expected_key, int) {
+    auto [first, last] = map.equal_range(expected_key);
+    equal(subrange(first, last), test_expected_range); // both-note 3{{in instantiation}}
+  };
+  test_found(m, "", {});
+}

@tbaederr tbaederr merged commit 1828381 into llvm:main Jul 6, 2025
13 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2025

LLVM Buildbot has detected a new failure on builder flang-arm64-windows-msvc running on linaro-armv8-windows-msvc-01 while building clang at step 7 "test-build-unified-tree-check-flang".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-flang) failure: test (failure)
******************** TEST 'Flang :: Semantics/OpenMP/loop-association.f90' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
"C:\Users\tcwg\scoop\apps\python\current\python.exe" C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Semantics\OpenMP/../test_errors.py C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Semantics\OpenMP\loop-association.f90 c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe -fopenmp
# executed command: 'C:\Users\tcwg\scoop\apps\python\current\python.exe' 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Semantics\OpenMP/../test_errors.py' 'C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\flang\test\Semantics\OpenMP\loop-association.f90' 'c:\users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe' -fopenmp
# .---command stdout------------
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
# | Stack dump:
# | 0.	Program arguments: C:\\Users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\build\\bin\\flang -fc1 -triple aarch64-pc-windows-msvc19.39.33523 -fsyntax-only -mrelocation-model pic -pic-level 2 -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon --dependent-lib=clang_rt.builtins-aarch64.lib -D_MT --dependent-lib=libcmt --dependent-lib=flang_rt.runtime.static.lib -D_MSC_VER=1939 -D_MSC_FULL_VER=193933523 -D_WIN32 -D_M_ARM64=1 -fopenmp -resource-dir C:\\Users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\build\\lib\\clang\\21 -mframe-pointer=none -x f95 C:\\Users\\tcwg\\llvm-worker\\flang-arm64-windows-msvc\\llvm-project\\flang\\test\\Semantics\\OpenMP\\loop-association.f90
# | Exception Code: 0xC0000005
# |  #0 0x00007ff6c5f22c34 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a92c34)
# |  #1 0x00007ff6c5f2091c (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a9091c)
# |  #2 0x00007ff6c5f22150 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a92150)
# |  #3 0x00007ff6c5f21858 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a91858)
# |  #4 0x00007ff6c5f20db8 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a90db8)
# |  #5 0x00007ff6c5f24734 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a94734)
# |  #6 0x00007ff6c5f1e318 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x1a8e318)
# |  #7 0x00007ff6c4d3c840 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8ac840)
# |  #8 0x00007ff6c4d85ca0 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f5ca0)
# |  #9 0x00007ff6c4e2eb5c (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x99eb5c)
# | #10 0x00007ff6c4d850dc (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x8f50dc)
# | #11 0x00007ff6c4528ac8 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x98ac8)
# | #12 0x00007ff6c453ea90 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0xaea90)
# | #13 0x00007ff6c44934e8 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x34e8)
# | #14 0x00007ff6c44920a4 (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x20a4)
# | #15 0x00007ff6c9151648 mlir::detail::FallbackTypeIDResolver::registerImplicitTypeID(class llvm::StringRef) (C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin\flang.exe+0x4cc1648)
# | #16 0x1d627ff6c91516e4
# | flang: error: flang frontend command failed due to signal (use -v to see invocation)
# | flang version 21.0.0git (https://github.com/llvm/llvm-project.git 1828381ed2591fe9cdc080c70f44ed7309be4df6)
# | Target: aarch64-pc-windows-msvc
# | Thread model: posix
# | InstalledDir: C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\bin
# | Build config: +assertions
# | flang: note: diagnostic msg: 
# | ********************
# | 
# | PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
# | Preprocessed source(s) and associated run script(s) are located at:
# | flang: note: diagnostic msg: C:\Users\tcwg\AppData\Local\Temp\lit-tmp-4hik845n\loop-association-4895e6
# | flang: note: diagnostic msg: C:\Users\tcwg\AppData\Local\Temp\lit-tmp-4hik845n\loop-association-4895e6.sh
# | flang: note: diagnostic msg: 
# | 
# | ********************
# | 
# `-----------------------------
# error: command failed with exit status: 1

...

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.

3 participants