[clang] [clang][ExprConst] Don't create useless temporary variable (PR #67716)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 28 10:40:39 PDT 2023


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/67716

We never use it anyway.

This code has been introduced in
410306bf6ed906af77978caa199e5d96376bae66, but it didn't really do anything back then either, as far as I can tell.

Fixes #57135

>From 9d2444645dfe72889a3e2be152992e708b2c2c42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 28 Sep 2023 19:31:09 +0200
Subject: [PATCH] [clang][ExprConst] Don't create useless temporary variable

We never use it anyway.

This code has been introduced in
410306bf6ed906af77978caa199e5d96376bae66, but it didn't really do
anything back then either, as far as I can tell.

Fixes #57135
---
 clang/lib/AST/ExprConstant.cpp | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fea06b97259fe31..04a751f1b4d09fb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10950,16 +10950,8 @@ bool ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(
 }
 
 bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
-  LValue CommonLV;
-  if (E->getCommonExpr() &&
-      !Evaluate(Info.CurrentCall->createTemporary(
-                    E->getCommonExpr(),
-                    getStorageType(Info.Ctx, E->getCommonExpr()),
-                    ScopeKind::FullExpression, CommonLV),
-                Info, E->getCommonExpr()->getSourceExpr()))
-    return false;
-
-  auto *CAT = cast<ConstantArrayType>(E->getType()->castAsArrayTypeUnsafe());
+  const auto *CAT =
+      cast<ConstantArrayType>(E->getType()->castAsArrayTypeUnsafe());
 
   uint64_t Elements = CAT->getSize().getZExtValue();
   Result = APValue(APValue::UninitArray(), Elements, Elements);



More information about the cfe-commits mailing list