diff options
author | Richard Smith <richard@metafoo.co.uk> | 2020-02-06 16:19:37 -0800 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2020-02-06 16:37:22 -0800 |
commit | 96c899449b61b866b583560a49c4627f561336fc (patch) | |
tree | ea3692e14e45cc4798dd3de3be8009adf04b18ce /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | 3e5d837cdabca5a7f0e965fa454b169bdd45b06a (diff) | |
download | llvm-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.cpp | 14 |
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() && |