]> granicus.if.org Git - clang/commit
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)
commit54b0fb8af38294b3571b798ce0053f79bb6e0d27
tree6f8edd0b21c3c9e81043e2d505b66403ed71097f
parent9558f9dcee80e526443ab99aa0a399df4194f60b
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374119 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
lib/CodeGen/CodeGenModule.cpp
test/CodeGenCXX/no-const-init-cxx2a.cpp [new file with mode: 0644]