Disallow the operand of __builtin_constant_p from modifying enclosing
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 4 May 2019 04:00:45 +0000 (04:00 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 4 May 2019 04:00:45 +0000 (04:00 +0000)
commit37be3363b54b5bf30e3c76ab48c8206da45dcd0e
tree88a30faa6fe6250b9eca1ee6b035c853fb7eba3f
parent1e393064fa2732e721524f95a12348b0fd981167
Disallow the operand of __builtin_constant_p from modifying enclosing
state when it's encountered while evaluating a constexpr function.

We attempt to follow GCC trunk's behavior here, but it is somewhat
inscrutible, so our behavior is only approximately the same for now.
Specifically, we only permit modification of objects whose lifetime
began within the operand of the __builtin_constant_p. GCC appears to
have effectively the same restriction, but also some unknown restriction
based on where and how the local state of the constexpr function is
mentioned within the operand (see added testcases).

llvm-svn: 359958
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/builtin-constant-p.cpp