aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard@metafoo.co.uk>2020-02-06 16:19:37 -0800
committerRichard Smith <richard@metafoo.co.uk>2020-02-06 16:37:22 -0800
commit96c899449b61b866b583560a49c4627f561336fc (patch)
treeea3692e14e45cc4798dd3de3be8009adf04b18ce /clang/lib/CodeGen/CGExprConstant.cpp
parent3e5d837cdabca5a7f0e965fa454b169bdd45b06a (diff)
downloadllvm-96c899449b61b866b583560a49c4627f561336fc.zip
llvm-96c899449b61b866b583560a49c4627f561336fc.tar.gz
llvm-96c899449b61b866b583560a49c4627f561336fc.tar.bz2
C++ DR2026: static storage duration variables are not zeroed before
constant initialization. Removing this zeroing regressed our code generation in a few cases, also fixed here. We now compute whether a variable has constant destruction even if it doesn't have a constant initializer, by trying to destroy a default-initialized value, and skip emitting a trivial default constructor for a variable even if it has non-trivial (but perhaps constant) destruction.
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 46ed90a..aa9c8f9 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1269,19 +1269,7 @@ public:
if (!E->getConstructor()->isTrivial())
return nullptr;
- // FIXME: We should not have to call getBaseElementType here.
- const auto *RT =
- CGM.getContext().getBaseElementType(Ty)->castAs<RecordType>();
- const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
-
- // If the class doesn't have a trivial destructor, we can't emit it as a
- // constant expr.
- if (!RD->hasTrivialDestructor())
- return nullptr;
-
- // Only copy and default constructors can be trivial.
-
-
+ // Only default and copy/move constructors can be trivial.
if (E->getNumArgs()) {
assert(E->getNumArgs() == 1 && "trivial ctor with > 1 argument");
assert(E->getConstructor()->isCopyOrMoveConstructor() &&