aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorMariya Podchishchaeva <mariya.podchishchaeva@intel.com>2023-03-07 10:57:23 -0500
committerMariya Podchishchaeva <mariya.podchishchaeva@intel.com>2023-03-07 10:57:35 -0500
commitaf682f0df83f3364dac7ab92f39c7209dfbce28a (patch)
tree0dc0e001e1e1ea783397e7f9ab8417c8da17eb3d /clang/lib/AST/ExprConstant.cpp
parent905a7577c5845c0ad40f8a98f704cc3747e0e4fa (diff)
downloadllvm-af682f0df83f3364dac7ab92f39c7209dfbce28a.zip
llvm-af682f0df83f3364dac7ab92f39c7209dfbce28a.tar.gz
llvm-af682f0df83f3364dac7ab92f39c7209dfbce28a.tar.bz2
[clang] Fix single-element array initialization in constexpr
https://reviews.llvm.org/D130791 added an improvement that in case array element has a trivial constructor, it is evaluated once and the result is re-used for remaining elements. Make sure the constructor is evaluated for single-elements arrays too. Fixes https://github.com/llvm/llvm-project/issues/60803 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D145486
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6b0beb1..26c2342 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10917,7 +10917,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
for (unsigned I = OldElts; I < N; ++I)
Value->getArrayInitializedElt(I) = Filler;
- if (HasTrivialConstructor && N == FinalSize) {
+ if (HasTrivialConstructor && N == FinalSize && FinalSize != 1) {
// If we have a trivial constructor, only evaluate it once and copy
// the result into all the array elements.
APValue &FirstResult = Value->getArrayInitializedElt(0);