]> granicus.if.org Git - clang/commit
[constexpr] Support for constant evaluation of __builtin_memcpy and
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 4 Aug 2018 00:57:17 +0000 (00:57 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 4 Aug 2018 00:57:17 +0000 (00:57 +0000)
commit44c07c3132f4dc88a86ee10030dabc74ae34171d
tree69137e03110361e2d7453ec92fb4e564f44caee5
parentb319a856c2fb1c61915ab0185fa0e416a3910182
[constexpr] Support for constant evaluation of __builtin_memcpy and
__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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338941 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/Builtins.def
include/clang/Basic/DiagnosticASTKinds.td
lib/AST/ExprConstant.cpp
test/CodeGen/builtin-memfns.c
test/SemaCXX/constexpr-string.cpp