Fix crash or wrong code bug if a lifetime-extended temporary contains a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Oct 2019 21:26:03 +0000 (21:26 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 8 Oct 2019 21:26:03 +0000 (21:26 +0000)
commit48632af25cfbe05c8e29307a397d60c9998e6231
treeb2e0316e42b77bd1a8c3a856015e2fecb9eaf36a
parentf61f13d4e7e08b44629a1411ace53c5c6aeaf32b
Fix crash or wrong code bug if a lifetime-extended temporary contains a
"non-constant" value.

If the constant evaluator evaluates part of a variable initializer,
including the initializer for some lifetime-extended temporary, but
fails to fully evaluate the initializer, it can leave behind wrong
values for temporaries encountered in that initialization. Don't try to
emit those from CodeGen! Instead, look at the values that constant
evaluation produced if (and only if) it actually succeeds and we're
emitting the lifetime-extending declaration's initializer as a constant.

llvm-svn: 374119
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/no-const-init-cxx2a.cpp [new file with mode: 0644]