[clang-tools-extra] [libcxx] Allow string to use SSO in constant evaluation. (PR #66576)

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 15:26:51 PDT 2023


================
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Ensure that strings which fit within the SSO size can be constant-initialized
----------------
jyknight wrote:

We do expect that to work. It doesn't work on GCC because libstdc++'s std::string has a self-pointer, and a self-pointer is only constant for a global (or function-local static), not a local variable.

Added a test that covers the local var case.

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


More information about the cfe-commits mailing list