summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constexpr-string.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Builtins] Treat `bcmp` as a builtin.Clement Courbet2019-02-141-0/+49
| | | | | | | | | | | | | | | | | Summary: This makes it consistent with `memcmp` and `__builtin_bcmp`. Also see the discussion in https://reviews.llvm.org/D56593. Reviewers: jyknight Subscribers: kristina, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58120 llvm-svn: 354023
* [ExprConstant] Improve memchr/memcmp for type mismatch and multibyte element ↵Hubert Tong2018-12-121-12/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | types Summary: `memchr` and `memcmp` operate upon the character units of the object representation; that is, the `size_t` parameter expresses the number of character units. The constant folding implementation is updated in this patch to account for multibyte element types in the arrays passed to `memchr`/`memcmp` and, in the case of `memcmp`, to account for the possibility that the arrays may have differing element types (even when they are byte-sized). Actual inspection of the object representation is not implemented. Comparisons are done only between elements with the same object size; that is, `memchr` will fail when inspecting at least one character unit of a multibyte element. The integer types are assumed to have two's complement representation with 0 for `false`, 1 for `true`, and no padding bits. `memcmp` on multibyte elements will only be able to fold in cases where enough elements are equal for the answer to be 0. Various tests are added to guard against incorrect folding for cases that miscompile on some system or other prior to this patch. At the same time, the unsigned 32-bit `wchar_t` testing in `test/SemaCXX/constexpr-string.cpp` is restored. Reviewers: rsmith, aaron.ballman, hfinkel Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55510 llvm-svn: 348938
* [constexpr] Fix ICE when memcpy() is given a pointer to an incomplete arrayPetr Pavlu2018-10-041-0/+37
| | | | | | | | | | Fix code for constant evaluation of __builtin_memcpy() and __builtin_memmove() that would attempt to divide by zero when given two pointers to an incomplete array. Differential Revision: https://reviews.llvm.org/D51855 llvm-svn: 343761
* Fix crash on call to __builtin_memcpy with a null pointer to anRichard Smith2018-09-131-0/+17
| | | | | | | | incomplete type. Also improve the diagnostics for similar situations. llvm-svn: 342192
* [constexpr] Support for constant evaluation of __builtin_memcpy andRichard Smith2018-08-041-6/+142
| | | | | | | | | | | | | | | | | | __builtin_memmove (in non-type-punning cases). This is intended to permit libc++ to make std::copy etc constexpr without sacrificing the optimization that uses memcpy on trivially-copyable types. __builtin_strcpy and __builtin_wcscpy are not handled by this change. They'd be straightforward to add, but we haven't encountered a need for them just yet. This reinstates r338455, reverted in r338602, with a fix to avoid trying to constant-evaluate a memcpy call if either pointer operand has an invalid designator. llvm-svn: 338941
* Revert r338455 "[constexpr] Support for constant evaluation of ↵Hans Wennborg2018-08-011-142/+6
| | | | | | | | | | | | | | | | __builtin_memcpy and __builtin_memmove (in non-type-punning cases)." It caused asserts during Chromium builds, see reply on the cfe-commits thread. > This is intended to permit libc++ to make std::copy etc constexpr > without sacrificing the optimization that uses memcpy on > trivially-copyable types. > > __builtin_strcpy and __builtin_wcscpy are not handled by this change. > They'd be straightforward to add, but we haven't encountered a need for > them just yet. llvm-svn: 338602
* [constexpr] Support for constant evaluation of __builtin_memcpy andRichard Smith2018-07-311-6/+142
| | | | | | | | | | | | | | __builtin_memmove (in non-type-punning cases). This is intended to permit libc++ to make std::copy etc constexpr without sacrificing the optimization that uses memcpy on trivially-copyable types. __builtin_strcpy and __builtin_wcscpy are not handled by this change. They'd be straightforward to add, but we haven't encountered a need for them just yet. llvm-svn: 338455
* [AST] Another attempt at fixing the ARM bots.Benjamin Kramer2018-04-241-3/+3
| | | | llvm-svn: 330690
* [AST] Use a bit of trickery to make test pass on platforms where wchar_t is ↵Benjamin Kramer2018-04-241-3/+5
| | | | | | unsigned. llvm-svn: 330689
* [AST] strcmp/memcmp always compares unsigned chars.Benjamin Kramer2018-04-231-0/+13
| | | | | | | This makes it return the right result in a couple of edge cases. The wide versions always do the comparison on the underlying wchar_t type. llvm-svn: 330656
* P0426: Make the library implementation of constexpr char_traits a little easierRichard Smith2017-01-201-0/+21
| | | | | | | | | by providing a memchr builtin that returns char* instead of void*. Also add a __has_feature flag to indicate the presence of constexpr forms of the relevant <string> functions. llvm-svn: 292555
* Support constant expression evaluation for wchar_t versions of simple stringRichard Smith2016-11-291-4/+99
| | | | | | functions, in order to support constexpr std::char_traits<wchar_t>. llvm-svn: 288193
* [c++1z] Support constant folding for __builtin_strchr and __builtin_memchr.Richard Smith2016-11-121-1/+39
| | | | llvm-svn: 286699
* [c++1z] Add constant-folding support for strcmp, strncmp, and memcmp, toRichard Smith2016-11-111-0/+68
support constexpr char_traits. llvm-svn: 286678
OpenPOWER on IntegriCloud